def __init__(self, parent=None, params={}): AbstractHandler.__init__(self, parent, params) self.actions = { 'setter': self.setter, 'switcher': self.switcher, 'sleep': self.sleep } self.temp_tags = {}
def __init__(self, parent=None, params={}): self.cachemax = 255 self.eventcache = OrderedDict() self.params = params AbstractHandler.__init__(self, parent, params) self.logger.info("Init web handler") resource = File(params["wwwPath"]) root = Resource() root.putChild("www", resource) root.putChild("get", smhs_web(parent)) #root.putChild("mon", monitor(self.eventcache)) self.site = server.Site(root)
def _settag(self, tag, value): self.logger.debug("Setting tag %s to %s" % (tag, value)) l = tag.split("_") # try: if len(l) == 2: if l[0] == __name__: if self._tags[l[1]] != value: self._set_listeners(l[1], value) AbstractHandler._settag(self, l[1], value) else: self.listeners[l[0]].settag(l[1], value) else: self._tags[tag] = value
def __init__(self, parent=None, params={}): AbstractHandler.__init__(self, parent, params) self.logger.info("Init async_plchandler") serverconfig = params["server"] self.serial_port = params["port"] self.pollint = serverconfig["pollingTimeout"] self.packetSize = int(serverconfig["packetSize"]) self.tagslist = {} self.writepool = {} self._inputctags = {} self._inputtag_threshold = int(serverconfig["counter_threshold"]) #fill tagslist with tags from all types for tagtype in self.config: self.tagslist.update(self.config[tagtype]) #fill address list self.full_address_list = {} for x in self.tagslist: if "address" in self.tagslist[x]: address = self.tagslist[x]["address"] self.full_address_list[int(address)] = x self.logger.debug("Full address list - %s" % self.full_address_list)
def __init__(self, parent=None, params={}): AbstractHandler.__init__(self, parent, params) self.logger.info("Init async_plchandler") serverconfig = params["server"] self.serial_port = params["port"] self.pollint = serverconfig["pollingTimeout"] self.packetSize = int(serverconfig["packetSize"]) self.tagslist = {} self.writepool = {} self._inputctags = {} self._inputtag_threshold = int(serverconfig["counter_threshold"]) # fill tagslist with tags from all types for tagtype in self.config: self.tagslist.update(self.config[tagtype]) # fill address list self.full_address_list = {} for x in self.tagslist: if "address" in self.tagslist[x]: address = self.tagslist[x]["address"] self.full_address_list[int(address)] = x self.logger.debug("Full address list - %s" % self.full_address_list)
def start(self): AbstractHandler.start(self) framer = ModbusFramer(ClientDecoder()) pol_list = {} for t in self.config.keys(): if t in ["output", "input", "inputc"]: address_list = {} for x in self.config[t]: address = self.tagslist[x]["address"] address_list[address] = x pol_list[t] = self._generate_address_map(address_list) factory = SMHSFactory(framer, pol_list, self.logger, self.reader, self.writepool) SerialModbusClient(factory, "/dev/plc", reactor, baudrate=9600, parity=PARITY_EVEN, bytesize=SEVENBITS, stopbits=STOPBITS_TWO, timeout=0)
def start(self): AbstractHandler.start(self) framer = ModbusFramer(ClientDecoder()) pol_list = {} for t in self.config.keys(): if t in ["output", "input", "inputc"]: address_list = {} for x in self.config[t]: address = self.tagslist[x]["address"] address_list[address] = x pol_list[t] = self._generate_address_map(address_list) factory = SMHSFactory(framer, pol_list, self.logger, self.reader, self.writepool) SerialModbusClient( factory, "/dev/plc", reactor, baudrate=9600, parity=PARITY_EVEN, bytesize=SEVENBITS, stopbits=STOPBITS_TWO, timeout=0, )
def _settag(self, tag, value): AbstractHandler._settag(self, tag, value) if str(value) == '1': self.run_action(tag)
def gettag(self, tag): if tag in self.temp_tags: return int(self.temp_tags[tag]) return AbstractHandler.gettag(self, tag)
def stop(self): AbstractHandler.stop(self) if self.lc: self.lc.stop()
def start(self): AbstractHandler.start(self) self.lc = LoopingCall(self.updatedate) self.lc.start(1)
def stop(self): AbstractHandler.stop(self) for listener in self.listeners: self._set_listeners(listener, 0) reactor.stop()
def __init__(self, parent=None, params={}): assert "configfile" in params, "no param configfile" self.listeners = {} AbstractHandler.__init__(self, parent, params) params = self.config[__name__]["params"] self.logger.info('Init core server')
def stop(self): AbstractHandler.stop(self)
def __init__(self, parent=None, params={}): AbstractHandler.__init__(self, parent, params) self.actions = {'setter': self.setter, 'switcher': self.switcher, 'sleep': self.sleep} self.temp_tags = {}
def start(self): AbstractHandler.start(self) self.port = reactor.listenTCP(int(self.params["port"]), self.site)
def stop(self): AbstractHandler.stop(self) if self.port: self.port.stopListening()