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 [2021/04/15 10:43]
m.chlupac
en:mervis-scada:50-api [2025/02/27 11:43] (current)
v.kohout [api/get/projectByParts]
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(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": 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**
Line 396: Line 592:
   </actionDefs>   </actionDefs>
 </executeActionsRequest></code> </executeActionsRequest></code>
 +
 +**Response**
 +
 +<code xml><?xml version="1.0" encoding="utf-8"?>
 +<executeActionsResponse xmlns:r="http://dev.rcware.eu/serialization/references" code="Ok" message="OK" xmlns="http://dev.rcware.eu/scada/error-reporting" /></code>
 +
 +====api/set/values====
 +
 +**Request**
 +
 +   * URL: /api/set/values?format=xml
 +   * Method: POST
 +   * Content-Type: text/xml
 +
 +<code xml>
 +<?xml version="1.0" encoding="UTF-8"?>
 +<setValuesRequest xmlns:r="http://dev.rcware.eu/serialization/references" xmlns="http://dev.rcware.eu/scada/datapoints" xmlns:n2="http://dev.rcware.eu/auth" xmlns:n1="http://dev.rcware.eu/scada/comm-props" >
 +   <n2:cred n="demo" p="demo"/>
 +        <values projId="1b2623be-eaa4-4e29-8596-c66dd85d5643">
 +            <dps>
 +                <d id="07d538d9-9f4b-46ca-ba4d-13b13b5302ff">
 +                    <props>
 +                        <p n="Source" t="2024-02-23T09:58:00Z" r:type="1c104bdf-ffcb-4c90-b491-e4781a91ef09">
 +                            <n1:v>23</n1:v>
 +                        </p>
 +                    </props>
 +                </d>
 +            </dps>
 +        </values>
 +</setValuesRequest></code>
  
 **Response** **Response**
Line 573: Line 799:
  </dps>  </dps>
 </getProjectByPartsResult></code> </getProjectByPartsResult></code>
 +
 +====api/get/projects====
 +
 +To get the list of projects.
 +
 +**Request**
 +
 +   * URL: /api/get/projects?format=xml
 +   * Method: POST
 +
 +<code javascript>
 +{
 + "cred":
 + {
 + "n":"xxx",
 + "p":"xxx"
 + },
 + "offset":0,
 + "count":250
 +}
 +</code>
 +
 +**Response**
 +
 +<code xml><?xml version="1.0" encoding="utf-8"?>
 +<?xml version="1.0" encoding="utf-8"?>
 +<getProjectsResult xmlns:r="http://dev.rcware.eu/serialization/references" xmlns:n1="http://dev.rcware.eu/loc" xmlns:n2="http://dev.rcware.eu/scada/notifications" xmlns:n3="http://dev.rcware.eu/scada/schemas" xmlns:n4="http://dev.rcware.eu/projectMetadata" dataVersion="638761649652581521" xmlns="http://dev.rcware.eu/scada/projects">
 +    <projects>
 +        <project id="00000000-3333-0000-0000-000001000001" name="P0001" domain="PP_Domain_0001" tz="Europe/Prague">
 +            <loc>
 +                <n1:gps lat="0" lon="0" />
 +            </loc>
 +            <mdi>
 +                <mi n2:moduleInstantiated="true" r:type="073d1b6c-24f5-435a-a5bd-1d54e04b0d06" r:def="1" />
 +                <mi n3:totalAllowedSchemasCount="1" n3:totalSchemasCount="1" r:type="aa8818ce-d47d-41ff-9be5-3de9f34d7ebf" />
 +            </mdi>
 +        </project>
 +        <project id="03cd3dd9-e170-4799-bc26-17ac0eccf780" name="aaa" domain="DomainTes1" tz="Europe/Prague">
 +            <mdi>
 +                <mi r:ref="1" r:type="073d1b6c-24f5-435a-a5bd-1d54e04b0d06" />
 +                <mi r:type="1fe100d2-2dbe-4737-bb10-7cf2a19123b2">
 +                    <n3:schemas />
 +                    <n3:schemaGroups />
 +                    <n3:slideShow />
 +                </mi>
 +            </mdi>
 +        </project>
 +    </projects>
 +</getProjectsResult>
 +</code>
 ===== Matlab Client ===== ===== Matlab Client =====
 ==== General notes client function parameters ==== ==== General notes client function parameters ====
  • © Energocentrum Plus, s.r.o. 2017 - 2025