def create_thing(self):
        # Create and Populate the TagGroup registry with JSON resource files.
        tgr = JSonTagGroupRegistry()
        tgr.register_tag_groups_from_uri(
            get_abs_file_uri(
                'definitions/TagGroup/com.adlinktech.example/LocationTagGroup.json'
            ))
        tgr.register_tag_groups_from_uri(
            get_abs_file_uri(
                'definitions/TagGroup/com.adlinktech.example/DistanceTagGroup.json'
            ))
        self._datariver.add_tag_group_registry(tgr)

        # Create and Populate the ThingClass registry with JSON resource files.
        tcr = JSonThingClassRegistry()
        tcr.register_thing_classes_from_uri(
            get_abs_file_uri(
                'definitions/ThingClass/com.adlinktech.example/DistanceServiceThingClass.json'
            ))
        self._datariver.add_thing_class_registry(tcr)

        # Create a Thing based on properties specified in a JSON resource file.
        tp = JSonThingProperties()
        tp.read_properties_from_uri(self._thing_properties_uri)
        return self._datariver.create_thing(tp)
Exemple #2
0
def load_thing_classes(dr: DataRiver, thing_class_dir: str):
    tcr = JSonThingClassRegistry()
    for entry in os.scandir(thing_class_dir):
        if entry.is_file() and entry.path.endswith('.json'):
            log.info(f'Loading thing class: {entry.path}')
            try:
                tcr.register_thing_classes_from_uri(f'file://{entry.path}')
            except Exception as e:
                log.error(f'Unable to load thing class: {entry.path} : {e}')
                pass
    dr.add_thing_class_registry(tcr)
   def create_thing(self):
       # Create and Populate the TagGroup registry with JSON resource files.
       tag_groups.Temperature_register_with_datariver(self._dr)
 
       # Create and Populate the ThingClass registry with JSON resource files.
       tcr = JSonThingClassRegistry()
       tcr.register_thing_classes_from_uri(get_abs_file_uri('definitions/ThingClass/com.adlinktech.example.protobuf/TemperatureDashboardThingClass.json'))
       self._dr.add_thing_class_registry(tcr)
 
       # Create a Thing based on properties specified in a JSON resource file.
       tp = JSonThingProperties()
       tp.read_properties_from_uri(self._thing_properties_uri)
       return ThingEx(self._dr.create_thing(tp))
   def create_thing(self):
       # Add listener for discovery of Things
       self._datariver.add_listener(self._new_thing_discovered_listener, self._dispatcher)
       
       # Create and Populate the ThingClass registry with JSON resource files.
       tcr = JSonThingClassRegistry()
       tcr.register_thing_classes_from_uri('file://definitions/ThingClass/com.adlinktech.example/ThingBrowserThingClass.json')
       self._datariver.add_thing_class_registry(tcr)
 
       # Create a Thing based on properties specified in a JSON resource file.
       tp = JSonThingProperties()
       tp.read_properties_from_uri(self._thing_properties_uri)
       
       return self._datariver.create_thing(tp)
   def create_thing(self):
       # Create and Populate the TagGroup registry with JSON resource files.
       RotationalSpeed_register_with_datariver(self._datariver)
 
       # Create and Populate the ThingClass registry with JSON resource files.
       tcr = JSonThingClassRegistry()
       tcr.register_thing_classes_from_uri('file://definitions/ThingClass/com.adlinktech.example.protobuf/RotationalSpeedSensorThingClass.json')
       self._datariver.add_thing_class_registry(tcr)
 
       # Create a Thing based on properties specified in a JSON resource file.
       tp = JSonThingProperties()
       tp.read_properties_from_uri(self._thing_properties_uri)
       
       return ThingEx(self._datariver.create_thing(tp))
Exemple #6
0
def register_thing_classes(dr: DataRiver, thing_class_dir: str,
                           thing_classes: List[str]):
    '''
    For each of the Thing Classes listed in thing_classes and whose definition is in thing_class_dir register them
    with the provided instance of the Data River; dr.

    The thing_classes list shoudl be the name of the file without the .json extension
    '''
    tcr = JSonThingClassRegistry()

    for tc in thing_classes:
        logging.info(f'Loading Thing Class: {tc}.json from {thing_class_dir}')
        tcr.register_thing_classes_from_uri(
            get_abs_file_uri(str(os.path.join(thing_class_dir, f'{tc}.json'))))

    dr.add_thing_class_registry(tcr)
Exemple #7
0
    def create_thing(self):
        #  Register the protobuf TagGroups
        Location_register_with_datariver(self._datariver)
        Distance_register_with_datariver(self._datariver)

        # Create and Populate the ThingClass registry with JSON resource files.
        tcr = JSonThingClassRegistry()
        tcr.register_thing_classes_from_uri(
            get_abs_file_uri(
                'definitions/ThingClass/com.adlinktech.example.protobuf/GpsSensorThingClass.json'
            ))
        self._datariver.add_thing_class_registry(tcr)

        # Create a Thing based on properties specified in a JSON resource file.
        tp = JSonThingProperties()
        tp.read_properties_from_uri(self._thing_properties_uri)
        return ThingEx(self._datariver.create_thing(tp))
Exemple #8
0
    def create_thing(self):
        # Create and Populate the TagGroup registry with JSON resource files.
        tgr = JSonTagGroupRegistry()
        tgr.register_tag_groups_from_uri(
            'file://definitions/TagGroup/com.adlinktech.example/SensorStateTagGroup.json'
        )
        tgr.register_tag_groups_from_uri(
            'file://definitions/TagGroup/com.adlinktech.example/FuelLevelTagGroup.json'
        )
        self._datariver.add_tag_group_registry(tgr)

        # Create and Populate the ThingClass registry with JSON resource files.
        tcr = JSonThingClassRegistry()
        tcr.register_thing_classes_from_uri(
            'file://definitions/ThingClass/com.adlinktech.example/FuelLevelSensorThingClass.json'
        )
        self._datariver.add_thing_class_registry(tcr)

        # Create a Thing based on properties specified in a JSON resource file.
        tp = JSonThingProperties()
        tp.read_properties_from_uri(self._thing_properties_uri)

        return self._datariver.create_thing(tp)