Hi,
how can I combine following conditions, for better transparency
----------------------------------
void Station2_M700_ValueChange(System.Object sender, Neo.ApplicationFramework.Interfaces.Events.ValueChangedEventArgs e)
{
ScriptModule1.Start();
}
void Station2_M710_ValueChange(System.Object sender, Neo.ApplicationFramework.Interfaces.Events.ValueChangedEventArgs e)
{
ScriptModule1.Start();
}
----------------------------------
Like this ... ? ->
"Station2_M700_ValueChange or Station2_M710_ValueChange"
{
ScriptModule1.Start();
}
----------------------------------
Thanks for reply
Joe
Combination "ValueChange" in Tag Script
-
- Posts: 824
- Joined: Tue Mar 13, 2012 9:53 am
Re: Combination "ValueChange" in Tag Script
Create a function that calls ScriptModule1.Start(). Then use that function in both of your ValueChange events.
You are free to create your own functions in a screen script. You do not have to use ours.
You are free to create your own functions in a screen script. You do not have to use ours.
Code: Select all
namespace Neo.ApplicationFramework.Generated
{
using System.Windows.Forms;
using System;
using System.Drawing;
using Neo.ApplicationFramework.Tools;
using Neo.ApplicationFramework.Common.Graphics.Logic;
using Neo.ApplicationFramework.Controls;
using Neo.ApplicationFramework.Interfaces;
public partial class Screen1
{
void Button1_Click(System.Object sender, System.EventArgs e)
{
MyFunction();
}
void MyFunction()
{
ScriptModule1.Start();
}
}
}
Best Regards,
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
Mark Monroe
Beijer Electronics, Inc. | Applications Engineer
-
- Posts: 22
- Joined: Fri May 25, 2012 7:44 am
- Location: Charlotte, NC. USA
Re: Combination "ValueChange" in Tag Script
A slightly different option is the one I use. I create 1 single ValueChanged event, or manually create a function with matching signature. Per your existing convention.
Now from the script editor for Tags you can right click each tag you wish to use this ValueChange event code, and "Hookup existing..."
You can also cast "sender" to a GlobalDataItem if you want to gain access to the Tag's name, Gain, or Value for further specific function upon the change in value.
For Example, Assuming 4 Tags [Tag1 ... Tag4] are created, each assigned the same event handler.
You can now react to an individual condition (such as Name) depending on which tag was changed.
This is the methodology I use to create a central value change event handler and dispatch functionality to other Class Methods depending on the desired behavior I want.
Code: Select all
void Station2_Mxxx_ValueChange(System.Object sender, Neo.ApplicationFramework.Interfaces.Events.ValueChangedEventArgs e)
{
ScriptModule1.Start();
}
For Example, Assuming 4 Tags [Tag1 ... Tag4] are created, each assigned the same event handler.
Code: Select all
void Station2_Mxxx_ValueChange(System.Object sender, Neo.ApplicationFramework.Interfaces.Events.ValueChangedEventArgs e)
{
GlobalDataItem tag = (GlobalDataItem)sender;
if(tag.Name.Equals("Tag2"))
MessageBox.Show("Tag2 Was Changed!");
}
This is the methodology I use to create a central value change event handler and dispatch functionality to other Class Methods depending on the desired behavior I want.
Best Regards,
Patrick Hall
Patrick Hall