|
-
Dec 5th, 2008, 06:21 PM
#1
Thread Starter
New Member
[2008] Program structure, multiple processes, serial
Using: visual studio 2008 w/ sql 2008
Background: We have created a program that creates an order consisting of tests that is sent to multiple analyzers via serial strings. The tests are then run through the analyzers and the results are sent back through serial and databased.
Problems: In order for the program to send the ordered tests or receive the results we have to have a toggle switch in order to specify which serial COM port to listen to.
Questions: Is having a 3-tier (UI - DB - Background Processes) program the best approach to this problem. If so, how would we structure the UI to communicate with the background processes constantly? Is multi-threading a better option?
Thoughts: We were considering converting our project into a 3-tier program. The user interface will have to send orders to the background processes. The background processes will be responsible for all of the serial data (business logic). Everything will be stored in SQL db. Need your advice. Thanks for reading, hope someone can help.
team sin2win
-
Dec 5th, 2008, 06:38 PM
#2
Re: [2008] Program structure, multiple processes, serial
if you look at my signature, you will find routines for a serial port. if you need multiple ports open at once, it won't work, as-is.
most serial port handlers run on separate threads to begin with.
-
Dec 5th, 2008, 07:05 PM
#3
Re: [2008] Program structure, multiple processes, serial
Would a test consist of sending out a string and waiting for a response? It seems to me that you could have a thread that sent out a request then exits. After all, you probably would want different threads listening. That sending may be so quick that there is no point in putting it in a thread (depending on how difficult it is to set up the output string).
There would be multiple background threads, one per com port. You could have some class that held the various com ports, and could be polled to determine which port was available. The steps would be like this:
Main Thread:
1) Ask for next available com port. If none are available, then you'd have to wait.
2) Send message out the com port and start a thread listening on that port.
Background Thread:
1) Each one listens on one COM port.
2)Once a message arrives:
A) Stick the message somewhere.
B) Raise an event on the main thread that the data is there.
C) Notify the COM holder class that the port is free.
D) Finish and quit.
That won't work if the communication is more than a simple Send/Receive.
My usual boring signature: Nothing
 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|