+ All Categories
Home > Documents > How to use the Database Interaction Object for SQL ......ASC Process Systems 28402 Livingston Ave....

How to use the Database Interaction Object for SQL ......ASC Process Systems 28402 Livingston Ave....

Date post: 06-Apr-2020
Category:
Upload: others
View: 0 times
Download: 0 times
Share this document with a friend
21
ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 www.aschome.com Document: CPC - Database Interaction Functionality 2.0.docx Page #1 How to use the Database Interaction Object for SQL communications Rev: 2.0 7/24/17
Transcript
Page 1: How to use the Database Interaction Object for SQL ......ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 Document: CPC - Database Interaction Functionality 2.0.docx Page

ASC Process Systems 28402 Livingston Ave.

Valencia, CA 91355 www.aschome.com

Document: CPC - Database Interaction Functionality 2.0.docx

Page #1

How to use the Database Interaction Object for SQL

communications

Rev: 2.0 7/24/17

Page 2: How to use the Database Interaction Object for SQL ......ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 Document: CPC - Database Interaction Functionality 2.0.docx Page

ASC Process Systems 28402 Livingston Ave.

Valencia, CA 91355 www.aschome.com

Document: CPC - Database Interaction Functionality 2.0.docx

Page #2

How to use the DatabaseInteraction object

Rev 2.0 - 7/24/17

The following manual describes the DatabaseInteraction object and how it can be used for bi-directional communications between a customer’s SQL database and CPC.

Table of Contents

CPC Database Interaction Functionality ................................................................................................................................. 2

Table of Contents .................................................................................................................................................................... 2

Purpose ................................................................................................................................................................................... 4

Database structure .................................................................................................................................................................. 4

Table: Runs ......................................................................................................................................................................... 4

Table: TransferLog ............................................................................................................................................................. 5

Table: Parts ....................................................................................................................................................................... 5

Table: PartFields ............................................................................................................................................................... 6

Table: PartAttachments ..................................................................................................................................................... 6

Table: RunData ................................................................................................................................................................. 7

Table: RealtimeData .......................................................................................................................................................... 8

Table: Messages ............................................................................................................................................................... 9

Table: RealtimeMessages ................................................................................................................................................. 9

DatabaseInteraction object ................................................................................................................................................... 10

Load position ..................................................................................................................................................................... 10

Object properties, methods, and scripts ............................................................................................................................ 11

SQL Management Studio ...................................................................................................................................................... 15

Setup of the object ................................................................................................................................................................ 17

Load in an OBF file for the DataIntegration object ............................................................................................................ 17

Connection strings and databases .................................................................................................................................... 17

Add the Calculate task to the tasker .................................................................................................................................. 17

Building a database ........................................................................................................................................................... 18

Initialization and testing a connection ................................................................................................................................ 18

Timing configuration .......................................................................................................................................................... 19

OnCalculate configuration ................................................................................................................................................. 19

Path setup .......................................................................................................................................................................... 19

Post-run parsing .................................................................................................................................................................... 20

Real-time data ....................................................................................................................................................................... 20

Tables for realtime storage ................................................................................................................................................ 20

Properties .......................................................................................................................................................................... 20

Page 3: How to use the Database Interaction Object for SQL ......ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 Document: CPC - Database Interaction Functionality 2.0.docx Page

ASC Process Systems 28402 Livingston Ave.

Valencia, CA 91355 www.aschome.com

Document: CPC - Database Interaction Functionality 2.0.docx

Page #3

Screen control.................................................................................................................................................................... 21

Operations ......................................................................................................................................................................... 21

Page 4: How to use the Database Interaction Object for SQL ......ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 Document: CPC - Database Interaction Functionality 2.0.docx Page

ASC Process Systems 28402 Livingston Ave.

Valencia, CA 91355 www.aschome.com

Document: CPC - Database Interaction Functionality 2.0.docx

Page #4

Purpose

The purpose of the new object is:

Provides a means for CPC to parse datafile after a run and transfer all run information, part information, part attachments, run data, and messages to an SQL database.

Provides a means for CPC to write real-time data (input values) to an SQL database during run.

Provides a means for CPC to write real-time messages to a database during a run.

