Implementing a data logger in the MDCF 2 framework
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.javaas 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 nameLoggerand selectDevicein theRolefield. - Click OK. A
Logger:Deviceentry will appear on the left pane underTypes->Component Types. - Right click
Logger:Device, chooseNew port..., type in the port name and select theTypeandDirection. TheTypeshould be the type of the data port that this logger port is about to listen to, andDirectionshould beSubscribefor a data logger. - Click OK. The
Logger:Deviceentry 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 Typeto beLogger. ALoggerinstance will appear on the right pane. - Now we have to connect the channels that
loggeris listening to.- Right click on the right pane, choose
Add connecton. Choose the correspondingPublisherandSubscriberports 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
Loggerclass.- 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/loggersto make it less clustering with other files. - Now in Eclipse, refresh the
/mdcf2-mockdevice/cimit_demo/loggersfolder. TheLogger.javafile 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
Loggerdevice 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_specfolder. 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
Loggersunder the/mdcf2-app-devfolder. - In Eclispe, include
Loggersas a source folder (probably optional?). - Open
/mdcf2-app-dev/AppFolderNameList.txt, addLoggersin an additional line and save. - Back in
MdcfDevelopmentEnvironment, right clickCIMIT_PCA_Interlockunder theConfigurationsentry, chooseCreate App Archive Folder Structure.... When prompted for the location, choose/mdcf2-app-dev/Loggers. - Right click
CIMIT_PCA_Interlockagain, chooseExport App Configuration.... When prompted for the location, choose the default location/mdcf2-app-dev/Loggers/mdcf/app/CIMIT_PCA_Interlock/appcfgand 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_specfolder to the/mdcf2-app-dev/Loggers/mdcf/app/CIMIT_PCA_Interlock/appcompfolder. Check again until successful.
- Now the new
Loggerdevice 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
*Listenerclass which implementsIMdcfMessageListener. The*is a port name. We use thehrListenerclass as an example. - In the
onMessagemethod of thehrListenerclass, 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.javaas a Java application. A window calledClinician Consolewill show. Within it, a window calledApp Launcheris 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.javaas a Java application. A window calledVirtual PCA Pumpwill show. - Switch back to
Clinician Console, on the left pane, click some entry other thanCIMIT_PCA_Interlockand then click it again. (TheRefreshbutton 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.javaas a Java application. - Switch back to
Clinician Consoleagain and “Refresh”. Now theloggeris 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
Consolewindow, the pane forLoggerclass will keep outputtinghr value: 80. This shows theloggeris now able to listen to this channel. - Switch back to the
Virtual PCA Pumpwindow, and click theGive Dosebutton. In the EclipseConsolewindow, it can be seen that thehr valuewill drop to around 50 and gradually bounce back to 80 again (or sometimes stuck with 79).
- In Eclipse, open the file
- Now the
Loggerimplementation can be started. To do more with the values in the message channels, implement theonMessagemethods for each of the*Listenerclasses in the/mdcf2-mockdevice/cimit_demo/loggers/Logger.javafile, including outputing these values to an external file.