Skip to content

Commit

Permalink
Started removing the unneeded stuff
Browse files Browse the repository at this point in the history
This probably doesnt work jet!
  • Loading branch information
Carlos Perez-Penichet committed Apr 25, 2011
1 parent 8c84544 commit f7e1828
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 333 deletions.
65 changes: 5 additions & 60 deletions bin/xraters.py
Expand Up @@ -87,11 +87,9 @@ def _connectCallback(self, connectionMaker):
gobject.timeout_add(45, self._drawAcc)
self.widget('actionDisconnect').set_sensitive(True)
self.widget('actionSave').set_sensitive(True)
self.widget('actionArm').set_sensitive(True)
self.widget('actionReset').set_sensitive(True)
self.widget('actionPause').set_sensitive(True)
self.widget('toolbutton1').set_related_action(self.widget('actionDisconnect'))
self.widget('toolbutton3').set_related_action(self.widget('actionArm'))
self._wiiMote.mesg_callback = self._getAcc
self._updBatteryLevel()
gobject.timeout_add_seconds(60, self._updBatteryLevel)
Expand All @@ -118,27 +116,12 @@ def _getAcc(self, messages, theTime=0):
self._acc[i] = float(axisAcc-self._acc_cal[0][i])
self._acc[i] /=(self._acc_cal[1][i]\
-self._acc_cal[0][i])
self._acc[i] /= 1.5
self._acc[i] *= self.preferences['accRange']
with self._dataLock:
# Store time and acceleration in the respective arrays
self._time.append(theTime-self._startTime)
[self._accData[i].append(self._acc[i]) for i in threeAxes]
# Compute correlation function
l = len(self._accData[self.preferences['Axis']])
c = abs(correlate(self._PATTERN,
self._accData[self.preferences['Axis']][l-len(self._PATTERN):l])[-1])
# If correlation is above threshold mark the time and
# start the experiment
if (not self._moving) and self._armed and \
(c > self.preferences['corrThreshold']):
self._moveTime = self._time[-1]
self._moving = True
# We only keep about 6 seconds worth of data if the experiment
# has not started but keep everything after the fall starts.
if (self._time[-1] - self._time[0] > 6) and \
((not self._draw) or \
((self._moveTime - self._time[0] > 2))):
# We only keep about 6 seconds worth of data
if (self._time[-1] - self._time[0] > 6):
with self._dataLock:
self._time.pop(0)
[self._accData[i].pop(0) for i in threeAxes]
Expand All @@ -158,17 +141,9 @@ def _drawAcc(self):
self._accAxis.set_xlim(lims[0], lims[1]+2)
lims = self._accAxis.get_xlim()
draw_flag = True
if (self._time[-1] - lims[0] > 6) and \
((not self._draw) or \
(self._draw and (self._moveTime - lims[0] > 2))):
if (self._time[-1] - lims[0] > 6):
self._accAxis.set_xlim(lims[0]+2, lims[1])
draw_flag = True
# Mark the start of the experiment with a vertical line
if (not self._draw) and self._moving:
self._draw = True
self._vline = self._accAxis.axvline(self._moveTime, color="k",
linestyle="--")
draw_flag = True
if draw_flag:
gobject.idle_add(self._accCanvas.draw)
# Do the actual update of the background
Expand Down Expand Up @@ -204,9 +179,6 @@ def _resetData(self):
self._accData = [list(), list(), list()]
self._time = list()
self._startTime = time.time()
self._armed = False
self._moving = False
self._draw = False
self._moveTime = self._startTime
self._Paused = False

Expand Down Expand Up @@ -234,7 +206,7 @@ def finish_initializing(self, builder):
self._accFigure = Figure(figsize=(8,6), dpi=72)
self._accAxis = self._accFigure.add_subplot(111)
self._accAxis.set_xlabel("time (s)")
self._accAxis.set_ylabel("gravity (g)")
self._accAxis.set_ylabel("acceleration (g)")
self._lines = self._accAxis.plot(self._time, self._accData[X],
self._time, self._accData[Y],
self._time, self._accData[Z],
Expand All @@ -243,8 +215,7 @@ def finish_initializing(self, builder):
'upper center',
ncol=3)
self._accAxis.set_xlim(0, 2)
self._accAxis.set_ylim(-self.preferences['accRange'],
self.preferences['accRange'])
self._accAxis.set_ylim(-3, 3)
self._accCanvas = FigureCanvas(self._accFigure)
self._accCanvas.mpl_connect("draw_event", self._upd_background)
self.__background = self._accCanvas.copy_from_bbox(self._accAxis.bbox)
Expand All @@ -269,9 +240,6 @@ def preferences(self, widget, data=None):
if response == gtk.RESPONSE_OK:
#make any updates based on changed preferences here
self.preferences = prefs.get_preferences()
self._accAxis.set_ylim(-self.preferences['accRange'],
self.preferences['accRange'])
self._accCanvas.draw()
prefs.destroy()

