|
@@ -359,8 +359,8 @@ class TestService(object):
|
|
self.__receiver2 = None
|
|
self.__receiver2 = None
|
|
self.__task_reset_error_rate_percent: bool = False
|
|
self.__task_reset_error_rate_percent: bool = False
|
|
self.__speed_timer: float = 0
|
|
self.__speed_timer: float = 0
|
|
- self.__speed_kbps: float = 0
|
|
|
|
- self.__speed_kbps2: float = 0
|
|
|
|
|
|
+ self.speed_kbps: float = 0
|
|
|
|
+ self.speed_kbps2: float = 0
|
|
self.__rev_timer_sec: float = time.time()
|
|
self.__rev_timer_sec: float = time.time()
|
|
self.__rev_timeout_sec: float = 2
|
|
self.__rev_timeout_sec: float = 2
|
|
|
|
|
|
@@ -521,21 +521,21 @@ class TestService(object):
|
|
else:
|
|
else:
|
|
error_rate_percent: float = 0.0
|
|
error_rate_percent: float = 0.0
|
|
self.error_rate_push(error_rate_percent, receiver_number)
|
|
self.error_rate_push(error_rate_percent, receiver_number)
|
|
- self.__update_speed(count_all, count_error_all, receiver_number)
|
|
|
|
|
|
+ self.__update_speed(count_all, pkg_lose_bytes, receiver_number)
|
|
return count_all, pkg_lose_bytes, count_error_all
|
|
return count_all, pkg_lose_bytes, count_error_all
|
|
else:
|
|
else:
|
|
return 0, 0, 0
|
|
return 0, 0, 0
|
|
|
|
|
|
- def __update_speed(self, count_all_bytes, count_error_bytes, receiver_number: int = None):
|
|
|
|
|
|
+ def __update_speed(self, count_all_bytes, pkg_lose_bytes, receiver_number: int = None):
|
|
get_time = time.time() - self.__speed_timer
|
|
get_time = time.time() - self.__speed_timer
|
|
if get_time != 0:
|
|
if get_time != 0:
|
|
- speed_kbps = (count_all_bytes - count_error_bytes) * 8 / (1000 * get_time)
|
|
|
|
|
|
+ speed_kbps = (count_all_bytes - pkg_lose_bytes) * 8 / (1000 * get_time)
|
|
else:
|
|
else:
|
|
speed_kbps = 0
|
|
speed_kbps = 0
|
|
if receiver_number == 2:
|
|
if receiver_number == 2:
|
|
- self.__speed_kbps2 = speed_kbps
|
|
|
|
|
|
+ self.speed_kbps2 = speed_kbps
|
|
else:
|
|
else:
|
|
- self.__speed_kbps = speed_kbps
|
|
|
|
|
|
+ self.speed_kbps = speed_kbps
|
|
|
|
|
|
def test_service(self, sender: PLCDeviceSender, receiver: PLCDeviceReceiver,
|
|
def test_service(self, sender: PLCDeviceSender, receiver: PLCDeviceReceiver,
|
|
receiver2: Optional[PLCDeviceReceiver] = None):
|
|
receiver2: Optional[PLCDeviceReceiver] = None):
|
|
@@ -582,7 +582,7 @@ class TestService(object):
|
|
self.__tester_output(f"error_rate: {self.error_rate_percent} %", if_print)
|
|
self.__tester_output(f"error_rate: {self.error_rate_percent} %", if_print)
|
|
self.__tester_output(f"DBG: 发包={self.__sender.send_pkg_number} 收包={self.__receiver.receive_pkg}",
|
|
self.__tester_output(f"DBG: 发包={self.__sender.send_pkg_number} 收包={self.__receiver.receive_pkg}",
|
|
if_print)
|
|
if_print)
|
|
- self.__tester_output(f"speed: {self.__speed_kbps} kbps", if_print)
|
|
|
|
|
|
+ self.__tester_output(f"speed: {self.speed_kbps} kbps", if_print)
|
|
self.__receiver.pull_up_signal_when_receiving = False
|
|
self.__receiver.pull_up_signal_when_receiving = False
|
|
time.sleep(self.__sender.sleep_sec_every_step)
|
|
time.sleep(self.__sender.sleep_sec_every_step)
|
|
if self.__sender.send_pkg_number % 10 == 0:
|
|
if self.__sender.send_pkg_number % 10 == 0:
|
|
@@ -600,14 +600,14 @@ class TestService(object):
|
|
self.__tester_output(f"error_rate: {self.error_rate_percent} %", if_print)
|
|
self.__tester_output(f"error_rate: {self.error_rate_percent} %", if_print)
|
|
self.__tester_output(f"DBG: 发包={self.__sender.send_pkg_number} 收包={self.__receiver.receive_pkg}",
|
|
self.__tester_output(f"DBG: 发包={self.__sender.send_pkg_number} 收包={self.__receiver.receive_pkg}",
|
|
if_print)
|
|
if_print)
|
|
- self.__tester_output(f"speed: {self.__speed_kbps} kbps", if_print)
|
|
|
|
|
|
+ self.__tester_output(f"speed: {self.speed_kbps} kbps", if_print)
|
|
self.__tester_output(f"Receiver [2]:", if_print)
|
|
self.__tester_output(f"Receiver [2]:", if_print)
|
|
self.__tester_output(
|
|
self.__tester_output(
|
|
f"all: {count_all2 * 8} bit, lose: {pkg_lose_bytes2 * 8} bit, error: {count_error2 * 8} bit", if_print)
|
|
f"all: {count_all2 * 8} bit, lose: {pkg_lose_bytes2 * 8} bit, error: {count_error2 * 8} bit", if_print)
|
|
self.__tester_output(f"error_rate: {self.error_rate_percent2} %", if_print)
|
|
self.__tester_output(f"error_rate: {self.error_rate_percent2} %", if_print)
|
|
self.__tester_output(f"DBG: 发包={self.__sender.send_pkg_number} 收包={self.__receiver2.receive_pkg}",
|
|
self.__tester_output(f"DBG: 发包={self.__sender.send_pkg_number} 收包={self.__receiver2.receive_pkg}",
|
|
if_print)
|
|
if_print)
|
|
- self.__tester_output(f"speed: {self.__speed_kbps2} kbps", if_print)
|
|
|
|
|
|
+ self.__tester_output(f"speed: {self.speed_kbps2} kbps", if_print)
|
|
self.__receiver.pull_up_signal_when_receiving = False
|
|
self.__receiver.pull_up_signal_when_receiving = False
|
|
time.sleep(self.__sender.sleep_sec_every_step)
|
|
time.sleep(self.__sender.sleep_sec_every_step)
|
|
if self.__sender.send_pkg_number % 10 == 0:
|
|
if self.__sender.send_pkg_number % 10 == 0:
|