<< Click to Display Table of Contents >> Manual > Monitoring system construction guide > Server logic construction > Write tag values to the DB (Batch transfer) |
overview
This section explains how to output tag data to a table in a database at any time.
Action used: Batch transfer(tag → ODBC) action
Download the sample
The creation examples shown on this page are provided with samples.
The sample can be downloaded from below.
The above sample includes a SQL file (DDL) to generate the table. Use it as a reference when creating the table.
Operation check
This sample requires a database to be prepared. Once the database is prepared, please bring the sample server configuration file online from FA-Server (yellow arrow).
After going online, if you write TRUE to U01.F01.T01, the tag value will be written to the record in the target table.
(Example of output to a table)
Setup Procedure
Tag configuration
1.Set tags.
Tag Name |
address |
the purpose |
---|---|---|
U01.F01.T01 |
X0000 |
A tag that triggers an action |
U01.F01.D0000~D0009 |
D0000 to D0009 |
Tags that output information |
Action Settings
1.Register the Batch transfer (tag → ODBC) action "A01".
2.Add a field to A01.
Drag and drop the
tag into A01. This action allows you to register tags simply by dragging and dropping them.
Field has been registered.
3.Batch transfer (Tag → ODBC) Action property settings and table creation
Create the target table in the database.
In this sample example, a table is created with the following contents:
Table name: BATCH_TABLE
Batch Name Field: BATCH_NAME
Value quality field: BATCH_QUALITY
Timestamp field: BATCH_TIME
Value field: BATCH_VALUE
(Field setting example for SQLServer2017)
The recommended data types for each connectable DBMS are described in "Database connection settings" in Appendix.
Next, set up the ODBC data source from the Batch transfer1 tab of the action. The ODBC setting procedure can be performed using the same operations for each ODBC. For ODBC settings, please refer to the description in "ODBC Settings" in the common settings of the action.
In this example, the data source is defined as "BATCH_TAG_ODBC". Also, specify the "BATCH_TABLE" created above as the table name to connect to.
Next, in the Actions tab, set the field names to be associated with the output data.
4.Writes the batch name to the database.
Batch transfer1 Click the "Create Manually" button on the tab to write the key batch name to the database.
The following shows the batch name written correctly to the database (SQLServer2017 example):
Event Settings
1.Create a Tag event to perform the action.
In this example, we will set the event to occur when U01.F01.T01 becomes TRUE.
Set the execution action to "A01".