fixes tests
Example Action / Lint (push) Successful in 2s
Example Action / BuildAndTest (push) Successful in 37s

This commit is contained in:
2026-06-05 14:22:05 +02:00
parent 521deaa921
commit 008a879d75
3 changed files with 21 additions and 16 deletions
+1 -1
View File
@@ -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)
+3 -3
View File
@@ -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:
+17 -12
View File
@@ -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")