def trigger_pause(self): if not self.connected: print "Device not connected" return False data = [] pause_trig = PV('pause_trigger_source') acquisition_mode = PV('acquisition_mode') poll(evt=1.e-5, iot=0.01) print "starting setup is, acquisition: " + str( acquisition_mode.get()) + " stoptrig: " + str(pause_trig.get()) acquisition_mode.put(0) poll(evt=1.e-5, iot=0.01) #pause_trig.put(1) util.put_check(pause_trig, 1) print "trig1: " + str(pause_trig.get()) poll(evt=1.0, iot=1.01) print "trig2: " + str(pause_trig.get()) data.append(pause_trig.get() == 1) time.sleep(3) print "trig3: " + str(pause_trig.get()) #pause_trig.put(0) util.put_check(pause_trig, 0) poll(evt=1.0, iot=1.01) data.append(pause_trig.get() == 0) time.sleep(3) print "trig4: " + str(pause_trig.get()) return data
def burst_size(self): if not self.connected: print "Device not connected" return False data = [] count = PV('in_counts_3') trig_mode = PV('trig_mode') low3 = PV('low_limit_3') int_time = PV('analog_out_period') trig_burst = PV('trig_burst') trig_buffer = PV('trig_buffer') init = PV('initiate') poll(evt=1.e-5, iot=0.01) util.put_check(trig_mode, 0) low3.put(0.0) int_time.put(10e-4) util.put_check(trig_buffer, 0) util.put_check(trig_burst, 1000) poll(evt=1.e-5, iot=0.01) def getCount(pvname, value, **kw): data.append(value) count.add_callback(getCount) t0 = time.time() init.put(1) t1 = time.time() # while caget('paused_state') != 1: # if time.time() - t1 > 30: # return "pause state never reached" # else: # pass pass1 = len(data) util.put_check(trig_burst, 10000) time.sleep(0.1) t2 = time.time() init.put(1) t3 = time.time() # while caget('paused_state') != 1: # if time.time() - t3 > 30: # return "pause state never reached 2nd time" # else: # pass pass2 = len(data) - pass1 # teardown util.put_check(trig_burst, 0) return pass1, pass2
def buffering_low(self): status = PV('status') if not util.check_device('C1', self.proc) and status.get() in range(0,3): print "device not connected" return False count3 = PV('in_counts_3') low_3 = PV('low_limit_3') low_4 = PV('low_limit_4') trig_buffer = PV('trig_buffer') init = PV('initiate') poll(evt=1.e-5, iot=0.01) data3 = [] def getCount3(pvname, value, **kw): data3.append(value) if util.put_check(low_3, 0.0) and util.put_check(low_4, 0.0) and util.put_check(trig_buffer, 1000) and util.put_fuzzy('analog_out_period', 10e-5, 0.05): pass else: print "setting not taking place" return False, False count3.add_callback(getCount3) init.put(1) t0 = time.time() while time.time() - t0 < 3: poll(evt=1.e-5, iot=0.01) time.sleep(2) return len(data3)
def stopcount_value(self, value): initial_check = util.expect(self.proc, ["A1"]) data1 = [] def getData1(pvname, value, **kw): if value != 0: data1.append(value) analog1 = PV('analogIn1') stop_count = PV('outStopCount') init = PV('initiate') analog2 = PV('analogIn2') poll(evt=1.e-5, iot=0.01) analog1.wait_for_connection() analog2.wait_for_connection() init.wait_for_connection() stop_count.wait_for_connection() util.put_check(stop_count, value) analog1.add_callback(getData1) init.put(1) poll(evt=1.e-5, iot=0.01) t0 = time.time() while time.time() - t0 < 10: poll(evt=1.e-5, iot=0.01) run = len(data1) return run
def trigger_start(self): if not self.connected: print "Device not connected" return False status = PV('status') print status.get() if status.get() not in range(0,3): print "status" return False data = [] start_trig = PV('start_trigger_source') acquisition_mode = PV('acquisition_mode') poll(evt=1.e-5, iot=0.01) print "starting setup is, acquisition: " + str(acquisition_mode.get()) + " stoptrig: " + str(start_trig.get()) acquisition_mode.put(0) poll(evt=1.e-5, iot=0.01) #start_trig.put(1) util.put_check(start_trig, 1) print "trig1: " + str(start_trig.get()) poll(evt=1.0, iot=1.01) print "trig2: " + str(start_trig.get()) data.append(start_trig.get() == 1) time.sleep(3) print "trig3: " + str(start_trig.get()) #start_trig.put(0) util.put_check(start_trig, 0) poll(evt=1.0, iot=1.01) data.append(start_trig.get() == 0) time.sleep(3) print "trig4: " + str(start_trig.get()) return data
def buffering(self, value): check = util.expect(self.proc, ["C1"]) count3 = PV('in_counts_3') low3 = PV('low_limit_3') trig_buffer = PV('trig_buffer', auto_monitor=False) int_time = PV('analog_out_period') init = PV('initiate') poll(evt=1.e-5, iot=0.01) data = [] #camonitor('trig_buffer') def getCount1(pvname, value, **kw): data.append(value) util.put_check(low3, 0.0) util.put_check(trig_buffer, value) util.put_fuzzy('analog_out_period', 10e-5, 0.05) print "set value " + str(value) print "buffer value " + str(trig_buffer.get()) #time.sleep(5) #print "buffer value " + str(trig_buffer.get()) count3.add_callback(getCount1) init.put(1) poll(evt=1.e-5, iot=0.01) t0 = time.time() while time.time() - t0 < 5: poll(evt=1.e-5, iot=0.01) run1 = len(data) return run1
def set_analog_outs(self): a1 = PV('analog_out_1') a2 = PV('analog_out_2') d = [] j = [] #print a1.get(), a2.get() a2.connect() #poll(evt=1.0, iot=0.01) a1.connect() poll(evt=1.0, iot=0.01) print a2.info for i in range(10): if i % 2 == 1: util.put_check(a2, 0.45) #util.put_check(a1, float(i)) else: util.put_check(a2, 0.5) #util.put_check(a1, float(i)) #j.append(a1.get()) d.append(a2.get()) print a1.status #util.put_check(a2, value2) print d print j return d
def test_stopcount(): proc = pexpect.spawn( "/home/steve/workspace/ig2_medical/ig2-2.6.7 /home/steve/workspace/ig2_medical/m10_stopcount.xml" ) proc.expect([pexpect.TIMEOUT, pexpect.EOF, 'Announce\(\) success'], timeout=10) print proc.after #util.pv_check('status', 0) stop = 1001 data1 = [] data2 = [] def getData1(pvname, value, **kw): if value != 0: data1.append(value) def getData2(pvname, value, **kw): if value != 0: data2.append(value) analog1 = PV('analogIn1') stop_count = PV('outStopCount') init = PV('initiate') analog2 = PV('analogIn2') analog1.wait_for_connection() analog2.wait_for_connection() init.wait_for_connection() stop_count.wait_for_connection() analog1.add_callback(getData1) if util.put_check('outStopCount', stop): init.put(1) t0 = time.time() while time.time() - t0 < 30: poll(evt=1.e-5, iot=0.01) else: print "Stopcount not set" return False buffered_run = len(data1) analog2.add_callback(getData2) time.sleep(2) if util.put_check('outStopCount', -1): init.put(1) t0 = time.time() while time.time() - t0 < 30: poll(evt=1.e-5, iot=0.01) else: print "Stopcount not set 2nd time" return False unbuffered_run = len(data2) return buffered_run, unbuffered_run
def io(self): if not self.connected: print "Device not connected" return False d_o = [] a_o = [] d_i = [] a_i = [] d_outs = { 1: PV('digitalOut1'), 2: PV('digitalOut2'), 3: PV('digitalOut3'), 4: PV('digitalOut4'), 5: PV('digitalOut5'), 6: PV('digitalOut6'), 7: PV('digitalOut7'), 8: PV('digitalOut8') } d_ins = { 1: PV('digitalIn1'), 2: PV('digitalIn2'), 3: PV('digitalIn3'), 4: PV('digitalIn4'), 5: PV('digitalIn5'), 6: PV('digitalIn6'), 7: PV('digitalIn7'), 8: PV('digitalIn8') } a_outs = { 1: PV('analogOut1'), 2: PV('analogOut2'), 3: PV('analogOut3'), 4: PV('analogOut4'), 5: PV('analogOut5'), 6: PV('analogOut6'), 7: PV('analogOut7'), 8: PV('analogOut8') } a_ins = { 1: PV('analogIn1'), 2: PV('analogIn2'), 3: PV('analogIn3'), 4: PV('analogIn4'), 5: PV('analogIn5'), 6: PV('analogIn6'), 7: PV('analogIn7'), 8: PV('analogIn8'), } poll(evt=1.e-5, iot=0.01) for i in range(0, 8): d_o.append(util.put_check(d_outs[i + 1], 1)) a_o.append(util.put_check(a_outs[i + 1], i)) d_i.append(util.pv_check(d_ins[i + 1], 1)) a_i.append(a_ins[i + 1].get() != None) return [x for sublist in [d_i, a_i, d_o, a_o] for x in sublist]
def buffering(self): poll(evt=1.9, iot=0.01) status = PV('status') poll(evt=1.9, iot=0.01) start_time = time.time() while status.get() not in (0, 3): print str(status.get()) + "not connected yet" print status.info print status connected = status.get() in (0, 3) poll(evt=1.0, iot=0.51) if time.time() - start_time >= 60: connected = False print "timed out" break print util.expect(self.proc, ["C1"]) count3 = PV('in_counts_3') count4 = PV('in_counts_4') low_3 = PV('low_limit_3') low_4 = PV('low_limit_4') trig_buffer = PV('trig_buffer') init = PV('initiate') poll(evt=1.e-5, iot=0.01) data3 = [] data4 = [] def getCount3(pvname, value, **kw): data3.append(value) def getCount4(pvname, value, **kw): data4.append(value) if util.put_check( low_3, 0.0) and util.put_check(low_4, 0.0) and util.put_check( trig_buffer, 1000) and util.put_fuzzy( 'analog_out_period', 10e-5, 0.05): pass else: print "setting not taking place" return False, False t0 = time.time() time.sleep(1) count3.add_callback(getCount3) count4.add_callback(getCount4) poll(evt=1.e-5, iot=0.01) init.put(1) poll(evt=1.e-5, iot=0.01) while time.time() - t0 < 3: poll(evt=1.e-5, iot=0.01) # end = self.proc.expect( # ['Announce\(\) success', pexpect.TIMEOUT, pexpect.EOF], timeout=3) return len(data3), len(data4)
def set_integration(self, value): check = util.expect(self.proc, ["C1"]) int_time = PV('analog_out_period', auto_monitor=False) util.put_check(int_time, value) print int_time.get() print int_time.get() print "before| intended: " + str(value) + " actual: " + str( int_time.get()) + " close check: " + str( util.isclose(value, int_time.get(use_monitor=False))) return int_time.get()
def stopcount(self): #self.proc = pexpect.spawn("/home/steve/workspace/ig2_medical/ig2-2.6.7 /home/steve/workspace/ig2_medical/m10_stopcount.xml") if not self.connected: print "Device not connected" return False #util.pv_check('status', 0) #self.stop = 1001 def getData1(pvname, value, **kw): if value != 0: self.data1.append(value) def getData2(pvname, value, **kw): if value != 0: self.data2.append(value) analog1 = PV('analogIn1') stop_count = PV('outStopCount') init = PV('initiate') analog2 = PV('analogIn2') poll(evt=1.e-5, iot=0.01) analog1.wait_for_connection() analog2.wait_for_connection() init.wait_for_connection() stop_count.wait_for_connection() analog1.add_callback(getData1) if util.put_check(stop_count, self.stop): init.put(1) t0 = time.time() while time.time() - t0 < 10: poll(evt=1.e-5, iot=0.01) else: print "Stopcount not set" return False buffered_run = len(self.data1) analog2.add_callback(getData2) if util.put_check(stop_count, -1): init.put(1) t0 = time.time() while time.time() - t0 < 10: poll(evt=1.e-5, iot=0.01) else: print "Stopcount not set 2nd time" return False unbuffered_run = len(self.data2) print unbuffered_run, buffered_run return buffered_run, unbuffered_run
def buffering(self): if not self.connected: print "Device not connected" return False count3 = PV('in_counts_3') count4 = PV('in_counts_4') low3 = PV('low_limit_3') low4 = PV('low_limit_4') trig_buffer = PV('trig_buffer') int_time = PV('analog_out_period') init = PV('initiate') poll(evt=1.e-5, iot=0.01) data1 = [] data2 = [] def getCount1(pvname, value, **kw): data1.append(value) def getCount2(pvname, value, **kw): data2.append(value) if util.put_check( low3, 0.0) and util.put_check(low4, 0.0) and util.put_check( trig_buffer, 1000) and util.put_fuzzy( 'analog_out_period', 10e-5, 0.05): pass else: print "setting not taking place" return False, False time.sleep(1) count3.add_callback(getCount1) init.put(1) t0 = time.time() while time.time() - t0 < 3: poll(evt=1.e-5, iot=0.01) run1 = len(data1) count3.remove_callback(1) count3.add_callback(getCount2) if util.put_check(trig_buffer, 500): pass else: print "setting 2nd time not taking place" return False, False init.put(1) t1 = time.time() while time.time() - t1 < 3: poll(evt=1.e-5, iot=0.01) run2 = len(data2) return run1, run2
def get_state(self): #print str(util.isclose(1.79999995232, 1.8)) state = PV('r_g0_state') outp = PV('g0_pressure') #outp.wait_for_connection() #print outp.get() util.put_check(outp, 1.8) print outp.get() return state.get()
def stopcount_value(self): if not self.connected: print "Device not connected" return False #util.pv_check('status', 0) #self.stop = 1001 data1 = [] data2 = [] def getData1(pvname, value, **kw): if value != 0: data1.append(value) def getData2(pvname, value, **kw): if value != 0: data2.append(value) analog1 = PV('analogIn1') stop_count = PV('outStopCount') init = PV('initiate') analog2 = PV('analogIn2') poll(evt=1.e-5, iot=0.01) analog1.wait_for_connection() analog2.wait_for_connection() init.wait_for_connection() stop_count.wait_for_connection() util.put_check(stop_count, 100) analog1.add_callback(getData1) init.put(1) poll(evt=1.e-5, iot=0.01) t0 = time.time() while time.time() - t0 < 10: poll(evt=1.e-5, iot=0.01) first_run = len(data1) analog1.remove_callback(0) analog1.add_callback(getData2) time.sleep(2) util.put_check(stop_count, 200) init.put(1) poll(evt=1.e-5, iot=0.01) t0 = time.time() while time.time() - t0 < 10: poll(evt=1.e-5, iot=0.01) second_run = len(data2) return first_run, second_run
def run(mode): util.put_check(accum_mode, mode) time.sleep(1) init.put(1) poll(evt=1.e-5, iot=0.01) t0 = time.time() while time.time() - t0 < 5: poll(evt=1.e-5, iot=0.01) init.put(0) poll(evt=1.e-5, iot=0.01)
def close_valve(self): command = PV('c_v1_command') state = PV('r_v1_state') c_open_close = PV('c_v1_open_close') r_open_close = PV('r_v1_open_close') if state.get() == 0: #c_open_close.put(1) util.put_check(c_open_close, 1) #c_open_close.put(0) util.put_check(c_open_close, 0) poll(evt=1.e-5, iot=0.01) return state.get()
def integration_set(self): data = [] if not self.connected: print "Device not connected" return False count = PV('in_counts_3') trig_mode, low3, low4, trig_buffer, int_time, init = PV( 'trig_mode'), PV('low_limit_3'), PV('low_limit_4'), PV( 'trig_buffer'), PV('analog_out_period'), PV('initiate') trig_mode.put(1) low3.put(0.0) low4.put(0.0) util.put_check(trig_buffer, 1000) #util.put_fuzzy('analog_out_period', 10e-5, 0.01) int_time.put(10e-5) poll(evt=1.e-5, iot=0.01) def getCount(pvname, value, **kw): data.append(value) count.add_callback(getCount) init.put(1) print trig_mode.get(), low3.get(), low4.get(), trig_buffer.get( ), int_time.get() print count.value print count.get() poll(evt=2.0, iot=2.01) print count.value print count.get() fast = count.value int_time.put(10e-3) t1 = time.time() # while caget('analog_out_period') != 10e-3: # if time.time() - t1 > 20: # return "integration period is not being set" # else: # pass init.put(1) time.sleep(5) slow = count.value if slow and fast: print slow, fast return slow / (fast + 0.01 * fast), slow / (fast - 0.01 * fast) else: print slow, fast return False
def enable_stopcount(self): if not self.connected: print "Device not connected" return False stop = 100 data1 = [] data2 = [] def getData1(pvname, value, **kw): if value != 0: data1.append(value) def getData2(pvname, value, **kw): if value != 0: data2.append(value) analog1 = PV('analogIn1') stop_count = PV('outStopCount') init = PV('initiate') analog2 = PV('analogIn2') poll(evt=1.e-5, iot=0.01) analog1.wait_for_connection() analog2.wait_for_connection() init.wait_for_connection() stop_count.wait_for_connection() analog1.add_callback(getData1) if util.put_check(stop_count, stop): init.put(1) t0 = time.time() while time.time() - t0 < 30: poll(evt=1.e-5, iot=0.01) else: print "Stopcount not set" return False buffered_run = len(data1) analog2.add_callback(getData2) time.sleep(2) if util.put_check(stop_count, -1): init.put(1) t0 = time.time() while time.time() - t0 < 30: poll(evt=1.e-5, iot=0.01) else: print "Stopcount not set 2nd time" return False unbuffered_run = len(data2) return buffered_run, unbuffered_run
def set_digital_outs(self, value): if util.expect(self.proc, ["A1"]) != 3: print "did not connect" return False init = PV('initiate') d_outs = {1: PV('digitalOut1'), 2: PV('digitalOut2'), 3: PV('digitalOut3'), 4: PV('digitalOut4')} poll(evt=1.0, iot=0.01) for i in range(4): util.put_check(d_outs[i + 1], value[i]) return [v.get() for v in d_outs.values()]
def trigger_stop(self): if not self.connected: print "Device not connected" return False status = PV('status') print status.get() if status.get() not in range(0,3): print "status" return False print caget('status') #time.sleep(5) data = [] stop_trig = PV('stop_trigger_source') acquisition_mode = PV('acquisition_mode') buff_mode = PV('buffered_acquisition') stopcount = PV('stop_count') poll(evt=1.e-5, iot=0.01) # stopcount.put(0) # poll(evt=1.e-5, iot=0.01) # buff_mode.put(0) # poll(evt=1.e-5, iot=0.01) # print util.put_check(stopcount, 0) # print stopcount.get() # print util.put_check(buff_mode, 0) # print buff_mode.get() poll(evt=1.e-5, iot=0.01) print "starting setup is, acquisition: " + str(acquisition_mode.get()) + " stoptrig: " + str(stop_trig.get()) acquisition_mode.put(0) poll(evt=1.e-5, iot=0.01) # buff_mode.put(1) # poll(evt=1.e-5, iot=0.01) # stopcount.put(1000) # poll(evt=1.e-5, iot=0.01) #stop_trig.put(1) util.put_check(stop_trig, 1) print "trig1: " + str(stop_trig.get()) poll(evt=1.0, iot=1.01) print "trig2: " + str(stop_trig.get()) data.append(stop_trig.get() == 1) time.sleep(3) print "trig3: " + str(stop_trig.get()) #stop_trig.put(0) util.put_check(stop_trig, 0) poll(evt=1.0, iot=1.01) data.append(stop_trig.get() == 0) time.sleep(3) print "trig4: " + str(stop_trig.get()) return data
def burst2(self, value): #connect = self.proc.expect([pexpect.TIMEOUT, pexpect.EOF, 'Announce\(\) success'], timeout=1) if not self.connected: print "Device not connected" return False burst = PV('burst_count') poll(evt=1.01, iot=1.01) util.put_check(burst, value) poll(evt=1.0, iot=1.01) caput('burst_count', value) # while burst.get() != 100: # burst.put(100) # poll(evt=1.0, iot=1.01) return burst.get()
def buffering(self): status = PV('status') if not util.check_device('C1', self.proc) and status.get() in range(0,3): print "device not connected" return False count3 = PV('in_counts_3') count4 = PV('in_counts_4') low_3 = PV('low_limit_3') low_4 = PV('low_limit_4') trig_buffer = PV('trig_buffer') init = PV('initiate') poll(evt=1.e-5, iot=0.01) data3 = [] data4 = [] def getCount3(pvname, value, **kw): data3.append(value) def getCount4(pvname, value, **kw): data4.append(value) if util.put_check(low_3, 0.0) and util.put_check(low_4, 0.0) and util.put_check(trig_buffer, 1000) and util.put_fuzzy('analog_out_period', 10e-5, 0.05): pass else: print "setting not taking place" return False, False t0 = time.time() # while caget('trig_buffer')!=1000 and caget('trig_mode')!=1: # if time.time() - t0 > 20: # return "buffer or mode never set" # else: # pass #util.put_check('initiate', 1) time.sleep(1) count3.add_callback(getCount3) count4.add_callback(getCount4) init.put(1) while time.time() - t0 < 3: poll(evt=1.e-5, iot=0.01) # time.sleep(2) end = self.proc.expect( ['Announce\(\) success', pexpect.TIMEOUT, pexpect.EOF], timeout=3) #print proc.before return len(data3), len(data4)
def open_valve(self): if self.connected != True: return False command = PV('c_v1_command') state = PV('r_v1_state') c_open_close = PV('c_v1_open_close') r_open_close = PV('r_v1_open_close') poll(evt=1.e-5, iot=0.01) if state.get() == 1.0: util.put_check(c_open_close, 0) #c_open_close.put(1) util.put_check(c_open_close, 1) poll(evt=1.e-5, iot=0.01) return state.get()
def set_digital_outs(self, values): initial_check = util.expect(self.proc, ["A1"]) d_outs = { 1: PV('digitalOut1'), 2: PV('digitalOut2'), 3: PV('digitalOut3'), 4: PV('digitalOut4'), 5: PV('digitalOut5'), 6: PV('digitalOut6'), 7: PV('digitalOut7'), 8: PV('digitalOut8') } poll(evt=1.e-5, iot=0.01) for i in range(0, 8): util.put_check(d_outs[i + 1], values[i]) return [v.get() for v in d_outs.values()]
def turn_on(self): command = PV('c_p0_command') state = PV('r_p0_state') c_on_off = PV('c_p0_on_off') r_on_off = PV('r_p0_on_off') c_normal = PV('c_p0_normal') c_faulted = PV('c_p0_faulted') c_freq = PV('c_p0_freq') if state.get() != 0.0: util.put_check(c_on_off, 0) util.put_check(c_on_off, 1) util.put_check(c_normal, 1) util.put_check(c_faulted, 0) util.put_check(c_freq, 490) return state.get()
def data_types(self): self.proc.expect(["ENABLED", pexpect.TIMEOUT, pexpect.EOF], timeout=10) test = [] a_o, a_i, d_o, d_i, s_i, s_o, i_i, i_o = {}, {}, {}, {}, {}, {}, {}, {} for i in range(1, 513): a_o[i] = PV('analog_out_' + str(i)) a_i[i] = PV('analog_in_' + str(i)) d_i[i] = PV('digital_in_' + str(i)) d_o[i] = PV('digital_out_' + str(i)) s_i[i] = PV('string_in_' + str(i)) s_o[i] = PV('string_out_' + str(i)) i_i[i] = PV('int_in_' + str(i)) i_o[i] = PV('int_out_' + str(i)) for x in range(1, 513): test.append(util.put_check(a_o[x], x)) for x in range(1, 513): test.append(util.put_check(d_o[x], 1)) for x in range(1, 513): test.append(util.put_check(i_o[x], x)) for x in range(1, 513): test.append(util.put_check(s_o[x], str(x))) for x in range(1, 513): test.append(util.pv_check(a_i[x], 0)) for x in range(1, 513): test.append(util.pv_check(d_i[x], 0)) for x in range(1, 513): test.append(util.pv_check(i_i[x], 0)) for x in range(1, 513): test.append(util.pv_check(s_i[x], '')) if all(x == True for x in test): return True else: return False
def burst_size(self, value): check = util.expect(self.proc, ["C1"]) data = [] print check print self.proc.after count = PV('in_counts_3') trig_mode = PV('trig_mode') low3 = PV('low_limit_3') int_time = PV('analog_out_period') trig_burst = PV('trig_burst', auto_monitor=False) trig_buffer = PV('trig_buffer', auto_monitor=False) init = PV('initiate') poll(evt=1.e-5, iot=0.01) util.put_check(trig_mode, 0) low3.put(0.0) int_time.put(10e-4) util.put_check(trig_buffer, value) util.put_check(trig_burst, value) print trig_burst.get(), trig_buffer.get(), trig_mode.get(), value poll(evt=1.e-5, iot=0.01) def getCount(pvname, value, **kw): if value != 0: data.append(value) print trig_buffer.get(use_monitor=False) print trig_burst.get(use_monitor=False) time.sleep(1) count.add_callback(getCount) print len(data) init.put(1) t0 = time.time() while time.time() - t0 < 5: poll(evt=1.e-5, iot=0.01) data_length = len(data) # teardown print len(data) print len(data) print len(data) util.put_check(trig_burst, 0) util.put_check(trig_buffer, 0) #print data return data_length
def io(self): # on = pexpect.spawn('curl "http://*****:*****@192.168.100.36/outlet?1=CCL"') # on2 = pexpect.spawn('curl "http://*****:*****@192.168.100.36/outlet?2=CCL"') #self.proc = pexpect.spawn("/home/steve/workspace/ig2_medical/ig2-2.6.7 /home/steve/workspace/ig2_medical/m10_io.xml") if not self.connected: print "Device not connected" return False init = PV('initiate') d_outs = { 1: PV('digitalOut1'), 2: PV('digitalOut2'), 3: PV('digitalOut3'), 4: PV('digitalOut4') } d_ins = { 1: PV('digitalIn1'), 2: PV('digitalIn2'), 3: PV('digitalIn3'), 4: PV('digitalIn4') } a_ins = {1: PV('analogIn1'), 2: PV('analogIn2')} a_outs = {1: PV('analogOut1'), 2: PV('analogOut2')} # dout1, dout2, dout3, dout4 = PV('digitalOut1'), PV('digitalOut2'), PV('digitalOut3'), PV('digitalOut4') # din1, din2, din3, din4 = PV('digitalIn1'), PV('digitalIn2'), PV('digitalIn3'), PV('digitalIn4') # aout1, aout2, aout3, aout4 = PV('analogOut1'), PV('analogOut2'), PV('analogOut3'), PV('analogOut4') # ain1, ain2, ain3, ain4 = PV('analogIn1'), PV('analogIn2'), PV('analogIn3'), PV('analogIn4') poll(evt=1.e-5, iot=0.01) d_i = [] a_i = [] d_o = [] a_o = [] init.put(1) poll(evt=1.e-5, iot=0.01) for i in range(0, 4): d_o.append(util.put_check(d_outs[i + 1], 1)) d_i.append(util.pv_check(d_ins[i + 1], 1)) for i in range(0, 2): a_o.append(util.put_check(a_outs[i + 1], i)) a_i.append(a_ins[i + 1].get() != None) print d_o return [x for sublist in [d_i, a_i, d_o, a_o] for x in sublist]
def turn_off(self): command = PV('c_p0_command') state = PV('r_p0_state') c_on_off = PV('c_p0_on_off') r_on_off = PV('r_p0_on_off') c_normal = PV('c_p0_normal') c_faulted = PV('c_p0_faulted') c_freq = PV('c_p0_freq') util.put_check(c_normal, 0) util.put_check(c_faulted, 0) util.put_check(c_freq, 1) print state.get() if state.get() in (0.0, 3.0, 5.0): util.put_check(c_on_off, 1) util.put_check(c_on_off, 0) return state.get()