NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

key format of database

Hello,

I would like to log results to a single Access database from multiple computers.

So I use the schema : Generic Insert (and not the Generic Recordset). (see Configure->Database Options->Schemas)

As a result, I've a primary key which is a GUID value.
In my Access table, the primary key looks like at : "1E6CB419-9954-47A1-80AC-...".
I'm not satisfied of this format of value. I prefer a numeric value (because my database already exists, and the primary key was a numeric value).

How can I have a numeric value for my keys, and log results to a single Access database from multiple computers?

Chris. (TestStand 2.0)
0 Kudos
Message 1 of 3
(3,141 Views)
Chris -
Unfortunately TestStand does not allow you to specify an arbitrary expression for a column that is designated as a primary key. Because of this limitation, the database logging feature cannot keep track of the value that was specified for a primary key and use it later when a table uses it as a foreign key. So this means that to write out key values, you need to keep track of them yourself in some way. In addition you would most likely not be able to use the STEP_PARENT column in a table. Below is a possible way of logging to a database as you asked.


Basic Requirement:
You need a way to guarentee that the primary key value that is generated by each computer for a single table that holds either UUT or step information does not conflict. In addition, the values that are generated by a single computer must increment without overlap.


Example:
You could use a unique base value for each computer and use an incrementing value per computer to make the key values for each level of table.

On each station, you could create the following station global values:

StationGlobals.ComputerBaseValue = xx0000000
StationGlobals.ComputerUUTKeyValue = 0
StationGlobals.ComputerStepKeyValue = 0
StationGlobals.ComputerOtherKeyValue = 0

Of course you would have to alter the database tables to use integer values for their key values.

For each primary and foreign key column defined in the Generic Insert schema, you would have to turn off the primary key and foreign key checkboxes, change the data type from GUID to Integer, and then use the following expressions to generate the key values:

UUT_RESULT
ID: "++StationGlobals.ComputerUUTKeyValue + StationGlobals.ComputerBaseValue"

STEP_RESULT
ID: "++StationGlobals.ComputerStepKeyValue + StationGlobals.ComputerBaseValue"
UUT_RESULT: "StationGlobals.ComputerUUTKeyValue + StationGlobals.ComputerBaseValue
STEP_PARENT: (You must delete this column from the schema and remove from the INSERT statement in the schema)

STEP_PASSFAIL:
ID: "++StationGlobals.ComputerOtherKeyValue + StationGlobals.ComputerBaseValue"
STEP_RESULT: "StationGlobals.ComputerStepKeyValue + StationGlobals.ComputerBaseValue


So the key values would look something like this:

xx0000000
xx0000001
xx0000002
xx0000...


Note that when using this methodology you should only log one UUT at a time on a single computer. If you must run parallel executions you should use a mutex to prevent two executions on a single computer from logging at once.

Note that if the TestStand process exits without saving the station globals file, the next execution that logs to the database might reuse key values. Depending on your constrainst this might error. You might have to manually fix the station global values when this happens.


Scott Richardson
Scott Richardson
https://testeract.com
Message 2 of 3
(3,141 Views)
Hello Scott,

I'm facing the same requirement (multiple PCs logging data into some data base in a remote PC).

1. Can I assume that the schema I need to use is Generic Insert? We haven't started to collect data seriously, as we are only experimenting with it.

2. What GUID stands for?

3. Since each PC have a differnt STATION_ID, can't I just use a primary key consist of ID (integer) + STATION_ID? I guess it means that I must add the STATION_ID key to all the tables.

What is your openion about it? The reason I bring it up is because the GUID key looks so complicated/not practaical to use... or am I wrong?

4) In the schema, when I look at the expression related to the different fields/columns, some of them appear in red color. Why is that?


Thank you
Rafi
0 Kudos
Message 3 of 3
(3,141 Views)