Get a variable from one program to another

I don’t even know how to ask this question, but I will give him a chance.

I have a program in C # that reads values ​​from sensors on the production line that indicate the status of the line. These values ​​are updated every 500 milliseconds. I have four lines for which this is done. I would like to write a “review” program that can access these values ​​over the network to give a good summary of how the factory works. My question is, how do I get values ​​from C # programs on line to a C # review program in real time?

If my question does not make much sense, let me know and I will try to rephrase it.

Thanks!

+4
source share
4 answers

It depends on a number of things, I would say. First of all, is it just the last value of each line that is interesting for the Browse application, or do you need several values ​​to determine the status of the line, or you probably want to have a history of values?

If you are only interested in the latter value, I would immediately pass that value to the review application. As suggested by others, you have many options:

  • Raw TCP using TcpClient (maybe a little too low level).
  • Print the http endpoint in the overview application (maybe this is a web application) and send new values ​​to this endpoint.
  • Use WCF to expose some endpoint ( named pipe , net.tcp , http , etc.) in the browse application and invoke this endpoint from each client application.
  • Use MSMQ so that each client logs messages that are then selected by the review application (also directly supported by WCF).

If you need some history of values ​​or you need several values ​​to determine the status of the line, I would go with a database solution. Then you need to choose: each client is written to the database or each client sends to the review application (using any of the communication tools described above), and the review application is written to the database.

Without knowing any restrictions for your situation, it is difficult to solve any of them.

+2
source

You have several options:

  • Msmq

Write messages in MSMQ ( Microsoft Queueing ). This (optional) permanent and fast storage for transporting messages between machines. Since you say that you need messages in another application in almost real time, then it makes sense to use MSMQ, because you do not want to write logic in this application to process a large number of incoming messages. Keep the MSMQ in the middle and take out what you need and most importantly when you can.

  • WCF

Another application may provide a WCF service that can be called by your application in real time every time data is available. The endpoint may be more than net.tcp, which means low overhead, especially if you send small messages.

Other options include what was said earlier: database, file, etc. Thus, you can choose between a wide range of options.

+3
source

You can use named pipes (see http://msdn.microsoft.com/en-us/library/bb546085.aspx ) to have a quick way to communicate between the two processes.

+2
source

Database. Put your values ​​in the database and another application will pull them out of the same database. This is a very common solution to this problem and opens up worlds of new scenarios.

see Relationship Database

+2
source

All Articles