mardi 8 novembre 2016

Design patterns recommendation for a Gui

I'm looking for a good advice/recommendation for a design pattern or another good idea to solve the folowing problem. At first some informations. I am writing a simulator, which simulates about 10 to 15 plants. Each plant is different and has different information, which i want to show on a GUI. Each plant works in its own thread. I want to display informations like the current state of the plant, the material that is currently in use ... and so on. My GUI consists of only a tab control with a single tab for every plant. Now my problem is to get the data displayed in a good way. The user can also control the plants, you can stop and start a plant or edit material that is used by a plant for example. So now i am looking for a good way to exchange the data between my GUI and my plant threads. I am a still new to programming, but i know that there are things like Data Binding, MVC, MVVM, ... but nothing really suited to my problem. That's at least my opinion. That's why i wanted to hear maybe different opinions.

I have the following idea to exchange data between the threads: i would create a model class for every plant in which both the gui and the plant thread would read/write. Everything synchronized of course. Then i would create an event in each plant that is thrown when the data i want to display is changed. But to keep the gui accessable for the user i would dynamically connect the gui only to the plant's event which is selected in the tab control. So when the tab changes i would i would connect the GUI with the selected plant. One tab shows only one plant. The problem is that you can speed up the simulation, so the data would change quite fast, that's why i need a smooth and good way to exchange the data. The plant runs in its own thread and reads the data in the model, it does not really need to be informed when the data is changed by the gui.

What is your opinion to my idea? Am i planning to do the biggest sh** that you have ever heard of? It would be great if you could give me some tipps. This simulator is part of my bachelor thesis, so it would be great if there were a good pattern that could be used (for a scientific background). I looked for patterns but like i said i didin't find a satisfying pattern, but i may be wrong. And sorry for my bad English!!!! I am using WPF. I nearly forgot to mention it.

Aucun commentaire:

Enregistrer un commentaire