Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
OPC Client in IntraWEB
#1
I have a Windows application that communicates with an OPC server using DCOM / COM communication, all managed in a thread.

My question is, can I move that thread to Intraweb (14.2.7), to be managed by the  Server Session (or a DataModule)? ... My idea to run the thread, read data from an OPC and share it  among all the users that access certain page in the WEB Browser.  Or it could be in conflict with the Intraweb Environment?

Thanks in advance for your help ... Regards

Lg
Reply
#2
In theory, it should work as a thread in the ServerController. I have a thread of my own that I create in the ServerController.OnCreate event. It has functions that I use in certain forms launched by the user.

Your final results will depend upon the functionality of your specific thread. You should try adding your thread unit to the project, and then instantiate it the ServerController. Compile it to see if you have any dependencies that also have to be included. Run your app to see if it still runs and supports sessions.

Since you are sharing it among sessions you may have to use TCriticalSections if you have code that should not be accessed by more than one thread at a time.
Reply
#3
Thanks Daniel, in fact it works on a thread and it works fine, but I see some instability in the communication that the thread informs and tries to restore. The error that is displayed every 1 hour (but it is variable) is the loss of the RPC on the remote server (OPC server). If I run a Windows application using the same thread, nothing bad happens for more than 36 hours ... that's why my concern is that something happens in the Intraweb environment. I have used threads with other protocols without problems. But the OPC has not worked so well for me.

Maybe you should do the OPC client in a Windows application that is activated by the Intraweb application and enable some kind of interprocess communication ... !!
Reply
#4
IntraWeb will not interfere or in any way bother any threads that you create yourself.
Reply
#5
It sounds like you have a resource issue, or threads that are colliding. You are supporting multiple sessions that will access the thread you created. Are you accessing any tables or global variables? If so, you will need critical sections to prevent multiple threads from using that code at the same time. Or you have to create dynamic resources inside the thread execution code. Are you using a timer inside the thread? That too would require critical section support for multiple sessions.

This may be a case where you create a Service for the thread that you can communicate with from the user sessions. I use this setup for anything that requires external processing, or that needs high performance. I typically use a table with a status field to trigger the service. When the service has completed its work it can set the status to completed. The client just waits in a timer loop for the status to change. You can even report interim status updates if needed. That setup also scales extremely well.
Reply
#6
Sorry for taking a long time to answer. The thread is working fine, but the OPC thread uses Com / DCom communication to contact the remote server. After a while working, something happens and then the link breaks and the OPC client loses the connection when the "remote RPC server impossible to execute" arises ... my plan is exactly to create a service to send certain information in a way simple (I was thinking of a file, but a table may be also a good idea).
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)