How to write a value from PG2 to the Controller
(I have already posted the below question in the solution bank forum without sucess)
I have a question regarding writing values from PG2 (800xA 5.1) to the Controller. I want to implement a functionality where when the user updates a ”Value” field (integer), PG2 also updates another variable (string) in the Controller with some string value. I have tried using the ”Hosted Input Item” ”Value Writer” using the ”Add Item Hosted Input Item” functionality. But it seems that the ”Value Writer” only works with buttons and is triggered by mouse up and mouse down actions. Changes in value fields do not trigger the "Value Writer". Does any body have experiance with this?
In other words: How do you write a value from PG2 to a variable in the Controller. The value in PG2 could be a continously calculated value in PG2 and it is not an input field accessed by the operator. In other words it is an internally calculated PG2 value.
The answer is "you dont" - at least not really in the way that you are trying to do.
The PG2 graphics are not a calculating tool. Thats why you cannot easily, and should not try to, do calculations in an operator graphic. There are many things that can go wrong and functionality like this could be very easily mis-used. Especially when you try to do a "continuously calculated value"- what happens when the graphic isnt open ? What happens if the graphic is opened twice etc.
However, there are several aspects that can do what you need
- Property Translation, can do simple calculations like re-ranging signals, convering values etc
- Property Translation Extended , is a Property Translation that can also generate string messages
- Property Transfer that can copy the results of a Property Translation back to the controller again.
- Calculation Aspects - for more complicated calculations.
In your PG2 graphic, just write the integer data to your controller as required. Then use a Property Translation aspect to convert your source value into your required value and a Property Transfer to write the result back into the controller again.
The results are only evaluated when your source data is changed or on a longer update cycle which you can set. By doing this you wont have problems related to whether a graphic is open or not. And you wont be hiding program code inside a graphic where another programmer will NEVER be able to find it.