Пример #1
0
def main():
    configureLogger("agent")
    ListenMQTTThread()
    registerAgent()  # Call the register endpoint and register Device I
    while True:
        try:
            if (iotUtils.IS_REGISTERED):
                currentTime = calendar.timegm(time.gmtime())
                latitudeLongitudeValue = iotUtils.generateLatitudeLongitudeValue(
                    1)
                PUSH_DATA_TO_STREAM = iotUtils.SENSOR_STATS.format(
                    currentTime, latitudeLongitudeValue[1],
                    latitudeLongitudeValue[0], iotUtils.VEHICLE_TYPE,
                    iotUtils.generateRandomValues(SPEED_LIMIT_MIN,
                                                  SPEED_LIMIT_MAX),
                    iotUtils.generateRandomValues(HEADING_MIN_LIMIT,
                                                  HEADING_MAX_LIMIT), "normal",
                    "This is a sample device type", True)
                mqttHandler.sendSensorValue(PUSH_DATA_TO_STREAM)
                print '~~~~~~~~~~~~~~~~~~~~~~~~ Publishing Device-Data ~~~~~~~~~~~~~~~~~~~~~~~~~'
                print('PUBLISHED DATA STREAM : ' + PUSH_DATA_TO_STREAM)
                time.sleep(PUSH_INTERVAL)
            else:
                registerAgent()
                time.sleep(PUSH_INTERVAL)
            time.sleep(PUSH_INTERVAL)
        except (KeyboardInterrupt, Exception) as e:
            print "agentStats: Exception in AgentThread (either KeyboardInterrupt or Other)"
            print("agentStats: " + str(e))
            print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
            pass
Пример #2
0
def main():
    configureLogger("agent")
    ListenMQTTThread()
    registerAgent()  # Call the register endpoint and register Device I
    while True:
        try:
            if iotUtils.IS_REGISTERED:
                currentTime = calendar.timegm(time.gmtime())
                latitudeLongitudeValue = iotUtils.generateLatitudeLongitudeValue(1)
                PUSH_DATA_TO_STREAM = iotUtils.SENSOR_STATS.format(
                    currentTime,
                    latitudeLongitudeValue[1],
                    latitudeLongitudeValue[0],
                    iotUtils.VEHICLE_TYPE,
                    iotUtils.generateRandomValues(SPEED_LIMIT_MIN, SPEED_LIMIT_MAX),
                    iotUtils.generateRandomValues(HEADING_MIN_LIMIT, HEADING_MAX_LIMIT),
                    "normal",
                    "This is a sample device type",
                    True,
                )
                mqttHandler.sendSensorValue(PUSH_DATA_TO_STREAM)
                print "~~~~~~~~~~~~~~~~~~~~~~~~ Publishing Device-Data ~~~~~~~~~~~~~~~~~~~~~~~~~"
                print ("PUBLISHED DATA STREAM : " + PUSH_DATA_TO_STREAM)
                time.sleep(PUSH_INTERVAL)
            else:
                registerAgent()
                time.sleep(PUSH_INTERVAL)
            time.sleep(PUSH_INTERVAL)
        except (KeyboardInterrupt, Exception) as e:
            print "agentStats: Exception in AgentThread (either KeyboardInterrupt or Other)"
            print ("agentStats: " + str(e))
            print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
            pass
Пример #3
0
def main():
    configureLogger("agent")
    ListenMQTTThread()
    registerAgent()  # Call the register endpoint and register Device I
    print "----------------------------------------------------------------------"
    while (True):
        if (iotUtils.IS_REGISTERED):
            print "-------------------------------------------------------------------------------------------------"
            currentTime = calendar.timegm(time.gmtime())
            randomLatitudeLongitudeValue = generateLatitudeLongitudeValue(
                INIT_LATITUDE, INIT_LONGITUDE, 5)
            print randomLatitudeLongitudeValue[1]
            PUSH_DATA = iotUtils.SENSOR_STATS + '"time":'+str(currentTime)+'},"payloadData":{"quatanium_val_q1":34,' \
                                                                           '"quatanium_val_q2":'+str(random.randint(15, 40))+',"quatanium_val_q3":' \
                        +str(random.randint(15, 40))+',"quatanium_val_q4":'+str(random.randint(5, 40))+',"velocity_x":' \
                        +str(random.randint(1, 5))+',"velocity_y":'+str(random.randint(1, 5))+',"velocity_z":' \
                        +str(random.randint(1, 5))+',"global_location_lat":'+str(randomLatitudeLongitudeValue[0]) \
                        +',"global_location_alt":45,"global_location_lon":'+str(randomLatitudeLongitudeValue[1]) \
                        +',"battery_level":'+ str(random.randint(15, 100))+',"battery_voltage":' \
                        +str(random.randint(15, 100))+',"pitch":'+str(random.randint(15, 40))+',"roll":' \
                        +str(random.randint(15, 40))+',"yaw":'+str(random.randint(15, 40))+'}}}'
            mqttHandler.sendSensorValue(PUSH_DATA)
            print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Publishing Device-Data ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
            print('PUBLISHED DATA: ' + PUSH_DATA)
            time.sleep(PUSH_INTERVAL)
        else:
            registerAgent()
            time.sleep(PUSH_INTERVAL)
        print "-------------------------------------------------------------------------------------------------"
