Dear Community User! We have started the migration process.
This community is now in READ ONLY mode.
Read more: Important information on the platform change.

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

Can I change an address of a OPC UA variable via script?

Can I change an address of a OPC UA variable via script?

JagJag1
New Poster

Hi, I am wondering if someone knows if there its possibility to change the PLC identifier of a variable via script. I.e. I would like the variable bellow to a different address in the PLC

PLC identifier:
|var|CODESYS Control Win V3 x64.Application.GVL.astItem[0].iStatus

 

New identifier

|var|CODESYS Control Win V3 x64.Application.GVL.Robot[1].iStatus

2 REPLIES 2

HmiGuide
Community Moderator
Community Moderator

Instead of changing the Opc UA address on client side, you can solve this in the PLC with a variable of type:
iStatusRef: REFERENCE TO INT:=iStatus1;

Variable definition of referenced variables.

{attribute 'global_init_slot' := '1000'} // defines initialization order. A lower value means an earlier initialization
VAR_GLOBAL
	{attribute 'symbol' := 'none'}
    iStatus1: INT:=100;
	{attribute 'symbol' := 'none'}
    iStatus2: INT:=200;
END_VAR

Variable definition of OpcUa variable

{attribute 'symbol' := 'readwrite'}
{attribute 'global_init_slot' := '2000'} // defines initialization order. A lower value means an earlier initialization
// https://docs.automation.boschrexroth.com/doc/3513354743/attribute-global-init-slot/6-06/en/
VAR_GLOBAL
	// reference must be initialized
	iStatusRef: REFERENCE TO INT:=iStatus1;
END_VAR

 PLC example program which changes the reference

IF (iSelect=1) THEN
	iStatusRef REF= iStatus1;
ELSE
	iStatusRef REF= iStatus2;
END_IF

Docu of attribute-global-init-slot 

webiq-sk
Frequent Contributor

WebIQ does not currently support this. The solution from @HmiGuide looks like a great way.

"You cannot change the HMI from the HMI" - with some exceptions like users, recipes, recorder data etc.,, but not the HMI configuration itself.

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