Data acquisition and design patterns
I have to write a flexible data acquisition and control panel in Java. I'm not a Java
programmer. I have experience in LabVIEW and electronics design, hence my question is rather fundamental (if not stupid).
I have to choose proper design pattern to make my program scalable.
I want to control a data acquisition modules. My program will have multiple threads:
* 1 GUI thread to send commands to DAQ devices (buttons clickable by users + graphs)
* number of device control threads
At first it seems that Model-View-Controller pattern will fit. I don't know how
should I solve inter-thread communication to make it scalable and completely separate GUI and device control threads. I think about message queues (this is how we do such things in LabVIEW). Java offers event listeners, nofify(), blocking queues.
Here is the scenario:
* GUI have 3 buttons:
1 - measure with 1st device
2 - measure with 2nd device
3 - measure with 3rd device.
User press button 1 (1st device) and a message "measure stuff" is sent to 1st device control thread. Button should be locked until the device finishes the operation (1-10 seconds). When the device finishes, device control thread sends a message "finished". Button should be unlocked on this message. GUI should not be locked during measurement so 2 other devices can be triggered when the 1st one is busy.
My problem here is bi-directional communication. I don't want to clutter my code with
dozen of action listeners or mixing message queue with event listeners. I want to make it easy to add arbitrary number of devices without too much glue code.
What is the best practice to solve this kind of problem with scalability and code maintainability in mind?
Feel free to correct my eastern european english :)