]> Pileus Git - ~andy/csm213a-hw/commitdiff
Update from Yue, and add rate column
authorAndy Spencer <andy753421@gmail.com>
Wed, 12 Feb 2014 20:22:53 +0000 (20:22 +0000)
committerAndy Spencer <andy753421@gmail.com>
Wed, 12 Feb 2014 20:22:53 +0000 (20:22 +0000)
vis/device.py
vis/visual.py
vis/visual.ui

index 7d47d77c0b006019fe44ec9775edbfbab201d379..d1f96e4d59448167f6fb42daed79d95bdcc9b902 100644 (file)
@@ -79,6 +79,12 @@ class Frame:
                    TYP_U8:  'B', TYP_U16: 'H', TYP_U32: 'I',
                    TYP_F32: 'f', TYP_F64: 'd'}
 
                    TYP_U8:  'B', TYP_U16: 'H', TYP_U32: 'I',
                    TYP_F32: 'f', TYP_F64: 'd'}
 
+        sampleNum= {SNS_ACC:   0,
+                   SNS_MAG:   0,
+                   SNS_LGT:   0,
+                   SNS_TCH:   0,
+                   SNS_A2D:   0}
+
        # Parser data
        index    = 0   # read index
        count    = 0   # number of items in frame
        # Parser data
        index    = 0   # read index
        count    = 0   # number of items in frame
@@ -87,7 +93,6 @@ class Frame:
        bits_typ = 0   # data type
        binary   = ""  # binary read-in
        values   = []  # converted numeric data
        bits_typ = 0   # data type
        binary   = ""  # binary read-in
        values   = []  # converted numeric data
-       total    = 0   # total states read so far
 
        # Constructor
        def __init__(self):
 
        # Constructor
        def __init__(self):
@@ -154,12 +159,13 @@ class Frame:
                fmt = Frame.fmtMap[self.bits_typ] * self.count
                sns = Frame.snsMap[self.bits_sns]
                self.values = unpack('<'+fmt, self.binary)
                fmt = Frame.fmtMap[self.bits_typ] * self.count
                sns = Frame.snsMap[self.bits_sns]
                self.values = unpack('<'+fmt, self.binary)
-               #print('convert: %3s = \'%3s\'%%[%s] -> [%s]' %
-               #       (sns, fmt, hexDump(self.binary), fltDump(self.values)))
 
 
-               if self.total % 100 == 0:
-                       print('read %d samples' % self.total);
-               self.total += 1;
+               # Print debug output
+                self.sampleNum[self.bits_sns] += 1
+               if self.sampleNum[self.bits_sns] == 1000:
+                        print('convert: %3s = \'%3s\'%%[%s] -> [%s]' %
+                              (sns, fmt, hexDump(self.binary), fltDump(self.values)))
+                        self.sampleNum[self.bits_sns] = 0
 
                # Create state
                state = State()
 
                # Create state
                state = State()
index 4f0e0e0019cbc3ef859e9cf0c87a04255b3074a0..2ad6db69324ab31f6ea82686d9089a9592f31b19 100644 (file)
@@ -37,6 +37,7 @@ class Visual:
                self.lgts     = get_objects(['lgt'])
                self.tchs     = get_objects(['tchp', 'tchd'])
                self.a2ds     = get_objects(['a2d0', 'a2d1', 'a2d2', 'a2d3', 'a2d4', 'a2d5'])
                self.lgts     = get_objects(['lgt'])
                self.tchs     = get_objects(['tchp', 'tchd'])
                self.a2ds     = get_objects(['a2d0', 'a2d1', 'a2d2', 'a2d3', 'a2d4', 'a2d5'])
+               self.smpl     = get_objects(['sampling'])
 
        # Signal handlers
        def on_hide(self, win, *args):
 
        # Signal handlers
        def on_hide(self, win, *args):
@@ -158,6 +159,7 @@ class Visual:
                setval(self.lgts,  state.lgt, [])
                setval(self.tchs,  state.tch, ['P', 'D'])
                setval(self.a2ds,  state.a2d, [])
                setval(self.lgts,  state.lgt, [])
                setval(self.tchs,  state.tch, ['P', 'D'])
                setval(self.a2ds,  state.a2d, [])
