In this post I summarize how to implement a data logger as a separate device for a set of interoperable medical devices connected onto the MDCF framework. Special thanks go to Andrew L. King for teaching me the high-level view as well as low-level details of everything with the MDCF 2 framework. All mistakes in this post are on me and all credit goes to him.
The basic idea is to use the MdcfDevelopmentEnvironment
to design the system, export the configurations, generate the logger program skeleton, and then implement the user logic. The steps are captured below. (Note: in the following, all paths starting with /mdcf2-
are relative to the Eclipse projects folder.)
- Download a copy of MDCF 2 from its download page.
- Follow the instructions on the download page to set up the projects.
- Run
/mdcf2-pde-standalone/src/mdcf/pde/MdcfDevelopmentEnvironment.java
as a Java application. - In
MdcfDevelopmentEnvironment
, open an existing workspace. The ones that come with the MDCF 2 distributions are stored in the folder/mdcf2-app-dev/workspaces
. In this example we use/mdcf2-app-dev/workspaces/CIMIT_PCA_Interlock.wksp.xml
. Save a copy, say its name isLogger.wksp.xml
. We will only work on this copy in the sequel. Remember to save often. - Define the component
Logger
.- In the left pane, open
Types
->Component Types
, you will see existing definitions of the devices and apps. - Right click
Component Types
, chooseNew component type...
, type in the nameLogger
and selectDevice
in theRole
field. - Click OK. A
Logger:Device
entry will appear on the left pane underTypes
->Component Types
. - Right click
Logger:Device
, chooseNew port...
, type in the port name and select theType
andDirection
. TheType
should be the type of the data port that this logger port is about to listen to, andDirection
should beSubscribe
for a data logger. - Click OK. The
Logger:Device
entry will now have children representing the port. - Repeat the above two steps until all ports are defined (for each data port of other device that should be recorded).
- In the left pane, open
- Instantiate an instance of the logger by right click on the right pane. Choose
Add component
->Device
. Type in anInstance Name
, saylogger
, and choose theComponent Type
to beLogger
. ALogger
instance will appear on the right pane. - Now we have to connect the channels that
logger
is listening to.- Right click on the right pane, choose
Add connecton
. Choose the correspondingPublisher
andSubscriber
ports accordingly. - Click OK. A arrow of connection should show in the right pane.
- Repeat the above two steps until all connections are made.
- Right click on the right pane, choose
- Now we can generate the code skeleton for the
Logger
class.- On the left pane, right click
Logger:Device
, chooseGenerate MDCF/Java Skeleton
. Choose the folder the java file is generated. In this case, we use/mdcf2-mockdevice/cimit_demo/loggers
to make it less clustering with other files. - Now in Eclipse, refresh the
/mdcf2-mockdevice/cimit_demo/loggers
folder. TheLogger.java
file should be found there. Open it. - Since it is not in the standard folder, the package information is incorrect. Fix this by adding
package loggers;
in the first line ofLogger.java
.
- On the left pane, right click
- For the new
Logger
device to be recognized by the MDCF 2 framework, its signature must be generated and added.- Switch back to
MdcfDevelopmentEnvironment
. - In the left pane, right lick
Logger:Device
, chooseGenerate Signature...
, and save the signature file to the/mdcf2-devicedatabase/comp_spec
folder. Say the name is/mdcf2-devicedatabase/comp_spec/Logger.compsig.xml
.
- Switch back to
- The MDCF 2 framework has also to know about the configuration of the new interoperability setting.
- To avoid cluster, we use a separate folder to store the setting with the logger.
- Make a new folder
Loggers
under the/mdcf2-app-dev
folder. - In Eclispe, include
Loggers
as a source folder (probably optional?). - Open
/mdcf2-app-dev/AppFolderNameList.txt
, addLoggers
in an additional line and save. - Back in
MdcfDevelopmentEnvironment
, right clickCIMIT_PCA_Interlock
under theConfigurations
entry, chooseCreate App Archive Folder Structure...
. When prompted for the location, choose/mdcf2-app-dev/Loggers
. - Right click
CIMIT_PCA_Interlock
again, chooseExport App Configuration...
. When prompted for the location, choose the default location/mdcf2-app-dev/Loggers/mdcf/app/CIMIT_PCA_Interlock/appcfg
and default nameCIMIT_PCA_Interlock.cfg.xml
. ClickSave
. - Again, right click
CIMIT_PCA_Interlock
, chooseCheck App Archive Consistency
. If any component signature is reported missing, copy them from the/mdcf2-devicedatabase/comp_spec
folder to the/mdcf2-app-dev/Loggers/mdcf/app/CIMIT_PCA_Interlock/appcomp
folder. Check again until successful.
- Now the new
Logger
device is registered and the new interoperability setting is saved. We write a short piece of code to test it.- In Eclipse, open the file
/mdcf2-mockdevice/cimit_demo/loggers/Logger.java
. - Find a
*Listener
class which implementsIMdcfMessageListener
. The*
is a port name. We use thehrListener
class as an example. - In the
onMessage
method of thehrListener
class, find the linehrData = Integer.parseInt(message.getTextMsg());
, below this line, addSystem.err.println("hr value: " + hrData);
. This will print the message values going out of the pulse oximeter component and seen by theLogger
. - Execute
/mdcf2-main/src/mdcf/main/ExecuteServerAndConsole.java
as a Java application. A window calledClinician Console
will show. Within it, a window calledApp Launcher
is shown. - On the left pane of
App Launcher
, clickCIMIT_PCA_Interlock
. On the right pane, four devices will show:CIMITRespiratoryRateMonitor
,logger
,CIMITPCAPump
, andCIMITPulseOximeter
. - Now execute
/mdcf2-mockdevice/cimit_demo/LoadVirtualPatientAndDevices.java
as a Java application. A window calledVirtual PCA Pump
will show. - Switch back to
Clinician Console
, on the left pane, click some entry other thanCIMIT_PCA_Interlock
and then click it again. (TheRefresh
button does not work.) On the right pane, three device out of the four (except for thelogger
) will be seen instantiated. - In Eclipse, execute
/mdcf2-mockdevice/cimit_demo/loggers/Logger.java
as a Java application. - Switch back to
Clinician Console
again and "Refresh". Now thelogger
is also instantiated. - Command-click (or Control-click under Windows) to select all four instantiations (the ones with green marks) of the devices on the right pane, and select
Launch
. - In Eclipse
Console
window, the pane forLogger
class will keep outputinghr value: 80
. This shows thelogger
is now able to listen to this channel. - Switch back to the
Virtual PCA Pump
window, and click theGive Dose
button. In the EclipseConsole
window, it can be seen that thehr value
will drop to around 50 and gradually bounce back to 80 again (or sometimes stuck with 79).
- In Eclipse, open the file
- Now the
Logger
implementation can be started. To do more with the values in the message channels, implement theonMessage
methods for each of the*Listener
classes in the/mdcf2-mockdevice/cimit_demo/loggers/Logger.java
file, including outputing these values to an external file.