Пример #1
0
    def test_logger_agent_started(self):

        uuid = self.direct_build_install_run_agent(AGENT_DIR, CONFIG_FILE)
        time.sleep(SLEEP_TIME)
        publish_addr = self.env()['AGENT_PUB_ADDR']
        self.assertIsNotNone(publish_addr)
        msg = {"oat1": "50", "oat2":"20.5"}
        print('ENVIRONMENT: ', publish_addr)
        pub = PublishMixin(publish_addr)
        pub.publish_json('pnnl/isb1/oat/all',{}, msg)
        time.sleep(SLEEP_TIME)
Пример #2
0
    def setup(self, opts):
        self.interval = float(opts.get('interval', 60))
        self.set_metadata('/',
                          {'Instrument/SamplingPeriod': str(self.interval)})

        self.add_collection('/actuators')

        publish_address = opts.get('publish_address', default_publish_address)

        PublishMixin._setup(self, publish_address)

        self.interface = self.get_interface(opts)

        self.all_path_depth, self.all_path_breadth = self.get_paths_for_point(
            '/' + DRIVER_TOPIC_ALL)

        self.meta_data = {}

        c = self.get_collection('/')
        #Flatten the meta data dict
        kv = buildkv('', c['Metadata'])
        self.meta_data[c.path] = dict(kv)

        for point in self.interface.get_register_names():
            register = self.interface.get_register_by_name(point)
            if register.register_type == 'bit':
                data_type = 'long'
            else:
                if register.python_type is int:
                    data_type = 'long'
                elif register.python_type is float:
                    data_type = 'double'
                else:
                    raise ValueError(
                        'sMAP currently only supports int and float based data types.'
                    )
            ts = self.add_timeseries('/' + point,
                                     register.units,
                                     data_type=data_type,
                                     description=register.description)

            pd = ts['Properties']
            ts_type = pd['ReadingType']
            if ts_type == 'double':
                ts_type = 'float'
            elif ts_type == 'long':
                ts_type = 'integer'

            self.meta_data[point] = {
                'units': pd['UnitofMeasure'],
                'type': ts_type,
                'tz': pd['Timezone']
            }

        for register in self.interface.get_registers_by_type('bit', False):
            point = register.point_name

            actuator_point = '/actuators/' + point

            print 'Setting up actuator point:', actuator_point

            a = self.add_actuator(actuator_point,
                                  register.units,
                                  InterfaceBitActuator,
                                  setup={
                                      'point_name': point,
                                      'interface': self.interface
                                  })  #, read_limit=1.0, write_limit=1.0)

            value = self.interface.get_point_sync(point)
            if value is None:
                print("ERROR: Failed to read " + actuator_point +
                      " interface returned None")
            else:
                self.add(actuator_point, value)

        for register in self.interface.get_registers_by_type('byte', False):
            point = register.point_name
            actuator_point = '/actuators/' + point

            print 'Setting up actuator point:', actuator_point

            if register.python_type is int:
                act_class, data_type = (InterfaceIntActuator, 'long')
            elif register.python_type is float:
                act_class, data_type = (InterfaceFloatActuator, 'double')
            else:
                raise ValueError(
                    'sMAP currently only supports int and float based data types.'
                )

            a = self.add_actuator(
                actuator_point,
                register.units,
                act_class,
                setup={
                    'point_name': point,
                    'interface': self.interface
                },
                data_type=data_type)  #, read_limit=1.0, write_limit=1.0)

            value = self.interface.get_point_sync(point)
            if value is not None:
                self.add(actuator_point, value)
            else:
                print("ERROR: Failed to read " + actuator_point +
                      " interface returned None")
