S allius/issue131 (#132)
* Make __publish_outstanding_mqtt public * update proxy counter - on client mode connection establishment or disconnecting update tje counection counter
This commit is contained in:
@@ -44,7 +44,7 @@ class AsyncStream():
|
|||||||
to = self.MAX_CLOUD_IDLE_TIME
|
to = self.MAX_CLOUD_IDLE_TIME
|
||||||
return to
|
return to
|
||||||
|
|
||||||
async def __publish_outstanding_mqtt(self):
|
async def publish_outstanding_mqtt(self):
|
||||||
'''Publish all outstanding MQTT topics'''
|
'''Publish all outstanding MQTT topics'''
|
||||||
try:
|
try:
|
||||||
if self.unique_id:
|
if self.unique_id:
|
||||||
@@ -58,10 +58,10 @@ class AsyncStream():
|
|||||||
logger.info(f'[{self.node_id}:{self.conn_no}] '
|
logger.info(f'[{self.node_id}:{self.conn_no}] '
|
||||||
f'Accept connection from {addr}')
|
f'Accept connection from {addr}')
|
||||||
self.inc_counter('Inverter_Cnt')
|
self.inc_counter('Inverter_Cnt')
|
||||||
await self.__publish_outstanding_mqtt()
|
await self.publish_outstanding_mqtt()
|
||||||
await self.loop()
|
await self.loop()
|
||||||
self.dec_counter('Inverter_Cnt')
|
self.dec_counter('Inverter_Cnt')
|
||||||
await self.__publish_outstanding_mqtt()
|
await self.publish_outstanding_mqtt()
|
||||||
logger.info(f'[{self.node_id}:{self.conn_no}] Server loop stopped for'
|
logger.info(f'[{self.node_id}:{self.conn_no}] Server loop stopped for'
|
||||||
f' r{self.r_addr}')
|
f' r{self.r_addr}')
|
||||||
|
|
||||||
|
|||||||
@@ -24,10 +24,12 @@ class ModbusConn():
|
|||||||
logging.info(f'[{self.stream.node_id}:{self.stream.conn_no}] '
|
logging.info(f'[{self.stream.node_id}:{self.stream.conn_no}] '
|
||||||
f'Connected to {self.addr}')
|
f'Connected to {self.addr}')
|
||||||
self.stream.inc_counter('Inverter_Cnt')
|
self.stream.inc_counter('Inverter_Cnt')
|
||||||
|
await self.stream.publish_outstanding_mqtt()
|
||||||
return self.stream
|
return self.stream
|
||||||
|
|
||||||
async def __aexit__(self, exc_type, exc, tb):
|
async def __aexit__(self, exc_type, exc, tb):
|
||||||
self.stream.dec_counter('Inverter_Cnt')
|
self.stream.dec_counter('Inverter_Cnt')
|
||||||
|
await self.stream.publish_outstanding_mqtt()
|
||||||
|
|
||||||
|
|
||||||
class ModbusTcp():
|
class ModbusTcp():
|
||||||
|
|||||||
Reference in New Issue
Block a user