06-03-2011 01:35 PM
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
06-06-2011 08:37 AM
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
06-07-2011 04:48 PM
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
06-08-2011 12:21 PM
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
06-09-2011 10:10 AM
@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
06-14-2011 06:17 PM
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
06-15-2011 09:48 AM
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
06-15-2011 11:19 AM
Doug,
Thanks for the response. Passing in the Object Ref for the notification is what I need. Works great. Thanks!
Regards
Pliskin
06-15-2011 12:16 PM
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);