def create_virtual_devices(self):
        vds = []
        vd = VirtualDevice('Complex 1 Temperature Monitor')

        vvg1 = VirtualValueGroup('facility-system/temperature/complex-1',
                                 "main")
        vvg1.set_generation_strategy(TimedGenerationStrategy(5))
        vvg1.set_packager_strategy(
            StringReplacePackagerStrategy(
                '{average_temperature:$0, max_temperature:$1, min_temperature:$2, moving_average_temperature:$3}'
            ))

        # add virtual values
        vv1 = VirtualValue('Current Temperature Value', '$0')
        vv1.add_input_data_source(
            InputDataSource('EnvironmentSensor1', 'main',
                            "facility-system/temperature/room-1",
                            JsonParsingStrategy("average_temperature")))
        vv1.set_aggregator_strategy(BasicFloatAverageAggregatorStrategy())
        vvg1.add_virtual_value(vv1)

        vv2 = VirtualValue('Maximum Temperature Value', '$1')
        vv2.add_input_data_source(
            InputDataSource('EnvironmentSensor1', 'main',
                            "facility-system/temperature/room-1",
                            JsonParsingStrategy("max_temperature")))
        vv2.set_aggregator_strategy(BasicFloatAverageAggregatorStrategy())
        vvg1.add_virtual_value(vv2)

        vv3 = VirtualValue('Minimum Temperature Value', '$2')
        vv3.add_input_data_source(
            InputDataSource('EnvironmentSensor1', 'main',
                            "facility-system/temperature/room-1",
                            JsonParsingStrategy("min_temperature")))
        vv3.set_aggregator_strategy(BasicFloatAverageAggregatorStrategy())
        vvg1.add_virtual_value(vv3)

        vv4 = VirtualValue('Moving Average Temperature Value', '$3')
        vv4.add_input_data_source(
            InputDataSource('EnvironmentSensor1', 'main',
                            "facility-system/temperature/room-1",
                            JsonParsingStrategy("moving_average_temperature")))
        vv4.set_aggregator_strategy(BasicFloatAverageAggregatorStrategy())
        vvg1.add_virtual_value(vv4)

        vd.add_virtual_value_group(vvg1)

        vds.append(vd)

        return vds
