can receive both monitor and detector udp events and send them to different kafka topics
This commit is contained in:
@@ -15,5 +15,6 @@ dbLoadRecords("$(StreamGenerator_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME),
|
||||
dbLoadRecords("$(StreamGenerator_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PORT=ASYN_SG, CHANNEL=1")
|
||||
dbLoadRecords("$(StreamGenerator_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PORT=ASYN_SG, CHANNEL=2")
|
||||
dbLoadRecords("$(StreamGenerator_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PORT=ASYN_SG, CHANNEL=3")
|
||||
dbLoadRecords("$(StreamGenerator_DB)channels.db", "INSTR=$(INSTR), NAME=$(NAME), PORT=ASYN_SG, CHANNEL=4")
|
||||
|
||||
iocInit()
|
||||
|
||||
@@ -54,19 +54,50 @@ while True:
|
||||
|
||||
tosend = list(header)
|
||||
|
||||
for i in range(num_events):
|
||||
d = list(data)
|
||||
# I believe, that in our case we never mix monitor and detector events as
|
||||
# the monitors should have id 0 and the detector events 1-9 so I have
|
||||
# excluded that posibility here. That would, however, if true mean we could
|
||||
# reduce also the number of checks on the parsing side of things...
|
||||
|
||||
# set monitor
|
||||
d[5] = (1 << 7) | random.randint(0,3)
|
||||
is_monitor = random.randint(0, 9)
|
||||
|
||||
# update trigger timestamp
|
||||
event_timestamp = (time.time_ns() // 100) - base_timestamp
|
||||
d[0] = event_timestamp & 0xff
|
||||
d[1] = (event_timestamp >> 8) & 0xff
|
||||
d[2] = (event_timestamp >> 16) & 0x07
|
||||
if is_monitor > 3:
|
||||
|
||||
tosend += d
|
||||
for i in range(num_events):
|
||||
d = list(data)
|
||||
|
||||
monitor = random.randint(0,3)
|
||||
|
||||
d[5] = (1 << 7) | monitor
|
||||
|
||||
# update trigger timestamp
|
||||
event_timestamp = (time.time_ns() // 100) - base_timestamp
|
||||
d[0] = event_timestamp & 0xff
|
||||
d[1] = (event_timestamp >> 8) & 0xff
|
||||
d[2] = (event_timestamp >> 16) & 0x07
|
||||
|
||||
tosend += d
|
||||
|
||||
else:
|
||||
|
||||
for i in range(num_events):
|
||||
d = list(data)
|
||||
|
||||
amplitude = random.randint(0, 255)
|
||||
x_pos = random.randint(0, 1023)
|
||||
y_pos = random.randint(0, 1023)
|
||||
event_timestamp = (time.time_ns() // 100) - base_timestamp
|
||||
|
||||
d[5] = (0 << 7) | (amplitude >> 1)
|
||||
d[4] = ((amplitude & 0x01) << 7) | (y_pos >> 3)
|
||||
d[3] = ((y_pos << 5) & 0xE0) | (x_pos >> 5)
|
||||
d[2] = ((x_pos << 3) & 0xF8)
|
||||
|
||||
d[0] = event_timestamp & 0xff
|
||||
d[1] = (event_timestamp >> 8) & 0xff
|
||||
d[2] |= (event_timestamp >> 16) & 0x07
|
||||
|
||||
tosend += d
|
||||
|
||||
sock.sendto(bytes(tosend), ('127.0.0.1', 54321))
|
||||
mv = memoryview(bytes(header)).cast('H')
|
||||
|
||||
Reference in New Issue
Block a user