def __init__(self, name): self.name = name self.clientid = config.clientid self.deviceid = config.get(self.name, 'deviceid') self.descr = config.get(self.name, 'descr', fallback='') self.host = config.get(self.name, 'host', fallback='127.0.0.1') self.port = config.getint(self.name, 'port', fallback=1883) self.username = config.get(self.name, 'username', fallback=None) self.password = config.get(self.name, 'password', fallback=None) self.transport = config.getenum(self.name, 'transport', enum=TLSTransports, fallback='tcp') csvfile = config.get(self.name, 'csvmap') csvmap = WCSVMap() self.mapping = csvmap.load(csvfile, WCSVType.XML) self.protocol = config.getenum(self.name, 'protocol', enum=MQProtocols, fallback='mqttv311') self.keepalive = config.getint(self.name, 'keepalive', fallback=60) self.topic = config.get(self.name, 'topic') self.qos = config.getint(self.name, 'qos', fallback=0) self.cacert = config.get(self.name, 'cacert', fallback=None) self.tlsenable = config.getboolean(self.name, 'tlsenable', fallback=False) self.tlsversion = config.getenum(self.name, 'tlsversion', enum=TLSVersions, fallback='tlsv1.0') self.tlsverify = config.getboolean(self.name, 'tlsverify', fallback=True) cache.store_meta(self.deviceid, self.name, self.descr, self.mapping)
def __init__(self, name): self.name = name self.lock = threading.Lock() self.clientid = config.clientid self.deviceid = config.get(self.name, 'deviceid') self.descr = config.get(self.name, 'descr', fallback='') self.port = config.get(self.name, 'port') self.slaveid = config.getint(self.name, 'slaveid', fallback=0) self.endian = config.getenum(self.name, 'endianity', enum=ModbusEndianity, fallback='little') self.stopbits = config.getfloat(self.name, 'stopbits', fallback=Defaults.Stopbits) self.bytesize = config.getint(self.name, 'bytesize', fallback=Defaults.Bytesize) self.parity = config.get(self.name, 'parity', fallback=Defaults.Parity) self.baudrate = config.getint(self.name, 'baudrate', fallback=Defaults.Baudrate) self.timeout = config.getint(self.name, 'timeout', fallback=Defaults.Timeout) csvfile = config.get(self.name, 'csvmap') csvmap = WCSVMap() self.mapping = csvmap.load(csvfile, WCSVType.Modbus) protocol = config.getenum(self.name, 'protocol', enum=ModbusProtocols, fallback='rtu') self.method = protocol cache.store_meta(self.deviceid, self.name, self.descr, self.mapping)
def __init__(self, name): self.name = name self.lock = threading.Lock() self.clientid = config.clientid self.deviceid = config.get(self.name, 'deviceid') self.descr = config.get(self.name, 'descr', fallback = '') self.host = config.get(self.name, 'host') self.port = config.getint(self.name, 'port', fallback = 102) self.ltsap = self.__str2tsap(config.get(self.name, 'ltsap')) self.ctsap = self.__str2tsap(config.get(self.name, 'ctsap')) self.version = config.getenum(self.name, 'version', enum={'logo7': 'logo7', 'logo8': 'logo8'}, fallback='logo8') csvfile = config.get(self.name, 'csvmap') csvmap = WCSVMap() self.mapping = csvmap.load(csvfile, WCSVType.Raw) self.lam = [('I', 1024, 8), ('AI', 1032, 32), ('Q', 1064, 8), ('AQ', 1072, 32), ('M', 1104, 14), ('AM', 1118, 128), ('NI', 1246, 16), ('NAI', 1262, 128), ('NQ', 1390, 16), ('NAQ', 1406, 64), ('VD', 0, 1466), ('VW', 0, 1468), ('V', 0, 1469)] if self.version == 'logo7': self.lam = [('I', 923, 3), ('AI', 926, 16), ('Q', 942, 2), ('AQ', 944, 4), ('M', 948, 4), ('AM', 952, 32), ('VD', 0, 980), ('VW', 0, 982), ('V', 0, 983)] self.__plc_validate() cache.store_meta(self.deviceid, self.name, self.descr, self.mapping) try: self.plc = s7.logo.Logo() except s7.snap7exceptions.Snap7Exception as e: logger.error('Snap7 error: %s' % str(e)) return None
def __init__(self, name): self.name = name self.clientid = config.clientid self.deviceid = config.get(self.name, 'deviceid') self.descr = config.get(self.name, 'descr', fallback='') self.host = config.get(self.name, 'host') self.port = config.getint(self.name, 'port', fallback=502) self.slaveid = config.getint(self.name, 'slaveid', fallback=0) self.endian = config.getenum(self.name, 'endianity', enum=ModbusEndianity, fallback='little') self.retries = config.getint(self.name, 'retries', fallback=3) self.backoff = config.getfloat(self.name, 'backoff', fallback=0.3) self.timeout = config.getfloat(self.name, 'timeout', fallback=3) csvfile = config.get(self.name, 'csvmap') csvmap = WCSVMap() self.mapping = csvmap.load(csvfile, WCSVType.Modbus) protocol = config.getenum(self.name, 'protocol', enum=ModbusProtocols, fallback='tcp') self.mbclient = protocol['client'] self.mbframer = protocol['framer'] cache.store_meta(self.deviceid, self.name, self.descr, self.mapping)
def __init__(self, name): self.name = name self.lock = threading.Lock() self.clientid = config.clientid self.deviceid = config.get(self.name, 'deviceid') self.descr = config.get(self.name, 'descr', fallback='') self.host = config.get(self.name, 'host') self.port = config.getint(self.name, 'port', fallback=102) self.slot = config.getint(self.name, 'slot') self.rack = config.getint(self.name, 'rack') csvfile = config.get(self.name, 'csvmap') csvmap = WCSVMap() self.mapping = csvmap.load(csvfile, WCSVType.Raw) self.lam = [('%IB', 'PE', 1), ('%IW', 'PE', 2), ('%ID', 'PE', 4), ('%I', 'PE', 1), ('%QB', 'PA', 1), ('%QW', 'PA', 2), ('%QD', 'PA', 4), ('%Q', 'PA', 1), ('%MB', 'MK', 1), ('%MW', 'MK', 2), ('%MD', 'MK', 4), ('%M', 'MK', 1), ('%DB', 'DB', 0), ('DBB', 'DB', 1), ('DBW', 'DB', 2), ('DBD', 'DB', 4), ('DBX', 'DB', 1)] self.__plc_validate() cache.store_meta(self.deviceid, self.name, self.descr, self.mapping) try: self.plc = s7.client.Client() except s7.snap7exceptions.Snap7Exception as e: logger.error('Snap7 error: %s' % str(e)) return None
def __init__(self, name): self.name = name self.clientid = config.clientid self.deviceid = config.get(self.name, 'deviceid') self.descr = config.get(self.name, 'descr', fallback='') self.host = config.get(self.name, 'host') self.port = config.getint(self.name, 'port', fallback=502) self.timeout = config.getfloat(self.name, 'timeout', fallback=3) self.xport = config.getint(self.name, 'xport') csvfile = config.get(self.name, 'csvmap') csvmap = WCSVMap() self.mapping = csvmap.load(csvfile, WCSVType.Raw) cache.store_meta(self.deviceid, self.name, self.descr, self.mapping)
def __init__(self, name): self.name = name self.clientid = config.clientid self.deviceid = config.get(self.name, 'deviceid') self.descr = config.get(self.name, 'descr', fallback = '') self.url = config.get(self.name, 'url') self.timeout = config.getint(self.name, 'timeout', fallback = 3) self.cid = config.getint(self.name, 'cid', fallback = -1) self.xport = config.getint(self.name, 'xport') csvfile = config.get(self.name, 'csvmap') csvmap = WCSVMap() self.mapping = csvmap.load(csvfile, WCSVType.Raw) cache.store_meta(self.deviceid, self.name, self.descr, self.mapping) self.__client = requests.session()
def __init__(self, name): self.name = name self.clientid = config.clientid self.deviceid = config.get(self.name, 'deviceid') self.descr = config.get(self.name, 'descr', fallback='') self.host = config.get(self.name, 'host') self.port = config.getint(self.name, 'port', fallback=502) self.slaveid = config.getint(self.name, 'slaveid', fallback=0) self.retries = config.getint(self.name, 'retries', fallback=3) self.backoff = config.getfloat(self.name, 'backoff', fallback=0.3) self.timeout = config.getfloat(self.name, 'timeout', fallback=3) csvfile = config.get(self.name, 'csvmap') csvmap = WCSVMap() self.mapping = csvmap.load(csvfile, WCSVType.Modbus) cache.store_meta(self.deviceid, self.name, self.descr, self.mapping)
def __init__(self, name): self.name = name self.wait = threading.Event() self.comm = None self.queue = queue.Queue() self.clientid = config.clientid self.deviceid = config.get(self.name, 'deviceid') self.descr = config.get(self.name, 'descr', fallback='') self.port = config.get(self.name, 'port', fallback=None) self.addr = config.get(self.name, 'addr') csvfile = config.get(self.name, 'csvmap') csvmap = WCSVMap() self.mapping = [] self.mapping = csvmap.load(csvfile, WCSVType.Raw) cache.store_meta(self.deviceid, self.name, self.descr, self.mapping)
def __init__(self, name): self.name = name self.wait = threading.Event() self.com = None self.queue = queue.Queue() self.clientid = config.clientid self.deviceid = config.get(self.name, 'deviceid') self.descr = config.get(self.name, 'descr', fallback = '') self.port = config.get(self.name, 'port', fallback = None) self.init = config.get(self.name, 'init', fallback = None) self.model = config.get(self.name, 'model', fallback = None) self.channel = config.getint(self.name, 'channel', fallback = None) self.retrytime = config.getint(self.name, 'retrytime', fallback = 0) csvfile = config.get(self.name, 'csvmap') csvmap = WCSVMap() self.mapping = csvmap.load(csvfile, WCSVType.Raw) cache.store_meta(self.deviceid, self.name, self.descr, self.mapping)
def __init__(self, name): self.name = name self.clientid = config.clientid self.deviceid = config.get(self.name, 'deviceid') self.descr = config.get(self.name, 'descr', fallback = '') self.host = config.get(self.name, 'host', fallback = '127.0.0.1') self.port = config.getint(self.name, 'port', fallback = 5672) self.retries = config.getint(self.name, 'retries', fallback = 3) self.timeout = config.getint(self.name, 'timeout', fallback = 60) self.username = config.get(self.name, 'username', fallback = None) self.password = config.get(self.name, 'password', fallback = None) self.vhost = config.get(self.name, 'vhost', fallback = '/') self.amqpurl = config.get(self.name, 'amqpurl', fallback = None) self.key = config.get(self.name, 'key') self.qos = config.getint(self.name, 'qos', fallback = 1) self.ssl = config.getboolean(self.name, 'ssl', fallback = False) self.channel = None csvfile = config.get(self.name, 'csvmap') csvmap = WCSVMap() self.mapping = csvmap.load(csvfile, WCSVType.JSON) cache.store_meta(self.deviceid, self.name, self.descr, self.mapping)