read coils
This commit is contained in:
@@ -4,12 +4,12 @@ steps:
|
||||
settings:
|
||||
repo: gitea.hottis.de/wn/digitaltwin1
|
||||
registry:
|
||||
from_secret: container_registry
|
||||
from_secret: local_registry
|
||||
tags: latest,${CI_COMMIT_SHA},${CI_COMMIT_TAG}
|
||||
username:
|
||||
from_secret: container_registry_username
|
||||
from_secret: local_username
|
||||
password:
|
||||
from_secret: container_registry_password
|
||||
from_secret: local_password
|
||||
dockerfile: Dockerfile
|
||||
when:
|
||||
- event: [push, tag]
|
||||
|
||||
@@ -12,6 +12,7 @@ data:
|
||||
MQTT__BROKER: "emqx01-anonymous-cluster-internal.broker.svc.cluster.local"
|
||||
MQTT__DIGITALOUTPUTTOPICPREFIX: "dt1/coil"
|
||||
MQTT__DIGITALINPUTTOPICPREFIX: "dt1/di"
|
||||
MQTT__COILINPUTTOPICPREFIX: "dt1/ci"
|
||||
MQTT__ANALOGINPUTEVENTTOPICPREFIX: "dt1/ai/event"
|
||||
MQTT__ANALOGINPUTPERIODICTOPICPREFIX: "dt1/ai/periodic"
|
||||
MQTT__ANALOGINPUTPUBLISHPERIOD: "60.0"
|
||||
|
||||
@@ -22,6 +22,7 @@ class MqttEventPublisher(AbstractMqttPublisher):
|
||||
continue
|
||||
|
||||
discreteInputChangeset = self.processImage.getChangedDiscreteInputs()
|
||||
coilInputChangeset = self.processImage.getChangedCoils()
|
||||
if not self.disableAnalogInputEventPublishing:
|
||||
analogInputChangeset = self.processImage.getChangedAnalogsInputs()
|
||||
|
||||
@@ -34,6 +35,15 @@ class MqttEventPublisher(AbstractMqttPublisher):
|
||||
str(discreteInputChangeItem[1][0]),
|
||||
retain=True)
|
||||
|
||||
for coilInputChangeItem in coilInputChangeset:
|
||||
logger.debug("Coil input {} changed from {} to {}"
|
||||
.format(coilInputChangeItem[0],
|
||||
coilInputChangeItem[1][1],
|
||||
coilInputChangeItem[1][0]))
|
||||
self.client.publish("{}/{}".format(self.config["coilInputTopicPrefix"], str(coilInputChangeItem[0])),
|
||||
str(coilInputChangeItem[1][0]),
|
||||
retain=True)
|
||||
|
||||
if not self.disableAnalogInputEventPublishing:
|
||||
for analogInputChangeItem in analogInputChangeset:
|
||||
logger.debug("Analog input {} changed from {} to {}"
|
||||
|
||||
@@ -64,12 +64,12 @@ class ProcessImage(Condition):
|
||||
self.coils[coilNum] = value
|
||||
self.coilEvent.set()
|
||||
|
||||
# def getChangedCoils(self):
|
||||
# if not self.initialized:
|
||||
# raise NotInitializedException
|
||||
# changedCoils = zippingFilter(self.coils, self.shadowCoils)
|
||||
def getChangedCoils(self):
|
||||
if not self.initialized:
|
||||
raise NotInitializedException
|
||||
changedCoils = zippingFilter(self.coils, self.shadowCoils)
|
||||
# self.shadowCoils = self.coils
|
||||
# return changedCoils
|
||||
return changedCoils
|
||||
|
||||
def getCoils(self):
|
||||
if not self.initialized:
|
||||
|
||||
@@ -6,6 +6,7 @@ class Config:
|
||||
'mqtt': [ 'broker',
|
||||
'digitalOutputTopicPrefix',
|
||||
'digitalInputTopicPrefix',
|
||||
'coilInputTopicPrefix',
|
||||
'analogInputEventTopicPrefix',
|
||||
'analogInputPeriodicTopicPrefix',
|
||||
'analogInputPublishPeriod',
|
||||
|
||||
Reference in New Issue
Block a user