Provides a means for the customer to transfer batch information (parts and part attachments) to the CPC system during part loading operations.

Provides a means for the customer to feed a recipe name, revision, and crc code to CPC and initiate an automatic or manual load of the specific recipe.

Provides a means for the customer to access raw run data in SQL database form after the run is completed.

Provides a means for the customer to access raw message data in SQL database form after the run is completed.

Database structure

The DatabaseInteraction object will create a SQL database with its Build method. Here’s are the tables and field that are created:

Table: Runs

The Runs table will store a unique record for each run in the equipment.

The RunID field will auto increment and is the primary key. The CPC system will store StartTime, EndTime, Duration, and other fields. The customer’s IT system will store the datetime field called CreatedTime indicating the date/time of record creation. The customer’s IT system will also set the Equipment, Recipe, RecipeDate, and RecipeRevision properties.

The Transfer status field will be written by both CPC and customer. The customer’s system will write a 1 to the field when it has transferred part information to the database, CPC will set it to 2 after successful import into CPC, CPC will then write a 3 after it has transferred run data to the database, and lastly the customer will write a 4 when it has successfully imported the data after the run.

FieldName DataType Comments

RunID Int Identity and Primary Key

Equipment Nchar(20) Name of equipment, set by customer

CreatedTime Datetime Set by customer system

StartTime Datetime Start of run, set by CPC at beginning of run

EndTime Datetime End of run, set by CPC at end of run

TransferStatus tinyint 1 = customer set parts, 2 = CPC imported parts, 3=CPC exported data, 4 = customer imported data

Duration Real Duration of run in minutes

Datafile Nchar(100) Path and filename of datafile

Recipe Nchar(100) Name of recipe

Page 5: How to use the Database Interaction Object for SQL ......ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 Document: CPC - Database Interaction Functionality 2.0.docx Page

ASC Process Systems 28402 Livingston Ave.

Valencia, CA 91355 www.aschome.com

Document: CPC - Database Interaction Functionality 2.0.docx

Page #5

RecipeDescription Nchar(100) Description of recipe (used for SaveAllData)

RecipeRevision Nchar(4) Revision of recipe

RecipeCRC Int CRC for Recipe

Operator Nchar(50) Operator name (used for SaveAllData)

LoadNumber Int Load number (used on some systems)

Table: TransferLog

This table is an audit log of transfer activities by customer’s IT system and CPC systems. Both parties will write messages to this log.

FieldName DataType Comments

LogID Int Unique, auto-number identify field, primary key

RunID Int Link to RunID in Runs table

Source Nchar(10) Set to ASC or customer

Message Nchar(100) Message indicating what happened.

Table: Parts

This table stores part data. This part information is either preloaded by the customer’s external programming or the records can be stored by CPC at the end of the run.

If the customer is pre-loading the part and batch information, CPC will modify the contents if part information changed during the run. CPC will also write the LeakRequirement and Leakvalue for the vacuum leak test.

FieldName DataType Comments

PartID Int Unique, auto-number identify field, primary key

RunID Int Link to RunID in Runs table

PartIndex Smallint Indicates position in list (1,2,3,4)

ParentPartIndex Smallint For multiple parts that are under one bag.

LeakRequirement Real

LeakValue Real

PartField1 Nchar(100) Value of 1st part field. (see PartFields)

PartField2 Nchar(100) Value of 2nd part field. (see PartFields)

PartField3 Nchar(100) Value of 3rd part field. (see PartFields)

PartField4 Nchar(100) Value of 4th part field. (see PartFields)

PartField5 Nchar(100) Value of 5th part field. (see PartFields)

PartField6 Nchar(100) Value of 6th part field. (see PartFields)

PartField7 Nchar(100) Value of 7th part field. (see PartFields)

Etc…

Page 6: How to use the Database Interaction Object for SQL ......ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 Document: CPC - Database Interaction Functionality 2.0.docx Page

ASC Process Systems 28402 Livingston Ave.

Valencia, CA 91355 www.aschome.com

Document: CPC - Database Interaction Functionality 2.0.docx

Page #6

Table: PartFields

This table is used to map CPC part database fields to Parts table field names. For example, PartField1 in the SQL database could be matched to WorkOrder in the CPC system. CPC will only load the fields identified in the PartFields table, even though there are more fields defined in the Parts table (ie. PartField15, PartField16, etc.).

