Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision Next revision Both sides next revision | ||
en:mervis-ide:65-webpanel:webpanel-api [2017/06/21 10:51] m.chlupac created |
en:mervis-ide:65-webpanel:webpanel-api [2019/05/21 09:57] m.chlupac |
||
---|---|---|---|
Line 3: | Line 3: | ||
Communication is based on HTTP protocol. Clients send HTTP POST request and get the response depending on the request. Each request must specify the credentials in case the credentials are specified for the project. | Communication is based on HTTP protocol. Clients send HTTP POST request and get the response depending on the request. Each request must specify the credentials in case the credentials are specified for the project. | ||
- | ===== Login request | + | ===== Login ===== |
- | Data: | + | ==== Request ==== |
- | <font inherit/courier new;; | + | **URL:** '' |
- | <font inherit/ | + | <code js>{ |
+ | | ||
+ | //optional - only for non-authenticated access | ||
+ | // | ||
+ | c: {u: " | ||
+ | }</code> | ||
- | <font inherit/ | + | ==== Response ==== |
- | <font inherit/ | + | <code js>{ |
- | + | ver : 1,// | |
- | <font inherit/ | + | code: "ok", //return code |
- | + | msg: "" | |
- | <font inherit/ | + | c : {u: "karel", p:"x"} //must be used for further communication |
- | + | }</code> | |
- | ===== Login response ===== | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
===== Data request ===== | ===== Data request ===== | ||
- | Data: | + | ==== Request ==== |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | <font inherit/ | + | **URL:** '' |
- | <font inherit/ | + | <code js>{ |
+ | ver : 1,// | ||
+ | //optional - only for non-authenticated access | ||
+ | // | ||
+ | c: {u: " | ||
+ | //variable IDs | ||
+ | v: [ " | ||
+ | " | ||
+ | }</code> | ||
* variable ID is unique string - in future, may be different for different platforms/ | * variable ID is unique string - in future, may be different for different platforms/ | ||
- | ==== Variable specification for RT2 ==== | + | === Variable specification for Mervis RT === |
* svc - protocol | * svc - protocol | ||
* Connection - generally, clients can request data from more sources (more or less corresponds to a connection definition of PLC). For local data (data belonging to the PLC that executes the request) it may be defaultconnection. | * Connection - generally, clients can request data from more sources (more or less corresponds to a connection definition of PLC). For local data (data belonging to the PLC that executes the request) it may be defaultconnection. | ||
* Variable id: it has a form of commUID[offset, | * Variable id: it has a form of commUID[offset, | ||
- | * Example: svc:// | + | * Example: |
- | * Represents a variable with the commUID 8776. 2 bytes from the offset 0 are returned. | + | * Represents a variable with the commUID 8776. 2 bytes from the offset 0 are returned. |
the POST body can be: | the POST body can be: | ||
- | 1) JSON string (AngularJS default behaviour): | + | - JSON string (AngularJS default behaviour): |
+ | - converted into POST parameters (jQuery default behaviour):< | ||
- | <font inherit/ | ||
- | 2) converted into POST parameters (jQuery default behaviour): | + | ==== Response ==== |
- | <font inherit/ | + | <code js>{ |
+ | ver : 1,// | ||
+ | code: " | ||
+ | msg: "", | ||
+ | v: [{ | ||
+ | i: "svc:// | ||
+ | v: " | ||
+ | q: " | ||
+ | t: 654654321654 //timestamp UTC, milliseconds since 1970 | ||
+ | } | ||
+ | ] | ||
+ | }</code> | ||
- | The best solution would be to support both versions. Easier is now the JSON string. | + | === Encoding of values - version 1 === |
- | + | ||
- | ===== Data response ===== | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | ==== Encoding of values - version 1 ==== | + | |
* Each value is transmitted as a big endian binary representation of the specified variable (and its offset and length). | * Each value is transmitted as a big endian binary representation of the specified variable (and its offset and length). | ||
Line 109: | Line 78: | ||
===== Command Request ===== | ===== Command Request ===== | ||
- | <font inherit/ | + | ==== Request ==== |
- | <font inherit/ | + | **URL:** '' |
- | <font inherit/ | + | <code js>{ |
+ | ver : 1,// | ||
+ | //optional - only for non-authenticated access | ||
+ | // | ||
+ | c: {u: " | ||
+ | v: [{ | ||
+ | i: " | ||
+ | // | ||
+ | time: " | ||
+ | | ||
+ | | ||
+ | // | ||
+ | set: 5, | ||
+ | // | ||
+ | // | ||
+ | | ||
+ | } | ||
+ | ] | ||
+ | }</code> | ||
- | <font inherit/ | + | * Warning : only one variable is expected in the request |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
- | + | ||
- | <font inherit/ | + | |
===== Historical Data Request ===== | ===== Historical Data Request ===== | ||
- | <font inherit/ | + | ==== Request ==== |
- | <font inherit/ | + | **URL:** '' |
- | <font inherit/ | + | <code js>{ |
+ | ver : 1,// | ||
+ | //optional - only for non-authenticated access | ||
+ | // | ||
+ | c: {u: " | ||
+ | v: [ {i:" | ||
+ | from: XXXX, | ||
+ | to: YYYY | ||
+ | }, | ||
+ | | ||
+ | from: XXXX, | ||
+ | to: YYYY | ||
+ | } | ||
+ | ] | ||
+ | }</code> | ||
- | <font inherit/ | + | ==== Response ==== |
- | <font inherit/ | + | <code javascript>{ |
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }], | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | | ||
+ | }] | ||
+ | } | ||
+ | </code> | ||
- | <font inherit/ | ||
- | |||
- | <font inherit/ | ||
- | |||
- | <font inherit/ | ||
- | |||
- | <font inherit/ | ||
- | |||
- | <font inherit/ | ||
- | |||
- | <font inherit/ | ||
- | |||
- | <font inherit/ | ||
- | |||
- | <font inherit/ | ||
- | |||
- | <font inherit/ | ||
- | |||
- | <font inherit/ | ||
- | |||
- | ===== Configuration Response ===== | ||
- | |||
- | <font inherit/ | ||
- | |||
- | <font inherit/ | ||
- | |||
- | <font inherit/ | ||
- | |||
- | <font inherit/ | ||
- | |||
- | <font inherit/ | ||
- | |||
- | <font inherit/ | ||
- | |||
- | <font inherit/ | ||
===== Native/ | ===== Native/ | ||
Note: big endian encoding (v1) | Note: big endian encoding (v1) | ||
- | |||
* integer (represents int8-int64) | * integer (represents int8-int64) | ||
* unsigned integer (represents uint8-uint64) | * unsigned integer (represents uint8-uint64) | ||
Line 208: | Line 170: | ||
* dt (date time - the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001) | * dt (date time - the number of 100-nanosecond intervals that have elapsed since 12:00:00 midnight, January 1, 0001) | ||
* time (time - the number of 100-nanosecond intervals) | * time (time - the number of 100-nanosecond intervals) | ||
- | * Enums are encoded into 32-bit int | + | * Enums are encoded into 32-bit int |