Welcome

>> Help for Asix v.7

www.asix.com.pl

Asix.Evo - Scripts

Doc. No ENH7E003

Version: 2012-08-29


1. The Basics of Using Scripts

In many applications there is a need to implement functionality that can not be achieved with standard mechanisms of diagrams and visualization objects. The typical examples of such functions are:

  • Performing non-standard calculations of the process variable values, particularly with the use of archival values.

  • Programming unusual responses to the events occurring in a controlled process.

  • Transferring the variable values and other information about the system operation outside the Asix.Evo application.

  • Advanced strategies for detecting alarm situations.

  • Loading data from non-standard data sources, e.g. from third-party databases.

  • Creating reports.

  • Creating specialized user interfaces, based on freely created windows.

In order to perform the above functions (and other similar), Asix.Evo features a module supporting the user script. Asix.Evo provides an integrated environment for creating and running scripts.

Asix.Evo uses the possibilities offered by the Net. platform. In fact, application scripts are fully compiled Net. modules. It is possible to use the C# and Visual Basic programming languages. The user scripts can use the full set of objects and the functions of .NET platform. Additionally, the script execution environment is extended with access functions to the Asix.Evo application components.

The user scripts are run in separate application domains and in their own threads. The scripts and the main application are isolated from each other. This way, the risk that the entire application will crush due to a script runtime error is minimized.


1.1 Creating Script

To create a new script:

  • Open the Application Explorer panel.

  • Double-click with the mouse on the Scripts node or execute the Create Script command from the context menu of the Scripts node. This will open the following window:

Fig. New Script Declaration Window.

  • Specify the script name and language and use the Create button.

The above activities will generate the script initial template and open the script edit panel.


1.2. Script Edition

Script edit panel is a basic tool for writing and running scripts in a test mode of the Asix.Evo application. Any other programming editor may be used as well - provided that the script file localization will be saved in the application definition directory.

Fig. Edit Panel of Scripts.

The Script Editor provides: code colouring based on a syntax, automatic formatting, immediate detection of errors, name prompting and completion, developing of component classes.

Incorrect code fragments are underlined in red. Additionally, a summary description of an error may by displayed in a tooltip. It is also possible to perform a full compilation of a script using the Test button. Any errors will be displayed in the table of messages.

One of the most useful editor function is developing components and complementation of names. The editor automatically detects the edition context, and at the right moments displays a box with alternatives proposed - they can be the class component names, variable names, enumeration components. The user can open the tooltip with the Ctrl-space keyboard shortcut.

The edit panel also allows for an easy management of script execution. The script can be run (with specified parameters or not), it is also possible to force its termination.


1.3. Methods to Run Scripts

Scripts in the Asix.Evo application are always run using the Script operator action.

Script(name, parameter1, parameter2, ...)

In the call content, the script name and the correct number of run parameters should be specified. The Script action can be used wherever the use of operator action is permitted.

Two main categories of scripts can be distinguished: interactive scripts run as a result of the operator activities and autonomous scripts, run in the application background, performing function not directly related to the operator activities.


1.3.1. Interactive Scripts

In the case of the interactive scripts, the Script operator action is used as an action linked to the visualization object event or as the user menu action.

Fig. The Example of Operator Action for Interactive Scripts.

The above example shows the component definition of the user menu which, when used, executes the StartAll script.

Fig. The Script Used to Handle the Button Press Event in the Button Class Object.

The following example shows identical action, but this time used to handle the button press event in the Button class object.


1.3.2. Autonomous Scripts

Autonomous scripts are usually run through the schedule mechanism. Scripts of this type are mostly used in the schedule components, which execution mode is set to Once at application start. In this mode, the script is run at the start-up and operates until the application is closed. It is also possible to use a periodic mode of initialisation or initialisation when a specific event occurs. In these modes, the script is run repeatedly, it should perform its task and then terminate.

Note:

The functionality of performing certain functions periodically or in response to the occurrence of certain events, can be easily implemented into the script which is run once. This technique is more effective, it does not require time-consuming process of running the script each time.

Fig. Scheduler - Execution Modes of Scripts.

The above example shows different execution modes of scripts.


1.4. Active Script Management

The application designer is provided with one more mechanism, of primarily diagnostic importance, used to control script operation. The Active Scripts panel is opened by selecting the Diagnostics/Active Scripts node in the Application Explorer panel.

Fig. The Active Script Panel.

The active script window allows monitoring, closing and restarting all the currently running scripts. It also enables starting new scripts.


1.5. Script Code Structure

The Asix.Evo scripts can be created in the C# and Visual Basic object-oriented languages. When the script is created, its code structure is generated:

C#

using System;
using System.Windows.Forms;
using Askom.AsixEvo.Scripting;

public class SkryptT1 : IScript
{
public bool Initialize(string[] aParameters, IApplication aApplication)
{
return true;
}

public void FinalizeScript()
{
}
}

VB

Imports System;
Imports System.Windows.Forms;

Imports Askom.AsixEvo.Scripting;

Public Class SkryptT2
Implements IScript

Public Function Initialize(ByVal aParameters() As String, ByVal aApplication As IApplication) As Boolean Implements IScript.Initialize

Return True
End Function

Public Sub FinalizeScript() Implements IScript.FinalizeScript

End Sub

End Class

The main script class must implement the IScript interface defined within the Askom.AsixEvo.Scripting area.

C#

public interface IScript
{
bool Initialize(string[] aParameters, IApplication aAscent);
void FinalizeScript();
}

VB

Public Interface IScript
Function Initialize(ByVal aParameters() As String, ByVal aApplication As IApplication) As Boolean
Sub FinalizeScript()
End Interface

The Initialize function, is the main function of the script called at the time of its initialization. The function receives two input parameters:

  • aParameters - it is the table containing all the parameters transmitted at the script execution;

  • aApplication - transmits a reference to the IApplication interface, which allows accessing the running application state. It is the basic mechanism of the script interoperability with the Asix.Evo application environment.

The value returned by the Initialize function, determines whether the script has been terminated. The true value means that the script has performed all of its functions and should be closed. This is a typical action of the so called one-time scripts. The resident scripts should return the false value. The script remains in the memory and will be able to continue running.

The FinalizeScript function is called directly before the script exits. It enables executing operations required for the correct closing of the script, e.g. release of the used system resources, closing connections with database, etc.


2.1. One-time Scripts

The one-time scripts are usually run interactively, by the operator or periodically, according to a schedule. Generally, the one-time script runs for a short period of time. All of its functions are within the Initialize method (or within the other methods called by the Initialize method). In the case of the one-time script, the Initialize method must return the true value.

The example shows the script which has to record the information on operator presence in a text file. The operator is responsible for periodical initialization of the script (e.g. by using correctly configured Button object), and each initialization will save a message to the registry file.

C#

using System;
using System.Windows.Forms;
using Askom.AsixEvo.Scripting;
using System.IO;

public class Single : IScript
{
public bool Initialize(string[] aParameters, IApplication aApplication)
{
StreamWriter writer = new StreamWriter(

Path.Combine(aApplication.ApplicationWorkingDirectory, "logs\\rejestr.txt"), true,

System.Text.ASCIIEncoding.GetEncoding(1250));
String msg = String.Format("{0} Operator presence notification: operator = {1}, workstation= {2}",

DateTime.Now, aApplication.CurrentUserName, aApplication.CurrentStationName);
writer.WriteLine(msg);
writer.Close();

aApplication.ReportMessage(EvoMessageType.Info, "Operator presence notification registered");

return true;
}

public void FinalizeScript()
{

}
}

VB

Imports System
Imports System.Windows.Forms
Imports Askom.AsixEvo.Scripting
Imports System.IO

Public Class SingleVB
Implements IScript

Public Function Initialize(ByVal aParameters() As String, ByVal aApplication As _

IApplication) As Boolean Implements IScript.Initialize

Dim writer As StreamWriter
writer = New StreamWriter(Path.Combine(aApplication.ApplicationWorkingDirectory,

"logs\\rejestr.txt"), True, System.Text.ASCIIEncoding.GetEncoding(1250))

Dim msg As String
msg = String.Format("{0} Operator presence notification: operator = {1}, workstation= {2}", _
Date.Now, aApplication.CurrentUserName, aApplication.CurrentStationName)
writer.WriteLine(msg)
writer.Close()

aApplication.ReportMessage(EvoMessageType.Info, " Operator presence notification registered ")

Return True

End Function

Public Sub FinalizeScript() Implements IScript.FinalizeScript

End Sub

End Class

The entire code is located in the Initialize function. First, the StreamWriter class object is created. In the object constructor a file name is transferred, the writing to file option and the text encoding method are selected (as the default UTF8 encoding would be used). The file name is created based on the application working directory name, returned by the ApplicationWorkingDirectory property. Then, a message text containing the name of the user currently logged in: CurrentUserName, and the workstation name: CurrentStationName, is created and saved. At the end, the Initialize function returns the true property informing of the termination of the script running.

The call of the ReportMessage function is not necessary. However, it is recommended to register messages informing about the script running and its possible execution errors in the standard message log.


2.2. Resident Scripts

The characteristic feature of the resident scripts is that after their initialization, they remain running until the application is closed. Generally, they are started along with the application according to the scheduler mechanism.

In the resident scripts, the Initialize method is usually used to initialize the script, and the main functionality is implemented in the created threads or in the declared return functions. For the resident script, the Initialize method must return the false value.

Different programming templates for resident script creation are available, and these templates are described in the subsequent sections.


2.2.1. Loops in Initialize Method

The method of continuous loop in the Initialize method is the simplest structure that have much in common with the one-time scripts. The main functionality is achieved by the Initialize method. However, the method running never ends (it will be automatically ended when the application is closed). This is the only case where, for obvious reasons, the value returned by the Initialize method is of no importance.

C#

using System;
using System.Windows.Forms;
using Askom.AsixEvo.Scripting;

public class Loop : IScript
{
IApplication application;

public bool Initialize(string[] aParameters, IApplication aApplication)
{
application = aApplication;
while (true)
{
DoTask();
aApplication.Sleep(TimeSpan.FromSeconds(1));
}

return true;
}

public void FinalizeScript()
{

}

void DoTask()
{
application.ReportMessage(EvoMessageType.Info, "The script running cycle completed");
}
}

VB

Imports System
Imports System.Windows.Forms
Imports Askom.AsixEvo.Scripting

Public Class LoopVB
Implements IScript

Dim application As IApplication
Public Function Initialize(ByVal aParameters() As String, ByVal aApplication As _

IApplication) As Boolean Implements IScript.Initialize

application = aApplication
While (True)

DoTask()
aApplication.Sleep(TimeSpan.FromSeconds(1))

End While

Return True

End Function

Public Sub FinalizeScript() Implements IScript.FinalizeScript

End Sub

Sub DoTask()

application.ReportMessage(EvoMessageType.Info, "The script running cycle completed")

End Sub

End Class

The main script functionality is achieved by the DoTask method. The Initialize method includes the While type continuous loop in which the DoTask method is called cyclically. Between the subsequent calls, the 1-second suspension of the running cycle takes place. The used Sleep method of the IApplication interface is the recommended method of suspending the script operation for a specific period of time.


2.2.2. Use of RegisterTimeEvent Function

The method of the RegisterTimeEvent function of the IApplication interface involves declaring the callback function, which will be executed periodically. The RegisterTimeEvent function allows the period and moments of the callback function execution to be very carefully specified.

C#

using System;
using System.Windows.Forms;
using Askom.AsixEvo.Scripting;

public class Timer : IScript
{
IApplication application;
public bool Initialize(string[] aParameters, IApplication aApplication)
{
application = aApplication;
application.RegisterTimeEvent(Report1Hour, TimeSpan.FromHours(1),

                                    TimeSpan.FromMinutes(15));
return false;
}

public void FinalizeScript()
{

}

void Report1Hour()
{
application.ReportMessage(EvoMessageType.Info, "Creating a report at a time" +

DateTime.Now);
}
}

VB

Imports System
Imports System.Windows.Forms
Imports Askom.AsixEvo.Scripting

Public Class TimerVB
Implements IScript

Dim application As IApplication
Public Function Initialize(ByVal aParameters() As String, ByVal aApplication _

As IApplication) As Boolean Implements IScript.Initialize

application = aApplication
application.RegisterTimeEvent(AddressOf Report1Hour, TimeSpan.FromHours(1), _

TimeSpan.FromMinutes(15))
Return False

End Function

Public Sub FinalizeScript() Implements IScript.FinalizeScript

End Sub

Sub Report1Hour()

application.ReportMessage(EvoMessageType.Info, "Creating a report at a time" _

& DateTime.Now)
End Sub

End Class

In the Initialize method the Report1Hour callback function is registered. Returning the false value loads the script into the memory.

The second parameter of the RegisterTimeEvent method specifies the period of time between the subsequent callback function calls, and the third parameter specifies the initial point offset. The Report1Hour method will be called every 1 hour, at 15 minutes past each full hour.


2.2.3. Creating Threads

When using the method of multiple threads, the CreateThread method of the IApplication interface is used. It is possible to create multiple threads to be executed independently. The threads functioning and their mutual synchronization is entirely arbitrary - the synchronization methods provided by the .NET platform should be used.

C#

using System;
using System.Windows.Forms;
using Askom.AsixEvo.Scripting;

public class ThreadDemo : IScript
{
IApplication application;
public bool Initialize(string[] aParameters, IApplication aApplication)
{
application = aApplication;

System.Threading.Thread t1 = aApplication.CreateThread(ThreadFun);
t1.Start();

return false;
}

public void FinalizeScript()
{

}

void ThreadFun()
{
while (true)
{
application.ReportMessage(EvoMessageType.Info, "The script running cycle completed");
application.Sleep(TimeSpan.FromSeconds(1));
}
}
}

VB

Imports System
Imports System.Windows.Forms
Imports Askom.AsixEvo.Scripting

Public Class ThreadDemoVB
Implements IScript

Dim application As IApplication
Public Function Initialize(ByVal aParameters() As String, ByVal aApplication As _

IApplication) As Boolean Implements IScript.Initialize

application = aApplication
Dim t As System.Threading.Thread
t = aApplication.CreateThread(AddressOf ThreadFun)
t.Start()
Return False

End Function

Public Sub FinalizeScript() Implements IScript.FinalizeScript

End Sub

Sub ThreadFun()

While True
application.ReportMessage(Askom.MessageLogging.MessageType.Warning, _

"The script running cycle completed")
application.Sleep(TimeSpan.FromSeconds(1))
End While

End Sub

End Class

In the Initialize method, with the CreateThread method a new working thread is created. The ThreadFun method is specified as the thread function. After creating, a new thread is run. Returning the false value loads the script into the memory, and the thread continues to operate.

Running the thread calls the ThreadFun method. The main script functionality is performed by the While continuous loop. Between the subsequent running cycles, the 1-second pause takes place. Creating threads that run without interruption should be avoided, as it causes a CPU overloading.

The method of independent threads should be used, when initialisation of more than one thread is necessary. The example shown can be implemented in an easier way, using the continuous loop method within the Initialize method.


2.2.4. Monitoring the Process Variable Changes

The method of creating the resident scripts, synchronised by the current process variable value changes involves declaring callback function which will be called whenever the variable state changes. To register a callback function, the RegisterStateEvent method of the IVariable interface is used. En example code can be found in the section concerning the readout of current values of process variables (see: 2.4. Readout of Current Values of Process Variables ).


2.2.5. Monitoring Alarm Status

The method of creating the resident scripts, synchronised by the changes of the selected alarm status involves declaring the callback function which will be called whenever the alarm status changes. To register a callback function, the RegisterStateEvent method of the IAlarm interface is used. En example code can be found in the section concerning monitoring alarm status (see: 2.9. Monitoring Alarm Status ).


2.3. Readout of Script Starting Parameters