FieldName DataType Comments

FieldID Int Unique, auto-number identify field, primary key

SQLFieldName Nchar(30) Name of SQL field name in Parts table

CPCFieldName Nchar(30) Name of CPC part field object (see Part Templates)

Table: PartAttachments

This table is used to identify part attachments on specific parts. For every attachment (ie. VSRC1, VPRB3, PTC4), the customer’s IT system will create an attachment, set it’s name (ie. PTC14), type (S,P,or T), and set it’s index (ie. 14)

FieldName DataType Comments

AttachmentID Int Unique, auto-number identify field, primary key

RunID Int Link to RunID in Runs table.

PartID Int Link to PartId in Parts table.

AttachmentName nchar(10) Name of input (ie. PTC18)

AttachmentType nchar(10) “PartTC” or “Probe” or “Source”

AttachmentIndex tinyint Index of specific attachment. (ie. 18 for PTC18)

DisableOnStart Bit Disable thermocouple on start

Page 7: How to use the Database Interaction Object for SQL ......ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 Document: CPC - Database Interaction Functionality 2.0.docx Page

ASC Process Systems 28402 Livingston Ave.

Valencia, CA 91355 www.aschome.com

Document: CPC - Database Interaction Functionality 2.0.docx

Page #7

Table: RunData

This table is used to store the run data after the run completes. After the run completes, the SaveData or SaveAllData methods will store datafile information to this table. Each datapoint will represent one complete interval of data.

The table includes a RunID field, date and elapsed time fields, and for each input on the system, a field for the value of the input (ie. 75.4) and a field to indicate whether the input is enabled or not (ie. PTC1ENABLED).

FieldName DataType Comments

DatapointID Int Unique, auto-number identify field, primary key

RunID Int Link to RunID in Runs table

RunDateTime Datetime Date and time of day of datapoint

RunElapsedTime Real Number of minutes into run

PTC1 Real Value of part thermocouple #1

PTC1ENABLED Bit Indicates enabled (1) or disabled(0)

PTC2 Real Value of part thermocouple #2

PTC2ENABLED Bit Indicates enabled (1) or disabled(0)

PTC2 Real Value of part thermocouple #2

PTC2ENABLED Bit Indicates enabled (1) or disabled(0)

Continue for each input. Only PTC inputs will have “ENABLED” partner fields.

Page 8: How to use the Database Interaction Object for SQL ......ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 Document: CPC - Database Interaction Functionality 2.0.docx Page

ASC Process Systems 28402 Livingston Ave.

Valencia, CA 91355 www.aschome.com

Document: CPC - Database Interaction Functionality 2.0.docx

Page #8

Table: RealtimeData

This table is used to store the input values in real-time. This data has not link to a run nor to parts. This table will only be created with the Build method if the Realtime properties are configured (see Realtime data section in manual)

The fields include DataTime (date and time of record), and the value and status of each input configured on the system.

FieldName DataType Comments

DatapointID Int Unique, auto-number identify field, primary key

DataTime Datetime Date and time of day of datapoint

PTC1 Real Value of part thermocouple #1

PTC1ENABLED Bit Indicates enabled (1) or disabled(0)

PTC2 Real Value of part thermocouple #2

PTC2ENABLED Bit Indicates enabled (1) or disabled(0)

PTC2 Real Value of part thermocouple #2

PTC2ENABLED Bit Indicates enabled (1) or disabled(0)

Continue for each input.

Page 9: How to use the Database Interaction Object for SQL ......ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 Document: CPC - Database Interaction Functionality 2.0.docx Page

ASC Process Systems 28402 Livingston Ave.

Valencia, CA 91355 www.aschome.com

Document: CPC - Database Interaction Functionality 2.0.docx

Page #9

Table: Messages

This table is used to store the message data post-run. This table is only updated with the SaveData and SaveAllData method, which parses the currently tagged datafile (DataAnalyze object). This is NOT used for real-time

FieldName DataType Comments

MessageID Int Unique, auto-number identify field, primary key

RunID Int Link to RunID in Runs table

MessageIndex Smallint Sequential index of each message in run.

