Index: HemodialysisDevice.py =================================================================== diff -u -r0c621e531fc03a19aef610cf9f06cf28dd9285cf -rb83f5ec66b645fac0d11fe649035512cf8b0d8e5 --- HemodialysisDevice.py (.../HemodialysisDevice.py) (revision 0c621e531fc03a19aef610cf9f06cf28dd9285cf) +++ HemodialysisDevice.py (.../HemodialysisDevice.py) (revision b83f5ec66b645fac0d11fe649035512cf8b0d8e5) @@ -23,7 +23,7 @@ """ \class HD - \brief Hemodialysis Device (HD) Dialin object API. It provides the basic interface to communicate with + \brief Hemodialysis Device (HD) Dialin API object. It provides the basic interface to communicate with the HD board """ @@ -34,7 +34,7 @@ \param bus: can bus, e.g. "can0" - \returns HD object that allows communication with board via port + \returns HD object provides test/service commands for the HD sub-system. \details For example: @@ -44,31 +44,41 @@ # Create listener self.can_interface = DialityCanMessenger(can_interface=can__interface) self.can_interface.start() + # Create command groups self._Basics = HD.HD__Basics(self) self.Alarms = HD.HD_Alarms(self) self.Buttons = HD.HD_Buttons(self) self.BloodFlow = HD.HD_BloodFlow(self) self.Watchdog = HD.HD_Watchdog(self) + # Create constants + self.NO_RESET = 0 + self.RESET = 1 class HD__Basics: """ \class HD__Basics \brief Hemodialysis Device (HD) Dialin API sub-class for basic HD commands. - """ def __init__(self, outer_instance): self.outer_instance = outer_instance + """ + HD__Basics constructor + \param outer_instance: reference to the HD (outer) class. + \returns HD__Basics object. + """ + + def login(self): """ - send login command via serial port + Constructs and sends a login command via CAN bus. Login required before \n + other commands can be sent to the HD. \returns 1 if logged in, 0 if log in failed - """ channel_id = 0x400 @@ -94,9 +104,11 @@ def HDMessageInsert(self, msg): """ - sends the insert HD message command + Constructs and sends the insert HD message command. Given message will \n + be inserted into the HD's received message queue for processing. \param msg: byte array - properly formatted HD message to insert + \returns 1 if successful, zero otherwise """ @@ -129,17 +141,23 @@ \class HD_Buttons \brief Hemodialysis Device (HD) Dialin API sub-class for button related commands. - """ def __init__(self, outer_instance): self.outer_instance = outer_instance + """ + HD_Buttons constructor + + \param outer_instance: reference to the HD (outer) class. + \returns HD_Buttons object. + """ + def OffButtonOverride(self, reset, state): """ - sends the Off button override command + Constructs and sends the Off button override command \param reset: integer - 1 to reset a previous override, 0 to override \param state: integer - 1 to override off button to "pressed", 0 to "released" @@ -178,7 +196,7 @@ def StopButtonOverride(self, reset, state): """ - sends the Stop button override command + Constructs and sends the Stop button override command \param reset: integer - 1 to reset a previous override, 0 to override \param state: integer - 1 to override stop button to "pressed", 0 to "released" @@ -220,15 +238,22 @@ \class HD_Watchdog \brief Hemodialysis Device (HD) Dialin API sub-class for watchdog related commands. - """ def __init__(self, outer_instance): self.outer_instance = outer_instance + """ + HD_Watchdog constructor + \param outer_instance: reference to the HD (outer) class. + + \returns HD_Watchdog object. + """ + + def WatchdogTaskCheckinOverride(self, reset, state, task): """ - sends the watchdog task check-in override command + Constructs and sends the watchdog task check-in override command \param reset: integer - 1 to reset a previous override, 0 to override \param state: integer - 1 for task checked in, 0 for task not checked in @@ -270,15 +295,22 @@ \class HD_Alarms \brief Hemodialysis Device (HD) Dialin API sub-class for alarm related commands. - """ def __init__(self, outer_instance): self.outer_instance = outer_instance + """ + HD_Alarms constructor + \param outer_instance: reference to the HD (outer) class. + + \returns HD_Alarms object. + """ + + def AlarmStateOverride(self, reset, state, alarm): """ - sends the alarm state override command + Constructs and sends the alarm state override command \param reset: integer - 1 to reset a previous override, 0 to override \param state: integer - 1 for alarm active, 0 for alarm inactive @@ -319,7 +351,7 @@ def AlarmTimeOverride(self, reset, time_ms, alarm): """ - sends the alarm time override command + Constructs and sends the alarm time override command \param reset: integer - 1 to reset a previous override, 0 to override \param time_ms: integer - time (in ms) since alarm was activated @@ -360,7 +392,7 @@ def AlarmLampPatternOverride(self, reset, pattern): """ - sends the alarm lamp pattern override command. + Constructs and sends the alarm lamp pattern override command. \param reset: integer - 1 to reset a previous override, 0 to override \param pattern: integer - ID of alarm lamp pattern to override with @@ -428,10 +460,18 @@ def __init__(self, outer_instance): self.outer_instance = outer_instance + """ + HD_BloodFlow constructor + \param outer_instance: reference to the HD (outer) class. + + \returns HD_BloodFlow object. + """ + + def BloodFlowSetPointOverride(self, reset, flow): """ - sends the blood flow set point override command + Constructs and sends the blood flow set point override command \param reset: integer - 1 to reset a previous override, 0 to override \param flow: integer - flow set point (in mL/min) to override with @@ -470,7 +510,7 @@ def BloodFlowMeasuredOverride(self, reset, flow): """ - sends the measured blood flow override command + Constructs and sends the measured blood flow override command \param reset: integer - 1 to reset a previous override, 0 to override \param flow: integer - measured flow (in mL/min) to override with @@ -506,10 +546,14 @@ return False + # TODO - add override command for blood pump motor speed (motor hall sensor via FPGA) + # TODO - add override command for blood pump speed (pump hall sensor via NHET?) - def BloodPumpMeasuredSpeedOverride(self, reset, speed): + + def BloodPumpMCMeasuredSpeedOverride(self, reset, speed): """ - sends the measured blood pump speed override command + Constructs and sends the measured blood pump motor controller speed \n + override command. \param reset: integer - 1 to reset a previous override, 0 to override \param speed: integer - speed (in RPM) to override with @@ -548,7 +592,7 @@ def BloodPumpMeasuredCurrentOverride(self, reset, curr): """ - sends the measured blood pump motor current override command + Constructs and sends the measured blood pump motor current override command \param reset: integer - 1 to reset a previous override, 0 to override \param curr: integer - current (in mA) to override with @@ -587,7 +631,7 @@ def BloodFlowBroadcastIntervalOverride(self, reset, ms): """ - sends the measured flow broadcast interval override command + Constructs and sends the measured flow broadcast interval override command \param reset: integer - 1 to reset a previous override, 0 to override \param ms: integer - interval (in ms) to override with @@ -648,16 +692,3 @@ # wait 2 seconds and then login to HD as a tester sleep(2) hd._Basics.login() - - # wait 5 seconds and then override the blood flow data interval to every 2 seconds - sleep(5) - hd.BloodFlow.BloodFlowBroadcastIntervalOverride(0,2000) -# hd.OffButtonOverride(0,1) - - # wait 5 seconds and then override the blood flow data interval to every 200 ms - sleep(5) - hd.BloodFlow.BloodFlowBroadcastIntervalOverride(0,200) - - # wait 5 seconds and then reset the blood flow data interval to normal - sleep(5) - hd.BloodFlow.BloodFlowBroadcastIntervalOverride(1,0)