Exemplo n.º 1
0
def data_packet(data):
    """
    This script makes a sensor packet and sends it to the NC.
    :param string data: The sensor data.
    """
    packet = packetmaker.make_data_packet(data)
    for pack in packet:
        send(pack)
Exemplo n.º 2
0
                        timestamp_epoch =  int(float(timestamp_utc.strftime("%s.%f"))* 1000)


                        # extract sensor name
                        output_array = sensorsData[1].split(':')
                        output_name = output_array[0]


                        try:
                            sensor_name = output2sensor[output_name]
                        except Exception as e:
                            print(("Output %s unknown" % (output_name)))
                            sensor_name = ''

                        if sensor_name:
                            sendData=[str(timestamp_date), 'env_sense', '1', 'default', str(timestamp_epoch), sensor_name, "meta.txt", sensorsData[1:-1]]
                            print(('Sending data: ', str(sendData)))
                            #packs and sends the data
                            packet = packetmaker.make_data_packet(sendData)
                            for pack in packet:
                                send(pack)




except KeyboardInterrupt as k:
    try:
        wxsensor.close()
    except:
        pass
Exemplo n.º 3
0
                                        reading_unit[Sensor_Index.index(
                                            currentSensor[0])])
                                    sensorReading_bucket[which_row][4] = list(
                                        reading_note[Sensor_Index.index(
                                            currentSensor[0])])
                                except:
                                    pass
                        for all in range(len(sensorReading_bucket)):
                            if (sensorReading_bucket[all] <> [[], [], [], [],
                                                              []]):
                                sendData = [
                                    sensor_names[all],
                                    int(time.time()),
                                    sensorReading_bucket[all][0],
                                    sensorReading_bucket[all][1],
                                    sensorReading_bucket[all][2],
                                    sensorReading_bucket[all][3],
                                    sensorReading_bucket[all][4]
                                ]
                                #print sendData
                                #packs and sends the data
                                packet = packetmaker.make_data_packet(sendData)
                                for pack in packet:
                                    send(pack)
                        time.sleep(1)
except KeyboardInterrupt, k:
    try:
        wxsensor.close()
    except:
        pass
Exemplo n.º 4
0
            "f",
            "f",
            "f",
            "f",
            "f",
            "f",
            "f",
            "f",
            "f",
        ]

        # Lastly, put it all together in Cassandra accepted format
        status_report = ["WagMan", timestamp, measuring, data_types, raw_data, units, [""]]

        # pack status report as waggle message
        packet = packetmaker.make_data_packet(status_report)

        # send status report to cloud
        for _pack in packet:
            send(_pack)
        # print status_report

    # Is SysMon about to inform me of a problem?
    elif incomingNotifier == "#":
        # Wait for problem report
        incomingProblem = ser_SysMon.readline().strip()
        # TODO change this if you no longer want WagMan data to go to Cassandra
        # problem report comes in a string
        # need to format problem report for Cassandra before sending to cloud.

        # First, convert string into list