Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
en:mervis-scada:50-api [2018/11/06 12:59] m.chlupac |
en:mervis-scada:50-api [2020/04/27 12:45] m.chlupac [api/set/executeActions] |
||
---|---|---|---|
Line 3: | Line 3: | ||
Mervis SCADA offers open REST-like API based on JSON and XML data formats. For full description please contact our [[: | Mervis SCADA offers open REST-like API based on JSON and XML data formats. For full description please contact our [[: | ||
+ | **Important: | ||
===== List of basic API methods ===== | ===== List of basic API methods ===== | ||
^Function^Description| | ^Function^Description| | ||
- | |||
^api/ | ^api/ | ||
^api/ | ^api/ | ||
Line 32: | Line 32: | ||
- | ===== Example | + | ===== Examples |
+ | |||
+ | ====api/ | ||
+ | |||
+ | **Request** | ||
+ | |||
+ | * URL: / | ||
+ | * Method: POST | ||
+ | |||
+ | **Request** | ||
+ | |||
+ | <code javascript> | ||
+ | {" | ||
+ | </ | ||
+ | |||
+ | **Response** | ||
+ | |||
+ | <code xml> | ||
+ | <?xml version=" | ||
+ | < | ||
+ | </ | ||
+ | |||
+ | * You **should** use the received token **t** in subsequent API calls. | ||
====api/ | ====api/ | ||
Line 45: | Line 67: | ||
" | " | ||
" | " | ||
- | " | + | " |
- | " | + | |
}, | }, | ||
" | " | ||
Line 119: | Line 140: | ||
+ | ====api/ | ||
+ | |||
+ | **Request** | ||
+ | |||
+ | * URL: / | ||
+ | * Method: POST | ||
+ | * Content-Type: | ||
+ | |||
+ | Attribute **i** sets **interval** ([[https:// | ||
+ | |||
+ | 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=" | ||
+ | < | ||
+ | xmlns: | ||
+ | xmlns: | ||
+ | projId=" | ||
+ | dpId=" | ||
+ | <n2:cred t=" | ||
+ | < | ||
+ | <hv ts=" | ||
+ | < | ||
+ | </hv> | ||
+ | <hv ts=" | ||
+ | < | ||
+ | </hv> | ||
+ | <hv ts=" | ||
+ | < | ||
+ | </hv> | ||
+ | <hv ts=" | ||
+ | < | ||
+ | </hv> | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | **Response** | ||
+ | |||
+ | * 200 OK | ||
+ | |||
+ | ====api/ | ||
+ | |||
+ | **Request** | ||
+ | |||
+ | * URL: / | ||
+ | * Method: POST | ||
+ | * Content-Type: | ||
+ | |||
+ | <code xml> | ||
+ | <?xml version=" | ||
+ | < | ||
+ | xmlns: | ||
+ | xmlns: | ||
+ | xmlns: | ||
+ | <n1:cred t=" | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | **Response** | ||
+ | |||
+ | <code xml><? | ||
+ | < | ||
+ | |||
+ | ====api/ | ||
+ | |||
+ | The right way how to retrieve current values of data points (property " | ||
+ | |||
+ | **Request** | ||
+ | |||
+ | * URL: / | ||
+ | * Method: POST | ||
+ | |||
+ | <code javascript> | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | } | ||
+ | ] | ||
+ | } | ||
+ | |||
+ | </ | ||
+ | |||
+ | **Response** | ||
+ | |||
+ | <code xml><? | ||
+ | <values xmlns: | ||
+ | < | ||
+ | <v projId=" | ||
+ | < | ||
+ | <d id=" | ||
+ | < | ||
+ | <p n=" | ||
+ | < | ||
+ | </p> | ||
+ | </ | ||
+ | </d> | ||
+ | <d id=" | ||
+ | < | ||
+ | <p n=" | ||
+ | < | ||
+ | </p> | ||
+ | </ | ||
+ | </d> | ||
+ | </ | ||
+ | </v> | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | |||
+ | ===== Matlab Client ===== | ||
+ | ==== General notes client function parameters ==== | ||
+ | * parameter names ID and Guid are used interchangeably in the Matlab client, it is always a universally unique identifier referring to project or a particular datapoint | ||
+ | * when plural is used, array of guids is expected (ie. {' | ||
+ | |||
+ | ==== Data download example ==== | ||
+ | |||
+ | <code matlab> | ||
+ | |||
+ | dataPointIDs = {' | ||
+ | projectId = ' | ||
+ | chartLegend = {'/ | ||
+ | from = now - 4; | ||
+ | to = now; | ||
+ | timeSpan = 300; %sec | ||
+ | |||
+ | [data, time] = scada.getData(projectId, | ||
+ | |||
+ | plot(time, | ||
+ | legend(chartLegend); | ||
+ | datetick;</ | ||
+ | |||
+ | |||
+ | ==== ScadaClient ==== | ||
+ | |||
+ | <code matlab> | ||
+ | |||
+ | Constructor of Mervis API wrapper. | ||
+ | |||
+ | ==== findAllDPsWithReqTags ==== | ||
+ | |||
+ | <code matlab> | ||
+ | |||
+ | Returns list of datapoints based on tags query. Example of tags definition: {' | ||
+ | |||
+ | ==== saveData==== | ||
+ | <code matlab> | ||
+ | Saves data into the Mervis database. | ||
+ | |||
+ | ==== deleteVariable ==== | ||
+ | <code matlab> | ||
+ | Deletes data of one variable based on from - to interval. If from - to is not defined, all data are deleted. Use carefully, there is no undo! | ||
+ | |||
+ | ==== setDataPointValue ==== | ||
+ | <code matlab> | ||
+ | Sets data point value using a button (primary the INIT button). Only numerical values are supported. Parameter buttonName is not mandatory. Value ' | ||
+ | |||
+ | {{ : | ||
+ | |||
+ | **Example: | ||
+ | <code matlab> | ||
+ | dpGuid = ' | ||
+ | projectId = ' | ||
+ | buttonName = ' | ||
+ | newValue = 1; | ||
+ | |||
+ | scada = ScadaClient(' | ||
+ | scada.setDataPointValue(projectId, | ||
+ | |||
+ | </ | ||
+ | ==== getData==== | ||
+ | <code matlab> | ||
+ | Downloads data. Span is a sampling interval in seconds, default is 300 sec. Zone is time zone ' | ||
+ | |||
+ | ==== getDpTags==== | ||
+ | <code matlab> | ||
+ | Returns tags of the particular datapoint. | ||
+ | |||
+ | |||
+ | ==== getAllProjectDPs==== | ||
+ | <code matlab> | ||
+ | Returns project IDs and names that are accessible to logged user. |