Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Tip

These are programming codes, which will be embedded in the system. They make it possible to individualize or create behaviors and actions on objects (tags, screens, reports) that do not exist natively in the system. The following sections describe how to create scripts using Action.NET

Configuring Tasks

Tasks, or TASKS are program codes, written in VB.Net or CSharp, which run from process events, when a trigger occurs or periodically at each pre-set time interval in the configuration.

From version 9.1 was also included support for using the Python language, see description of this feature in Integration with Python, in this guide.

The Action.NET comes with the following built-in, predefined tasks:

  • ServerStartup - Executed when the project starts running. It runs on the server (computer that runs TServer.exe).

  • ServerShutdown - Executed when the project is terminated. It runs on the server.

  • ClientStartup - Executed on each client when the TVisualizer.exe (DISPLAYS module) starts working.

  • ClientShutdown - Executed on each client when the DISPLAYS module is closed.

The following figure shows the TASKS tab of the SCRIPTS menu workspace.
To set up tasks:

  1. Go to Edit> Scripts> Tasks.

  2. Enter or select the information as needed.

Column

Description

Name

Type a name for the task. The system lets you know if the name is not valid.

Code

Read-only. By default the dot Net language selected when you created the project. On the Code Editor tab, you can change the language of the code. To change the design pattern, go to Info > Settings.

Trigger

Type or select the event (tag or object) that will be used to trigger the execution of the task. The task runs when the object value changes.

Period

Enter the execution frequency of the task. The field is format hh:mm:ss

Domain

