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 is Logger.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, choose New component type..., type in the name Logger and select Device in the Role field.
• Click OK. A Logger:Device entry will appear on the left pane under Types -> Component Types.
• Right click Logger:Device, choose New port..., type in the port name and select the Type and Direction. The Type should be the type of the data port that this logger port is about to listen to, and Direction should be Subscribe 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).
• Instantiate an instance of the logger by right click on the right pane. Choose Add component -> Device. Type in an Instance Name, say logger, and choose the Component Type to be Logger. A Logger 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 corresponding Publisher and Subscriber ports accordingly.
• Click OK. A arrow of connection should show in the right pane.
• Repeat the above two steps until all connections are made.
• Now we can generate the code skeleton for the Logger class.
• On the left pane, right click Logger:Device, choose Generate 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. The Logger.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 of Logger.java.
• 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, choose Generate Signature..., and save the signature file to the /mdcf2-devicedatabase/comp_spec folder. Say the name is /mdcf2-devicedatabase/comp_spec/Logger.compsig.xml.
• 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, add Loggers in an additional line and save.
• Back in MdcfDevelopmentEnvironment, right click CIMIT_PCA_Interlock under the Configurations entry, choose Create App Archive Folder Structure.... When prompted for the location, choose /mdcf2-app-dev/Loggers.
• Right click CIMIT_PCA_Interlock again, choose Export App Configuration.... When prompted for the location, choose the default location /mdcf2-app-dev/Loggers/mdcf/app/CIMIT_PCA_Interlock/appcfg and default name CIMIT_PCA_Interlock.cfg.xml. Click Save.
• Again, right click CIMIT_PCA_Interlock, choose Check 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 implements IMdcfMessageListener. The * is a port name. We use the hrListener class as an example.
• In the onMessage method of the hrListener class, find the line hrData = Integer.parseInt(message.getTextMsg());, below this line, add System.err.println("hr value: " + hrData);. This will print the message values going out of the pulse oximeter component and seen by the Logger.
• Execute /mdcf2-main/src/mdcf/main/ExecuteServerAndConsole.java as a Java application. A window called Clinician Console will show. Within it, a window called App Launcher is shown.
• On the left pane of App Launcher, click CIMIT_PCA_Interlock. On the right pane, four devices will show: CIMITRespiratoryRateMonitor, logger, CIMITPCAPump, and CIMITPulseOximeter.
• Now execute /mdcf2-mockdevice/cimit_demo/LoadVirtualPatientAndDevices.java as a Java application. A window called Virtual PCA Pump will show.
• Switch back to Clinician Console, on the left pane, click some entry other than CIMIT_PCA_Interlock and then click it again. (The Refresh button does not work.) On the right pane, three device out of the four (except for the logger) 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 the logger 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 for Logger class will keep outputting hr value: 80. This shows the logger is now able to listen to this channel.
• Switch back to the Virtual PCA Pump window, and click the Give Dose button. In the Eclipse Console window, it can be seen that the hr value will drop to around 50 and gradually bounce back to 80 again (or sometimes stuck with 79).
• Now the Logger implementation can be started. To do more with the values in the message channels, implement the onMessage 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.