When starting a script, the aParameters array, from which all the call parameters values can be readout is transferred to the Initialize function. The parameter mechanism allows writing the universal scripts, which functioning details depend on the call method. The transfer of process variable name, an alarm ID, a file name, etc., are the typical examples.

Two call parameters readout methods are available. The first method is used to view all elements of the parameter array. In the second one, an access to an argument by specifying its consecutive number is used.

C#

using System;
using System.Windows.Forms;
using Askom.AsixEvo.Scripting;

public class Argumenty : IScript
{
public bool Initialize(string[] aParameters, IApplication aApplication)
{
int i = 0;
if (aParameters != null)
{
foreach (string p in aParameters)
aApplication.ReportMessage(EvoMessageType.Info,

String.Format("Parametr {0} = {1}", ++i, p));
}

return true;
}

public void FinalizeScript()
{

}
}

VB

Imports System
Imports System.Windows.Forms
Imports Askom.AsixEvo.Scripting

Public Class ArgumentyVB
Implements IScript

Public Function Initialize(ByVal aParameters() As String, ByVal aApplication _

As IApplication) As Boolean Implements IScript.Initialize

Dim i As Integer
i = 0

If (Not aParameters Is Nothing) Then
For Each p As String In aParameters
i += 1
aApplication.ReportMessage(EvoMessageType.Info, _

String.Format("Parametr {0} = {1}", i, p))
Next p
End If

Return True

End Function

Public Sub FinalizeScript() Implements IScript.FinalizeScript

End Sub

End Class

The above code shows iteration method which applies to all the elements of the aParameters parameter array.

C#

using System;
using System.Windows.Forms;
using Askom.AsixEvo.Scripting;

public class Argumenty : IScript
{
public bool Initialize(string[] aParameters, IApplication aApplication)
{

if (aParameters == null || aParameters.Length < 2)
aApplication.ReportMessage(EvoMessageType.Info, "Too few parameters");
else
{
aApplication.ReportMessage(EvoMessageType.Info, "Parametr 1 = " + aParameters[0]);
aApplication.ReportMessage(EvoMessageType.Info, "Parametr 2 = " + aParameters[1]);
}

return true;
}

public void FinalizeScript()
{

}
}

VB

Imports System
Imports System.Windows.Forms
Imports Askom.AsixEvo.Scripting

Public Class ArgumentyVB
Implements IScript

Public Function Initialize(ByVal aParameters() As String, ByVal aApplication As _

IApplication) As Boolean Implements IScript.Initialize

If (aParameters Is Nothing) Then
aApplication.ReportMessage(EvoMessageType.Info, "No parameters")
ElseIf (aParameters.Length < 2) Then
aApplication.ReportMessage(EvoMessageType.Info, "Too few parameters")
Else
aApplication.ReportMessage(EvoMessageType.Info, "Parametr 1 = " + aParameters(0))
aApplication.ReportMessage(EvoMessageType.Info, "Parametr 2 = " + aParameters(1))
End If

Return True

End Function

Public Sub FinalizeScript() Implements IScript.FinalizeScript

End Sub

End Class

The above code shows the parameter readout method involving specification of the component index in the aParameters array. Prior the readout attempt it is necessary to check if the correct number of parameters was transmitted into the script.


2.4. Readout of Current Process Variable Values

Using the IVariable interface objects, the access to current values of process variables is achieved. The first step is always to obtain such an object for the selected variable via the GetVariable function of the IApplication interface.

The example shows the simplest case in which the current variable value is stored in the messages log once.

C#

using System;
using System.Windows.Forms;
using Askom.AsixEvo.Scripting;

public class CurrValues : IScript
{
public bool Initialize(string[] aParameters, IApplication aApplication)
{
IVariable v = aApplication.GetVariable(aParameters[0], false);
if (v == null)

aApplication.ReportMessage(EvoMessageType.Error,
string.Format("The variable {0} is not defined", aParameters[0])); else
{
if (v.VariableState.IsGood)
{
aApplication.ReportMessage(EvoMessageType.Error,
string.Format("The value of variable {0}, Timestemp: {1}",
v.VariableState.Value, v.VariableState.TimeStamp));
}
else
aApplication.ReportMessage(EvoMessageType.Error,
string.Format("Incorrect status of the value {0} ", v.VariableState.Status));

v.Dispose();
}

return true;
}

public void FinalizeScript()
{
}
}

VB

Imports System
Imports System.Windows.Forms
Imports Askom.AsixEvo.Scripting

Public Class CurrValuesVB
Implements IScript

Public Function Initialize(ByVal aParameters() As String, ByVal aApplication As _

IApplication) As Boolean Implements IScript.Initialize

Dim v As IVariable
v = aApplication.GetVariable(aParameters(0), False)
If v Is Nothing Then
aApplication.ReportMessage(EvoMessageType.Error, _
String.Format("The variable {0} is not defined", aParameters(0)))
Else
If (v.VariableState.IsGood) Then
aApplication.ReportMessage(EvoMessageType.Error, _
String.Format("The value of variable {0}, Timestemp: {1}", _
v.VariableState.Value, v.VariableState.TimeStamp))
Else
aApplication.ReportMessage(EvoMessageType.Error, _
String.Format("Incorrect status of the value {0} ", v.VariableState.Status))
End If
v.Dispose()
End If

Return True

End Function

Public Sub FinalizeScript() Implements IScript.FinalizeScript

End Sub

End Class

After obtaining the correct IVariable object for the variable of the name transmitted in the call parameters, the variable value is stored in the log. The current value, status and timestamp are accessed via the VariableState property of the variable object. Please take a note how the variable correctness is verified via calling the IsGood method.

The variable value obtained in the example is the result of the last scheduled refreshing of variable. When variables are rarely refreshed, this variable can be outdated. If a script requires running with the most current value, use the Read function of the IVariable interface.

C#

using System;
using System.Windows.Forms;
using Askom.AsixEvo.Scripting;

public class CurrValuesRead : IScript
{
public bool Initialize(string[] aParameters, IApplication aApplication)
{
IVariable v = aApplication.GetVariable(aParameters[0], false);
if (v == null)
{
aApplication.ReportMessage(EvoMessageType.Error,
string.Format("The variable {0} is not defined", aParameters[0]));
}
else
{
VariableState vValue = v.Read();
if (vValue.IsGood)
{
aApplication.ReportMessage(EvoMessageType.Error,
string.Format("The value of variable {0}, Timestemp: {1}",
vValue.Value, vValue.TimeStamp));
}
else
aApplication.ReportMessage(EvoMessageType.Error,
string.Format("Incorrect status of the value {0} ", vValue.Status));

v.Dispose();
}
return true;
}

public void FinalizeScript()
{
}
}

VB

Imports System
Imports System.Windows.Forms
Imports Askom.AsixEvo.Scripting

Public Class CurrValuesReadVB
Implements IScript

Public Function Initialize(ByVal aParameters() As String, ByVal aApplication As _

IApplication) As Boolean Implements IScript.Initialize

Dim v As IVariable
v = aApplication.GetVariable(aParameters(0), False)
If v Is Nothing Then
aApplication.ReportMessage(EvoMessageType.Error, _
String.Format("The variable {0} is not defined", aParameters(0)))
Else
Dim vValue As VariableState
vValue = v.Read()
If (vValue.IsGood) Then
aApplication.ReportMessage(EvoMessageType.Error, _
String.Format("The value of variable {0}, Timestemp: {1}", _
vValue.Value, vValue.TimeStamp))
Else
aApplication.ReportMessage(EvoMessageType.Error, _
String.Format("Incorrect status of the value {0} ", vValue.Status))
End If
v.Dispose()
End If

Return True

End Function

Public Sub FinalizeScript() Implements IScript.FinalizeScript

End Sub

End Class

However, it should be noted that an excessive use of the Read function can heavily overload a communication link and deteriorate the performance of the entire Application.


2.4.1. Cyclical Readout of Current Process Variable Values

The necessity for the cyclical readout and processing the process variable value is a typical case. In such cases, the periodical call mechanism of the selected function may be used.

The following example script saves the current values of two variables to a text file. Saving is performed every 15 minutes.

C#

using System;
using System.Windows.Forms;
using Askom.AsixEvo.Scripting;
using System.IO;

public class CurrValuesReport : IScript
{
IApplication application;
IVariable v1, v2;

public bool Initialize(string[] aParameters, IApplication aApplication)
{
application = aApplication;
v1 = aApplication.GetVariable(aParameters[0], true);
v2 = aApplication.GetVariable(aParameters[1], true);
aApplication.RegisterTimeEvent(Report15Min, TimeSpan.FromMinutes(15),

TimeSpan.FromMinutes(0));
return false;
}

public void FinalizeScript()
{

}

void Report15Min()
{
StreamWriter writer = new StreamWriter(
Path.Combine(application.ApplicationWorkingDirectory, "logs\\reports.txt"), true,
System.Text.ASCIIEncoding.GetEncoding(1250));
String msg = String.Format("{0},{1},{2}",
DateTime.Now, v1.VariableState.IsGood ? v1.VariableState.Value : "?",
v2.VariableState.IsGood ? v2.VariableState.Value : "?");
writer.WriteLine(msg);
writer.Close();
}
}

VB

Imports System
Imports System.Windows.Forms
Imports Askom.AsixEvo.Scripting
Imports System.IO

Public Class CurrentValuesReportVB
Implements IScript

Dim application As IApplication
Dim v1, v2 As IVariable
Public Function Initialize(ByVal aParameters() As String, ByVal aApplication As _

IApplication) As Boolean Implements IScript.Initialize

application = aApplication
v1 = aApplication.GetVariable(aParameters(0), True)
v2 = aApplication.GetVariable(aParameters(1), True)
application.RegisterTimeEvent(Report15Min, TimeSpan.FromMinutes(15), _

TimeSpan.FromMinutes(0))
Return False

End Function

Public Sub FinalizeScript() Implements IScript.FinalizeScript

End Sub

Sub Report15Min()

Dim writer As StreamWriter
writer = New StreamWriter( _
Path.Combine(application.ApplicationWorkingDirectory, "logs\\reports.txt"), True, _
System.Text.ASCIIEncoding.GetEncoding(1250))
Dim msg, v1v, v2v As String
If v1.VariableState.IsGood Then v1v = v1.VariableState.Value Else v1v = "?"
If v2.VariableState.IsGood Then v2v = v2.VariableState.Value Else v2v = "?"
msg = String.Format("{0},{1},{2}", DateTime.Now, v1v, v2v)
writer.WriteLine(msg)
writer.Close()

End Sub

End Class

Within the Initialize function two IVariable objects which will be used to readout the variable values are created. It is important to set the second parameter of the GetVariable function to True. This enables the process variable refreshing - if the refreshing is not performed, the variable value, when loaded within the periodic function, is outdated.

The RegisterTimeEvent function registers the Report15Min periodic function. The function will be performed every 15 minutes, at 0, 15, 30 and 45 minute.

The Initialize function returns the False value, which causes the script to continue running.

Within the Report15Min function, data recording to a file is executed - the variable values are loaded in the standard way, via the VariableState property.


2.4.2. Current Value Readout Controlled by the Variable

2.4.2. Current Value Readout Controlled by the Variable Refreshing

The other method of variable value cyclic processing is to use the RegisterStateEvent function that register a callback function called immediately whenever the variable is refreshed. This allows for immediate response to a change of the variable status. The callback function method is used in scenarios such as automatic calculation of the derivative value or detection of alarm situations.

The example of the script that uses RegisterStateEvent function is shown in the section concerning setting the variable values (see 2.5. Setting Process Variable Values ).


2.5. Setting Process Variable Values

In addition to the variable value readout, the IVariable interface also allows setting new values of variables based on calculations performed or on external data sources. The variable value can be changed using the SetVariableValue and SetVariableBits functions. The SetVariableBits function allows changing the individual bits of the variable value.


2.5.1. Calculation of Variable Derivative Values

The below script shows the method of calculating the third variable value based on the values of two standard variables. The script also shows the application of the refreshing callback function used to monitor the input variable values.

C#

using System;
using System.Windows.Forms;
using Askom.AsixEvo.Scripting;

public class VarCalc : IScript
{
IApplication application;
IVariable vIn1, vIn2, vOut;

public bool Initialize(string[] aParameters, IApplication aApplication)
{
application = aApplication;
vIn1 = aApplication.GetVariable(aParameters[0], true);
vIn2 = aApplication.GetVariable(aParameters[1], true);
vOut = aApplication.GetVariable(aParameters[2], false);
vIn1.RegisterStateEvent(RefreshedEvent);
vIn2.RegisterStateEvent(RefreshedEvent);
return false;
}

public void FinalizeScript()
{

}

void RefreshedEvent(string aVariableName, VariableState aVariableState)
{
try
{
if (vIn1.VariableState.IsGood && vIn2.VariableState.IsGood)
{
vOut.SetVariableValue(Recalculate(Convert.ToDouble(vIn1.VariableState.Value),
Convert.ToDouble(vIn2.VariableState.Value)));
}
}
catch (Exception e)
{
application.ReportMessage(EvoMessageType.Error, e.Message);

}
}

double Recalculate(double v1, double v2)
{
return v1 + v2;
}

}

VB

Imports System
Imports System.Windows.Forms
Imports Askom.AsixEvo.Scripting

Public Class VarCalcVB
Implements IScript

Dim application As IApplication
Dim vIn1, vIn2, vOut As IVariable

Public Function Initialize(ByVal aParameters() As String, ByVal aApplication As _

IApplication) As Boolean Implements IScript.Initialize

application = aApplication
vIn1 = aApplication.GetVariable(aParameters(0), True)
vIn2 = aApplication.GetVariable(aParameters(1), True)
vOut = aApplication.GetVariable(aParameters(2), False)
vIn1.RegisterStateEvent(AddressOf RefreshedEvent)
vIn2.RegisterStateEvent(AddressOf RefreshedEvent)
Return False

End Function

Public Sub FinalizeScript() Implements IScript.FinalizeScript
End Sub

Sub RefreshedEvent(ByVal aVariableName As String, ByVal aVariableState As VariableState)

Try
If (vIn1.VariableState.IsGood And vIn2.VariableState.IsGood) Then

vOut.SetVariableValue(

Recalculate(Convert.ToDouble(vIn1.VariableState.Value), _
Convert.ToDouble(vIn2.VariableState.Value)))

End If
Catch e As Exception
application.ReportMessage(EvoMessageType.Error, e.Message)
End Try

End Sub

Function Recalculate(ByVal v1 As Double, ByVal v2 As Double) As Double

Recalculate = v1 + v2

End Function

End Class

Within the Initialize function two IVariable objects which will be used to readout the variable values and one Ivariable object of calculated variable are created. It is important to set the second parameter of the GetVariable function to True for both input variables. Then, using the registerStateEvent method the RefresehedEvent callback function is declared for the input variables. It will be called whenever values of any of the input variables are changed.

The Initialize function returns the False value, which causes the script to continue running.

Within the RefreshedEvent function a new calculated value is calculated, and then the calculated variable is set using the SetVariableValue function. The parameters of the aVariableName and aVariableState callback functions can be used to determine which variable has been changed and to which value, but in the script from the example it was not needed.

Please take a note of the method of protecting the code using the try structure. The code is resistant to lack of, or incorrect input variable values.


2.5.2. Obtaining Values from External Sources

The below script sends periodically a ping to a device specified with an address or name. On the basis of the result, it sets the value of the selected variable to true or false. The calculated variable should be located in the None type channel.

C#

using System;
using System.Windows.Forms;
using Askom.AsixEvo.Scripting;
using System.Net.NetworkInformation;

