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

ASSIGN VARIABLE BY UI-ACTION

ASSIGN VARIABLE BY UI-ACTION

Hulk
Member

Hi all,

I need to assign variable each other by using UI-Action as below.

For example: I have 2 objects to control: Motor 01 & Motor 02. Each motor has its variable :

+ Motor 01: M01_Start, M01_Stop, M01_Run; 

+ Motor 02: M02_Start, M02_Stop, M02_Run; 

And common variables which are assigned to Pop up window when click to each object. Those variable will be assigned to specific motor to control. 

You can refer to pictures below for understanding.

Hulk_0-1679846685961.png

In this case if I click to Motor 01 then I need M01_Start = CMD_Start; M01_Stop = CMD_Stop the same for Motor 02.

My question is to how can I assign those variables and then I can only use CMD_Start & CMD_Stop to control all of my objects?

I was thinking about WriteDirect() function but it seems only support for one Item & one value.

Could you please help to give some ideas for this? UI-Action code is highly appreciated.

Thank you and hope to get your feedback soon.

Regards!

6 REPLIES 6

webiq-sk
Frequent Contributor

Do you only want to set these values when clicking on the button?
If that's the case just add multiple "write-item" UI Actions to your buttons.

Hello,

No. Just simplely think how to assign M01_Start = CMD_Start by using UI-Action code. Popup window just a reference that I need that code to do this application.

Thank you for prompt feedback!

webiq-sk
Frequent Contributor

Of course writeDirect supports setting multiple values at once as you can read in the documentation:
https://www.smart-hmi.com/user/download/deliver/docs/documentation-webiq-visuals-reference-2.13-e58c...

I don't quite understand what you want to do because I see two stateless button widgets and three similar stateless buttons.

Are you trying to implement some kind of HTML radio element functionality where you have a kind of state "motor 1 selected" or "motor 2 selected" and then when you click on one of the buttons the currently selected motor will be started or stopped?

Can you please explain this in such a way that someone who does not know your HMI and project what you exactly want to achieve can understand this? Unfortunately I don't 😉

Something like: "When I click on button A I want this to happen: write value X from ... to Y...."

AndreasL
Long-established Member

As i understand it you want to run M1 when that is selected and M2 when that is selected.

In that case, create a virtual tag: "SelectedMotor", set it to 1 when pressing M1, and 2 when pressing M2.

Then duplicate the buttons, one set for M1 and one set for M2, and then hide/show them (or the container they are in) depending on the value of "SelectedMotor" (using a css selector)

Hello,

FYI.

As I need to create popup window to control the pump as below.

Hulk_0-1679904302233.png

Then I need to assign common variable (variables created once on the popup) and assign directly to specific pump vairable when clicking to the pump.

@webiq-sk  has recommand me to use placeholder inside each of composites to control it. assigning common vairable from popup window to specific pump variable should not be done as it is only assign a "value" to the "variable".

Thank you for supporting.

 

webiq-sk
Frequent Contributor

What's actually wanted here is to change item names used inside widgets when the user clicks on a pump.

So the popup opened when the user clicks on the pump widget should use all of the items specific to that pump.

For this the popup has to be put inside a composite widget and placeholders have to be used. Then when the user clicks on the pump the UI Action "composite-placeholders" is used to modify the item names used in the widgets in the popup for the specific pump, then the popup will be opened by the UI Action "popup-menu".

I have attached a working demo that illustrates this. This works best if all of your items only differ in a single part of the item, like "pump[4].speed" - then a single placeholder for replacing the offset would be sufficient as shown in the demo.

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