FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
10-25-2022 04:06 PM - last edited on 11-02-2022 02:46 PM by CodeShepherd
I would like to create a new remote device like the following:
(see docu: https://docs.automation.boschrexroth.com/doc/3584808565/configuration/latest/en/)
So I've to send/create a JSON/String to the node devices/remotes. Can I do that with the FB DL_CreateNode?
Solved! Go to Solution.
10-27-2022 11:26 AM - edited 11-02-2022 02:46 PM
As you are sending an object you have to use DL_CreateNodeValue and create a fitting flatbuffer that can be sent. The flatbuffer description can be found in the metadata of node "devices/remote" --> "createType: types/datalayer/remoteconfig" --> "comm_datalayer_remote_ConfigItem". This flatbuffer is part of the CXA_AUTOMATIONCORE_FBS.
10-27-2022 01:40 PM - last edited on 11-02-2022 02:47 PM by CodeShepherd
Sorry, but without a documentation or an example it's not possible for me to find a solution. There are so many fb's and methods available what makes it very complicated. See below:
start with fb DL_CreateNodeValue -> needs DL_NodeValue
-> DL_NodeValue has a lot of methods
...
11-02-2022 04:20 PM - edited 11-02-2022 04:21 PM
See this post for another example and for your case see my working example below:
Declaration:
PROGRAM PROG_comm_datalayer_remote_ConfigItem
VAR
fbConfigItem: CXA_AutomationCore_fbs.comm_datalayer_remote_ConfigItem; //Flatbuffer function out of CXA_Automationcore_fbs
fbBuilder: flatbuffers.FlatBufferBuilder; // Declare the flatbuffer builder out of CXA_Flatbuffers
fbDL_CreateNodeValue: DL_CreateNodeValue; //Funktion block to write an flatbuffer out of CXA_Datalayer
bExecute: BOOL;
bDone: BOOL;
bActive: BOOL;
bError: BOOL;
ErrorID: CXA_Datalayer.ERROR_CODE;
ErrorIdent: CXA_Datalayer.ERROR_STRUCT;
fbValueIn: CXA_Datalayer.DL_NodeValue;
fbValueOut: CXA_Datalayer.DL_NodeValue;
bStart_write: BOOL;
udiName: UDINT;
udiAddress: UDINT;
strName: STRING := 'otherControl';
strAddress: STRING := 'tcp://192.168.1.1:2069';
END_VAR
Implementation:
//////////////////Write values /////////////////////////
IF bStart_write THEN
fbBuilder(forceDefaults := TRUE); //Start flatbuffer builder and load with default values
udiName := fbBuilder.createString(strName); //Create flatbuffer offset
udiAddress := fbBuilder.createString(strAddress); //Create flatbuffer offset
fbConfigItem.startConfigItem(fbBuilder); //Start flatbuffer function using the builder
fbConfigItem.addName(udiName); //Add offset to the flatbuffer
fbConfigItem.addAddress(udiAddress); //Add offset to the flatbuffer
fbBuilder.finish(fbConfigItem.endConfigItem()); // Finish complete builder and closing the fbConfigItem
fbValueIn.SetFlatbuffer(fbBuilder); //Set flatbuffer out of the builder in the variable to be written
bExecute := TRUE;
bStart_write := FALSE;
END_IF
fbDL_CreateNodeValue(
Execute:= bExecute,
Done=> bDone,
Active=> bActive,
Error=> bError,
ErrorID=> ErrorID,
ErrorIdent=> ErrorIdent,
ClientId:= ,
NodeName:= 'devices/remotes', //Path of the node that should be written
NodeValueIn:= fbValueIn,
NodeValueOut:= fbValueOut);