diff --git a/devices/Statistics.py b/devices/Statistics.py index 917609e5850dc9bf6c2975e59e21d0265df815da..7625ef54edfdb4f7a125b9ee45f173a2bab60632 100644 --- a/devices/Statistics.py +++ b/devices/Statistics.py @@ -36,7 +36,7 @@ class SST(hardware_device): # ----------------- SST_Port = device_property( - dtype='DevULong', + dtype='DevUShort', mandatory=True ) @@ -45,8 +45,8 @@ class SST(hardware_device): # ---------- # -------- - packet_count_R = attribute_wrapper(comms_annotation={"parameter": "packet_count"}, datatype=numpy.int64) - timestamp_R = attribute_wrapper(comms_annotation={"parameter": "timestamp"}, datatype=numpy.int64) + packet_count_R = attribute_wrapper(comms_annotation={"parameter": "packet_count_R"}, datatype=numpy.int64) + last_packet_timestamp_R = attribute_wrapper(comms_annotation={"parameter": "last_packet_timestamp_R"}, datatype=numpy.int64) # -------- # overloaded functions @@ -73,7 +73,7 @@ class SST(hardware_device): except Exception as e: # use the pass function instead of setting read/write fails i.set_pass_func() - self.warn_stream("error while setting the sst attribute {} read/write function. {}".format(i, e)) + self.warn_stream("error while setting the sst attribute {} read/write function. {}. using pass function instead".format(i, e)) pass self.sst_client.start() diff --git a/devices/clients/sst_client.py b/devices/clients/sst_client.py index e05d26ccfb9bd9f290cdbf0624102c121a7e9e49..bd137bfecfb8c6395ceb1702bc3770e65f72e89b 100644 --- a/devices/clients/sst_client.py +++ b/devices/clients/sst_client.py @@ -153,8 +153,8 @@ class SST(Thread): self.last_packet = None self.parameters = { - "packet_count": numpy.int64(0), - "timestamp": numpy.int64(0) + "packet_count_R": numpy.int64(0), + "last_packet_timestamp_R": numpy.int64(0) } super().__init__() @@ -166,17 +166,17 @@ class SST(Thread): while True: if len(self.deque) > 0: - packet = self.deque.pop() + packet = self.deque.popleft() # if packet is None: # break - self.decode(packet) + self.process_packet(packet) def __del__(self): self.deque.appendleft(None) self.join() - def decode(self, packet): - self.parameters["packet_count"] = self.parameters["packet_count"] + numpy.int64(1) - self.parameters["timestamp"] = numpy.int64(int(time.time())) + def process_packet(self, packet): + self.parameters["packet_count_R"] += 1 + self.parameters["last_packet_timestamp_R"] = numpy.int64(int(time.time())) diff --git a/devices/udp_simulator.py b/devices/udp_simulator.py index e9415ffb6408da80e4aff260434e1f4109652c7a..9720cff969f4db0a1f406359512036357b224076 100644 --- a/devices/udp_simulator.py +++ b/devices/udp_simulator.py @@ -9,14 +9,14 @@ MESSAGE = "{}".format(i) print("UDP target IP: %s" % UDP_IP) print("UDP target port: %s" % UDP_PORT) -print("message: %s" % MESSAGE) -sock = socket.socket(socket.AF_INET, # Internet - socket.SOCK_DGRAM) # UDP +sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # create UDP socket while True: sock.sendto(bytes(MESSAGE, "utf-8"), (UDP_IP, UDP_PORT)) i += 1 MESSAGE = "{}".format(i) + + #sleep for an arbitrary amount of time. Currently 0.2 settings for visual testing. time.sleep(0.2) - # time.sleep(0.1) +