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> (Code Editor, Tasks, and Classes)</h1>

</div>



Introduction to

Script

the Scripts Module

The Script module supports various Scripts Module supports multiple programming languages, such as including C#, VB.NET, Python, and JavaScript, enabling the creation of high-performance server-side and client-side scripts. It offers a comprehensive set of features, including multi-threaded task execution, event-driven actions, creation of libraries for methods and classes, and integration with third-party libraries. The 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. Furthermore, the Script The module simplifies the development of distributed applications by distributed application development using server or client domains and ensuring ensures high performance through the compilation of custom code .The Script module also allows users to extend graphics displays power by implementing compilation. Additionally, it enhances graphical displays with Display Code Behind functions and provides 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
  • Integration with Third-Party Libraries.

On this page:

Table of Contents
maxLevel3
stylenone




Key Concepts and Terms

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


Panel
bgColor#ffffff

Script Tasks

A Script Task defines a

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

. For example, you can create a Task to execute every second, or when any specific Tag in the Project has a new Value

.


Panel
bgColor#ffffff

Script Classes

A

Script Class is a

library of functions and methods that

you

can

consume on

be used in Script Tasks, Expressions, or from the Code Behind on

the

graphical Displays

. The use of Scripts Classes allows a more efficient and clean organization of Project logic and calculations

.



Panel
bgColor#ffffff

Script Expressions

When you need to execute one

One line of code in

a reaction

response to an event,

instead of creating a Script Task, you can configure just one line at the Script Expressions table. For example, when one tag changes its value, you need to set another tag value, or call a Script Class, it is easier to define just the one line Expression instead of a Task

where the entire script isn't necessary.


Panel
bgColor#ffffff

Script References

Script References are external

External DLLs included for a script or display code compilation.





Understanding the

Script

Scripts Module

Feature

Module Highlights

  • Built-in Code Editor: Our code editor works for C#, VB.NET, JavaScript, and Python languages, or as well as XML and JSON documents.
  • Server and Client Domains: Create scripts Create scripts that execute on the server for global reach, or they can execute on the client side for local reach.  
  • Events and Scheduling: Tasks and expressions can be triggered to execute 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, for ensuring maximum system security and performance. 
  • Object Orientation , and Project Elements: All solution elements, including Tags, Datasets, Alarms, devices, status of communications and communication statuses, are immediately accessible via IntelliSense , as they are native .NET objects, no . 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:With seamless integration of Python language and applications, the The Script module delivers exceptional scripting capabilities across various programming languages with seamless integration of Python. You can also configure any version of the Python interpreter for each project. 




Configuring the

Script

Scripts Module

Configuration Workflow

Script module configuration workflow
ActionWhere Comments

Manage Class Scripts

Scripts→ Classes. Learn more at ScriptClasses.


Manage Task Scripts

Scripts→ Task. Learn more at Script Tasks.


Manage Expressions

Scripts→ Expressions. Learn more at Script Expressions.


Manage References

Scripts→ References. Learn more at Script References.


Track the module changes

Scripts→ Monitor. Learn more at Scripts Monitor.






Working with the Script Module

Runtime Execution

For a detailed understanding of the script execution process on the software framework, refer to the Scripts Runtime Execution and get insights into managing and optimizing scripts' performance.

Monitoring the Script Module

The Scripts Monitor feature tracks and assesses script performance, providing crucial insights for optimizing your software platform. Dive into the Explore Monitoring Scripts for an in-depth exploration of script monitoring techniques.

Client-Server Programming

To read learn more about client-server programming in the software framework context, please explore see Client-Server Programming.

Client-Server Data Security

To ensure the security and integrity of your data within the software framework, explore Client-Server Data Security. This resource provides detailed information on safeguarding data exchanges between clients and servers, protecting your project from potential security risks.

Leveraging Built-in Function Libraries

The Script module provides several built-in classes and methods libraries that can greatly streamline your project development process. If you're interested in leveraging the powerful built-in function libraries of software frameworkFor detailed documentation, see Built-in Methods and Libraries for detailed documentation. 




Troubleshooting and Best Practices

Table of ContentsmaxLevel4minLevel3include#

Troubleshooting and Common
#Issues
Issues

The Historian 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.

Expression Syntax: Check the syntax of the expressions, ensuring they comply with VB.Net or C# standards.

Execution Settings: Ensure that the execution settings are correct, so that the expressions are executed as expected.

Reference Issues: Make sure that all external references are configured correctly and that there are no compatibility issues or conflicts. Code Editor

Syntax Errors: Check for syntax errors in the code. Use the 'Auto Format' feature to identify potential issues.

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.

Best Practices and Recommendations

Tasks:

  • Naming Convention: Use a coherent and descriptive naming convention
to name the
  • 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.
 

Classes:

  • Reusable Code: Promote code reuse
through the creation of
  • by creating classes that encapsulate functionalities
that can be reused
  • for use in various parts of the project.

Expressions:

  • Expression Optimization: Write optimized expressions to ensure efficient execution and
to
  • reduce resource usage.

External

Libaries 

Libraries:

  • 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
that
  • all scripts are correct and up to date.




Script Runtime Attributes

The Script namespace 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.


ModuleScript properties

Property

Type

Description

Script.IsStarted

Boolean

Flag indicating if the module Dataset has started.

Script.OpenStatusMessage

String

Message OK or error when initiating the module.


To learn about the basic concepts of namespaces and objects, you can refer to→ Read more about Objects and Namespaces.





In this section:

Page Treeroot@selfspacesV10What's Next?