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
en:mervis-scada:50-api [2020/04/27 12:45]
m.chlupac [api/set/history]
en:mervis-scada:50-api [2023/09/26 14:42] (current)
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 40: Line 41:
    * URL: /api/checkCredentials?format=xml    * URL: /api/checkCredentials?format=xml
    * Method: POST    * Method: POST
- 
-**Request** 
  
 <code javascript> <code javascript>
Line 56: Line 55:
   * You **should** use the received token **t** in subsequent API calls.   * You **should** use the received token **t** in subsequent API calls.
  
-====api/get/history====+ 
 + 
 +==== api/v3/get/history ==== 
 + 
 +**Request** 
 + 
 +   * URL: /api/v3/get/history?format=json 
 +   * Method: POST 
 +   * Downloading of one or multiple trends with single API call 
 +   * You should always use "token" instead of simple "name" a "password". Non-token call is slower. 
 +   * "seriesParameters" [optional] - use only if you request different parameters than "commonSeriesParameters" 
 +   * "clientReference" [optional] - use for your own identification of the series 
 +   * Items: "segmenation", "requestState" and "serverState" should always copy the values from the last server response. First call should use empty "segmentation"
 + 
 + 
 +<code javascript> 
 +
 +    "credentials":
 +        "token":"guid" //string 
 +    }, 
 +    "request":
 +        "commonSeriesParameters":
 +            "from": "2018-12-01T00:00:00Z", //UTC dateTime 
 +            "to": "2018-12-01T10:00:00Z"//UTC dateTime 
 +        }, 
 +        "series":
 +            { 
 +                "seriesParameters":
 +                    "from": "2017-11-28T14:26:16.5029619Z",//UTC dateTime 
 +                    "to": "2018-11-28T14:26:16.5029619Z" //UTC dateTime 
 +                }, 
 +                "clientReference": "myId2a", //string 
 +                "provider":
 +                    "parameters":
 +                        "projectId": "5abf8ca0-94ba-48df-8d3c-7ebe87a12fd0", //guid 
 +                        "dataPointId": "2a9c26c9-2ce3-49c4-909d-9ac1143121f1" //guid 
 +                    } 
 +                } 
 +            }, 
 +            { 
 +                "clientReference": "myId1a", 
 +                "provider":
 +                    "parameters":
 +                        "projectId": "5abf8ca0-94ba-48df-8d3c-7ebe87a12fd0", 
 +                        "dataPointId": "62cf4083-31ed-4bc1-be25-044ba837a9f0" 
 +                    } 
 +                } 
 +            } 
 +        ] 
 +    }, 
 +    "dataSpecification":
 +        "limits":
 +            "count": 1000 //int 
 +        } 
 +    }, 
 +    "segmentation":
 +        "requestState": ";;2;;0", //string 
 +        "serverState": "xyz" //string 
 +    } 
 +
 +</code> 
 + 
 +**Response** 
 + 
 +   * Empty "segmentation" ("requestState") marks response containing last data of the requested series 
 +   * "requestState" and "serverState" must be copied to the next API call 
 +   * Values 
 +     * v - value 
 +     * ts - timestamp - start of the value validity period 
 +     * gt - goodthrough - end of the value validity period 
 +     * i - interval, only present if it differs from the interval in Meta section 
 +   * Meta 
 +     * type - value type - double, string, datetime 
 +     * unit - unit 
 +     * interval - expected interval between the stored records. Useful to identify missing data. 
 + 
 +<code javascript> 
 +
 +"result":
 +        "code": 0, //int 
 +        "subCode": 0, //int 
 +        "message": "" //string 
 +    }, 
 +    "data":
 +        "count": 3, //int 
 +        "historyData":
 +            { 
 +                "clientReference": "myId2a", //string 
 +                "provider":
 +                    "id": "689e32fa-24a2-448e-9374-6158e6e6cb15", //guid 
 +                    "parameters":
 +                        "projectId": "5abf8ca0-94ba-48df-8d3c-7ebe87a12fd0", //guid 
 +                        "dataPointId": "2a9c26c9-2ce3-49c4-909d-9ac1143121f1" //guid 
 +                    } 
 +                }, 
 +                "meta":
 +                    "type": "string", //string 
 +                    "unit": "", //string 
 +                    "interval": "PT3M" //string - ISO8601 Timespan 
 +                }, 
 +                "values":
 +                    { 
 +                        "v": "AUT", //string 
 +                        "ts": "2018-11-26T12:22:15.25795Z", //dateTime 
 +                        "gt": "2018-11-26T13:22:15.5784067Z" //dateTime 
 +                    } 
 +                ] 
 +            }, 
 +            { 
 +                "clientReference": "myId1a", 
 +                "provider":
 +                    "parameters":
 +                        "projectId": "5abf8ca0-94ba-48df-8d3c-7ebe87a12fd0", 
 +                        "dataPointId": "62cf4083-31ed-4bc1-be25-044ba837a9f0" 
 +                    } 
 +                }, 
 +                "meta":
 +                    "type": "double", 
 +                    "unit": "hod", 
 +                    "interval": "PT3M" 
 +                }, 
 +                "values":
 +                    { 
 +                        "v": 12939,//double 
 +                        "ts": "2018-11-30T23:58:15.2394603Z", 
 +                        "gt": "2018-12-01T01:37:15.4869553Z" 
 +                    }, 
 +                    { 
 +                        "v": 12946, 
 +                        "ts": "2018-12-01T09:22:16.2049051Z", 
 +                        "gt": "2018-12-01T10:37:15.4023519Z", 
 +                        "i": "PT4M" 
 +                    } 
 +                ] 
 +            } 
 +        ] 
 +    }, 
 +    "segmentation":
 +        "requestState": "xyz", //string 
 +        "serverState": "xyz" //string 
 +    } 
 +
 + 
 + 
 +</code> 
 + 
 +**Demo** 
 +<code javascript> 
 +
 +    "credentials":
 +        "name": "demo", 
 +        "password": "demo" 
 +    }, 
 +    "request":
 +        "commonSeriesParameters":
 +            "from": "2018-12-01T00:00:00Z", 
 +            "to": "2018-12-01T00:11:00Z" 
 +        }, 
 +        "series":
 +            { 
 +                "clientReference": "myId1", 
 +                "provider":
 +                    "parameters":
 +                        "projectId": "5abf8ca0-94ba-48df-8d3c-7ebe87a12fd0", 
 +                        "dataPointId": "acad79f3-3358-42dd-9b74-98733e63d771" 
 +                    } 
 +                } 
 +            }, 
 +            { 
 +                "clientReference": "myId2", 
 +                "provider":
 +                    "parameters":
 +                        "projectId": "5abf8ca0-94ba-48df-8d3c-7ebe87a12fd0", 
 +                        "dataPointId": "14cf0dbb-b050-43aa-a6f0-22886c33ed8e" 
 +                    } 
 +                } 
 +            } 
 +        ] 
 +    }, 
 +    "dataSpecification":
 +        "limits":
 +            "count": 1000 
 +        } 
 +    } 
 +
 + 
 +</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(1692788459000)\/", 
 +  "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":
 +                            }, 
 +                            "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":
 +                            }, 
 +                            "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":
 +                            }, 
 +                            "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====
  
 **Request** **Request**
