a couple of fixes and daemon=True disabled
This commit is contained in:
parent
cab0aec533
commit
b6077b0ec8
@ -428,9 +428,9 @@ class CmdServer(threading.Thread):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
self.config = config
|
self.config = config
|
||||||
self.server = MyThreadingTCPServer((config.cmdAddress, config.cmdPort), CmdHandle, MyCmdUserData(config, notifier, registers))
|
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()
|
self.server.serve_forever()
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ class CommunicationProcessor(threading.Thread):
|
|||||||
self.pubQueue = pubQueue
|
self.pubQueue = pubQueue
|
||||||
# wiringpi.wiringPiSetup()
|
# wiringpi.wiringPiSetup()
|
||||||
# wiringpi.pinMode(ERROR_PIN, wiringpi.OUTPUT)
|
# wiringpi.pinMode(ERROR_PIN, wiringpi.OUTPUT)
|
||||||
self.daemon = True
|
# self.daemon = True
|
||||||
if self.config.modbusDebug:
|
if self.config.modbusDebug:
|
||||||
logging.getLogger('pymodbus').setLevel(logging.DEBUG)
|
logging.getLogger('pymodbus').setLevel(logging.DEBUG)
|
||||||
else:
|
else:
|
||||||
|
@ -13,5 +13,5 @@ class Config(object):
|
|||||||
self.serialPort = '/dev/ttyAMA0'
|
self.serialPort = '/dev/ttyAMA0'
|
||||||
self.serialBaudRate = 9600
|
self.serialBaudRate = 9600
|
||||||
self.interCommDelay = 0.025
|
self.interCommDelay = 0.025
|
||||||
self.heartbeatTopic = 'Iot/Heartbeat/Modbus2'
|
self.heartbeatTopic = 'IoT/Heartbeat/Modbus2'
|
||||||
self.heartbeatPeriod = 10.0
|
self.heartbeatPeriod = 10.0
|
@ -8,7 +8,7 @@ class Heartbeat(threading.Thread):
|
|||||||
super().__init__()
|
super().__init__()
|
||||||
self.config = config
|
self.config = config
|
||||||
self.pubQueue = pubQueue
|
self.pubQueue = pubQueue
|
||||||
self.daemon = True
|
# self.daemon = True
|
||||||
self.logger = logging.getLogger('Heartbeat')
|
self.logger = logging.getLogger('Heartbeat')
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
@ -9,6 +9,9 @@ class PublishItem(object):
|
|||||||
self.topic = topic
|
self.topic = topic
|
||||||
self.payload = payload
|
self.payload = payload
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return 'Topic: {0}, Payload: {1}'.format(self.topic, self.payload)
|
||||||
|
|
||||||
def mqttOnConnectCallback(client, userdata, flags, rc):
|
def mqttOnConnectCallback(client, userdata, flags, rc):
|
||||||
userdata.onConnect()
|
userdata.onConnect()
|
||||||
|
|
||||||
@ -28,7 +31,7 @@ class MqttProcessor(threading.Thread, AbstractNotificationReceiver):
|
|||||||
self.client = mqtt.Client(userdata=self)
|
self.client = mqtt.Client(userdata=self)
|
||||||
self.subscriptions = []
|
self.subscriptions = []
|
||||||
self.topicRegisterMap ={}
|
self.topicRegisterMap ={}
|
||||||
self.daemon = True
|
# self.daemon = True
|
||||||
self.logger = logging.getLogger('MqttProcessor')
|
self.logger = logging.getLogger('MqttProcessor')
|
||||||
|
|
||||||
def __processUpdatedRegisters(self, force=False):
|
def __processUpdatedRegisters(self, force=False):
|
||||||
@ -67,6 +70,7 @@ class MqttProcessor(threading.Thread, AbstractNotificationReceiver):
|
|||||||
while True:
|
while True:
|
||||||
pubItem = self.pubQueue.get()
|
pubItem = self.pubQueue.get()
|
||||||
if isinstance(pubItem, PublishItem):
|
if isinstance(pubItem, PublishItem):
|
||||||
|
self.logger.debug('Publishing {0!s}'.format(pubItem))
|
||||||
self.client.publish(pubItem.topic, pubItem.payload)
|
self.client.publish(pubItem.topic, pubItem.payload)
|
||||||
Pins.pinsWrite('MSG', False)
|
Pins.pinsWrite('MSG', False)
|
||||||
else:
|
else:
|
||||||
|
@ -23,5 +23,5 @@ class MyRS485(serial.Serial):
|
|||||||
if self.buf[0] & termios.TIOCSER_TEMT:
|
if self.buf[0] & termios.TIOCSER_TEMT:
|
||||||
break
|
break
|
||||||
# wiringpi.digitalWrite(DE_PIN, wiringpi.LOW)
|
# wiringpi.digitalWrite(DE_PIN, wiringpi.LOW)
|
||||||
Pins.pinsWrite('DE', False
|
Pins.pinsWrite('DE', False)
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ class ScanRateConsideringQueueFeeder(threading.Thread, AbstractNotificationRecei
|
|||||||
self.registers = registers
|
self.registers = registers
|
||||||
self.queue = queue
|
self.queue = queue
|
||||||
self.delayEvent = threading.Event()
|
self.delayEvent = threading.Event()
|
||||||
self.daemon = True
|
# self.daemon = True
|
||||||
self.logger = logging.getLogger('ScanRateConsideringQueueFeeder')
|
self.logger = logging.getLogger('ScanRateConsideringQueueFeeder')
|
||||||
|
|
||||||
def getMinimalScanrate(self):
|
def getMinimalScanrate(self):
|
||||||
|
@ -49,16 +49,15 @@ if __name__ == "__main__":
|
|||||||
mp.start()
|
mp.start()
|
||||||
logger.debug('MqttProcessor started')
|
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 = CmdServer.CmdServer(config, nf, datapoints)
|
||||||
cs.start()
|
cs.start()
|
||||||
logger.debug('CmdServer started')
|
logger.debug('CmdServer started')
|
||||||
|
|
||||||
hb = Heartbeat.HeartBeat(config, pubQueue)
|
hb = Heartbeat.Heartbeat(config, pubQueue)
|
||||||
hb.start()
|
hb.start()
|
||||||
logger.debug('Heartbeat started')
|
logger.debug('Heartbeat started')
|
||||||
|
|
||||||
|
qf = ScanRateConsideringQueueFeeder.ScanRateConsideringQueueFeeder(config, datapoints, queue)
|
||||||
|
nf.register(qf)
|
||||||
|
qf.start()
|
||||||
|
logger.debug('ScanRateConsideringQueueFeeder started')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user