Support Forums
Help with scripts, execute a command when something is clicked

Hello,

We're familiar with most SCADA software, but still learning VTSCADA. We are used to the flexibility of script to do things that native symbols and widgets do not do.

Right now, we are trying to configure a button that when clicked, will perform:

TagA = TagB. (where TagA and TagB are Analog Values)

Searching through the help files, we can only find "button" style widgets in VTSCADA that set a tag to a hard number.

Is there a way to make buttons that perform scripts such as this? Thanks.

Hello, We're familiar with most SCADA software, but still learning VTSCADA. We are used to the flexibility of script to do things that native symbols and widgets do not do. Right now, we are trying to configure a button that when clicked, will perform: TagA = TagB. (where TagA and TagB are Analog Values) Searching through the help files, we can only find "button" style widgets in VTSCADA that set a tag to a hard number. Is there a way to make buttons that perform scripts such as this? Thanks.

Use a multi-write tag and draw it on a page as a button. No scripting is required smile

Use a multi-write tag and draw it on a page as a button. No scripting is required :)

Trihedral Engineering Ltd.

Huh. I fell right into that pitfall. Thanks for the help.

62ac7a1672b30

Hey, if you can think of any way to do this within a widget using parameters instead of tags, please let me know!
For example, when a button in a widget is clicked, set one parameter equal to another parameter.

Huh. I fell right into that pitfall. Thanks for the help. ![62ac7a1672b30](serve/attachment&path=62ac7a1672b30) Hey, if you can think of any way to do this within a widget using parameters instead of tags, please let me know! For example, when a button in a widget is clicked, set one parameter equal to another parameter.

Can you describe what you are trying to achieve here in more detail? There are several ways to work with tag or widget parameters, but depending on the need, my suggestion could be quite different.

Can you describe what you are trying to achieve here in more detail? There are several ways to work with tag or widget parameters, but depending on the need, my suggestion could be quite different.

Trihedral Engineering Ltd.

Dave, wow I appreciate your attentiveness and help on this.

It is a simple selector switch widget (the native one doesn't quite work for us).

When user clicks left position, [switchvalue]=[leftvalue]
when user clicks center position: [switchvalue] = [middlevalue]
when user clicks right position: [switchvalue] = [rightvalue]

All those bracketed things are parameters.

Thanks.

Dave, wow I appreciate your attentiveness and help on this. It is a simple selector switch widget (the native one doesn't quite work for us). When user clicks left position, [switchvalue]=[leftvalue] when user clicks center position: [switchvalue] = [middlevalue] when user clicks right position: [switchvalue] = [rightvalue] All those bracketed things are parameters. Thanks.

I wanted to learn a couple of things here myself... So the link below is a very rough starting point for your custom selector switch. Note the provided code is for reference only and has not been tested or debugged.

To import the widget, open the Idea Studio and go to File -> Import -> Widget.

https://drive.google.com/file/d/1xUszhdrk5DiUtq-RspS8hI0mzbbd70qA/view?usp=sharing

As an aside, we hope to make some decent syntax highlighting available to everyone soon.

I wanted to learn a couple of things here myself... So the link below is a very rough starting point for your custom selector switch. **Note the provided code is for reference only and has not been tested or debugged.** To import the widget, open the Idea Studio and go to File -> Import -> Widget. https://drive.google.com/file/d/1xUszhdrk5DiUtq-RspS8hI0mzbbd70qA/view?usp=sharing As an aside, we hope to make some decent syntax highlighting available to everyone soon.

Trihedral Engineering Ltd.

Thanks Dave. That widget works.
I learned a lot, even by reading the source code. Appreciate your time.

Thanks Dave. That widget works. I learned a lot, even by reading the source code. Appreciate your time.

I'm glad this worked out for you. I tried to write the code in a way that would highlight some of the most used tools in custom code such as the If Watch()[] statement. Note that VTScada also includes programming applications like the Source Debugger and profiler which can be helpful when watching variables, adding breakpoints or determining system resource use. If you don't see them in the VAM, just add a new application, select advanced, and add existing. You should see them located in the application installation directory.

I should note that each has a learning curve and I'm not sure how many resources we have to help with this though I believe we have some helpful YouTube videos from VTScadaFest.

I'm glad this worked out for you. I tried to write the code in a way that would highlight some of the most used tools in custom code such as the If Watch()[] statement. Note that VTScada also includes programming applications like the Source Debugger and profiler which can be helpful when watching variables, adding breakpoints or determining system resource use. If you don't see them in the VAM, just add a new application, select advanced, and add existing. You should see them located in the application installation directory. I should note that each has a learning curve and I'm not sure how many resources we have to help with this though I believe we have some helpful YouTube videos from VTScadaFest.

Trihedral Engineering Ltd.

edited Jun 24 '22 at 2:13 pm

Just a note on this. I have used watch() in widgets a few more times and there is a weird behavior (in 12.1.07 at least) where the tag value will change in the tag database, but not actually get written out to the device. There is then a mismatch between the tag database and the PLC. Also if using redundant servers the tag database value will change on the primary but not on the secondary. Again doesn’t change in the PLC. So yes, use set value widget as a workaround.

Just a note on this. I have used watch() in widgets a few more times and there is a weird behavior (in 12.1.07 at least) where the tag value will change in the tag database, but not actually get written out to the device. There is then a mismatch between the tag database and the PLC. Also if using redundant servers the tag database value will change on the primary but not on the secondary. Again doesn’t change in the PLC. So yes, use set value widget as a workaround.
366
8
2
live preview
enter atleast 10 characters
WARNING: You mentioned %MENTIONS%, but they cannot see this message and will not be notified
Saving...
Saved
With selected deselect posts show selected posts
All posts under this topic will be deleted ?
Pending draft ... Click to resume editing
Discard draft