• 沒有找到結果。

Sending sensor data samples with timestamps

在文檔中 國立交通大學 (頁 25-28)

3. FileLogger device Implementation

3.1. Sending sensor data samples with timestamps

As we mentioned in chapter 2.3, to obtain more accurate experiment

need to collect not only the sensor data samples but also the sampled times. There are two cases for the implementation. In the first case, there

sensor, and for every received sensor data sample, we add the timesta add_timestamp function (see Fig. 17).

In the second case, the sensor (such as a

Therefore, the sensor data samples are sent to the IoTtalk server with timestamps.

To implement the functions for sending the data of with timestamps, we add a tag for timestamp

device and reuse the DF format of the Remote Control device in the (edutalk/fixtures/defalut.yaml)

Fig. 18 shows the IDFs

Remote Control device. The lectureRC model includes sensors and the MorSensor sensors.

Smartphone sensors, as an example, parameters 1 to 3 in floating represent the 3-dimensional data measured by the acceleration sensor Another example is the IDF Alcohol

in Fig. 20. Parameter 1, by the alcohol sensor.

device Implementation

This chapter describes the implementation of the FileLogger device. We first describe how to send data with timestamps from the Remote Control device to IoTtalk.

Then, we explain how to provide the variables for users to access the da timestamps in the lecture program with the Cyber device. Last, we

FileLogger device receives data with timestamps.

3.1 Sending sensor data samples with timestamps

As we mentioned in chapter 2.3, to obtain more accurate experiment

need to collect not only the sensor data samples but also the sampled times. There are two cases for the implementation. In the first case, there is no timer available

sensor, and for every received sensor data sample, we add the timesta add_timestamp function (see Fig. 17).

Fig. 17. The add_timestamp function.

In the second case, the sensor (such as a Smartphone) has a built Therefore, the sensor data samples are sent to the IoTtalk server with timestamps.

To implement the functions for sending the data of the Remote Control device , we add a tag for timestamps in DFs of each DM for Remote Control device and reuse the DF format of the Remote Control device in the

xtures/defalut.yaml) to match the following default DF format.

IDFs of lectureRC (Remote Control) model, the DM of the Remote Control device. The lectureRC model includes IDFs

sensors and the MorSensor sensors. Taking Acceleration-I, one of the IDFs of as an example, parameters 1 to 3 in floating

dimensional data measured by the acceleration sensor

Another example is the IDF Alcohol-I of MorSensor sensors. Its data format is shown a floating-point number, which represents the data measured This chapter describes the implementation of the FileLogger device. We first describe how to send data with timestamps from the Remote Control device to IoTtalk.

to access the data and timestamps in the lecture program with the Cyber device. Last, we illustrate how the

As we mentioned in chapter 2.3, to obtain more accurate experiment results, we need to collect not only the sensor data samples but also the sampled times. There are is no timer available in the sensor, and for every received sensor data sample, we add the timestamp with the

martphone) has a built-in timer.

Therefore, the sensor data samples are sent to the IoTtalk server with timestamps.

Remote Control device in DFs of each DM for Remote Control device and reuse the DF format of the Remote Control device in the configuration file

to match the following default DF format.

RC (Remote Control) model, the DM of the point number, which represents the data measured

Fig.

Fig.

F

To embed timestamps to the sampled data, we modify the event handlers of SA (edutalk/static/js/rc/sensor.js

receives a new sample from timestamp by using the getTime

passes the UNIX timestamp to the corresponding attributes of each sensor ig. 18. The IDFs of the lectureRC model.

ig. 19. Acceleration-I device feature format.

Fig. 20. Alcohol-I device feature format.

embed timestamps to the sampled data, we modify the event handlers of SA edutalk/static/js/rc/sensor.js) of the Remote Control device. When the event handler

rom the sensor, it creates a Date object and o

getTime function of the Date object. The event handler then passes the UNIX timestamp to the corresponding attributes of each sensor

embed timestamps to the sampled data, we modify the event handlers of SA ) of the Remote Control device. When the event handler creates a Date object and obtains the UNIX function of the Date object. The event handler then passes the UNIX timestamp to the corresponding attributes of each sensor. For

examples, we add a new attribute acc.time for the accelerometer and another new attribute alc.time for the Alcoholmeter.

After the Remote Control device has sampled the sensor data with the timestamp, it displays them on the display web page and pushes the data to IoTtalk. Therefore, we modify the display web page (edutalk/templates/rc/index.html) of the Remote Control device to show the data on the screen of the Smartphone and modify the event handlers of SA (edutalk/static/js/rc/sensor.js) of the Remote Control device to push the data with timestamps to IoTtalk.

To show the sampled data with timestamps on the screen of the Smartphone, we add a new row below the sampled data for each sensor. To help people recognize, we convert the timestamp from UNIX format to a human-readable format. The result of the display web page of the Remote Control device is shown as Fig. 21. To push the data with timestamps to IoTtalk, we simply use the push_sensor_value and the push_handler functions like before, since the event handler already attached timestamps to the sampled data.

Fig. 21. The display web page of the Remote Control device.

在文檔中 國立交通大學 (頁 25-28)