]> jspc29.x-matter.uni-frankfurt.de Git - mvd_epics.git/commitdiff
DASH: precision rounding / unit replacement / switch
authorOle Artz <ole.artz@t-online.de>
Mon, 14 Aug 2017 12:34:05 +0000 (14:34 +0200)
committerOle Artz <ole.artz@t-online.de>
Mon, 14 Aug 2017 12:34:05 +0000 (14:34 +0200)
python_suite/dashboard/dashboard.py
python_suite/dashboard/static/css/style.css
python_suite/dashboard/views/pv_overview.jinja2

index 5c3b2427343c9ce245d32527ed5c12ce7816e31f..6eea4933c62847895f27f7a0e7b07764bcdb1175 100755 (executable)
@@ -39,6 +39,7 @@ def cb_connection_change(**kwargs):
             pv['value'] = '- disconnected -'
             pv['unit'] = ''
             pv['classes'] = 'disconnected'
+            pv['precision'] = None
 
 
 def cb_value_update(**kwargs):
@@ -64,11 +65,15 @@ def cb_value_update(**kwargs):
                      pv['value'] = kwargs['char_value']
             else:
                 pv['value'] = kwargs['value']
+            pv['precision'] = kwargs['precision']
+            #if type(kwargs['precision']) == int and ('double' in kwargs['type'] or 'float' in kwargs['type']):
+            #    pv['value'] = round(pv['value'], kwargs['precision'])
+            if kwargs['enum_strs'] == (b'OFF', b'ON'):
+                pv['classes'] += ' switch'
             if pv['value'] is None: pv['value'] = '- disconnected -'
             pv['unit'] = kwargs['units'] or ''
-            if pv['value'] == 'OFF': pv['value'] = '- OFF -'
-            if pv['value'] == 'ON': pv['value'] = '- ON -'
-
+            if pv['unit'] == 'deg C': pv['unit'] = '&degC'
+            if pv['unit'] == 'g/m3': pv['unit'] = 'g/m&sup3'
 @route('/')
 @view('pv_overview.jinja2')
 def index():
@@ -109,6 +114,7 @@ def main():
         for pv in group['PVs']:
             pv['value'] = '- disconnected (initial) -'
             pv['unit'] = ''
+            pv['precision'] = None
             pv['classes'] = 'disconnected'
             PVS[pv['name']] = epics.PV(pv['name'], auto_monitor=True, form='ctrl', callback=cb_value_update, connection_callback=cb_connection_change)
 
index 78969f5fce82fe103aa7e00095a0036abe2c5cee..d347cdc8243d9969b1b6a5d3652065792b13f9f5 100644 (file)
   text-align: center;
 }
 
-.Cooling table, th, td {
+table, th, td {
   border: 1px solid black;
 }
 
-.Cooling table, th {
+table, th {
   text-align: left;
 }
 
+/* ALARMS */
 .invalid_alarm:after {
   content: "- invalid -";
   position: relative;
   border: 3px solid #EBFF00;
 }
 
+/* TOGGLE ON/OFF */
+.toggle {
+  overflow: hidden;
+  display: inline-block;
+  width: 8em;
+  padding: 0.125em;
+  }
+  .toggle input {
+    position: absolute;
+    visibility: hidden;
+    }
+  .toggle span {
+    position: relative;
+    left: 0%;
+    display: block;
+    text-transform: uppercase;
+    text-align: center;
+    
+    -webkit-transition: left 200ms ease-out;
+       -moz-transition: left 200ms ease-out;
+         -o-transition: left 200ms ease-out;
+            transition: left 200ms ease-out;
+    }
+    .toggle :checked + span {
+      left: 50%;
+      }
+
+  .toggle span:before {
+    content: attr(data-unchecked);
+    display: block;
+    width: 50%;
+    background-color: #525252;
+    border-radius: 0.15em;
+    box-shadow: inset 0 0.1em 0 rgba(255, 255, 255, 0.3);
+    color: white;
+    }
+
+  .toggle :checked + span:before {
+    content: attr(data-checked);
+    background-color: #0099CC;
+    }
index 56b4ded5bb36215c9b03eefa423636db5aa98d62..85be53e84f98796f768a38ef51bdc71d4bd26d5d 100644 (file)
                                                {% for PV in group.PVs %}
                                                <tr>
                                                        <td>{{ PV.name }}</td>
-                                                       <td class="{{ PV.classes }}">{{ PV.value }}</td>
+                                                       <td class="{{ PV.classes }}">
+                                                               {% if 'switch' in PV.classes %}
+                                                                       <label class="toggle">
+                                                                               <input type="checkbox" disabled readonly {{ 'checked' if 'ON' in PV.value else '' }}>
+                                                                               <span data-unchecked="OFF" data-checked="ON"></span>
+                                                                       </label>
+                                                               {% else %}
+                                                                       {% if PV.precision is number %}
+                                                                               {{ PV.value|round(PV.precision) }}
+                                                                       {% else %}
+                                                                               {{ PV.value }}
+                                                                       {% endif %}
+                                                               {% endif %}
+                                                       </td>
                                                        <td>{{ PV.unit }}</td>
                                                </tr>
                                                {% endfor %}