How to implement an application that can be two applications or one?

To clarify:

  • I want to collect data from a hardware sensor and display it on a PC in the place where it is collected.
  • I want to do some data mining and show the results on a PC that may or may not be hosted.

So, some people may need both functions in one place, and some of them.

What is the best way to provide this, given that there is likely to be some common code?

Two separate applications or one application that can display the functionality of A, B or A and B indentation on the client?

Should you use one application to display two windows? Side by Side, Tablet or what?

Or does it just depend on part of the string?

+4
source share
2 answers

I would use separate applications. A non-visual background service that collects data and a viewer application to display to users. The viewer application can then be run on the local computer and remote computers, all of which connect to the service to receive data updates.

+7
source

At Delphi, I implemented a very close software solution for complex biological analysis.

I see at least two implementation patterns:

1 - You can use the same Delphi executable file at the same time:

  • Background service application
  • GUI application.

Keep in mind that in this case two instances of the executable file will be executed. Thus, you cannot easily share variables between two pieces of code, they will have to rely on some IPC mechanism: GDI messages are light and fast, but not allowed with Vista for the service application, so I assume that the named pipe will be the right candidate.

Advantage: part of the service will be executed in the background, even before the user opens a Windows session (this makes sense for the background task).

Disadvantage: more complex IPC to implement.

But if you make the IPC network ready, you can remotely consult all your data: you can install the client application on the network, even if it is necessary on the Internet. Or you can deploy the Ajax application if you use publication, for example. some JSON or HTML content over HTTP.

(I used this project for my automated device with HTTP / 1.1 Client-Server ORM to share the same classes between client and server).

2 - You can have one Delphi executable file simultaneously with a background application and a graphical interface.

To implement this:

  • Overwrite the OnClose / wmClose event to prevent the form from closing; instead minimize it in the tray;
  • Create a semaphore to localize an existing application: therefore, when you start another .exe time, it restores the main application;
  • The tray icon will have a menu or restore the application by double-clicking;
  • Create a background thread to handle all measures - use a loop with a Sleep call.
+3
source

All Articles