4 Commits
0.0.2 ... 0.0.7

5 changed files with 8 additions and 6 deletions

View File

@ -27,5 +27,5 @@ WORKDIR ${APP_DIR}
VOLUME ${CONF_DIR} VOLUME ${CONF_DIR}
CMD "python digitaltwin1.py -f ./config/config.ini" CMD [ "/usr/local/bin/python", "digitaltwin1.py", "-f", "./config/config.ini" ]

View File

@ -12,7 +12,7 @@ def modbusStart(config, processImage):
def modbusHandler(config, processImage): def modbusHandler(config, processImage):
modbusClient = config["modbus"]["client"] modbusClient = config["modbus"]["client"]
modbusRefreshPeriod = config["modbus"]["scanrate"] modbusRefreshPeriod = float(config["modbus"]["scanrate"])
client = ModbusClient(modbusClient) client = ModbusClient(modbusClient)

View File

@ -15,7 +15,7 @@ class MqttCoilSubscriber(AbstractMqttPublisher):
def localLoop(self): def localLoop(self):
while True: while True:
sleep(self.config["analogInputPublishPeriod"]) sleep(float(self.config["analogInputPublishPeriod"]))
def onMessage(self, topic, payload): def onMessage(self, topic, payload):
logger.warning("mqtt message received: {} -> {}".format(topic, str(payload))) logger.warning("mqtt message received: {} -> {}".format(topic, str(payload)))

View File

@ -27,7 +27,8 @@ class MqttEventPublisher(AbstractMqttPublisher):
discreteInputChangeItem[1][1], discreteInputChangeItem[1][1],
discreteInputChangeItem[1][0])) discreteInputChangeItem[1][0]))
self.client.publish("{}/{}".format(self.config["digitalInputTopicPrefix"], str(discreteInputChangeItem[0])), self.client.publish("{}/{}".format(self.config["digitalInputTopicPrefix"], str(discreteInputChangeItem[0])),
str(discreteInputChangeItem[1][0])) str(discreteInputChangeItem[1][0]),
retain=True)
for analogInputChangeItem in analogInputChangeset: for analogInputChangeItem in analogInputChangeset:
logger.debug("Analog input {} changed from {} to {}" logger.debug("Analog input {} changed from {} to {}"
@ -36,6 +37,7 @@ class MqttEventPublisher(AbstractMqttPublisher):
analogInputChangeItem[1][0])) analogInputChangeItem[1][0]))
self.client.publish("{}/{}".format(self.config["analogInputEventTopicPrefix"], str(analogInputChangeItem[0])), self.client.publish("{}/{}".format(self.config["analogInputEventTopicPrefix"], str(analogInputChangeItem[0])),
str(analogInputChangeItem[1][0])) str(analogInputChangeItem[1][0]),
retain=True)

View File

@ -28,5 +28,5 @@ class MqttPeriodPublisher(AbstractMqttPublisher):
self.client.publish("{}/{}".format(self.config["analogInputPeriodicTopicPrefix"], str(analogInputItem[0])), self.client.publish("{}/{}".format(self.config["analogInputPeriodicTopicPrefix"], str(analogInputItem[0])),
str(analogInputItem[1])) str(analogInputItem[1]))
sleep(self.config["analogInputPublishPeriod"]) sleep(float(self.config["analogInputPublishPeriod"]))