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-ide:65-webpanel:webpanel-api [2017/06/21 11:00] m.chlupac |
en:mervis-ide:65-webpanel:webpanel-api [2019/05/21 09:57] m.chlupac |
||
---|---|---|---|
Line 2: | Line 2: | ||
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 ===== | ===== Login ===== | ||
==== Request ==== | ==== Request ==== | ||
- | Data: | + | **URL:** '' |
- | '' | + | |
- | ver : 1,// | + | <code js>{ |
- | //optional - only for non-authenticated access | + | ver : 1,// |
- | // | + | //optional - only for non-authenticated access |
- | c: {u: “karel”, p: “x”} | + | // |
- | + | c: {u: "karel", p: "x"} | |
- | }'' | + | }</ |
==== Response ==== | ==== Response ==== | ||
- | { | + | <code js>{ |
- | ver : 1,// | + | ver : 1,// |
- | code: | + | code: "ok", //return code |
- | msg: “”, //error message | + | msg: "" |
- | c : {u: “karel”, p:”x”} //must be used for further communication | + | c : {u: "karel", p:"x"} //must be used for further communication |
- | } | + | }</ |
===== Data request ===== | ===== Data request ===== | ||
Line 27: | Line 29: | ||
==== Request ==== | ==== Request ==== | ||
- | Data: | + | **URL:** '' |
- | '' | + | |
- | ver : 1,// | + | <code js>{ |
- | //optional - only for non-authenticated access | + | ver : 1,// |
- | // | + | //optional - only for non-authenticated access |
- | c: {u: “karel”, p: “x”}, | + | // |
- | //variable IDs | + | c: {u: "karel", p: "x"}, |
- | v: [ “svc:// | + | //variable IDs |
- | “svc:// | + | v: [ "svc:// |
- | }'' | + | "svc:// |
+ | }</ | ||
* 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: | ||
- | - JSON string (AngularJS default behaviour): | + | - JSON string (AngularJS default behaviour): |
- | '' | + | - converted into POST parameters (jQuery default behaviour):< |
- | - converted into POST parameters (jQuery default behaviour): | + | |
- | '' | + | |
- | The best solution would be to support both versions. Easier is now the JSON string. | ||
==== Response ==== | ==== Response ==== | ||
- | '' | + | <code js>{ |
- | ver : 1,// | + | ver : 1,// |
- | code: | + | |
- | msg: “”, //error message | + | |
v: [{ | v: [{ | ||
- | | + | |
- | | + | |
- | | + | |
- | t: 654654321654 //timestamp UTC, milliseconds since 1970 | + | |
} | } | ||
] | ] | ||
- | }'' | + | }</ |
=== Encoding of values - version 1 === | === Encoding of values - version 1 === | ||
- | Ea | + | |
===== Command Request ===== | ===== Command Request ===== | ||
Line 80: | Line 80: | ||
==== Request ==== | ==== Request ==== | ||
+ | **URL:** '' | ||
- | '' | + | <code js>{ |
ver : 1,//version | ver : 1,//version | ||
// | // | ||
// | // | ||
- | c: {u: “karel”, p: “x”}, | + | c: {u: "karel", p: "x"}, |
v: [{ | v: [{ | ||
- | | + | |
// | // | ||
- | | + | |
- | | + | |
- | | + | |
// | // | ||
set: 5, | set: 5, | ||
- | // | + | // |
// | // | ||
- | | + | |
} | } | ||
] | ] | ||
- | }'' | + | }</ |
* Warning : only one variable is expected in the request for the tiniest (uPLC) platforms - other variables are ignored | * Warning : only one variable is expected in the request for the tiniest (uPLC) platforms - other variables are ignored | ||
Line 107: | Line 108: | ||
==== Request ==== | ==== Request ==== | ||
- | '' | + | **URL: |
+ | |||
+ | <code js>{ | ||
ver : 1,//version | ver : 1,//version | ||
// | // | ||
// | // | ||
- | c: {u: “karel”, p: “x”}, | + | c: {u: "karel", p: "x"}, |
- | v: [ {i:“svc:// | + | v: [ {i:"svc:// |
from: XXXX, | from: XXXX, | ||
to: YYYY | to: YYYY | ||
}, | }, | ||
- | {i:“svc:// | + | {i:"svc:// |
from: XXXX, | from: XXXX, | ||
to: YYYY | to: YYYY | ||
} | } | ||
] | ] | ||
- | }'' | + | }</code> |
- | + | ||
- | + | ||
- | + | ||
- | ===== Configuration Response ===== | + | |
- | + | ||
- | '' | + | |
- | ver : 1,//version | + | |
- | platform: “uPLC”, | + | |
- | maxVariablesInRequest: | + | |
- | maxRequestSize: | + | |
- | preferedLanguage: | + | |
- | }'' | + | |
+ | ==== Response ==== | ||
+ | <code javascript> | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }], | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | }, | ||
+ | { | ||
+ | " | ||
+ | " | ||
+ | | ||
+ | }] | ||
+ | } | ||
+ | </ | ||
- | ====== Native/ | + | ===== Native/ |
Note: big endian encoding (v1) | Note: big endian encoding (v1) |