NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

setup database dynamically

We read a partnumber in the Pre UUT Callback and want to use that partnumber to choose the database to log to.  If I set RunState.Caller.Locals.DatabaseOptions.ConnectionString  from the Pre UUT Callback, this works only for the first device.  It seems that the database is hold open until the OI is closed. And any later changes in the  ConnectionString for/from  the next device aren't honored any more.  Is possible to change the database  once it is opened using the standart sequencial model of Teststand 7.1 ?  

 

 
0 Kudos
Message 1 of 13
(4,690 Views)

Hi Markus,

Try RunState.Root.Locals.DatabaseOptions.ConnectionString.

but if you are in Pre-Uut why don't you use just Locals.DatabaseOptions.ConnectionString

Greetings

Juergen

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 2 of 13
(4,687 Views)
Locals.DatabaseOptions.ConnectionString exists in the model sequence. There is no Locals.DatabaseOptions.ConnectionString in the pre-UUT callback of the client sequence available ( at least in TestStand 7.1). So I have to go one level above with Runstate.Caller... And problem is not that the changed ConnectionString doesn't reach the databasequence, but that it is evaluated only once ( before logging the first device). And any change later seems to be ignored.
0 Kudos
Message 3 of 13
(4,676 Views)

Hi Markus,

oh, yes I told you no sense!! if you are in Pre Uut there wil be no only the locals of Pre Uut !! Sorry.
But what about trying Root instead Caller. I tried this in TS 4.0 and it worked

Just set a Break point in LogToDatabase  you will see that it work

Greetings

Juergen

 

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 4 of 13
(4,669 Views)

Setting a breakpoint in the Databasesequence shows that Parameters.DatabaseOptions.ConnectionString does hold the expected changed value. But nevertheless TestStand still logs to the same database as opened for the first device. 

We are using an Access database as backend, which creates a <database>.ldb lockfile when you are accessing <database>.mdb. And that lockfile exists still after logging the data to the database for the first device is finished and it never changes. And is removed only, when you leave the UUT loop by terminating the sequence. So I'am quite sure that  ITSDBLog.LogResult(), which is called to do the database logging, just ignores any changed value of ConnectionString once is has opened a database but just holds the allready opened database open until you close the sequence. An single stepping when terminating the sequence also didn't reveal any step, which seems to close the database link. The lock was removed when a new sequence execution was started. Is there any easy way to change that behaviour ?



Message Edited by markus kossmann on 03-17-2008 08:30 AM

Message Edited by markus kossmann on 03-17-2008 08:32 AM
0 Kudos
Message 5 of 13
(4,649 Views)

Hi Markus,

Are you closing the database using the Close Database step somewhere are the end of your Sequence?

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 6 of 13
(4,642 Views)
No, I'am using the standart database logging sequence and basically the Sequential Model  of TestStand-3.1. There seems to be no Close Database step in these sequences.
0 Kudos
Message 7 of 13
(4,639 Views)

Hi Markus,

That was a bit a stupid question of mine, I was think you were using the Database step types. Smiley Sad

Had a quick look at the Database logging code, can't see where its is releasing the database. If its in one the destructors, then it might be performed because TestStand is keeping the objects in memory.

What you could try is added a couple of steps to the Close DB Handles sequences, on the Open the database using the setting in the DatabaseOptions and the second to close the database. This sequence is called in the Cleanup of the ProcessModel.

Regards

Ray Farmer

Regards
Ray Farmer
0 Kudos
Message 8 of 13
(4,630 Views)

Hi Ray;

It's not clear to me how to access the Database handles created by the LogResults Method of TSDBLog ( which is called from the Database sequence to log the data) from  TestStand.  

0 Kudos
Message 9 of 13
(4,626 Views)

Hi Markus, Hi Ray

Just an addition on Ray's answer. What are you thinking about "rewriting" the model. I think if you put all the DB-SequenceCalls into the loop of an UUT this should work. Place Get Database Options after PreUUT Callback and CloseDBHandles before PostUUT Callback.

Hope this helps.

Greetings

juergen

--Signature--
Sessions NI-Week 2017 2016
Feedback or kudos are welcome
0 Kudos
Message 10 of 13
(4,609 Views)