Versions Compared

Key

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


HTML
<style>
.text-span-6 {
    background-image: linear-gradient(99deg, rgba(170, 163, 239, .5), rgba(125, 203, 207, .5));
    border-radius: 50px;
    padding-left: 15px;
    padding-right: 15px;
}

#title-text {
display: none;
}

.panelgradient {
    background-image: linear-gradient(180deg, #d5def0, whitesmoke);
    border-radius: 8px;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 4rem;
    display: flex;
    position: relative;
}

</style>


<div class ="panelgradient">

<h1 style="text-align: center;">Scripts <br> (Tasks and Classes)</h1>

</div>



Introduction to the Scripts Module

The Scripts Module supports multiple programming languages, including C#, VB.NET, Python, and JavaScript, enabling the creation of high-performance server-side and client-side scripts on Display Code-Behind. Its built-in code editor streamlines development with automated translation between C# and VB.NET and provides access to all .NET Framework classes available in Visual Studio. The module simplifies distributed application development using server or client domains and ensures high performance through custom code compilation. Additionally, it enhances graphical displays with Display Code Behind functions and offers debugging tools for quick identification and resolution of coding issues.

The Scripts Module Allows:

  • Multi-Threaded Task Execution
  • Event-Driven Actions 
  • Library Creation for Methods and Classes
  • Intermixing C#, VB.NET and Python classes.
  • Integration with Third-Party Libraries.

On this page:

Table of Contents
maxLevel3
minLevel2
stylenone




Key Concepts and Terms

The Scripts Module manages and executes user-defined scripts for automation and process control. 


Panel
bgColor#ffffff

ScriptTask

Defines code that executes in reaction to an event (trigger) or periodically at specified intervals.


Panel
bgColor#ffffff

ScriptClass

A library of functions and methods that can be used in Script Tasks, Expressions, or from the Code Behind on graphical Displays.



Panel
bgColor#ffffff

ScriptExpression

One line of code in response to an event, where the entire script isn't necessary.


Panel
bgColor#ffffff

Script References

External DLLs included for a script or display code compilation.





Understanding the Scripts Module

Module Highlights

  • Built-in Code Editor: Our code editor works for C#, VB.NET, JavaScript, and Python languages.
  • Server and Client Domains: Create scripts that execute on the server for global reach, or on the client side for local reach.
  • Events and Scheduling: Tasks and expressions can be triggered by date, time, condition, calendar, tag change, or interval. Execution is distributed among processes, each running in its own application domain, isolated from the real-time database, ensuring maximum system security and performance.
  • Object Orientation and Solution Object: All solution objects, including Tags, Datasets, Alarms, devices, and communication statuses, are immediately accessible via IntelliSense as native .NET objects. No temporary tags or function calls are required. With a single command, move data from Tags to .NET objects and external Data-tables.
  • Configure your Python Interpreter: The Script module delivers exceptional scripting capabilities across various programming languages with seamless integration of Python. You can configure any version of the Python interpreter for each project.




Configuring the Scripts Module

Configuration Workflow

Scripts Module configuration workflow
ActionWhere Comments

Manage ScriptClasses

Scripts→Classes

Create or Import you function Library. Learn more at Scripts Classes.

Manage ScriptTasks

Scripts→Tasks

Create or Import Tasks. Learn more at Scripts Tasks.

Manage ScriptExpressions

Scripts→Expressions

For simple event or time driven actions, use Expressions. Learn more at Scripts Expressions.

Manage Script References

Scripts→References. 

If you code required their party libraries, include the references. Learn more at Scripts References.





Working with the Scripts Module

Runtime Execution

The key concept to be aware on the execution of the Tasks and Expressions define on the Script Module is that they execute on the Server computer.

Only the CodeBehind of the displays is executed on each Client Computer. The Script Classes can be consumed by both Server and Client stations.

Current solution are prorating User Interfaces that are Portable, meaning the exact same drawing and display configuration can run both as a WPF Windows RichClient, or as Web HTML5 page inside a browser. If you intend to run the graphical interface only on WPF Windows, not web pages, it is possible to enable in Solution → Settings to allow Tasks and Expressions running on the Client side.

For complex solutions or very large solutions, it's useful to get a deeper understanding of the Module execution process, see Scripts Module Execution if that is your case.




Script Runtime Attributes

The Namespace Script is the entry point for all objects related to the Scripts module.

The Script.Class object lists all configured tables and its runtime properties. The Script.Task object lists all configured database connections and their runtime properties.

Examples:

Script Task properties

Property

Type

Description

Script.Task.Task1.ExecutionCount

Integer

Number of times the Script Task <Task1> was executed.

Script.Task.Task1.LastCPUTime

TimeSpan

The Amount of CPU used the last time the Script Task Task1 was executed.

→ Read more about Objects and Namespaces.




Anchor
BestPractices
BestPractices
Best Practices and Troubleshooting

Best Practices and Recommendations

  • Code Formatting:  Use the 'Format' feature of the editor for more readability.
  • Naming Convention: Use a coherent and descriptive naming convention for tasks.
  • Task Domain: Select the appropriate domain for each task, considering whether the task is more suitable for client-side or server-side execution. Remember, Client-Side Tasks only applicable to RichClients
  • Reusable Code: Promote code reuse by creating classes that encapsulate functionalities for use in various parts of the project.
  • Library Management: Manage libraries and external components effectively to avoid conflicts and compatibility issues.
  • Code Consistency: Maintain code consistency by following best practices and coding conventions.
  • Build Before Deployment: Always perform a build operation before deploying a project in a production environment to ensure all scripts are correct and up to date.
Troubleshooting and Common Issues

The Scripts module may encounter some issues in its operation. Here are some common issues and their troubleshooting:

  • Build Errors and Warnings: Make sure to check the 'BuildStatus' and 'BuildErrors' tabs to identify and address errors and warnings that arise during the build.
  • Code Language: If you change the code language in the code editor, confirm that the code has been correctly converted to the selected language.
  • Build Order: Ensure that the build order of the classes is set up correctly to avoid circular dependencies or initialization issues.
  • Domain Selection: Ensure that the domain is selected correctly (Client or Server) based on the needs of your project.
  • Reference Issues: Make sure that all external references are configured correctly and that there are no compatibility issues or conflicts. Code Editor
  • Code Formatting:  Use the 'Format' feature of the editor for more readability.
  • Incremental Compilation Issues: Monitor the incremental compilation process to identify and resolve potential issues that may arise.
  • Debugger Setup: Ensure that the debugger setup is correct to allow effective code debugging.
  • Breakpoints and Watch Variables: Use breakpoints and watch variables effectively to identify and resolve issues.

Script Runtime Attributes

The Namespace Script is the entry point for all objects related to the Scripts module.

The Script.Class object lists all configured tables and its runtime properties. The Script.Task object lists all configured database connections and their runtime properties.

Examples:

Script Task properties

Property

Type

Description

Script.Task.Task1.ExecutionCount

Integer

Number of times the Script Task <Task1> was executed.

Script.Task.Task1.LastCPUTime

TimeSpan

The Amount of CPU used the last time the Script Task Task1 was executed.

→ Read more about Objects and Namespaces
  • .




In this section:

Page Tree
root@self
spacesV10

...