Table of Contents

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

URL: http://[ip-address-of-the-plc]/login.cgi

{
  ver : 1,//version
  //optional - only for non-authenticated access
  //credentials
  c: {u: "karel", p: "x"}	
}

Response

{
  ver : 1,//version
  code: "ok", //return code
  msg: "", //error message
  c : {u: "karel", p:"x"} //must be used for further communication
}

Data request

Request

URL: http://[ip-address-of-the-plc]/values.cgi

{
  ver : 1,//version
  //optional - only for non-authenticated access
  //credentials
  c: {u: "karel", p: "x"},
  //variable IDs
  v: [ "svc://defaultConnection/myVarId1",
     "svc://otherConnection/xxxYYYYDDD"]
}

Example

{
 "ver": 1,
 "c": {
  "u": "Visitor",
  "p": "b39576d3da8eb2b0e262645e84707cdc"
 },
 "v": ["svc://DefaultConnection/9104[0,4]", 
       "svc://DefaultConnection/9105[0,4]", 
       "svc://DefaultConnection/9129[456,4]"]
}

Variable specification for Mervis RT

the POST body can be:

  1. JSON string (AngularJS default behaviour):
    {"ver":1,"c":{"u":"karel","p":"x"},"v":["svc://defaultConnection/myVarId1","svc://otherConnection/xxxYYYYDDD"]}
  2. 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

Response

{
 ver : 1,//version
 code: "ok", //return code
 msg: "", //error message
v: [{
     i: "svc://defaultConnection/myVarId1", //variable Id
     v: "ACA1", //value - binary encoded
     q: "G",//quality
     t: 654654321654 //timestamp UTC, milliseconds since 1970
     }
   ]
}

Encoding of values - version 1

Example

{
 "ver": 1.0,
 "code": "ok",
 "msg": "",
 "v": [{
   "i": "svc://DefaultConnection/9104[0,4]",
   "v": "C376DC63",
   "q"
   : "good",
   "t": 636940178310000000
  }, {
   "i": "svc://DefaultConnection/9105[0,4]",
   "v": "C0400000",
   "q": "good",
   "t": 636940178310000000
  }, {
   "i": "svc://DefaultConnection/9129[456,4]",
   "v": "C0400000",
   "q": "good",
   "t": 636940178310000000
  }
 ]
}

Command Request

Request

URL: http://[ip-address-of-the-plc]/command.cgi

{
	ver : 1,//version
     //optional - only for non-authenticated access
	//credentials
	c: {u: "karel", p: "x"},
v: [{
     i: "svc://defaultConnection/myVarId1", //variable Id
     //digital setter
     time: "20.0", //digital setter has some time property...
     state: "2", //state that should be applied
     defaultValue: "6", //some default value
     //analogPlusMinusInit, TPG, ...
     set: 5,
     //set: "<?cdata....?>" //TPG
     //login - pin
     login: "1234"
     }
   ]
}

Historical Data Request

Request

URL: http://[ip-address-of-the-plc]/history.cgi

{
	ver : 1,//version
     //optional - only for non-authenticated access
	//credentials
	c: {u: "karel", p: "x"},
v: [ {i:"svc://defaultConnection/myVarId1", 
      from: XXXX, 
      to: YYYY
      },
     {i:"svc://defaultConnection/myVarId1", 
      from: XXXX, 
      to: YYYY
     }
   ]
}

Response

{
 "ver": 1,
 "code": "ok",
 "msg": "",
 "v": [{
  "i": "svc://DefaultConnection/15[0,1]",
  "v": [{
   "t": 636579093300049300,
   "v": "00"
  },
  {
   "t": 636579093600055900,
   "v": "00"
  }],
  "n": 10
 },
 {
  "i": "svc://DefaultConnection/16[0,1]", //variable ID
  "v": [
 {
  "t": 636579093300049300,                //timestamp (UTC)
  "v": "00"                               //value
 },
 {
  "t": 636579093600055900,
  "v": "00"
 },"n": 10                                //offset for the following request. -1 = reading finished
}]
}

Native/built-in data types

Note: big endian encoding (v1)