Пример #4
0
def main():
    configureLogger("agent")
    ListenMQTTThread()
    registerAgent()  # Call the register endpoint and register Device I
    while True:
        try:
            if (iotUtils.IS_REGISTERED):
                currentTime = calendar.timegm(time.gmtime())
                sensorValue = getSensorValue()
                PUSH_DATA_TO_STREAM_1 = iotUtils.SENSOR_STATS_SENSOR1.format(
                    currentTime, sensorValue)
                sensorValue = getSensorValue()
                PUSH_DATA_TO_STREAM_2 = iotUtils.SENSOR_STATS_SENSOR2.format(
                    currentTime, sensorValue)
                mqttHandler.sendSensorValue(PUSH_DATA_TO_STREAM_1,
                                            PUSH_DATA_TO_STREAM_2)
                print '~~~~~~~~~~~~~~~~~~~~~~~~ Publishing Device-Data ~~~~~~~~~~~~~~~~~~~~~~~~~'
                print('PUBLISHED DATA STREAM 1: ' + PUSH_DATA_TO_STREAM_1)
                print('PUBLISHED DATA STREAM 2: ' + PUSH_DATA_TO_STREAM_2)
            else:
                registerAgent()
            time.sleep(PUSH_INTERVAL)
        except (KeyboardInterrupt, Exception) as e:
            print "agentStats: Exception in AgentThread (either KeyboardInterrupt or Other)"
            print("agentStats: " + str(e))
            print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
            pass
Пример #5
0
def main():
    configureLogger("agent")
    ListenMQTTThread()
    device = led.matrix()
    while True:
        try:
            iotUtils.PUSH_INTERVAL = iotUtils.getPushValue()
            PUSH_INTERVAL = iotUtils.PUSH_INTERVAL
            iotUtils.LEDS_STATE = iotUtils.getLedsValue().upper()
            LEDS_STATE = iotUtils.LEDS_STATE

            currentTime = calendar.timegm(time.gmtime())
            sensorValue = iotUtils.getSensorValue()
            if (LEDS_STATE == "ON"):
                device.show_message(str(sensorValue))
            PUSH_DATA_TO_STREAM_1 = iotUtils.SENSOR_STATS_SENSOR1.format(
                currentTime, sensorValue)
            mqttHandler.sendSensorValue(PUSH_DATA_TO_STREAM_1)
            print '~~~~~~~~~~~~~~~~~~~~~~~~ Publishing Device-Data ~~~~~~~~~~~~~~~~~~~~~~~~~'
            print('PUBLISHED DATA STREAM 1: ' + PUSH_DATA_TO_STREAM_1)
            print '~~~~~~~~~~~~~~~~~~~~~~~~ End of Publishing Data ~~~~~~~~~~~~~~~~~~~~~~~~~'
            time.sleep(PUSH_INTERVAL)
        except (KeyboardInterrupt, Exception) as e:
            print "agentStats: Exception in AgentThread (either KeyboardInterrupt or Other)"
            print("agentStats: " + str(e))
            os.system("sudo /etc/init.d/agentd.sh stop")
            print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
            sys.exit(0)
            pass
