Threads for multiple devices

Roman M.
Kovrov, Vladimir

Feb 7, 2019
2 Posts

0  |  0  

Re: Threads for multiple devices

Hello.
I'm not programmer but I have good skill application develop in ATEasy.
Actually we work on project in which we need to collect information from multiple devices (power supplies, relay module, therochamber) and to indicate many parametrs on the user form. I use many threads for it. Some questions are:
1. Can I create threads from user form? I know it work. But is this correct?
2. I have aprox 20 devices. Is it correct to create 20 threads for each one? Or I need to combine some devices in one thread?
3. Are there any tips for synchronizing multiple processes in my case? I know CriticalSectios and Mutex can be used for this But I have not expierence. Any tips and recommendation will be helpful.

Thank you in advance.
Roman

DrATEasy (Ron Y.)
Mission Viejo, CA

Feb 7, 2019
358 Posts

0  |  0  

Re: Threads for multiple devices

1. Yes you can create threads from form event. I recommend to place the thread procedure outside the form (in module procedure and not form procedure). That way if the form is destroyed the thread can continue.
2. You can create a thread for each device or combine them. It really depends on the code you have. You can try 20 threads and see if the performance you are getting is OK, if not, you can combine the threads. The language.prg example have examples of using synchronization objects.

Ron

Roman M.
Kovrov, Vladimir

Feb 8, 2019
2 Posts

0  |  0  

Re: Threads for multiple devices

Thank you Ron.
1. Yes, I understood. I need threads wich will be write from devices to global variables and thread which will be read from global variables to form. And I need synchronize this R/W threads  by Critical Section or something else.
2.  Multiple threads for each devices work OK but sometimes I get error from IOTable Receive. Power supplies controlled by  TCP/IP. But I think this is issue of power supplies.

Thank you for support.



Please Note
You need to have a M@GIC account to participate in the Forums.
Not yet registered on our website? Click here to register today!

All content, information and opinions presented on the Marvin Test Solutions User Forums are those of the authors of the posts and messages and not Marvin Test Solutions'. All attachments and files are downloaded at your own risk. [Read More]