Dear Community User! We are updating our platform to a new system.
Read more: Important information on the platform change.

cancel
Showing results for 
Search instead for 
Did you mean: 
SOLVED

CXA_Datalayer: How to create a remote device via PLC?

CXA_Datalayer: How to create a remote device via PLC?

LunatiX
New Contributor

I would like to create a new remote device like the following:

LunatiX_0-1666706565015.png

(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?

3 REPLIES 3

CodeShepherd
Community Moderator
Community Moderator

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.

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

LunatiX_2-1666870660610.png

 

-> DL_NodeValue has a lot of methods

...

LunatiX_0-1666870434742.png

 

LunatiX_1-1666870446096.png

CodeShepherd
Community Moderator
Community Moderator

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);

 

Icon--AD-black-48x48Icon--address-consumer-data-black-48x48Icon--appointment-black-48x48Icon--back-left-black-48x48Icon--calendar-black-48x48Icon--center-alignedIcon--Checkbox-checkIcon--clock-black-48x48Icon--close-black-48x48Icon--compare-black-48x48Icon--confirmation-black-48x48Icon--dealer-details-black-48x48Icon--delete-black-48x48Icon--delivery-black-48x48Icon--down-black-48x48Icon--download-black-48x48Ic-OverlayAlertIcon--externallink-black-48x48Icon-Filledforward-right_adjustedIcon--grid-view-black-48x48IC_gd_Check-Circle170821_Icons_Community170823_Bosch_Icons170823_Bosch_Icons170821_Icons_CommunityIC-logout170821_Icons_Community170825_Bosch_Icons170821_Icons_CommunityIC-shopping-cart2170821_Icons_CommunityIC-upIC_UserIcon--imageIcon--info-i-black-48x48Icon--left-alignedIcon--Less-minimize-black-48x48Icon-FilledIcon--List-Check-grennIcon--List-Check-blackIcon--List-Cross-blackIcon--list-view-mobile-black-48x48Icon--list-view-black-48x48Icon--More-Maximize-black-48x48Icon--my-product-black-48x48Icon--newsletter-black-48x48Icon--payment-black-48x48Icon--print-black-48x48Icon--promotion-black-48x48Icon--registration-black-48x48Icon--Reset-black-48x48Icon--right-alignedshare-circle1Icon--share-black-48x48Icon--shopping-bag-black-48x48Icon-shopping-cartIcon--start-play-black-48x48Icon--store-locator-black-48x48Ic-OverlayAlertIcon--summary-black-48x48tumblrIcon-FilledvineIc-OverlayAlertwhishlist