def quit(self, widget, data=None):
Expand Down Expand Up @@ -306,42 +274,19 @@ def on_wiiDisconnect(self, widget, data=None):
self.widget('actionDisconnect').set_sensitive(False)
self.widget('actionWiiConnect').set_sensitive(True)
self.widget('actionReset').set_sensitive(False)
self.widget('actionArm').set_sensitive(False)
self.widget('actionPause').set_sensitive(False)
self.widget('toolbutton3').set_related_action(self.widget('actionArm'))
self.widget('toolbutton1').set_related_action(self.widget('actionWiiConnect'))
self.widget('actionSave').set_sensitive(True)
self.widget('statusbar').pop(self.widget("statusbar").get_context_id(''))
self._setBatteryIndicator(0)

def on_Arm(self, widget, data=None):
"""Signal handler for the arm action
"""
self.widget('actionArm').set_sensitive(False)
self.widget('actionDisarm').set_sensitive(True)
self.widget('toolbutton3').set_related_action(self.widget('actionDisarm'))
self._armed = True

def on_Disarm(self, widget, data=None):
"""Signal handler for the disarm action
"""
self.widget('actionArm').set_sensitive(True)
self.widget('actionDisarm').set_sensitive(False)
self.widget('toolbutton3').set_related_action(self.widget('actionArm'))
self._armed = False

def on_Reset(self, widget, data=None):
"""Signal handler for the reset action
"""
if self._draw:
self._vline.remove()
self._resetData()
self._accAxis.set_xlim(0, 2)
gobject.idle_add(self._accCanvas.draw)
self.on_Disarm(widget, data)

def on_Pause(self, widge, data=None):
"""Signal handler for the pause action
Expand Down
180 changes: 1 addition & 179 deletions data/ui/PreferencesXratersDialog.ui
Expand Up @@ -46,18 +46,6 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label1">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Acc _Range: </property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">combobox_AccRange</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
Expand All @@ -84,15 +72,6 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkComboBox" id="combobox_AccRange">
<property name="visible">True</property>
<property name="model">liststore_Axis</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
</object>
Expand All @@ -118,163 +97,6 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frame2">
<property name="visible">True</property>
<property name="label_xalign">0</property>
<property name="shadow_type">none</property>
<child>
<object class="GtkHBox" id="hbox2">
<property name="visible">True</property>
<child>
<object class="GtkAlignment" id="alignment2">
<property name="visible">True</property>
<property name="left_padding">20</property>
<child>
<object class="GtkVBox" id="vbox4">
<property name="visible">True</property>
<child>
<object class="GtkLabel" id="label9">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Axis of interest:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">combobox_Axis</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label2">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">Corr. _Threshold:</property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">spin_CorrThreshold</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label7">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Fire Delay (ms): </property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">spin_FireDelay</property>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label8">
<property name="visible">True</property>
<property name="xalign">0</property>
<property name="label" translatable="yes">_Photo Delay (ms): </property>
<property name="use_underline">True</property>
<property name="mnemonic_widget">spin_PhotoDelay</property>
</object>
<packing>
<property name="position">3</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkAlignment" id="alignment5">
<property name="visible">True</property>
<property name="right_padding">1</property>
<child>
<object class="GtkVBox" id="vbox3">
<property name="visible">True</property>
<child>
<object class="GtkComboBox" id="combobox_Axis">
<property name="visible">True</property>
<property name="model">liststore_Axis</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spin_CorrThreshold">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">•</property>
<property name="activates_default">True</property>
<property name="adjustment">adjustmentThresholdSpin</property>
<property name="climb_rate">0.10000000000000001</property>
<property name="digits">2</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spin_FireDelay">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">•</property>
<property name="activates_default">True</property>
<property name="adjustment">adjustmentFireSpin</property>
<property name="climb_rate">1</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkSpinButton" id="spin_PhotoDelay">
<property name="width_request">200</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="invisible_char">•</property>
<property name="activates_default">True</property>
<property name="adjustment">adjustmentPhotoSpin</property>
<property name="climb_rate">1</property>
<property name="snap_to_ticks">True</property>
<property name="numeric">True</property>
</object>
<packing>
<property name="position">3</property>
</packing>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="padding">12</property>
<property name="position">1</property>
</packing>
</child>
</object>
</child>
<child type="label">
<object class="GtkLabel" id="label4">
<property name="visible">True</property>
<property name="label" translatable="yes">&lt;b&gt;Experiment&lt;/b&gt;</property>
<property name="use_markup">True</property>
</object>
</child>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkFrame" id="frame3">
<property name="visible">True</property>
Expand Down Expand Up @@ -331,7 +153,7 @@
</child>
</object>
<packing>
<property name="position">2</property>
<property name="position">1</property>
</packing>
</child>
</object>
Expand Down

0 comments on commit f7e1828

Please sign in to comment.