Пример #3
0
    def setup(self, opts):
        self.interval = float(opts.get("interval", 60))
        self.set_metadata("/", {"Instrument/SamplingPeriod": str(self.interval)})

        self.add_collection("/actuators")

        publish_address = opts.get("publish_address", default_publish_address)

        PublishMixin._setup(self, publish_address)

        self.interface = self.get_interface(opts)

        self.all_path_depth, self.all_path_breadth = self.get_paths_for_point("/" + DRIVER_TOPIC_ALL)

        self.meta_data = {}

        c = self.get_collection("/")
        # Flatten the meta data dict
        kv = buildkv("", c["Metadata"])
        self.meta_data[c.path] = dict(kv)

        for point in self.interface.get_register_names():
            register = self.interface.get_register_by_name(point)
            if register.register_type == "bit":
                data_type = "long"
            else:
                if register.python_type is int:
                    data_type = "long"
                elif register.python_type is float:
                    data_type = "double"
                else:
                    raise ValueError("sMAP currently only supports int and float based data types.")
            ts = self.add_timeseries("/" + point, register.units, data_type=data_type, description=register.description)

            pd = ts["Properties"]
            ts_type = pd["ReadingType"]
            if ts_type == "double":
                ts_type = "float"
            elif ts_type == "long":
                ts_type = "integer"

            self.meta_data[point] = {"units": pd["UnitofMeasure"], "type": ts_type, "tz": pd["Timezone"]}

        for register in self.interface.get_registers_by_type("bit", False):
            point = register.point_name

            actuator_point = "/actuators/" + point

            print "Setting up actuator point:", actuator_point

            a = self.add_actuator(
                actuator_point,
                register.units,
                InterfaceBitActuator,
                setup={"point_name": point, "interface": self.interface},
            )  # , read_limit=1.0, write_limit=1.0)

            value = self.interface.get_point_sync(point)
            if value is None:
                print ("ERROR: Failed to read " + actuator_point + " interface returned None")
            else:
                self.add(actuator_point, value)

        for register in self.interface.get_registers_by_type("byte", False):
            point = register.point_name
            actuator_point = "/actuators/" + point

            print "Setting up actuator point:", actuator_point

            if register.python_type is int:
                act_class, data_type = (InterfaceIntActuator, "long")
            elif register.python_type is float:
                act_class, data_type = (InterfaceFloatActuator, "double")
            else:
                raise ValueError("sMAP currently only supports int and float based data types.")

            a = self.add_actuator(
                actuator_point,
                register.units,
                act_class,
                setup={"point_name": point, "interface": self.interface},
                data_type=data_type,
            )  # , read_limit=1.0, write_limit=1.0)

            value = self.interface.get_point_sync(point)
            if value is not None:
                self.add(actuator_point, value)
            else:
                print ("ERROR: Failed to read " + actuator_point + " interface returned None")