public class Ping : IScript
{
IEventInfo mTimeTickInfo;
System.Net.NetworkInformation.Ping mPing;
IVariable mPingVar;
string mHost;

public bool Initialize(string[] aParameters, IApplication aApplication)
{
mHost = aParameters[0];

mPing = new System.Net.NetworkInformation.Ping();
mPingVar = aApplication.GetVariable(aParameters[1], false);

if (mPingVar != null && mPing != null)
{
mTimeTickInfo = aApplication.RegisterTimeEvent(PingCheck, TimeSpan.FromSeconds(5),

TimeSpan.MinValue);
return false;
}
else
return true;
}

public void FinalizeScript()
{
}

void PingCheck()
{
System.Net.NetworkInformation.PingReply reply = mPing.Send(mHost, 500);
mPingVar.SetVariableValue(reply.Status==System.Net.NetworkInformation.IPStatus.Success);
}
}

VB

Imports System
Imports System.Windows.Forms
Imports Askom.AsixEvo.Scripting

Public Class PingVB
Implements IScript

Dim mTimeTickInfo As IEventInfo
Dim mPing As System.Net.NetworkInformation.Ping
Dim mPingVar As IVariable
Dim mHost As String

Public Function Initialize(ByVal aParameters() As String, ByVal aApplication As _

IApplication) As Boolean Implements IScript.Initialize

mHost = aParameters(0)

mPing = New System.Net.NetworkInformation.Ping()
mPingVar = aApplication.GetVariable(aParameters(1), False)

If (mPingVar Is Nothing Or mPing Is Nothing) Then
Return True
Else
mTimeTickInfo = aApplication.RegisterTimeEvent(AddressOf PingCheck, _

TimeSpan.FromSeconds(5), TimeSpan.MinValue)
Return False
End If

End Function

Public Sub FinalizeScript() Implements IScript.FinalizeScript
End Sub

Sub PingCheck()

Dim reply As System.Net.NetworkInformation.PingReply

reply = mPing.Send(mHost, 500)
mPingVar.SetVariableValue(reply.Status=System.Net.NetworkInformation.IPStatus.Success)

End Sub

End Class

The PingCheck function is executed every 5 seconds. The process variable value is set based on the Send function result for the System.Net.NetworkInformation.Ping class object.


2.6. Readout of Archive Values of Process Variables

The IVariable interface also allows reading out historical values of variables. Generating reports and production indicator calculation based on archived data are the typical applications of this function.

The following example shows the method of creating a simple report in the HTML format.

C#

using System;
using System.IO;
using System.Windows.Forms;
using Askom.AsixEvo.Scripting;

public class RaportHtml : IScript
{
public bool Initialize(string[] aParameters, IApplication aApplication)
{
IVariable v = aApplication.GetVariable(aParameters[0], false);
if(v == null)
{
aApplication.ReportMessage( EvoMessageType.Error,

" Report generation error: Variable missing " + aParameters[0]);
return true;
}

DateTime day = DateTime.Today;
DateTime day0 = day.AddDays(-1);
ArcQuery q = new ArcQuery(day0, day, "average", TimeSpan.FromHours(1));

IArcQueryResult res = v.OrderArcData(q);

int loopCnt = 0;
while(res.ResultStatus == ArcResultStatus.Processing)
{
if(loopCnt > 200)
{
aApplication.ReportMessage(EvoMessageType.Error, "Report generation error! Response timed out.");
v.Dispose();
return true;
}

aApplication.Sleep(TimeSpan.FromMilliseconds(100));
loopCnt++;
}

if(res.ResultStatus == ArcResultStatus.Ready)
{
StreamWriter sw = null;
System.Text.StringBuilder sb = new System.Text.StringBuilder();
try
{
sb.AppendLine(

"<html><head><title>Raport -

Hourly averages of the previous day </title></head><body>"); sb.AppendLine("<table width=\"25%\" align=\"center\" border=\"1\" >");
sb.AppendLine("<tr><th>Godzina</th><th>Srednia</th></tr>");

if(res.Values != null)
{
foreach(ArcVariableState p in res.Values)
{

sb.AppendLine(

"<tr><td>" + p.TimeStamp.ToString() + "</td><td>" + p.Value + "</td></tr>"); }
}
sb.AppendLine("</table>");
sb.AppendLine("</body></html>");

string file = Path.Combine(aApplication.ApplicationWorkingDirectory,

"reports\\report.html");

sw = new StreamWriter(file);
sw.Write(sb.ToString());
System.Diagnostics.Process.Start(file);
}
catch(Exception ex)
{
aApplication.ReportMessage(EvoMessageType.Error,

"File saving error: " + ex.Message);
}
finally
{
if(sw != null)
{
sw.Close();
sw.Dispose();
}
}
}
else if(res.ResultStatus == ArcResultStatus.Error)
aApplication.ReportMessage(EvoMessageType.Error,

"Report generation error! " + res.ErrorDescription);

v.Dispose();
return true;
}

public void FinalizeScript()
{
}
}

VB

Imports System
Imports System.Windows.Forms
Imports Askom.AsixEvo.Scripting

Public Class RaportHtmlVB
Implements IScript

Public Function Initialize(ByVal aParameters() As String, ByVal aApplication As _

IApplication) As Boolean Implements IScript.Initialize

Dim v As IVariable
v = aApplication.GetVariable(aParameters(0), False)
If (v Is Nothing) Then
aApplication.ReportMessage(EvoMessageType.Error, _

"Report generation error: Variable missing" & aParameters(0))
Return True
End If

Dim day, day0 As DateTime
day = DateTime.Today
day0 = day.AddDays(-1)
Dim q As ArcQuery
q = New ArcQuery(day0, day, "average", TimeSpan.FromHours(1))

Dim res As IArcQueryResult
res = v.OrderArcData(q)

Dim loopCnt As Integer
loopCnt = 0
While (res.ResultStatus = ArcResultStatus.Processing)

If (loopCnt > 200) Then
aApplication.ReportMessage(EvoMessageType.Error, _
"Report generation error! Response timed out.")
v.Dispose()
Return True
End If

aApplication.Sleep(TimeSpan.FromMilliseconds(100))
loopCnt += 1

End While

If (res.ResultStatus = ArcResultStatus.Ready) Then

Dim sw As System.IO.StreamWriter
sw = Nothing
Dim sb As System.Text.StringBuilder
sb = New System.Text.StringBuilder()
Try
sb.AppendLine( _

"<html><head><title>Raport - Hourly averages of the previous day </title></head><body>")
sb.AppendLine("<table width=""25%"" align=""center"" border=""1"" >")
sb.AppendLine("<tr><th>Godzina</th><th>Srednia</th></tr>")

If (Not res.Values Is Nothing) Then

For Each p As ArcVariableState In res.Values
sb.AppendLine( _ "<tr><td>" & p.TimeStamp.ToString() & "</td><td>" & p.Value & "</td></tr>")
Next p
sb.AppendLine("</table>")
sb.AppendLine("</body></html>")

Dim file As String
file = System.IO.Path.Combine( _

aApplication.ApplicationWorkingDirectory, "reports\\report.html")
sw = New System.IO.StreamWriter(file)
sw.Write(sb.ToString())
System.Diagnostics.Process.Start(file)

End If

Catch ex As Exception
aApplication.ReportMessage(EvoMessageType.Error, _

"File saving error: " & ex.Message)
Finally
If (Not sw Is Nothing) Then
sw.Close()
sw.Dispose()
End If
End Try
ElseIf (res.ResultStatus = ArcResultStatus.Error) Then
aApplication.ReportMessage(EvoMessageType.Error, _

"Report generation error! " & res.ErrorDescription)
End If

v.Dispose()
Return True

End Function

Public Sub FinalizeScript() Implements IScript.FinalizeScript

End Sub

End Class

Readout of the archived values is initialized by calling the OrderArcData function of the IVariable interface. The call parameter is an object of the ArcQuery class that specifies what data and from which period are to be loaded. In the example, the data are loaded from the last day, and the returned values are the 1-hourly averages.

Waiting for the operation completion after initiating the readout involves testing the status of the ResultStatus operation execution (the alternative method for the waiting is declaration of a callback function called upon readout termination). After identification of the operation successful termination, the script generates an output report. The archival values are returned in the Values collection accessed via the execution status object. The collection class consists of the ArcVariableState objects - each object determines the value, status and timestamp of a single archival value.

When the report is generated, calling the Start method of the Process object opens the report in the default web browser.


2.7. Using Array Variables

The array variables use method differs marginally from the standard variable handling. Only the interpretation method of the Value property of the VariableState object is different.


2.7.1. Array Variables Readout

The following example saves values of all elements of the array variable of a name specified in the starting parameters to the messages log.

C#

using System;

using System.Windows.Forms;

using Askom.AsixEvo.Scripting;

public class TableGet : IScript

{

public bool Initialize(string[] aParameters, IApplication aApplication)

{

IVariable v = aApplication.GetVariable(aParameters[0], false);

v.Read();

int[] valTable = (int[])(v.VariableState.Value);

System.Text.StringBuilder sb = new System.Text.StringBuilder();

foreach (int val in valTable)

{

sb.Append(val);

sb.Append(" ");

}

aApplication.ReportMessage(EvoMessageType.Info, sb.ToString());

v.Dispose();

return true;

}

public void FinalizeScript()

{

}

}

VB

Imports System

Imports System.Windows.Forms

Imports Askom.AsixEvo.Scripting

Public Class TableGetVB

Implements IScript

Public Function Initialize(ByVal aParameters() As String, ByVal aApplication _

As IApplication) As Boolean Implements IScript.Initialize

Dim v As IVariable = aApplication.GetVariable(aParameters(0), False)

v.Read()

Dim valTable() As Integer = v.VariableState.Value

Dim sb As System.Text.StringBuilder = New System.Text.StringBuilder()

For Each val As Integer In valTable

sb.Append(val)

sb.Append(" ")

Next val

aApplication.ReportMessage(EvoMessageType.Info, sb.ToString())

v.Dispose()

Return True

End Function

Public Sub FinalizeScript() Implements IScript.FinalizeScript

End Sub

End Class

The key element of the script is to substitute for the ValTable local variable the Value property of the process variable associated with a relevant value type declaration. It is important to maintain compliance of the valTable variable type with a type of the process variable resulting from its definition and acquisition method.

In addition to the shown example of the iteration applying to all elements of the array, a direct readout of any element using an index notation, e.g. valTable [5] (C #) or valTable(5) (VB) is also possible.


2.7.2. Saving Array Variables

The following example shows the method of using the array variables to store a lot of information in a single variable. The script reads the text file contents including messages that will be displayed on a diagram. The first five lines of the file are read. The texts read are saved to subsequent components of process variable.

It is assumed that the used variable is located in the channel of NONE type and its Value Type attribute is Table.

C#

using System;

using System.IO;

using System.Windows.Forms;

using Askom.AsixEvo.Scripting;

public class Messages : IScript

{

public bool Initialize(string[] aParameters, IApplication aApplication)

{

try

{

StreamReader file = new StreamReader(aParameters[0],System.Text.Encoding.Default);

string[] msgs = new string[5];

msgs[0] = file.ReadLine();

msgs[1] = file.ReadLine();

msgs[2] = file.ReadLine();

msgs[3] = file.ReadLine();

msgs[4] = file.ReadLine();

IVariable v = aApplication.GetVariable(aParameters[1], false);

v.SetVariableValue(msgs);

v.Dispose();

file.Close();

}

catch (Exception e)

{

aApplication.ReportMessage(EvoMessageType.Info,"Error in Messages: " + e.Message);

}

return true;

}

public void FinalizeScript()

{

}

}

VB

Imports System

Imports System.IO

Imports System.Windows.Forms

Imports Askom.AsixEvo.Scripting

Public Class MessagesVB

Implements IScript

Public Function Initialize(ByVal aParameters() As String, ByVal aApplication _

As IApplication) As Boolean Implements IScript.Initialize

Try

Dim file As StreamReader = _

New StreamReader(aParameters(0), System.Text.Encoding.Default)

Dim msgs(4) As String

msgs(0) = file.ReadLine()

msgs(1) = file.ReadLine()

msgs(2) = file.ReadLine()

msgs(3) = file.ReadLine()

msgs(4) = file.ReadLine()

Dim v As IVariable = aApplication.GetVariable(aParameters(1), False)

v.SetVariableValue(msgs)

v.Dispose()

file.Close()

Catch e As Exception

aApplication.ReportMessage(EvoMessageType.Info,"Error in Messages: " + e.Message)

End Try

Return True

End Function

Public Sub FinalizeScript() Implements IScript.FinalizeScript

End Sub

End Class

A local five-component array variable is created in a script. Then, based on the text file contents, its subsequent components are set. The standard call to the SetVariableValue method terminates the script running.

In the diagram objects, it is possible to call to the array variable component using the TableElement function e.g. TableElement(Variable (zmienna),2).


2.8. Transferring Pattern Trends

The applications using a pattern trends are typically responsible for transferring the trend definition to the controller. It can be done with sequence of operations sending subsequent points via a single variable, but generally, it is preferable to send the entire definition in a single transmission using an array variable.

The GetTrendPatternPoints method of the IApplication interface is used to readout the pattern trends.

C#

using System;

using System.Windows.Forms;

using Askom.AsixEvo.Scripting;

public class Curve : IScript

{

public bool Initialize(string[] aParameters, IApplication aApplication)

{

IVariable v = aApplication.GetVariable(aParameters[1], false);

int varSize = Convert.ToInt32(v.VariableAttribute("ElementsCount"));

int[] transferBuffer = new int[varSize];

int pointsCount = 0;

foreach (TrendPatternPoint point in

aApplication.GetTrendPatternPoints(aParameters[0]))

{

if (pointsCount <= varSize - 2)

{

transferBuffer[pointsCount] = (int)point.TimeStamp.TotalSeconds;

transferBuffer[pointsCount + 1] = (int)point.Value;

pointsCount += 2;

}

else

{

if (pointsCount <= varSize)

transferBuffer[pointsCount] = 0;

break;

}

}

v.SetVariableValue(transferBuffer);

v.Dispose();

return true;

}

public void FinalizeScript()

{

}

}

VB

Imports System

Imports System.Windows.Forms

Imports Askom.AsixEvo.Scripting

Public Class CurveVB

Implements IScript

Public Function Initialize(ByVal aParameters() As String, ByVal aApplication _

As IApplication) As Boolean Implements IScript.Initialize

Dim v As IVariable = aApplication.GetVariable(aParameters(1), False)

Dim varSize As Integer = Convert.ToInt32(v.VariableAttribute("ElementsCount"))

Dim pointsCount As Integer = 0

Dim transferBuffer() As Integer = New Integer(varSize) {}

For Each point As TrendPatternPoint In _

aApplication.GetTrendPatternPoints(aParameters(0))

If pointsCount <= varSize - 2 Then

transferBuffer(pointsCount) = CInt(point.TimeStamp.TotalSeconds)

transferBuffer(pointsCount + 1) = CInt(point.Value)

pointsCount += 2

Else

If (pointsCount <= varSize) Then transferBuffer(pointsCount) = 0

Exit For

End If

Next point

v.SetVariableValue(transferBuffer)

v.Dispose()

Return True

End Function

Public Sub FinalizeScript() Implements IScript.FinalizeScript

End Sub

End Class

To define the size of the buffer available, the first operation performed within the script is the readout of the ElementsCount attribute of the target variable. It is assumed that the variable components are 32-bit integers. In addition, the transferBuffer array is created which size is compatible with the size of the process variable.

Next, the subsequent points of the trend pattern (loaded via the GetTrendPatternPoints method) are recorded in pairs (a time shift and point value) into the subsequent elements of the transferBuffer array. If the trend does not fill the entire array, a single zero value indicating the trend end is added.

The standard call to the SetVariableValue method terminates the script running.


2.9. Controlling the Alarm Status

Services of the object script model allow the application alarm system operation to be fully controlled. This applies both to monitoring alarm status and application detection of alarm events.


2.9.1. Readout of Active Alarm Status

The group of the IApplication interface methods provides access to the current state of the alarm system. The basic functions include: GetActiveAlarms returning the collection of the alarm IDs currently stored in the active alarm log; GetDefinedAlarms which allows accessing all the defined alarms; and GetAlarm returning a reference to the IAlarm interface. The properties and methods of this interface allow reading all data concerning a specific alarm - its definition and current status.

The presented example shows the method of creating a simple report in which, at the time of script execution, the basic information on all active alarms are recorded.

The script requires determining two parameters: the name of a domain and output file.

C#

using System;

using System.IO;

using System.Windows.Forms;

using Askom.AsixEvo.Scripting;

public class AlarmReport : IScript

{

public bool Initialize(string[] aParameters, IApplication aApplication)

{

try

{

StreamWriter sw = new StreamWriter

                                      (aParameters[1], false, System.Text.Encoding.UTF8);

foreach (string aid in aApplication.GetActiveAlarms(aParameters[0]))

{

IAlarm alarm = aApplication.GetAlarm(aid);

if (alarm.AlarmState.IsActive && !alarm.AlarmState.IsFinished)

{

String desc = String.Format

("{0:dd-MM-yyyy hh:mm:ss.fff} {1,10} {2,-40} {3}",

alarm.AlarmState.BeginTimeStamp, alarm.Id,

alarm.AlarmState.FormattedBeginText, alarm.AlarmState.BeginExprValue);

sw.WriteLine(desc);

}

}

sw.Close();

}

catch (Exception)

{

}

return true;

}

public void FinalizeScript()

{

}

}

VB

Imports System

Imports System.IO

Imports System.Windows.Forms

Imports Askom.AsixEvo.Scripting

Public Class AlarmReportVB

Implements IScript

Public Function Initialize(ByVal aParameters() As String, ByVal aApplication _

As IApplication) As Boolean Implements IScript.Initialize

Try

Dim sw As StreamWriter = New StreamWriter _

(aParameters(1), False, System.Text.Encoding.UTF8)

For Each aid As String In aApplication.GetActiveAlarms(aParameters(0))

Dim alarm As IAlarm = aApplication.GetAlarm(aid)

If alarm.AlarmState.IsActive And Not alarm.AlarmState.IsFinished Then

Dim desc As String = String.Format _

("{0:dd-MM-yyyy hh:mm:ss.fff} {1,10} {2,-40} {3}", _

alarm.AlarmState.BeginTimeStamp, alarm.Id, _

alarm.AlarmState.FormattedBeginText, alarm.AlarmState.BeginExprValue)

sw.WriteLine(desc)

End If

Next aid

sw.Close()

Catch a As Exception

End Try

Return True

End Function

Public Sub FinalizeScript() Implements IScript.FinalizeScript

End Sub

End Class

The GetActiveAlarms function returns the collection of IDs of all alarms belonging to the selected domain, present in the active alarm log at a given moment. Next, for each of these alarms, using GetAlarm function, the reference to the IAlarm object is loaded. Via this reference, all alarm data are loaded. Within the if statement it is checked whether the alarm is active. The AlarmState.IsActive test checks whether the alarm is present in the active alarm log. The second part of the test uses the AlarmState.IsFinished property to determine whether the alarm is terminated - in the active alarm log, the data about a recently terminated alarm can be stored over a certain period of time. After recognition that the alarm is definitely active, the selected information about the alarm is saved to a file.


2.9.2. Active Monitoring of Alarm Status

In addition to the periodic readout of the alarm state shown in the previous example, an active monitoring is also possible. In this variant, it is possible to react immediately to the alarm occurrence or to another change of its status. The monitoring function can be declared using the RegisterStateEvent method of the IAlarm interface. The example code can be found in the RegisterStateEvent method description. See: 3.3.2.3. RegisterStateEvent ).


