Example #1
0
 def setup(self, opts):
     bacnet.Init(opts.get('iface', 'eth0'), '47900')
     with open(opts.get('db'), 'r') as fp:
         self.db = json.load(fp)
     self.rate = int(opts.get('rate', 60))
     self.devices = map(re.compile, opts.get('devices', ['.*']))
     self.points = map(re.compile, opts.get('points', ['.*']))
     self.ffilter = _get_class(opts.get('filter')) if opts.get('filter') else None
     self.pathnamer = _get_class(opts.get('pathnamer')) if opts.get('pathnamer') else None
     for (dev, obj, path) in self._iter_points():
         unit = str(obj['unit']).strip()
         if unit.isdigit():
             unit = str(bacnet.type_str(int(unit)))
         self.add_timeseries(path, unit, data_type='double')
Example #2
0
 def setup(self, opts):
     bacnet.Init(opts.get('iface', 'eth0'), '47900')
     with open(opts.get('db'), 'r') as fp:
         self.db = json.load(fp)
     self.rate = int(opts.get('rate', 60))
     self.devices = map(re.compile, opts.get('devices', ['.*']))
     self.points = map(re.compile, opts.get('points', ['.*']))
     self.ffilter = _get_class(
         opts.get('filter')) if opts.get('filter') else None
     self.pathnamer = _get_class(
         opts.get('pathnamer')) if opts.get('pathnamer') else None
     for (dev, obj, path) in self._iter_points():
         unit = str(obj['unit']).strip()
         if unit.isdigit():
             unit = str(bacnet.type_str(int(unit)))
         self.add_timeseries(path, unit, data_type='double')
Example #3
0
    def setup(self, opts):
        bacnet.Init(opts.get('iface', 'eth0'), '47900')
        with open(opts.get('db'), 'r') as fp:
            self.db = json.load(fp)
        self.rate = int(opts.get('rate', 60))
        self.devices = map(re.compile, opts.get('devices', ['.*']))
        self.points = map(re.compile, opts.get('points', ['.*']))
        self.ffilter = _get_class(opts.get('filter')) if opts.get('filter') else None
        self.pathnamer = _get_class(opts.get('pathnamer')) if opts.get('pathnamer') else None
        self.actuators = _get_class(opts.get('actuators')) if opts.get('actuators') else None

        if self.actuators:
            act_names = [a['name'] for a in self.actuators]
        for (dev, obj, path) in self._iter_points():
            unit = str(obj['unit']).strip()
            if unit.isdigit():
                unit = str(bacnet.type_str(int(unit)))
            self.add_timeseries(path, unit, data_type='double')

            # Add actuators
            if self.actuators and obj['name'] in act_names:
                actuator = find(lambda a: a['name'] == obj['name'], self.actuators)
                setup = {'obj': obj, 'dev': dev}
                if obj['props']['type'] in [bacnet.OBJECT_ANALOG_INPUT, 
                                            bacnet.OBJECT_ANALOG_OUTPUT, 
                                            bacnet.OBJECT_ANALOG_VALUE]:
                    setup['range'] = actuator['range']
                    setup['application_tag'] = bacnet.BACNET_APPLICATION_TAG_REAL
                    act = ContinuousActuator(**setup)
                    data_type = 'double'
                elif obj['props']['type'] in [bacnet.OBJECT_BINARY_INPUT,
                                              bacnet.OBJECT_BINARY_OUTPUT,
                                              bacnet.OBJECT_BINARY_VALUE]:
                    setup['application_tag'] = bacnet.BACNET_APPLICATION_TAG_ENUMERATED
                    act = BinaryActuator(**setup)
                    data_type = 'long'
                elif obj['props']['type'] in [bacnet.OBJECT_MULTI_STATE_INPUT,
                                              bacnet.OBJECT_MULTI_STATE_OUTPUT,
                                              bacnet.OBJECT_MULTI_STATE_VALUE]:
                    setup['application_tag'] = bacnet.BACNET_APPLICATION_TAG_ENUMERATED
                    setup['states'] = actuator['states']
                    act = DiscreteActuator(**setup)
                    data_type = 'long'
                if act:
                    print "adding actuator:", path, unit, act
                    self.add_actuator(path + "_act", unit, act, data_type=data_type, write_limit=5)
Example #4
0
 def setup(self, opts):
     bacnet.Init(opts.get('iface', 'eth0'), '47900')
     with open(opts.get('db'), 'r') as fp:
         self.db = json.load(fp)
     self.rate = int(opts.get('rate', 60))
     self.devices = map(re.compile, opts.get('devices', ['.*']))
     self.points = map(re.compile, opts.get('points', ['.*']))
     self.ffilter = _get_class(opts.get('filter')) if opts.get('filter') else None
     self.pathnamer = _get_class(opts.get('pathnamer')) if opts.get('pathnamer') else None
     for (dev, obj, path) in self._iter_points():
         unit = str(obj['unit']).strip()
         if unit.isdigit():
             unit = str(bacnet.type_str(int(unit)))
         self.add_timeseries(path, unit, data_type='double')
         # Nasty hack, but timeseries doesn't provide the interface/ dynamic adding data  -Kaifei
         if obj['desc']:
           self.get_timeseries(path).__setitem__("Description", obj['desc'])