Ejemplo n.º 1
0
    def run(self, registry):
        from liota.entities.devices.thermistor_simulated import ThermistorSimulated
        import pint

        # Get values from configuration file
        config_path = registry.get("package_conf")
        config = read_user_config(config_path + '/sampleProp.conf')

        # create a pint unit registry
        ureg = pint.UnitRegistry()
        # initialize and run the physical model (simulated device)
        thermistor_simulator = ThermistorSimulated(name=config['DeviceName'],
                                                   ureg=ureg)

        registry.register("thermistor_simulator", thermistor_simulator)
Ejemplo n.º 2
0
    try:

        # create a Edge System object encapsulating the particulars of a gateway/board
        # argument is the name of this Edge System
        edge_system = Dk300EdgeSystem(config['EdgeSystemName'])

        # resister the Edge System with the IoTCC instance
        # this call creates a representation (a Resource) in IoTCC for this IoT System with the name given
        reg_edge_system = iotcc.register(edge_system)

        # these call set properties on the Resource representing the IoT System
        # properties are a key:value store
        reg_edge_system.set_properties(config['SystemPropList'])

        # create the device object and register it on IoTCC
        thermistor_model = ThermistorSimulated(name=config['DeviceName'],
                                               ureg=ureg)

        reg_thermistor_model = iotcc.register(thermistor_model)
        iotcc.create_relationship(reg_edge_system, reg_thermistor_model)

        reg_thermistor_model.set_properties(config['DevicePropList'])

        metric_name = "model.thermistor.temperature"
        thermistor_temper = Metric(
            name=metric_name,
            unit=ureg.degC,
            interval=5,
            sampling_function=get_thermistor_temperature)
        reg_thermistor_temper = iotcc.register(thermistor_temper)
        iotcc.create_relationship(reg_thermistor_model, reg_thermistor_temper)
        reg_thermistor_temper.start_collecting()