Question

I do have the following scenario: I do have a shell and two modules(moduleA.dll,moduleB.dll included via bootstrapper), this I created using PRISM4.

ModuleA reads a database and from that information it should open a serial port. This module offers also to send commands via the serial connection.

ModuleB can also send data to the same serial connection, the moduleA already openend. Furthermore moduleB should contain a plot which plots data coming from the serial port.

E.g.: ModuleA sends "Setting1,Setting2" ModuleB sends "Start" -->ModuleB receives data (-->Plot data) ModuleB sends "Stop"

So for my understanding they should somehow share the this serial port instance. Any ideas how to setup this scenario?

Thanks in advance.

Was it helpful?

Solution

Your initial modules/class setup seems wrong. The concept of modules is mainly useful for pluggable, optional functionality, not what you describe here: it seems ModuleB can't exist without ModuleA (as it needs the port A has and probably needs the settings to be sent first etc), and vice-versa having only ModuleA without ModuleB makes no sense either (only sending settings but no data communication).

If the setup you have is really as simple as what you write, just use a single module for all serial port communication. What you can do then, is abstract the database away into a seperate module and eventually the plotting as well. Then if you ever switch to another database, you just provide a new module. Likewise for the plot. (note, this is just an example of what you could do and by no means this is inteded to be the solution to your particular problem). For the 'abstracting away' part you use dependency injection with MEF/Unity: create interfaces in a common project, export an implementation of the interface in a module, import it in another module.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top