NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

How to share notification with CVI?

Hi All

 

I found a similar post but the links don't work

 

http://forums.ni.com/t5/NI-TestStand/How-can-I-access-a-Notification-from-a-CVI-Dll/m-p/77132

 

I am looking to be able to Set a Notification from some multi threaded CVI code.

 

Thanks

0 Kudos
Message 1 of 9
(4,060 Views)

I was able to find the thread that the broken link was referencing - it's got an Example that might be helpful.

 

Link: How to pass sync steps from TestStand to LabVIEW?

 

Hope this helps.

 

-Jack

0 Kudos
Message 2 of 9
(4,034 Views)

Hi NIExpert,

 

Can you give me some more detail about what you are trying to do and what you have tried so far?  Are you using a dll or a CVI User Interface?  Are you trying to determine if a Notification is set from CVI, or are you trying to control a Notification from CVI?

 

Regards,

 

Brandon V.

Applications Engineering

National Instruments

www.ni.com/support

 

 

0 Kudos
Message 3 of 9
(4,009 Views)

I wish to create a Notifier Object in TestStand  and then Send a Notification from CVI code.   TestStand will be waiting for that Notification

 

 

I just found a post that referers to the Syncronization API function panel tssync.fp.  This might be what I am looking for

0 Kudos
Message 4 of 9
(3,990 Views)

@NIExpert wrote:

I wish to create a Notifier Object in TestStand  and then Send a Notification from CVI code.   TestStand will be waiting for that Notification

 

 

I just found a post that referers to the Syncronization API function panel tssync.fp.  This might be what I am looking for


Yes, you need that in combination with the engine api Engine.GetSynchronizationManager(). See the TestStand API help for more details.

 

Hope this helps,

-Doug

0 Kudos
Message 5 of 9
(3,973 Views)

Hi Doug,

 

Would greatly appreciate it if you (or anyone) could provide a little insight about what I'm missing.

 

The goal is to have sockets in TestStand waiting for the Notifications to be set by CVI code. 

 

Environment:  Windows XP, TestStand 4.1, and LabWindows CVI 8.5.

 

For starters to see what works, I created a Notification named "HOLD" inside a sequence and

passed "ThisContext" to a function (SetNotify) in a CVI dll.

 

 

Upon execution of   Hr = TS_EngineGetSyncManager (seqContextCVI, &ErrInfo, "HOLD", &SyncMgrObj)

 

Hr is set to {0x80004002 = "No such interface supported"}

 

Here is my test code:

 

void __declspec(dllexport) __cdecl  SetNotify (CAObjHandle seqContextCVI)
{
   ERRORINFO      ErrInfo;
   CAObjHandle      hDataPropObj;
   CAObjHandle      hSyncMgr;   
   LPUNKNOWN    SyncMgrObj;
   VARIANT            SyncMgrVar;
   HRESULT           Hr;
   
 
    Hr = TS_EngineGetSyncManager (seqContextCVI, &ErrInfo, "HOLD", &SyncMgrObj);
  
    SyncMgrVar = CA_VariantIUnknown (SyncMgrObj);  

   

    CA_VariantConvertToType (&SyncMgrVar, CAVT_OBJHANDLE, &hSyncMgr);
  
     Hr = TSSyncLib_INotificationSetEx (hSyncMgr, NULL, hContext, hDataPropObj, VFALSE, VFALSE);

}

 

 

Regards,

Pliskin 

 

0 Kudos
Message 6 of 9
(3,919 Views)

1) a sequence context is not an engine object. You should add an additional parameter to your function, CAObjHandle engine, and pass RunState.Engine as the argument for that parameter from TestStand.

2) The sync manager is not a notification, you would need to get the notification from the sync manager using the API in tssync.h

3) You are never closing the object handle and are thus leaking the sync manager object.

4) You could greatly simplify your code by just passing the notification reference directly into your function from teststand. When you create a notification in teststand using the step type, you can optionally store it in an object reference variable (i.e. a local variable of type Object Reference). Do that, then pass it into your function rewritten with the following prototype:

void __declspec(dllexport) __cdecl  SetNotify (CAObjHandle notification)

{

}

 

But if that's all you are doing in your CVI code, I don't see much benefit to this, vs. just using the notification step type directly.

 

-Doug

Message 7 of 9
(3,907 Views)

Doug,

 

Thanks for the response. Passing in the Object Ref for the notification is what I need. Works great. Thanks!

 

Regards

Pliskin 

0 Kudos
Message 8 of 9
(3,900 Views)

This should work as a simple example for setting a notifier from CVI.  You may be able to build on it for more usefull applications

 

Regards

 

Vijay

 

 

 

 CAObjHandle NotifierObj = 0;
 CAObjHandle hDataPropObj = 0;
 CAObjHandle      hSyncMgr = 0;  
 
 VARIANT SyncMgrVar;
 LPUNKNOWN SyncMan;
 TSObj_Engine TSEngine;
 
 TS_SeqContextGetEngine (testData->seqContextCVI, &RikErrorInfo, &TSEngine);
 
 TS_EngineGetSyncManager (TSEngine, &RikErrorInfo, "Autonomous", &SyncMan);  //This Notifier was created in teh TS sequence

 SyncMgrVar = CA_VariantIUnknown (SyncMan);   
 CA_VariantConvertToType (&SyncMgrVar, CAVT_OBJHANDLE, &hSyncMgr);
     
 TSSyncLib_ISyncManagerGetNotification (hSyncMgr, &RikErrorInfo, "Autonmous", &NotifierObj);  //get the notifier object
 
TSSyncLib_INotificationSetEx (NotifierObj, &RikErrorInfo, testData->seqContextCVI, hDataPropObj, VFALSE, VFALSE);


CA_DiscardObjHandle(hDataPropObj); 
CA_DiscardObjHandle(NotifierObj);
CA_DiscardObjHandle(hSyncMgr);     
CA_DiscardObjHandle(TSEngine);    
 

0 Kudos
Message 9 of 9
(3,897 Views)