Line 177: 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**
Line 188: Line 571:
    * URL: /api/set/executeActions?format=xml    * URL: /api/set/executeActions?format=xml
    * Method: POST    * Method: POST
 +   * Content-Type: text/xml
  
 <code xml> <code xml>
Line 267: Line 651:
 </values></code> </values></code>
  
 +====api/get/projectByParts====
  
 +To get the list of datapoints.
 +
 +**Request**
 +
 +   * URL: /api/get/projectByParts?format=xml
 +   * Method: POST
 +
 +<code javascript>
 +{
 + "cred": {
 +  "t": "xxxxxx"
 + },
 + "projId": "5abf8ca0-94ba-48df-8d3c-7ebe87a12fd0",
 + "treeId": "Visual tree",
 + "partType": 0,
 + "offset": 0,
 + "count": 250
 +}
 +</code>
 +
 +**Response**
 +
 +<code xml><?xml version="1.0" encoding="utf-8"?>
 +<getProjectByPartsResult xmlns:r="http://dev.rcware.eu/serialization/references" projId="5abf8ca0-94ba-48df-8d3c-7ebe87a12fd0" dataVersion="637305748282414171" totalCount="79" nextOffset="-1" xmlns:n1="http://dev.rcware.eu/scada/comm-props" xmlns:n2="http://dev.rcware.eu/rt2com" xmlns:n3="http://dev.rcware.eu/scada/basic-props" xmlns:n4="http://dev.rcware.eu/scada/legacy-props" xmlns="http://dev.rcware.eu/scada/datapoints">
 + <dps>
 +  <dp id="393df7b4-bb8d-4e8f-92a7-bf785508894a" n="Provozni podminky OK" canAct="true" canAlr="true">
 +   <v>
 +    <props>
 +     <p n="Source" t="2020-10-05T07:17:11.601879Z" q="Good" n1:dateTimeKind="UTC" r:type="1c104bdf-ffcb-4c90-b491-e4781a91ef09">
 +      <n1:r n2:rp="PT0S" r:type="7b047602-40da-4095-9093-062ba30fd15e">
 +       <n2:a id="3b1e3b8b-2186-4dcf-b157-8032c768d1e1" n="SW.Provozni podminky OK"/>
 +      </n1:r>
 +      <n1:w r:type="5ddc9dbf-a6bd-458b-a6ab-f661db0e3a64">
 +       <n2:a id="3b1e3b8b-2186-4dcf-b157-8032c768d1e1" n="SW.Provozni podminky OK"/>
 +      </n1:w>
 +      <n1:v>1</n1:v>
 +     </p>
 +     <p n="Output" t="2020-10-05T07:16:58.751431Z" q="Good" r:type="177e726a-3180-4152-bef2-6254e7055e1f">
 +      <n3:v>OK</n3:v>
 +     </p>
 +     <p n="StdVis_V1" t="2015-06-03T13:17:13.5190205Z" q="Good" r:type="b0db7bd7-0375-4830-90f2-6d918bac41ee">
 +      <n3:v>
 +       <n3:props>
 +        <n3:p>
 +         <n3:pn>Output</n3:pn>
 +         <n3:props>
 +          <n3:p r:type="256a44f6-32e4-4a75-b7c2-08eed38f151d">
 +           <n3:ordMap>
 +            <n3:grOrd>
 +             <n3:t>OK</n3:t>
 +             <n3:o>0</n3:o>
 +            </n3:grOrd>
 +            <n3:grOrd>
 +             <n3:t>ALARM</n3:t>
 +             <n3:o>1</n3:o>
 +            </n3:grOrd>
 +           </n3:ordMap>
 +          </n3:p>
 +         </n3:props>
 +        </n3:p>
 +       </n3:props>
 +      </n3:v>
 +     </p>
 +    </props>
 +   </v>
 +   <core r:type="2f04d90c-ee95-4cb6-b945-146e33021945"/>
 +  </dp>
 +  <dp id="3e5c0b88-45fd-4e3f-b1b2-1a365327ec90" n="Zaplavení" canAct="true" canAlr="true">
 +   <v>
 +    <props>
 +     <p n="Source" t="2020-08-17T10:21:46.470472Z" q="Good" n1:dateTimeKind="UTC" r:type="1c104bdf-ffcb-4c90-b491-e4781a91ef09">
 +      <n1:r n2:rp="PT0S" r:type="7b047602-40da-4095-9093-062ba30fd15e">
 +       <n2:a id="45c31fe4-00b0-4498-b9f6-adfe6a2fe34b" n="SW.Zaplavení mem"/>
 +      </n1:r>
 +      <n1:w r:type="5ddc9dbf-a6bd-458b-a6ab-f661db0e3a64">
 +       <n2:a id="45c31fe4-00b0-4498-b9f6-adfe6a2fe34b" n="SW.Zaplavení mem"/>
 +      </n1:w>
 +      <n1:v>0</n1:v>
 +     </p>
 +     <p n="Output" t="2020-08-17T10:21:46.470472Z" q="Good" r:type="177e726a-3180-4152-bef2-6254e7055e1f">
 +      <n3:v>OK</n3:v>
 +     </p>
 +     <p n="StdVis_V1" t="2015-06-03T13:17:13.5190205Z" q="Good" r:type="b0db7bd7-0375-4830-90f2-6d918bac41ee">
 +      <n3:v>
 +       <n3:props>
 +        <n3:p>
 +         <n3:pn>Output</n3:pn>
 +         <n3:props>
 +          <n3:p r:type="256a44f6-32e4-4a75-b7c2-08eed38f151d">
 +           <n3:ordMap>
 +            <n3:grOrd>
 +             <n3:t>OK</n3:t>
 +             <n3:o>0</n3:o>
 +            </n3:grOrd>
 +            <n3:grOrd>
 +             <n3:t>ALARM</n3:t>
 +             <n3:o>1</n3:o>
 +            </n3:grOrd>
 +           </n3:ordMap>
 +          </n3:p>
 +         </n3:props>
 +        </n3:p>
 +       </n3:props>
 +      </n3:v>
 +     </p>
 +    </props>
 +   </v>
 +   <core r:type="2f04d90c-ee95-4cb6-b945-146e33021945"/>
 +   <alr>
 +    <def enabled="true" delay="PT1M"/>
 +    <galrs/>
 +    <status user="SYSTEM" incidentId="88ba7198-de57-4854-8130-60c240a09522" lastChangeTime="2020-08-11T12:37:04.8002341Z"/>
 +   </alr>
 +  </dp>
 + </dps>
 +</getProjectByPartsResult></code>
 ===== Matlab Client ===== ===== Matlab Client =====
 ==== General notes client function parameters ==== ==== General notes client function parameters ====
  • © Energocentrum Plus, s.r.o. 2017 - 2024