Differences
This shows you the differences between two versions of the page.
en:mervis-ide:65-webpanel:webpanel-api [2017/06/21 11:05] m.chlupac |
en:mervis-ide:65-webpanel:webpanel-api [2019/05/21 11:13] |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Webpanel API ====== | ||
- | |||
- | 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 ==== | ||
- | |||
- | Data | ||
- | <code js>{ | ||
- | ver : 1,//version | ||
- | //optional - only for non-authenticated access | ||
- | // | ||
- | c: {u: “karel”, | ||
- | |||
- | }</ | ||
- | |||
- | ==== Response ==== | ||
- | |||
- | <code js>{ | ||
- | ver : 1,//version | ||
- | code: “ok”, //return code | ||
- | msg: “”, //error message | ||
- | c : {u: “karel”, | ||
- | }</ | ||
- | |||
- | ===== Data request ===== | ||
- | |||
- | ==== Request ==== | ||
- | |||
- | Data | ||
- | <code js>{ | ||
- | ver : 1,//version | ||
- | //optional - only for non-authenticated access | ||
- | // | ||
- | c: {u: “karel”, | ||
- | //variable IDs | ||
- | v: [ “svc:// | ||
- | | ||
- | }</ | ||
- | |||
- | * variable ID is unique string - in future, may be different for different platforms/ | ||
- | |||
- | === Variable specification for RT2 === | ||
- | |||
- | * 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. | ||
- | * Variable id: it has a form of commUID[offset, | ||
- | * Example: '' | ||
- | * Represents a variable with the commUID 8776. 2 bytes from the offset 0 are returned. | ||
- | |||
- | the POST body can be: | ||
- | |||
- | - JSON string (AngularJS default behaviour): | ||
- | <code js> | ||
- | - converted into POST parameters (jQuery default behaviour): | ||
- | < | ||
- | |||
- | The best solution would be to support both versions. Easier is now the JSON string. | ||
- | |||
- | ==== Response ==== | ||
- | |||
- | <code js>{ | ||
- | ver : 1,//version | ||
- | code: “ok”, //return code | ||
- | msg: “”, //error message | ||
- | v: [{ | ||
- | i: “svc:// | ||
- | v: ”ACA1”, //value - binary encoded | ||
- | q: “G”,// | ||
- | t: 654654321654 //timestamp UTC, milliseconds since 1970 | ||
- | } | ||
- | ] | ||
- | }</ | ||
- | |||
- | === Encoding of values - version 1 === | ||
- | |||
- | Ea * Unordered List Itemch value is transmitted as a big endian binary representation of the specified variable (and its offset and length). | ||
- | |||
- | ===== Command Request ===== | ||
- | |||
- | ==== Request ==== | ||
- | |||
- | |||
- | <code js>{ | ||
- | ver : 1,//version | ||
- | // | ||
- | // | ||
- | c: {u: “karel”, | ||
- | v: [{ | ||
- | i: “svc:// | ||
- | // | ||
- | time: ”20.0”, //digital setter has some time property... | ||
- | | ||
- | | ||
- | // | ||
- | set: 5, | ||
- | // | ||
- | // | ||
- | | ||
- | } | ||
- | ] | ||
- | }</ | ||
- | |||
- | * Warning : only one variable is expected in the request for the tiniest (uPLC) platforms - other variables are ignored | ||
- | |||
- | ===== Historical Data Request ===== | ||
- | |||
- | ==== Request ==== | ||
- | |||
- | <code js>{ | ||
- | ver : 1,//version | ||
- | // | ||
- | // | ||
- | c: {u: “karel”, | ||
- | v: [ {i: | ||
- | from: XXXX, | ||
- | to: YYYY | ||
- | }, | ||
- | | ||
- | from: XXXX, | ||
- | to: YYYY | ||
- | } | ||
- | ] | ||
- | }</ | ||
- | |||
- | |||
- | |||
- | ===== Configuration Response ===== | ||
- | |||
- | <code js>{ | ||
- | ver : 1,//version | ||
- | platform: “uPLC”, | ||
- | maxVariablesInRequest: | ||
- | maxRequestSize: | ||
- | preferedLanguage: | ||
- | }</ | ||
- | |||
- | |||
- | |||
- | |||
- | ====== Native/ | ||
- | |||
- | Note: big endian encoding (v1) | ||
- | * integer (represents int8-int64) | ||
- | * unsigned integer (represents uint8-uint64) | ||
- | * double (double64) | ||
- | * float (float32) | ||
- | * bool (boolean - 0 ~ false, 1 ~ true) | ||
- | * 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) | ||
- | * Enums are encoded into 32-bit int | ||