From: Andy Spencer Date: Wed, 12 Feb 2014 20:22:53 +0000 (+0000) Subject: Update from Yue, and add rate column X-Git-Url: http://pileus.org/git/?p=~andy%2Fcsm213a-hw;a=commitdiff_plain;h=2f86fd9689f36563206cc14f0d270d189e2d2f49 Update from Yue, and add rate column --- diff --git a/vis/device.py b/vis/device.py index 7d47d77..d1f96e4 100644 --- a/vis/device.py +++ b/vis/device.py @@ -79,6 +79,12 @@ class Frame: 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 @@ -87,7 +93,6 @@ class Frame: bits_typ = 0 # data type binary = "" # binary read-in values = [] # converted numeric data - total = 0 # total states read so far # 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) - #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() diff --git a/vis/visual.py b/vis/visual.py index 4f0e0e0..2ad6db6 100644 --- a/vis/visual.py +++ b/vis/visual.py @@ -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.smpl = get_objects(['sampling']) # 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.smpl, state.) self.history = self.history[1:] + [state.a2d[0]] self.window.queue_draw() diff --git a/vis/visual.ui b/vis/visual.ui index 4973021..9ec396d 100644 --- a/vis/visual.ui +++ b/vis/visual.ui @@ -2,6 +2,21 @@ + + Serial + gtk-connect + + + + Settings + gtk-preferences + + + + Xively + gtk-connect + + 100 1 @@ -47,22 +62,7 @@ 1 10 - - Serial - gtk-connect - - - - Settings - gtk-preferences - - - - Xively - gtk-connect - - False 5 @@ -100,6 +100,7 @@ False True + end 0 @@ -465,11 +466,15 @@ 10 + 500 + 400 False + 400 + 400 True False @@ -801,13 +806,14 @@ True False 6 - 2 + 3 20 5 True False + 0 Sensor @@ -822,14 +828,15 @@ True False + 0 Current Value - 1 - 2 + 2 + 3 GTK_FILL @@ -879,8 +886,8 @@ - 1 - 2 + 2 + 3 1 2 GTK_FILL @@ -932,8 +939,8 @@ - 1 - 2 + 2 + 3 2 3 GTK_FILL @@ -1024,8 +1031,8 @@ - 1 - 2 + 2 + 3 5 6 GTK_FILL @@ -1133,8 +1140,8 @@ - 1 - 2 + 2 + 3 3 4 GTK_FILL @@ -1158,12 +1165,104 @@ + + 2 + 3 + 4 + 5 + GTK_FILL + + + + + True + False + 0 + Rate + + + + + + 1 + 2 + GTK_FILL + GTK_FILL + + + + + True + False + 0 + 0.0 + + + 1 + 2 + 1 + 2 + GTK_FILL + + + + + True + False + 0 + 0.0 + + + 1 + 2 + 2 + 3 + GTK_FILL + + + + + True + False + 0 + 0.0 + + + 1 + 2 + 3 + 4 + GTK_FILL + + + + + True + False + 0 + 0.0 + 1 2 4 5 - GTK_FILL + GTK_FILL + + + + + True + False + 0 + 0.0 + + + 1 + 2 + 5 + 6 + GTK_FILL