+               #setval(self.smpl,  state.)
 
                self.history = self.history[1:] + [state.a2d[0]]
                self.window.queue_draw()
 
                self.history = self.history[1:] + [state.a2d[0]]
                self.window.queue_draw()
index 497302180ec1394459b150fde08cf14764626a85..9ec396d668b7cb03125555503632d05a751d5f65 100644 (file)
@@ -2,6 +2,21 @@
 <interface>
   <requires lib="gtk+" version="2.24"/>
   <!-- interface-naming-policy project-wide -->
 <interface>
   <requires lib="gtk+" version="2.24"/>
   <!-- interface-naming-policy project-wide -->
+  <object class="GtkToggleAction" id="serial_act">
+    <property name="label" translatable="yes">Serial</property>
+    <property name="stock_id">gtk-connect</property>
+    <signal name="activate" handler="on_serial" swapped="no"/>
+  </object>
+  <object class="GtkAction" id="settings_act">
+    <property name="label" translatable="yes">Settings</property>
+    <property name="stock_id">gtk-preferences</property>
+    <signal name="activate" handler="on_show" swapped="no"/>
+  </object>
+  <object class="GtkToggleAction" id="xively_act">
+    <property name="label" translatable="yes">Xively</property>
+    <property name="stock_id">gtk-connect</property>
+    <signal name="activate" handler="on_xively" swapped="no"/>
+  </object>
   <object class="GtkAdjustment" id="a2d_adj">
     <property name="upper">100</property>
     <property name="value">1</property>
   <object class="GtkAdjustment" id="a2d_adj">
     <property name="upper">100</property>
     <property name="value">1</property>
     <property name="step_increment">1</property>
     <property name="page_increment">10</property>
   </object>
     <property name="step_increment">1</property>
     <property name="page_increment">10</property>
   </object>
-  <object class="GtkToggleAction" id="serial_act">
-    <property name="label" translatable="yes">Serial</property>
-    <property name="stock_id">gtk-connect</property>
-    <signal name="activate" handler="on_serial" swapped="no"/>
-  </object>
   <object class="GtkTextBuffer" id="serial_buf"/>
   <object class="GtkTextBuffer" id="serial_buf"/>
-  <object class="GtkAction" id="settings_act">
-    <property name="label" translatable="yes">Settings</property>
-    <property name="stock_id">gtk-preferences</property>
-    <signal name="activate" handler="on_show" swapped="no"/>
-  </object>
-  <object class="GtkToggleAction" id="xively_act">
-    <property name="label" translatable="yes">Xively</property>
-    <property name="stock_id">gtk-connect</property>
-    <signal name="activate" handler="on_xively" swapped="no"/>
-  </object>
   <object class="GtkDialog" id="settings">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>
   <object class="GtkDialog" id="settings">
     <property name="can_focus">False</property>
     <property name="border_width">5</property>
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
+            <property name="pack_type">end</property>
             <property name="position">0</property>
           </packing>
         </child>
             <property name="position">0</property>
           </packing>
         </child>
     <property name="page_increment">10</property>
   </object>
   <object class="GtkWindow" id="window">
     <property name="page_increment">10</property>
   </object>
   <object class="GtkWindow" id="window">
+    <property name="width_request">500</property>
+    <property name="height_request">400</property>
     <property name="can_focus">False</property>
     <signal name="destroy" handler="on_destroy" swapped="no"/>
     <signal name="key-press-event" handler="on_key" swapped="no"/>
     <child>
       <object class="GtkVBox" id="vbox">
     <property name="can_focus">False</property>
     <signal name="destroy" handler="on_destroy" swapped="no"/>
     <signal name="key-press-event" handler="on_key" swapped="no"/>
     <child>
       <object class="GtkVBox" id="vbox">
+        <property name="width_request">400</property>
+        <property name="height_request">400</property>
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <child>
         <property name="visible">True</property>
         <property name="can_focus">False</property>
         <child>
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="n_rows">6</property>
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
                 <property name="n_rows">6</property>
