NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to programmatically add a sequence file to a project

Hi,
Using Teststand C++ API, I would like to add a sequence file to the current project in the current workspace.

My sequence file has been created using engine->NewSequenceFile(); and saved in the path "Path" (as std::string).
I try to create a new workspace file this way :

engine->CurrentWorkspaceFile->GetRootWorkspaceObject()->NewFile( _com_util::ConvertStringToBSTR(Path.c_str()) );

But this line throw a com exception "Unknown error 0xFFFFBC63" which should correspond to error -17309

What is the correct way to do this ?

Thank you.

0 Kudos
Message 1 of 5
(4,598 Views)

hello

 

Could you provide the code you're using, for example the order of functions you're calling?

So that we could look closer at your project.

 

Thanks

Regards

 

 

0 Kudos
Message 2 of 5
(4,554 Views)

Thank you for your answer.

 

Here the code I'm using :

 

 

    string newSeqName = "myNewSequence";
    TS::SequenceFilePtr newSeqFile = _currentContext.engine->NewSequenceFile();
    TS::WorkspaceObjectPtr workspacePtr = _currentContext.engine->CurrentWorkspaceFile->GetRootWorkspaceObject();
    string chapterPath = getFolderFromFilePath(string(workspacePtr->GetPath())) + "\\";
    chapterPath += newSeqName + ".seq";
    try
    {
        newSeqFile->Save(chapterPath.c_str());
    } catch (_com_error const & e) {
        gcLogModuleError("Error on save :  %s", e.ErrorMessage());
    }
    TS::WorkspaceObjectPtr newSeqObj;
    try {
        newSeqObj = workspacePtr->NewFile( _com_util::ConvertStringToBSTR(chapterPath.c_str()) );
    } catch (_com_error const & e) {
        gcLogModuleError("got error on newfile :  %s ", e.ErrorMessage());
    }
workspacePtr->InsertObject(newSeqObj, workspacePtr->NumContainedObjects);
    _currentContext.engine->CurrentWorkspaceFile->AsPropertyObjectFile()->IncChangeCount();
    _currentContext.engine->ReleaseSequenceFile(newSeqFile);
    _currentContext.engine->SaveAllModifiedSeqFiles(0);

 

this code saves in the right place my file "NewSequence.seq"

Generate error TS_Err_IllegalOperationOnValue

 

 

 

0 Kudos
Message 3 of 5
(4,547 Views)

Hello,

Looking at your code, the way to script TestStand is to - create a workspace, the create a project then create a sequence. It doesn't appear in your code that you create a project.

Please could you try this using the Workspace.Objectfile.Newfile(path du projet)? The project file extension is .tpj.

Thanks

 

0 Kudos
Message 4 of 5
(4,528 Views)

Hello,

 

I want to add a sequence to the current project of the current workspace but GetProjectFile() always give me an invalid pointer in :

_currentContext.engine->CurrentWorkspaceFile->RootWorkspaceObject->GetProjectFile()

 

If I create a new project, I don't see how to add a sequence to it once I got my TS::WorkspaceObjectPtr.

Is there documentation/example on this subject ?

Thank you.

0 Kudos
Message 5 of 5
(4,512 Views)