def run(self, registry): from liota.edge_component.pfa_component import PFAComponent # initialize and run the physical model (simulated device) pfa_component = PFAComponent(config['modelPath'], None) registry.register("pfa_component", pfa_component)
reg_vibration_metric = graphite.register(vibration_metric) graphite.create_relationship(reg_sensor_tag, reg_vibration_metric) reg_vibration_metric.start_collecting() rpm_metric = Metric( name="windmill.RPM", unit=None, interval=0, aggregation_size=1, sampling_function=lambda: get_rpm(sensor_tag_collector)) reg_rpm_metric = graphite.register(rpm_metric) graphite.create_relationship(reg_sensor_tag, reg_rpm_metric) reg_rpm_metric.start_collecting() pfa_rpm_metric = Metric(name="windmill.RPM", unit=None, interval=0, aggregation_size=1, sampling_function=get_rpm_for_model) edge_component = PFAComponent( '/home/pi/Desktop/Borathon/liota/edge_intelligence_models/windmill/finalized_model.pfa', 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 graphite failed" sensor_tag_collector.stop()
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("/Users/vkohli/sample.csv") sample = PFAComponent( '/home/pi/Desktop/Borathon/liota/edge_intelligence_models/windmill/finalized_model.pfa', action_actuator) sample_metric = Metric(name="File Metric", unit=None, interval=10, aggregation_size=1, sampling_function=read_csv_file) reg_sample_metric = sample.register(sample_metric) reg_sample_metric.start_collecting()
def test_PFAComponent_takes_valid_actionActuator(self): edge_component = PFAComponent(ModelPath, action_actuator) assert isinstance(edge_component, PFAComponent)
def test_PFAComponent_fails_without_valid_actionActuator(self): #Fails if action_actuator not of function type with self.assertRaises(Exception): edge_component = PFAComponent(ModelPath, "asd") assertNotIsInstance(edge_component, PFAComponent)
def test_PFAComponent_fails_without_valid_ModelPath(self): with self.assertRaises(Exception): edge_component = PFAComponent(ModelPath, "asd") assert isinstance(edge_component, PFAComponent)
reg_vibration_metric.start_collecting() rpm_metric = Metric( name="windmill.RPM", unit=None, interval=0, aggregation_size=1, sampling_function=lambda: get_rpm(sensor_tag_collector) ) reg_rpm_metric = graphite.register(rpm_metric) graphite.create_relationship(reg_sensor_tag, reg_rpm_metric) reg_rpm_metric.start_collecting() ''' pfa_rpm_metric = Metric(name="windmill.RPM", unit=None, interval=0, aggregation_size=1, sampling_function=get_rpm_for_model) #Model-Path can be edited in the sampleProp.conf file #pass value to actuator as of now the action_actuator prints the value on the console edge_component = PFAComponent(config['ModelPath'], 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 graphite failed" sensor_tag_collector.stop()