2.9.3. Alarm Notification

The scripts can perform the full functionality of the alarm detection strategy. The example given in this section, performs such a strategy. Its operation is based on the cyclical readout of the text file in which the alarm text IDs separated by a semicolon are saved (via the external application controlling the state of the system). The presence of an ID in the file indicates that the alarm is active. The script is responsible for transferring information from the file to the application alarm system. The initial step is to define the "External" type alarm strategy and the alarm definition associated with this strategy. In the definition of each alarm, in the "Detection parameters" attribute, the ID which corresponds in the text file to this alarm should be specified.

The example script requires at its start the following three parameters to be specified: the text file name, the alarm domain name and the strategy name in the context of which the script will run. The script start should be set in the application schedule, using the Script action. The action should be run in the "once at the application initialization" mode.

C#

using System;

using System.IO;

using System.Windows.Forms;

using Askom.AsixEvo.Scripting;

using System.Collections.Generic;

public class AlarmStrat : IScript

{

IApplication application;

string alarmStateFile;

string domain;

string strategy;

List<IAlarm> myAlarms = new List<IAlarm>();

public bool Initialize(string[] aParameters, IApplication aApplication)

{

application = aApplication;

alarmStateFile = aParameters[0];

domain = aParameters[1];

strategy = aParameters[2];

foreach (string name in application.GetDefinedAlarms(domain))

{

IAlarm ia = application.GetAlarm(domain, name);

if (ia.Definition.Strategy == strategy)

myAlarms.Add(ia);

}

aApplication.RegisterTimeEvent(StrategyFun, TimeSpan.FromSeconds(10),

TimeSpan.FromSeconds(0));

return false;

}

public void FinalizeScript()

{

}

char[] separator = { ';' };

void StrategyFun()

{

if (application.GetAlarmDomainStationMode(domain)!=AlarmStationMode.ActiveController)

return;

try

{

StreamReader file = new StreamReader(alarmStateFile,System.Text.Encoding.Default);

List<string> content = new List<string>(file.ReadToEnd().Split(separator));

foreach (IAlarm alarm in myAlarms)

{

bool isOn = content.IndexOf(alarm.Definition.DetectionParameters) != -1;

if (isOn)

{

if (!alarm.AlarmState.IsActive || alarm.AlarmState.IsFinished)

{

alarm.Raise();

}

}

else

{

if (alarm.AlarmState.IsActive && !alarm.AlarmState.IsFinished)

{

alarm.Cancel();

}

}

}

file.Close();

}

catch (Exception e)

{

application.ReportMessage(EvoMessageType.Info, "Error in AlarmStrat: "+e.Message);

}

}

}

VB

Imports System

Imports System.IO

Imports System.Windows.Forms

Imports System.Collections.Generic

Imports Askom.AsixEvo.Scripting

Public Class AlarmStratVb

Implements IScript

Dim application As IApplication

Dim alarmStateFile As String

Dim domain As String

Dim strategy As String

Dim myAlarms As List(Of IAlarm) = New List(Of IAlarm)

Public Function Initialize(ByVal aParameters() As String, ByVal aApplication _

As IApplication) As Boolean Implements IScript.Initialize

application = aApplication

alarmStateFile = aParameters(0)

domain = aParameters(1)

strategy = aParameters(2)

Dim ia As IAlarm

For Each name As String In application.GetDefinedAlarms(domain)

ia = application.GetAlarm(domain, name)

If (ia.Definition.Strategy = strategy) Then

myAlarms.Add(ia)

End If

Next name

aApplication.RegisterTimeEvent(AddressOf StrategyFun, TimeSpan.FromSeconds(10),_

TimeSpan.FromSeconds(0))

Return False

End Function

Public Sub FinalizeScript() Implements IScript.FinalizeScript

End Sub

Dim separator() As Char = {";"}

Public Sub StrategyFun()

If application.GetAlarmDomainStationMode(domain) <> _

AlarmStationMode.ActiveController Then

Return

End If

Try

Dim file As StreamReader = New StreamReader(alarmStateFile, _

System.Text.Encoding.Default)

Dim content As List(Of String) = New List(Of String) _

(file.ReadToEnd().Split(separator))

For Each alarm As IAlarm In myAlarms

Dim isOn As Boolean = _

Not content.IndexOf(alarm.Definition.DetectionParameters) = -1

If isOn Then

If (Not alarm.AlarmState.IsActive) Or alarm.AlarmState.IsFinished Then

alarm.Raise()

End If

Else

If alarm.AlarmState.IsActive And (Not alarm.AlarmState.IsFinished) Then

alarm.Cancel()

End If

End If

Next alarm

file.Close()

Catch e As Exception

application.ReportMessage(EvoMessageType.Info, "Error in AlarmStrat: "+e.Message)

End Try

End Sub

End Class

Within the Initialize function, the list of all alarms belonging to the domain and alarm strategy indicated by the parameters, is created. The GetDefinedAlarms function returns all alarms belonging to the domain. Then, for each domain alarm, the reference to the IAlarm interface is loaded and via this interface it is checked whether the alarm belongs to the right strategy. When the configuration data are read out, the StrategyFun function is registered - this function will be executed every 10 seconds.

At the start, the StrategyFun function checks the domain operation mode. Alarms are detected only when the workstation is the domain active controller. Next, the text file is read out and the list of identifiers is parsed. For each alarm of the strategy, the current status is determined on the basis of data read out from the file. The same applies to the alarm status in the application. If incompatibility is detected, the alarm is reported with the Raise method or cancelled with the Cancel method. Both methods potentially allow reporting additional data related to an event. These data would be stored in the alarm log. It is also possible to specify explicitly the time of event - in the example script, the event time is identical to the time of execution of the Raise or Cancel functions.

The current alarm status detection is performed according to the description in the example concerning the alarm status readout.


2.10 Using the Context of Script Starting

One of the script starting method it to use the Script action associated with handling the visualization object event on a diagram. In such case, it is possible to check the starting context - this allows writing a script that adapts to its call context.

The starting context describes an object of the IContext interface that can be obtained by the readout of the ExecutionContext property of IApplication interface. The most useful property of the IContext object is MainVar property returning the main variable name of the object for which the script has been started.

C#

using System;

using System.Windows.Forms;

using Askom.AsixEvo.Scripting;

public class Context : IScript

{

public bool Initialize(string[] aParameters, IApplication aApplication)

{

string mainVar = aApplication.ExecutionContext.MainVariable;

if (!string.IsNullOrEmpty(mainVar))

{

IVariable v = aApplication.GetVariable(mainVar, false);

if (v != null)

{

try

{

if (v.VariableState.IsGood)

{

v.SetVariableValue((UInt32)v.VariableState.Value + 1);

}

}

catch (Exception e)

{

aApplication.ReportMessage(EvoMessageType.Error, e.Message);

}

finally

{

v.Dispose();

}

}

}

return true;

}

public void FinalizeScript()

{

}

}

VB

Imports System

Imports System.Windows.Forms

Imports Askom.AsixEvo.Scripting

Public Class ContextVB

Implements IScript

Public Function Initialize(ByVal aParameters() As String, ByVal aApplication As _

IApplication) As Boolean Implements IScript.Initialize

Dim mainVar As String

mainVar = aApplication.ExecutionContext.MainVariable

If Not String.IsNullOrEmpty(mainVar) Then

Dim v As IVariable

v = aApplication.GetVariable(mainVar, False)

If Not v Is Nothing Then

Try

If (v.VariableState.IsGood) Then

v.SetVariableValue(v.VariableState.Value + 1)

End If

Catch e As Exception

aApplication.ReportMessage(EvoMessageType.Error, e.Message)

Finally

v.Dispose()

End Try

End If

End If

Return True

End Function

Public Sub FinalizeScript() Implements IScript.FinalizeScript

End Sub

End Class

In the above example, the main variable name is loaded from the script starting context. Then, provided that the readout of the current value is successful, the variable value is incremented.

The alternative method of context script starting within the object event handling is a dynamic structure of the operator action contents and transferring context data in the script parameters.

Example:

^Script(Context,LocalProperty(ControlVar))

The above action starts the Context script with transferring, in the form of parameter, the controlled variable name of the object, in the context of which the action is executed.


2.11 Multilingual Scripts

If the scripts runs within the multilanguage application, using a texts compatible with the current application language becomes very important. In this type of scripts it is possible to use two mechanisms. It is possible to use a multilanguage pool of the application texts or to calculate the text correct form in the script code.

C#

using System;
using System.Windows.Forms;
using Askom.AsixEvo.Scripting;

public class LangMessage : IScript
{
IApplication application;
public bool Initialize(string[] aParameters, IApplication aApplication)
{
application = aApplication;
aApplication.ReportMessage(EvoMessageType.Info,

aApplication.ApplicationText("ScriptStartInfo"));
aApplication.ReportMessage(EvoMessageType.Info, StartMsg());
return true;
}

public void FinalizeScript()
{
}

string StartMsg()
{
switch (application.CurrentApplicationLanguage)
{
case "pl":
return "Skrypt uruchomiony";

case "en":
default:
return "Script started";
}
}
}

VB

Imports System
Imports System.Windows.Forms
Imports Askom.AsixEvo.Scripting

Public Class LangMessageVB
Implements IScript

Dim application As IApplication
Public Function Initialize(ByVal aParameters() As String, ByVal aApplication As _

IApplication) As Boolean Implements IScript.Initialize

application = aApplication
aApplication.ReportMessage(EvoMessageType.Info, _

aApplication.ApplicationText("ScriptStartInfo"))
aApplication.ReportMessage(EvoMessageType.Info, StartMsg())
Return True

End Function

Public Sub FinalizeScript() Implements IScript.FinalizeScript
End Sub

Function StartMsg() As String

Select Case application.CurrentApplicationLanguage

Case "pl"
Return "Skrypt uruchomiony"

Case "en"
Return "Script started"
Case Else
Return "Script started"

End Select

End Function

End Class

In the above code, in the first call of the ReportMessage method, a message contents is loaded from the Application text pool using the ApplicationText method. The "ScriptStartInfo" is the text identifier used in the Application text pool. The ApplicationText method returns the text version compatible with the current operation language.

In the second ReportMessage call, the message contents is determined by the StartMsg function. This function calculates the appropriate language version based on the current values of the ​​CurrentApplicationLanguage property of the IApplication interface.


2.12. Creating Window Interface

The Asix.Evo system scripts also allow creating custom windows for the interaction with the application user. Asix.Evo does not provide any specific mechanisms for creating the windows, however, the application designer can use all the means provided by the .NET programming platform.


2.12.1. Message Displaying

The simplest type of windows are message windows, alternatively extended with the possibility of asking the user to make simple Yes/No type decisions. The easiest way to achieve such functionality is to use the Show method of the System.Windows.Forms.MessageBox class.

C#

using System;
using System.Windows.Forms;
using Askom.AsixEvo.Scripting;

public class Message : IScript
{
public bool Initialize(string[] aParameters, IApplication aApplication)
{
if (aApplication.HasRole("SuperUser"))
{
DialogResult result = MessageBox.Show("Do you want to start the line? ?", "Start",

MessageBoxButtons.YesNo);
if (result == DialogResult.Yes)
{
IVariable v = aApplication.GetVariable("LineState", false);
v.SetVariableBits(1, 1);
v.Dispose();
}
}
else
MessageBox.Show("Your privileges are insufficient !", "Access denied");
return true;
}

public void FinalizeScript()
{

}
}

VB

Imports System
Imports System.Windows.Forms
Imports Askom.AsixEvo.Scripting

Public Class MessageVB
Implements IScript

Public Function Initialize(ByVal aParameters() As String, ByVal aApplication As _

IApplication) As Boolean Implements IScript.Initialize

If aApplication.HasRole("SuperUser") Then

Dim result As DialogResult
result = MessageBox.Show("Do you want to start the line ?", "Start", _

MessageBoxButtons.YesNo)
If result = DialogResult.Yes Then

Dim v As IVariable
v = aApplication.GetVariable("LineState", False)
v.SetVariableBits(1, 1)
v.Dispose()

End If

