270 likes | 404 Views
Interactive CARA Simulation. Prof. Insup Lee. Hierarchical EFSM Specification for CARA. Interactive Simulation. CHARON simulator CHARON is able to simulate state flows Each state machine can be simulated in an agent Agents can work concurrently Java-based GUI
E N D
Interactive CARA Simulation Prof. Insup Lee
Interactive Simulation • CHARON simulator • CHARON is able to simulate state flows • Each state machine can be simulated in an agent • Agents can work concurrently • Java-based GUI • Allow user to change the CARA environment online • Display soft button • Display dialog windows • Display run-time pumping mode and pump status • Display the dynamic data and notation • How to fill the gap between CHARON Simulation and GUI • File sim.dat is written by CHARON simulation, and will be read by GUI during running • File gui.dat is written by GUI and will be read by Environment agent in CHARON simulation
CARA Simulation in CHARON • CHARON Features • Architectural Hierarchy • simulate the hierarchical EFSM structure • Each state machine in the EFSM is corresponding to an agent in CHARON • Behavior Hierarchy • Allow to simulate the mode control and state transaction • Discrete & Continuous Variable Updates • Make it possible for time-triggered transaction in CARA
CARA Implementation in CHARON • CARA System • Pump Monitor • Monitor Plug-In • Monitor Continuity • Monitor AirOk • Monitor OccOk • Monitor backEMF • Monitor Impedance • BP monitor • BP Detector • Cuff Detector • AL Detector • PW Detector • BP Handler • Initial Auto-control • Valid BP Handler • Cuff Handler in AC • AL Handler in AC • PW Handler in AC • BP Checker • Control Algorithm • Mode control algorithm • Polling algorithm • Additional simulation • Environment • To catch the changes and setting in GUI • Propaq Platform • To simulate the hardware propaq, buffering the BP values and detecting time • System Clock • To create a system-scale timer
Explanations (1) • Cuff (AL, PW) Detector • Detect BP data stream from Propaq, update cuff (AL, PW) value if new arrival, and calculate the average cuff value every minute • Cuff (AL, PW) Handler in AC • In Auto-control, handle cuff (AL, PW) value to decide whether it is lost, whether it can be as the control BP source, whether it is required to be corroborated, and determine the driven voltage for pump to control the infusion speed
Explanations (2) • Initial Auto-Control • Decide the initial control BP source and value during initial Auto-control stage • Valid BP Handler • keep trace whether the control BP source is valid during Auto-control mode • Mode Control Algorithm • Keep trace the pump mode: unknown, wait, manual, initial auto-control, and auto-control • Polling Algorithm • Keep trace of the back EMF and impedance value to decide the polling status, and get the current flow rate, accumulated infusion volume, and average flow rate every minute
Java-Based GUI By clicking the “Change Conditions” button, users can change the environment setting for CARA (as following figure)
Run-time Dialog Windows • Start Ok Window • When CHARON simulation satisfies the conditions to trigger initial Auto-control mode, it will send a signal to GUI. So, GUI will pop up the “Start Ok Window”. • Set Point Window • After the above ok button is clicked, GUI shows the “change set point” button, if it is pressed, a dialog window will be pop up.
Override Window • During corroboration, CARA allows user to decide whether to override or not. At that time, GUI will pop up such dialog window. • Terminate Window • During Auto-Control mode, a “Terminate AC” button is visible. When it is clicked, another dialog window is available.
Run-Time GUI • During simulation, GUI will display messages and show/hide some buttons corresponding to different mode Initial state of GUI After click “start ok” button Running in Auto-Control mode
M100 Infusion Pump Experiment Design
Motivation We have been modeling an abstract system Physical setup allows us to understand system better, test code against the real hardware.
Hardware Simulation of CARA The Penn Team has developed a hardware platform to simulate the functions of the CARA system and assist in evaluating the simulation software.
Hardware Simulation Components • The hardware consists of four components: • M100 Infusion Pump • 2 1000mL flasks • Pressure Sensor • A/D interface
M100 Infusion Pump The M100 Infusion Pump interfaces with the controlling computer via the gold connector on the right. This allows computer control of the pump’s functions.
Pressure Sensor We built a simple pressure sensor which detects 0 – 6 psi and outputs 0 – 5 volts. It is compatible with our d/a converter and the pressure ranges we wish to experiment with.
Operation of the System • Normal operation consists of running the pump until the pressure in the top flask reaches the desired level. • ‘Since the flask is sealed, pumping fluid into it raises the pressure, and this is detected by the pressure sensor. • The system can also detect and react to faults.
Starting Condition Luer Connector 1/8” PP Tubing Data Pressure Sensor Quanser MultiQ Swing
Pump is Primed Luer Connector 1/8” PP Tubing Data Pressure Sensor Quanser MultiQ Swing
Pumping Starts Luer Connector 1/8” PP Tubing Data Pressure Sensor Quanser MultiQ Swing
Normal Operation Luer Connector 1/8” PP Tubing Data Pressure Sensor Quanser MultiQ Swing
Bleeding Luer Connector 1/8” PP Tubing Data Pressure Sensor Quanser MultiQ Swing
Hardware Prototype • We connected the Simulation and GUI to the hardware setup. • This allowed us to write a CHARON specification and quickly see it run on the actual hardware.
Future Work • Perfect Charon / Gui / Hardware interaction • Build a general purpose prototyping platform based on Charon