Pārlūkot izejas kodu

added ventil and mode elements.

https://github.com/kit-ipe/bora/issues/2

Signed-off-by: nicolaisi <nicholas.jerome@kit.edu>
nicolaisi 8 gadi atpakaļ
vecāks
revīzija
10eb398265
6 mainītis faili ar 88 papildinājumiem un 40 dzēšanām
  1. 5 4
      cache.yaml
  2. 5 2
      core.py
  3. 53 19
      designer.html
  4. 13 2
      status.html
  5. 11 13
      style.yaml
  6. 1 0
      varname.yaml

+ 5 - 4
cache.yaml

@@ -1,4 +1,5 @@
-320-RTP-3-1101: '115.8197860717773'
-320-RTY-3-2101: '120.6334609985352'
-320-RTY-3-3101: '116.0701599121094'
-411-REI-1-1110-0030: '0.0'
+320-MOD-0-0001: '2'
+320-RTP-3-1101: '79.79348754882812'
+320-RTY-3-2101: '113.3070297241211'
+320-RTY-3-3101: '112.0582504272461'
+411-REI-1-1110-0030: '0'

+ 5 - 2
core.py

@@ -100,7 +100,7 @@ def fetchDataADEI():
             print last_value
             test_x = float(last_value)
         except ValueError:
-            last_value = None
+            last_value = ""
  	print last_value
         cache_data[param] = last_value
 
@@ -276,7 +276,10 @@ class AdeiKatrinHandler(tornado.web.RequestHandler):
         print cr, len(cr)
         
         # parameter name stored in ADEI with '-IST_Val' suffix
-        match_token = params['sensor_name'] + "-IST_Val"
+        if "MOD" in params['sensor_name']:
+	    match_token = params['sensor_name'] + "-MODUS_Val"
+    	else:
+	    match_token = params['sensor_name'] + "-IST_Val"
         db_mask = None
         for i, item in enumerate(cr):
             if "[" and "]" in item.strip():

+ 53 - 19
designer.html

@@ -36,6 +36,12 @@
 {% else %}
 {% end %}
 
+{% if data['style'][key]['type'] == "integer-to-string" %}
+<div style='position: absolute; top: {{ data['style'][key]['top'] }}; left:{{ data['style'][key]['left'] }}; width:{{ data['style'][key]['width'] }}px; height:{{ data['style'][key]['height'] }}px;' data-dict="{{ data['style'][key]['dict'] }}" data-type="{{ data['style'][key]['type'] }}" class='varbox' id="{{ key }}">
+<p><span style="color: #000; font-size: {{ data['style'][key]['header']['size'] }}; font-weight: {{ data['style'][key]['header']['weight'] }};" class="title">{{ data['style'][key]['header']['title'] }} </span><br /><span style="color: #000; font-size: {{ data['style'][key]['unit']['size'] }}; font-weight: {{ data['style'][key]['unit']['weight'] }};" class="varval">??? </span></p>
+</div>
+{% else %}
+{% end %}
 
 
 {% end %}