Else
MessageBox.Show("Your privileges are insufficient !", "Access denied")
End If

Return True

End Function

Public Sub FinalizeScript() Implements IScript.FinalizeScript

End Sub

End Class

The script checks whether the user is assigned to the SuperUser role. If yes, the message box asking whether the line is to be started is displayed. When the user confirms the operation, the LineState variable least significant bit is set to 1.


2.12.2. Windows Created within Script Contents

It is possible to application a dialogue window within a script contents. It is possible to create windows of any complexity, however, this technique works for not very big windows.

In the following example, the window consisting of two text edit fields and two buttons is created.

C#

using System;
using System.Windows.Forms;
using Askom.AsixEvo.Scripting;

public class FormBuilder : IScript
{
Form entryForm;
TextBox xPos, yPos;

public bool Initialize(string[] aParameters, IApplication aApplication)
{

IVariable varX, varY;

varX = aApplication.GetVariable(aParameters[0], true);
varY = aApplication.GetVariable(aParameters[1], true);

CreateForm();

xPos.Text = varX.VariableState.FormattedValue;
yPos.Text = varY.VariableState.FormattedValue;
DialogResult res = entryForm.ShowDialog();
if (res == DialogResult.OK)
{
Int32 newX, newY;
if (Int32.TryParse(xPos.Text, out newX) && Int32.TryParse(yPos.Text, out newY))
{
varX.SetVariableValue(newX);
varY.SetVariableValue(newY);
}
else
MessageBox.Show("Incorrect values");
}

varX.Dispose();
varX.Dispose();
return true;
}

public void FinalizeScript()
{
}

void CreateForm()
{
Label label1 = new Label();
label1.AutoSize = true;
label1.Location = new System.Drawing.Point(24, 29);
label1.Size = new System.Drawing.Size(54, 13);
label1.Text = "X Position";

xPos = new TextBox();
xPos.Location = new System.Drawing.Point(97, 26);
xPos.Size = new System.Drawing.Size(132, 20);

Label label2 = new Label();
label2.AutoSize = true;
label2.Location = new System.Drawing.Point(24, 68);
label2.Size = new System.Drawing.Size(54, 13);
label2.Text = "Y Position";

yPos = new System.Windows.Forms.TextBox();
yPos.Location = new System.Drawing.Point(97, 65);
yPos.Size = new System.Drawing.Size(132, 20);

Button buttonOk = new Button();
buttonOk.DialogResult = DialogResult.OK;
buttonOk.Location = new System.Drawing.Point(280, 20);
buttonOk.Size = new System.Drawing.Size(142, 30);
buttonOk.Text = "&OK";
buttonOk.UseVisualStyleBackColor = true;

Button buttonCancel = new Button();
buttonCancel.DialogResult = DialogResult.Cancel;
buttonCancel.Location = new System.Drawing.Point(280, 59);
buttonCancel.Size = new System.Drawing.Size(142, 30);
buttonCancel.Text = "&Cancel";
buttonCancel.UseVisualStyleBackColor = true;

entryForm = new Form();
entryForm.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
entryForm.AutoScaleMode = AutoScaleMode.Font;
entryForm.CancelButton = buttonCancel;
entryForm.ClientSize = new System.Drawing.Size(466, 103);
entryForm.Controls.Add(buttonCancel);
entryForm.Controls.Add(buttonOk);
entryForm.Controls.Add(yPos);
entryForm.Controls.Add(label2);
entryForm.Controls.Add(xPos);
entryForm.Controls.Add(label1);
entryForm.FormBorderStyle = FormBorderStyle.FixedSingle;
entryForm.MaximizeBox = false;
entryForm.MinimizeBox = false;
entryForm.StartPosition = FormStartPosition.CenterScreen;
entryForm.Text = "Coordinates";
entryForm.TopMost = true;
}
}

VB

Imports System
Imports System.Windows.Forms
Imports Askom.AsixEvo.Scripting

Public Class FormBuilderVB
Implements IScript

Dim entryForm As Form
Dim xPos, yPos As TextBox

Public Function Initialize(ByVal aParameters() As String, ByVal aApplication As _

IApplication) As Boolean Implements IScript.Initialize

Dim varX, varY As IVariable

varX = aApplication.GetVariable(aParameters(0), True)
varY = aApplication.GetVariable(aParameters(1), True)

CreateForm()

xPos.Text = varX.VariableState.FormattedValue
yPos.Text = varY.VariableState.FormattedValue
If (entryForm.ShowDialog() = DialogResult.OK) Then

Dim newX, newY As Int32
If (Int32.TryParse(xPos.Text, newX) And Int32.TryParse(yPos.Text, newY)) Then
varX.SetVariableValue(newX)
varY.SetVariableValue(newY)
Else
MessageBox.Show("Incorrect values")
End If

End If

varX.Dispose()
varX.Dispose()

Return True

End Function

Public Sub FinalizeScript() Implements IScript.FinalizeScript

End Sub

Sub CreateForm()

Dim label1 As Label
label1 = New Label()
label1.AutoSize = True
label1.Location = New System.Drawing.Point(24, 29)
label1.Size = New System.Drawing.Size(54, 13)
label1.Text = "X Position"

xPos = New TextBox()
xPos.Location = New System.Drawing.Point(97, 26)
xPos.Size = New System.Drawing.Size(132, 20)

Dim label2 As Label
label2 = New Label()
label2.AutoSize = True
label2.Location = New System.Drawing.Point(24, 68)
label2.Size = New System.Drawing.Size(54, 13)
label2.Text = "Y Position"

yPos = New System.Windows.Forms.TextBox()
yPos.Location = New System.Drawing.Point(97, 65)
yPos.Size = New System.Drawing.Size(132, 20)

Dim buttonOk As Button
buttonOk = New Button()
buttonOk.DialogResult = DialogResult.OK
buttonOk.Location = New System.Drawing.Point(280, 20)
buttonOk.Size = New System.Drawing.Size(142, 30)
buttonOk.Text = "&OK"
buttonOk.UseVisualStyleBackColor = True

Dim buttonCancel As Button
buttonCancel = New Button()
buttonCancel.DialogResult = DialogResult.Cancel
buttonCancel.Location = New System.Drawing.Point(280, 59)
buttonCancel.Size = New System.Drawing.Size(142, 30)
buttonCancel.Text = "&Cancel"
buttonCancel.UseVisualStyleBackColor = True

entryForm = New Form()
entryForm.AutoScaleDimensions = New System.Drawing.SizeF(6.0F, 13.0F)
entryForm.AutoScaleMode = AutoScaleMode.Font
entryForm.CancelButton = buttonCancel
entryForm.ClientSize = New System.Drawing.Size(466, 103)
entryForm.Controls.Add(buttonCancel)
entryForm.Controls.Add(buttonOk)
entryForm.Controls.Add(yPos)
entryForm.Controls.Add(label2)
entryForm.Controls.Add(xPos)
entryForm.Controls.Add(label1)
entryForm.FormBorderStyle = FormBorderStyle.FixedSingle
entryForm.MaximizeBox = False
entryForm.MinimizeBox = False
entryForm.StartPosition = FormStartPosition.CenterScreen
entryForm.Text = "Coordinates"
entryForm.TopMost = True

End Sub

End Class

The CreateForm function programs the dialogue window object. Before opening the window, the edit fields are set in accordance with the current variable values transmitted within the script call parameters. Then, the window is opened in the dialogue mode via the ShowDialog method of the window object. Returning to the script code is performed after closing the window. If the window was closed with the OK button, an attempt to convert the entered values into integers and sending the new values to the process variables is performed.


2.12.3. Using Built-in Libraries

The alternative of the direct dialogue window programming is to create windows in the external environment such as the VisualStudio, to compile them into DLL files, and then, to use in the Asix.Evo script only the call to the ready code.

In the following example, the library called EvoDialog.dll including the code of the EvoDialog class that inherits from System.Windows.Forms.Form, will be used. The EvoDialog class provides two properties used to set input values and one property in which, after closing the window, a diagram name will be saved.

C#

using System;

using System.Windows.Forms;

using Askom.AsixEvo.Scripting;

using EvoAddOns;

public class Dialog : IScript

{

public bool Initialize(string[] aParameters, IApplication aApplication)

{

IVariable varX, varY;

varX = aApplication.GetVariable(aParameters[0], true);

varY = aApplication.GetVariable(aParameters[1], true);

EvoDialog dialog = new EvoDialog();

dialog.XPos = varX.VariableState.FormattedValue;

dialog.YPos = varY.VariableState.FormattedValue;

if (dialog.ShowDialog() == DialogResult.OK)

{

if (!String.IsNullOrEmpty(dialog.Diagram))

aApplication.ExecuteAction(EvoMessageType.Info,

"OpenWindow(Main,P1," + dialog.Diagram + ",null)");

}

varX.Dispose();

varY.Dispose();

return true;

}

public void FinalizeScript()

{

}

}

VB

Imports System

Imports System.Windows.Forms

Imports Askom.AsixEvo.Scripting

Imports EvoAddOns

Public Class DialogVB

Implements IScript

Public Function Initialize(ByVal aParameters() As String, ByVal aApplication As _

IApplication) As Boolean Implements IScript.Initialize

Dim varX, varY As IVariable

varX = aApplication.GetVariable(aParameters(0), True)

varY = aApplication.GetVariable(aParameters(1), True)

Dim dialog As EvoDialog

dialog = New EvoDialog()

dialog.XPos = varX.VariableState.FormattedValue

dialog.YPos = varY.VariableState.FormattedValue

If dialog.ShowDialog() = DialogResult.OK Then

If Not String.IsNullOrEmpty(dialog.Diagram) Then

aApplication.ExecuteAction(EvoMessageType.Info, _

"OpenWindow(Main,P1," & dialog.Diagram & ",null)")

End If

End If

varX.Dispose()

varY.Dispose()

Return True

End Function

Public Sub FinalizeScript() Implements IScript.FinalizeScript

End Sub

End Class

In the code above the EvoDialog window object is created. Then, the Xpos and Ypos window properties are set in accordance with the current values of two variables of names transmitted in the script starting parameters. The dialogue window is opened using the ShowDialog function, and if the window with the DialogResult.OK status is closed, the operator action opening a diagram of the name transmitted in the Diagram property of the window, is constructed and executed.

For the correct execution of an example script, two additional conditions must be met:

  • the EvoDialog.dll file (alternatively along with the additional libraries) must be copied to the Addons subdirectory of the application definition directory.

  • In the References tab of the script edit panel, the reference to the EvoDialog.dll file should be added.

The described technique of extending the scrip functionality by adding libraries, can be also used to perform other tasks, not related to the user interface.


3.1. IApplication Interface

The IApplication interface is the basic mechanism of script interaction with the Asix.Evo application environment. The interface provides a variety of services. Some have just an informative meaning. Other are used to organise the script operation. The interface is also used to create the other objects that allow accessing the application data such as process variable values, or alarms statuses.

A reference to the object that implements the IApplication interface is transmitted into the script when the script Initialize function is called.


3.1.1.1. ApplicationAddonsDirectory

string ApplicationAddonsDirectory { get; }

ReadOnly Property ApplicationAddonsDirectory As String

The property returns a complete access path to the directory where all the files of application extensions of the application are located.


3.1.1.2. ApplicationDirectory

string ApplicationDirectory { get; }

ReadOnly Property ApplicationDirectory As String

This property returns a complete access path to the application definitional directory. If the script for running requires files with additional parameters, it is recommended to store them in the application definition directory.


3.1.1.3. ApplicationName

string ApplicationName { get; }

ReadOnly Property ApplicationName As String

This property returns the Application name defined in the workstation settings.


3.1.1.4. ApplicationWorkingDirectory

string ApplicationWorkingDirectory { get; }

ReadOnly Property ApplicationWorkingDirectory As String

This property returns a complete access path to the application working directory. If the script functioning aims to create and save an information to files, it is recommended to save them in the application working directory.


3.1.1.5. CurrentApplicationLanguage

tring CurrentApplicationLanguage { get; }

ReadOnly Property CurrentApplicationLanguage As String

This property returns the language name in which the application is currently running. The language names are two-letter abbreviations, e.g., pl for the Polish language, en for the English language.


3.1.1.6. CurrentStationName

string CurrentStationName { get; }

ReadOnly Property CurrentStationName As String

This property returns the workstation name in the context of which the Application is executed.


3.1.1.7. CurrentUserId

string CurrentUserId { get; }

ReadOnly Property CurrentUserId As String

This property returns the ID of the currently logged user.


3.1.1.8. CurrentUserName

string CurrentUserName { get; }

ReadOnly Property CurrentUserName As String

This property returns the name of the currently logged user.


3.1.1.9. CurrentUserRoles

string CurrentUserRoles { get; }

ReadOnly Property CurrentUserRoles As String

The property returns the names of all roles to which the currently logged user is assigned. The role names are returned in the form of a single text in which individual names are separated by commas. If only checking whether the user is assigned to a particular role is required, it is easier to use the HasRole function.


3.1.1.10 ProgramVersion

string ProgramVersion { get; }

ReadOnly Property ProgramVersion As String

This property returns the AsixEvo application version. The version number is returned in the form of a single text consisting of four numbers separated by dots.


3.1.1.11 ScriptName

string ScriptName { get; }

ReadOnly Property ScriptName As String

This property returns the name of script being run.


3.1.1.12 ExecutionContext

IContext ExecutionContext { get; }

ReadOnly Property ExecutionContext As IContext

This property returns a reference to the object implementing the IContext interface. This interface contains properties that define the context of the script call. The call context is particularly important for the interactive scripts started within the event handling of the visualization objects. On the basis of a context, it is possible to load e.g. the object main variable name.


3.1.2.1. ApplicationText

string ApplicationText(string aTextId);

Function ApplicationText (ByVal aTextId As String) As String

This function supports the multilingual applications. It returns a text from the application text pool. The text with the ID specified in the aTextId parameter in a language version compatible with the current application language, is returned.


3.1.2.2. CreateThread

Thread CreateThread(ThreadStart aThreadFunction);

Function CreateThread (ByVal aThreadFunction As System.Threading.ThreadStart) As System.Threading.Thread

This function creates a new thread for the script running. The aThreadFunction parameter specifies the function which will be executed within the new thread. The thread function must be compatible with the system ThreadStart delegate. The CreateThread function returns the system object of Thread class, through which the script running can be controlled.

It is recommended to create threads via the CreateThread function within the Asix.Evo scripts, instead of using the direct methods of the .NET platform.

Example:

  C#

void ThreadFnc()

{

//

// thread code

//

}

public bool Initialize(string[] aParameters, IApplication aApplication)
{

Thread t1 = aApplication.CreateThread(ThreadFnc);

t1.Start();

return false;
}

VB

Sub ThreadFun()

'

' kod wątku

'

End Sub

Public Function Initialize(ByVal aParameters() As String, ByVal aApplication As _

IApplication) As Boolean Implements IScript.Initialize

Dim t1 As System.Threading.Thread

t1 = aApplication.CreateThread(AddressOf ThreadFun)

t1.Start()

Return False

End Function

The ThreadFnc function constitutes a thread code. The CreateThread call creates a thread, and the Start function of the Thread object starts the thread.


3.1.2.3. ExecuteAction

bool ExecuteAction(string aAction);

Function ExecuteAction (ByVal aAction As String) As Boolean

The function starts the operator action specified by the aAction parameter. The function returns the false value if an error of the action execution occurred.

The ExecuteAction function extends the Asix.Evo script with a full set of operations implemented into the applications via the operator actions. However, it should be noted that some actions executed in the context of the resident script may have adverse effects. For example, executing the OpenWindow action at a random point of time may be unexpected to a user.


3.1.2.4. GetAlarm

IAlarm GetAlarm(string aAlarmName);

IAlarm GetAlarm(string aDomainName, string aAlarmName);

