1. iorodeo
  2. water_channel_plugins

Commits

iorodeo  committed 189984a

Added example demonstrating how to read previous trial's data form the log
file.

  • Participants
  • Parent commits 466f167
  • Branches default

Comments (0)

Files changed (1)

File src/water_channel_plugins/example_position_plugin.py

View file
             raise ValueError, 'incorrect startup mode - must be position trajectory'
 
         # Check for log file
-        if self.logFileName is None:
+        if logFileName is None:
             raise ValueError, 'no log file set, log file required for plugin to function'
         
         self.robotControlObj = robotControlObj
                 self.doneFcn()
                 return
 
+            # Sort trials and get the latest
             trial_list = [x for x in list(f) if 'trial' in x]
-            print trial_list
-
+            trial_list.sort()
+            data  = f[trial_list[-1]]['data']
+            t, force = data['time'], data['force']
 
         # Design outscan set point array
         setptValues = run_defs.get_ramp( 
         self.inProgressFcn(False)
 
 
+def trial_cmp(x,y):
+    """
+    Comparison function for sorting trials
+    """
+    num_x = int(x.split('_')[-1])
+    num_y = int(y.split('_')[-1])
+    if num_x > num_y:
+        return 1
+    elif num_x < num_y:
+        return -1
+    else:
+        return 0