02-19-2011 02:47 PM
We have developed a TestStand (4.2) OI including a tracelogger function. Code moduls (dll's coded in C++) used in sequences can send trace messages to the OI using the PostUIMessage function (see following code):
try
{
// Get the thread that is
executing from the Sequence Context
thread =
seqContext->GetThread();
thread->PostUIMessage(
static_cast<enum
UIMessageCodes>(UIMsg_UserMessageBase+4)
,Level
,_bstr_t(Msg)
,TRUE);
}
catch( _com_error &com_error ) /* TestStand API only
throws this kind of exception */
{
.....
}
It happens that every 10ms a message is send. In general this works well both when running the sequence in the sequence editor and in our OI. But after a time spawn of about 10 min to a few hours (depends on the frequency of the messages) the PostUIMessage throws a com_error Exception.
Remark: The code is declared as critical section to ensure it works in multi threaded environments too.
Does someone has an idea what might be the reason for these exceptions and how to avoid them?
Thanks in advance
Peter
Solved! Go to Solution.
02-21-2011 11:10 AM
Please post the details of the exception. What is the error message and code?
-Doug
02-22-2011 09:09 AM
Hi Peter,
You wrote that cycle rate is about 10ms.
This is fast! Normally i use such rates in worker threads or separate TS threads.
If you have such of this in your code module or sequence file.
Maybe your variables "seqSontext" or "thread" is not valid.
Before calling thread->PostUIMessage check that everything is valid.
Hope this helps
Juergen
02-22-2011 01:46 PM
Hi Juergen,
you wrote:
>> Maybe your variables "seqSontext" or "thread" is not valid.<<
Yes, that's the reason for the exceptions. We called the function 'PostUIMessage' from a thread started by a sequence. The sequence finished but the thread continued posting UIMessages (with an invalid thread or SequenceContext).
Thank you for your post!
Peter
02-23-2011 10:28 AM
You can pass the Engine into a code module instead of the sequence context and call Engine.PostUIMessage() to post a message that doesn't depend on a thread or execution. You can pass a null reference for the execution and thread parameters. Be careful if you are passing some teststand data using the activeX parameter. Any data gotten from the sequence context or potentially shared between threads will need to take thread synchronization into account.
Hope this helps,
-Doug
02-23-2011 02:43 PM
Hi Doug,
that's a very good idea. I think this will help us to improve the usability of our tracelogger.
Thanks for your post.
Peter
10-21-2011 01:43 AM
Hi all,
I am planning to create multi thread for my application, which acquires more data in real time and displas in report format, this application having time delays.. So i have planned to change my application as multi threaded one.
I read this point from internet, I want to conform that is point is correct or not? If its correct then how to overcome the time dalays and how to implement thread priority.
Changing the priorities of a VI via VI properties -> Execution -> Priority will only have a significant effect on LabVIEW RT systems. On Windows OS, changed priorities will have almost no effect.
Expecting the valuable reply.
10-21-2011 09:21 AM - edited 10-21-2011 09:22 AM
You can modify the win32 thread priority of a TestStand thread using the Thread Priority step type. It's not going to solve all problems though and you have to be very careful if you use the higher priorities since they can starve other threads of CPU time.
-Doug
11-09-2011 03:47 AM
Mr.Doug,
Thanks for the Valuable reply. I am sorry for my late reply.
I have applied the thread priorities to all threads and there is no change in CPU time ( No effect using multi threading concept). I would like to know in detail Mr.Doug..
My Problem :
1) Collecting data (which is a flaw location from plate) with the help of ultrasonic waves and its real time data, I am displaying the flaw location which is collected (using PCL 1751 cards) in the Graphical format. Here i am not getting the actual position of the flaw. Due to the time delay.
Solution implemented :
1) Implemeted multi thread concept but still facing the same issues.
Example:
Actual flaw position say : 120 MM (from plate)
First time when i execute my application it shows : 110 MM
Next time when i execute it shows as : 113 MM
Like this it varying every time.
Could you please help me out to sort this issue.
Thanks and Expecting the Solution....
11-09-2011 09:43 AM
How much of a delay does it take to introduce the kind of error you are seeing? Are you able to achieve the responsiveness you need in a trivial program outside of TestStand?
Windows is not a real-time OS. I'm not an expert on real-time hardware/software so maybe someone else can provide you better advice, but I think there are probably things you can do with FPGA or a real-time OS that might help you get the results you are looking for.
-Doug