API - Получение данных для события/en — различия между версиями
(Новая страница: «Consider an example of two events. Event number 1 is the parent event. It starts on the 5th second of every minute and ends on the 40th second of every minute. Th…») |
(Новая страница: «The second event is the child event for the first event. Therefore, it can only be executed when the first event is executed. In addition, the condition is limite…») |
||
Строка 22: | Строка 22: | ||
[[Файл:Event-data-2.png|700px]] | [[Файл:Event-data-2.png|700px]] | ||
− | + | The second event is the child event for the first event. Therefore, it can only be executed when the first event is executed. In addition, the condition is limited so that it starts at the 25th second of every minute and ends at the 35th. Data for it is written to the log every 2 seconds. The current value of the I60 register is written to the log. Screenshots illustrate the setting of this event. | |
<br> | <br> | ||
[[Файл:Event-data-5.png|700px]]<br><br> | [[Файл:Event-data-5.png|700px]]<br><br> |
Версия 09:12, 18 апреля 2018
To get data from event log, it is necessary to run following GET-query for URL http://192.168.1.1/api/event-data/2. Here 2 - is the ID of the graph of interest.
In the request headers, you must pass the API key and the boundaries of the time interval of interest. X-WH-START and X-WH-END are transmitted in UnixTime format. For example:
X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7 X-WH-START: 1422797440 X-WH-END: 1422997405
Also, in the headers, you must specify the desired data exchange format. Currently, only the JSON format is supported.
Accept: application/json Content-Type: application/json
Consider an example of two events. Event number 1 is the parent event. It starts on the 5th second of every minute and ends on the 40th second of every minute. The log records data once for the entire event. The time of the beginning of the event and the last value of the interval register I60 are recorded in the log. Screenshots illustrate the setting of this event.
The second event is the child event for the first event. Therefore, it can only be executed when the first event is executed. In addition, the condition is limited so that it starts at the 25th second of every minute and ends at the 35th. Data for it is written to the log every 2 seconds. The current value of the I60 register is written to the log. Screenshots illustrate the setting of this event.
Пример запроса данных о событии номер 1:
URL: http://192.168.1.1/api/event-data/1
Method: GET
Заголовки:
Accept: application/json Content-Type: application/json Accept-Encoding: gzip, deflate, sdch X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7 X-WH-START: 1422797440 X-WH-END: 1422997405
Пример ответа:
[ { "rowid": "3050", "event_id": "1", "start_time": "1422797405", "end_time": "1422797440", "xtra_regs": [ { "E1.0": 1422797405 }, { "E1.1": 39 } ] }, { "rowid": "3052", "event_id": "1", "start_time": "1422797465", "end_time": "1422797500", "xtra_regs": [ { "E1.0": 1422797465 }, { "E1.1": 39 } ] }, { "rowid": "3054", "event_id": "1", "start_time": "1422797525", "end_time": "1422797560", "xtra_regs": [ { "E1.0": 1422797525 }, { "E1.1": 39 } ] }, { "rowid": "3056", "event_id": "1", "start_time": "1422797585", "end_time": "1422797680", "xtra_regs": [ { "E1.0": 1422797585 }, { "E1.1": 39 } ] }, { "rowid": "3058", "event_id": "1", "start_time": "1422797705", "end_time": "1422797740", "xtra_regs": [ { "E1.0": 1422797705 }, { "E1.1": 39 } ] }, { "rowid": "3060", "event_id": "1", "start_time": "1422797765", "end_time": "1422797800", "xtra_regs": [ { "E1.0": 1422797765 }, { "E1.1": 39 } ] }, { "rowid": "3062", "event_id": "1", "start_time": "1422797825", "end_time": "0", "xtra_regs": [ { "E1.0": 1422797825 }, { "E1.1": 39 } ] } ]
Атрибуты данных события:
rowid | int | Уникальный идентификатор события в базе данных |
event_id | int | ID события |
start_time | int | Время начала события |
end_time | int | Время окончания события. Если событие еще не окончилось то end_time = 0 |
xtra_regs | object | Объект с данными о дополнительных регистрах которые сохраняются в логе событий. Ключ-значение. |
Формат имени дополнительных регистров:
"E" + ID события + "." + порядковый номер регистра в событии начиная с нуля
Пример запроса данных для события номер 2:
URL: http://192.168.1.1/api/event-data/2
Method: GET
Заголовки:
Accept: application/json Content-Type: application/json Accept-Encoding: gzip, deflate, sdch X-WH-APIKEY: F3C74230818DA487BB2017CE5D0290F4DABCAFD7 X-WH-START: 1422804505 X-WH-END: 1422800200
Пример ответа:
[ { "rowid": "3201", "event_id": "2", "start_time": "1422804505", "end_time": "1422804515", "xtra_regs": [ { "E2.0": 25 } ] }, { "rowid": "3201", "event_id": "2", "start_time": "1422804505", "end_time": "1422804515", "xtra_regs": [ { "E2.0": 27 } ] }, { "rowid": "3201", "event_id": "2", "start_time": "1422804505", "end_time": "1422804515", "xtra_regs": [ { "E2.0": 29 } ] }, { "rowid": "3201", "event_id": "2", "start_time": "1422804505", "end_time": "1422804515", "xtra_regs": [ { "E2.0": 31 } ] }, { "rowid": "3201", "event_id": "2", "start_time": "1422804505", "end_time": "1422804515", "xtra_regs": [ { "E2.0": 33 } ] } ]