Beispiel #1
0
    def run(self, registry):
        from liota.edge_component.sklearn_edge_component import SKLearnEdgeComponent
        # initialize and run the physical model (simulated device)
        sklearn_edge_component = SKLearnEdgeComponent(config['modelPath'],
                                                      None)

        registry.register("sklearn_edge_component", sklearn_edge_component)
 def test_SKLearnEdgeComponent_takes_valid_actionActuator(self):
     edge_component = SKLearnEdgeComponent(ModelPath, action_actuator)
     assert isinstance(edge_component, SKLearnEdgeComponent)
 def test_SKLearnEdgeComponent_fails_without_valid_actionActuator(self):
     #Fails if action_actuator not of function type
     with self.assertRaises(Exception):
         edge_component = SKLearnEdgeComponent(ModelPath, "asd")
         assertNotIsInstance(edge_component, SKLearnEdgeComponent)
 def test_SKLearnEdgeComponent_fails_without_valid_ModelPath(self):
     with self.assertRaises(Exception):
         edge_component = SKLearnEdgeComponent(ModelPath, "asd")
         assert isinstance(edge_component, SKLearnEdgeComponent)
 def test_Component_fails_without_valid_ModelPath(self):
     with self.assertRaises(Exception):
         edge_component = SKLearnEdgeComponent("/home/asd", "asd")
         assertNotIsInstance(edge_component, SKLearnEdgeComponent)

def action_actuator(value):
    print value


def read_csv_file():
    global line
    line += 1
    if not line > len(rows):
        return int(rows[line][0])


# ---------------------------------------------------------------------------
# In this example, we demonstrate how System health and some simulated data
# can be directed to data center component IoTCC using Liota.
# The program illustrates the ease of use Liota brings to IoT application developers.

if __name__ == '__main__':
    read_file("/home/vl/Desktop/sample.csv")
    sample = SKLearnEdgeComponent(
        '/home/pi/Desktop/Borathon/liota/edge_intelligence_models/windmill/finalized_model.sav',
        action_actuator)
    sample_metric = Metric(name="File Metric",
                           unit=None,
                           interval=1,
                           aggregation_size=1,
                           sampling_function=read_csv_file)
    reg_sample_metric = sample.register(sample_metric)
    reg_sample_metric.start_collecting()
        reg_vibration_metric.start_collecting()

        rpm_metric = Metric(
            name="RPM",
            unit=None,
            interval=0,
            aggregation_size=1,
            sampling_function=lambda: get_rpm(sensor_tag_collector)
        )
        reg_rpm_metric = iotcc.register(rpm_metric)
        iotcc.create_relationship(reg_sensor_tag, reg_rpm_metric)
        reg_rpm_metric.start_collecting()

        pfa_rpm_metric = Metric(
            name="RPM",
            unit=None,
            interval=0,
            aggregation_size=1,
            sampling_function=get_rpm_for_model
        )

        edge_component = SKLearnEdgeComponent('/home/pi/Desktop/Borathon/liota/edge_intelligence_models/windmill/finalized_model.sav',
                                              actuator_udm=action_actuator)

        pfa_reg_rpm_metric = edge_component.register(pfa_rpm_metric)
        pfa_reg_rpm_metric.start_collecting()

    except RegistrationFailure:
        print "Registration to IOTCC failed"
        sensor_tag_collector.stop()