Exemplo n.º 1
0
class Alert(DA):

    data = []
    container_name = "alertContainer"

    def _on_register(self):

        alert_subscription = ContentSubscription(
            None, self.container_name, content_handler=self._consumption_data)
        self.add_content_subscription(alert_subscription)
        print "alert_subscription to: Alert Container:" + self.container_name

    def _consumption_data(self, application, container, content):
        print "Got content at ZoneAlert"
        for i in content:
            min_match_percentage = i['min_match_percentage']
            match_percentage = i['match_percentage']
            lat = i['latitude']
            lon = i['longitude']
            drone_id = i['drone_id']
            base64image = i['base64image']
            self.data.append(match_percentage)
            print "ALERT!!! - Possible Mining Zone detected at [Latitude, Longitude]: [", lat, ",", lon, "] with a dominant color match of:", match_percentage, "% > ", min_match_percentage, "% by Drone", drone_id, "Subscribe to this container to retrieve Base64 Image String"


app_instance = Alert()
gateway_ip = 'localhost:4000'
runner = FlaskRunner(app_instance, port=5097, host='localhost')
runner.run(gateway_ip)
Exemplo n.º 2
0
 def connect_to_local(self):
     print("IpeAe Starting....")
     runner = FlaskRunner(self)
     runner.run("http://localhost:8000")
Exemplo n.º 3
0
# Example 16: Creating a simple Container

from openmtc_app.onem2m import XAE
from openmtc_app.flask_runner import FlaskRunner

class MyAE(XAE):
    def _on_register(self):
        container = self.create_container(None, "myContainer")

app_instance = MyAE()
runner = FlaskRunner(app_instance)
runner.run("http://localhost:8000")
Exemplo n.º 4
0
        # while True:
        #     match_percentage = randint(0,100)
        #     lat = randint(-90,90)
        #     lon = randint(-180,180)
        #     data = {
        #         "match_percentage": match_percentage,
        # 		"latitude": lat,
        # 		"longitude": lon,
        #         "drone_id":1,
        #         "base64image": "base64imageLongString"
        #     }
        #     self.push_content(self.container, data)
        #     print data
        #     time.sleep(5)


app_instance = DroneSensor()
app_instance.app_id = 'DroneSensor'
app_instance.search_strings = ('ZonesInfo', )
gateway_add = 'localhost:4000'
runner = FlaskRunner(app_instance,port=5001)
runner.run(gateway_add)