-                <property name="n_columns">2</property>
+                <property name="n_columns">3</property>
                 <property name="column_spacing">20</property>
                 <property name="row_spacing">5</property>
                 <child>
                   <object class="GtkLabel" id="data_sensor">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                 <property name="column_spacing">20</property>
                 <property name="row_spacing">5</property>
                 <child>
                   <object class="GtkLabel" id="data_sensor">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
                     <property name="label" translatable="yes">Sensor</property>
                     <attributes>
                       <attribute name="weight" value="bold"/>
                     <property name="label" translatable="yes">Sensor</property>
                     <attributes>
                       <attribute name="weight" value="bold"/>
                   <object class="GtkLabel" id="data_value">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
                   <object class="GtkLabel" id="data_value">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
                     <property name="label" translatable="yes">Current Value</property>
                     <attributes>
                       <attribute name="weight" value="bold"/>
                     </attributes>
                   </object>
                   <packing>
                     <property name="label" translatable="yes">Current Value</property>
                     <attributes>
                       <attribute name="weight" value="bold"/>
                     </attributes>
                   </object>
                   <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
                     <property name="y_options">GTK_FILL</property>
                   </packing>
                 </child>
                     <property name="y_options">GTK_FILL</property>
                   </packing>
                 </child>
                     </child>
                   </object>
                   <packing>
                     </child>
                   </object>
                   <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
                     <property name="top_attach">1</property>
                     <property name="bottom_attach">2</property>
                     <property name="y_options">GTK_FILL</property>
                     <property name="top_attach">1</property>
                     <property name="bottom_attach">2</property>
                     <property name="y_options">GTK_FILL</property>
                     </child>
                   </object>
                   <packing>
                     </child>
                   </object>
                   <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
                     <property name="top_attach">2</property>
                     <property name="bottom_attach">3</property>
                     <property name="y_options">GTK_FILL</property>
                     <property name="top_attach">2</property>
                     <property name="bottom_attach">3</property>
                     <property name="y_options">GTK_FILL</property>
                     </child>
                   </object>
                   <packing>
                     </child>
                   </object>
                   <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
                     <property name="top_attach">5</property>
                     <property name="bottom_attach">6</property>
                     <property name="y_options">GTK_FILL</property>
                     <property name="top_attach">5</property>
                     <property name="bottom_attach">6</property>
                     <property name="y_options">GTK_FILL</property>
                     </child>
                   </object>
                   <packing>
                     </child>
                   </object>
                   <packing>
-                    <property name="left_attach">1</property>
-                    <property name="right_attach">2</property>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
                     <property name="top_attach">3</property>
                     <property name="bottom_attach">4</property>
                     <property name="y_options">GTK_FILL</property>
                     <property name="top_attach">3</property>
                     <property name="bottom_attach">4</property>
                     <property name="y_options">GTK_FILL</property>
                       </packing>
                     </child>
                   </object>
                       </packing>
                     </child>
                   </object>
+                  <packing>
+                    <property name="left_attach">2</property>
+                    <property name="right_attach">3</property>
+                    <property name="top_attach">4</property>
+                    <property name="bottom_attach">5</property>
+                    <property name="y_options">GTK_FILL</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="data_sensor1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">Rate</property>
+                    <attributes>
+                      <attribute name="weight" value="bold"/>
+                    </attributes>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options">GTK_FILL</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="acc_rate">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">0.0</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">1</property>
+                    <property name="bottom_attach">2</property>
+                    <property name="x_options">GTK_FILL</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="mag_rate">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">0.0</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">2</property>
+                    <property name="bottom_attach">3</property>
+                    <property name="x_options">GTK_FILL</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="tch_rate">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">0.0</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">3</property>
+                    <property name="bottom_attach">4</property>
+                    <property name="x_options">GTK_FILL</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="lgt_rate">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">0.0</property>
+                  </object>
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="right_attach">2</property>
                     <property name="top_attach">4</property>
                     <property name="bottom_attach">5</property>
                   <packing>
                     <property name="left_attach">1</property>
                     <property name="right_attach">2</property>
                     <property name="top_attach">4</property>
                     <property name="bottom_attach">5</property>
-                    <property name="y_options">GTK_FILL</property>
+                    <property name="x_options">GTK_FILL</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="a2d_rate">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">0.0</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="top_attach">5</property>
+                    <property name="bottom_attach">6</property>
+                    <property name="x_options">GTK_FILL</property>
                   </packing>
                 </child>
               </object>
                   </packing>
                 </child>
               </object>