MessageTime DateTime Date and time of day of message

ElapsedTime Real Current runtime in minutes

MessageText Nchar(100) Text of message in CPC

MessageType nchar(10) System, or Alarm, or Manual, or…

Part Smallint Index of part associated with alarm message

TagName Nchar(10) Name of sensor generating alarm

Value Nchar(10) Value of sensor that generated alarm

Criteria Nchar(10) Comparison and alarm value (ie. >)

Setting Nchar(10) Value of alarm setting.

Table: RealtimeMessages

This table is used to store the real-time messages. Each message that occurs will be logged to this table. These records have no link to the run.

FieldName DataType Comments

MessageID Int Unique, auto-number identify field, primary key

MessageIndex Smallint Sequential index of each message in run.

MessageTime DateTime Date and time of day of message

MessageText Nchar(100) Text of message in CPC

MessageType nchar(10) System, or Alarm, or Manual, or…

Part Nchar(3) Index of part associated with alarm message

TagName Nchar(10) Name of sensor generating alarm

Value Nchar(10) Value of sensor that generated alarm

Criteria Nchar(10) Comparison and alarm value (ie. >)

Setting Nchar(10) Value of alarm setting.

Page 10: How to use the Database Interaction Object for SQL ......ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 Document: CPC - Database Interaction Functionality 2.0.docx Page

ASC Process Systems 28402 Livingston Ave.

Valencia, CA 91355 www.aschome.com

Document: CPC - Database Interaction Functionality 2.0.docx

Page #10

DatabaseInteraction object

The new DatabaseInteraction handles all of the communications with the SQL database.

Object position

The object can be located anywhere in the object structure, but we recommend that it be placed on the main level (ie. .DatabaseInteraction) or as a child of the the specific equipment object.

Here’s an example of the object located below the Equipment object.

As a child of the Autoclave object, and positioned below the DataManager object.

Page 11: How to use the Database Interaction Object for SQL ......ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 Document: CPC - Database Interaction Functionality 2.0.docx Page

ASC Process Systems 28402 Livingston Ave.

Valencia, CA 91355 www.aschome.com

Document: CPC - Database Interaction Functionality 2.0.docx

Page #11

Object properties, methods, and scripts

The object is shown below.

Page 12: How to use the Database Interaction Object for SQL ......ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 Document: CPC - Database Interaction Functionality 2.0.docx Page

ASC Process Systems 28402 Livingston Ave.

Valencia, CA 91355 www.aschome.com

Document: CPC - Database Interaction Functionality 2.0.docx

Page #12

Enabled – A true or false indicating whether the object is functional.

Description – text describing the object. Optional.

ConnectionString – SQL connection string used to connect to the database. Standard convention apply. The above example was used to connect to a local SQLEXPRESS database.

Interval – Time entry (ie. 5S) which is used to regulate the operation of the object. When an interval is entered, the object and the OnCalculate quick-script will be regulated to occur once every interval. This provides a regulation on the communication to the database primarily for the method “GetTransferStatus”

LastTime – used by the system to calculate the interval.

OpenStatus – True or False, indicating whether there is an open connection to the database. This property is only updated by the GetOpenStatus method.

TransferStatus – This is set when the GetTransferStatus method is executed. The TransferStatus is a field in the Runs table which is used by both CPC and the customer to indicate the status of run communications.

1 = Customer has created a new Run record and has written part information to the database.

2 = CPC has loaded the parts into the system.

3 = CPC has written data to the database after the run.

4 = Customer has read the run data, messages, and part information from the database.

RunID - This property value is created automatically by the SQL engine during creation of the Runs table record. CPC fetches this information from the most current record during the GetTransferStatus method.

Recipe - This property value is set by the customer in the Recipe field of the Runs table. CPC fetches this information from the most current record during the GetTransferStatus method. The Recipe property is then used for the LoadRecipe method.

RecipeRevision - This property value is set by the customer in the RecipeRevision field of the Runs table. CPC fetches this information from the most current record during the GetTransferStatus method. The RecipeRevision property is then used for the LoadRecipe method for validating the recipe.

