NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Create sequence from template

Solved!
Go to solution

Hi all!

I'm developing a test application using Teststand 2.0 (which is requires by the customer, so i cannot upgrade) , i need to create a new sequence or a set of sequnces based on pre written templates.

 

Adding a voice to to the tools menu that creates the new seq from the template would be ok.

 

i searched the forums and i found the thread:

 

http://forums.ni.com/ni/board/message?board.id=330&message.id=3438&query.id=305522#M3438

 

 

 here is what i managed to do so far

 

1) I call the IEngine.GetSequenceFile() with my template path to get the seqfile handle.

 

2) I use the PropertyObject.Clone() method to duplicate th sequence ad retrerive the new handle.

 

3) I save the new sequence with the SequenceFile.Save method.

 

4) I open the new sequence in the editor interface by using the function Runstate.Thread.PostUIMessageEX .

 

the parameters passed to this last call are 

 

eventCode = UIMsg_OpenWindows

numericDataParam = 0

stringDataParam = "MainSequence"

activeXDataParam = Locals.ClonedSeqFile // this is the handle to the sequence cloned from the template

syncronous= false

 

 

with the code above i can create a new sequence , save it and open it in the editor. 

What i need to do is open the sequence in the editor WITHOUT saving it, since it's just a new file template (the usere must be prompted for a path when saving it).

If i remove the third step the sequence gives me an error.

 

SO the question is is there a way ot create a sequence handle and open it in the editor before saving the file to disk?

 

Thanks in advance!!

 

Marco

 

 

 

0 Kudos
Message 1 of 4
(3,432 Views)

Hi Marco, you're quite right. For making things correctly you don't need to save the cloned sequence File; instead, just set a Sequence File display name (es. "New sequence file template") through the DisplayName property and then increment the Change Count associated with the clone in order to set it as "modified" (and putting an asterisk next to the display name into the sequence editor).

 

So you must do (my suggestions in bold) : 

 

  1. Call the IEngine.GetSequenceFile() with my template path to get the seqfile handle
  2. use the PropertyObject.Clone() method to duplicate the sequence and retrerive the new handle
  3. Set sequence file display name for the clone by accessing PropertyObjectFile.DisplayName property
  4. Increment the ChangeCount for the clone by calling PropertyObjectFile.IncChangeCount method
  5. open the new sequence in the editor interface by using the function Runstate.Thread.PostUIMessageEX .

     

    the parameters passed to this last call are 

     

    eventCode = UIMsg_OpenWindows

    numericDataParam = 0

    stringDataParam = "MainSequence"

    activeXDataParam = Locals.ClonedSeqFile // this is the handle to the sequence cloned from the template

    syncronous= false

  6. Remember to release the handles associated to the original Sequence File and to the clone too, in order to avoid memory leaks.

Hope this helps!

 

Best Regards,

 

Fabio

Fabio M.
NI
Principal Engineer
0 Kudos
Message 2 of 4
(3,396 Views)

Hi Fabio, first of all thanks for the reply.

 

I tried to add the steps you suggested in your reply but i still got an error with the "Runstate.Thread.PostUIMessageEX" method: when i try to open a sequence that is not saved to the disk (even if i know the handle)  it gives me a 'Could not find file *."' error

 

Maybe i misunderstood something of you explanation... 

 

Thanks in advance!

 

Marco.

0 Kudos
Message 3 of 4
(3,378 Views)
Solution
Accepted by topic author guzzi350tt

Maybe i solved the problem: the Runstate.Thread.PostUIMessageEX doesn't work when the activex sequenceFile ref has an empty path, so i can write a temp path in this field using the PropertyObjectFile.Path attribute with the cloned sequence handle.

 

To obtain the temp path i get the last used dir (IEngine.FileDialogDirHistoryList) concatenated to an unique file name (i use kernel32.dll to check if the new name exists and i change it until is a non existant one).

 

I set the new sequence as modified  (PropertyObjectFile.IncChangeCount()) and i open the sequence int the editor.

 

now when i press the save button i get a prompt asking for the new sequence path.

 

let me know if there is a better solution.

 

P.S

the  PropertyObjectFile.displayname doesn't seem to work

 

Regards

 

Marco

 

0 Kudos
Message 4 of 4
(3,372 Views)