1
0

CODESYSとNode-RED間のデータ通信 その2

Posted at

はじめに

CODESYSとNode-RED間でのデータ受け渡しについて、
こちらのCODESYS Network Variable List parserを使用する方法について記載します。
※以下の記事の続きです。

CODESYS側の設定(受信側)

Application
オブジェクト変数の追加
ネットワーク変数リスト(受信側)

image.png

ファイルからのインポートしか選択できなかったので、送信側を一旦作って保存したファイルを編集

image.png

以下のように作成したファイルをインポートしました。

UDPポート:1203
リストの識別子:2
パック変数:✓

NVL_Receive.gvl
<GVL>
  <Declarations><![CDATA[{attribute 'qualified_only'}
VAR_GLOBAL
	gInput:BOOL;
    gOutput:BOOL;
    gCounter:UINT;
END_VAR]]></Declarations>
  <NetvarSettings Protocol="UDP">
    <ListIdentifier>2</ListIdentifier>
    <Pack>True</Pack>
    <Checksum>False</Checksum>
    <Acknowledge>False</Acknowledge>
    <CyclicTransmission>True</CyclicTransmission>
    <TransmissionOnChange>False</TransmissionOnChange>
    <TransmissionOnEvent>False</TransmissionOnEvent>
    <Interval>T#50ms</Interval>
    <MinGap>T#20ms</MinGap>
    <EventVariable>
    </EventVariable>
    <ProtocolSettings>
      <ProtocolSetting Name="Broadcast Adr." Value="255.255.255.255" />
      <ProtocolSetting Name="Port" Value="1203" />
    </ProtocolSettings>
  </NetvarSettings>
</GVL>

Node-RED側の設定(送信側)

送信用のノードを配置し、設定します。
設定が終わった後、デプロイを実行して動作するか確認します。

image.png

コピー用ノード
コピー用
[
    {
        "id": "9f44f0bfcba073a2",
        "type": "ui_button",
        "z": "23ae7f30186932ef",
        "name": "",
        "group": "b4cbb1eea7449882",
        "order": 1,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "true",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "{\"gInput2\":false,\"gOutput2\":true,\"gCounter2\":10}",
        "payloadType": "json",
        "topic": "item",
        "topicType": "msg",
        "x": 110,
        "y": 300,
        "wires": [
            [
                "a19469b76760e4b5"
            ]
        ]
    },
    {
        "id": "5380c9759ecfe20f",
        "type": "nvl-send",
        "z": "23ae7f30186932ef",
        "name": "",
        "definition": "VAR_GLOBAL\n    gInput2:BOOL;\n    gOutput2:BOOL;\n    gCounter2:UINT;\nEND_VAR",
        "listId": "2",
        "globaltypes": "",
        "pack": "true",
        "port": "1203",
        "x": 420,
        "y": 320,
        "wires": [
            [
                "8e81019ea0659ac7",
                "0134f8c946bf020d"
            ]
        ]
    },
    {
        "id": "8e81019ea0659ac7",
        "type": "udp out",
        "z": "23ae7f30186932ef",
        "name": "",
        "addr": "127.0.0.1",
        "iface": "",
        "port": "1203",
        "ipv": "udp4",
        "outport": "",
        "base64": false,
        "multicast": "false",
        "x": 650,
        "y": 300,
        "wires": []
    },
    {
        "id": "a19469b76760e4b5",
        "type": "function",
        "z": "23ae7f30186932ef",
        "name": "function 2",
        "func": "\nmsg = {\n    \"payload\" : {\n        \"gInput2\" : false,\n        \"gOutput2\":true,\n        \"gCounter2\":15\n    }\n}\nreturn msg;",
        "outputs": 1,
        "timeout": 0,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 260,
        "y": 300,
        "wires": [
            [
                "5380c9759ecfe20f"
            ]
        ]
    },
    {
        "id": "0134f8c946bf020d",
        "type": "debug",
        "z": "23ae7f30186932ef",
        "name": "debug 5",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 620,
        "y": 360,
        "wires": []
    },
    {
        "id": "77abc1137d256c79",
        "type": "ui_button",
        "z": "23ae7f30186932ef",
        "name": "",
        "group": "b4cbb1eea7449882",
        "order": 1,
        "width": 0,
        "height": 0,
        "passthru": false,
        "label": "false",
        "tooltip": "",
        "color": "",
        "bgcolor": "",
        "className": "",
        "icon": "",
        "payload": "{\"gInput2\":false,\"gOutput2\":false,\"gCounter2\":111}",
        "payloadType": "json",
        "topic": "item",
        "topicType": "msg",
        "x": 110,
        "y": 360,
        "wires": [
            [
                "5380c9759ecfe20f"
            ]
        ]
    },
    {
        "id": "b4cbb1eea7449882",
        "type": "ui_group",
        "name": "Browse",
        "tab": "ec09a280e1494ca8",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "ec09a280e1494ca8",
        "type": "ui_tab",
        "name": "ホーム",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0