def send_status_event(self, isev, idev, time, bore=False, eore=False): ev = pyeudaq.Event('RawEvent', self.name + '_status') idda, iddd, status = self.daq.power_status() temp = self.daq.carrier_temp() ev.SetTag('IDDA', '%.2f mA' % idda) ev.SetTag('IDDD', '%.2f mA' % iddd) ev.SetTag('Temperature', '%.2f C' % temp if temp else 'Invalid temperature read!') ev.SetTag('Event', '%d' % idev) ev.SetTag('Time', time.isoformat()) if bore: ev.SetBORE() ev.SetTag('FPGA_GIT', self.daq.get_fpga_git()) ev.SetTag('FPGA_COMPILE', self.daq.get_fpga_tcompile().isoformat()) #ev.SetTag('FX3_GIT' ,self.daq.get_fx3_git()) #ev.SetTag('FX3_COMPILE' ,self.daq.get_fx3_tcompile().isoformat()) git = subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip() diff = subprocess.check_output(['git', 'diff']) ev.SetTag('EUDAQ_GIT', git) ev.SetTag('EUDAQ_DIFF', diff) ev.SetTag('ALPIDEDAQ_GIT', self.daq.get_software_git()) ev.SetTag('ALPIDEDAQ_DIFF', self.daq.get_software_diff()) if eore: ev.SetEORE() if bore or eore: for reg, addr in ALPIDE_DUMP_REGS.items(): ev.SetTag( 'ALPIDE_%04x_%s' % (addr, reg), '%d' % self.daq.alpide_reg_read(addr, chipid=self.chipid)) self.daq.trgmon.lat.issue() for reg in self.daq.trgmon.regs: ev.SetTag('TRGMON_' + reg.upper(), '%d' % self.daq.trgmon.regs[reg].read()) self.SendEvent(ev)
def BuildAndWrite(self): #print('BUILD:',self.iev,'remaining events in queues: ',[len(q) for q in self.producer_queues.values()]) if all(len(q)!=0 for q in self.producer_queues.values()): globalev=pyeudaq.Event('RawEvent','ITS3global') for queue in self.producer_queues.values(): # TODO: cross-checks! (timing + eventids) subev=queue.popleft() globalev.AddSubEvent(subev) self.WriteEvent(globalev) self.ndev+=1
def RunLoop(self): print "Start of RunLoop in ExamplePyProducer" trigger_n = 0 while (self.is_running): ev = pyeudaq.Event("RawEvent", "sub_name") ev.SetTriggerN(trigger_n) print ev self.SendEvent(ev) trigger_n += 1 time.sleep(1) print "End of RunLoop in ExamplePyProducer"
def send_status_event(self, time, bore=False, eore=False): ev = pyeudaq.Event('RawEvent', self.name + '_status') ev.SetTag('Time', time.isoformat()) with self.lock: ev.SetTag('Pressure', '%.2f mbar' % self.pth.getP()) ev.SetTag('Temperature', '%.2f degC' % self.pth.getT()) ev.SetTag('Humidity', '%.2f rel%%' % self.pth.getH()) if bore: ev.SetBORE() if eore: ev.SetEORE() self.SendEvent(ev)
def RunLoop(self): print "Start of RunLoop in ExamplePyProducer" trigger_n = 0 while (self.is_running): ev = pyeudaq.Event("RawEvent", "sub_name") ev.SetTriggerN(trigger_n) block = bytes(r'raw_data_string') ev.AddBlock(0, block) print ev self.SendEvent(ev) trigger_n += 1 time.sleep(1) print "End of RunLoop in ExamplePyProducer"
def send_status_event(self, isev, idev, time, bore=False, eore=False): ev = pyeudaq.Event('RawEvent', self.name + '_status') ev.SetTag('Event', '%d' % idev) ev.SetTag('Time', time.isoformat()) if bore: ev.SetBORE() git = subprocess.check_output(['git', 'rev-parse', 'HEAD']).strip() diff = subprocess.check_output(['git', 'diff']) ev.SetTag('EUDAQ_GIT', git) ev.SetTag('EUDAQ_DIFF', diff) if eore: ev.SetEORE() self.SendEvent(ev)
def DoReceive(self, con, ev): self.dict_con_ev[con].append(ev) for con, ev_queue in self.dict_con_ev.items(): #print ( con, len(ev_queue) ) if (len(ev_queue) == 0): return sync_ev = pyeudaq.Event('RawEvent', 'mysyncdata') for con, ev_queue in self.dict_con_ev.items(): sub_ev = ev_queue.popleft() sync_ev.AddSubEvent(sub_ev) self.WriteEvent(sync_ev)
def RunLoop(self): print("Start of RunLoop in ExamplePyProducer") trigger_n = 0 while (self.is_running): ev = pyeudaq.Event("RawEvent", "sub_name") ev.SetTriggerN(trigger_n) #block = bytes(r'raw_data_string') #ev.AddBlock(0, block) #print ev # Mengqing: datastr = 'raw_data_string' block = bytes(datastr, 'utf-8') ev.AddBlock(0, block) print(ev) self.SendEvent(ev) trigger_n += 1 time.sleep(1) print("End of RunLoop in ExamplePyProducer")
def read_and_send_event(self, iev): self.daq.arm() if self.trigger_on == 'AUX': print('release bsy') self.trigger.write( trigger.Trigger.MOD_SOFTBUSY, 0, 0x2, commit=True ) # releases software busy and arms setting it right after receivign of trigger print('wait data') self.daq.wait() print('done') data = self.daq.rdo() ev = pyeudaq.Event('RawEvent', self.name) tev = 0 # no global time stamp (TODO: can the osciloscope provide one?) ev.SetEventN( iev ) # clarification: iev is the number of received events (starting from zero) # FIXME: is overwritten in SendEvent ev.SetTriggerN(iev) # clarification: itrg is set to iev ev.SetTimestamp(begin=tev, end=tev) ev.SetDeviceN(self.plane) ev.AddBlock(0, bytes(data)) self.SendEvent(ev) return True
def read_and_send_event(self, iev): raw = self.daq.event_read() if raw: raw = bytes(raw) assert len(raw) >= 20 assert list(raw[:4]) == [0xAA] * 4 assert list(raw[-4:]) == [0xBB] * 4 itrg = sum(b << (j * 8) for j, b in enumerate(raw[4:8])) tev = sum(b << (j * 8) for j, b in enumerate(raw[8:16])) ev = pyeudaq.Event('RawEvent', self.name) ev.SetEventN( iev ) # clarification: iev is the number of received events (starting from zero) # FIXME: is overwritten in SendEvent ev.SetTriggerN( itrg ) # clarification: itrg is the event number form the DAQ board ev.SetTimestamp(begin=tev, end=tev) ev.SetDeviceN(self.plane) ev.AddBlock(0, raw) self.SendEvent(ev) return True else: return False