Пример #6
0
def main():
    configureLogger("agent")
    ListenMQTTThread()
    registerAgent()  # Call the register endpoint and register Device I
    print "\nConnecting to vehicle on: %s" % CONNECTION_TARGET
    print "----------------------------------------------------------------------"
    vehicle = connect(CONNECTION_TARGET, wait_ready=True, baud=BAUD)
    while (True):
        if (iotUtils.IS_REGISTERED):
            currentTime = calendar.timegm(time.gmtime())
            PUSH_DATA = iotUtils.SENSOR_STATS + '"time":'+str(currentTime)+'},"payloadData":{"quatanium_val_q1":'+0\
                        +',"quatanium_val_q2":'+0+',"quatanium_val_q3":'+0+',"quatanium_val_q4":'+0+',"velocity_x":'\
                        +str(vehicle.velocity[0])+',"velocity_y":'+str(vehicle.velocity[1])+',"velocity_z":'\
                        +str(vehicle.velocity[2])+',"global_location_lat":'+str(vehicle.location.global_relative_frame.lat)\
                        +',"global_location_alt":'+str(vehicle.location.global_relative_frame.alt)\
                        +',"global_location_lon":'+str(vehicle.location.global_relative_frame.lon)+',"battery_level":'\
                        +str(vehicle.battery.level)+',"battery_voltage":'+str(vehicle.battery.voltage)+',"pitch":'\
                        +str(vehicle.attitude.pitch)+',"roll":'+str(vehicle.attitude.roll)+',"yaw":'\
                        +str(vehicle.attitude.yaw)+',"deviceType":"IRIS_DRONE"}}}'
            mqttHandler.sendSensorValue(PUSH_DATA)
            print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Publishing Device-Data ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
            print('PUBLISHED DATA: ' + PUSH_DATA)
            time.sleep(PUSH_INTERVAL)
        else:
            registerAgent()
            time.sleep(PUSH_INTERVAL)
        print "-------------------------------------------------------------------------------------------------"
Пример #7
0
def main():
    configureLogger("agent")
    ListenMQTTThread()
    registerAgent()  # Call the register endpoint and register Device I
    print "\nConnecting to vehicle on: %s" % CONNECTION_TARGET
    print "----------------------------------------------------------------------"
    vehicle = connect(CONNECTION_TARGET, wait_ready=True, baud=BAUD)
    while (True):
        if(iotUtils.IS_REGISTERED):
            currentTime = calendar.timegm(time.gmtime())
            PUSH_DATA = iotUtils.SENSOR_STATS + '"time":'+str(currentTime)+'},"payloadData":{"quatanium_val_q1":'+0\
                        +',"quatanium_val_q2":'+0+',"quatanium_val_q3":'+0+',"quatanium_val_q4":'+0+',"velocity_x":'\
                        +str(vehicle.velocity[0])+',"velocity_y":'+str(vehicle.velocity[1])+',"velocity_z":'\
                        +str(vehicle.velocity[2])+',"global_location_lat":'+str(vehicle.location.global_relative_frame.lat)\
                        +',"global_location_alt":'+str(vehicle.location.global_relative_frame.alt)\
                        +',"global_location_lon":'+str(vehicle.location.global_relative_frame.lon)+',"battery_level":'\
                        +str(vehicle.battery.level)+',"battery_voltage":'+str(vehicle.battery.voltage)+',"pitch":'\
                        +str(vehicle.attitude.pitch)+',"roll":'+str(vehicle.attitude.roll)+',"yaw":'\
                        +str(vehicle.attitude.yaw)+',"deviceType":"IRIS_DRONE"}}}';
            mqttHandler.sendSensorValue(PUSH_DATA)
            print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Publishing Device-Data ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
            print ('PUBLISHED DATA: ' + PUSH_DATA)
            time.sleep(PUSH_INTERVAL)
        else:
            registerAgent()
            time.sleep(PUSH_INTERVAL)
        print "-------------------------------------------------------------------------------------------------"
def main():
    configureLogger("agent")
    ListenMQTTThread()
    #registerAgent()  # Call the register endpoint and register Device I
    while True:
           # send ack
         mqttHandler.sendSensorValue(10)
         pushSensorValue()
Пример #9
0
def main():
    configureLogger("agent")
    ListenMQTTThread()
    #registerAgent()  # Call the register endpoint and register Device I
    while True:
        # send ack
        mqttHandler.sendSensorValue(10)
        pushSensorValue()
