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
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:45]
m.chlupac [Request]
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: +<code js>
-''+  ver : 1,//version 
- ver : 1,//version +  //optional - only for non-authenticated access 
- //optional - only for non-authenticated access +  //credentials 
- //credentials +  c: {u: “karel”, p: “x”}  
- c: {u: “karel”, p: “x”} +}</code> 
-  +
-}''+
 ==== Response ==== ==== Response ====
  
-+<code js>
- ver : 1,//version +  ver : 1,//version 
- code: “ok”, //return code +  code: “ok”, //return code 
- msg: “”, //error message +  msg: “”, //error message 
-c : {u: “karel”, p:”x”} //must be used for further communication +  c : {u: “karel”, p:”x”} //must be used for further communication 
-}+}</code>
  
 ===== Data request ===== ===== Data request =====
Line 27: Line 27:
 ==== Request ==== ==== Request ====
  
-Data: +**URL:** ''http://[ip-address-of-the-plc]/values.cgi'' 
-''+ 
- ver : 1,//version +<code js>
- //optional - only for non-authenticated access +  ver : 1,//version 
- //credentials +  //optional - only for non-authenticated access 
- c: {u: “karel”, p: “x”}, +  //credentials 
- //variable IDs +  c: {u: “karel”, p: “x”}, 
-v: [ “svc://defaultConnection/myVarId1”,+  //variable IDs 
 +  v: [ “svc://defaultConnection/myVarId1”,
      “svc://otherConnection/xxxYYYYDDD”]      “svc://otherConnection/xxxYYYYDDD”]
-}''+}</code>
  
   * variable ID is unique string - in future, may be different for different platforms/protocol versions (uPLC - int?, SharkRT - string)   * variable ID is unique string - in future, may be different for different platforms/protocol versions (uPLC - int?, SharkRT - string)
  
-=== 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, lenght]. CommUID can be retrieved from a .vlist file of the IDE 2 project and specifies a variable. Variables can be of a complex and large types. In this case a user can retrieve only a small part of the variable by using the offset and length.   * Variable id: it has a form of commUID[offset, lenght]. CommUID can be retrieved from a .vlist file of the IDE 2 project and specifies a variable. Variables can be of a complex and large types. In this case a user can retrieve only a small part of the variable by using the offset and length.
-  * Example: svc://defaultConnection/877* 0,2]+  * Example: <code>svc://defaultConnection/877* 0,2]</code>
     * 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): <code js>{"ver":1,"c":{"u":"karel","p":"x"},"v":["svc://defaultConnection/myVarId1","svc://otherConnection/xxxYYYYDDD"]}</code> 
-''{"ver":1,"c":{"u":"karel","p":"x"},"v":["svc://defaultConnection/myVarId1","svc://otherConnection/xxxYYYYDDD"]}'' +  - converted into POST parameters (jQuery default behaviour):<code>ver=1&c%5Bu%5D=karel&c%5Bp%5D=x&v%5B%5D=svc%3A%2F%2FdefaultConnection%2FmyVarId1&v%5B%5D=svc%3A%2F%2FotherConnection%2FxxxYYYYDDD</code>
-  - converted into POST parameters (jQuery default behaviour): +
-''ver=1&c%5Bu%5D=karel&c%5Bp%5D=x&v%5B%5D=svc%3A%2F%2FdefaultConnection%2FmyVarId1&v%5B%5D=svc%3A%2F%2FotherConnection%2FxxxYYYYDDD''+
  
-The best solution would be to support both versions. Easier is now the JSON string. 
  
 ==== Response ==== ==== Response ====
  
-''+<code js>
- ver : 1,//version + ver : 1,//version 
- code: ok, //return code + code: "ok", //return code 
- msg: “”, //error message+ msg: "", //error message
 v: [{ v: [{
-     i: svc://defaultConnection/myVarId1, //variable Id +     i: "svc://defaultConnection/myVarId1", //variable Id 
-     v: ACA1, //value - binary encoded +     v: "ACA1", //value - binary encoded 
-     q: G,//quality +     q: "G",//quality 
-      t: 654654321654 //timestamp UTC, milliseconds since 1970+     t: 654654321654 //timestamp UTC, milliseconds since 1970
      }      }
    ]    ]
-}''+}</code>
  
 === Encoding of values - version 1 === === 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).+  Each value is transmitted as a big endian binary representation of the specified variable (and its offset and length).
  
 ===== Command Request ===== ===== Command Request =====
Line 81: Line 79:
  
  
-''{+<code js>{
  ver : 1,//version  ver : 1,//version
      //optional - only for non-authenticated access      //optional - only for non-authenticated access
Line 99: Line 97:
      }      }
    ]    ]
-}''+}</code>
  
   * 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 105:
 ==== Request ==== ==== Request ====
  
-''{+<code js>{
  ver : 1,//version  ver : 1,//version
      //optional - only for non-authenticated access      //optional - only for non-authenticated access
Line 121: Line 119:
      }      }
    ]    ]
-}''+}</code>
  
  
Line 127: Line 125:
 ===== Configuration Response ===== ===== Configuration Response =====
  
-''+<code js>
- ver : 1,//version +  ver : 1,//version 
-platform: “uPLC”, +  platform: “uPLC”, 
-maxVariablesInRequest: 5, +  maxVariablesInRequest: 5, 
-maxRequestSize: 1500, //http body size in bytes +  maxRequestSize: 1500, //http body size in bytes 
-preferedLanguage: “en-US” +  preferedLanguage: “en-US” 
-}''+}</code>
  
  
  
  
-====== Native/built-in data types ======+===== Native/built-in data types =====
  
 Note: big endian encoding (v1) Note: big endian encoding (v1)
  • © Energocentrum Plus, s.r.o. 2017 - 2024