RecipeCRC - This property value is originally created by the customer in the Recipe field of the Runs table. CPC fetches this information from the most current record during the GetTransferStatus method. The RecipeCRC property is then used by CPC to validate the recipe. The CRC calculation for the recipe must match the CRC value passed in the database for successful load of the recipe.

RecipeLoadStatus – This property is True if the recipe loaded correctly and false if it didn’t. This property is used to initiate alarming and screen status of the transfer.

RecipeLoadMessage – This property holds the message describing the status of the recipe load process. If the load occurred properly, the message will read “LoadRecipe complete”. If there was an error, the error message will be displayed.

ActionError – This property is True if there was an error during the last method call. The value is false if the method occurred properly. This property is used to initiate alarming and screen status of the transfer.

ActionMessage – This property shows the status of the last method call. If there were no errors, the message will indicate that the action was “complete”. If there was an error, the message will show a description of the error.

RecipeProcessorPath – object path to the RecipeProcessor object. This path is used by the object to find the RecipeProcessor object for use in the LoadRecipe method.

DataAnalyzePath – object path to the DataAnalyze object. This path is used by the object to find the DataAnalyze object for use in the SaveData method.

CurrentBatchPath – object path to the CurrentBatch object. This path is used by the object to find the CurrentBatch object for use in the LoadParts method.

Page 13: How to use the Database Interaction Object for SQL ......ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 Document: CPC - Database Interaction Functionality 2.0.docx Page

ASC Process Systems 28402 Livingston Ave.

Valencia, CA 91355 www.aschome.com

Document: CPC - Database Interaction Functionality 2.0.docx

Page #13

InputsPath – object path to the Inputs object. This path is used by the object during the AddDataFields method as well as the LoadParts method.

OutputsPath – object path to the Inputs object. This path is used by the object during LoadParts method.

Calculate – this is a method that is initiated by a Tasker object. The method calculates the interval timer and if the interval has expired will execute the OnCalculate script. No database functions are implicitly called during a Calculation, unless those methods are executed from within the OnCalculate script.

OpenConnection – this method opens the connection to the database using the current ConnectionString. The method will update ActionError and ActionMessage properties, but will not automatically return the OpenStatus property. You will have to run the GetOpenStatus method to query the open status of the connection. In normal operation the opening of the connection will be handled by the OnCalculate custom quick-script.

CloseConnection – this method closes the current connection to the database. The method will update the OpenStatus property as well as the ActionError and ActionMessage properties. In normal operation the connection will be closed after the parts have been loaded and will not be opened again until the run has completed.

GetOpenStatus – this method queries the connection object and signals whether the connection is still open. The method will update the OpenStatus property as well as the ActionError and ActionMessage properties.

GetTransferStatus – this method opens the Runs table and loads information from the most recent record. The information loaded and properties updated includes the following:

RunID – the unique identifier for the run

TransferStatus – the numeric code indicating the phase of bi-directional communications.

Recipe – the name of the recipe, as set by the customer

RecipeRevision – the revision of the recipe

RecipeCRC – the CRC code to be used to validate the recipe

The method also updates the ActionError and ActionMessage properties.

SetTransferStatus – this method is used to write the TransferStatus property to the most recent record of the Runs table. This is usually managed by custom programming in the OnCalculate quickscript.

LoadParts – this method will initiate the following steps:

1. System will delete all parts in the current batch.

2. System will open the Parts, PartFields, and PartAttachments table in the database and load all information keyed to the current RunID.

3. System will create part objects, part attachment objects, and part field objects according to the information loaded from the database.

4. System will set the ActionError and ActionMessage accordingly.

LoadRecipe – this method will initiate the following steps:

1. System will check that a run is not in progress. If running, the load operation will fail.

2. System will attempt to find a recipe with the same name. It will propogate in main recipe tree and also in recipe folders.

3. Once discovering the recipe, it will confirm that the most current revision in the recipe matches the RecipeRevision as identified by the customer’s field value. If there is a mismatch, the load operation will fail.

4. Upon successful revision match, the system will check for the CRC requirement. If the RecipeCRC field value is 0, no CRC checking will occur. If the RecipeCRC value is positive, the system will calculate the CRC of the recipe and compare to the RecipeCRC value. If there is a match, the recipe will be loaded. If there is a failure, he recipe load will fail.

