Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
en:mervis-scada:50-api [2021/04/15 10:43]
m.chlupac
en:mervis-scada:50-api [2023/09/26 14:41]
v.kohout [api/get/history/specific]
Line 15: Line 15:
 ^api/get/history/specific|| ^api/get/history/specific||
 ^api/set/history|| ^api/set/history||
 +^api/replace/history||
 ^api/get/values|| ^api/get/values||
 ^api/get/alarms|| ^api/get/alarms||
Line 242: Line 243:
 </code> </code>
  
 +==== api/get/history/specific ====
 +
 +**Request**
 +
 +   * URL: /api/get/history/specific?format=json
 +   * Method: POST
 +   * You should always use token ("t") instead of simple name and password ("n" and "p"). Non-token call is slower.
 +   * "dataSpec" - data specification
 +      MinTimestamp = 0,
 +      MaxTimestamp = 1,
 +      FirstLessThanReferenceDateTime = 2,
 +      FirstLessThanOrEqualThanReferenceTime = 3,
 +      FirstGreaterThanReferenceDateTime = 4,
 +      FirstGreaterThanOrEqualThanReferenceTime = 5,
 +      MaxGoodThroughTime = 6 
 +   * "refTime" [optional] - reference time for dataSpec values 2 to 5
 +
 +
 +<code javascript>
 +{
 + "cred":
 + {
 +  "n":"test",
 +  "p":"test"
 + },
 +  "projId":"b4d96a6d-2b3d-48eb-af30-d11e875ba7ed",
 +  "offset":0,
 +  "count":1000,
 +  "dataSpec":2, 
 +  "refTime":"\/Date(123)\/",
 +  "dpIds":["58426e69-46ba-4925-9a5c-d7d65efb9886","f4501a2e-62ed-430e-9346-5e155e730fe3","28e7d087-917a-456a-9d02-96882f572286"]
 +}
 +</code>
 +
 +**Response**
 +
 +   * Values
 +     * v - value
 +     * ts - timestamp - start of the value validity period
 +     * gt - goodthrough - end of the value validity period
 +     * i - interval
 +
 +<code javascript>
 +{
 +    "ns": {
 +        "r": "http://dev.rcware.eu/serialization/references",
 +        "n1": "http://dev.rcware.eu/scada/history",
 +        "n2": "http://dev.rcware.eu/scada/datapoints",
 +        "n3": "http://dev.rcware.eu/scada/basic-props"
 +    },
 +    "doc": {
 +        "n1:getHistorySpecificResult": {
 +            "n2:pl": [
 +                {
 +                    "n2:p": {
 +                        "n1:hist": {
 +                            "@": {
 +                                "n1:projId": "b4d96a6d-2b3d-48eb-af30-d11e875ba7ed",
 +                                "n1:dpId": "58426e69-46ba-4925-9a5c-d7d65efb9886",
 +                                "n1:propName": "Output",
 +                                "n1:interval": "00:00:00",
 +                                "n1:historyState": "",
 +                                "n1:nextValOfs": 0
 +                            },
 +                            "n1:errMsg": "",
 +                            "n1:vals": [
 +                                {
 +                                    "n1:hv": {
 +                                        "@": {
 +                                            "n1:ts": "2023-08-23T11:00:57.7010708Z",
 +                                            "n1:i": "1.00:00:00"
 +                                        },
 +                                        "n3:v": 12.48
 +                                    }
 +                                }
 +                            ]
 +                        },
 +                        "@": {
 +                            "r:type": "b133774d-21ce-42b6-add3-57c012079c55"
 +                        }
 +                    }
 +                },
 +                {
 +                    "n2:p": {
 +                        "n1:hist": {
 +                            "@": {
 +                                "n1:projId": "b4d96a6d-2b3d-48eb-af30-d11e875ba7ed",
 +                                "n1:dpId": "f4501a2e-62ed-430e-9346-5e155e730fe3",
 +                                "n1:propName": "Output",
 +                                "n1:interval": "00:00:00",
 +                                "n1:historyState": "",
 +                                "n1:nextValOfs": 0
 +                            },
 +                            "n1:errMsg": "",
 +                            "n1:vals": [
 +                                {
 +                                    "n1:hv": {
 +                                        "@": {
 +                                            "n1:ts": "2023-08-23T10:38:43.784Z",
 +                                            "n1:gt": "2023-08-23T11:18:00.207Z",
 +                                            "n1:i": "00:00:30"
 +                                        },
 +                                        "n3:v": 5.0
 +                                    }
 +                                }
 +                            ]
 +                        },
 +                        "@": {
 +                            "r:type": "b133774d-21ce-42b6-add3-57c012079c55"
 +                        }
 +                    }
 +                },
 +                {
 +                    "n2:p": {
 +                        "n1:hist": {
 +                            "@": {
 +                                "n1:projId": "b4d96a6d-2b3d-48eb-af30-d11e875ba7ed",
 +                                "n1:dpId": "28e7d087-917a-456a-9d02-96882f572286",
 +                                "n1:propName": "Output",
 +                                "n1:interval": "00:00:00",
 +                                "n1:historyState": "",
 +                                "n1:nextValOfs": 0
 +                            },
 +                            "n1:errMsg": "",
 +                            "n1:vals": [
 +                                {
 +                                    "n1:hv": {
 +                                        "@": {
 +                                            "n1:ts": "2023-08-23T10:38:43.786Z",
 +                                            "n1:gt": "2023-08-23T11:18:00.207Z",
 +                                            "n1:i": "00:00:30"
 +                                        },
 +                                        "n3:v": "ZAP"
 +                                    }
 +                                }
 +                            ]
 +                        },
 +                        "@": {
 +                            "r:type": "177e726a-3180-4152-bef2-6254e7055e1f"
 +                        }
 +                    }
 +                }
 +            ],
 +            "@": {
 +                "r:type": "1c4c1ddc-463f-443d-883a-19489cd2e53a"
 +            }
 +        }
 +    }
 +}
 +
 +</code>
  
 ==== [Depricated] api/get/history==== ==== [Depricated] api/get/history====
