Run your own logic in the background (SC2)

<< Click to Display Table of Contents >>

Manual > Monitoring system construction guide > Server logic construction >

Run your own logic in the background (SC2)

Build your own logic with Script Ver.2 actions

By using the Script Ver. 2 action (SC2), you can build your own logic using scripts that use the “SC2 syntax” on the FA-Server side.

 

In SC2 syntax, you can write advanced scripts such as if statements (conditional branching), for statements (repetitive processing), and original function definitions. In addition, it is equipped with a variety of event functions such as the OnTagValueChange event that receives tag value changes and OnExpressionValueChanged that receives the satisfaction of the condition of a pre-registered formula.

 

The following content provides examples of building your own logic using Script Ver. 2.

 

 

Action used: Script Ver2 Action

 

content

overview

Script Ver2 event usage example

 

This is a sample of how to use the events in script Ver2. You can check the behavior of each of the following events.

 

OnInitialize/OnTerminate/OnTimer/OnTagValueChanged/OnHeartBeat/OnExpressionValueChanged

 

Access the database from script Ver2

 

By using Direct query database(SQL) control, you can connect to the database from script Ver2 via ODBC and execute SQL.

 

Get historical data from script Ver2

 

By using Historical data control, you can connect from script Ver2 to each action with server functionality, such as summary action, logger action, and Historical data server action, and obtain historical data (time series data).

 

Access tags periodically from script Ver2

 

This is a sample of script Ver2 that reads tags at regular intervals and performs processing according to the tag value.

 

Detecting changes in tag values from script Ver2

 

This is a sample script Ver2 that periodically detects changes in tag values and performs processing according to the changed tag values.