Page 14: How to use the Database Interaction Object for SQL ......ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 Document: CPC - Database Interaction Functionality 2.0.docx Page

ASC Process Systems 28402 Livingston Ave.

Valencia, CA 91355 www.aschome.com

Document: CPC - Database Interaction Functionality 2.0.docx

Page #14

5. System will set the RecipeLoadStatus, RecipeLoadMessage, ActionError and ActionMessage accordingly.

SaveData – this method will initiate the following steps:

1. System will scan the DataAnalyze object and find the most current datafile. This is normally set after the run is completed.

2. System will load the datafile and parse relevant information.

3. The most recent record in the Runs table will be updated with StartTime, EndTime, and Duration of the run.

4. The RunData table will be updated with all data intervals, keyed to the current RunID

5. The Messages table will be updated with all messages, keyed to the current RunID.

6. System will set the ActionError and ActionMessage accordingly.

AddDataFields – this method will cause CPC to add fields to the RunData table for each of the inputs in the Inputs object. This operation is usually performed with a new database, however subsequent operations will be non-destructive. The ActionError and ActionMessage properties will also be updated.

OnCalculate – this quickscript is used for custom programming used to automate the methods and properties of the object.

SaveLeakTest – this method is used prior to a run start to save the current leaktest values to the specific part field. This is only needed in situations where the part information was created by the customer’s remote system.

DatabaseToBuild – the name of the database to build using the method BuildDatabase

CommandToExecute – this command text can be sent to the SQL server using the Execute method.

MasterConnectionString – this property is used by the BuildDatabase method and points to the Master database of the specific SQL server.

Execute – this method performs a SQL execute of the command contained in CommandToExecute property.

BuildDatabase – this method creates the database and adds tables and fields.

SaveAllData – this method loads, parses, and stores the data contained in the datafile to the SQL database. This method requires that the connection be open prior to executing and that the DataAnalyze datafile properties be set prior to running.

EquipmentPath – path to the description property of the equipment object. (ie. .Autoclave\Description). You can also target another property if you don’t want to use the equipment object (ie. .Autoclave.Variables.DBEquipment\Value).

Realtime properties – see “Realtime data” section later in this manual.

Page 15: How to use the Database Interaction Object for SQL ......ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 Document: CPC - Database Interaction Functionality 2.0.docx Page

ASC Process Systems 28402 Livingston Ave.

Valencia, CA 91355 www.aschome.com

Document: CPC - Database Interaction Functionality 2.0.docx

Page #15

SQL Management Studio

In order to check the SQL operations, you’ll need to use the SQL Management Studio software. You can get this client software by installing SQL Server 2012 Express on your local machine. This is also a great way of testing SQL connection locally before you connect to a customer SQL database.

Here’s how to logon to Management Studio locally. In the example below, the ASSET4792 is a specific computer name. You can replace with your local computer or it can be a remote SQL server machine.

Here’s the view of some databases in SQL. You can expose tables and other information from the

Page 16: How to use the Database Interaction Object for SQL ......ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 Document: CPC - Database Interaction Functionality 2.0.docx Page

ASC Process Systems 28402 Livingston Ave.

Valencia, CA 91355 www.aschome.com

Document: CPC - Database Interaction Functionality 2.0.docx

Page #16

You can expose the tables for each database created.

You can right-click on each table and select “Select Top 1000 Rows” to view the current data records.

Here’s the view. You can refresh the table view by typing <F5<

Page 17: How to use the Database Interaction Object for SQL ......ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 Document: CPC - Database Interaction Functionality 2.0.docx Page

ASC Process Systems 28402 Livingston Ave.

Valencia, CA 91355 www.aschome.com

Document: CPC - Database Interaction Functionality 2.0.docx

Page #17

Setup of the object

The object must be setup before communications can occur.

Load in an OBF file for the DataIntegration object

If requested, ASC can provide a pre-configured object to you. You can load the .obf file by opening the object editor, double-clicking on autoclave, click once on DataManager, and then right-click and select LoadFromFile. Select the DataIntegration.obf file from disk and the system will load the object into the tree.

Connection strings and databases

