Updates PLCChannel with plc_type and fixes read procedure

This commit is contained in:
Patrick McDonagh
2018-03-01 15:25:35 -06:00
parent 31fab3ab2a
commit bfded45953
2 changed files with 6 additions and 6 deletions

View File

@@ -192,7 +192,7 @@ class ModbusChannel(Channel):
class PLCChannel(Channel):
"""PLC Channel Object."""
def __init__(self, ip, mesh_name, plc_tag, data_type, chg_threshold, guarantee_sec, map_=False, write_enabled=False):
def __init__(self, ip, mesh_name, plc_tag, data_type, chg_threshold, guarantee_sec, map_=False, write_enabled=False, plc_type='CLX'):
"""Initialize the channel."""
super(PLCChannel, self).__init__(mesh_name, data_type, chg_threshold, guarantee_sec, map_, write_enabled)
self.plc_ip = ip
@@ -206,12 +206,13 @@ class PLCChannel(Channel):
self.guarantee_sec = guarantee_sec
self.map_ = map_
self.write_enabled = write_enabled
self.plc_type = plc_type
def read(self):
"""Read the value."""
plc_value = None
if self.plc_tag and self.plc_ip:
read_value = read_tag(self.plc_ip, self.plc_tag)
read_value = read_tag(self.plc_ip, self.plc_tag, plc_type=self.plc_type)
if read_value:
plc_value = read_value[0]

View File

@@ -3,9 +3,7 @@
import threading
import sys
from device_base import deviceBase
from Channel import Channel, read_tag, write_tag, BoolArrayChannels
from Maps import {{cookiecutter.driver_name}}_map as maps
from Maps import reverse_map
from Channel import Channel, read_tag, write_tag
import persistence
from random import randint
from utilities import get_public_ip_address
@@ -86,7 +84,8 @@ class start(threading.Thread, deviceBase):
logger.warning("FORCE SEND: TRUE")
for c in CHANNELS:
if c.read(self.forceSend):
v = c.read()
if c.check(self.forceSend):
self.sendtodbDev(1, c.mesh_name, c.value, 0, '{{cookiecutter.driver_name}}')