Пример #10
0
def main():
    configureLogger("agent")
    ListenMQTTThread()
    registerAgent()  # Call the register endpoint and register Device I
    print "----------------------------------------------------------------------"
    while True:
        if iotUtils.IS_REGISTERED:
            print "-------------------------------------------------------------------------------------------------"
            currentTime = calendar.timegm(time.gmtime())
            randomLatitudeLongitudeValue = generateLatitudeLongitudeValue(INIT_LATITUDE, INIT_LONGITUDE, 5)
            print randomLatitudeLongitudeValue[1]
            PUSH_DATA = (
                iotUtils.SENSOR_STATS + '"time":' + str(currentTime) + '},"payloadData":{"quatanium_val_q1":34,'
                '"quatanium_val_q2":'
                + str(random.randint(15, 40))
                + ',"quatanium_val_q3":'
                + str(random.randint(15, 40))
                + ',"quatanium_val_q4":'
                + str(random.randint(5, 40))
                + ',"velocity_x":'
                + str(random.randint(1, 5))
                + ',"velocity_y":'
                + str(random.randint(1, 5))
                + ',"velocity_z":'
                + str(random.randint(1, 5))
                + ',"global_location_lat":'
                + str(randomLatitudeLongitudeValue[0])
                + ',"global_location_alt":45,"global_location_lon":'
                + str(randomLatitudeLongitudeValue[1])
                + ',"battery_level":'
                + str(random.randint(15, 100))
                + ',"battery_voltage":'
                + str(random.randint(15, 100))
                + ',"pitch":'
                + str(random.randint(15, 40))
                + ',"roll":'
                + str(random.randint(15, 40))
                + ',"yaw":'
                + str(random.randint(15, 40))
                + "}}}"
            )
            mqttHandler.sendSensorValue(PUSH_DATA)
            print "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Publishing Device-Data ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
            print ("PUBLISHED DATA: " + PUSH_DATA)
            time.sleep(PUSH_INTERVAL)
        else:
            registerAgent()
            time.sleep(PUSH_INTERVAL)
        print "-------------------------------------------------------------------------------------------------"
Пример #11
0
def main():
    configureLogger("agent")
    ListenMQTTThread()
    registerAgent()  # Call the register endpoint and register Device I
    while True:
        try:
            if(iotUtils.IS_REGISTERED):
                mqttHandler.sendSensorValue("Sensor:"+str(getSensorValue()))
                pushSensorValue()
            else:
                registerAgent()
            time.sleep(PUSH_INTERVAL)
        except (KeyboardInterrupt, Exception) as e:
            print "agentStats: Exception in AgentThread (either KeyboardInterrupt or Other)"
            print ("agentStats: " + str(e))
            print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
            pass
Пример #12
0
def main():
    configureLogger("agent")
    ListenMQTTThread()
    TemperatureReaderThread()
    while True:
        try:

            currentTime = calendar.timegm(time.gmtime())
            sensorValue = getSensorValue()
            PUSH_DATA_TO_STREAM_1 = iotUtils.SENSOR_STATS_SENSOR1.format(currentTime, sensorValue)

            mqttHandler.sendSensorValue(PUSH_DATA_TO_STREAM_1)
            print '~~~~~~~~~~~~~~~~~~~~~~~~ Publishing Device-Data ~~~~~~~~~~~~~~~~~~~~~~~~~'
            print ('PUBLISHED DATA STREAM 1: ' + PUSH_DATA_TO_STREAM_1)

            time.sleep(PUSH_INTERVAL)
        except (KeyboardInterrupt, Exception) as e:
            print "agentStats: Exception in AgentThread (either KeyboardInterrupt or Other)"
            print ("agentStats: " + str(e))
            print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
            pass
Пример #13
0
def main():
    configureLogger("agent")
    ListenMQTTThread()
    registerAgent()  # Call the register endpoint and register Device I
    while True:
        try:
            if(iotUtils.IS_REGISTERED):
                currentTime = calendar.timegm(time.gmtime())
                tempValue = getSensorValue()
                PUSH_DATA = iotUtils.SENSOR_STATS.format(currentTime, tempValue)
                mqttHandler.sendSensorValue(PUSH_DATA)
                print '~~~~~~~~~~~~~~~~~~~~~~~~ Publishing Device-Data ~~~~~~~~~~~~~~~~~~~~~~~~~'
                print ('PUBLISHED DATA: ' + PUSH_DATA)
            else:
                registerAgent()
            time.sleep(PUSH_INTERVAL)
        except (KeyboardInterrupt, Exception) as e:
            print "agentStats: Exception in AgentThread (either KeyboardInterrupt or Other)"
            print ("agentStats: " + str(e))
            print '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
            pass