Select the location where the script runs:

  • Client-Task performed on each client system. These are tasks that apply locally (on the user's computer), for example, reporting.

  • Server-Task run on the system server. These are tasks that apply to the entire application, i.e. at the global level

InitialState

Select the initial state of tasks:

  • Enabled- Task is ready to run from the start.

  • Disabled -Task is not ready to run. Allows you to activate the task under specific conditions.

BuildStatus

Read-only. Task code situation according to the continuous build process.

  • Green Mark - Task compiled without errors.

  • Mark in Red X - The task has errors or Warnings. With a double click the system will show the code at the point where the Warning or error is. Errors prevented the execution of the specific Task. The rest of the application will run normally.

EditSecurity

Allows you to choose the security level for editing the code of this Task. Clicking appears the window with the categories of users who will have access to change this TASK.

BuildErrors

Read-only. Show errors found since the last "Build"

Description

Enter a description for task.

  • After you have completed the data entry on the row describing the TASK, enter the code for the Task.

  • A double click on the line causes you to access the task code area in the Code Editor. See in "Working with the Code Editor" ,

  • At the end of the code change click Save at the top of the workspace.

Configuring Classes

Classes allow you to create a repository of libraries of classes, methods, and functions that you can use throughout the application. You can call these classes from within Tasks, other classes, and From Screens (Code Behind).
The Action.NET comes with the following built-in classes:

  • ServerMain Library-Methods available for all server tasks.

  • ClientMain Library-Methods available to all clients.

To set up classes:

  1. Go to Edit> Scripts> Classes.

  2. Enter or select the information as needed.

Column

Description

Name

Enter a name for the class. The system indicates whether the name is not valid by showing in red the outline of the field.

Code

Read-only. By default the dot Net language selected when you created the project. On the Code Editor tab, you can change the language of the code. To change the design pattern, go to Info > Settings.

Column

Description

Domain

Select the location where the class runs:

  • Client Class - Executed on each client system. These are classes that apply locally (on the user's computer), for example, reporting.

  • Server-Run class on the system server. These are classes that apply to the entire application, i.e. at the global level

BuildStatus

Read-only. Class code situation according to the continuous build process.

  • Green Mark - class compiled without errors.

  • Red X Mark - The class has errors or Warnings. With a double click the system will show the code at the point where the Warning or error is. Errors prevented the execution of the specific class. The rest of the application will run normally.

BuildErrors

Read-only. Displays all errors encountered during the last build

EditSecurity

Allows you to choose the security level for editing the code of this Task. Clicking appears the window with the categories of users who will have access to change this TASK.

Description

Enter a description of the class

  • Enter the code for the class.

    • Double-click the line to access the tab Code Editor (Code Editor). See Working with the Code Editor.

  • At the end click Save in the top bar of the workspace.

Working with the Code Editor

You can write code both in the VB.Net as in CSharp. You can also switch between the two. If you change your language selection option in the code editor, the system automatically converts existing code to the selected language.
If you need to create references to your own pieces of code (assemblies), you can use the facilities available in Run > Build > References.
Because it is a fully compatible application with dot NET, you can find in the market or on the internet, excerpts of source code, for free use, inclusive. dot NET products and libraries, plus your own libraries that you can use immediately.
The Action.NET exposes to the Script programmer many DOT NET libraries that can be used in the application. There are some methods that are very often necessary, such as type conversion, or copying tags to datatables for dot NET objects, or for dynamically configuring communication parameters, which are included in a toolkit library of their own. To use these methods, you just need to put TK. in the code editor, pre-fixing the method.

Example:

Code Block
double x = TK.ConvertTo <double> ("123");


The available methods are described in Toolkits.html.

To edit the code:

  1. Go to Edit> Scripts> CodeEditor .

  2. From the drop-down list in the main toolbar, select the Task or Class you want to edit.

    • To create a new Task or Class, see "

Set up
  1. Click the Save toolbar at the top of the workspace.

Tip

Two DOT NET libraries are available for use with Action.NET:

  • For internal Script are available inline methods that you can call using TK. <methodName>. For more information on these methods, see the manual Toolkits.html.

  • If you use Microsoft Visual Studio, the library is available for use with Action.NET. For more information about this library, see the Toolkits.html.

Info

NOTE - When you are using the code editor, the system constantly compiles the code in the background. You can also "Build" the entire project as needed. For more information, see "Running the Application"

Configuring Expressions

The last tab in the workspace Scripts is used for the creation of Expressions that also function as a simple line of code that will run under certain conditions, providing a result.
In addition to the table that can be updated by Edit> Script> Expressions, in several other places in the Action.NET Engineering space, you can type and use expressions, using the same syntax described here, to get a result value from the expression or to configure a condition.
Expressions are merely encodings in the syntax VB.Net, such as both aritmetic expressions or calls to methods of classes defined or accessible in the project. The Intellisense facility is oriented only to Tags and application objects, not considering the language, but expressions are compiled using the default compiler VB.Net, so what you can write without syntax errors in the code editor, you can also write to the Expression code.
The Action.NET implements some automated overrides, such as == to =, so the syntax of an expression is very close to a C# declaration, but without the need to add the ";" at the end.
In this way, both programmers VB.NET like C# are able to use expression fields without differences.
In expressions, you do not need to put @ before tag names. You need the @ in the code editor to differentiate the Project Tags from the NET dot variables. However, because expressions do not have local variables dot NET, then you can use the project objects directly.
For aritmetic operators, you must use the default operators as described in the DOT NET documentation.
To allow single-line evaluation, the dot NET language has the IIF command, which is actually used only with IF. The IF command has three parameters.
For instance:
IF (A, B, C)

  • The first parameter is a condition.

  • This method returns B if condition A is true;

  • And he returns C, if the condition is false.

Example: If (tag. A = 1, "True", "False") will return a string according to the value of the tag.A.
In this dot,NET method, all three parameters are evaluated regardless of the condition. For example, if you have
IF (tag. A = 1, script.class.client.Func1(),script.class.client.Func2())
Both Func1 and Func2 will always run. Only the return value will be different based on the value of tag.A.
The IF or IIF method needs to evaluate the parameters before calling the method. There are many situations where you want to run only the function according to the value.
For this scenario the Action.NET has a method called TIF, which has this behavior. So you use the expression:
TIF (tag. A = 1,script.class.client.Func1(),script.class.client.Func2())
Only Func1 () or Func2 () will be executed, according to the value of Tag.A
The TIF method is defined in the class library that is automatically exposed to expressions that are in the Toolkit function library.
For more complex calculations, you can call a class that you must first create in the Classes tab. See in "Configuring Classes" .

To set up expressions:

  1. Go to Edit> Scripts> Expressions .

  2. Enter or select the information as needed.

Column

Description

Object

Select an existing tag or object.

Expression

Type the expression. The expression can be a basic mathematical expression, use a class, or be a conditional expression.

Domain

Select where the expression runs:

  • Customer - Expression will be executed on each client system. These are expressions that apply locally (on the user's computer), for example, reporting.

  • Server - Expression will run on the system server. These are expressions that apply throughout the application, i.e. globally.

Column

Description

Execution

Select when the expression is executed:

  • OnChange - The expression is executed when the value of any tag in the expression changes.

  • Trigger_TimeTimeInterval - The expression runs when the configured trigger event occurs or when the time interval set in the period is expired.

  • Change_Startup - The expression runs when the value of any tag in the expression changes or in the application match.

  • Trigger_TimeOfDay - The expression runs when the local time reaches the value set in Time.

Trigger

Type or select a tag or object that will be used to trigger the execution of the expression. The execution trigger will occur when the value of the tag or object changes.

Team

Time time or period used as a reference for each of the execution types.

DisableConditio

Type or select a tag or object that will be used to disable the execution of the expression

BuildStatus

Read-only. Updated code status after clicking
Verify, verify.

  • Green Mark - Expression compiled without errors.

  • Red X Tag - The Expression contains errors.

BuildErrors

Read-only. Displays all errors encountered during the last build

  • Click Verify to check the validity of the expression.

Using the .NET debugger

Creating Debug Information

The Action.NET has an integrated DOT NET debugger. To use it, the local computer must have cache files with the files needed to run the debugger.

The steps to enable the debugger are:

  1. Enable Debug Information in Run> Build> Messages: at the top of the panel check the "Include Debug Information" option.

  2. If necessary, save back the source code that you want to debug, so the debug information is created. This step is only required the first time you open the project on your computer. After that, the background build will keep generating the debug information as the code changes to allow the use of breakpoints and execution step by step.

Attaching the DOT NET debugger

In order to have a DOT NET debugging session, the Engineering environment must be connected to the runtime environment and the dot NET debugger attached ("Attached") to the server process or client process.

Follow these steps.

  1. During the implementation of the project, either in Run>Test or Run>Startup enable the connection check box.

  2. If the project is already running, you can go to Run>Test or Run>Startup, depending on the type of execution you want to attach, and connect to the execution system by pressing the connection button on those pages.

  3. Open any script that has debug information and press the Attach. NET debugger. A message at the bottom of the engineering workspace will show that a debugging session is active with the server components or client components of the running project.

When the NET dot debugger is attached the system will stop at the defined breakpoints and will also stop automatically when any NET Exception occurs.

See in the Code Editor the Buttons to Attach and Detach debugger, run, run step by step create breakpoints shown in the red rectangle. At the bottom debug status information.

Breakpoints, Walkthrough, and Watch

To set up a breakpoint, open the desired code, select the line, and press insert breakpoint in the toolbar, or click the left vertical bar of the code window.
When the system stops at a breakpoint, you can perform step by step by pressing the run-by-step buttons or have the button continue by pressing continue.
In order to inspect local variables of dot NET tags or project objects, you can select the text in the script editor, and when execution stops at a breakpoint, the toolkit will show the current value of the variable.
You can also add. local dot NET variables or project objects in the Code Editor's own Watch window (bottom) When adding tags or project objects, you need to use the @symbols, example@tag.tag1, for the system to distinguish between project objects, and local dot NET variables. Keep in mind that your Watch will be updated only when execution is stopped. If you want to have real-time values for tags and objects, you can open the PropertyWatch diagnostic tool described in "Tools for Diagnosis" .

Runtime Script Object

The Script namespace is the entry point for all objects related to the Scripts module.
The Script.Task object lists all configured Tasks and their properties at run time.
The objects Script.Class list classes and their properties at the configured runtime.
See in {+}http://www.spinengenharia.com.br/help/an-2016/runtime/index.html+ . for the full programming reference on runtime objects.

panel


Scroll ignore
scroll-viewporttrue
scroll-pdftrue
scroll-officetrue
scroll-chmtrue
scroll-htmltrue
scroll-docbooktrue
scroll-eclipsehelptrue
scroll-epubtrue

On this page:

toc12false