The object includes a number of properties that must be configured to talk to the different SQL versions and databases. In order to connect to a database, you must setup a valid ADO.DB connection string. You can find samples of this on the Internet by searching “SQL connection strings”. There are different connection strings depending on the version of SQL and the type of security authentication.

Here’s a typical connection string for connecting to a local SQLEXPRESS 2012 database called “Normal” which has a user and password. This SQL assumes a username = User and a password = Open.

Provider=SQLNCLI11; Data Source=.\SQLEXPRESS; Database=Normal; user id=user; password=open

ConnectionString – This property should point to the main database used for storing post-run datafile information.

DatabaseToBuild – this property holds the name of the database used in ConnectionString (ie. Normal). This is used during the Build method.

RealtimeConnectionString – This property can be blank, which would then default to the same connection string as in ConnectionString. You can also define a different SQL provider and/or different database. Here’s an example where real-time information will be stored to a different database in the local SQLEXPRESS 2012 system:

Provider=SQLNCLI11; Data Source=.\SQLEXPRESS; Database=Realtime; user id=user; password=open

RealtimeDatabase – this property holds the name of the database defined in the RealtimeConnection string (ie. Realtime). This name will be used for the Build method.

Add the Calculate task to the tasker

The object’s Calculate method must be added to the tasker of your specific equipment. The task object should run the Calculate method of the object.

The Calculate method is required for the real-time data saving operations and also is used to run the OnCalculate script. Although the Calculate method will be called at the same performance of the tasker, the Interval property of the object will slow the calculation to a reasonable interval (ie. 5S or 10S).

Page 18: How to use the Database Interaction Object for SQL ......ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 Document: CPC - Database Interaction Functionality 2.0.docx Page

ASC Process Systems 28402 Livingston Ave.

Valencia, CA 91355 www.aschome.com

Document: CPC - Database Interaction Functionality 2.0.docx

Page #18

Building a database

You must first ensure that the DatabaseInteraction object can talk to the SQL server. Testing this on the local SQL Express database is the easiest to test.

Once SQL is setup and you have created valid connections strings, you can use the Build method to create and build the empty database(s). Once created, you can use the SQL Management Studio to view the database and confirm operation.

CPC handles the creation and table/field creation. The Build method uses the MasterDatabase, DatabaseToBuild, and RealtimeDatabase properties.

MasterConnectionString – This should point to the Master database in the SQL server. Here’s an example:

Provider=SQLNCLI11; Data Source=.\SQLEXPRESS; Database=Master; user id=user; password=open

DatabaseToBuild – This is the name of the database to build. In the example in the connection string above, this would be: Normal.

RealtimeDatabase – This is the name of the real-time database used to store the real-time tables. This can be different than the main database. Example: Realtime

When you have successfully built a database, the Management Studio will show the database. You can click on “Databases” node and press <F5> to refresh the studio’s tree.

Initialization and testing a connection

Once the database is created, you must initialize and open the connection prior to communication. This initializing is normally automated in either the OnStartup script of the Server object or it can be handled in the OnCalculate script of the DatabaseInteraction object (see above). Initializing is performed with the OpenConnection method.

You can test whether you have a valid connection by manually running the OpenConnection method and then viewing the ActionMessage, OpenStatus, and RealtimeOpenStatus. You should do this after you have added the

Here’s what you should see if the connection opens properly.

If you are also storing real-time data to a different database, you’ll see the results of that connection as well.

Note: You can add an alarm objects to monitor the OpenStatus and RealtimeOpenStatus properties. These alarms will notify the operator if the database open status is False. You should also add these to the Status screen.

If you can’t get the connection to open, make sure you have proper security credentials in your connection strings and that your database is already built. You can view databases using the SQL Database Management Studio application.

Page 19: How to use the Database Interaction Object for SQL ......ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 Document: CPC - Database Interaction Functionality 2.0.docx Page

ASC Process Systems 28402 Livingston Ave.

Valencia, CA 91355 www.aschome.com

Document: CPC - Database Interaction Functionality 2.0.docx

Page #19

Timing configuration

Timers are used for a couple of processes within the DatabaseInteraction object.

Interval – this property should hold a value of 5S or 10S. This is a delay that is used to trigger the calculation at a slower interval than the Task object’s performance. A value of 5S will cause the OnCalculate script to execute every 5 seconds.

