Beispiel #1
0
 def OnRunSequence(self, itm):
     """
     
         Actions initiating a sequence run.
         
         Parameters:
             itm    -    root item for sequence (wx.TreeItem)
     
     """
     # disable controls
     self.ToggleControls(False)
     
     # refresh events
     self.RefreshEvents()
     
     # initialize data tree
     stree = self.list_events.GetItemSubTree(itm, ScanEvent)
     ev = self.list_events.GetItemPyData(itm)
     meas = Measurement(stree.data.name,stree)
     meas.BuildDataTree()
     
     # check that events work with associated data
     self.plot_or_save = [False]*meas.count
     if not(self.CheckValidity(stree,meas)):
         print "Invalid event tree!"
         self.ToggleControls(True)
         return
     del self.plot_or_save
     
     # store event tree in XML format
     doc = self.BuildXMLTree(itm)
     meas.xml = doc.toprettyxml(indent="  ", newl="\n")
     
     # store system state (state of instruments before measurement)
     from terapy import hardware
     doc = hardware.get_system_state()
     meas.systemState = doc.toprettyxml(indent="  ", newl="\n")
     
     # announce measurement start
     pub.sendMessage("scan.start", inst=meas)
     
     self.scanThread = ScanThread(ev, meas)
     self.scanThread.start()
Beispiel #2
0
 def run(self, data):
     self.itmList = self.get_children()
     n=0
     # store original data
     data0 = Measurement()
     data0.data = []
     for m_id in self.m_ids:
         data0.data.append(DataArray())
         if hasattr(data.data[m_id].data,'__iter__'):
             data0.data[m_id].data = zeros(data.data[m_id].data.shape)
         else:
             data0.data[m_id].data = 0
     # repeat sub-sequence
     while n<self.avg and self.can_run:
         n+=1
         self.run_children(data)
         for m_id in self.m_ids:
             data0.data[m_id].data = data0.data[m_id].data + data.data[m_id].data
         data.Increment(self.m_ids)
     for m_id in self.m_ids:
         data.data[m_id].data = data0.data[m_id].data/self.avg
     return data