Function GetAlarm (ByVal aAlarmName As String) As IAlarm

Function GetAlarm (ByVal aDomain As String, ByVal aAlarmName As String) As IAlarm

This function returns a reference to the object implementing the IAlarm interface for the alarm of the ID specified by the aAlarmName parameter belonging to the domain called aDomain. The call version which does not specifies the domain name, relates to the application default domain (the first defined).

The IAlarm interface allows obtaining information on the alarm definition and its current status. It also allows controlling the alarm status: the alarm notification, termination and acknowledge.


3.1.2.5. GetAlarmDomainController

string[] GetAlarmDomainController(string aDomain);

Function GetAlarmDomainController (ByVal aDomain As String) As String()

This function returns the workstation name of the controller active in the alarm domain specified by the aDomain parameter. If the domain name is blank, the call relates to the application default domain (the first defined).


3.1.2.6. GetAlarmDomains

string[] GetAlarmDomains();

Function GetAlarmDomains () As String()

This function returns the array of all active alarm domain names defined in the application.


3.1.2.7. GetAlarmDomainStationMode

AlarmStationMode GetAlarmDomainStationName(string aDomain);

Function GetAlarmDomainStationName (ByVal aDomain As String) As AlarmStationMode

This function returns the current alarm system operation m in the alarm domain specified by the aDomain parameter. If the domain name is blank, the call relates to the application default domain (the first defined).

The AlarmStationMode enumerated type can have the following values: ActiveController, PasiveController, Terminal and Undetermined. The Undetermined mode is a transition mode, which can be returned in a transient states, e.g. when the domain is started.


3.1.2.8. GetActiveAlarms

string[] GetActiveAlarms(string aDomain);

Function GetActiveAlarms (ByVal aDomain As String) As String()

This function returns the array of IDs of all currently active alarms in the alarm domain, specified by the aDomain parameter. If the domain name is blank, the call relates to the application default domain (the first defined).


3.1.2.9. GetDefinedAlarms

string[] GetDefinedAlarms(string aDomain);

Function GetDefinedAlarms (ByVal aDomain As String) As String()

This function returns the array of IDs of all alarms defined in the alarm domain, specified by the aDomain parameter. If the domain name is blank, the call relates to the application default domain (the first defined).


3.1.2.10 GetTrendPatternPoints

TrendPatternPoint[] GetTrendPatternPoints(string aPatternName);

Function GetTrendPatternPoints(ByVal aPatternName As String) As TrendPatternPoint()

The function returns the array of points of the pattern trend which name is specified in the aPatternName parameter.

The function is used in the scripts responsible for transferring the pattern trend curve to a controller.


3.1.2.11 GetVariable

IVariable GetVariable(string aVarName, bool aRefresh);

Function GetVariable(ByVal aVarName As String, ByVal aRefresh As Boolean) As IVariable

This function returns a reference to the object implementing the IVariable interface for the variable with a name specified by the aVarName parameter. The aRefresh parameter specifies whether to start refreshing (a periodic readout) of variable value. The refreshing should be enabled for monitoring the changes of current variable values. If a script will only use the archival data or will only control the variable value, the refreshing enabling is not required.

The IVariable interface allows obtaining information on the variable definition and its current value. It also allows reading out the archival values, and provides methods of recording variable values.


3.1.2.12 GlobalProperty

object GlobalProperty(string aPropertyName);

Function GlobalProperty (ByVal aPropertyName As String) As Object

This function returns the definition of the application global property of a name specified by the aPropertyName parameter.


3.1.2.13 HasRole

bool HasRole(string aRoleName);

Function HasRole (ByVal aRoleName As String) As Boolean

This function returns the boolean value that determines whether the currently logged user is assigned to the role transmitted in the aRoleName parameter.


3.1.2.14 RegisterTimeEvent

IEventInfo RegisterTimeEvent(SimpleEvent aFunction, TimeSpan aPeriod, TimeSpan aAlign);

Function RegisterTimeEvent(ByVal aFunction As SimpleEvent, ByVal aPeriod As System.TimeSpan, ByVal aAlign As System.TimeSpan) As IEventInfo

This function is used to register a callback function that will be periodically called at a specific intervals. The aFunction parameter specifies the function to be executed periodically - this function must be compatible with the SimpleEvent delegate.

delegate void SimpleEvent();

Delegate Sub SimpleEvent()

The aPeriod parameter specifies the period of time during which the callback function will be performed. The aAlign parameter specifies the start time adjustment according to the beginning of a day. If this parameter is lower than zero (e.g. TimeSpan.FromSeconds (-1)), the adjustment is not executed. If the aAlign is equal to zero, the callback function will be called every aPeriod period, starting at 00:00 hour. If the aAlign is higher than zero, the callback function will be called every aPeriod period, starting at 00:00 + aAlign hour.

The RegisterTimeEvent function returns a value that can be used to unregister the callback function with the UnregisterEvent method.

Example:

C#

void CallbackFun()

{

//

// kod funkcji zwrotnej

//

}

public bool Initialize(string[] aParameters, IApplication aApplication)
{

aApplication.RegisterTimeEvent(CallbackFun, TimeSpan.FromHours(1),

TimeSpan.FromMinutes(15));

return false;
}

VB

Sub CallbackFun()

'

' kod funkcji zwrotnej

'

End Sub

Public Function Initialize(ByVal aParameters() As String, ByVal aApplication As _

IApplication) As Boolean Implements IScript.Initialize

aApplication.RegisterTimeEvent(AddressOf CallbackFun, TimeSpan.FromHours(1),_

TimeSpan.FromMinutes(15))

Return False

End Function

The CallbackFun function will be performed 15 minutes after every hour, i.e. at 0:15, 1:15, 2:15, etc.


3.1.2.15 ReportMessage

void ReportMessage(EvoMessageType aType, string aText);

Sub ReportMessage (ByVal aType As EvoMessageType, ByVal aText As String)

The function records a message of a contents specified in the aText parameter in the application log. The aType parameter specifies a message priority. The EvoMessageType enumerated type can have the following values: Exception, Error, Warning, Info, Trace. The Trace type messages are not displayed in the message window, they are only stored in a log file.

A reporting level for the script operation recorded in the message log is set by the script developer. However, it should be noted that all errors which occurred during the operation should be reported. In particular, it concerns the resident scripts.


3.1.2.16 Sleep

void Sleep(TimeSpan aTimeSpan);

Sub Sleep (ByVal aTimeSpan As System.TimeSpan)

This function suspends the script current thread running for a period of time specified in the aTimeSpan parameter. This function should be used wherever a waiting for an event occurrence or elapsing of a specific period of time is required. In no case, do not use the active loop which tests the conditions - it leads to a CPU overloading.

Example:

C#

aApplication.Sleep(TimeSpan.FromSeconds(5));

VB

aApplication.Sleep(TimeSpan.FromSeconds(5))

The call suspends the script for 5 seconds.


3.1.2.17 TerminateScript

void TerminateScript(bool aWithFinalize);

Sub TerminateScript (ByVal aWithFinalize As Boolean)

Calling the function terminates the script running. The aWithFinalize parameter determines, whether during the process of the script exiting, the script Finalize method should be executed.

The TerminateScript function is used only in special cases. The interactive scripts (one-time) are usually terminated by exiting the Initialize function with the true return value. The resident scripts are terminated automatically, along with the application closing.


3.1.2.18 UnregisterEvent

void UnregisterEvent(IEventInfo aCallbackInfo);

Sub UnregisterEvent(ByVal aCallbackInfo As IEventInfo)

Unregistering the function started according to a time schedule, which was previously registered using the RegisterTimeEvent function. The value returned at the time of function recording, should be transmitted as the aCallbackInfo parameter.


3.2. IContext Interface

The IContext interface features properties that define the context of script call. The call context is particularly important for the interactive scripts started within the event handling of the visualization objects. The interface allows linking the script to its starting method.

The reference to the IContext interface can be obtained by the readout of the ExecutionContext property of the IApplication interface.


3.2.1.1. Diagram

string Diagram { get; }

ReadOnly Property Diagram As String

This property returns the diagram name in the context of which the script was executed.


3.2.1.2. DiagramObject

string DiagramObject { get; }

ReadOnly Property DiagramObject As String

This property returns the visualization object name, in the context of which the script was executed.


3.2.1.3. IsWebBrowser

bool IsWebBrowser { get; }

ReadOnly Property IsWebBrowser As Boolean

This property returns information on whether the application is running in a browser environment.


3.2.1.4. MainVariable

string MainVariable { get; }

ReadOnly Property MainVariable As String

This property returns the main variable name of the visualization object, in the context of which the script has been executed.


3.2.1.5. ScriptStartTime

     DateTime ScriptStartTime { get; }

ReadOnly Property ScriptStartTime As Date

This property returns the point of time at which the script has been executed.


3.2.1.6. WebServerAddress

string WebServerAddress { get; }

ReadOnly Property WebServerAddress As String

This property returns the address of the WWW server from which the browser application was loaded.


3.3. IVariable Interface

The IVariable interface allows obtaining information concerning the variable definition and its current value, a readout of archival values, active monitoring of the current value changes and sharing a variable value recording method.

The reference to the IVariable interface for the selected alarm variable can be obtained by calling the GetVariable from the IApplication interface.


3.3.1.1. Name

string Name { get; }

ReadOnly Property Name As String

This property returns the name of process variable controlled by a reference to the IAlarm interface.


3.3.1.2. IsRefreshed

bool IsRefreshed { get; }

ReadOnly Property IsRefreshed As Boolean

This property returns the information whether a cycle refreshing of the variable is performed. The refresh mode is declared at the time of the IVariable interface creation using the GetVariable function of the IApplication interface.


3.3.1.3. VariableState

VariableState VariableState { get; }

ReadOnly Property VariableState As VariableState

This property returns the object of the VariableState class, from which a current value and status of process variable can be read out. A variable value is loaded from the last refreshing of variable. The refreshing period is specified in the definition of process variable.


3.3.2.1. OrderArcData

IArcQueryResult OrderArcData(ArcQuery aQuery);

Function OrderArcData (ByVal aQuery As ArcQuery) As IArcQueryResult

This function is used to read out an archival data of process variable. The ArcQuery class object transmitted as the aQuery parameter specifies the readout parameters, in particular, the period of time and aggregation method. The OrderArcData function only initiates the historical data readout process. The returned object of the IArcQueryResult interface is used to control the process of data collection and the process of calculated data readout.

Example:

C#

public bool Initialize(string[] aParameters, IApplication aApplication)

{

IVariable iv = aApplication.GetVariable("A004", false);

IArcQueryResult qr = iv.OrderArcData(new ArcQuery(DateTime.Today, DateTime.Now,

"average", TimeSpan.FromMinutes(15)));

if (qr.ResultStatus == ArcResultStatus.Processing)

qr.Wait();

if (qr.ResultStatus == ArcResultStatus.Error)

aApplication.ReportMessage(EvoMessageType.Error, "OrderArcData error: " +

qr.ErrorDescription);

else

{

foreach (ArcVariableState v in qr.Values)

aApplication.ReportMessage(EvoMessageType.Info, v.TimeStamp.ToString() +

": " + v.Value.ToString());

}

return true;

}

VB

Public Function Initialize(ByVal aParameters() As String, ByVal aApplication As _

IApplication) As Boolean Implements IScript.Initialize

Dim iv As IVariable

iv = aApplication.GetVariable("A004", False)

Dim qr As IArcQueryResult

qr = iv.OrderArcData(New ArcQuery(Date.Today, Date.Now, _

"average", TimeSpan.FromMinutes(15)))

If (qr.ResultStatus = ArcResultStatus.Processing)

Qr.Wait()

End If

If (qr.ResultStatus = ArcResultStatus.Error)

aApplication.ReportMessage(EvoMessageType.Error, _

"OrderArcData error: " + qr.ErrorDescription)

Else

For Each v As ArcVariableState In qr.Values

aApplication.ReportMessage(EvoMessageType.Error, _

v.TimeStamp.ToString() + ": " + v.Value.ToString())

Next v

End If

Return True

End Function

The ArcQuery class object transmitted in the call of the OrderArcData method reads out the 15-minute average values from the period since the beginning of a day until the current moment. Pending for the operation termination, by calling the Wait function of the IArcQueryResult object, returned as a result of the OrderArcData method execution, is started after a readout process initialization. If the readout was completed successfully, all archival values returned through the Values property of the IArcQueryResult class object are recorded to the message log.


3.3.2.2. Read

VariableState Read();

 Function Read () As VariableState

This function returns the VariableState class object from which the current value and status of process variable can be read out. This function forces a variable real readout; a variable value relates to the moment at which the function was executed.

The function execution time depends on the time of variable value readout from a data source.


3.3.2.3. RegisterStateEvent

void RegisterStateEvent(VariableEvent aFunction);

Sub RegisterStateEvent(ByVal aFunction As VariableEvent)

This function is used to register a callback function which will be called whenever a variable value, status, or controlled variable time are changed. The aFunction parameter specifies the function which monitors a variable state - it must be compatible with the SimpleEvent delegate.

delegate void VariableEvent(string aVariableName, VariableState aVariableState);

Delegate Sub VariableEvent(ByVal aVariableName As String, ByVal aVariableState As VariableState)

When the monitoring function is called, two parameters are transmitted into it. The aVariableName parameter specifies the name of variable. It is possible to link the same monitoring function to many variables, and with the aVariableName parameter it can be distinguished to which variable the call applies. The aVariableState parameter forwards the object from which a current variable state can be read out.

For the correct operation of the monitoring function, enabling a variable refreshing when creating an object of the IVariable interface is required. The monitoring function can be unregistered using the UnegisterStateEvent method.

Example:

C#

IApplication application;

void ValueFun(string aVariableName, VariableState aVariableState)

{

// kod funkcji zwrotnej

application.ReportMessage(EvoMessageType.Info, aVariableName + " = " +

aVariableState.FormattedValue);

}

public bool Initialize(string[] aParameters, IApplication aApplication)
{

application = aApplication;

IVariable iv = aApplication.GetVariable("varTest", true);

iv.RegisterStateEvent(ValueFun);

return false;
}

VB

Dim application As IApplication

Sub ValueFun(aVariableName As String, aVariableState As VariableState)

' kod funkcji zwrotnej

application.ReportMessage(EvoMessageType.Info, aVariableName & _

" = " & aVariableState.FormattedValue)

End Sub

Public Function Initialize(ByVal aParameters() As String, ByVal aApplication As _

IApplication) As Boolean Implements Initialize

application = aApplication

Dim iv As IVariable

iv = application.GetVariable("varTest", True)

iv.RegisterStateEvent(AddressOf ValueFun)

Return False

End Function

The above code creates the IVariable object for the varTest variable with a variable refreshing enabled. Then, the ValueFun monitoring function is registered, which whenever a variable state is changed records an information consisting of a variable name and its current value in the message log.


3.3.2.4. SetVariableBits

bool SetVariableBits(long aValue, long aMask);

bool SetVariableValue(long aValue, long aMask, StatusOpc aStatus);

Function SetVariableBits(ByVal aValue As Long, ByVal aMask As Long) As Boolean

Function SetVariableBits(ByVal aValue As Long, ByVal aMask As Long, ByVal aStatus As Askom.Ascent.StatusOpc) As Boolean

This function sets the process variable to the value specified in the aValue parameter with an additional masking of the bits changed by the aMask parameter. In the first phase of the execution, the current variable value is read out, and then bits to which in the aMask mask the value of 1 corresponds are changed according to the values in the aValue parameter.

The call version with the aStatus parameter additionally sets a new variable status. Versions without the aStatus parameter always set the status to StatusOpc.Good.

In a case of failure, the function returns the false value. Since the function is executed asynchronously, the correctness test only applies to preconditions compliance. In a case of a communication error occurrence, the error will be reported in the message panel.