RealtimeInterval – this property defines the interval used to store realtime input values during real-time database saving. This is normally set for 60S or 2M. Do not set this too short due to slow-down in CPC performance.

OnCalculate configuration

The OnCalculate script is used for automating the bi-directional communications of the object, and it can be used for initializing the object.

Here’s the code that will automatically open a connection when CPC starts tasking the DatabaseInteraction object:

Path setup

There are a number of paths that must be configured before the object is first opened. These should point to the specific objects identified:

There is also another path that should point to the property used for the Equipment name. This can target the Description property of the Equipment object (ie. .Autoclave\Description) or you can target a variable value. This defines the name of the equipment for parsing of datafiles.

There are also a number of other path properties in other objects that must be set to target the DataInteraction object.

MessageManager object. This instructs the message manager to route messages to the real-time records of the database.

Checks object. This instructs the Checks object to update the part information with leak-test information. This is only used for configurations where the customer’s IT system is passing part information to CPC.

Page 20: How to use the Database Interaction Object for SQL ......ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 Document: CPC - Database Interaction Functionality 2.0.docx Page

ASC Process Systems 28402 Livingston Ave.

Valencia, CA 91355 www.aschome.com

Document: CPC - Database Interaction Functionality 2.0.docx

Page #20

Post-run parsing

To parse and transfer data at the end of the run, you must put the following code in your AfterEndRun script. This must be placed after you have set the DataAnalyze datafilename properties.

Real-time data

Real-time saving of information is different than the post-run parsing and saving. In real-time mode, the system will store input values at a predefined interval and messages (ie. Alarm, System, Manual) will also be saved.

Tables for realtime storage

When you setup a valid connection string and database name, the “Build” method will create the realtime tables. The realtime tables are:

RealtimeData – stores input values and input status with each column named by input name. This also includes a DataTime column which stores the date/time of the save record.

RealtimeMessages – used by the system to store realtime alarm and other types of messages. This requires that the DatabaseInteractionPath property in the MessageManager be properly configured to the Databaseinteraction object.

Properties

RealtimeConnectionString - This property defines the ADO-DB connection string to the database used for real-time data saving. The DatabaseInteraction object allows the real-time data to be saved to a different provider and database.

If the property is blank, the real-time tables will be stored to the normal database defined in the ConnectionString.

RealtimeDatabaseName - This property sets the name of the databasedefines the ADO-DB connection string to the database used for real-time data saving. The DatabaseInteraction object allows the real-time data to be saved to a different provider and database.

It’s important to note that this database name must match exactly the database identified in the RealtimeConnectionString (ie. Database=Realtime)

It’s also important that if the RealtimeConnectionString is blank, the RealtimeDatabaseName must be the same as the property DatabaseToBuild.

RealtimeOpenStatus - This property identifies if the database connection is open or closed. If True, the real-time data will be activated.

Page 21: How to use the Database Interaction Object for SQL ......ASC Process Systems 28402 Livingston Ave. Valencia, CA 91355 Document: CPC - Database Interaction Functionality 2.0.docx Page

ASC Process Systems 28402 Livingston Ave.

Valencia, CA 91355 www.aschome.com

Document: CPC - Database Interaction Functionality 2.0.docx

Page #21

RealtimeEnable - This property turns on the real-time input saving. When enabled, the system will store input values to the RealtimeData table at the interval defined by “RealtimeInterval” property.

RealtimeInterval - This property is used to define the interval at which the system will store real-time data (input values) to the RealtimeData table.

RealtimeLastTime - This property is set by the system and is used to keep track of the next interval.

SaveRealtimeData - This method is used for storing a non-interval save to the RealtimeData table.

Screen control

It’s a good thing to setup DatabaseInteraction enabling in your Support Screen. You should allow the operator to enable or disable the operation of the SQL as well as the RealtimeEnable property. You can also give them the ability to set a different RealtimeInterval property value.

Operations

Once everything is configured, you can turn on the RealtimeEnable to True and the Calculate method will begin to execute real-time data saving. You can confirm this in the Management Studio.

You can also test the message saving by going to the Message Screen and enter an Operation Message. You can then view the RealtimeMessages table in the database to ensure that the messages were stored.


Recommended