This article describes how to use events for data collection in TransSECS.
Before this, you should have done tool characterization that is connected to your host project, and you have requested defined RPTIDs from the tool, by right clicking on “RPTIDs” and “Online RPTIDs from Tool”.
The following steps describe how to setup RPTIDs to link with VIDs, CEIDs and collect data in TransSECS for a GEM host project, with StandAloneGEMTool.
Right click on “RPTIDs” and select “Add RPTID”.
Now you see one RPTID0 (-1) listed under the RPTIDs.
RPTID Configuration
RPTID: must be greater than zero and unique
RPT Name: a unique name for this report, must start with a letter character and have no spaces
Then select the VIDs to be requested in the report. Select VIDs on the left side of the list and press the > arrow key to select these one at a time and move them to the right side. VIDs on the right side will be used in the report.
Note: CLOCK and VIDs with spaces in their names should not be used. CLOCK is often a reserved word in SQL (specifically MySQL) so will cause a database write error if used as a column name. You can rename the VIDs in the VID node so there is no conflict (do not change the VID id number, only the text name). Same with VIDs with spaces in the names. Either remove the space or use an underscore _ character for the space.
Now link reports (RPTIDs) to the events (CEIDs): One event can have many reports, depends on how you define the RPTID and what data you want to collect. Here we have an example of linking RPTID100 (LotData) to “START” event, and link RPTID(100) and RPTID(101) to “COMPLETED” event.
Add this script to the “Script” box, to check for quality and validate the other variables:
var TransSecsController = Java.type('com.ergotech.transsecs.secs.TransSecsController'); var StringValueObject = Java.type('com.ergotech.vib.valueobjects.StringValueObject'); if (incomingValue.getQuality() === 0) { var map = incomingValue.getProperty("MAP"); if (map !== null) { var controller = TransSecsController.getSingleController(); if (controller !== null) { var name = controller.getControllerName(); if (name !== null) { map.put("EQUIP_ID", new StringValueObject(name)); } } } } incomingValue;
The following steps describe how to set up the database connection and table for the data collection.
Add a Devices node to your project if there is not already one by right clicking on the Project name and selecting “ Add Devices”
To add a DatabaseConnection to enable the connection to your database, right-click item “Devices”, then select “Add DatabaseConnection”
You can rename the DatabaseConnection to another name (do not use spaces in the name) such as MyTestDatabase or whatever you’d like. In this example we will keep the name “DatabaseConnection” for clarity.
Configure the DatabaseConnection parameters: add the driver class name, username, password, and jdbc specific connection string (see the Database Cheat Sheet for hints).
Note: when entering the password you must press the Enter key on your keyboard and then click on another field to make sure the password is entered.
Also: for most databases you can enter the password on the connection url as parameters passed to the database. If you want to do that do not enter the username and password (leave these properties empty).
The next step is to add a place for the S1F3 data to be collected. This is the Historical “table” bean added under the DatabaseConnection node of the Devices node in the TransSECS project.
To add the Historical table for the data, right-click the DatabaseConnection and select “Historical”.
Configure the Historical bean by setting “Create Table” to true. You can change the name of this bean for reference (especially if you plan to use several historical tables in your project). Best practices suggests no spaces in the name and the name must start with a letter.
By setting Create Table to True, TransSECS will manage the schema when creating the table and columns in the database. It will add additional columns if you add more values, but won't delete columns. The VID names will be used as column names and a ReadingTime column will be added and used to record the timestamp of the data.
Again, its important when you set up the database to allow this user to have the CREATE permission so that the table creation is allowed.
The last step is to select the database table to store data.
You've setup database Connection and historical table, under the RPTID configuration, there is a Devices and Tag selector shown in the image below.
Select the Device Name (the database connection name) and the Tag Name (your Historical table bean for this data collection).
This completes the setup of event report data collection. The next step is to build the project, go live with the tool, start collecting data, and check that the data is stored as expected in the database table.
Make sure your tool is running and ready for a host connection. For this test we are using the StandAloneGEMTool running on localhost and listening on HSMS port 5010/id 1.
In TransSECS press the hammer/start button to build the project. When the project is built, toggle the SIM button to LIVE.
On StandAloneGEMTool, select the STARTED event and trigger it, then you can trigger the COMPLETED event. The data should be saved as you trigger the events.
You can check the table you created in the database.
A video guide for how to collect event report data (RPTIDs)and store to a database table also is available on youtube:
https://www.youtube.com/watch?v=SlWOgyQv4kM
For S1F3 polling–another approach of collecting and storing data, from periodic S1F3/S1F4 messages between events, please see this wiki article: TransSECS Host--Configuring S1F3 Polling in TransSECS for a Host Project