a couple of fixes and daemon=True disabled

This commit is contained in:
Wolfgang Hottgenroth 2019-07-27 23:56:19 +01:00
parent cab0aec533
commit b6077b0ec8
8 changed files with 18 additions and 15 deletions

View File

@ -428,9 +428,9 @@ class CmdServer(threading.Thread):
super().__init__()
self.config = config
self.server = MyThreadingTCPServer((config.cmdAddress, config.cmdPort), CmdHandle, MyCmdUserData(config, notifier, registers))
self.daemon = True
# self.daemon = True
def start(self):
def run(self):
self.server.serve_forever()

View File

@ -20,7 +20,7 @@ class CommunicationProcessor(threading.Thread):
self.pubQueue = pubQueue
# wiringpi.wiringPiSetup()
# wiringpi.pinMode(ERROR_PIN, wiringpi.OUTPUT)
self.daemon = True
# self.daemon = True
if self.config.modbusDebug:
logging.getLogger('pymodbus').setLevel(logging.DEBUG)
else:

View File

@ -13,5 +13,5 @@ class Config(object):
self.serialPort = '/dev/ttyAMA0'
self.serialBaudRate = 9600
self.interCommDelay = 0.025
self.heartbeatTopic = 'Iot/Heartbeat/Modbus2'
self.heartbeatPeriod = 10.0
self.heartbeatTopic = 'IoT/Heartbeat/Modbus2'
self.heartbeatPeriod = 10.0

View File

@ -8,7 +8,7 @@ class Heartbeat(threading.Thread):
super().__init__()
self.config = config
self.pubQueue = pubQueue
self.daemon = True
# self.daemon = True
self.logger = logging.getLogger('Heartbeat')
def run(self):

View File

@ -9,6 +9,9 @@ class PublishItem(object):
self.topic = topic
self.payload = payload
def __str__(self):
return 'Topic: {0}, Payload: {1}'.format(self.topic, self.payload)
def mqttOnConnectCallback(client, userdata, flags, rc):
userdata.onConnect()
@ -28,7 +31,7 @@ class MqttProcessor(threading.Thread, AbstractNotificationReceiver):
self.client = mqtt.Client(userdata=self)
self.subscriptions = []
self.topicRegisterMap ={}
self.daemon = True
# self.daemon = True
self.logger = logging.getLogger('MqttProcessor')
def __processUpdatedRegisters(self, force=False):
@ -67,6 +70,7 @@ class MqttProcessor(threading.Thread, AbstractNotificationReceiver):
while True:
pubItem = self.pubQueue.get()
if isinstance(pubItem, PublishItem):
self.logger.debug('Publishing {0!s}'.format(pubItem))
self.client.publish(pubItem.topic, pubItem.payload)
Pins.pinsWrite('MSG', False)
else:

View File

@ -23,5 +23,5 @@ class MyRS485(serial.Serial):
if self.buf[0] & termios.TIOCSER_TEMT:
break
# wiringpi.digitalWrite(DE_PIN, wiringpi.LOW)
Pins.pinsWrite('DE', False
Pins.pinsWrite('DE', False)

View File

@ -10,7 +10,7 @@ class ScanRateConsideringQueueFeeder(threading.Thread, AbstractNotificationRecei
self.registers = registers
self.queue = queue
self.delayEvent = threading.Event()
self.daemon = True
# self.daemon = True
self.logger = logging.getLogger('ScanRateConsideringQueueFeeder')
def getMinimalScanrate(self):

View File

@ -49,16 +49,15 @@ if __name__ == "__main__":
mp.start()
logger.debug('MqttProcessor started')
qf = ScanRateConsideringQueueFeeder.ScanRateConsideringQueueFeeder(config, datapoints, queue)
nf.register(qf)
qf.start()
logger.debug('ScanRateConsideringQueueFeeder started')
cs = CmdServer.CmdServer(config, nf, datapoints)
cs.start()
logger.debug('CmdServer started')
hb = Heartbeat.HeartBeat(config, pubQueue)
hb = Heartbeat.Heartbeat(config, pubQueue)
hb.start()
logger.debug('Heartbeat started')
qf = ScanRateConsideringQueueFeeder.ScanRateConsideringQueueFeeder(config, datapoints, queue)
nf.register(qf)
qf.start()
logger.debug('ScanRateConsideringQueueFeeder started')