Web request to PLC values – POST

Domat Control System Forums mark… process stations Web request to PLC values – POST

This topic contains 0 replies, has 1 voice, and was last updated by  Jan Vidim 12.7. 2018 13:50.

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #19528

    Jan Vidim
    Keymaster

    The request URL is
    http://192.168.1.55:80/api.cgi
    (set your PLCs IP address instead of 192.168.1.55)

    and the POST request is
    {"ver":1,"c":{"u":"aaa","p":"bbb"},"v":["svc://DefaultConnection/4[0,1]","svc://DefaultConnection/3[0,1]","svc://DefaultConnection/2[0,2]"]}

    - this is an example for web user “aaa” and password “bbb” from a project where the .vlist file contains three variables:

    #ver:1.0
    Project;Name;Type;CommUid;Offset;Length;ParentTypeFamily;HistoryId
    web_test;$main$.$tmparg_0$;$int$;1;0;2;none;
    web_test;$var3$;$int$;2;0;2;none;
    web_test;$var2$;$bool$;3;0;1;none;
    web_test;$var1$;$usint$;4;0;1;none;

    As you can see, every variable must be called as a complete thing with the length and offset as well in square brackets (like [0,1], [0,2] above), as listed in the .vlist file.

    The PLC response from the test is:

    
    {"ver":1,"code":"ok","msg":"","v":[{"i": "svc://DefaultConnection/4[0,1]", "v": "15", "q": "good", "t": 636669898310000000},{"i": "svc://DefaultConnection/3[0,1]", "v": "01", "q": "good", "t": 636669898310000000},{"i": "svc://DefaultConnection/2[0,2]", "v": "0015", "q": "good", "t": 636669898310000000}]}

    Note that all values are in hex. Real values must be converted from the floating point representation. The integer values above are 21 dec, which is 15 hex, as you can see in
    "v": "15"

    The bool variable with ID of 3 is True, which is “01″.
    "svc://DefaultConnection/3[0,1]", "v": "01"

    • This topic was modified 4 months ago by  Jan Vidim.
Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.