Line 364: Line 516:
   </vals>   </vals>
 </setHistoryRequest></code> </setHistoryRequest></code>
 +
 +**Response**
 +
 +   * 200 OK
 +
 +====api/replace/history====
 +
 +**Request**
 +
 +   * URL: /api/replace/history?format=xml
 +   * Method: POST
 +   * Content-Type: text/xml
 +
 +Attribute **i** sets **interval** ([[https://en.wikipedia.org/wiki/ISO_8601#Time_intervals|ISO 8601]]) in which the next value should be expected to be saved into a database.
 +
 +Even though there could be used name and password in **cred** - you should always use **token** to get the best performance.
 +
 +All date and time values are supposed to be in UTC.
 +
 +<code xml>
 +<?xml version="1.0" encoding="UTF-8"?>
 +<replaceHistoryRequest xmlns="http://dev.rcware.eu/scada/history" 
 +xmlns:n2="http://dev.rcware.eu/auth" 
 +xmlns:n1="http://dev.rcware.eu/scada/basic-props" 
 +projId="5abf8ca0-94ba-48df-8d3c-7ebe87a12fd0" 
 +dpId="e86dba6d-1250-4e7f-aafb-84fd28324710"
 +from="2020-03-15T11:00:00+00:00"
 +to="2020-03-18T11:00:00+00:00">
 +  <n2:cred t="xxxxx"/><!-- token should be used here -->
 +  <vals>
 +    <hv ts="2020-03-15T11:00:00+00:00" i="P1D">
 +      <n1:v>2.7</n1:v>
 +    </hv>
 +    <hv ts="2020-03-16T11:00:00+00:00" i="P1D">
 +      <n1:v>3.0</n1:v>
 +    </hv>
 +    <hv ts="2020-03-17T11:00:00+00:00" i="P1D">
 +      <n1:v>2.0</n1:v>
 +    </hv>
 +    <hv ts="2020-03-18T11:00:00+00:00" i="P1D">
 +      <n1:v>2.3</n1:v>
 +    </hv>
 +  </vals>
 +</replaceHistoryRequest></code>
  
 **Response** **Response**
  • © Energocentrum Plus, s.r.o. 2017 - 2024