Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
commands.c
00001 /************************************************************** 00002 * commands.c 00003 * 00004 * This Module contains the command handler and menus for the 00005 * Medical alert tone demo 00006 * 00007 * Copyright(C) 2007, NXP Semiconductor 00008 * All rights reserved. 00009 * 00010 * Port to mbed 2012 (WH) 00011 **************************************************************/ 00012 00013 #include "mbed.h" 00014 #include "commands.h" 00015 #include "IEC60601-1-8.h" 00016 00017 //Externals from main 00018 extern Serial pc; 00019 extern bool running; 00020 extern IEC60601 IEC_Alarm; 00021 00022 enum State_Type {MAIN_STATE, HI_PRI_STATE, MED_PRI_STATE, LO_PRI_STATE, TST_STATE}; 00023 State_Type cmd_state; 00024 00025 unsigned char proc_cmd; 00026 00027 // Menus 00028 void MainMenu(void) { 00029 pc.printf ("Main Commands:\n\r"); 00030 pc.printf ("Press '0' to Exit\n\r"); 00031 pc.printf ("Press '1' for High Priority Alarm Menu\n\r"); 00032 pc.printf ("Press '2' for Medium Priority Alarm Menu\n\r"); 00033 pc.printf ("Press '3' for Low Priority Alarm Menu\n\r"); 00034 pc.printf ("Press '4' for Test Menu\n\r"); 00035 pc.printf ("Enter Command Number: "); 00036 } 00037 00038 void HPMenu(void) { 00039 pc.printf ("High Priority Commands:\n\r"); 00040 pc.printf (" 0 - Exit High Priority Commands\n\r"); 00041 pc.printf (" 1 - High Priority General Alarm\n\r"); 00042 pc.printf (" 2 - High Priority Cardiac Alarm\n\r"); 00043 pc.printf (" 3 - High Priority Artificial Perfusion Alarm\n\r"); 00044 pc.printf (" 4 - High Priority Ventilation Alarm\n\r"); 00045 pc.printf (" 5 - High Priority Temperature Alarm\n\r"); 00046 pc.printf (" 6 - High Priority Oxygen Alarm\n\r"); 00047 pc.printf (" 7 - High Priority Drug Delivery Alarm\n\r"); 00048 pc.printf (" 8 - High Priority Equipment/Supply Failure Alarm\n\r"); 00049 pc.printf ("Enter Command Number: "); 00050 } 00051 00052 void MPMenu(void) { 00053 pc.printf ("Medium Priority Commands:\n\r"); 00054 pc.printf (" 0 - Exit Medium Priority Commands\n\r"); 00055 pc.printf (" 1 - Medium Priority General Alarm\n\r"); 00056 pc.printf (" 2 - Medium Priority Cardiac Alarm\n\r"); 00057 pc.printf (" 3 - Medium Priority Artificial Perfusion Alarm\n\r"); 00058 pc.printf (" 4 - Medium Priority Ventilation Alarm\n\r"); 00059 pc.printf (" 5 - Medium Priority Temperature Alarm\n\r"); 00060 pc.printf (" 6 - Medium Priority Oxygen Alarm\n\r"); 00061 pc.printf (" 7 - Medium Priority Drug Delivery Alarm\n\r"); 00062 pc.printf (" 8 - Medium Priority Equipment/Supply Failure Alarm\n\r"); 00063 pc.printf ("Enter Command Number: "); 00064 } 00065 00066 void LPMenu(void) { 00067 pc.printf ("Low Priority Commands:\n\r"); 00068 pc.printf (" 0 - Exit Low Priority Commands\n\r"); 00069 pc.printf (" 1 - Low Priority General Alarm\n\r"); 00070 pc.printf ("Enter Command Number: "); 00071 00072 } 00073 00074 void TSTMenu(void) { 00075 pc.printf ("Test Commands:\n\r"); 00076 pc.printf (" 0 - Exit Test Commands\n\r"); 00077 pc.printf (" 1 - Sound Low Multi-Tone\n\r"); 00078 pc.printf (" 2 - Sound High Multi-Tone\n\r"); 00079 pc.printf (" 3 - Sound Low Single Tone\n\r"); 00080 pc.printf (" 4 - Sound High Single Tone\n\r"); 00081 pc.printf (" 5 - Reset Test Settings\n\r"); 00082 pc.printf ("Enter Command Number: "); 00083 00084 } 00085 00086 void ShowMenu() { 00087 00088 switch (cmd_state) { 00089 case MAIN_STATE: 00090 MainMenu(); 00091 break; 00092 case HI_PRI_STATE: 00093 HPMenu(); 00094 break; 00095 case MED_PRI_STATE: 00096 MPMenu(); 00097 break; 00098 case LO_PRI_STATE: 00099 LPMenu(); 00100 break; 00101 case TST_STATE: 00102 TSTMenu(); 00103 break; 00104 default: 00105 break; 00106 } 00107 } 00108 00109 00110 00111 //Commands 00112 void MainCommnds(char command) { 00113 switch (command) { 00114 case '0': 00115 pc.printf("Done\n\r"); 00116 running = false; 00117 break; 00118 00119 case '1': 00120 cmd_state = HI_PRI_STATE; 00121 break; 00122 00123 case '2': 00124 cmd_state = MED_PRI_STATE; 00125 break; 00126 00127 case '3': 00128 cmd_state = LO_PRI_STATE; 00129 break; 00130 00131 case '4': 00132 cmd_state = TST_STATE; 00133 break; 00134 default: 00135 break; 00136 } 00137 } 00138 00139 00140 void HPCommnds(char command) { 00141 00142 switch (command) 00143 { 00144 case '0': 00145 cmd_state = MAIN_STATE; 00146 break; 00147 case '1': 00148 pc.printf ("High Priority General Alarm\n\r"); 00149 IEC_Alarm.TurnOnAlarm(HIGH, GENERAL); 00150 break; 00151 case '2': 00152 pc.printf ("High Priority Cardiac Alarm\n\r"); 00153 IEC_Alarm.TurnOnAlarm(HIGH, CARDIOVASCULAR); 00154 break; 00155 case '3': 00156 pc.printf ("High Priority Artificial Perfusion Alarm\n\r"); 00157 IEC_Alarm.TurnOnAlarm(HIGH, PERFUSION); 00158 break; 00159 case '4': 00160 pc.printf ("High Priority Ventilation Alarm\n\r"); 00161 IEC_Alarm.TurnOnAlarm(HIGH, VENTILATION); 00162 break; 00163 case '5': 00164 pc.printf ("High Priority Temperature Alarm\n\r"); 00165 IEC_Alarm.TurnOnAlarm(HIGH, TEMPERATURE); 00166 break; 00167 case '6': 00168 pc.printf ("High Priority Oxygen Alarm\n\r"); 00169 IEC_Alarm.TurnOnAlarm(HIGH, OXYGEN); 00170 break; 00171 case '7': 00172 pc.printf ("High Priority Drug Delivery Alarm\n\r"); 00173 IEC_Alarm.TurnOnAlarm(HIGH, DRUG_DELIVERY); 00174 break; 00175 case '8': 00176 pc.printf ("High Priority Equipment/Supply Failure Alarm\n\r"); 00177 IEC_Alarm.TurnOnAlarm(HIGH, POWER_FAIL); 00178 break; 00179 default: 00180 pc.printf ("Command not supported\n\r"); 00181 break; 00182 } 00183 } 00184 00185 void MPCommnds(char command) { 00186 00187 switch (command) 00188 { 00189 case '0': 00190 cmd_state = MAIN_STATE; 00191 break; 00192 case '1': 00193 pc.printf ("Medium Priority General Alarm\n\r"); 00194 IEC_Alarm.TurnOnAlarm(MEDIUM, GENERAL); 00195 break; 00196 case '2': 00197 pc.printf ("Medium Priority Cardiac Alarm\n\r"); 00198 IEC_Alarm.TurnOnAlarm(MEDIUM, CARDIOVASCULAR); 00199 break; 00200 case '3': 00201 pc.printf ("Medium Priority Artificial Perfusion Alarm\n\r"); 00202 IEC_Alarm.TurnOnAlarm(MEDIUM, PERFUSION); 00203 break; 00204 case '4': 00205 pc.printf ("Medium Priority Ventilation Alarm\n\r"); 00206 IEC_Alarm.TurnOnAlarm(MEDIUM, VENTILATION); 00207 break; 00208 case '5': 00209 pc.printf ("Medium Priority Temperature Alarm\n\r"); 00210 IEC_Alarm.TurnOnAlarm(MEDIUM, TEMPERATURE); 00211 break; 00212 case '6': 00213 pc.printf ("Medium Priority Oxygen Alarm\n\r"); 00214 IEC_Alarm.TurnOnAlarm(MEDIUM, OXYGEN); 00215 break; 00216 case '7': 00217 pc.printf ("Medium Priority Drug Delivery Alarm\n\r"); 00218 IEC_Alarm.TurnOnAlarm(MEDIUM, DRUG_DELIVERY); 00219 break; 00220 case '8': 00221 pc.printf ("Medium Priority Equipment/Supply Failure Alarm\n\r"); 00222 IEC_Alarm.TurnOnAlarm(MEDIUM, POWER_FAIL); 00223 break; 00224 default: 00225 pc.printf ("Command not supported\n\r"); 00226 break; 00227 } 00228 } 00229 00230 void LPCommnds(char command) 00231 { 00232 switch (command) { 00233 case '0': 00234 cmd_state = MAIN_STATE; 00235 break; 00236 case '1': 00237 pc.printf ("Low Priority Alarm\n\r"); 00238 IEC_Alarm.TurnOnAlarm(LOW, LOW_ALARM); 00239 break; 00240 00241 default: 00242 pc.printf ("Command not supported\n\r"); 00243 break; 00244 } 00245 } 00246 00247 void TestCommnds(char command) { 00248 00249 switch (command) { 00250 case '0': 00251 cmd_state = MAIN_STATE; 00252 IEC_Alarm.TestAlarm(C4, 255, 255, 255, 255, 255); // make sure weightfactors are reset 00253 break; 00254 case '1': 00255 pc.printf ("Sound Low Multi Tone\n\r"); 00256 IEC_Alarm.TestAlarm(C4, 255, 255, 255, 255, 255); 00257 break; 00258 case '2': 00259 pc.printf ("Sound High Multi Tone\n\r"); 00260 IEC_Alarm.TestAlarm(C5, 255, 255, 255, 255, 255); 00261 break; 00262 case '3': 00263 pc.printf ("Sound Low Single Tone\n\r"); 00264 IEC_Alarm.TestAlarm(C4, 255, 0, 0, 0, 0); 00265 break; 00266 case '4': 00267 pc.printf ("Sound High Single Tone\n\r"); 00268 IEC_Alarm.TestAlarm(C5, 0, 0, 0, 0, 255); 00269 break; 00270 case '5': 00271 pc.printf ("Reset Test Settings\n\r"); 00272 IEC_Alarm.TestAlarm(C4, 255, 255, 255, 255, 255); 00273 break; 00274 default: 00275 pc.printf ("Command not supported\n\r"); 00276 break; 00277 } 00278 } 00279 00280 void InitCommand(void) { 00281 00282 cmd_state = MAIN_STATE; 00283 } 00284 00285 00286 00287 void DecodeCommand(char command) { 00288 00289 switch (cmd_state) { 00290 case MAIN_STATE: 00291 // pc.printf ("Main Commands:\n\r"); 00292 MainCommnds(command); 00293 break; 00294 00295 case HI_PRI_STATE: 00296 // pc.printf ("High Priority Commands:\n\r"); 00297 HPCommnds(command); 00298 break; 00299 00300 case MED_PRI_STATE: 00301 // pc.printf ("Medium Priority Commands:\n\r"); 00302 MPCommnds(command); 00303 break; 00304 00305 case LO_PRI_STATE: 00306 // pc.printf ("Low Priority Commands:\n\r"); 00307 LPCommnds(command); 00308 break; 00309 00310 case TST_STATE: 00311 // pc.printf ("Test Commands:\n\r"); 00312 TestCommnds(command); 00313 break; 00314 00315 default: 00316 break; 00317 } 00318 } 00319 00320 00321 00322 00323 00324
Generated on Wed Jul 13 2022 14:29:31 by
1.7.2
IEC60601-1-8 Audible Alert Generator