diff --git a/db/time.db b/db/time.db index cdc539e..54a3094 100644 --- a/db/time.db +++ b/db/time.db @@ -22,7 +22,7 @@ record(ai,"$(INSTR)$(NAME):T") record(dfanout, "$(INSTR)$(NAME):T_POLL") { - field(DESC, "Channel $(CHANNEL) poll sequence") + field(DESC, "Time channel poll sequence") field(SELM, "All") field(OMSL, "closed_loop") field(DOL, 1) diff --git a/sim/daq_sim.py b/sim/daq_sim.py index d4da2ee..1116132 100644 --- a/sim/daq_sim.py +++ b/sim/daq_sim.py @@ -134,7 +134,7 @@ class DAQ: if self.getMonitorCount() >= self.presetcount: self.counts[self.monitor] = self.presetcount if self.presetcount > 0 else self.counts[self.monitor] - self.status = 0 + self.status = 0 else: raise Exception("Invalid State") @@ -191,7 +191,7 @@ class DAQ: def setGate(self, channel, highlow): self.gate[channel - 1] = highlow - + with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: s.bind((HOST, PORT)) @@ -216,7 +216,7 @@ with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: received = '' logger.info(f'RECEIVED: "{received}"') return received - + daq = DAQ(TOTAL_CH) while True: diff --git a/test/test.py b/test/test.py index c7d45ff..af5dce4 100755 --- a/test/test.py +++ b/test/test.py @@ -42,31 +42,36 @@ def get_piped_output(proc): def getState(instr, name): result = run(['caget', f'{instr}{name}:STATUS'], stdout=PIPE) - state = result.stdout.decode('ascii').rstrip().split()[1] + state = result.stdout.decode('ascii').rstrip().split()[1] print(f'Currently in state {state}') return state def getCount(instr, name, ch): - result = run(['caget', f'{instr}{name}:M{ch}'], stdout=PIPE) + result = run(['caget', f'{instr}{name}:CH{ch}'], stdout=PIPE) count = int(result.stdout.decode('ascii').rstrip().split()[1]) - print(f'M{ch} == {count}') + print(f'CH{ch} == {count}') return count def presetTime(instr, name, time): - print(f'Starting count for {time} seconds') - run(['caput', f'{instr}{name}:PRESET-TIME', f'{time}']) + print(f'Setting preset on time channel of {time} seconds') + run(['caput', f'{instr}{name}:T_PRESET', f'{time}']) -def presetCount(instr, name, count): - print(f'Starting count until channel 1 reaches {count}') - run(['caput', f'{instr}{name}:PRESET-COUNT', f'{count}']) +def presetCount(instr, name, channel, count): + print(f'Setting preset on channel {channel} of {count} counts') + run(['caput', f'{instr}{name}:CH{channel}_PRESET', f'{count}']) + +def startCount(instr, name): + print('Starting Count') + run(['caput', f'{instr}{name}:START', '1']) def testCanCount(instr, name): # Check in Idle State assert getState(instr, name) == 'Idle', 'Not in valid state' - + # Start Time Based Count and Check that Status Changes assert getCount(instr, name, 1) == 0, "Erroneous nonzero starting count value" presetTime(instr, name, 5) + startCount(instr, name) time.sleep(1) assert getState(instr, name) == 'Counting', 'Didn\'t start counting' time.sleep(5) @@ -74,8 +79,10 @@ def testCanCount(instr, name): assert getCount(instr, name, 1) > 0, 'No events were counted' # Start Monitor Based Count and Check that Status Changes + presetChannel = 1 presetAmount = 100 - presetCount(instr, name, presetAmount) + presetCount(instr, name, presetChannel, presetAmount) + startCount(instr, name) time.sleep(1) assert getState(instr, name) == 'Counting', 'Didn\'t start counting' assert getCount(instr, name, 1) < presetAmount @@ -99,8 +106,6 @@ def test(instr, name): if 'iocRun: All initialization complete' in line: break # IOC is now running - #time.sleep(20) - print("IOC Initialisation Complete") print("Starting Tests")