3.3.2.5. SetVariableValue

bool SetVariableValue(object aValue);

bool SetVariableValue(object aValue, StatusOpc aStatus);

Function SetVariableValue(ByVal aValue As Object) As Boolean

Function SetVariableValue(ByVal aValue As Object, ByVal aStatus As Askom.Ascent.StatusOpc) As Boolean

This function sets the process variable to the value specified in the AValue parameter.

The call version with the aStatus parameter additionally sets a new variable status. Versions without the aStatus parameter always set the status to StatusOpc.Good.

In a case of failure, the function returns the false value. Since the function is executed asynchronously, the correctness test only applies to preconditions compliance. In a case of a communication error occurrence, the error will be reported in the message panel.


3.3.2.6. UnregisterStateEvent

void UnregisterStateEvent();

Sub UnregisterStateEvent()

Unregistering the monitoring function of a variable value, which was previously registered using the RegisterStateEvent function.


3.3.2.7. VariableAttribute

object VariableAttribute(string aAttributeName);

Function VariableAttribute (ByVal aAttributeName As String) As Object

This function returns the attribute definition for a process variable of a name specified with the aAttributeName parameter.


3.4. VariableState Class

The VariableState class object allows reading the current value of process variable, its status and timestamp. The VariableState class objects are created through the IVariable interface using the VariableState property or the Read function. They are also provided as the parameter of the variable value change monitoring function, registered by the RegisterStateEvent function of the IVariable interface.


3.4.1.1. FormattedValue

string FormattedValue { get; }

ReadOnly Property FormattedValue As String

This property returns the text value of the process variable created based on the format defined in the variable definition database.


3.4.1.2. IsBad

bool IsBad { get; }

ReadOnly Property IsBad As Boolean

This property determines whether a variable value status is incorrect.


3.4.1.3. IsGood

bool IsGood { get; }

ReadOnly Property IsGood As Boolean

The property determines whether a variable value status is correct.


3.4.1.4. IsUncertain

bool IsUncertain { get; }

ReadOnly Property IsUncertain As Boolean

The property determines whether a variable value status is uncertain.


3.4.1.5. RawValue

object RawValue { get; }

ReadOnly Property RawValue As Object

The property returns a raw value of process variable. This is a variable original value read out by a driver of a communication channel, before applying the conversion function defined in the variable database in the ReadConvertingFunction attribute.

NOTE: if the Asix6 communication channel is used, the property value is pre-calculated by the Asmen communication module based on the ConversionFunction attribute.


3.4.1.6. Status

public StatusOpc Status { get; }

ReadOnly Property Status As Askom.Ascent.StatusOpc

This property returns the detailed status of process variable value ​​in the convention of the OPC communication interface. In the case of simple tests of variable status, it is recommended to use the IsGood, IsBad and IsUncertain properties.


3.4.1.7. TimeStamp

DateTime TimeStamp { get; }

ReadOnly Property TimeStamp As Date

This property returns the readout time of variable value.


3.4.1.8. Value

object Value { get; }

ReadOnly Property Value As Object

This property returns a process variable value after completing all the calculations resulting from the variable definition in the variable database definition.


3.5. ArcQuery Class

The ArcQuery class is used to specify the parameters for a process variable archive values readout. The ArcQuery objects are used in the OrderArcData method calls of the IVariable interface.


3.5.1. Constructor

ArcQuery (DateTime aStartTime, DateTime aEndTime)

Public Sub New(ByVal aStartTime As Date, ByVal aEndTime As Date)

The constructor creates an object of parameters for the query relating to a raw data readout. The aStartTime and aEndTime parameters designate respectively the beginning and the end of the period of time from which the data should be read.

ArcQuery ( DateTime aStartTime, DateTime aEndTime, string aAggregate, TimeSpan aAggregateInterval)

Public Sub New(ByVal aStartTime As Date, ByVal aEndTime As Date, ByVal aAggregate As String, ByVal aAggregateInterval As System.TimeSpan)

The constructor creates an object of parameters for the query relating to an aggregate data readout. The aStartTime and aEndTime parameters designate respectively the beginning and the end of the period of time from which the data should be read. The aAggregate parameter specifies the name of the used aggregate, and the aAggregateInterva parameter specifies its calculation period.

See also

Asix.Evo_Types_of_Archival_Data_Aggregates (PDF/CHM)


3.5.2.1. Aggregate

string Aggregate { get; }

ReadOnly Property Aggregate As String

This property returns the aggregate name used in the query on archival data.


3.5.2.2. AggregateInterval

TimeSpan TimeStamp { get; }

ReadOnly Property AggregateInterval As System.TimeSpan

This property returns the aggregate calculation period used in the query on archival data.


3.5.2.3. EndTime

DateTime EndTime { get; }

ReadOnly Property EndTime As Date

This property returns the end of the period of time from which archival data are to be read.


3.5.2.4. ProcessedDataQuery

bool ProcessedDataQuery { get; }

ReadOnly Property ProcessedDataQuery As Boolean

This property returns the information on the type of archival data to which the query relates. The true value indicates on an aggregated data readout, and the false value indicates on a raw data readout.


3.5.2.5. StartTime

DateTime StartTime { get; }

ReadOnly Property StartTime As Date

This property returns the beginning of the period of time, from which archival data are to be read out.


3.6. IArcQueryResult Interface

The IArcQueryResult interface is used to control the execution of archival data readout operation initiated by the OrderArcData method of the IVariable interface. The properties and methods of the interface allow checking whether, and how the operation was completed and provide the read out values.


3.6.1.1. ErrorDescription

string ErrorDescription { get; }

ReadOnly Property ErrorDescription As String

This property returns the text describing an archival data readout error (when the ResultStatus property is equal to ArcResultStatus.Error).


3.6.1.2. Query

ArcQuery Query { get; }

ReadOnly Property Query As ArcQuery

This property returns the ArcQuery class object from which the archival data readout parameters can be read, used in the OrderArcData function.


3.6.1.3. ResultStatus

ArcResultStatus ResultStatus { get; }

ReadOnly Property ResultStatus As ArcResultStatus

This property returns the current progress for the historical data reading operation. The enumeration type of ArcResultStatus may have the following values:

  • Processing - the data reading operation is in progress

  • Ready - the data reading operation has been completed successfully

  • Error - the data reading operation has been completed with an error


3.6.1.4. Values

ArcVariableState[ ] Values { get; }

ReadOnly Property ArcVariableState As ArcVariableState( )

This property returns the historical trend points array, which is obtained by executing the OrderArcData function.


3.6.1.5. VariableName

string VariableName { get; }

ReadOnly Property VariableName As String

This property returns the name of the variable for which the historical data are read.


3.6.2.1. CancelQuery

void CancelQuery( );

Sub CancelQuery ( )

The CancelQuery method allows to stop the historical data reading operation in progress.


3.6.2.2. RegisterQueryResultEvent

void RegisterQueryResultEvent(ArcQueryResultEvent aFunction);

Sub RegisterQueryResultEvent(ByVal aFunction As ArcQueryResultEvent)

This function is used to register the callback function to be called when the historical data reading operation is completed. The aFunction parameter specifies the callback function - it must be compatible with the ArcQueryResultEvent delegate.

delegate void ArcQueryResultEvent(IArcQueryResult aQueryResult);

Delegate Sub ArcQueryResultEvent(ByVal aQueryResult As IArcQueryResult)

The reference to the IArcQueryResult interface is transferred through the aQueryResult parameter to the callback function which was performed in the context of this interface.

The function of waiting for the completion of the reading can be unregistered by using the UnregisterQueryResultEvent method.

Example:

C#

IApplication application;

void ArcQueryFun(IArcQueryResult aQueryResult)

{

if (aQueryResult.ResultStatus == ArcResultStatus.Error)

application.ReportMessage(EvoMessageType.Error, "OrderArcData error: " +

aQueryResult.ErrorDescription);

else

{

foreach (ArcVariableState v in aQueryResult.Values)

application.ReportMessage(EvoMessageType.Error, v.TimeStamp.ToString() +

": " + v.Value.ToString());

}

application.TerminateScript(true);

}

public bool Initialize(string[] aParameters, IApplication aApplication)

{

application = aApplication;

IVariable iv = aApplication.GetVariable("A004", false);

IArcQueryResult qr = iv.OrderArcData(new ArcQuery(DateTime.Today,

DateTime.Now,"average",TimeSpan.FromMinutes(15)));

if (qr.ResultStatus == ArcResultStatus.Error)

aApplication.ReportMessage(EvoMessageType.Error, "OrderArcData error: " +

qr.ErrorDescription);

else

qr.RegisterQueryResultEvent(ArcQueryFun);

return false;

}

VB

Dim application As IApplication

Sub QueryArcFun(aQueryResult As IArcQueryResult)

If (aQueryResult.ResultStatus = ArcResultStatus.Error)

application.ReportMessage(EvoMessageType.Error, _

"OrderArcData error: " + aQueryResult.ErrorDescription)

Else

For Each v As ArcVariableState In aQueryResult.Values

application.ReportMessage(EvoMessageType.Error, _

v.TimeStamp.ToString() + ": " + v.Value.ToString())

Next v

End If

application.TerminateScript(True)

End Sub

Public Function Initialize(ByVal aParameters() As String, ByVal aApplication As _

IApplication) As Boolean Implements IScript.Initialize

application = aApplication

Dim iv As IVariable

iv = aApplication.GetVariable("A004", False)

Dim qr As IArcQueryResult

qr = iv.OrderArcData(New ArcQuery(Date.Today, Date.Now, _

"average", TimeSpan.FromMinutes(15)))

If (qr.ResultStatus = ArcResultStatus.Error)

aApplication.ReportMessage(EvoMessageType.Error, _

"OrderArcData error: " + qr.ErrorDescription)

Else

qr.RegisterQueryResultEvent(AddressOf QueryArcFun)

End If

Return False

End Function

The ArcQuery class object transmitted in the call of the OrderArcData method reads out the 15-minute average values from the period since the beginning of a day until the current moment. If the initiation of reading operation is successful, the ArcQueryFun function will be registered and executed at the operation completion. The record to the message log is done within the ArcQueryFun callback function for all the historical values that have been returned by the Values property of object of IArcQueryResult class transferred by the function call. Then, the script running is completed.


3.6.2.3. UnregisterQueryResultEvent

void UnregisterQueryResultEvent();

Sub UnregisterQueryResultEvent()

Unregistering the function being in progress, which was previously registered using the RegisterQueryResultEvent function.


3.6.2.4. Wait

bool Wait();

Function Wait() As Boolean

This function suspends running of the script until the historical data read operation is completed. This function is provided with a 5-minute waiting time limit. If the data is not read within this time, the function returns false.

An alternative to the Wait function is to use the Sleep function of the IApplication interface combined with the QueryResult status monitoring.


3.7. ArcVariableState Class

The object of ArcVariableState class stores information on the single value of historical process variable. The historical values array which is returned as the result of a query for the historical trend of variable may be obtained using the Values property of the IArcQueryResult interface.


3.7.1.1. IsBad

bool IsBad { get; }

ReadOnly Property IsBad As Boolean

This property determines whether a variable value status is incorrect.


3.7.1.2. IsGood

bool IsGood { get; }

ReadOnly Property IsGood As Boolean

The property determines whether a variable value status is correct.


3.7.1.3. IsUncertain

bool IsUncertain { get; }

ReadOnly Property IsUncertain As Boolean

The property determines whether a variable value status is uncertain.


3.7.1.4. Status

public StatusOpc Status { get; }

ReadOnly Property Status As Askom.Ascent.StatusOpc

This property returns the detailed status of process variable value in the convention of the OPC communication interface. In the case of simple tests of variable status, it is recommended to use the IsGood, IsBad and IsUncertain properties.


3.7.1.5. TimeStamp

DateTime TimeStamp { get; }

ReadOnly Property TimeStamp As Date

This property returns the time stamp of the historical value.


3.7.1.6. Value

object Value { get; }

ReadOnly Property Value As Object

This property returns the historical value of the process variable registered at the time specified by the TiemStamp property.


3.8. IAlarm Interface

The IAlarm interface allows you to obtain information concerning the definition of alarm and its current status. It also allows controlling the alarm status: the alarm notification, termination and acknowledge.

The reference to the IAlarm interface for the selected alarm can be obtained by calling the GetAlarm function from the IApplication interface.


3.8.1.1. AlarmState

AlarmState AlarmState { get; }

ReadOnly Property AlarmState As AlarmState

This property returns an object of AlarmState class from which the information regarding the current state of the alarm monitored via the reference to the IAlarm interface can be read out. If the active alarm log contains more than one event, the latest event status is returned.


3.8.1.2. Definition

AlarmProperties Definition { get; }

ReadOnly Property Definition As AlarmProperties

This property returns an object of AlarmProperties class from which the information regarding the definition of the alarm monitored via the reference to the IAlarm interface can be read out.


3.8.1.3. Domain

string Domain { get; }

ReadOnly Property Domain As String

This property returns an alarm domain name which includes the alarm monitored via the reference to the IAlarm interface.


3.8.1.4. Id

string Id { get; }

ReadOnly Property Id As String

This property returns the ID of the alarm monitored via reference to the IAlarm interface.


3.8.2.1. Accept

bool Accept();

Function Accept() As Boolean

This method is used to acknowledge the alarm. It acts the same way as the alarm acknowledgement done by the operator using the alarm table. This function returns the initial execution status. A value of true means that the operation has been accepted for execution. Acknowledgement can not be completed due to failure in meeting conditions checked in later phases of the operation execution, such as lack of workstation permissions for acknowledge of the alarms of the domain.


3.8.2.2. Cancel

bool Cancel(params object[ ] aParameters);

bool Cancel(DateTime aEndTime, params object[ ] aParameters);

Function Cancel(ByVal ParamArray aParameters( ) As Object) As Boolean

Function Cancel(ByVal aEndTime As Date , ByVal ParamArray aParameters( ) As Object) As Boolean

This method allows reporting the alarm event termination. An optional aParameters parameter table is used to provide additional data related with the event. The significance of these data is entirely up to application designer. The call made using the aEndTime parameter allows explicit specification of the event time. If the call does not include the aEndTime parameter the event time is automatically set at the current moment. The method can be performed only for alarms that belong to an external alarm diagnosis strategy.

This function returns the initial execution status. A value of true means that the operation has been accepted for execution. However, the declaration may be ignored because of the failure in meeting conditions checked in later phases of the operation execution, e.g. the workstation is not an active domain controller and the normal external strategy (not global) has been used.


3.8.2.3. Raise

bool Raise(params object[ ] aParameters);

bool Raise(DateTime aStartTime, params object[ ] aParameters);

Function Raise(ByVal ParamArray aParameters( ) As Object) As Boolean

Function Raise(ByVal aStartTime As Date , ByVal ParamArray aParameters( ) As Object) As Boolean

This method allows reporting the alarm event beginning. An optional aParameters parameter table is used to provide additional data related with the event. The significance of these data is entirely up to application designer. The call made using the aStartTime parameter allows explicit specification of the event time. If the call does not include the parameter the event time is automatically set at the current moment. The method can be performed only for alarms that belong to an external alarm diagnosis strategy.

This function returns the initial execution status. A value of true means that the operation has been accepted for execution. However, the declaration may be ignored because of the failure in meeting conditions checked in later phases of the operation execution, e.g. the workstation is not an active domain controller and the normal external strategy (not global) has been used.


3.8.2.4. RegisterStateEvent

void RegisterStateEvent(AlarmEvent aFunction);

Sub RegisterStateEvent(ByVal aFunction As AlarmEvent)

This function is used to register the callback function to be called on every change of the controlled alarm state. This applies to both alarm beginning and termination events as well as status changes caused by the operator actions, such as the alarm acknowledgement.

