Example #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)
Example #2
0
    def _consumption_data(self, application, container, content):
        print "Got content at Central"
        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']
            image = i['base64image']
            self.data.append(match_percentage)
            if match_percentage > min_match_percentage:
                data = {
                    "match_percentage": match_percentage,
                    "min_match_percentage": min_match_percentage,
                    "latitude": lat,
                    "longitude": lon,
                    "drone_id": drone_id,
                    "base64image": image
                }
                self.push_content(self.alertContainers[drone_id - 1], data)
                print "ALERT SENT - Possible Mining Zone detected at [Latitude, Longitude]: [", lat, ",", lon, "] with a dominant color match  of", match_percentage, "% > ", min_match_percentage, "% by Drone ", drone_id, "- information stored at container:", container.name
            else:
                print "Zone OK - dominant color match of", match_percentage, "% - Drone", drone_id, "at [Latitude, Longitude]: [", lat, ",", lon, "]", "- Container:", container.name


app_instance = Central()

core_ip = 'localhost:4000'
runner = FlaskRunner(app_instance, port=5076, host='localhost')
runner.run(core_ip)
Example #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")
Example #4
0
File: Home.py Project: juaoose/send
			flow = randint(0, 100)
			oximetro = randint(0, 100)
            temperatura = randint(0,100)
            data = {
                "temperature": temperatura,
				"glucose": glucosa,
				"presion": presion,
				"flow": flow,
				"spo2": oximetro
                "house_id":self.house_id
            }
            self.push_content(self.container, data)
            print data
            time.sleep(5)

##identificador de cada sensor
house_id = 1
app_instance = TempSensor(house_id)
app_instance.app_id = 'TempSensor1'
app_instance.search_strings = ("TempHomes", )
gateway_add = '192.168.169.135:4000'
runner = FlaskRunner(app_instance,port=5001)
runner.run(gateway_add)







Example #5
0
 def connect_to_local(self):
     print("IpeAe Starting....")
     runner = FlaskRunner(self)
     runner.run("http://localhost:8000")
Example #6
0
from openmtc_app.flask_runner import FlaskRunner
from openmtc_app import ContentSubscription, DA

##Este se encarga de imprimir todo lo que se guarde en el contenedor de alertas, al que solo se envian los datos cuando la temperatura es mayor a 70
class Alarm(DA):

    data = []
    container_name = "alarmContainer"
    def _on_register(self):

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

    def _consumption_data(self, application, container, content):
        print "Got content"
        for i in content:
			##necesito un try catch para ver que tipo de alerta es.
            temp = i['temperature']
            house_id = i['house_id']
            self.data.append(temp)
            print "PROBLEMA:Temperatura:", temp

app_instance = Alarm()
gateway_ip= '192.168.169.135:4000'
runner = FlaskRunner(app_instance, port=5097, host='192.168.169.137')
runner.run(gateway_ip)
Example #7
0
                print "OK:Glucosa:", glucosa, "house_id: ", house_id, " Container: ", container.name
			##Verificar Oximeter	
			if spo2 < 0.94:
                print "PROBLEMA:Oximeter:", spo2 , "house_id: ", house_id, " Container: ", container.name
                data = {
                    "spo2": spo2,
                    "house_id": house_id
                }
                self.push_content(self.alertContainers[house_id-1], data)
                ##print "Sent alert - temp:", temp, "house_id: ", house_id
            else:
                print "OK:Oximeter:", spo2, "house_id: ", house_id, " Container: ", container.name
			##Verificar respiracion
			if flow > 37.5:
                print "PROBLEMA:Respiracion:", flow , "house_id: ", house_id, " Container: ", container.name
                data = {
                    "flow": flow,
                    "house_id": house_id
                }
                self.push_content(self.alertContainers[house_id-1], data)
                ##print "Sent alert - temp:", temp, "house_id: ", house_id
            else:
                print "OK:Respiracion:", flow, "house_id: ", house_id, " Container: ", container.name


app_instance = Central()

core_ip = '192.168.169.135:4000'
runner = FlaskRunner(app_instance, port=5076, host='192.168.169.137')
runner.run(core_ip)
Example #8
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)