Beispiel #2
0
    def create_virtual_devices(self):
        vds = []

        vd = VirtualDevice('Building 1')

        vvg1 = VirtualValueGroup('facility-system/buildings/building/1',
                                 "output")
        vvg1.set_generation_strategy(OnDataReceivedGenerationStrategy())
        vvg1.set_packager_strategy(
            StringReplacePackagerStrategy(
                '{all_doors_closed:$0, all_windows_closed:$1}'))

        # add virtual values
        vv1 = VirtualValue('All Doors Closed', '$0')
        vv1.add_input_data_source(
            InputDataSource('DoorSensor1', 'input', "jarvis/door/1/changes",
                            JsonParsingStrategy('newState')))
        vv1.add_input_data_source(
            InputDataSource('DoorSensor2', 'input', "jarvis/door/2/changes",
                            JsonParsingStrategy('newState')))
        vv1.set_aggregator_strategy(
            AllBooleanValuesEqualValueAggregatorStrategy('closed'))
        vvg1.add_virtual_value(vv1)

        vv2 = VirtualValue('All Windows Closed', '$1')
        vv2.add_input_data_source(
            InputDataSource('WindowSensor1', 'input',
                            "jarvis/window/1/changes",
                            JsonParsingStrategy('newState')))
        vv2.add_input_data_source(
            InputDataSource('WindowSensor2', 'input',
                            "jarvis/window/2/changes",
                            JsonParsingStrategy('newState')))
        vv2.add_input_data_source(
            InputDataSource('WindowSensor3', 'input',
                            "jarvis/window/3/changes",
                            JsonParsingStrategy('newState')))
        vv2.set_aggregator_strategy(
            AllBooleanValuesEqualValueAggregatorStrategy('closed'))
        vvg1.add_virtual_value(vv2)

        vd.add_virtual_value_group(vvg1)

        vds.append(vd)

        return vds
    def create_virtual_devices(self):
        vds = []
        vd = VirtualDevice('Room 1 Temperature Monitor')

        vvg1 = VirtualValueGroup('facility-system/temperature/room-1', "output")
        vvg1.set_generation_strategy(TimedGenerationStrategy(5))
        vvg1.set_packager_strategy(StringReplacePackagerStrategy(
            '{average_temperature:$0, max_temperature:$1, min_temperature:$2, moving_average_temperature:$3}'))

        # add virtual values
        vv1 = VirtualValue('Current Temperature Value', '$0')
        vv1.add_input_data_source(InputDataSource('EnvironmentSensor1', 'input', "maproject/environment/2/updates",
                                                  JsonParsingStrategy("temperature")))
        vv1.add_input_data_source(InputDataSource("TemperatureSensor20", "input", "maproject/temperature/20/updates",
                                                  RawParsingStrategy()))
        vv1.add_input_data_source(InputDataSource("TemperatureSensor21", "input", "maproject/temperature/21/updates",
                                                  RawParsingStrategy()))
        vv1.add_input_data_source(InputDataSource("TemperatureSensor22", "input", "maproject/temperature/22/updates",
                                                  RawParsingStrategy()))
        vv1.set_aggregator_strategy(BasicFloatAverageAggregatorStrategy())
        vvg1.add_virtual_value(vv1)

        vv2 = VirtualValue('Maximum Temperature Value', '$1')
        vv2.add_input_data_source(InputDataSource('EnvironmentSensor1', 'input', "maproject/environment/2/updates",
                                                  JsonParsingStrategy("temperature")))
        vv2.add_input_data_source(InputDataSource("TemperatureSensor20", "input", "maproject/temperature/20/updates",
                                                  RawParsingStrategy()))
        vv2.add_input_data_source(InputDataSource("TemperatureSensor21", "input", "maproject/temperature/21/updates",
                                                  RawParsingStrategy()))
        vv2.add_input_data_source(InputDataSource("TemperatureSensor22", "input", "maproject/temperature/22/updates",
                                                  RawParsingStrategy()))
        vv2.set_aggregator_strategy(FloatMaximumAggregatorStrategy())
        vvg1.add_virtual_value(vv2)

        vv3 = VirtualValue('Minimum Temperature Value', '$2')
        vv3.add_input_data_source(InputDataSource('EnvironmentSensor1', 'input', "maproject/environment/2/updates",
                                                  JsonParsingStrategy("temperature")))
        vv3.add_input_data_source(InputDataSource("TemperatureSensor20", "input", "maproject/temperature/20/updates",
                                                  RawParsingStrategy()))
        vv3.add_input_data_source(InputDataSource("TemperatureSensor21", "input", "maproject/temperature/21/updates",
                                                  RawParsingStrategy()))
        vv3.add_input_data_source(InputDataSource("TemperatureSensor22", "input", "maproject/temperature/22/updates",
                                                  RawParsingStrategy()))
        vv3.set_aggregator_strategy(FloatMinimumAggregatorStrategy())
        vvg1.add_virtual_value(vv3)

        vv4 = VirtualValue('Moving Average Temperature Value', '$3')
        vv4.add_input_data_source(InputDataSource('EnvironmentSensor1', 'input', "maproject/environment/2/updates",
                                                  JsonParsingStrategy("temperature")))
        vv4.add_input_data_source(InputDataSource("TemperatureSensor20", "input", "maproject/temperature/20/updates",
                                                  RawParsingStrategy()))
        vv4.add_input_data_source(InputDataSource("TemperatureSensor21", "input", "maproject/temperature/21/updates",
                                                  RawParsingStrategy()))
        vv4.add_input_data_source(InputDataSource("TemperatureSensor22", "input", "maproject/temperature/22/updates",
                                                  RawParsingStrategy()))
        vv4.set_aggregator_strategy(MovingAverageAggregatorStrategy())
        vvg1.add_virtual_value(vv4)

        vd.add_virtual_value_group(vvg1)

        vds.append(vd)

        return vds