The aFunction parameter specifies the alarm monitoring function - it must be compatible with the AlarmEvent delegate.

delegate void AlarmEvent(string aDomain, string aAlarm, AlarmState aAlarmState, AlarmEventType aEventType);

Delegate Sub AlarmEvent(ByVal aDomain As String, ByVal aAlarm As String, ByVal aAlarmState As AlarmState ,ByVal aEventType As AlarmEventType)

When the monitoring function is called the three parameters are transmitted to it. The aDomain and aAlarm parameters specify correspondingly the domain name and Alarm ID, which is concerned by the callback function call. The aAlarmState parameter forwards the object from which the current alarm state may be readout. The AEventType parameter specifies the type of event. The AlarmEventType enumeration type takes the following values: AlarmBegin (detection of the alarm beginning), AlarmEnd (detection of the alarm end), AlarmManagement (change of state resulting from the operator's actions, such as the alarm acknowledgement), DomainStart(activating the domain), DomainStop(stopping the domain).

The monitoring function can be unregistered using the UnegisterStateEvent method.

Example:

C#

IApplication application;

void AlarmFun(string aDomain, string aAlarm, AlarmState aAlarmState,

AlarmEventType aEventType)

{

// kod funkcji zwrotnej

if (aEventType == AlarmEventType.AlarmBegin)

application.ReportMessage(EvoMessageType.Info, aAlarm + ": alarm rozpoczęty");

}

public bool Initialize(string[] aParameters, IApplication aApplication)

{

application = aApplication;

IAlarm ia = application.GetAlarm("Blok1","DemoB1");

ia.RegisterStateEvent(AlarmFun);

return false;

}

VB

Dim application As IApplication

Sub AlarmFun(aDomain As String, aName As String, aAlarmState As AlarmState, aEventType As AlarmEventType)

' kod funkcji zwrotnej

If aEventType = AlarmEventType.AlarmBegin Then

application.ReportMessage(EvoMessageType.Info, aName & ": alarm rozpoczęty")

End If

End Sub

Public Function Initialize(ByVal aParameters() As String, ByVal aApplication As _

IApplication) As Boolean Implements IScript.Initialize

application = aApplication

Dim ia As IAlarm

ia = application.GetAlarm("Blok1", "DemoB1")

ia.RegisterStateEvent(AddressOf AlarmFun)

Return False

End Function

The above code creates the IAlarm object for the DemoB1 alarm from the Blok1 domain. Then, the AlarmFun monitoring function is recorded, which checks the type of event and records the information on alarm beginning events in the message log every time the alarm state is changed.


3.8.2.5. UnregisterStateEvent

void UnregisterStateEvent();

Sub UnregisterStateEvent()

Unregistering the alarm state monitoring function, which was previously registered using the RegisterStateEventfunction.


3.9. AlarmState Object

The AlarmState object stores information about the current alarm state. The AlarmState objects can be obtained via the AlarmState property of the IAlarm interface. They are also provided as a parameter of the alarm state monitoring function, which is registered using the RegisterStateEvent function of the IAlarm interface.

Access to the alarm states is provided based on the active alarm log - this means that the details of the alarm status are available only if the event relating to this alarm exists in the active alarm log. When the data are not available, the IsActive property object is false.


3.9.1.1. AcceptanceOperatorId

string AcceptanceOperatorId { get; }

ReadOnly Property AcceptanceOperatorId As String

This property returns the ID of the user who acknowledged the alarm event.


3.9.1.2. AcceptanceStationName

string AcceptanceStationName { get; }

ReadOnly Property AcceptanceStationName As String

This property returns the name of workstation on which the alarm event was acknowledged.


3.9.1.3. AcceptanceTimeStamp

DateTime AcceptanceTimeStamp { get; }

ReadOnly Property AcceptanceTimeStamp As Date

This property returns the time the alarm event was acknowledged by the user.


3.9.1.4. BeginDetectionTimeStamp

DateTime BeginDetectionTimeStamp { get; }

ReadOnly Property BeginDetectionTimeStamp As Date

This property returns the time at which the beginning of the alarm event was detected.


3.9.1.5. BeginExprValue

object BeginExprValue { get; }

ReadOnly Property BeginExprValue As Object

This property returns the value of the expression associated with the alarm, calculated at the alarm beginning detection.


3.9.1.6. BeginTimeStamp

DateTime BeginTimeStamp { get; }

ReadOnly Property BeginTimeStamp As Date

This property returns the time of the alarm event beginning


3.9.1.7. EndDetectionTimeStamp

DateTime EndDetectionTimeStamp { get; }

ReadOnly Property EndDetectionTimeStamp As Date

This property returns the time at which the end of the alarm event was detected.


3.9.1.8. EndExprValue

object EndExprValue { get; }

ReadOnly Property EndExprValue As Object

This property returns the value of the expression associated with the alarm, calculated at the alarm end detection.


3.9.1.9. EndTimeStamp

DateTime EndTimeStamp { get; }

ReadOnly Property EndTimeStamp As Date

This property returns the time of the alarm event end.


3.9.1.10 FormattedBeginText

string FormattedBeginText { get; }

ReadOnly Property FormattedBeginText As String

This property returns the text describing the beginning of the alarm event. All dynamically created inserts associated with the call parameters are generated within the text returned.


3.9.1.11 FormattedEndText

string FormattedEndText { get; }

ReadOnly Property FormattedEndText As String

This property returns the text describing the end of the alarm event. All dynamically created inserts associated with the call parameters are generated within the text returned.


3.9.1.12 IsAccepted

bool IsAccepted { get; }

ReadOnly Property IsAccepted As Boolean

This property determines whether the alarm event has been acknowledged by the user.


3.9.1.13 IsActive

bool IsActive { get; }

       ReadOnly Property IsActive As Boolean

This property determines whether the event entry relating to the alarm monitored by the object exists in the active alarm log. The value of false means that there is no information about the alarm and all the other properties of AlarmState object have indefinite values.


3.9.1.14 IsExcluded

bool IsExcluded { get; }

ReadOnly Property IsExcluded As Boolean

This property determines whether the alarm is excluded from handling. The excluded alarms are not shown in the alarm tables, but their details are stored in the active alarm log and are available for use in the scripts.


3.9.1.15 IsFinished

bool IsFinished { get; }

ReadOnly Property IsFinished As Boolean

This property determines whether the alarm stored in the active alarm log has already been ended. Depending on the configuration, the active alarm log is able to keep the details of the event that has already been ended. The alarm should be considered as active (not ended) if the IsActive property is true and IsFinished property is false.


3.9.1.16 WasFiltered

bool WasFiltered { get; }

ReadOnly Property WasFiltered As Boolean

This property determines whether an alarm event recorded in the log was subjected to the time filter mechanisms.


3.10 AlarmProperties Object

The AlarmProperties object stores information about the alarm definition. The object can be obtained via the Definition property of the IAlarm interface.


3.10.1.1. Action

string Action { get; }

ReadOnly Property Action As String

This property returns the contents of the operator action defined for the alarm.


3.10.1.2. DetectionParameters

string DetectionParameters { get; }

ReadOnly Property DetectionParameters As String

This property returns the Detection parameters attribute of alarm definition. If the external alarm detection strategy is carried out by means of script mechanism, it is possible to use the DetectionParameters as the information source specifying how the alarm state is to be detected.


3.10.1.3. BeginText

string BeginText { get; }

ReadOnly Property BeginText As String

This property returns the text describing the beginning of the alarm in the original form used in the alarm definition - formatting inserts {} are not converted.


3.10.1.4. EndText

string EndText { get; }

ReadOnly Property EndText As String

This property returns the text describing the end of the alarm in the original form used in the alarm definition - formatting inserts {} are not converted.


3.10.1.5. Id

string Id { get; }

ReadOnly Property Id As String

This property returns the ID of the alarm, which attributes are stored in the object.


3.10.1.6. IsStartOnly

bool IsStartOnly { get; }

ReadOnly Property IsStartOnly As Boolean

This property returns information specifying if the alarm belongs to the notification category. Alarms of this category do not have the events assigned to their ends.


3.10.1.7. Priority

int Priority { get; }

ReadOnly Property Priority As Integer

This property returns the alarm priority (importance). The following values are available:

  • 0 – critical alarm

  • 1 – urgent alarm

  • 2 – alert alarm

  • 3 – warning

  • 4 – message


3.10.1.8. Strategy

string Strategy { get; }

ReadOnly Property Strategy As String

This property returns the name of the alarm detection strategy.


3.11 TrendPatternPoint Object

The TrendPatternPoint object defines a single point of pattern trend. The array of pattern trend points can be downloaded using the GetTrendPatternPoints method of the IApplication interface.


3.11.1.1. TimeStamp

TimeSpan TimeStamp { get; }

ReadOnly Property TimeStamp As System.TimeSpan

This property specifies the pattern trend point - specified as the time interval from the beginning of the curve.


3.11.1.2. Value

double Value { get; }

ReadOnly Property Value As Double

This property determines the value of the pattern trend point.


Asix.Evo_Scripts

Table of Contents

1. The basics of using scripts

1.1 Creating Script

1.2. Script Edition

1.3. Methods to Run Scripts

1.3.1. Interactive Scripts

1.3.2. Autonomous Scripts

1.4. Active Script Management

1.5. Script Code Structure

2. Examples of Typical Scripts

2.1. One-time Scripts

2.2. Resident Scripts

2.2.1. Loops in Initialize Method

2.2.2. Use of RegisterTimeEvent Function

2.2.3. Creating Threads

2.2.4. Monitoring the Process Variable Changes

2.2.5. Monitoring Alarm Status

2.3. Readout of Script Starting Parameters

2.4. Readout of Current Process Variable Values

2.4.1. Cyclical Readout of Current Process Variable Values

2.4.2. Current Value Readout Controlled by the Variable Refreshing

2.5. Setting Process Variable Values

2.5.1. Calculation of Variable Derivative Values

2.5.2. Obtaining Values from External Sources

2.6. Readout of Archive Values of Process Variables

2.7. Using Array Variables

2.7.1. Array Variables Readout

2.7.2. Saving Array Variables

2.8. Transferring Pattern Trends

2.9. Controlling the Alarm Status

2.9.1. Readout of Active Alarm Status

2.9.2. Active Monitoring of Alarm Status

2.9.3. Alarm Notification

2.10 Using the Context of Script Starting

2.11 Multilingual Scripts

2.12. Creating Window Interface

2.12.1. Message Displaying

2.12.2. Windows Created within Script Contents

2.12.3. Using Built-in Libraries

3. Object Model of Scripts

3.1. IApplication Interface

3.1.1. Properties

3.1.1.1. ApplicationAddonsDirectory

3.1.1.2. ApplicationDirectory

3.1.1.3. ApplicationName

3.1.1.4. ApplicationWorkingDirectory

3.1.1.5. CurrentApplicationLanguage

3.1.1.6. CurrentStationName

3.1.1.7. CurrentUserId

3.1.1.8. CurrentUserName

3.1.1.9. CurrentUserRoles

3.1.1.10 ProgramVersion

3.1.1.11 ScriptName

3.1.1.12 ExecutionContext

3.1.2. Methods

3.1.2.1. ApplicationText

3.1.2.2. CreateThread

3.1.2.3. ExecuteAction

3.1.2.4. GetAlarm

3.1.2.5. GetAlarmDomainController

3.1.2.6. GetAlarmDomains

3.1.2.7. GetAlarmDomainStationMode

3.1.2.8. GetActiveAlarms

3.1.2.9. GetDefinedAlarms

3.1.2.10 GetTrendPatternPoints

3.1.2.11 GetVariable

3.1.2.12 GlobalProperty

3.1.2.13 HasRole

3.1.2.14 RegisterTimeEvent

3.1.2.15 ReportMessage

3.1.2.16 Sleep

3.1.2.17 TerminateScript

3.1.2.18 UnregisterEvent

3.2. IContext Interface

3.2.1. Properties

3.2.1.1. Diagram

3.2.1.2. DiagramObject

3.2.1.3. IsWebBrowser

3.2.1.4. MainVariable

3.2.1.5. ScriptStartTime

3.2.1.6. WebServerAddress

3.3. IVariable Interface

3.3.1. Properties

3.3.1.1. Name

3.3.1.2. IsRefreshed

3.3.1.3. VariableState

3.3.2. Methods

3.3.2.1. OrderArcData

3.3.2.2. Read

3.3.2.3. RegisterStateEvent

3.3.2.4. SetVariableBits

3.3.2.5. SetVariableValue

3.3.2.6. UnregisterStateEvent

3.3.2.7. VariableAttribute

3.4. VariableState Class

3.4.1. Properties

3.4.1.1. FormattedValue

3.4.1.2. IsBad

3.4.1.3. IsGood

3.4.1.4. IsUncertain

3.4.1.5. RawValue

3.4.1.6. Status

3.4.1.7. TimeStamp

3.4.1.8. Value

3.5. ArcQuery Class

3.5.1. Constructor

3.5.2. Properties

3.5.2.1. Aggregate

3.5.2.2. AggregateInterval

3.5.2.3. EndTime

3.5.2.4. ProcessedDataQuery

3.5.2.5. StartTime

3.6. IArcQueryResult Interface

3.6.1. Properties

3.6.1.1. ErrorDescription

3.6.1.2. Query

3.6.1.3. ResultStatus

3.6.1.4. Values

3.6.1.5. VariableName

3.6.2. Methods

3.6.2.1. CancelQuery

3.6.2.2. RegisterQueryResultEvent

3.6.2.3. UnregisterQueryResultEvent

3.6.2.4. Wait

3.7. ArcVariableState Class

3.7.1. Properties

3.7.1.1. IsBad

3.7.1.2. IsGood

3.7.1.3. IsUncertain

3.7.1.4. Status

3.7.1.5. TimeStamp

3.7.1.6. Value

3.8. IAlarm Interface

3.8.1. Properties

3.8.1.1. AlarmState

3.8.1.2. Definition

3.8.1.3. Domain

3.8.1.4. Id

3.8.2. Methods

3.8.2.1. Accept

3.8.2.2. Cancel

3.8.2.3. Raise

3.8.2.4. RegisterStateEvent

3.8.2.5. UnregisterStateEvent

3.9. AlarmState Object

3.9.1. Properties

3.9.1.1. AcceptanceOperatorId

3.9.1.2. AcceptanceStationName

3.9.1.3. AcceptanceTimeStamp

3.9.1.4. BeginDetectionTimeStamp

3.9.1.5. BeginExprValue

3.9.1.6. BeginTimeStamp

3.9.1.7. EndDetectionTimeStamp

3.9.1.8. EndExprValue

3.9.1.9. EndTimeStamp

3.9.1.10 FormattedBeginText

3.9.1.11 FormattedEndText

3.9.1.12 IsAccepted

3.9.1.13 IsActive

3.9.1.14 IsExcluded

3.9.1.15 IsFinished

3.9.1.16 WasFiltered

3.10 AlarmProperties Object

3.10.1. Properties

3.10.1.1. Action

3.10.1.2. DetectionParameters

3.10.1.3. BeginText

3.10.1.4. EndText

3.10.1.5. Id

3.10.1.6. IsStartOnly

3.10.1.7. Priority

3.10.1.8. Strategy

3.11 TrendPatternPoint Object

3.11.1. Properties

3.11.1.1. TimeStamp

3.11.1.2. Value


2. Examples of Typical Scripts


3.1.1. Properties


3.1.2. Methods


3.2.1. Properties


3.3.1. Properties


3.3.2. Methods


3.4.1. Properties


3.5.2. Properties


3.6.1. Properties


3.6.2. Methods


3.7.1. Properties


3.8.1. Properties


3.8.2. Methods


3.9.1. Properties


3.10.1. Properties


3.11.1. Properties


3. Object Model of Scripts