@@ -155,17 +161,9 @@ function add() {
                     "<span class='unit_title'>" + unit_text + "</span></p>" +
         	    "</div>";
         } else if (vartype == "ventil") {
-            var token = unit_text.split(";");
-            var lhs = token[0];
-            var rhs = token[1];
-            var data_on, data_off;
-            if (lhs.split(":")[0] == "on") {
-                data_on = lhs.split(":")[1];
-                data_off = rhs.split(":")[1];
-            } else {
-                data_off = lhs.split(":")[1];
-                data_on = rhs.split(":")[1];
-            }
+            var token = JSON.parse(unit_text);
+            data_on = token["on"];
+            data_off = token["off"];
 
             html_text = "<div " +
                     "style='position: absolute; " +
@@ -183,6 +181,29 @@ function add() {
  		    "<img width='100%' height='100%' " + 
                     "src='{{ static_url("ventil_inactive.png") }}'></img>" +
         	    "</div>";	    
+	} else if (vartype == "integer-to-string") {
+            console.log("Inside I2S");
+            html_text = "<div " +
+                    "style='position: absolute; " +
+                           "top:0; " +
+                           "left:0;' " +
+                    "class='varbox' " + 
+                    "id='" + varname +
+                    "' data-type='" + vartype +
+                    "' data-dict='" + unit_text +
+                    "'>" +
+                    "<p>" +
+                    "<span style='color: " + title_color + ";" + 
+                    "font-size:" + title_size + "px; " + 
+                    "font-weight: " + title_style + ";' " + 
+                    "class='title'>" + title_text +
+                    " </span><br />" + 
+                    "<span style='color: " + unit_color + "; " + 
+                           "font-size:" + unit_size + "px; " +
+                           "font-weight: " + unit_style + ";' " + 
+                    "class='varval'>Standard Operation </span>" + 
+                    "</p>" +
+        	    "</div>";
 	}
         $( "body" ).append(html_text);
         $("#"+varname).draggable();
@@ -210,17 +231,14 @@ function mysave(data) {
             tmp["top"] = $("#"+key).css("top");
             tmp["width"] = $("#"+key).width();
             tmp["height"] = $("#"+key).height();
-            //tmp["type"] = $("#vartype option:selected").val();
-            //tmp["min"] = $("#elem_min_range").val();
-            //tmp["max"] = $("#elem_max_range").val();
-            tmp["min"] = $("#"+key).attr("min");
-            tmp["max"] = $("#"+key).attr("max");
             tmp["type"] = $("#"+key).attr("data-type");
 
             if ( $("#"+key).attr("data-type") == "data" ) {
             	tmp["condition"] = $("#"+key).attr("data-cond");
             	tmp["lesser"] = $("#"+key).attr("data-lesser");
             	tmp["larger"] = $("#"+key).attr("data-larger");
+            	tmp["min"] = $("#"+key).attr("min");
+           	tmp["max"] = $("#"+key).attr("max");
             
             	header = {};
             	header["title"] = $(".title", "#"+key).text();
@@ -237,17 +255,33 @@ function mysave(data) {
             	tmp["header"] = header;
             	tmp["unit"] = unit;
             } else if ( $("#"+key).attr("data-type") == "ventil" ) {
-		//console.log("Ventil !!");
-            	//console.log($(".unit_title", "#"+key).text());
             	tmp["on"] = $("#"+key).attr("data-on");
             	tmp["off"] = $("#"+key).attr("data-off");
+            } else if ( $("#"+key).attr("data-type") == "integer-to-string" ) {
+            	tmp["dict"] = $("#"+key).attr("data-dict");
+            	header = {};
+            	header["title"] = $(".title", "#"+key).text();
+            	//header["color"] = $(".title", "#"+key).css("color");
+            	header["size"] = $(".title", "#"+key).css("font-size");
+            	header["weight"] = $(".title", "#"+key).css("font-weight");
+            
+            	unit = {};
+            	unit["title"] = $(".unit_title", "#"+key).text();
+            	//unit["color"] = $(".varval", "#"+key).css("color");
+            	unit["size"] = $(".varval", "#"+key).css("font-size");
+            	unit["weight"] = $(".varval", "#"+key).css("font-weight");
+
+            	tmp["header"] = header;
+            	tmp["unit"] = unit;
             }
 
             position[key] = tmp;
         }
     }
-    console.log(position);
+    //console.log("Check here");
+    //console.log(position);
     var dataToSend = JSON.stringify(position);
+    console.log(dataToSend);
     $.ajax({
         url: '/save/',
         type: 'POST',

+ 13 - 2
status.html

@@ -40,6 +40,13 @@ data-type="{{ data['style'][key]['type'] }}" data-lesser="{{ data['style'][key][
 {% else %}
 {% end %}
 
+{% if data['style'][key]['type'] == "integer-to-string" %}
+<div style='position: absolute; top: {{ data['style'][key]['top'] }}; left:{{ data['style'][key]['left'] }}; width:{{ data['style'][key]['width'] }}px; height:{{ data['style'][key]['height'] }}px;' data-dict="{{ data['style'][key]['dict'] }}" data-type="{{ data['style'][key]['type'] }}" class='databox' id="{{ key }}">
+<p><span style="color: #000; font-size: {{ data['style'][key]['header']['size'] }}; font-weight: {{ data['style'][key]['header']['weight'] }};" class="title">{{ data['style'][key]['header']['title'] }} </span><br /><span style="color: #000; font-size: {{ data['style'][key]['unit']['size'] }}; font-weight: {{ data['style'][key]['unit']['weight'] }};" class="varval">??? </span></p>
+</div>
+{% else %}
+{% end %}
+
 
 {% end %}
 {% else %}
@@ -99,7 +106,6 @@ function myTimer() {
 		    $(".unit_title", "#" + key).css("color", set_color);
                     
 		    } else if (data_type == "ventil") {
-			console.log("The VENTIL way");
                         var on_attr = $("#" + key).attr('data-on');
                         var off_attr = $("#" + key).attr('data-off');
  			if (parseFloat(response[key]) == parseFloat(on_attr)) {
@@ -108,7 +114,12 @@ function myTimer() {
  			if (parseFloat(response[key]) == parseFloat(off_attr)) {
  			    $("img", "#" + key).attr("src", "{{ static_url('ventil_inactive.png') }}");
       			}
-
+		    } else if (data_type == "integer-to-string") {
+                        var dict_attr = JSON.parse($("#" + key).attr('data-dict'));
+                        console.log("CHECK");
+			console.log(response[key]);
+			console.log(dict_attr);
+                        $(".varval", "#" + key).text(dict_attr[response[key]]);
 		    }
 		}
             }

+ 11 - 13
style.yaml

@@ -1,25 +1,23 @@
-320-RTP-3-1101:
-  condition: ''
+320-MOD-0-0001:
+  dict: '{"0": "zero mode", "2": "two mode"}'
   header:
     size: 28px
-    title: '        '
+    title: 'Operation Mode '
     weight: '400'
-  height: 82.991
-  larger: '70'
-  left: 1145.98px
-  lesser: '0'
-  top: 423px
-  type: data
+  height: 131.99099999999999
+  left: 170px
+  top: 71px
+  type: integer-to-string
   unit:
     size: 28px
-    title: '       K'
+    title: ''
     weight: '400'
-  width: 139.99099999999999
+  width: 301.991
 411-REI-1-1110-0030:
   height: 50.991
-  left: 802px
+  left: 778px
   'off': '1'
   'on': '0'
-  top: 275px
+  top: 283px
   type: ventil
   width: 49.991

+ 1 - 0
varname.yaml

@@ -1,3 +1,4 @@
+320-MOD-0-0001: db_server=cscps&db_name=ControlSystem_CPS&db_group=320_SYS&db_mask=all&window=-1&db_mask=0
 320-RTP-3-1101: db_server=cscps&db_name=ControlSystem_CPS&db_group=320_STR_Strahlrohr&db_mask=all&window=-1&db_mask=180
 320-RTY-3-2101: db_server=cscps&db_name=ControlSystem_CPS&db_group=320_STR_Strahlrohr&db_mask=all&window=-1&db_mask=213
 320-RTY-3-3101: db_server=cscps&db_name=ControlSystem_CPS&db_group=320_STR_Strahlrohr&db_mask=all&window=-1&db_mask=222