What you want is possible, but is not very simple.
Problem is, that PmgButton has not defined any value like button state (other object pmgButtonTwo has that value).
Because abowe, yuo can do it useing scripting.
When you use scripting, than you can't directly read/write properties of pmaObjects in script in any pmgObjects. You can do this using methods defined in the pmaPanel object, in which relevant button exists.
PmgButton has two events: onButtonDown, onButtonUp. You can use this events to call method of the pmaPanel defined by you, which is called on server and can access to any pmaObject.
Method in pmaPanel can be defined like that:
name: SetVal, parameters: bVal (true/false)
script in the method:
- Code: Select all
pMe.Pm("../Data#vars/value").Value = bVal;
Calling this method from the buttons events like this:
- Code: Select all
pMe.PmPanel.Methods.SetVal(1); //in the onButtonDown event, in onButtonUp set value 0
When variable "value" has been defined with "Comm" data extension with possibility to writing value to the PLC, then write to this variable can send this value to the PLC.
Note:
In this case operator have to "wait" when value from pmgButton writes into the variable and after that can release this button, in other case value of the variable can be wrote for very short time.
Better solution is using method AddEventTimer of the pmaRoot object, which can automatically reset value after defined time (i.e. 0.5 second).
Than script in button will be only in one event, better is place it in the onButtonUp event:
- Code: Select all
pMe.PmPanel.Methods.SetVal(1);
Script in this method should be like that:
- Code: Select all
pMe.Pm("../Data#vars/value").Value = 1;
pMe.Root.AddEventTimer(500, 1, pMe.GetPathName(), onTick);
function onTick()
{
pMe.Pm("../Data#vars/value").Value = 0;
}
This solution is better, because operator must not wait for writing value into the PLC, and application automatically resets value after required amount of time.
This will be work in WEB panels too, because request from button to the application will be send only once and setting and resetting value is whole executed in server part of the application.
Hope this helps
Best regards