Поставил ожидание после первого вычитывания регистров
This commit is contained in:
parent
f067b12619
commit
0b4942de7d
13
endpoint.py
13
endpoint.py
@ -167,12 +167,9 @@ class Endpoint(Thread):
|
|||||||
last_row = None
|
last_row = None
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
# вычислим время до следующего опроса
|
# время следующего опроса
|
||||||
curr_time = datetime.now()
|
|
||||||
need_time = last_query + scan_rate
|
need_time = last_query + scan_rate
|
||||||
if need_time > curr_time:
|
|
||||||
delta = need_time - curr_time
|
|
||||||
time.sleep(delta.seconds + (delta.microseconds / 1000000))
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
row = self.__mb_read_all_regs()
|
row = self.__mb_read_all_regs()
|
||||||
@ -199,6 +196,12 @@ class Endpoint(Thread):
|
|||||||
time.sleep(0.1) # небольшая задержка, чтоб не спамить запросами
|
time.sleep(0.1) # небольшая задержка, чтоб не спамить запросами
|
||||||
need_time = datetime.now() + scan_rate
|
need_time = datetime.now() + scan_rate
|
||||||
|
|
||||||
|
# вычислим время до следующего опроса и подождем
|
||||||
|
curr_time = datetime.now()
|
||||||
|
if need_time > curr_time:
|
||||||
|
delta = need_time - curr_time
|
||||||
|
time.sleep(delta.seconds + (delta.microseconds / 1000000))
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
# запускаем клиента модбас
|
# запускаем клиента модбас
|
||||||
self.mb = ModbusClient(
|
self.mb = ModbusClient(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user