Reputation: 21
I need to make a WPF application that has two windows for it's UI that will be used simultaneously by two separate users. It needs to run on a single PC with dual monitors so that each UI screen displays on its own monitor. The app is for an industrial controls interface for a machine we are building.
Machine description: The system is a test stand for a pump manufacturer. They would like to have two operators manning the station. So it needs to be able to test two pumps at the same time but not synchronously (each operator my start their test at different times). The system will test for leaks, vibration, flow, pressure and motor current. There are hundreds of different models all with different test parameters as well as different test procedures. It is desired to have a single PC and a single PLC as the control hardware. The PC will have dual touchscreen monitors (one for each operator), two bar code scanners (one for each operator) and two Zebra label printers (one for each operator). The PC will interface with a Allen Bradley Compact Logix PLC via EtherNet I/P. The PLC will be programmed to control all of the actuators and sensors on the machine. The PC will command the PLC to execute the various test sequences after it has written the appropriate parameters to the PLC. The PLC will collect data during a test sequence, and the PC app will retrieve it and write it to persistent storage.
Application description: The application will use an SQL Express database to store all the pump model's testing parameters as well as the data collected during the test for each pump. The app will provide provide twin UI's that have identical functionality but are capable of operating independently of each other. The app will have a UI screen for entering and editing the parameters for all the different pump models, another screen to view data collected for a given pump and the main screen that will display the current pump under test info, such as the parameters that are in use, the test progress and live transducer data. A usage scenario is as follows: The operator receives a batch of pumps with it comes a work order sheet, he/she scans the bar code on the work order the app decodes the scan and extracts the model number, it then retrieves the test parameters from the database and displays the info on screen, after operator confirmation it writes the parameters and test sequence to the PLC. The operator loads the pump into the test chamber and closes a safety door. A "Begin Test" button is presented to the operator after the PLC confirms pump present and safety doors closed. The operator presses the "Begin Test" button and the PC and PLC 'talk to each other to perform the test sequence while the PC updates the UI to keep the operator informed of the progress and results for each step of the sequence. When testing is complete the PC generates a GUID for the pump and stores the test data linked to the GUID in the database and prints a bar code label encoded with the GUID and a pass/fail status code. The safety door unlocks The operator at the second station is performing the same tasks but with a different work order, which can be a different model pump so the testing on the other station is completely independent of each other.
My question is this: Is it possible to have a single WPF app instantiate two separate UI threads on separate monitors so that both UI windows appear to have focus simultaneously. And if so how do you do it. A couple of other points to deal with are: each monitor will be a touch screen so two separate mouse inputs need to be handled and each user will have a bar code scanner so two USB or serial scanners will need to be monitored for input.
Upvotes: 2
Views: 714
Reputation: 18098
As the other answers stated, only one window can have focus at a time. Input from either user will reach last focused window.
Consider creating one server app and two remote UI apps that communicate with server. That way, you have one app running logic, but two remote-apps feeding it input, from to separate machines. (One of the input machine can also be used as the server's machine.)
You could also have two desktop apps that communicate directly with each other (on separate machines) with no server app, but that would be a little trickier to implement.
Upvotes: 1
Reputation: 25146
sounds like you'd be better off with 2 machines, and one instance running on each.
others have already brought up the focus issues, but you also have double the sensors/etc to manage too.
you could either spend $$ on writing a super complicated app that violates most of the rules about one set of inputs+focus, or spend taht same $$ getting another machine to run the app?
Upvotes: 1
Reputation: 74692
You cannot have two windows with window focus at the same time, regardless of how many threads are in use. The best solution is to just create a standard WPF app with one giant window - this will allow you to do what you want.
Upvotes: 1
Reputation: 29083
Windows will only send touch input to one window at a time. Nothing you can do about that. The 'workaround' would be to handle all of the input from within one window, do some hit testing, and then react accordingly.
Upvotes: 0
Reputation: 28839
I don't know for sure if you can have two focuses (foci?) at once in a WPF app, but it sounds like it could get messy quickly. It seems to me that a much cleaner solution would be to run two separate instances of the application.
Upvotes: 0