Пример #4
0
    def setup(self, opts):
        self.interval = float(opts.get('interval',60))
        self.set_metadata('/', {'Instrument/SamplingPeriod' : str(self.interval)})
          
        self.add_collection('/actuators')
        
        publish_address = opts.get('publish_address', default_publish_address)
        
        PublishMixin._setup(self, publish_address)
        
        self.interface = self.get_interface(opts)
         
        self.all_path_depth, self.all_path_breadth = self.get_paths_for_point('/'+DRIVER_TOPIC_ALL)

        self.meta_data = {}
        
        c = self.get_collection('/')
        #Flatten the meta data dict
        kv = buildkv('', c['Metadata'])
        self.meta_data[c.path] = dict(kv)
        
        for point in self.interface.get_register_names():
            register = self.interface.get_register_by_name(point)
            if register.register_type == 'bit':
                data_type = 'long'
            else:
                if register.python_type is int:
                    data_type = 'long'
                elif register.python_type is float:
                    data_type = 'double'
                else:
                    raise ValueError('sMAP currently only supports int and float based data types.')
            ts = self.add_timeseries('/'+point, register.units, data_type=data_type, description=register.description)
            
            pd = ts['Properties']
            ts_type = pd['ReadingType']
            if ts_type == 'double':
                ts_type = 'float'
            elif ts_type == 'long':
                ts_type = 'integer'
            
            self.meta_data[point] = {'units': pd['UnitofMeasure'],
                                       'type': ts_type,
                                       'tz': pd['Timezone']}
             
        for register in self.interface.get_registers_by_type('bit',False):
            point = register.point_name
            
            actuator_point = '/actuators/'+point
            
            print 'Setting up actuator point:', actuator_point
            
            a = self.add_actuator(actuator_point, register.units, InterfaceBitActuator, 
                              setup={'point_name':point, 'interface': self.interface}) #, read_limit=1.0, write_limit=1.0)
            
            value = self.interface.get_point_sync(point)
            if value is None:
                print("ERROR: Failed to read " + actuator_point + " interface returned None")
            else:
                self.add(actuator_point, value)
            
            
        for register in self.interface.get_registers_by_type('byte',False):
            point = register.point_name
            actuator_point = '/actuators/'+point
            
            print 'Setting up actuator point:', actuator_point
            
            if register.python_type is int:
                act_class, data_type = (InterfaceIntActuator, 'long')
            elif register.python_type is float:
                act_class, data_type = (InterfaceFloatActuator, 'double')
            else:
                raise ValueError('sMAP currently only supports int and float based data types.')
                        
            a = self.add_actuator(actuator_point, register.units, act_class, 
                              setup={'point_name':point, 'interface': self.interface},
                              data_type=data_type) #, read_limit=1.0, write_limit=1.0)
            
        
            value = self.interface.get_point_sync(point)
            if value is not None:
                self.add(actuator_point, value)
            else:
                print("ERROR: Failed to read " + actuator_point + " interface returned None")
Пример #5
0
    def setup(self, opts):
        self.interval = float(opts.get('interval', 60))
        self.set_metadata('/',
                          {'Instrument/SamplingPeriod': str(self.interval)})

        self.add_collection('/actuators')

        publish_address = opts.get('publish_address', default_publish_address)

        PublishMixin._setup(self, publish_address)

        self.interface = self.get_interface(opts)

        self.all_path_depth, self.all_path_breadth = self.get_paths_for_point(
            '/all')

        for point in self.interface.get_register_names():
            register = self.interface.get_register_by_name(point)
            if register.register_type == 'bit':
                data_type = 'long'
            else:
                if register.python_type is int:
                    data_type = 'long'
                elif register.python_type is float:
                    data_type = 'double'
                else:
                    raise ValueError(
                        'sMAP currently only supports int and float based data types.'
                    )
            self.add_timeseries('/' + point,
                                register.units,
                                data_type=data_type,
                                description=register.description)

        for register in self.interface.get_registers_by_type('bit', False):
            point = register.point_name

            actuator_point = '/actuators/' + point

            print 'Setting up actuator point:', actuator_point

            a = self.add_actuator(actuator_point,
                                  register.units,
                                  InterfaceBitActuator,
                                  setup={
                                      'point_name': point,
                                      'interface': self.interface
                                  })  #, read_limit=1.0, write_limit=1.0)

            value = self.interface.get_point_sync(point)
            if value is None:
                print("ERROR: Failed to read " + actuator_point +
                      " interface returned None")
            else:
                self.add(actuator_point, value)

        for register in self.interface.get_registers_by_type('byte', False):
            point = register.point_name
            actuator_point = '/actuators/' + point

            print 'Setting up actuator point:', actuator_point

            if register.python_type is int:
                act_class, data_type = (InterfaceIntActuator, 'long')
            elif register.python_type is float:
                act_class, data_type = (InterfaceFloatActuator, 'double')
            else:
                raise ValueError(
                    'sMAP currently only supports int and float based data types.'
                )

            a = self.add_actuator(
                actuator_point,
                register.units,
                act_class,
                setup={
                    'point_name': point,
                    'interface': self.interface
                },
                data_type=data_type)  #, read_limit=1.0, write_limit=1.0)

            value = self.interface.get_point_sync(point)
            if value is not None:
                self.add(actuator_point, value)
            else:
                print("ERROR: Failed to read " + actuator_point +
                      " interface returned None")