Ejemplo n.º 1
0
 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 = {}
Ejemplo n.º 2
0
 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)
Ejemplo n.º 3
0
 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
Ejemplo n.º 4
0
 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
Ejemplo n.º 5
0
 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)
Ejemplo n.º 6
0
 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)
Ejemplo n.º 7
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)
Ejemplo n.º 8
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,
     )
Ejemplo n.º 9
0
 def _settag(self, tag, value):
     AbstractHandler._settag(self, tag, value)
     if str(value) == '1':
         self.run_action(tag)
Ejemplo n.º 10
0
 def gettag(self, tag):
     if tag in self.temp_tags:
         return int(self.temp_tags[tag])
     return AbstractHandler.gettag(self, tag)
Ejemplo n.º 11
0
 def stop(self):
     AbstractHandler.stop(self)
     if self.lc:
         self.lc.stop()
Ejemplo n.º 12
0
 def start(self):
     AbstractHandler.start(self)
     self.lc = LoopingCall(self.updatedate)
     self.lc.start(1)
Ejemplo n.º 13
0
 def stop(self):
     AbstractHandler.stop(self)
     for listener in self.listeners:
         self._set_listeners(listener, 0)
     reactor.stop()
Ejemplo n.º 14
0
 def gettag(self, tag):
     if tag in self.temp_tags:
         return int(self.temp_tags[tag])
     return AbstractHandler.gettag(self, tag)
Ejemplo n.º 15
0
 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')
Ejemplo n.º 16
0
 def stop(self):
     AbstractHandler.stop(self)
     if self.lc:
         self.lc.stop()
Ejemplo n.º 17
0
 def _settag(self, tag, value):
     AbstractHandler._settag(self, tag, value)
     if str(value) == '1':
         self.run_action(tag)
Ejemplo n.º 18
0
 def stop(self):
     AbstractHandler.stop(self)
Ejemplo n.º 19
0
 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 = {}
Ejemplo n.º 20
0
 def start(self):
     AbstractHandler.start(self)
     self.lc = LoopingCall(self.updatedate)
     self.lc.start(1)
Ejemplo n.º 21
0
 def start(self):
     AbstractHandler.start(self)
     self.port = reactor.listenTCP(int(self.params["port"]), self.site)
Ejemplo n.º 22
0
 def stop(self):
     AbstractHandler.stop(self)
     if self.port:
         self.port.stopListening()
Ejemplo n.º 23
0
 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')
Ejemplo n.º 24
0
 def stop(self):
     AbstractHandler.stop(self)
Ejemplo n.º 25
0
 def stop(self):
     AbstractHandler.stop(self)
     for listener in self.listeners:
         self._set_listeners(listener, 0)
     reactor.stop()