mirror of
				https://github.com/thingsboard/thingsboard-gateway
				synced 2025-10-26 22:31:42 +08:00 
			
		
		
		
	Fixed Modbus Slaves stopping
This commit is contained in:
		
							parent
							
								
									618d2d411f
								
							
						
					
					
						commit
						3e951c092c
					
				|  | @ -302,6 +302,11 @@ class ModbusConnector(Connector, Thread): | |||
|     def close(self): | ||||
|         self.__stopped = True | ||||
|         self.__stop_connections_to_masters() | ||||
| 
 | ||||
|         # Stop all slaves | ||||
|         for slave in self.__slaves: | ||||
|             slave.close() | ||||
| 
 | ||||
|         if reactor.running: | ||||
|             ServerStop() | ||||
|         self.__log.info('%s has been stopped.', self.get_name()) | ||||
|  |  | |||
|  | @ -71,6 +71,7 @@ class Slave(Thread): | |||
| 
 | ||||
|         self.last_polled_time = None | ||||
|         self.daemon = True | ||||
|         self.stop = False | ||||
| 
 | ||||
|         self.start() | ||||
| 
 | ||||
|  | @ -78,7 +79,7 @@ class Slave(Thread): | |||
|         self.callback(self) | ||||
|         self.last_polled_time = time() | ||||
| 
 | ||||
|         while True: | ||||
|         while not self.stop: | ||||
|             if time() - self.last_polled_time >= self.poll_period: | ||||
|                 self.callback(self) | ||||
|                 self.last_polled_time = time() | ||||
|  | @ -88,6 +89,9 @@ class Slave(Thread): | |||
|     def run(self): | ||||
|         self.timer() | ||||
| 
 | ||||
|     def close(self): | ||||
|         self.stop = True | ||||
| 
 | ||||
|     def get_name(self): | ||||
|         return self.name | ||||
| 
 | ||||
|  |  | |||
|  | @ -477,7 +477,8 @@ class TBGatewayService: | |||
|                     # self.__check_shared_attributes() | ||||
| 
 | ||||
|                 if cur_time - connectors_configuration_check_time > self.__config["thingsboard"].get( | ||||
|                         "checkConnectorsConfigurationInSeconds", 60) * 1000: | ||||
|                         "checkConnectorsConfigurationInSeconds", 60) * 1000 and not ( | ||||
|                         self.__remote_configurator is not None and self.__remote_configurator.in_process): | ||||
|                     self.check_connector_configuration_updates() | ||||
|                     connectors_configuration_check_time = time() * 1000 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 samson0v
						samson0v