File view
| 1 | //$Id: ism_setup_state.lib,v 1.11 2008-09-10 00:41:50 charlie Exp $ |
| 2 | /* |
| 3 | $Log: ism_setup_state.lib,v $ |
| 4 | |
| 5 | |
| 6 | */ |
| 7 | |
| 8 | /*** BeginHeader */ |
| 9 | |
| 10 | #ifndef __ISM_SETUP_STATE_4711_ |
| 11 | #define __ISM_SETUP_STATE_4711_ |
| 12 | |
| 13 | /*** EndHeader */ |
| 14 | |
| 15 | /*** BeginHeader |
| 16 | |
| 17 | InitializeSetupState |
| 18 | MenuState |
| 19 | SetupStateHandler |
| 20 | |
| 21 | */ |
| 22 | |
| 23 | |
| 24 | //Global function prototypes ************************************************************ |
| 25 | |
| 26 | nodebug void InitializeSetupState(int aCode); //initialize setup state |
| 27 | nodebug void MenuState(); // Menu state machine |
| 28 | nodebug void SetupStateHandler(); //call next state |
| 29 | |
| 30 | /*** EndHeader */ |
| 31 | |
| 32 | //Messages ****************************************************************************** |
| 33 | |
| 34 | char EndSetupMsg[DISPLAY_LENGTH_DEF]; |
| 35 | char SetupTopLine[DISPLAY_LENGTH + 1]; |
| 36 | char SetupBottomLine[DISPLAY_LENGTH + 1]; |
| 37 | char blankDisplay[DISPLAY_LENGTH+1]; |
| 38 | |
| 39 | //Local state machine variables ********************************************************* |
| 40 | |
| 41 | int PreviousSetupState; // index for previous active state |
| 42 | int SetupState; // index pointing to next state |
| 43 | int RestartState; |
| 44 | int SetupDone; // Setup Done Flag |
| 45 | int ProductID; // Current product |
| 46 | int pwDest; |
| 47 | int UpdateFlag; |
| 48 | Ms OnTime; |
| 49 | Ms OffTime; |
| 50 | |
| 51 | Ms RunTime; // Temp storage of time info |
| 52 | int Turbine; |
| 53 | |
| 54 | //Local function prototypes ************************************************************* |
| 55 | |
| 56 | // Resilence |
| 57 | nodebug void RunTimeSetup(int first); |
| 58 | nodebug void ResilVal(int first); |
| 59 | nodebug void DurTime(int first); |
| 60 | nodebug void DelayTime(int first); |
| 61 | nodebug void DisableTimeSetup(int first); |
| 62 | nodebug void DisableStartTime(int first); |
| 63 | nodebug void DisableEndTime(int first); |
| 64 | nodebug void SumpMenu(int first); |
| 65 | nodebug void SumpMenuType(int first); |
| 66 | nodebug void SumpMenuShutDown(int first); |
| 67 | nodebug void PressureMenu(int first); |
| 68 | nodebug void MinRunPressure(int first); |
| 69 | nodebug void TestHighPressure(int first); |
| 70 | nodebug void TestLowPressure(int first); |
| 71 | nodebug void TimeOfDay(int first); |
| 72 | nodebug void TestMenu(int first); |
| 73 | nodebug void RetriesRePres(int first); |
| 74 | nodebug void Retries3GPH(int first); |
| 75 | void ShutDownType(int first); |
| 76 | void FlowDelayTime(int first); |
| 77 | void PresCheckTime(int first); |
| 78 | nodebug void ModBusConfig(int first); |
| 79 | nodebug void ModBusCommSetting(int first); |
| 80 | nodebug void ModBusAddress(int first); |
| 81 | nodebug void ModBusRegOffset(int first); |
| 82 | nodebug void SiteConfig(int first); |
| 83 | nodebug void NumOfTurbines(int first); |
| 84 | nodebug void LeadTurbines(int first); |
| 85 | nodebug void LeakDetectors(int first); |
| 86 | nodebug void RunTurbines(int first); |
| 87 | nodebug void Rotate(int first); |
| 88 | nodebug void TurbineAuth(int first); |
| 89 | nodebug void SuctionCV(int first); |
| 90 | nodebug void PressureCV(int first); |
| 91 | nodebug void DispCV(int first); |
| 92 | nodebug void OnOffTime(int first); |
| 93 | nodebug void Reset(int first); |
| 94 | nodebug void SetupOverRide(int first); |
| 95 | nodebug void View(int first); |
| 96 | nodebug void PresTestProd(int first); |
| 97 | void PrecisionTestMenu(int first); |
| 98 | nodebug void Print(int first); |
| 99 | nodebug int TestSetup(); |
| 100 | |
| 101 | |
| 102 | //SetupState indexes list *************************************************************** |
| 103 | |
| 104 | enum |
| 105 | { |
| 106 | SETUPNOSTATE = -1, |
| 107 | SETUP_RUN_TIME_SETUP = 0, |
| 108 | SETUP_RESIL_VAL = 1, |
| 109 | SETUP_RUN_TIME = 2, |
| 110 | SETUP_DELAY_TIME, |
| 111 | SETUP_DISABLE_TIME_SETUP, |
| 112 | SETUP_DISABLE_START_TIME, |
| 113 | SETUP_DISABLE_END_TIME, |
| 114 | SETUP_SUMP_MENU, |
| 115 | SETUP_SUMP_MENU_TYPE, |
| 116 | SETUP_SUMP_MENU_SHUTDOWN, |
| 117 | SETUP_PRESSURE_MENU, |
| 118 | SETUP_RUN_PRESSURE, |
| 119 | SETUP_HIGH_PRESSURE, |
| 120 | SETUP_LOW_PRESSURE, |
| 121 | SETUP_TEST_MENU, |
| 122 | SETUP_RETRIES_REPRES, |
| 123 | SETUP_RETRIES_3GPH, |
| 124 | SETUP_SHUTDOWN_TYPE, |
| 125 | SETUP_FLOWDELAY_TIME, |
| 126 | SETUP_PRESCHECK_TIME, |
| 127 | SETUP_TIME_OF_DAY, |
| 128 | SETUP_MODBUS_CONFIG, |
| 129 | SETUP_MODBUS_COMM_SETTINGS, |
| 130 | SETUP_MODBUS_ADDRESS, |
| 131 | SETUP_MODBUS_REG_OFFSET, |
| 132 | SETUP_SITE_CONFIG, |
| 133 | SETUP_NUM_OF_TURBINES, |
| 134 | SETUP_LEAD_TURBINES, |
| 135 | SETUP_LEAK_DETECTOR, |
| 136 | SETUP_RUN_TURBINES, |
| 137 | SETUP_ROTATE, |
| 138 | SETUP_TURBINE_AUTH, |
| 139 | SETUP_SUCTION_CV, |
| 140 | SETUP_PRESSURE_CV, |
| 141 | SETUP_DISP_CV, |
| 142 | SETUP_ONOFF_TIME, |
| 143 | SETUP_RESET, |
| 144 | SETUP_OVERRIDE, |
| 145 | SETUP_VIEW, |
| 146 | SETUP_PREC_TEST_PROD, |
| 147 | SETUP_PRECISION_TEST, |
| 148 | SETUP_PRINT, |
| 149 | }; |
| 150 | |
| 151 | //SetupState machine table ************************************************************** |
| 152 | |
| 153 | void (* const SetupStateTable[]) () = |
| 154 | { |
| 155 | RunTimeSetup, |
| 156 | ResilVal, |
| 157 | DurTime, |
| 158 | DelayTime, |
| 159 | DisableTimeSetup, |
| 160 | DisableStartTime, |
| 161 | DisableEndTime, |
| 162 | SumpMenu, |
| 163 | SumpMenuType, |
| 164 | SumpMenuShutDown, |
| 165 | PressureMenu, |
| 166 | MinRunPressure, |
| 167 | TestHighPressure, |
| 168 | TestLowPressure, |
| 169 | TestMenu, |
| 170 | RetriesRePres, |
| 171 | Retries3GPH, |
| 172 | ShutDownType, |
| 173 | FlowDelayTime, |
| 174 | PresCheckTime, |
| 175 | TimeOfDay, |
| 176 | ModBusConfig, |
| 177 | ModBusCommSetting, |
| 178 | ModBusAddress, |
| 179 | ModBusRegOffset, |
| 180 | SiteConfig, |
| 181 | NumOfTurbines, |
| 182 | LeadTurbines, |
| 183 | LeakDetectors, |
| 184 | RunTurbines, |
| 185 | Rotate, |
| 186 | TurbineAuth, |
| 187 | SuctionCV, |
| 188 | PressureCV, |
| 189 | DispCV, |
| 190 | OnOffTime, |
| 191 | Reset, |
| 192 | SetupOverRide, |
| 193 | View, |
| 194 | PresTestProd, |
| 195 | PrecisionTestMenu, |
| 196 | |
| 197 | }; |
| 198 | |
| 199 | |
| 200 | //Initialize setup state **************************************************************** |
| 201 | |
| 202 | void InitializeSetupState (int aCode) |
| 203 | { |
| 204 | if (aCode == RESETPB) |
| 205 | SetupState = SETUP_RESET; |
| 206 | else if (aCode == SETUPPB) |
| 207 | SetupState = SETUP_RUN_TIME_SETUP; // init state to SETUPDONE to indicate beginning |
| 208 | else if (aCode == TESTPB) |
| 209 | SetupState = SETUP_PREC_TEST_PROD; |
| 210 | else if (aCode == PRINTPB) |
| 211 | SetupState = SETUP_PRINT; |
| 212 | |
| 213 | PreviousSetupState = SETUPNOSTATE; // init prev state to SETUPNOSTATE, diff from SETUPDONE |
| 214 | RestartState = 0; |
| 215 | ProductID = 0; // Set first produxt |
| 216 | Config.MenuFlag = 1; // Set in menu flag |
| 217 | Disp.UpdateFlag = 0; // Set dont update display flag |
| 218 | SetupDone = 0; // Clear done setup |
| 219 | strcpy(blankDisplay, " "); |
| 220 | UpdateFlag = 0; // Reset Flash write flag |
| 221 | } |
| 222 | |
| 223 | // MenuState ******************************************************************* |
| 224 | |
| 225 | void MenuState() |
| 226 | { |
| 227 | int i; |
| 228 | |
| 229 | if (Config.MenuFlag) |
| 230 | SetupStateHandler(); |
| 231 | else if (GetKeyEdgeFlag()) |
| 232 | { |
| 233 | if (GetKeyCode() == SETUPPB) |
| 234 | { |
| 235 | InitializeSetupState (SETUPPB); |
| 236 | SetupStateHandler(); |
| 237 | } |
| 238 | else if (GetKeyCode() == RESETPB) |
| 239 | { |
| 240 | if (Config.SiteConfigFlag) |
| 241 | { |
| 242 | InitializeSetupState (RESETPB); |
| 243 | SetupStateHandler(); |
| 244 | } |
| 245 | } |
| 246 | else if (GetKeyCode() == TESTPB) |
| 247 | { |
| 248 | |
| 249 | if (Config.SiteConfigFlag) |
| 250 | { |
| 251 | InitializeSetupState (TESTPB); |
| 252 | SetupStateHandler(); |
| 253 | } |
| 254 | |
| 255 | } |
| 256 | else if (GetKeyCode() == PRINTPB) |
| 257 | { |
| 258 | #if PRINTER_ON |
| 259 | if (Config.SiteConfigFlag) |
| 260 | { |
| 261 | InitializeSetupState (PRINTPB); |
| 262 | SetupStateHandler(); |
| 263 | } |
| 264 | #endif |
| 265 | } |
| 266 | else if (GetKeyCode() == ENTERPB) |
| 267 | { |
| 268 | Disp.Hold = 1; |
| 269 | Disp.HoldTimer = MS_TIMER; |
| 270 | } |
| 271 | else if (GetKeyCode() == CLEARPB) |
| 272 | { |
| 273 | Disp.Hold = 0; |
| 274 | } |
| 275 | else if ((GetKeyCode() == UPPB) && Config.ViewCnl != -1) |
| 276 | { |
| 277 | if (Config.ViewCnl == Config.N_Turbines - 1) |
| 278 | Config.ViewCnl++; |
| 279 | } |
| 280 | else if ((GetKeyCode() == DOWNPB) && Config.ViewCnl != -1) |
| 281 | { |
| 282 | if (Config.ViewCnl != 0) |
| 283 | Config.ViewCnl--; |
| 284 | } |
| 285 | } |
| 286 | |
| 287 | #if MODBUS_S_ON |
| 288 | // Scan Comm Control Commands |
| 289 | if (GetWrControlReg(RESET_ALL_CHANNELS, 0)) |
| 290 | { |
| 291 | for (i = 0 ; i < Config.N_Turbines ; i++) |
| 292 | { |
| 293 | Channel[i].ResetPbFlag = 1; |
| 294 | } |
| 295 | SetWrControlReg(RESET_ALL_CHANNELS, 0, OFF); |
| 296 | ResetLDNIOPS(); |
| 297 | |
| 298 | } |
| 299 | else |
| 300 | SetWrControlReg(RESET_ALL_CHANNELS, 0, OFF); |
| 301 | |
| 302 | for (i = 0 ; i < N_ISM ; i++) |
| 303 | { |
| 304 | // Reset |
| 305 | if (GetWrControlReg(RESET_CHANNEL, i)) |
| 306 | { |
| 307 | Channel[i].ResetPbFlag = 1; |
| 308 | SetWrControlReg(RESET_CHANNEL, i, OFF); |
| 309 | ResetLDNIOPS(); |
| 310 | |
| 311 | } |
| 312 | else |
| 313 | SetWrControlReg(RESET_CHANNEL, i, OFF); |
| 314 | } |
| 315 | |
| 316 | for (i = 0 ; i < N_PROD ; i++) |
| 317 | { |
| 318 | // 0.1 Test |
| 319 | if (GetWrControlReg(PRECISION_TEST_01, i)) |
| 320 | { |
| 321 | if Channel[Product[i].LeadTurbine].PrecTest.Status == PT_INACTIVE) |
| 322 | { |
| 323 | Channel[Product[i].LeadTurbine].PrecTest.Status = PT_PENDING; |
| 324 | Channel[Product[i].LeadTurbine].PrecTest.Type = TEST_PNT1; |
| 325 | SetWrControlReg(PRECISION_TEST_01, i, OFF); |
| 326 | } |
| 327 | } |
| 328 | else |
| 329 | SetWrControlReg(PRECISION_TEST_01, i, OFF); |
| 330 | |
| 331 | // 0.2 Test |
| 332 | if (GetWrControlReg(PRECISION_TEST_02, i)) |
| 333 | { |
| 334 | if Channel[Product[i].LeadTurbine].PrecTest.Status == PT_INACTIVE) |
| 335 | { |
| 336 | Channel[Product[i].LeadTurbine].PrecTest.Status = PT_PENDING; |
| 337 | Channel[Product[i].LeadTurbine].PrecTest.Type = TEST_PNT2; |
| 338 | SetWrControlReg(PRECISION_TEST_02, i, OFF); |
| 339 | } |
| 340 | } |
| 341 | else |
| 342 | SetWrControlReg(PRECISION_TEST_02, i, OFF); |
| 343 | |
| 344 | // Abort Test |
| 345 | if (GetWrControlReg(PRECISION_TEST_ABORT, i)) |
| 346 | { |
| 347 | TestStop(&Channel[Product[ProductID].LeadTurbine].PrecTest) |
| 348 | SetWrControlReg(PRECISION_TEST_ABORT, i, OFF); |
| 349 | } |
| 350 | else |
| 351 | SetWrControlReg(PRECISION_TEST_ABORT, i, OFF); |
| 352 | } |
| 353 | #endif |
| 354 | } |
| 355 | |
| 356 | //SetupState handler ******************************************************************** |
| 357 | |
| 358 | void SetupStateHandler () // direct program to next state |
| 359 | { |
| 360 | int first; |
| 361 | int tmpSetupState; |
| 362 | first = 0; |
| 363 | |
| 364 | if (PreviousSetupState != SetupState || RestartState) // test for first time through state |
| 365 | { |
| 366 | first = 1; |
| 367 | RestartState = 0; |
| 368 | } |
| 369 | tmpSetupState = SetupState; // update previous state reg |
| 370 | SetupStateTable[SetupState] (first); // call next state |
| 371 | PreviousSetupState = tmpSetupState; // Set state to previous |
| 372 | |
| 373 | if (SetupDone) // If setup is done |
| 374 | { |
| 375 | Config.MenuFlag = 0; // Clear menu flag |
| 376 | if (Config.SiteConfigFlag) |
| 377 | { |
| 378 | Disp.UpdateFlag = 1; // Clear Display write flag |
| 379 | #if FLASH_DATA |
| 380 | WriteConfig(); |
| 381 | #endif |
| 382 | } |
| 383 | else |
| 384 | { |
| 385 | DisplayMsgCtr(" "," "); |
| 386 | Disp.UpdateFlag = 0; |
| 387 | DisplayMsgCtr(PRODUCT_NAME_STRING, VersionString()); |
| 388 | } |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | // RunTime ***************************************************************************** |
| 393 | |
| 394 | void RunTimeSetup(int first) |
| 395 | { |
| 396 | int aCode; // Keycode |
| 397 | |
| 398 | if (first) // If first time in state |
| 399 | { |
| 400 | DisplayMsg("RESILIENCY ENTRY", " "); // Post Msg |
| 401 | printf("RUN TIME SETUP\n"); |
| 402 | } |
| 403 | else if (GetKeyEdgeFlag()) // If key press |
| 404 | { |
| 405 | aCode = GetKeyCode(); // Get key |
| 406 | if (aCode == SETUPPB) // If setup |
| 407 | { |
| 408 | SetupState = SETUP_DISABLE_TIME_SETUP; // Goto Disable time |
| 409 | } |
| 410 | else if (aCode == CLEARPB) // If clear |
| 411 | SetupDone = 1; // Leave menu |
| 412 | else if (aCode == ENTERPB && Config.SiteConfigFlag) // if enter and site already configured |
| 413 | { |
| 414 | SetupState = SETUP_RESIL_VAL; // Goto Run time |
| 415 | ProductID = 0; |
| 416 | } |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | // Resilience value ************************************************************************** |
| 421 | |
| 422 | void ResilVal(int first) |
| 423 | { |
| 424 | int aCode; // Keycode |
| 425 | static int FirstDigit; // First pressed digi flag |
| 426 | int i; // Counter |
| 427 | int result; // Entery done |
| 428 | int CurrentProduct; // Product currently servicing |
| 429 | char value[5]; |
| 430 | |
| 431 | result = 0; // Clear entery done flag |
| 432 | CurrentProduct = ProductID; // Grab current product |
| 433 | |
| 434 | if (first) // If first pass |
| 435 | { |
| 436 | Turbine = Product[ProductID].ResilVal; // Grab duration for current product |
| 437 | strcpy(SetupTopLine, "RESILIENCE VALUE"); // Set Top row text |
| 438 | sprintf(SetupBottomLine, "PRODUCT %d %4u",ProductID+1, Turbine); // Set buttom row wiht info |
| 439 | DisplayMsg(SetupTopLine, SetupBottomLine); // Write Display |
| 440 | FirstDigit = 1; // Set first number flag |
| 441 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 442 | printf("%s \n", SetupBottomLine); // Print info to STFIO |
| 443 | } |
| 444 | else if (GetKeyEdgeFlag()) // If key pressed |
| 445 | { |
| 446 | aCode = GetKeyCode(); // Grab key |
| 447 | if (aCode == DOWNPB || aCode == UPPB) // If numeric key |
| 448 | { |
| 449 | UpdateDigit(aCode, SetupBottomLine, 11, 16, 1.0, 0.0, 9999.0, GetFastFlag()); |
| 450 | FirstDigit = 0; // Clear flag |
| 451 | } |
| 452 | else if (aCode == ENTERPB) // If enter pb |
| 453 | { |
| 454 | strncpy(value, SetupBottomLine+11, 5); |
| 455 | Turbine = (int)(atof(value)); |
| 456 | result = 1; |
| 457 | RestartState = 1; |
| 458 | |
| 459 | } |
| 460 | else if (aCode == CLEARPB) // If clear pb |
| 461 | { |
| 462 | sprintf(SetupBottomLine, "PRODUCT %d %d",ProductID+1, Turbine); // Set buttom row wiht info |
| 463 | RestartState = 1; |
| 464 | } |
| 465 | else if (aCode == SETUPPB) // If Setup pb |
| 466 | { |
| 467 | strncpy(value, SetupBottomLine+11, 5); |
| 468 | Turbine = (int)(atof(value)); |
| 469 | result = 1; // Entry done |
| 470 | SetupState = SETUP_RUN_TIME_SETUP; |
| 471 | // Goto disable time entry |
| 472 | } |
| 473 | |
| 474 | if (result) // If got final value |
| 475 | { |
| 476 | if (Turbine <= 9999 && Turbine >= 0) |
| 477 | { |
| 478 | if (Product[CurrentProduct].ResilVal != Turbine) |
| 479 | { |
| 480 | Product[CurrentProduct].ResilVal = Turbine; |
| 481 | |
| 482 | for (i = Product[CurrentProduct].FirstTurbine ; // Loop through proucts |
| 483 | i < Product[CurrentProduct].FirstTurbine + Product[CurrentProduct].N_Turbines ; |
| 484 | i++) |
| 485 | { |
| 486 | if (Turbine > 0) |
| 487 | { |
| 488 | Channel[i].ResilVal = Turbine; |
| 489 | #if MODBUS_M_ON |
| 490 | SetLDNReg(i, RESIL, Turbine); |
| 491 | #endif |
| 492 | } |
| 493 | else |
| 494 | Channel[i].ResilVal = 1; |
| 495 | } |
| 496 | } |
| 497 | } |
| 498 | if (ProductID+1 < Config.N_Products) |
| 499 | ProductID++; |
| 500 | else |
| 501 | ProductID = 0; |
| 502 | UpdateFlag = 1; |
| 503 | } |
| 504 | else |
| 505 | { |
| 506 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 507 | } |
| 508 | } |
| 509 | } |
| 510 | |
| 511 | // RunTime Menu ****************************************************************************** |
| 512 | |
| 513 | void DurTime(int first) |
| 514 | { |
| 515 | int aCode; // Keycode |
| 516 | static int FirstDigit; // First pressed digi flag |
| 517 | int i; // Counter |
| 518 | int result; // Entery done |
| 519 | int CurrentProduct; // Product currently servicing |
| 520 | char value[5]; |
| 521 | |
| 522 | result = 0; // Clear entery done flag |
| 523 | CurrentProduct = ProductID; // Grab current product |
| 524 | |
| 525 | if (first) // If first pass |
| 526 | { |
| 527 | RunTime = Channel[Product[ProductID].FirstTurbine].DurationTime; // Grab duration for current product |
| 528 | strcpy(SetupTopLine, "REPRESS TIME MIN"); // Set Top row text |
| 529 | sprintf(SetupBottomLine, "PRODUCT %d %2u",ProductID+1, RunTime / 60); // Set buttom row wiht info |
| 530 | sprintf(SetupBottomLine, "%s.%1u", SetupBottomLine, (RunTime % 60)/6); |
| 531 | DisplayMsg(SetupTopLine, SetupBottomLine); // Write Display |
| 532 | FirstDigit = 1; // Set first number flag |
| 533 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 534 | printf("%s \n", SetupBottomLine); // Print info to STFIO |
| 535 | } |
| 536 | else if (GetKeyEdgeFlag()) // If key pressed |
| 537 | { |
| 538 | aCode = GetKeyCode(); // Grab key |
| 539 | if (aCode == DOWNPB || aCode == UPPB) // If numeric key |
| 540 | { |
| 541 | UpdateDigit(aCode, SetupBottomLine, 11, 16, .1, 0.0, 20.0, GetFastFlag()); |
| 542 | FirstDigit = 0; // Clear flag |
| 543 | } |
| 544 | else if (aCode == ENTERPB) // If enter pb |
| 545 | { |
| 546 | strncpy(value, SetupBottomLine+11, 5); |
| 547 | RunTime = (int)(atof(value) * 60); |
| 548 | result = 1; // Entery done |
| 549 | SetupState = SETUP_DELAY_TIME; // Goto delay time entry |
| 550 | } |
| 551 | else if (aCode == CLEARPB) // If clear pb |
| 552 | { |
| 553 | sprintf(SetupBottomLine, "PRODUCT %d %2u",ProductID+1, RunTime / 60); // Set buttom row wiht info |
| 554 | sprintf(SetupBottomLine, "%s.%1u", SetupBottomLine, (RunTime % 60)/6); // Set buttom row wiht info |
| 555 | RestartState = 1; |
| 556 | } |
| 557 | else if (aCode == SETUPPB) // If Setup pb |
| 558 | { |
| 559 | strncpy(value, SetupBottomLine+11, 5); |
| 560 | RunTime = (int)(atof(value) * 60); |
| 561 | result = 1; // Entry done |
| 562 | SetupState = SETUP_RUN_TIME_SETUP; // Goto disable time entry |
| 563 | } // Beep if last product // Beep if invalid key |
| 564 | |
| 565 | if (result) // If got final value |
| 566 | { |
| 567 | if (RunTime <= 20 * 60 && RunTime >= 0) |
| 568 | { |
| 569 | for (i = Product[CurrentProduct].FirstTurbine ; // Loop through proucts |
| 570 | i < Product[CurrentProduct].FirstTurbine + Product[CurrentProduct].N_Turbines ; |
| 571 | i++) |
| 572 | { |
| 573 | Channel[i].DurationTime = RunTime; // Set duration time |
| 574 | UpdateFlag = 1; |
| 575 | } |
| 576 | } |
| 577 | else |
| 578 | { |
| 579 | RestartState = 1; |
| 580 | } |
| 581 | } |
| 582 | else |
| 583 | { |
| 584 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 585 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 586 | } |
| 587 | } |
| 588 | } |
| 589 | |
| 590 | // Delay Time Menu ********************************************************************** |
| 591 | |
| 592 | void DelayTime(int first) |
| 593 | { |
| 594 | int aCode; // Keycode |
| 595 | static int FirstDigit; // First pressed digi flag |
| 596 | int i; // Counter |
| 597 | int result; // Entery done |
| 598 | int CurrentProduct; // Product currently servicing |
| 599 | char value[5]; |
| 600 | |
| 601 | result = 0; // Clear entery done flag |
| 602 | CurrentProduct = ProductID; // Grab current product |
| 603 | |
| 604 | if (first) // If first pass |
| 605 | { |
| 606 | RunTime = Channel[Product[ProductID].FirstTurbine].DelayTime; // Grab duration for current product |
| 607 | sprintf(SetupTopLine, "DELAY TIME MIN "); // Set Top row text |
| 608 | sprintf(SetupBottomLine, "PRODUCT %d %3u",ProductID+1, RunTime / 60); // Set buttom row wiht info |
| 609 | sprintf(SetupBottomLine, "%s.%1u", SetupBottomLine, (RunTime % 60)/6); |
| 610 | DisplayMsg(SetupTopLine, SetupBottomLine); // Write Display |
| 611 | FirstDigit = 1; // Set first number flag |
| 612 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 613 | printf("%s \n", SetupBottomLine); // Print info to STFIO |
| 614 | } |
| 615 | else if (GetKeyEdgeFlag()) // If key pressed |
| 616 | { |
| 617 | aCode = GetKeyCode(); // Grab key |
| 618 | if (aCode == DOWNPB || aCode == UPPB) // If numeric key |
| 619 | { |
| 620 | UpdateDigit(aCode, SetupBottomLine, 11, 16, .1, 0.1, 150.0, GetFastFlag()); |
| 621 | FirstDigit = 0; // Clear flag |
| 622 | } |
| 623 | else if (aCode == ENTERPB) // If enter pb |
| 624 | { |
| 625 | strncpy(value, SetupBottomLine+11, 5); |
| 626 | RunTime = (int)(atof(value) * 60); |
| 627 | result = 1; // Entery done |
| 628 | SetupState = SETUP_RESIL_VAL; // Goto delay time entry |
| 629 | if (ProductID+1 < Config.N_Products) |
| 630 | ProductID++; |
| 631 | else |
| 632 | ProductID = 0; |
| 633 | } |
| 634 | else if (aCode == CLEARPB) // If clear pb |
| 635 | { |
| 636 | sprintf(SetupBottomLine, "PRODUCT %d %3u",ProductID+1, RunTime / 60); // Set buttom row wiht info |
| 637 | sprintf(SetupBottomLine, "%s.%1u", SetupBottomLine, (RunTime % 60)/6); |
| 638 | RestartState = 1; |
| 639 | } |
| 640 | else if (aCode == SETUPPB) // If Setup pb |
| 641 | { |
| 642 | strncpy(value, SetupBottomLine+11, 5); |
| 643 | RunTime = (int)(atof(value) * 60); |
| 644 | result = 1; // Entry done |
| 645 | SetupState = SETUP_RUN_TIME_SETUP; // Goto disable time entry |
| 646 | } // Beep if last product // Beep if invalid key |
| 647 | |
| 648 | if (result) // If got final value |
| 649 | { |
| 650 | if (RunTime <= 150 * 60 && RunTime >= 0) |
| 651 | { |
| 652 | for (i = Product[CurrentProduct].FirstTurbine ; // Loop through proucts |
| 653 | i < Product[CurrentProduct].FirstTurbine + Product[CurrentProduct].N_Turbines ; |
| 654 | i++) |
| 655 | { |
| 656 | Channel[i].DelayTime = RunTime; // Set duration time |
| 657 | UpdateFlag = 1; |
| 658 | } |
| 659 | } |
| 660 | else |
| 661 | { |
| 662 | RestartState = 1; |
| 663 | } |
| 664 | } |
| 665 | else |
| 666 | { |
| 667 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 668 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 669 | } |
| 670 | } |
| 671 | } |
| 672 | |
| 673 | // Disable Time Setup ********************************************************************* |
| 674 | |
| 675 | void DisableTimeSetup(int first) |
| 676 | { |
| 677 | int aCode; // Keycode |
| 678 | |
| 679 | if (first) // If first time in state |
| 680 | { |
| 681 | DisplayMsg(" REPRESSURE ", " DISABLE TIME "); // Post Msg |
| 682 | printf("DISABLE TIME\n"); |
| 683 | } |
| 684 | else if (GetKeyEdgeFlag()) // If key press |
| 685 | { |
| 686 | aCode = GetKeyCode(); // Get key |
| 687 | if (aCode == SETUPPB) // If setup |
| 688 | SetupState = SETUP_SUMP_MENU; // Goto Disable time |
| 689 | else if (aCode == CLEARPB) // If clear |
| 690 | SetupDone = 1; // Leave menu |
| 691 | else if (aCode == ENTERPB && Config.SiteConfigFlag) // if enter and site already configured |
| 692 | SetupState = SETUP_DISABLE_START_TIME; // Goto Run time |
| 693 | } |
| 694 | } |
| 695 | |
| 696 | // Disable start time ******************************************************************** |
| 697 | |
| 698 | void DisableStartTime(int first) |
| 699 | { |
| 700 | int aCode; // Keycode |
| 701 | static int FirstDigit; // First pressed digi flag |
| 702 | int i; // Counter |
| 703 | int result; // Entery done |
| 704 | int CurrentProduct; // Product currently servicing |
| 705 | char value[5]; |
| 706 | |
| 707 | result = 0; // Clear entery done flag |
| 708 | CurrentProduct = ProductID; // Grab current product |
| 709 | |
| 710 | if (first) // If first pass |
| 711 | { |
| 712 | Turbine = Product[ProductID].DisStartTimeHours; // Grab duration for current product |
| 713 | strcpy(SetupTopLine, "DIS START HOUR "); // Set Top row text |
| 714 | sprintf(SetupBottomLine, "PRODUCT %d %2d",ProductID+1, Turbine); // Set buttom row wiht info |
| 715 | DisplayMsg(SetupTopLine, SetupBottomLine); // Write Display |
| 716 | FirstDigit = 1; // Set first number flag |
| 717 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 718 | printf("%s \n", SetupBottomLine); // Print info to STFIO |
| 719 | } |
| 720 | else if (GetKeyEdgeFlag()) // If key pressed |
| 721 | { |
| 722 | aCode = GetKeyCode(); // Grab key |
| 723 | if (aCode == DOWNPB || aCode == UPPB) // If numeric key |
| 724 | { |
| 725 | UpdateDigit(aCode, SetupBottomLine, 11, 16, 1, 0.0, 23.0, GetFastFlag()); |
| 726 | FirstDigit = 0; // Clear flag |
| 727 | } |
| 728 | else if (aCode == ENTERPB) // If enter pb |
| 729 | { |
| 730 | strncpy(value, SetupBottomLine+11, 5); |
| 731 | Turbine = atoi(value); |
| 732 | result = 1; // Entery done |
| 733 | SetupState = SETUP_DISABLE_END_TIME; // Goto delay time entry |
| 734 | } |
| 735 | else if (aCode == CLEARPB) // If clear pb |
| 736 | { |
| 737 | sprintf(SetupBottomLine, "PRODUCT %d %d",ProductID+1, Turbine); // Set buttom row wiht info // Set buttom row wiht info |
| 738 | RestartState = 1; |
| 739 | } |
| 740 | else if (aCode == SETUPPB) // If Setup pb |
| 741 | { |
| 742 | strncpy(value, SetupBottomLine+11, 5); |
| 743 | Turbine = atoi(value); |
| 744 | result = 1; // Entry done |
| 745 | SetupState = SETUP_SUMP_MENU; // Goto disable time entry |
| 746 | } |
| 747 | |
| 748 | if (result) // If got final value |
| 749 | { |
| 750 | if (Turbine <= 23 && Turbine >= 0) |
| 751 | { |
| 752 | Product[CurrentProduct].DisStartTimeHours = Turbine; // Set duration time |
| 753 | Product[CurrentProduct].DisStartTimeMin = 0; |
| 754 | UpdateFlag = 1; |
| 755 | } |
| 756 | else |
| 757 | { |
| 758 | RestartState = 1; |
| 759 | } |
| 760 | } |
| 761 | else |
| 762 | { |
| 763 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 764 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 765 | } |
| 766 | } |
| 767 | } |
| 768 | |
| 769 | // Disable end time ******************************************************************************** |
| 770 | |
| 771 | void DisableEndTime(int first) |
| 772 | { |
| 773 | int aCode; // Keycode |
| 774 | static int FirstDigit; // First pressed digi flag |
| 775 | int i; // Counter |
| 776 | int result; // Entery done |
| 777 | int CurrentProduct; // Product currently servicing |
| 778 | char value[5]; |
| 779 | |
| 780 | result = 0; // Clear entery done flag |
| 781 | CurrentProduct = ProductID; // Grab current product |
| 782 | |
| 783 | if (first) // If first pass |
| 784 | { |
| 785 | Turbine = Product[ProductID].DisEndTimeHours; // Grab duration for current product |
| 786 | strcpy(SetupTopLine, "DIS END HOUR "); // Set Top row text |
| 787 | sprintf(SetupBottomLine, "PRODUCT %d %2d",ProductID+1, Turbine); // Set buttom row wiht info |
| 788 | DisplayMsg(SetupTopLine, SetupBottomLine); // Write Display |
| 789 | FirstDigit = 1; // Set first number flag |
| 790 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 791 | printf("%s \n", SetupBottomLine); // Print info to STFIO |
| 792 | } |
| 793 | else if (GetKeyEdgeFlag()) // If key pressed |
| 794 | { |
| 795 | aCode = GetKeyCode(); // Grab key |
| 796 | if (aCode == DOWNPB || aCode == UPPB) // If numeric key |
| 797 | { |
| 798 | UpdateDigit(aCode, SetupBottomLine, 11, 16, 1, 0.0, 23.0, GetFastFlag()); |
| 799 | FirstDigit = 0; // Clear flag |
| 800 | } |
| 801 | else if (aCode == ENTERPB) // If enter pb |
| 802 | { |
| 803 | strncpy(value, SetupBottomLine+11, 5); |
| 804 | Turbine = atoi(value); |
| 805 | result = 1; // Entery done |
| 806 | SetupState = SETUP_DISABLE_START_TIME; // Goto delay time entry |
| 807 | if (ProductID+1 < Config.N_Products) |
| 808 | ProductID++; |
| 809 | else |
| 810 | ProductID = 0; |
| 811 | } |
| 812 | else if (aCode == CLEARPB) // If clear pb |
| 813 | { |
| 814 | sprintf(SetupBottomLine, "PRODUCT %d %2d",ProductID+1, Turbine); // Set buttom row wiht info // Set buttom row wiht info |
| 815 | RestartState = 1; |
| 816 | } |
| 817 | else if (aCode == SETUPPB) // If Setup pb |
| 818 | { |
| 819 | strncpy(value, SetupBottomLine+11, 5); |
| 820 | Turbine = atoi(value); |
| 821 | result = 1; // Entry done |
| 822 | SetupState = SETUP_SUMP_MENU; // Goto disable time entry |
| 823 | } // Beep if last produc // Beep if invalid key |
| 824 | |
| 825 | if (result) // If got final value |
| 826 | { |
| 827 | if (Turbine <= 23 && Turbine >= 0) |
| 828 | { |
| 829 | Product[CurrentProduct].DisEndTimeHours = Turbine; // Set duration time |
| 830 | Product[CurrentProduct].DisEndTimeMin = 0; |
| 831 | UpdateFlag = 1; |
| 832 | } |
| 833 | else |
| 834 | { |
| 835 | RestartState = 1; |
| 836 | } |
| 837 | } |
| 838 | else |
| 839 | { |
| 840 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 841 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 842 | } |
| 843 | } |
| 844 | } |
| 845 | |
| 846 | // Sump Menu ************************************************************************************ |
| 847 | |
| 848 | void SumpMenu(int first) |
| 849 | { |
| 850 | int aCode; // Keycode |
| 851 | int result; |
| 852 | |
| 853 | result = 0; |
| 854 | |
| 855 | if (first) // If first pass |
| 856 | { |
| 857 | strcpy(SetupTopLine, " SUMP SENSOR "); // Set Top row text |
| 858 | strcpy(SetupBottomLine, " SETUP "); |
| 859 | DisplayMsgCtr(SetupTopLine, SetupBottomLine); // Update dislpay |
| 860 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 861 | printf("%s \n", SetupBottomLine); // Print info to STFIO |
| 862 | } |
| 863 | else if (GetKeyEdgeFlag()) // If key pressed |
| 864 | { |
| 865 | aCode = GetKeyCode(); // Grab key |
| 866 | if (aCode == SETUPPB) // If Setup pb |
| 867 | { |
| 868 | #if MODBUS_M_ON |
| 869 | SetupState = SETUP_PRESSURE_MENU; |
| 870 | #else |
| 871 | SetupState = SETUP_TEST_MENU; |
| 872 | #endif |
| 873 | } |
| 874 | else if (aCode == CLEARPB) |
| 875 | SetupDone = 1; |
| 876 | else if (aCode == ENTERPB) |
| 877 | SetupState = SETUP_SUMP_MENU_TYPE; |
| 878 | } |
| 879 | } |
| 880 | |
| 881 | // Sump Menu Type ************************************************************************************ |
| 882 | |
| 883 | void SumpMenuType(int first) |
| 884 | { |
| 885 | int aCode; // Keycode |
| 886 | int result; |
| 887 | |
| 888 | result = 0; |
| 889 | |
| 890 | if (first) // If first pass |
| 891 | { |
| 892 | strcpy(SetupTopLine, "SUMP SENSOR TYPE"); // Set Top row text |
| 893 | if (Config.Sump.NoSumpFlag) // Put current status in display |
| 894 | strcpy(SetupBottomLine, " NO SUMP SENSOR "); // Set buttom row wiht info |
| 895 | else if (Config.Sump.AlarmPos == SUMP_OPEN) |
| 896 | strcpy(SetupBottomLine, "NORMALLY CLOSED "); |
| 897 | else if (Config.Sump.AlarmPos == SUMP_CLOSED) |
| 898 | strcpy(SetupBottomLine, " NORMALLY OPEN "); |
| 899 | DisplayMsgCtr(SetupTopLine, SetupBottomLine); // Update dislpay |
| 900 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 901 | printf("%s \n", SetupBottomLine); // Print info to STFIO |
| 902 | } |
| 903 | else if (GetKeyEdgeFlag()) // If key pressed |
| 904 | { |
| 905 | aCode = GetKeyCode(); // Grab key |
| 906 | if (aCode == SETUPPB) // If Setup pb |
| 907 | { |
| 908 | SetupState = SETUP_SUMP_MENU; // Goto Time of day |
| 909 | } |
| 910 | else if (aCode == ENTERPB) |
| 911 | { |
| 912 | SetupState = SETUP_SUMP_MENU_SHUTDOWN; // Goto Time of day |
| 913 | } |
| 914 | else if (aCode == UPPB) // If up pb |
| 915 | { |
| 916 | if (Config.Sump.NoSumpFlag) |
| 917 | { |
| 918 | Config.Sump.AlarmPos = SUMP_CLOSED; |
| 919 | Config.Sump.NoSumpFlag = 0; |
| 920 | strcpy(SetupBottomLine, " NORMALLY OPEN "); |
| 921 | result = 1; |
| 922 | } |
| 923 | else if (Config.Sump.AlarmPos == SUMP_OPEN) |
| 924 | { |
| 925 | Config.Sump.AlarmPos = SUMP_OPEN; |
| 926 | Config.Sump.NoSumpFlag = 1; |
| 927 | strcpy(SetupBottomLine, " NO SUMP SENSOR "); |
| 928 | result = 1; |
| 929 | } |
| 930 | else |
| 931 | { |
| 932 | Config.Sump.AlarmPos = SUMP_OPEN; |
| 933 | Config.Sump.NoSumpFlag = 0; |
| 934 | strcpy(SetupBottomLine, "NORMALLY CLOSED "); |
| 935 | result = 1; |
| 936 | } |
| 937 | } |
| 938 | else if (aCode == DOWNPB) // If down pb |
| 939 | { |
| 940 | if (Config.Sump.NoSumpFlag) |
| 941 | { |
| 942 | Config.Sump.AlarmPos = SUMP_OPEN; |
| 943 | Config.Sump.NoSumpFlag = 0; |
| 944 | strcpy(SetupBottomLine, "NORMALLY CLOSED "); |
| 945 | result = 1; |
| 946 | } |
| 947 | else if (Config.Sump.AlarmPos == SUMP_OPEN) |
| 948 | { |
| 949 | Config.Sump.AlarmPos = SUMP_CLOSED; |
| 950 | Config.Sump.NoSumpFlag = 0; |
| 951 | strcpy(SetupBottomLine, " NORMALLY OPEN "); |
| 952 | result = 1; |
| 953 | } |
| 954 | else |
| 955 | { |
| 956 | Config.Sump.AlarmPos = SUMP_OPEN; |
| 957 | Config.Sump.NoSumpFlag = 1; |
| 958 | strcpy(SetupBottomLine, " NO SUMP SENSOR "); |
| 959 | result = 1; |
| 960 | } |
| 961 | } |
| 962 | else if (aCode == CLEARPB) // If clear |
| 963 | { |
| 964 | SetupState = SETUP_SUMP_MENU; // Leave menu |
| 965 | } |
| 966 | |
| 967 | if (result) |
| 968 | { |
| 969 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 970 | DisplayMsgCtr(SetupTopLine, SetupBottomLine); // Update dislpay |
| 971 | UpdateFlag = 1; |
| 972 | } // Beep if invalid key |
| 973 | } |
| 974 | } |
| 975 | |
| 976 | // Sump Menu Shutdown************************************************************************************ |
| 977 | |
| 978 | void SumpMenuShutDown(int first) |
| 979 | { |
| 980 | int aCode; // Keycode |
| 981 | int result; |
| 982 | |
| 983 | result = 0; |
| 984 | |
| 985 | if (first) // If first pass |
| 986 | { |
| 987 | strcpy(SetupTopLine, " SUMP SHUTDOWN "); // Set Top row text |
| 988 | if (!Config.Sump.ShutDnFlag) // Put current status in display |
| 989 | strcpy(SetupBottomLine, " ALARM ONLY "); // Set buttom row wiht info |
| 990 | else if (Config.Sump.PerProdFlag) |
| 991 | strcpy(SetupBottomLine, " PRODUCT "); |
| 992 | else |
| 993 | strcpy(SetupBottomLine, " CHANNEL "); |
| 994 | DisplayMsgCtr(SetupTopLine, SetupBottomLine); // Update dislpay |
| 995 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 996 | printf("%s \n", SetupBottomLine); // Print info to STFIO |
| 997 | } |
| 998 | else if (GetKeyEdgeFlag()) // If key pressed |
| 999 | { |
| 1000 | aCode = GetKeyCode(); // Grab key |
| 1001 | if (aCode == SETUPPB) // If Setup pb |
| 1002 | { |
| 1003 | SetupState = SETUP_SUMP_MENU; // Goto Time of day |
| 1004 | } |
| 1005 | else if (aCode == ENTERPB) |
| 1006 | { |
| 1007 | SetupState = SETUP_SUMP_MENU_TYPE; // Goto Time of day |
| 1008 | } |
| 1009 | else if (aCode == UPPB) // If up pb |
| 1010 | { |
| 1011 | if (!Config.Sump.ShutDnFlag) |
| 1012 | { |
| 1013 | Config.Sump.ShutDnFlag = 1; |
| 1014 | Config.Sump.PerProdFlag = 0; |
| 1015 | strcpy(SetupBottomLine, " CHANNEL "); |
| 1016 | result = 1; |
| 1017 | } |
| 1018 | else if (!Config.Sump.PerProdFlag) |
| 1019 | { |
| 1020 | Config.Sump.ShutDnFlag = 1; |
| 1021 | Config.Sump.PerProdFlag = 1; |
| 1022 | strcpy(SetupBottomLine, " PRODUCT "); |
| 1023 | result = 1; |
| 1024 | } |
| 1025 | else |
| 1026 | { |
| 1027 | Config.Sump.ShutDnFlag = 0; |
| 1028 | Config.Sump.PerProdFlag = 0; |
| 1029 | strcpy(SetupBottomLine, " ALARM ONLY "); |
| 1030 | result = 1; |
| 1031 | } |
| 1032 | } |
| 1033 | else if (aCode == DOWNPB) // If down pb |
| 1034 | { |
| 1035 | if (!Config.Sump.ShutDnFlag) |
| 1036 | { |
| 1037 | Config.Sump.ShutDnFlag = 1; |
| 1038 | Config.Sump.PerProdFlag = 0; |
| 1039 | strcpy(SetupBottomLine, " CHANNEL "); |
| 1040 | result = 1; |
| 1041 | } |
| 1042 | else if (!Config.Sump.PerProdFlag) |
| 1043 | { |
| 1044 | Config.Sump.ShutDnFlag = 1; |
| 1045 | Config.Sump.PerProdFlag = 1; |
| 1046 | strcpy(SetupBottomLine, " PRODUCT "); |
| 1047 | result = 1; |
| 1048 | } |
| 1049 | else |
| 1050 | { |
| 1051 | Config.Sump.ShutDnFlag = 0; |
| 1052 | Config.Sump.PerProdFlag = 0; |
| 1053 | strcpy(SetupBottomLine, " ALARM ONLY "); |
| 1054 | result = 1; |
| 1055 | } |
| 1056 | } |
| 1057 | else if (aCode == CLEARPB) // If clear |
| 1058 | { |
| 1059 | SetupState = SETUP_SUMP_MENU; // Leave menu |
| 1060 | } |
| 1061 | |
| 1062 | if (result) |
| 1063 | { |
| 1064 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 1065 | DisplayMsgCtr(SetupTopLine, SetupBottomLine); // Update dislpay |
| 1066 | UpdateFlag = 1; |
| 1067 | } // Beep if invalid key |
| 1068 | } |
| 1069 | } |
| 1070 | |
| 1071 | // Pressure Suub Menu ********************************************************** |
| 1072 | void PressureMenu(int first) |
| 1073 | { |
| 1074 | int aCode; // Keycode |
| 1075 | |
| 1076 | if (first) // If first time in state |
| 1077 | { |
| 1078 | DisplayMsg(" PRESSURE SETUP ", " "); // Post Msg |
| 1079 | printf("PRESSURE SETUP\n"); |
| 1080 | } |
| 1081 | else if (GetKeyEdgeFlag()) // If key press |
| 1082 | { |
| 1083 | aCode = GetKeyCode(); // Get key |
| 1084 | if (aCode == SETUPPB) // If setup |
| 1085 | { |
| 1086 | //SetupState = SETUP_TEST_MENU; // Goto Disable time |
| 1087 | SetupState = SETUP_TIME_OF_DAY; // Goto Disable time |
| 1088 | } |
| 1089 | else if (aCode == CLEARPB) // If clear |
| 1090 | SetupDone = 1; // Leave menu |
| 1091 | else if (aCode == ENTERPB && Config.SiteConfigFlag) // if enter and site already configured |
| 1092 | { |
| 1093 | SetupState = SETUP_RUN_PRESSURE; // Goto Run time |
| 1094 | ProductID = 0; |
| 1095 | } |
| 1096 | } |
| 1097 | } |
| 1098 | |
| 1099 | // Run Pressure Menu *********************************************************** |
| 1100 | void MinRunPressure(int first) |
| 1101 | { |
| 1102 | int aCode; // Keycode |
| 1103 | static int FirstDigit; // First pressed digi flag |
| 1104 | int i; // Counter |
| 1105 | int result; // Entery done |
| 1106 | int CurrentProduct; // Product currently servicing |
| 1107 | char value[5]; |
| 1108 | |
| 1109 | result = 0; // Clear entery done flag |
| 1110 | CurrentProduct = ProductID; // Grab current product |
| 1111 | |
| 1112 | if (first) // If first pass |
| 1113 | { |
| 1114 | Turbine = Product[ProductID].RunPressure; // Grab duration for current product |
| 1115 | strcpy(SetupTopLine, "MIN RUN PRESSURE"); // Set Top row text |
| 1116 | sprintf(SetupBottomLine, "PRODUCT %d %2u PSI",ProductID+1, Turbine); // Set buttom row wiht info |
| 1117 | DisplayMsg(SetupTopLine, SetupBottomLine); // Write Display |
| 1118 | FirstDigit = 1; // Set first number flag |
| 1119 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 1120 | printf("%s \n", SetupBottomLine); // Print info to STFIO |
| 1121 | } |
| 1122 | else if (GetKeyEdgeFlag()) // If key pressed |
| 1123 | { |
| 1124 | aCode = GetKeyCode(); // Grab key |
| 1125 | if (aCode == DOWNPB || aCode == UPPB) // If numeric key |
| 1126 | { |
| 1127 | UpdateDigit(aCode, SetupBottomLine, 10, 12, 1.0, 0.0, 50.0, GetFastFlag()); |
| 1128 | FirstDigit = 0; // Clear flag |
| 1129 | } |
| 1130 | else if (aCode == ENTERPB) // If enter pb |
| 1131 | { |
| 1132 | strncpy(value, SetupBottomLine+10, 3); |
| 1133 | Turbine = (int)(atof(value)); |
| 1134 | result = 1; // Entery done |
| 1135 | SetupState = SETUP_HIGH_PRESSURE; // Goto delay time entry |
| 1136 | } |
| 1137 | else if (aCode == CLEARPB) // If clear pb |
| 1138 | { |
| 1139 | sprintf(SetupBottomLine, "PRODUCT %d %2u PSI",ProductID+1, Turbine); // Set buttom row wiht info |
| 1140 | RestartState = 1; |
| 1141 | } |
| 1142 | else if (aCode == SETUPPB) // If Setup pb |
| 1143 | { |
| 1144 | strncpy(value, SetupBottomLine+10, 3); |
| 1145 | Turbine = (int)(atof(value)); |
| 1146 | result = 1; // Entry done |
| 1147 | SetupState = SETUP_PRESSURE_MENU; |
| 1148 | // Goto disable time entry |
| 1149 | } |
| 1150 | |
| 1151 | if (result && Turbine <= 50 && Turbine >= 0) // If got final value |
| 1152 | { |
| 1153 | Product[CurrentProduct].RunPressure = Turbine; |
| 1154 | for (i = Product[CurrentProduct].FirstTurbine ; // Loop through proucts |
| 1155 | i < Product[CurrentProduct].FirstTurbine + Product[CurrentProduct].N_Turbines ; |
| 1156 | i++) |
| 1157 | { |
| 1158 | Channel[i].RunPressure = Turbine; |
| 1159 | UpdateFlag = 1; |
| 1160 | } |
| 1161 | } |
| 1162 | else |
| 1163 | { |
| 1164 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 1165 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 1166 | } |
| 1167 | } |
| 1168 | } |
| 1169 | |
| 1170 | // High Test Pressure Menu ***************************************************** |
| 1171 | void TestHighPressure(int first) |
| 1172 | { |
| 1173 | int aCode; // Keycode |
| 1174 | static int FirstDigit; // First pressed digi flag |
| 1175 | int i; // Counter |
| 1176 | int result; // Entery done |
| 1177 | int CurrentProduct; // Product currently servicing |
| 1178 | char value[5]; |
| 1179 | |
| 1180 | result = 0; // Clear entery done flag |
| 1181 | CurrentProduct = ProductID; // Grab current product |
| 1182 | |
| 1183 | if (first) // If first pass |
| 1184 | { |
| 1185 | Turbine = Product[ProductID].HighPressure; // Grab duration for current product |
| 1186 | strcpy(SetupTopLine, "TEST HI PRESSURE"); // Set Top row text |
| 1187 | sprintf(SetupBottomLine, "PRODUCT %d %2u PSI",ProductID+1, Turbine); // Set buttom row wiht info |
| 1188 | DisplayMsg(SetupTopLine, SetupBottomLine); // Write Display |
| 1189 | FirstDigit = 1; // Set first number flag |
| 1190 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 1191 | printf("%s \n", SetupBottomLine); // Print info to STFIO |
| 1192 | } |
| 1193 | else if (GetKeyEdgeFlag()) // If key pressed |
| 1194 | { |
| 1195 | aCode = GetKeyCode(); // Grab key |
| 1196 | if (aCode == DOWNPB || aCode == UPPB) // If numeric key |
| 1197 | { |
| 1198 | UpdateDigit(aCode, SetupBottomLine, 10, 12, 1.0, 0.0, 50.0, GetFastFlag()); |
| 1199 | FirstDigit = 0; // Clear flag |
| 1200 | } |
| 1201 | else if (aCode == ENTERPB) // If enter pb |
| 1202 | { |
| 1203 | strncpy(value, SetupBottomLine+10, 3); |
| 1204 | Turbine = (int)(atof(value)); |
| 1205 | result = 1; // Entery done |
| 1206 | SetupState = SETUP_LOW_PRESSURE; // Goto delay time entry |
| 1207 | } |
| 1208 | else if (aCode == CLEARPB) // If clear pb |
| 1209 | { |
| 1210 | sprintf(SetupBottomLine, "PRODUCT %d %2u PSI",ProductID+1, Turbine); // Set buttom row wiht info |
| 1211 | RestartState = 1; |
| 1212 | } |
| 1213 | else if (aCode == SETUPPB) // If Setup pb |
| 1214 | { |
| 1215 | strncpy(value, SetupBottomLine+10, 3); |
| 1216 | Turbine = (int)(atof(value)); |
| 1217 | result = 1; // Entry done |
| 1218 | SetupState = SETUP_PRESSURE_MENU; |
| 1219 | // Goto disable time entry |
| 1220 | } |
| 1221 | |
| 1222 | if (result && Turbine <= 50 && Turbine >= 0) // If got final value |
| 1223 | { |
| 1224 | Product[CurrentProduct].HighPressure = Turbine; |
| 1225 | for (i = Product[CurrentProduct].FirstTurbine ; // Loop through proucts |
| 1226 | i < Product[CurrentProduct].FirstTurbine + Product[CurrentProduct].N_Turbines ; |
| 1227 | i++) |
| 1228 | { |
| 1229 | Channel[i].HighPressure = Turbine; |
| 1230 | UpdateFlag = 1; |
| 1231 | } |
| 1232 | } |
| 1233 | else |
| 1234 | { |
| 1235 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 1236 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 1237 | } |
| 1238 | } |
| 1239 | } |
| 1240 | |
| 1241 | // Low Test Pressure Menu ****************************************************** |
| 1242 | void TestLowPressure(int first) |
| 1243 | { |
| 1244 | int aCode; // Keycode |
| 1245 | static int FirstDigit; // First pressed digi flag |
| 1246 | int i; // Counter |
| 1247 | int result; // Entery done |
| 1248 | int CurrentProduct; // Product currently servicing |
| 1249 | char value[5]; |
| 1250 | |
| 1251 | result = 0; // Clear entery done flag |
| 1252 | CurrentProduct = ProductID; // Grab current product |
| 1253 | |
| 1254 | if (first) // If first pass |
| 1255 | { |
| 1256 | Turbine = Product[ProductID].LowPressure; // Grab duration for current product |
| 1257 | strcpy(SetupTopLine, "TEST LO PRESSURE"); // Set Top row text |
| 1258 | sprintf(SetupBottomLine, "PRODUCT %d %2u PSI",ProductID+1, Turbine); // Set buttom row wiht info |
| 1259 | DisplayMsg(SetupTopLine, SetupBottomLine); // Write Display |
| 1260 | FirstDigit = 1; // Set first number flag |
| 1261 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 1262 | printf("%s \n", SetupBottomLine); // Print info to STFIO |
| 1263 | } |
| 1264 | else if (GetKeyEdgeFlag()) // If key pressed |
| 1265 | { |
| 1266 | aCode = GetKeyCode(); // Grab key |
| 1267 | if (aCode == DOWNPB || aCode == UPPB) // If numeric key |
| 1268 | { |
| 1269 | UpdateDigit(aCode, SetupBottomLine, 10, 12, 1.0, 0.0, Product[ProductID].HighPressure, GetFastFlag()); |
| 1270 | FirstDigit = 0; // Clear flag |
| 1271 | } |
| 1272 | else if (aCode == ENTERPB) // If enter pb |
| 1273 | { |
| 1274 | strncpy(value, SetupBottomLine+10, 3); |
| 1275 | Turbine = (int)(atof(value)); |
| 1276 | result = 1; // Entery done |
| 1277 | SetupState = SETUP_RUN_PRESSURE; // Goto delay time entry |
| 1278 | if (ProductID+1 < Config.N_Products) |
| 1279 | ProductID++; |
| 1280 | else |
| 1281 | ProductID = 0; |
| 1282 | } |
| 1283 | else if (aCode == CLEARPB) // If clear pb |
| 1284 | { |
| 1285 | sprintf(SetupBottomLine, "PRODUCT %d %2u PSI",ProductID+1, Turbine); // Set buttom row wiht info |
| 1286 | RestartState = 1; |
| 1287 | } |
| 1288 | else if (aCode == SETUPPB) // If Setup pb |
| 1289 | { |
| 1290 | strncpy(value, SetupBottomLine+10, 3); |
| 1291 | Turbine = (int)(atof(value)); |
| 1292 | result = 1; // Entry done |
| 1293 | SetupState = SETUP_PRESSURE_MENU; |
| 1294 | // Goto disable time entry |
| 1295 | } |
| 1296 | |
| 1297 | if (result && Turbine < Product[ProductID].HighPressure && Turbine >= 0) // If got final value |
| 1298 | { |
| 1299 | Product[CurrentProduct].LowPressure = Turbine; |
| 1300 | for (i = Product[CurrentProduct].FirstTurbine ; // Loop through proucts |
| 1301 | i < Product[CurrentProduct].FirstTurbine + Product[CurrentProduct].N_Turbines ; |
| 1302 | i++) |
| 1303 | { |
| 1304 | Channel[i].LowPressure = Turbine; |
| 1305 | UpdateFlag = 1; |
| 1306 | } |
| 1307 | } |
| 1308 | else |
| 1309 | { |
| 1310 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 1311 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 1312 | } |
| 1313 | } |
| 1314 | } |
| 1315 | |
| 1316 | // Test Menu ************************************************************************************ |
| 1317 | |
| 1318 | void TestMenu(int first) |
| 1319 | { |
| 1320 | int aCode; // Keycode |
| 1321 | |
| 1322 | if (first) // If first time in state |
| 1323 | { |
| 1324 | DisplayMsg(" TEST SETUP ", " "); // Post Msg |
| 1325 | printf("TEST SETUP\n"); |
| 1326 | } |
| 1327 | else if (GetKeyEdgeFlag()) // If key press |
| 1328 | { |
| 1329 | aCode = GetKeyCode(); // Get key |
| 1330 | if (aCode == SETUPPB) // If setup |
| 1331 | { |
| 1332 | SetupState = SETUP_TIME_OF_DAY; // Goto Disable time |
| 1333 | } |
| 1334 | else if (aCode == CLEARPB) // If clear |
| 1335 | SetupDone = 1; // Leave menu |
| 1336 | else if (aCode == ENTERPB && Config.SiteConfigFlag) // if enter and site already configured |
| 1337 | { |
| 1338 | SetupState = SETUP_RETRIES_REPRES; // Goto Run time |
| 1339 | ProductID = 0; |
| 1340 | } |
| 1341 | } |
| 1342 | } |
| 1343 | |
| 1344 | // Repressure Retries *************************************************************************** |
| 1345 | |
| 1346 | void RetriesRePres(int first) |
| 1347 | { |
| 1348 | int aCode; // Keycode |
| 1349 | static int FirstDigit; // First pressed digi flag |
| 1350 | int result; // Entery done |
| 1351 | char value[5]; |
| 1352 | |
| 1353 | result = 0; // Clear entery done flag // Grab current product |
| 1354 | |
| 1355 | if (first) // If first pass |
| 1356 | { |
| 1357 | Turbine = Config.RePresRetries; |
| 1358 | strcpy(SetupTopLine, "REPRESS RETRIES "); // Set Top row text |
| 1359 | sprintf(SetupBottomLine, " %d ", Turbine); // Set buttom row wiht info |
| 1360 | DisplayMsg(SetupTopLine, SetupBottomLine); // Write Display |
| 1361 | FirstDigit = 1; // Set first number flag |
| 1362 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 1363 | printf("%s \n", SetupBottomLine); // Print info to STFIO |
| 1364 | } |
| 1365 | else if (GetKeyEdgeFlag()) // If key pressed |
| 1366 | { |
| 1367 | aCode = GetKeyCode(); // Grab key |
| 1368 | if (aCode == DOWNPB || aCode == UPPB) // If numeric key |
| 1369 | { |
| 1370 | UpdateDigit(aCode, SetupBottomLine, 7, 8, 1.0, 1.0, 9.0, GetFastFlag()); |
| 1371 | FirstDigit = 0; // Clear flag |
| 1372 | } |
| 1373 | else if (aCode == ENTERPB) // If enter pb |
| 1374 | { |
| 1375 | strncpy(value, SetupBottomLine+7, 1); |
| 1376 | Turbine = (int)(atof(value)); |
| 1377 | result = 1; // Entery done |
| 1378 | SetupState = SETUP_RETRIES_3GPH; // Goto delay time entry |
| 1379 | } |
| 1380 | else if (aCode == CLEARPB) // If clear pb |
| 1381 | { |
| 1382 | sprintf(SetupBottomLine, " %d ", Turbine); // Set buttom row wiht info |
| 1383 | RestartState = 1; |
| 1384 | } |
| 1385 | else if (aCode == SETUPPB) // If Setup pb |
| 1386 | { |
| 1387 | strncpy(value, SetupBottomLine+7, 1); |
| 1388 | Turbine = (int)(atof(value)); |
| 1389 | result = 1; // Entry done |
| 1390 | SetupState = SETUP_TEST_MENU; |
| 1391 | // Goto disable time entry |
| 1392 | } |
| 1393 | |
| 1394 | if (result && Turbine < 10 && Turbine >= 0) // If got final value |
| 1395 | { |
| 1396 | Config.RePresRetries = Turbine; |
| 1397 | } |
| 1398 | else |
| 1399 | { |
| 1400 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 1401 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 1402 | } |
| 1403 | } |
| 1404 | } |
| 1405 | |
| 1406 | // 3 GPH Retries ******************************************************************************** |
| 1407 | |
| 1408 | void Retries3GPH(int first) |
| 1409 | { |
| 1410 | int aCode; // Keycode |
| 1411 | static int FirstDigit; // First pressed digi flag |
| 1412 | int result; // Entery done |
| 1413 | char value[5]; |
| 1414 | |
| 1415 | result = 0; // Clear entery done flag // Grab current product |
| 1416 | |
| 1417 | if (first) // If first pass |
| 1418 | { |
| 1419 | Turbine = Config.PresRetries; |
| 1420 | strcpy(SetupTopLine, " 3 GPH RETRIES "); // Set Top row text |
| 1421 | sprintf(SetupBottomLine, " %d ", Turbine); // Set buttom row wiht info |
| 1422 | DisplayMsg(SetupTopLine, SetupBottomLine); // Write Display |
| 1423 | FirstDigit = 1; // Set first number flag |
| 1424 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 1425 | printf("%s \n", SetupBottomLine); // Print info to STFIO |
| 1426 | } |
| 1427 | else if (GetKeyEdgeFlag()) // If key pressed |
| 1428 | { |
| 1429 | aCode = GetKeyCode(); // Grab key |
| 1430 | if (aCode == DOWNPB || aCode == UPPB) // If numeric key |
| 1431 | { |
| 1432 | UpdateDigit(aCode, SetupBottomLine, 7, 8, 1.0, 1.0, 9.0, GetFastFlag()); |
| 1433 | FirstDigit = 0; // Clear flag |
| 1434 | } |
| 1435 | else if (aCode == ENTERPB) // If enter pb |
| 1436 | { |
| 1437 | strncpy(value, SetupBottomLine+7, 1); |
| 1438 | Turbine = (int)(atof(value)); |
| 1439 | result = 1; // Entery done |
| 1440 | SetupState = SETUP_SHUTDOWN_TYPE; // Goto delay time entry |
| 1441 | } |
| 1442 | else if (aCode == CLEARPB) // If clear pb |
| 1443 | { |
| 1444 | sprintf(SetupBottomLine, " %d ", Turbine); // Set buttom row wiht info |
| 1445 | RestartState = 1; |
| 1446 | } |
| 1447 | else if (aCode == SETUPPB) // If Setup pb |
| 1448 | { |
| 1449 | strncpy(value, SetupBottomLine+7, 1); |
| 1450 | Turbine = (int)(atof(value)); |
| 1451 | result = 1; // Entry done |
| 1452 | SetupState = SETUP_TEST_MENU; |
| 1453 | // Goto disable time entry |
| 1454 | } |
| 1455 | |
| 1456 | if (result && Turbine < 10 && Turbine >= 0) // If got final value |
| 1457 | { |
| 1458 | Config.PresRetries = Turbine; |
| 1459 | } |
| 1460 | else |
| 1461 | { |
| 1462 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 1463 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 1464 | } |
| 1465 | } |
| 1466 | } |
| 1467 | |
| 1468 | // ShutDown Type Menu *************************************************************************** |
| 1469 | |
| 1470 | void ShutDownType(int first) |
| 1471 | { |
| 1472 | int aCode; // Keycode |
| 1473 | int result; |
| 1474 | |
| 1475 | result = 0; |
| 1476 | |
| 1477 | if (first) // If first pass |
| 1478 | { |
| 1479 | strcpy(SetupTopLine, " ALARM ACTION "); // Set Top row text |
| 1480 | if (Config.ShutDownMode == SD_ALARM_ONLY) // Put current status in display |
| 1481 | strcpy(SetupBottomLine, " ALARM ONLY "); // Set buttom row wiht info |
| 1482 | else if (Config.ShutDownMode == SD_PER_PRODUCT) |
| 1483 | strcpy(SetupBottomLine, " PER PRODUCT "); |
| 1484 | else if (Config.ShutDownMode == SD_PER_CHANNEL) |
| 1485 | strcpy(SetupBottomLine, " PER CHANNEL "); |
| 1486 | else |
| 1487 | strcpy(SetupBottomLine, " DISP WARN ONLY "); |
| 1488 | DisplayMsgCtr(SetupTopLine, SetupBottomLine); // Update dislpay |
| 1489 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 1490 | printf("%s \n", SetupBottomLine); // Print info to STFIO |
| 1491 | } |
| 1492 | else if (GetKeyEdgeFlag()) // If key pressed |
| 1493 | { |
| 1494 | aCode = GetKeyCode(); // Grab key |
| 1495 | if (aCode == SETUPPB) // If Setup pb |
| 1496 | { |
| 1497 | SetupState = SETUP_TEST_MENU; // Goto Time of day |
| 1498 | } |
| 1499 | else if (aCode == ENTERPB) |
| 1500 | { |
| 1501 | #if FLOWSWITCH > 0 |
| 1502 | SetupState = SETUP_FLOWDELAY_TIME; |
| 1503 | #else |
| 1504 | SetupState = SETUP_RETRIES_REPRES; |
| 1505 | #endif // Goto Time of day |
| 1506 | } |
| 1507 | else if (aCode == UPPB) // If up pb |
| 1508 | { |
| 1509 | if (Config.ShutDownMode == SD_ALARM_ONLY) |
| 1510 | { |
| 1511 | Config.ShutDownMode = SD_NO_DISPENSE; |
| 1512 | strcpy(SetupBottomLine, " DISP WARN ONLY "); |
| 1513 | result = 1; |
| 1514 | } |
| 1515 | else if (Config.ShutDownMode == SD_NO_DISPENSE) |
| 1516 | { |
| 1517 | Config.ShutDownMode = SD_PER_CHANNEL; |
| 1518 | strcpy(SetupBottomLine, " PER CHANNEL "); |
| 1519 | result = 1; |
| 1520 | } |
| 1521 | else if (Config.ShutDownMode == SD_PER_CHANNEL) |
| 1522 | { |
| 1523 | Config.ShutDownMode = SD_PER_PRODUCT; |
| 1524 | strcpy(SetupBottomLine, " PER PRODUCT "); |
| 1525 | result = 1; |
| 1526 | } |
| 1527 | else |
| 1528 | { |
| 1529 | Config.ShutDownMode = SD_ALARM_ONLY; |
| 1530 | strcpy(SetupBottomLine, " ALARM ONLY "); |
| 1531 | result = 1; |
| 1532 | } |
| 1533 | } |
| 1534 | else if (aCode == DOWNPB) // If down pb |
| 1535 | { |
| 1536 | if (Config.ShutDownMode == SD_ALARM_ONLY) |
| 1537 | { |
| 1538 | Config.ShutDownMode = SD_PER_PRODUCT; |
| 1539 | strcpy(SetupBottomLine, " PER PRODUCT "); |
| 1540 | result = 1; |
| 1541 | } |
| 1542 | else if (Config.ShutDownMode == SD_PER_PRODUCT) |
| 1543 | { |
| 1544 | Config.ShutDownMode = SD_PER_CHANNEL; |
| 1545 | strcpy(SetupBottomLine, " PER CHANNEL "); |
| 1546 | result = 1; |
| 1547 | } |
| 1548 | else if (Config.ShutDownMode == SD_PER_CHANNEL) |
| 1549 | { |
| 1550 | Config.ShutDownMode = SD_NO_DISPENSE; |
| 1551 | strcpy(SetupBottomLine, " DISP WARN ONLY "); |
| 1552 | result = 1; |
| 1553 | } |
| 1554 | else |
| 1555 | { |
| 1556 | Config.ShutDownMode = SD_ALARM_ONLY; |
| 1557 | strcpy(SetupBottomLine, " ALARM ONLY "); |
| 1558 | result = 1; |
| 1559 | } |
| 1560 | } |
| 1561 | else if (aCode == CLEARPB) // If clear |
| 1562 | { |
| 1563 | SetupState = SETUP_TEST_MENU; // Leave menu |
| 1564 | } |
| 1565 | |
| 1566 | if (result) |
| 1567 | { |
| 1568 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 1569 | DisplayMsgCtr(SetupTopLine, SetupBottomLine); // Update dislpay |
| 1570 | UpdateFlag = 1; |
| 1571 | } // Beep if invalid key |
| 1572 | } |
| 1573 | } |
| 1574 | |
| 1575 | // Flow Switch Delay Time Menu ****************************************************************** |
| 1576 | |
| 1577 | void FlowDelayTime(int first) |
| 1578 | { |
| 1579 | int aCode; // Keycode |
| 1580 | static int FirstDigit; // First pressed digi flag |
| 1581 | int result; // Entery done |
| 1582 | char value[5]; |
| 1583 | |
| 1584 | result = 0; // Clear entery done flag // Grab current product |
| 1585 | |
| 1586 | if (first) // If first pass |
| 1587 | { |
| 1588 | Turbine = Config.FlowDelay; |
| 1589 | strcpy(SetupTopLine, "FLOW SW DELY SEC"); // Set Top row text |
| 1590 | sprintf(SetupBottomLine, " %3u ", Turbine); // Set buttom row wiht info |
| 1591 | DisplayMsg(SetupTopLine, SetupBottomLine); // Write Display |
| 1592 | FirstDigit = 1; // Set first number flag |
| 1593 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 1594 | printf("%s \n", SetupBottomLine); // Print info to STFIO |
| 1595 | } |
| 1596 | else if (GetKeyEdgeFlag()) // If key pressed |
| 1597 | { |
| 1598 | aCode = GetKeyCode(); // Grab key |
| 1599 | if (aCode == DOWNPB || aCode == UPPB) // If numeric key |
| 1600 | { |
| 1601 | UpdateDigit(aCode, SetupBottomLine, 6, 9, 1.0, 1.0, 999.0, GetFastFlag()); |
| 1602 | FirstDigit = 0; // Clear flag |
| 1603 | } |
| 1604 | else if (aCode == ENTERPB) // If enter pb |
| 1605 | { |
| 1606 | strncpy(value, SetupBottomLine+6, 3); |
| 1607 | Turbine = (int)(atof(value)); |
| 1608 | result = 1; // Entery done |
| 1609 | SetupState = SETUP_PRESCHECK_TIME; // Goto delay time entry |
| 1610 | } |
| 1611 | else if (aCode == CLEARPB) // If clear pb |
| 1612 | { |
| 1613 | sprintf(SetupBottomLine, " %3u ", Turbine); // Set buttom row wiht info |
| 1614 | RestartState = 1; |
| 1615 | } |
| 1616 | else if (aCode == SETUPPB) // If Setup pb |
| 1617 | { |
| 1618 | strncpy(value, SetupBottomLine+6, 3); |
| 1619 | Turbine = (int)(atof(value)); |
| 1620 | result = 1; // Entry done |
| 1621 | SetupState = SETUP_TEST_MENU; |
| 1622 | // Goto disable time entry |
| 1623 | } |
| 1624 | |
| 1625 | if (result && Turbine <= 999 && Turbine > 0) // If got final value |
| 1626 | { |
| 1627 | Config.FlowDelay = Turbine; |
| 1628 | } |
| 1629 | else |
| 1630 | { |
| 1631 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 1632 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 1633 | } |
| 1634 | } |
| 1635 | } |
| 1636 | |
| 1637 | // Pressure Check Time Menu ****************************************************************** |
| 1638 | |
| 1639 | void PresCheckTime(int first) |
| 1640 | { |
| 1641 | int aCode; // Keycode |
| 1642 | static int FirstDigit; // First pressed digi flag |
| 1643 | int result; // Entery done |
| 1644 | char value[5]; |
| 1645 | |
| 1646 | result = 0; // Clear entery done flag // Grab current product |
| 1647 | |
| 1648 | if (first) // If first pass |
| 1649 | { |
| 1650 | Turbine = Config.PresCheckDelay; |
| 1651 | strcpy(SetupTopLine, " PRES CHECK SEC "); // Set Top row text |
| 1652 | sprintf(SetupBottomLine, " %3u ", Turbine); // Set buttom row wiht info |
| 1653 | DisplayMsg(SetupTopLine, SetupBottomLine); // Write Display |
| 1654 | FirstDigit = 1; // Set first number flag |
| 1655 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 1656 | printf("%s \n", SetupBottomLine); // Print info to STFIO |
| 1657 | } |
| 1658 | else if (GetKeyEdgeFlag()) // If key pressed |
| 1659 | { |
| 1660 | aCode = GetKeyCode(); // Grab key |
| 1661 | if (aCode == DOWNPB || aCode == UPPB) // If numeric key |
| 1662 | { |
| 1663 | UpdateDigit(aCode, SetupBottomLine, 6, 9, 1.0, 1.0, 999.0, GetFastFlag()); |
| 1664 | FirstDigit = 0; // Clear flag |
| 1665 | } |
| 1666 | else if (aCode == ENTERPB) // If enter pb |
| 1667 | { |
| 1668 | strncpy(value, SetupBottomLine+6, 3); |
| 1669 | Turbine = (int)(atof(value)); |
| 1670 | result = 1; // Entery done |
| 1671 | SetupState = SETUP_RETRIES_REPRES; // Goto delay time entry |
| 1672 | } |
| 1673 | else if (aCode == CLEARPB) // If clear pb |
| 1674 | { |
| 1675 | sprintf(SetupBottomLine, " %3u ", Turbine); // Set buttom row wiht info |
| 1676 | RestartState = 1; |
| 1677 | } |
| 1678 | else if (aCode == SETUPPB) // If Setup pb |
| 1679 | { |
| 1680 | strncpy(value, SetupBottomLine+6, 3); |
| 1681 | Turbine = (int)(atof(value)); |
| 1682 | result = 1; // Entry done |
| 1683 | SetupState = SETUP_TEST_MENU; |
| 1684 | // Goto disable time entry |
| 1685 | } |
| 1686 | |
| 1687 | if (result && Turbine <= 999 && Turbine > 0) // If got final value |
| 1688 | { |
| 1689 | Config.PresCheckDelay = Turbine; |
| 1690 | } |
| 1691 | else |
| 1692 | { |
| 1693 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 1694 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 1695 | } |
| 1696 | } |
| 1697 | } |
| 1698 | |
| 1699 | // Time Of Day ********************************************************************************** |
| 1700 | |
| 1701 | void TimeOfDay(int first) |
| 1702 | { |
| 1703 | int aCode; // Keycode |
| 1704 | int result; // Return status |
| 1705 | static int SetDate; |
| 1706 | |
| 1707 | result = 0; |
| 1708 | |
| 1709 | if (first) // If first time in state |
| 1710 | { |
| 1711 | DisplayMsg(" SET DATE/TIME? ", " "); // Post Msg |
| 1712 | printf("SET DATE/TIME?\n"); |
| 1713 | InitializeDateTime(); |
| 1714 | SetDate = 0; |
| 1715 | } |
| 1716 | else if (SetDate) |
| 1717 | result = TodStateHandler(); // Run Time of day state machine |
| 1718 | else if (GetKeyEdgeFlag()) // If key press |
| 1719 | { |
| 1720 | aCode = GetKeyCode(); // Get key |
| 1721 | if (aCode == SETUPPB) // If setup |
| 1722 | result = 1; // Leave menu |
| 1723 | else if (aCode == CLEARPB) // If clear |
| 1724 | SetupDone = 1; // Leave menu |
| 1725 | else if (aCode == ENTERPB) // if enter and site already configured |
| 1726 | SetDate = 1; // Goto Run time // Key error |
| 1727 | } |
| 1728 | if (result != 0) // If Time of day done |
| 1729 | { |
| 1730 | SetDate = 0; |
| 1731 | #if MODBUS_S_ON |
| 1732 | SetupState = SETUP_MODBUS_CONFIG; |
| 1733 | #else |
| 1734 | SetupState = SETUP_SITE_CONFIG; // Go to config |
| 1735 | #endif |
| 1736 | } |
| 1737 | } |
| 1738 | |
| 1739 | // ModBus Config Sub menu ****************************************************** |
| 1740 | void ModBusConfig(int first) |
| 1741 | { |
| 1742 | int aCode; // Keycode |
| 1743 | int result; |
| 1744 | |
| 1745 | result = 0; |
| 1746 | |
| 1747 | if (first) // If first pass |
| 1748 | { |
| 1749 | strcpy(SetupTopLine, " MODBUS RS485 "); // Set Top row text |
| 1750 | strcpy(SetupBottomLine, " SETUP "); |
| 1751 | DisplayMsgCtr(SetupTopLine, SetupBottomLine); // Update dislpay |
| 1752 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 1753 | printf("%s \n", SetupBottomLine); // Print info to STFIO |
| 1754 | } |
| 1755 | else if (GetKeyEdgeFlag()) // If key pressed |
| 1756 | { |
| 1757 | aCode = GetKeyCode(); // Grab key |
| 1758 | if (aCode == SETUPPB) // If Setup pb |
| 1759 | SetupState = SETUP_SITE_CONFIG; // Goto Time of day |
| 1760 | else if (aCode == CLEARPB) |
| 1761 | SetupDone = 1; |
| 1762 | else if (aCode == ENTERPB) |
| 1763 | SetupState = SETUP_MODBUS_COMM_SETTINGS; |
| 1764 | } |
| 1765 | } |
| 1766 | |
| 1767 | // ModBus Config Comm Settings ************************************************* |
| 1768 | void ModBusCommSetting(int first) |
| 1769 | { |
| 1770 | int aCode; // Keycode |
| 1771 | |
| 1772 | if (first) // If first pass |
| 1773 | { |
| 1774 | Turbine = Config.ModBus.Baudidx; |
| 1775 | strcpy(SetupTopLine, " BAUD RATE "); // Set Top row text |
| 1776 | sprintf(SetupBottomLine, " %6ld ", BaudRate[Turbine]); // Set buttom row wiht info |
| 1777 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 1778 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 1779 | printf("%s \n", SetupBottomLine); // Print info to STFIO |
| 1780 | } |
| 1781 | else if (GetKeyEdgeFlag()) // If key pressed |
| 1782 | { |
| 1783 | aCode = GetKeyCode(); // Grab key |
| 1784 | if (aCode == SETUPPB) |
| 1785 | { // If Setup pb |
| 1786 | SetupState = SETUP_MODBUS_CONFIG; |
| 1787 | Config.ModBus.Baudidx = Turbine; // Mark setup done |
| 1788 | } |
| 1789 | else if (aCode == ENTERPB) // If enter pb |
| 1790 | { |
| 1791 | SetupState = SETUP_MODBUS_ADDRESS; |
| 1792 | Config.ModBus.Baudidx = Turbine; |
| 1793 | } |
| 1794 | else if (aCode == CLEARPB) // If clear pb |
| 1795 | { |
| 1796 | Turbine = Config.ModBus.Baudidx; |
| 1797 | sprintf(SetupBottomLine, " %6ld ", BaudRate[Turbine]); // Reset display to old value |
| 1798 | RestartState = 1; |
| 1799 | } // Goto Num of turbines |
| 1800 | else if (aCode == UPPB) // If up pb |
| 1801 | { |
| 1802 | Turbine++; |
| 1803 | if (Turbine >= BaudRateLength) Turbine = 0; |
| 1804 | sprintf(SetupBottomLine, " %6ld ", BaudRate[Turbine]); // Beep if first product |
| 1805 | } |
| 1806 | else if (aCode == DOWNPB) // If down pb |
| 1807 | { |
| 1808 | Turbine--; |
| 1809 | if (Turbine < 0) Turbine = BaudRateLength - 1; |
| 1810 | sprintf(SetupBottomLine, " %6ld ", BaudRate[Turbine]); // Beep if last product |
| 1811 | } // Beep if invalid key |
| 1812 | |
| 1813 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 1814 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 1815 | } |
| 1816 | } |
| 1817 | |
| 1818 | // ModBus Slave Address ******************************************************** |
| 1819 | void ModBusAddress(int first) |
| 1820 | { |
| 1821 | int aCode; // Keycode |
| 1822 | char value[5]; // Init no change |
| 1823 | |
| 1824 | if (first) // If first pass |
| 1825 | { |
| 1826 | Turbine = Config.ModBus.Address; // Grab duration for current product |
| 1827 | strcpy(SetupTopLine, " MODBUS ADDRESS "); // Set Top row text |
| 1828 | sprintf(SetupBottomLine, " %3d ", Turbine); // Set buttom row wiht info |
| 1829 | DisplayMsg(SetupTopLine, SetupBottomLine); // Write Display |
| 1830 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 1831 | printf("%s \n", SetupBottomLine); // Print info to STFIO |
| 1832 | } |
| 1833 | else if (GetKeyEdgeFlag()) // If key pressed |
| 1834 | { |
| 1835 | aCode = GetKeyCode(); // Grab key |
| 1836 | if (aCode == DOWNPB || aCode == UPPB) // If numeric key |
| 1837 | { |
| 1838 | UpdateDigit(aCode, SetupBottomLine, 6, 9, 1.0, 1.0, 254.0, GetFastFlag()); // Clear flag |
| 1839 | } |
| 1840 | else if (aCode == ENTERPB) // If enter pb |
| 1841 | { |
| 1842 | strncpy(value, SetupBottomLine+6, 3); |
| 1843 | Config.ModBus.Address = atoi(value); |
| 1844 | SetupState = SETUP_MODBUS_REG_OFFSET; // Goto Num of lead turbines |
| 1845 | } |
| 1846 | else if (aCode == CLEARPB) // If clear pb |
| 1847 | { |
| 1848 | sprintf(SetupBottomLine, " %3d ", Turbine); // Reset display to old value |
| 1849 | RestartState = 1; |
| 1850 | } |
| 1851 | else if (aCode == SETUPPB) // If Setup pb |
| 1852 | { |
| 1853 | strncpy(value, SetupBottomLine+5, 4); |
| 1854 | Config.ModBus.Address = atoi(value); |
| 1855 | SetupState = SETUP_MODBUS_CONFIG; // Mark setup done |
| 1856 | } // Beep if last product // Beep if invalid key |
| 1857 | |
| 1858 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 1859 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 1860 | } |
| 1861 | } |
| 1862 | |
| 1863 | // ModBus Registory Offset ***************************************************** |
| 1864 | void ModBusRegOffset(int first) |
| 1865 | { |
| 1866 | int aCode; // Keycode |
| 1867 | |
| 1868 | if (first) // If first pass |
| 1869 | { |
| 1870 | Turbine = Config.ModBus.Offsetidx; |
| 1871 | strcpy(SetupTopLine, " OFFSET ADDRESS "); // Set Top row text |
| 1872 | sprintf(SetupBottomLine, " %5u ", Offset[Turbine]); // Set buttom row wiht info |
| 1873 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 1874 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 1875 | printf("%s \n", SetupBottomLine); // Print info to STFIO |
| 1876 | } |
| 1877 | else if (GetKeyEdgeFlag()) // If key pressed |
| 1878 | { |
| 1879 | aCode = GetKeyCode(); // Grab key |
| 1880 | if (aCode == SETUPPB) |
| 1881 | { // If Setup pb |
| 1882 | SetupState = SETUP_MODBUS_CONFIG; |
| 1883 | Config.ModBus.Offsetidx = Turbine; // Mark setup done |
| 1884 | } |
| 1885 | else if (aCode == ENTERPB) // If enter pb |
| 1886 | { |
| 1887 | SetupState = SETUP_MODBUS_COMM_SETTINGS; |
| 1888 | Config.ModBus.Offsetidx = Turbine; |
| 1889 | } |
| 1890 | else if (aCode == CLEARPB) // If clear pb |
| 1891 | { |
| 1892 | Turbine = Config.ModBus.Offsetidx; |
| 1893 | sprintf(SetupBottomLine, " %5u ", Offset[Turbine]); // Reset display to old value |
| 1894 | RestartState = 1; |
| 1895 | } // Goto Num of turbines |
| 1896 | else if (aCode == UPPB) // If up pb |
| 1897 | { |
| 1898 | Turbine++; |
| 1899 | if (Turbine >= OffsetLength) Turbine = 0; |
| 1900 | sprintf(SetupBottomLine, " %5u ", Offset[Turbine]); // Beep if first product |
| 1901 | } |
| 1902 | else if (aCode == DOWNPB) // If down pb |
| 1903 | { |
| 1904 | Turbine--; |
| 1905 | if (Turbine < 0) Turbine = OffsetLength - 1; |
| 1906 | sprintf(SetupBottomLine, " %5u ", Offset[Turbine]); // Beep if last product |
| 1907 | } // Beep if invalid key |
| 1908 | |
| 1909 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 1910 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 1911 | } |
| 1912 | } |
| 1913 | |
| 1914 | // Site Config **************************************************************************** |
| 1915 | |
| 1916 | void SiteConfig(int first) |
| 1917 | { |
| 1918 | int aCode; // Keycode |
| 1919 | |
| 1920 | if (first) // If first time in state |
| 1921 | { |
| 1922 | DisplayMsg(" SITE ", " CONFIGURATION "); // Post Msg |
| 1923 | printf("CONFIGURATION\n"); |
| 1924 | } |
| 1925 | else if (GetKeyEdgeFlag()) // If key press |
| 1926 | { |
| 1927 | aCode = GetKeyCode(); // Get key |
| 1928 | if (aCode == SETUPPB) // If setup |
| 1929 | { |
| 1930 | SetupDone = 1; |
| 1931 | } |
| 1932 | else if (aCode == CLEARPB) // If clear |
| 1933 | SetupDone = 1; // Leave menu |
| 1934 | else if (aCode == ENTERPB) // if enter and site already configured |
| 1935 | { |
| 1936 | SetupState = SETUP_NUM_OF_TURBINES; // Goto Run time |
| 1937 | pwDest = SETUP_NUM_OF_TURBINES; |
| 1938 | ProductID = 0; |
| 1939 | } // Key error |
| 1940 | } |
| 1941 | } |
| 1942 | |
| 1943 | // Number of Turbines ****************************************************************************** |
| 1944 | |
| 1945 | void NumOfTurbines(int first) |
| 1946 | { |
| 1947 | int aCode; // Keycode |
| 1948 | static int FirstDigit; // First pressed digi flag |
| 1949 | int result; // Entery done |
| 1950 | int CurrentProduct; // Product currently servicing |
| 1951 | int Temp; |
| 1952 | int NextState; |
| 1953 | char value[5]; |
| 1954 | |
| 1955 | result = 0; // Clear entery done flag |
| 1956 | CurrentProduct = ProductID; // Grab current product |
| 1957 | NextState = SetupState; // Init no change |
| 1958 | |
| 1959 | if (first) // If first pass |
| 1960 | { |
| 1961 | Turbine = Product[ProductID].N_Turbines; // Grab duration for current product |
| 1962 | strcpy(SetupTopLine, "NUM OF TURBINES "); // Set Top row text |
| 1963 | sprintf(SetupBottomLine, "PRODUCT %d %d",ProductID+1,Turbine); // Set buttom row wiht info |
| 1964 | DisplayMsg(SetupTopLine, SetupBottomLine); // Write Display |
| 1965 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 1966 | printf("%s \n", SetupBottomLine); |
| 1967 | if (PreviousSetupState == SETUP_ONOFF_TIME) |
| 1968 | { |
| 1969 | Product[ProductID].CV.OnDly = OnTime; |
| 1970 | Product[ProductID].CV.OffDly = OffTime; |
| 1971 | } // Print info to STFIO |
| 1972 | } |
| 1973 | else if (GetKeyEdgeFlag()) // If key pressed |
| 1974 | { |
| 1975 | aCode = GetKeyCode(); // Grab key |
| 1976 | if (aCode == DOWNPB || aCode == UPPB) // If numeric key |
| 1977 | { |
| 1978 | UpdateDigit(aCode, SetupBottomLine, 11, 16, 1.0, 0.0, N_ISM,GetFastFlag()); |
| 1979 | FirstDigit = 0; // Clear flag |
| 1980 | } |
| 1981 | else if (aCode == ENTERPB) // If enter pb |
| 1982 | { |
| 1983 | strncpy(value, SetupBottomLine+11, 5); |
| 1984 | Turbine = atoi(value); |
| 1985 | result = 1; |
| 1986 | if (Turbine < 1) |
| 1987 | { |
| 1988 | NextState = SETUP_NUM_OF_TURBINES; |
| 1989 | RestartState = 1; |
| 1990 | if (ProductID+1 < N_PROD) |
| 1991 | ProductID++; |
| 1992 | else |
| 1993 | ProductID = 0; |
| 1994 | } |
| 1995 | else if (Turbine == 1) |
| 1996 | { |
| 1997 | #if CV_ON |
| 1998 | NextState = SETUP_SUCTION_CV; |
| 1999 | #else |
| 2000 | NextState = SETUP_NUM_OF_TURBINES; |
| 2001 | RestartState = 1; |
| 2002 | if (ProductID+1 < N_PROD) |
| 2003 | ProductID++; |
| 2004 | else |
| 2005 | ProductID = 0; |
| 2006 | #endif |
| 2007 | } |
| 2008 | else // Entery done |
| 2009 | NextState = SETUP_LEAD_TURBINES; // Goto Num of lead turbines |
| 2010 | } |
| 2011 | else if (aCode == TESTPB) |
| 2012 | { |
| 2013 | strncpy(value, SetupBottomLine+11, 5); |
| 2014 | Turbine = atoi(value); |
| 2015 | result = 1; |
| 2016 | OnTime = Product[ProductID].CV.OnDly; |
| 2017 | OffTime = Product[ProductID].CV.OffDly; |
| 2018 | NextState = SETUP_ONOFF_TIME; |
| 2019 | } |
| 2020 | else if (aCode == CLEARPB) // If clear pb |
| 2021 | { |
| 2022 | sprintf(SetupBottomLine, "PRODUCT %d %d",ProductID+1,Turbine); // Reset display to old value |
| 2023 | RestartState = 1; |
| 2024 | } |
| 2025 | else if (aCode == SETUPPB) // If Setup pb |
| 2026 | { |
| 2027 | ChannelSetup(); // Setup channels based on config |
| 2028 | SetupDone = 1; // Mark setup done |
| 2029 | } // Beep if invalid key |
| 2030 | |
| 2031 | if (result) // If got final value |
| 2032 | { |
| 2033 | Temp = Product[CurrentProduct].N_Turbines; // Grab current value |
| 2034 | Product[CurrentProduct].N_Turbines = Turbine; // Right new values to table |
| 2035 | if (Turbine < 1) |
| 2036 | { |
| 2037 | Product[CurrentProduct].N_LeadTurbines = Turbine; |
| 2038 | Product[CurrentProduct].N_RunTurbines = Turbine; |
| 2039 | Product[CurrentProduct].N_PistonSwitches = Turbine; |
| 2040 | Product[CurrentProduct].RotateFlag = OFF; |
| 2041 | Product[CurrentProduct].AutoAuthFlag = OFF; |
| 2042 | } |
| 2043 | else if (TestSetup()) // Test new volue |
| 2044 | { |
| 2045 | SetupState = NextState; |
| 2046 | if (Turbine <= 1) |
| 2047 | { |
| 2048 | Product[CurrentProduct].N_LeadTurbines = Turbine; |
| 2049 | Product[CurrentProduct].N_RunTurbines = Turbine; |
| 2050 | Product[CurrentProduct].N_PistonSwitches = Turbine; |
| 2051 | Product[CurrentProduct].RotateFlag = OFF; |
| 2052 | Product[CurrentProduct].AutoAuthFlag = OFF; |
| 2053 | } |
| 2054 | } // Go to next state |
| 2055 | else |
| 2056 | { |
| 2057 | Product[CurrentProduct].N_Turbines = Temp; // Reset entty to original |
| 2058 | RestartState = 1; // Rerun state as first |
| 2059 | } |
| 2060 | } |
| 2061 | else |
| 2062 | { |
| 2063 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 2064 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 2065 | } |
| 2066 | } |
| 2067 | } |
| 2068 | |
| 2069 | // Number of Lead Turbines *************************************************************************** |
| 2070 | |
| 2071 | void LeadTurbines(int first) |
| 2072 | { |
| 2073 | int aCode; // Keycode |
| 2074 | int result; // Entery done |
| 2075 | int CurrentProduct; // Product currently servicing |
| 2076 | int NextState; |
| 2077 | char value[5]; |
| 2078 | |
| 2079 | result = 0; // Clear entery done flag |
| 2080 | CurrentProduct = ProductID; // Grab current product |
| 2081 | NextState = SetupState; // Init no change |
| 2082 | |
| 2083 | if (first) // If first pass |
| 2084 | { |
| 2085 | Turbine = Product[ProductID].N_LeadTurbines; // Grab duration for current product |
| 2086 | strcpy(SetupTopLine, "NUM OF LEAD TURB"); // Set Top row text |
| 2087 | sprintf(SetupBottomLine, "PRODUCT %d %d",ProductID+1,Turbine); // Set buttom row wiht info |
| 2088 | DisplayMsg(SetupTopLine, SetupBottomLine); // Write Display |
| 2089 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 2090 | printf("%s \n", SetupBottomLine); // Print info to STFIO |
| 2091 | } |
| 2092 | else if (GetKeyEdgeFlag()) // If key pressed |
| 2093 | { |
| 2094 | aCode = GetKeyCode(); // Grab key |
| 2095 | if (aCode == DOWNPB || aCode == UPPB) // If numeric key |
| 2096 | { |
| 2097 | UpdateDigit(aCode, SetupBottomLine, 11, 16, 1.0, 1.0, Product[CurrentProduct].N_Turbines, GetFastFlag()); // Clear flag |
| 2098 | } |
| 2099 | else if (aCode == ENTERPB) // If enter pb |
| 2100 | { |
| 2101 | strncpy(value, SetupBottomLine+11, 5); |
| 2102 | Turbine = atoi(value); |
| 2103 | result = 1; // Entery done // Goto Num of lead turbines |
| 2104 | NextState = SETUP_LEAK_DETECTOR; |
| 2105 | } |
| 2106 | else if (aCode == CLEARPB) // If clear pb |
| 2107 | { |
| 2108 | sprintf(SetupBottomLine, "PRODUCT %d %d",ProductID+1,Turbine); // Reset display to old value |
| 2109 | RestartState = 1; |
| 2110 | } |
| 2111 | else if (aCode == SETUPPB) // If Setup pb |
| 2112 | { |
| 2113 | ChannelSetup(); // Setup channels based on config |
| 2114 | SetupDone = 1; // Mark setup done |
| 2115 | } // Beep if last product // Beep if invalid key |
| 2116 | |
| 2117 | if (result) // If got final value |
| 2118 | { |
| 2119 | if (Turbine <= Product[CurrentProduct].N_Turbines) // Test new volue |
| 2120 | { |
| 2121 | Product[CurrentProduct].N_LeadTurbines = Turbine; |
| 2122 | if (Turbine == 1) |
| 2123 | Product[CurrentProduct].RotateFlag = OFF; |
| 2124 | SetupState = NextState; // Go to next state |
| 2125 | } |
| 2126 | else |
| 2127 | { // Error |
| 2128 | RestartState = 1; // Rerun state as first |
| 2129 | } |
| 2130 | } |
| 2131 | else |
| 2132 | { |
| 2133 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 2134 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 2135 | } |
| 2136 | } |
| 2137 | } |
| 2138 | |
| 2139 | // Number of Lead Turbines *************************************************************************** |
| 2140 | |
| 2141 | void LeakDetectors(int first) |
| 2142 | { |
| 2143 | int aCode; // Keycode |
| 2144 | int result; // Entery done |
| 2145 | int CurrentProduct; // Product currently servicing |
| 2146 | int NextState; |
| 2147 | char value[5]; |
| 2148 | |
| 2149 | result = 0; // Clear entery done flag |
| 2150 | CurrentProduct = ProductID; // Grab current product |
| 2151 | NextState = SetupState; // Init no change |
| 2152 | |
| 2153 | if (first) // If first pass |
| 2154 | { |
| 2155 | Turbine = Product[ProductID].N_PistonSwitches; // Grab duration for current product |
| 2156 | strcpy(SetupTopLine, " NUM OF LDNs "); // Set Top row text |
| 2157 | sprintf(SetupBottomLine, "PRODUCT %d %d",ProductID+1,Turbine); // Set buttom row wiht info |
| 2158 | DisplayMsg(SetupTopLine, SetupBottomLine); // Write Display |
| 2159 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 2160 | printf("%s \n", SetupBottomLine); // Print info to STFIO |
| 2161 | } |
| 2162 | else if (GetKeyEdgeFlag()) // If key pressed |
| 2163 | { |
| 2164 | aCode = GetKeyCode(); // Grab key |
| 2165 | if (aCode == DOWNPB || aCode == UPPB) // If numeric key |
| 2166 | { |
| 2167 | UpdateDigit(aCode, SetupBottomLine, 11, 16, 1.0, 1.0, Product[CurrentProduct].N_LeadTurbines, GetFastFlag()); // Clear flag |
| 2168 | } |
| 2169 | else if (aCode == ENTERPB) // If enter pb |
| 2170 | { |
| 2171 | strncpy(value, SetupBottomLine+11, 5); |
| 2172 | Turbine = atoi(value); |
| 2173 | result = 1; // Entery done // Goto Num of lead turbines |
| 2174 | NextState = SETUP_RUN_TURBINES; |
| 2175 | } |
| 2176 | else if (aCode == CLEARPB) // If clear pb |
| 2177 | { |
| 2178 | sprintf(SetupBottomLine, "PRODUCT %d %d",ProductID+1,Turbine); // Reset display to old value |
| 2179 | RestartState = 1; |
| 2180 | } |
| 2181 | else if (aCode == SETUPPB) // If Setup pb |
| 2182 | { |
| 2183 | ChannelSetup(); // Setup channels based on config |
| 2184 | SetupDone = 1; // Mark setup done // Clear previous state so this state runs like new |
| 2185 | } // Beep if last product // Beep if invalid key |
| 2186 | |
| 2187 | if (result) // If got final value |
| 2188 | { |
| 2189 | if (Turbine > N_PRES_INPUTS) |
| 2190 | Turbine = N_PRES_INPUTS; |
| 2191 | if (Turbine <= Product[CurrentProduct].N_LeadTurbines) // Test new volue |
| 2192 | { |
| 2193 | Product[CurrentProduct].N_PistonSwitches = Turbine; |
| 2194 | SetupState = NextState; // Go to next state |
| 2195 | } |
| 2196 | else |
| 2197 | { // Error |
| 2198 | RestartState = 1; // Rerun state as first |
| 2199 | } |
| 2200 | } |
| 2201 | else |
| 2202 | { |
| 2203 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 2204 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 2205 | } |
| 2206 | } |
| 2207 | } |
| 2208 | |
| 2209 | // Number of Run Turbines *************************************************************************** |
| 2210 | |
| 2211 | void RunTurbines(int first) |
| 2212 | { |
| 2213 | int aCode; // Keycode |
| 2214 | int result; // Entery done |
| 2215 | int CurrentProduct; // Product currently servicing |
| 2216 | int NextState; |
| 2217 | char value[5]; |
| 2218 | |
| 2219 | result = 0; // Clear entery done flag |
| 2220 | CurrentProduct = ProductID; // Grab current product |
| 2221 | NextState = SetupState; // Init no change |
| 2222 | |
| 2223 | if (first) // If first pass |
| 2224 | { |
| 2225 | Turbine = Product[ProductID].N_RunTurbines; // Grab duration for current product |
| 2226 | strcpy(SetupTopLine, "NUM OF RUN TURB "); // Set Top row text |
| 2227 | sprintf(SetupBottomLine, "PRODUCT %d %d",ProductID+1,Turbine); // Set buttom row wiht info |
| 2228 | DisplayMsg(SetupTopLine, SetupBottomLine); // Write Display |
| 2229 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 2230 | printf("%s \n", SetupBottomLine); // Print info to STFIO |
| 2231 | } |
| 2232 | else if (GetKeyEdgeFlag()) // If key pressed |
| 2233 | { |
| 2234 | aCode = GetKeyCode(); // Grab key |
| 2235 | if (aCode == DOWNPB || aCode == UPPB) // If numeric key |
| 2236 | { |
| 2237 | UpdateDigit(aCode, SetupBottomLine, 11, 16, 1.0, 1.0, Product[CurrentProduct].N_Turbines, GetFastFlag()); // Clear flag |
| 2238 | } |
| 2239 | else if (aCode == ENTERPB) // If enter pb |
| 2240 | { |
| 2241 | strncpy(value, SetupBottomLine+11, 5); |
| 2242 | Turbine = atoi(value); |
| 2243 | result = 1; |
| 2244 | if (Product[ProductID].N_LeadTurbines <= 1) |
| 2245 | NextState = SETUP_TURBINE_AUTH; |
| 2246 | else // Entery done |
| 2247 | NextState = SETUP_ROTATE; // Goto Num of lead turbines |
| 2248 | } |
| 2249 | else if (aCode == CLEARPB) // If clear pb |
| 2250 | { |
| 2251 | sprintf(SetupBottomLine, "PRODUCT %d %d",ProductID+1,Turbine); // Reset display to old value |
| 2252 | RestartState = 1; |
| 2253 | } |
| 2254 | else if (aCode == SETUPPB) // If Setup pb |
| 2255 | { |
| 2256 | ChannelSetup(); // Setup channels based on config |
| 2257 | SetupDone = 1; // Mark setup done |
| 2258 | } // Beep if last product // Beep if invalid key |
| 2259 | |
| 2260 | if (result) // If got final value |
| 2261 | { |
| 2262 | if (Turbine <= Product[CurrentProduct].N_Turbines) // Test new volue |
| 2263 | { |
| 2264 | Product[CurrentProduct].N_RunTurbines = Turbine; |
| 2265 | SetupState = NextState; // Go to next state |
| 2266 | } |
| 2267 | else |
| 2268 | { // Error |
| 2269 | RestartState = 1; // Rerun state as first |
| 2270 | } |
| 2271 | } |
| 2272 | else |
| 2273 | { |
| 2274 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 2275 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 2276 | } |
| 2277 | } |
| 2278 | } |
| 2279 | |
| 2280 | // Rotate Lead Turbine *************************************************************************** |
| 2281 | |
| 2282 | void Rotate(int first) |
| 2283 | { |
| 2284 | int aCode; // Keycode |
| 2285 | |
| 2286 | if (first) // If first pass |
| 2287 | { |
| 2288 | strcpy(SetupTopLine, "ROTATE TURBINES?"); // Set Top row text |
| 2289 | if (Product[ProductID].RotateFlag) // Put current status in display |
| 2290 | sprintf(SetupBottomLine, "PRODUCT %d YES",ProductID+1); // Set buttom row wiht info |
| 2291 | else |
| 2292 | sprintf(SetupBottomLine, "PRODUCT %d NO",ProductID+1); // Set buttom row wiht info |
| 2293 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 2294 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 2295 | printf("%s \n", SetupBottomLine); // Print info to STFIO |
| 2296 | } |
| 2297 | else if (GetKeyEdgeFlag()) // If key pressed |
| 2298 | { |
| 2299 | aCode = GetKeyCode(); // Grab key |
| 2300 | if (aCode == SETUPPB) // If Setup pb |
| 2301 | { |
| 2302 | ChannelSetup(); // Setup channels based on config |
| 2303 | SetupDone = 1; // Mark setup done |
| 2304 | } |
| 2305 | else if (aCode == ENTERPB) // If enter pb |
| 2306 | SetupState = SETUP_TURBINE_AUTH; // Goto Num of turbines |
| 2307 | else if (aCode == UPPB) // If up pb |
| 2308 | { |
| 2309 | Product[ProductID].RotateFlag = ON; |
| 2310 | sprintf(SetupBottomLine, "PRODUCT %d YES",ProductID+1); // Beep if first product |
| 2311 | } |
| 2312 | else if (aCode == DOWNPB) // If down pb |
| 2313 | { |
| 2314 | Product[ProductID].RotateFlag = OFF; |
| 2315 | sprintf(SetupBottomLine, "PRODUCT %d NO",ProductID+1); // Beep if last product |
| 2316 | } // Beep if invalid key |
| 2317 | |
| 2318 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 2319 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 2320 | } |
| 2321 | } |
| 2322 | |
| 2323 | |
| 2324 | // Turbine Auth function*************************************************************************** |
| 2325 | |
| 2326 | const char AuthString[][] = |
| 2327 | { |
| 2328 | "INPUT BASED AUTH", |
| 2329 | "AUTO BASED AUTH", |
| 2330 | "PRES BASED AUTH" |
| 2331 | }; |
| 2332 | |
| 2333 | void TurbineAuth(int first) |
| 2334 | { |
| 2335 | int aCode; // Keycode |
| 2336 | |
| 2337 | if (first) // If first pass |
| 2338 | { |
| 2339 | sprintf(SetupBottomLine, "PRODUCT %d ",ProductID+1); // Put current status in display |
| 2340 | strcpy(SetupTopLine, AuthString[Product[ProductID].AutoAuthFlag]); |
| 2341 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 2342 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 2343 | printf("%s \n", SetupBottomLine); // Print info to STFIO |
| 2344 | } |
| 2345 | else if (GetKeyEdgeFlag()) // If key pressed |
| 2346 | { |
| 2347 | aCode = GetKeyCode(); // Grab key |
| 2348 | if (aCode == SETUPPB) // If Setup pb |
| 2349 | { |
| 2350 | ChannelSetup(); // Setup channels based on config |
| 2351 | SetupDone = 1; // Mark setup done |
| 2352 | } |
| 2353 | else if (aCode == ENTERPB) |
| 2354 | { |
| 2355 | #if CV_ON |
| 2356 | SetupState = SETUP_SUCTION_CV; |
| 2357 | #else |
| 2358 | SetupState = SETUP_NUM_OF_TURBINES; |
| 2359 | if (ProductID+1 < N_PROD) |
| 2360 | ProductID++; |
| 2361 | else |
| 2362 | ProductID = 0; |
| 2363 | #endif // If enter pb |
| 2364 | } |
| 2365 | else if (aCode == UPPB) // If up pb |
| 2366 | { |
| 2367 | |
| 2368 | Product[ProductID].AutoAuthFlag--; |
| 2369 | if (Product[ProductID].AutoAuthFlag < AUTH_INPUT) |
| 2370 | Product[ProductID].AutoAuthFlag = AUTH_DEMAND; |
| 2371 | strcpy(SetupTopLine, AuthString[Product[ProductID].AutoAuthFlag]); // Beep if first product |
| 2372 | } |
| 2373 | else if (aCode == DOWNPB) // If down pb |
| 2374 | { |
| 2375 | Product[ProductID].AutoAuthFlag++; |
| 2376 | if (Product[ProductID].AutoAuthFlag > AUTH_DEMAND) |
| 2377 | Product[ProductID].AutoAuthFlag = AUTH_INPUT; |
| 2378 | strcpy(SetupTopLine, AuthString[Product[ProductID].AutoAuthFlag]); // Beep if last product |
| 2379 | } // Beep if invalid key |
| 2380 | |
| 2381 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 2382 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 2383 | } |
| 2384 | } |
| 2385 | |
| 2386 | // Number of Suction CV ****************************************************************************** |
| 2387 | |
| 2388 | void SuctionCV(int first) |
| 2389 | { |
| 2390 | int aCode; // Keycode |
| 2391 | static int FirstDigit; // First pressed digi flag |
| 2392 | int result; // Entery done |
| 2393 | int CurrentProduct; // Product currently servicing |
| 2394 | int Temp; |
| 2395 | int NextState; |
| 2396 | char value[5]; |
| 2397 | |
| 2398 | result = 0; // Clear entery done flag |
| 2399 | CurrentProduct = ProductID; // Grab current product |
| 2400 | NextState = SetupState; // Init no change |
| 2401 | |
| 2402 | if (first) // If first pass |
| 2403 | { |
| 2404 | Turbine = Product[ProductID].CV.SCV; // Grab duration for current product |
| 2405 | strcpy(SetupTopLine, "NUM SUCTION CV "); // Set Top row text |
| 2406 | sprintf(SetupBottomLine, "PRODUCT %d %d",ProductID+1,Turbine); // Set buttom row wiht info |
| 2407 | DisplayMsg(SetupTopLine, SetupBottomLine); // Write Display |
| 2408 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 2409 | printf("%s \n", SetupBottomLine); |
| 2410 | if (PreviousSetupState == SETUP_ONOFF_TIME) |
| 2411 | { |
| 2412 | Product[CurrentProduct].CV.scvOnDly = OnTime; |
| 2413 | Product[CurrentProduct].CV.scvOffDly = OffTime; |
| 2414 | } // Print info to STFIO |
| 2415 | } |
| 2416 | else if (GetKeyEdgeFlag()) // If key pressed |
| 2417 | { |
| 2418 | aCode = GetKeyCode(); // Grab key |
| 2419 | if (aCode == DOWNPB || aCode == UPPB) // If numeric key |
| 2420 | { |
| 2421 | UpdateDigit(aCode, SetupBottomLine, 11, 16, 1.0, 0.0, N_ISM, GetFastFlag()); |
| 2422 | FirstDigit = 0; // Clear flag |
| 2423 | } |
| 2424 | else if (aCode == ENTERPB) // If enter pb |
| 2425 | { |
| 2426 | strncpy(value, SetupBottomLine+11, 5); |
| 2427 | Turbine = atoi(value); |
| 2428 | result = 1; |
| 2429 | NextState = SETUP_PRESSURE_CV; |
| 2430 | } |
| 2431 | else if (aCode == TESTPB) |
| 2432 | { |
| 2433 | strncpy(value, SetupBottomLine+11, 5); |
| 2434 | Turbine = atoi(value); |
| 2435 | result = 1; |
| 2436 | OnTime = Product[CurrentProduct].CV.scvOnDly; |
| 2437 | OffTime = Product[CurrentProduct].CV.scvOffDly; |
| 2438 | NextState = SETUP_ONOFF_TIME; |
| 2439 | } |
| 2440 | else if (aCode == CLEARPB) // If clear pb |
| 2441 | { |
| 2442 | sprintf(SetupBottomLine, "PRODUCT %d %d",ProductID+1,Turbine); // Reset display to old value |
| 2443 | RestartState = 1; |
| 2444 | } |
| 2445 | else if (aCode == SETUPPB) // If Setup pb |
| 2446 | { |
| 2447 | ChannelSetup(); // Setup channels based on config |
| 2448 | SetupDone = 1; // Mark setup done // Beep if last product |
| 2449 | } // Beep if invalid key |
| 2450 | |
| 2451 | if (result) // If got final value |
| 2452 | { |
| 2453 | Temp = Product[CurrentProduct].N_Turbines; |
| 2454 | if (Product[CurrentProduct].N_Turbines <= Turbine) |
| 2455 | Product[CurrentProduct].N_Turbines = Turbine; // Right new values to tabl |
| 2456 | if (TestSetup()) // Test new volue |
| 2457 | { |
| 2458 | SetupState = NextState; |
| 2459 | Product[CurrentProduct].CV.SCV = Turbine; |
| 2460 | } // Go to next state |
| 2461 | else |
| 2462 | { // Error |
| 2463 | RestartState = 1; // Rerun state as first |
| 2464 | } |
| 2465 | Product[CurrentProduct].N_Turbines = Temp; |
| 2466 | } |
| 2467 | else |
| 2468 | { |
| 2469 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 2470 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 2471 | } |
| 2472 | } |
| 2473 | } |
| 2474 | |
| 2475 | // Number of Pressure CV ****************************************************************************** |
| 2476 | |
| 2477 | void PressureCV(int first) |
| 2478 | { |
| 2479 | int aCode; // Keycode |
| 2480 | static int FirstDigit; // First pressed digi flag |
| 2481 | int result; // Entery done |
| 2482 | int CurrentProduct; // Product currently servicing |
| 2483 | int Temp; |
| 2484 | int NextState; |
| 2485 | char value[5]; |
| 2486 | |
| 2487 | result = 0; // Clear entery done flag |
| 2488 | CurrentProduct = ProductID; // Grab current product |
| 2489 | NextState = SetupState; // Init no change |
| 2490 | |
| 2491 | if (first) // If first pass |
| 2492 | { |
| 2493 | Turbine = Product[ProductID].CV.PCV; // Grab duration for current product |
| 2494 | strcpy(SetupTopLine, "NUM PRESSURE CV "); // Set Top row text |
| 2495 | sprintf(SetupBottomLine, "PRODUCT %d %d",ProductID+1,Turbine); // Set buttom row wiht info |
| 2496 | DisplayMsg(SetupTopLine, SetupBottomLine); // Write Display |
| 2497 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 2498 | printf("%s \n", SetupBottomLine); |
| 2499 | if (PreviousSetupState == SETUP_ONOFF_TIME) |
| 2500 | { |
| 2501 | Product[CurrentProduct].CV.pcvOnDly = OnTime; |
| 2502 | Product[CurrentProduct].CV.pcvOffDly = OffTime; |
| 2503 | } // Print info to STFIO |
| 2504 | } |
| 2505 | else if (GetKeyEdgeFlag()) // If key pressed |
| 2506 | { |
| 2507 | aCode = GetKeyCode(); // Grab key |
| 2508 | if (aCode == DOWNPB || aCode == UPPB) // If numeric key |
| 2509 | { |
| 2510 | UpdateDigit(aCode, SetupBottomLine, 11, 16, 1.0, 0.0, N_ISM, GetFastFlag()); |
| 2511 | FirstDigit = 0; // Clear flag |
| 2512 | } |
| 2513 | else if (aCode == ENTERPB) // If enter pb |
| 2514 | { |
| 2515 | strncpy(value, SetupBottomLine+11, 5); |
| 2516 | Turbine = atoi(value); |
| 2517 | result = 1; |
| 2518 | NextState = SETUP_DISP_CV; |
| 2519 | } |
| 2520 | else if (aCode == TESTPB) |
| 2521 | { |
| 2522 | strncpy(value, SetupBottomLine+11, 5); |
| 2523 | Turbine = atoi(value); |
| 2524 | result = 1; |
| 2525 | OnTime = Product[CurrentProduct].CV.pcvOnDly; |
| 2526 | OffTime = Product[CurrentProduct].CV.pcvOffDly; |
| 2527 | NextState = SETUP_ONOFF_TIME; |
| 2528 | } |
| 2529 | else if (aCode == CLEARPB) // If clear pb |
| 2530 | { |
| 2531 | sprintf(SetupBottomLine, "PRODUCT %d %d",ProductID+1,Turbine); // Reset display to old value |
| 2532 | RestartState = 1; |
| 2533 | } |
| 2534 | else if (aCode == SETUPPB) // If Setup pb |
| 2535 | { |
| 2536 | ChannelSetup(); // Setup channels based on config |
| 2537 | SetupDone = 1; // Mark setup done |
| 2538 | } // Beep if invalid key |
| 2539 | |
| 2540 | if (result) // If got final value |
| 2541 | { |
| 2542 | Temp = Product[CurrentProduct].N_Turbines; |
| 2543 | if (Product[CurrentProduct].N_Turbines <= Turbine) |
| 2544 | Product[CurrentProduct].N_Turbines = Turbine; // Right new values to table |
| 2545 | if (TestSetup()) // Test new volue |
| 2546 | { |
| 2547 | SetupState = NextState; |
| 2548 | Product[CurrentProduct].CV.PCV = Turbine; |
| 2549 | } // Go to next state |
| 2550 | else |
| 2551 | { |
| 2552 | RestartState = 1; // Rerun state as first |
| 2553 | } |
| 2554 | Product[CurrentProduct].N_Turbines = Temp; |
| 2555 | } |
| 2556 | else |
| 2557 | { |
| 2558 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 2559 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 2560 | } |
| 2561 | } |
| 2562 | } |
| 2563 | |
| 2564 | // Number of Disp CV ****************************************************************************** |
| 2565 | |
| 2566 | void DispCV(int first) |
| 2567 | { |
| 2568 | int aCode; // Keycode |
| 2569 | static int FirstDigit; // First pressed digi flag |
| 2570 | int result; // Entery done |
| 2571 | int CurrentProduct; // Product currently servicing |
| 2572 | int Temp; |
| 2573 | int NextState; |
| 2574 | char value[5]; |
| 2575 | |
| 2576 | result = 0; // Clear entery done flag |
| 2577 | CurrentProduct = ProductID; // Grab current product |
| 2578 | NextState = SetupState; // Init no change |
| 2579 | |
| 2580 | if (first) // If first pass |
| 2581 | { |
| 2582 | Turbine = Product[ProductID].CV.DCV; // Grab duration for current product |
| 2583 | strcpy(SetupTopLine, "NUM DISPENSER CV"); // Set Top row text |
| 2584 | sprintf(SetupBottomLine, "PRODUCT %d %d",ProductID+1,Turbine); // Set buttom row wiht info |
| 2585 | DisplayMsg(SetupTopLine, SetupBottomLine); // Write Display |
| 2586 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 2587 | printf("%s \n", SetupBottomLine); |
| 2588 | if (PreviousSetupState == SETUP_ONOFF_TIME) |
| 2589 | { |
| 2590 | Product[CurrentProduct].CV.dcvOnDly = OnTime; |
| 2591 | Product[CurrentProduct].CV.dcvOffDly = OffTime; |
| 2592 | } // Print info to STFIO |
| 2593 | } |
| 2594 | else if (GetKeyEdgeFlag()) // If key pressed |
| 2595 | { |
| 2596 | aCode = GetKeyCode(); // Grab key |
| 2597 | if (aCode == DOWNPB || aCode == UPPB) // If numeric key |
| 2598 | { |
| 2599 | UpdateDigit(aCode, SetupBottomLine, 11, 16, 1.0, 0.0, N_ISM, GetFastFlag()); |
| 2600 | FirstDigit = 0; // Clear flag |
| 2601 | } |
| 2602 | else if (aCode == ENTERPB) // If enter pb |
| 2603 | { |
| 2604 | strncpy(value, SetupBottomLine+11, 5); |
| 2605 | Turbine = atoi(value); |
| 2606 | result = 1; |
| 2607 | NextState = SETUP_NUM_OF_TURBINES; // Goto Num of turbines |
| 2608 | if (ProductID+1 < N_PROD) |
| 2609 | ProductID++; |
| 2610 | else |
| 2611 | ProductID = 0; |
| 2612 | } |
| 2613 | else if (aCode == TESTPB) |
| 2614 | { |
| 2615 | strncpy(value, SetupBottomLine+11, 5); |
| 2616 | Turbine = atoi(value); |
| 2617 | result = 1; |
| 2618 | OnTime = Product[CurrentProduct].CV.dcvOnDly; |
| 2619 | OffTime = Product[CurrentProduct].CV.dcvOffDly; |
| 2620 | NextState = SETUP_ONOFF_TIME; |
| 2621 | } |
| 2622 | else if (aCode == CLEARPB) // If clear pb |
| 2623 | { |
| 2624 | sprintf(SetupBottomLine, "PRODUCT %d %d",ProductID+1,Turbine); // Reset display to old value |
| 2625 | RestartState = 1; |
| 2626 | } |
| 2627 | else if (aCode == SETUPPB) // If Setup pb |
| 2628 | { |
| 2629 | ChannelSetup(); // Setup channels based on config |
| 2630 | SetupDone = 1; // Mark setup done // Beep if last product |
| 2631 | } // Beep if invalid key |
| 2632 | |
| 2633 | if (result) // If got final value |
| 2634 | { |
| 2635 | Temp = Product[CurrentProduct].N_Turbines; |
| 2636 | if (Product[CurrentProduct].N_Turbines <= Turbine) |
| 2637 | Product[CurrentProduct].N_Turbines = Turbine; // Right new values to table |
| 2638 | if (TestSetup()) // Test new volue |
| 2639 | { |
| 2640 | SetupState = NextState; |
| 2641 | Product[CurrentProduct].CV.DCV = Turbine; |
| 2642 | } // Go to next state |
| 2643 | else |
| 2644 | { |
| 2645 | Product[CurrentProduct].N_Turbines = Temp; // Error |
| 2646 | RestartState = 1; // Rerun state as first |
| 2647 | } |
| 2648 | } |
| 2649 | else |
| 2650 | { |
| 2651 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 2652 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 2653 | } |
| 2654 | } |
| 2655 | } |
| 2656 | |
| 2657 | // On Off Time Menu ****************************************************************************** |
| 2658 | |
| 2659 | void OnOffTime(int first) |
| 2660 | { |
| 2661 | int aCode; // Keycode |
| 2662 | static int FirstDigit; // First pressed digi flag |
| 2663 | int i; // Counter |
| 2664 | int result; // Entery done |
| 2665 | int CurrentProduct; // Product currently servicing |
| 2666 | char value[5]; |
| 2667 | static int MenuCalled; |
| 2668 | static int TimeOnFlag; |
| 2669 | |
| 2670 | result = 0; // Clear entery done flag |
| 2671 | CurrentProduct = ProductID; // Grab current product |
| 2672 | |
| 2673 | if (first) // If first pass |
| 2674 | { |
| 2675 | if (PreviousSetupState == SETUP_ONOFF_TIME) |
| 2676 | { |
| 2677 | TimeOnFlag = FALSE; |
| 2678 | RunTime = OffTime; |
| 2679 | strcpy(SetupTopLine, " TIME DELAY OFF "); |
| 2680 | } |
| 2681 | else |
| 2682 | { |
| 2683 | TimeOnFlag = TRUE; |
| 2684 | MenuCalled = PreviousSetupState; |
| 2685 | RunTime = OnTime; |
| 2686 | strcpy(SetupTopLine, " TIME DELAY ON "); |
| 2687 | } |
| 2688 | sprintf(SetupBottomLine, "PRODUCT %d %3u",ProductID+1,RunTime); // Set Top row text |
| 2689 | DisplayMsg(SetupTopLine, SetupBottomLine); // Write Display |
| 2690 | FirstDigit = 1; // Set first number flag |
| 2691 | printf("%s \n", SetupTopLine); // Print info to STDIO |
| 2692 | printf("%s \n", SetupBottomLine); // Print info to STFIO |
| 2693 | } |
| 2694 | else if (GetKeyEdgeFlag()) // If key pressed |
| 2695 | { |
| 2696 | aCode = GetKeyCode(); // Grab key |
| 2697 | if (aCode == DOWNPB || aCode == UPPB) // If numeric key |
| 2698 | { |
| 2699 | UpdateDigit(aCode, SetupBottomLine, 11, 16, 1.0, 0.0, 999.0, GetFastFlag()); |
| 2700 | FirstDigit = 0; // Clear flag |
| 2701 | } |
| 2702 | else if (aCode == ENTERPB) // If enter pb |
| 2703 | { |
| 2704 | strncpy(value, SetupBottomLine+11, 5); |
| 2705 | RunTime = (int)(atof(value)); |
| 2706 | result = 1; |
| 2707 | if (TimeOnFlag) |
| 2708 | RestartState = 1; |
| 2709 | else |
| 2710 | { |
| 2711 | SetupState = MenuCalled; |
| 2712 | MenuCalled = -1; |
| 2713 | } // Entery done |
| 2714 | } |
| 2715 | else if (aCode == CLEARPB) // If clear pb |
| 2716 | { |
| 2717 | RestartState = 1; |
| 2718 | } |
| 2719 | else if (aCode == SETUPPB) // If Setup pb |
| 2720 | { |
| 2721 | strncpy(value, SetupBottomLine+11, 5); |
| 2722 | RunTime = (int)(atof(value)); |
| 2723 | result = 1; // Entry done |
| 2724 | SetupState = MenuCalled; |
| 2725 | MenuCalled = -1; // Goto disable time entry |
| 2726 | } // Beep if invalid key |
| 2727 | |
| 2728 | if (result) // If got final value |
| 2729 | { |
| 2730 | if (RunTime <= 999 && RunTime >= 0) |
| 2731 | { |
| 2732 | if (TimeOnFlag) |
| 2733 | OnTime = RunTime; |
| 2734 | else |
| 2735 | OffTime = RunTime; |
| 2736 | } |
| 2737 | else |
| 2738 | { |
| 2739 | RestartState = 1; |
| 2740 | } |
| 2741 | } |
| 2742 | else |
| 2743 | { |
| 2744 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 2745 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 2746 | } |
| 2747 | } |
| 2748 | } |
| 2749 | |
| 2750 | // Reset Menu ************************************************************************ |
| 2751 | |
| 2752 | void Reset(int first) |
| 2753 | { |
| 2754 | int aCode; |
| 2755 | int i; |
| 2756 | |
| 2757 | if (first) |
| 2758 | { |
| 2759 | strcpy(SetupTopLine, " RESET CHANNEL ? "); |
| 2760 | strcpy(SetupBottomLine, " All "); |
| 2761 | DisplayMsg(SetupTopLine, SetupBottomLine); |
| 2762 | } |
| 2763 | else if (GetKeyEdgeFlag()) |
| 2764 | { |
| 2765 | aCode = GetKeyCode(); |
| 2766 | if (aCode == DOWNPB || aCode == UPPB) // If numeric key |
| 2767 | { |
| 2768 | if (atoi(SetupBottomLine)-1 < 0) |
| 2769 | { |
| 2770 | if (aCode == UPPB) |
| 2771 | strcpy(SetupBottomLine, " 1 "); |
| 2772 | else |
| 2773 | sprintf(SetupBottomLine, " %d ", Config.N_Turbines); |
| 2774 | } |
| 2775 | else |
| 2776 | UpdateDigit(aCode, SetupBottomLine, 7, 8, 1.0, 1.0, Config.N_Turbines, GetFastFlag()); // Clear flag |
| 2777 | } |
| 2778 | else if (aCode == ENTERPB) |
| 2779 | { |
| 2780 | aCode = atoi(SetupBottomLine)-1; |
| 2781 | if (aCode < 0) |
| 2782 | { |
| 2783 | for (i = 0 ; i < Config.N_Turbines ; i++) |
| 2784 | Channel[i].ResetPbFlag = 1; |
| 2785 | } |
| 2786 | else if (aCode < Config.N_Turbines) |
| 2787 | { |
| 2788 | if (Channel[aCode].State == 6 && Config.Sump.ShutDnFlag) |
| 2789 | { |
| 2790 | for (i = Channel[aCode].Prod->FirstTurbine ; |
| 2791 | i < Channel[aCode].Prod->FirstTurbine + Channel[aCode].Prod->N_Turbines ; |
| 2792 | i++) |
| 2793 | Channel[i].ResetPbFlag = 1; |
| 2794 | } |
| 2795 | Channel[aCode].ResetPbFlag = 1; |
| 2796 | } |
| 2797 | SetupDone = 1; |
| 2798 | } |
| 2799 | else if (aCode == SETUPPB) |
| 2800 | SetupDone = 1; |
| 2801 | |
| 2802 | DisplayMsg(SetupTopLine, SetupBottomLine); |
| 2803 | } |
| 2804 | } |
| 2805 | |
| 2806 | // OverRide Menu ************************************************************************ |
| 2807 | |
| 2808 | void SetupOverRide(int first) |
| 2809 | { |
| 2810 | int aCode; |
| 2811 | |
| 2812 | if (first) |
| 2813 | { |
| 2814 | strcpy(SetupTopLine, "OVERRIDE TOGGLE"); |
| 2815 | strcpy(SetupBottomLine, blankDisplay); |
| 2816 | DisplayMsg(SetupTopLine, SetupBottomLine); |
| 2817 | } |
| 2818 | else if (GetKeyEdgeFlag()) |
| 2819 | { |
| 2820 | aCode = GetKeyCode(); |
| 2821 | if (aCode == DOWNPB || aCode == UPPB) // If numeric key |
| 2822 | { |
| 2823 | UpdateDigit(aCode, SetupBottomLine, 8, 10, 1.0, 1.0, 8.0, GetFastFlag()); // Clear flag |
| 2824 | DisplayMsg(SetupTopLine, SetupBottomLine); |
| 2825 | } |
| 2826 | else if (aCode == ENTERPB) |
| 2827 | { |
| 2828 | aCode = atoi(SetupBottomLine)-1; |
| 2829 | if (aCode < Config.N_Turbines && aCode >= 0) |
| 2830 | Channel[aCode].OverRideFlag = !Channel[aCode].OverRideFlag; |
| 2831 | SetupDone = 1; |
| 2832 | } |
| 2833 | else if (aCode == SETUPPB) |
| 2834 | SetupDone = 1; |
| 2835 | } |
| 2836 | } |
| 2837 | |
| 2838 | // View Menu ************************************************************************ |
| 2839 | |
| 2840 | void View(int first) |
| 2841 | { |
| 2842 | int aCode; |
| 2843 | |
| 2844 | if (first) |
| 2845 | { |
| 2846 | strcpy(SetupTopLine, " VIEW CHANNEL? "); |
| 2847 | strcpy(SetupBottomLine, blankDisplay); |
| 2848 | DisplayMsg(SetupTopLine, SetupBottomLine); |
| 2849 | } |
| 2850 | else if (GetKeyEdgeFlag()) |
| 2851 | { |
| 2852 | aCode = GetKeyCode(); |
| 2853 | if (aCode == DOWNPB || aCode == UPPB) // If numeric key |
| 2854 | { |
| 2855 | UpdateDigit(aCode, SetupBottomLine, 8, 10, 1.0, 1.0, 8.0, GetFastFlag()); // Clear flag |
| 2856 | DisplayMsg(SetupTopLine, SetupBottomLine); |
| 2857 | } |
| 2858 | else if (aCode == ENTERPB) |
| 2859 | { |
| 2860 | aCode = atoi(SetupBottomLine)-1; |
| 2861 | if (aCode == Config.ViewCnl) |
| 2862 | Config.ViewCnl = -1; |
| 2863 | else if (aCode < Config.N_Turbines && aCode >= 0) |
| 2864 | Config.ViewCnl = aCode; |
| 2865 | SetupDone = 1; |
| 2866 | } |
| 2867 | else if (aCode == SETUPPB) |
| 2868 | SetupDone = 1; |
| 2869 | else if (aCode == CLEARPB) |
| 2870 | { |
| 2871 | Config.ViewCnl = -1; |
| 2872 | SetupDone = 1; |
| 2873 | } |
| 2874 | } |
| 2875 | } |
| 2876 | |
| 2877 | // Precision Test Product Menu ************************************************* |
| 2878 | void PresTestProd(int first) |
| 2879 | { |
| 2880 | int aCode; |
| 2881 | |
| 2882 | if (first) |
| 2883 | { |
| 2884 | strcpy(SetupTopLine, " CHOOSE PRODUCT "); |
| 2885 | strcpy(SetupBottomLine, " 1 "); |
| 2886 | ProductID = 0; |
| 2887 | DisplayMsg(SetupTopLine, SetupBottomLine); |
| 2888 | } |
| 2889 | else if (GetKeyEdgeFlag()) |
| 2890 | { |
| 2891 | aCode = GetKeyCode(); |
| 2892 | if (aCode == DOWNPB || aCode == UPPB) // If numeric key |
| 2893 | { |
| 2894 | UpdateDigit(aCode, SetupBottomLine, 7, 8, 1.0, 1.0, (float)Config.N_Products, GetFastFlag()); // Clear flag |
| 2895 | DisplayMsg(SetupTopLine, SetupBottomLine); |
| 2896 | } |
| 2897 | else if (aCode == ENTERPB) |
| 2898 | { |
| 2899 | aCode = atoi(SetupBottomLine); |
| 2900 | ProductID = aCode - 1; |
| 2901 | SetupState = SETUP_PRECISION_TEST; |
| 2902 | } |
| 2903 | else if (aCode == SETUPPB) |
| 2904 | SetupDone = 1; |
| 2905 | else if (aCode == CLEARPB) |
| 2906 | { |
| 2907 | SetupDone = 1; |
| 2908 | } |
| 2909 | } |
| 2910 | } |
| 2911 | |
| 2912 | // Precision Test Menu ********************************************************* |
| 2913 | void PrecisionTestMenu(int first) { |
| 2914 | int aCode; |
| 2915 | int leadTurbine; |
| 2916 | int status; |
| 2917 | |
| 2918 | if (first) { |
| 2919 | leadTurbine = Product[ProductID].LeadTurbine; |
| 2920 | status = Channel[leadTurbine].PrecTest.Status; |
| 2921 | if (status == PT_INACTIVE) { |
| 2922 | strcpy(SetupTopLine, " PRECISION TEST "); |
| 2923 | sprintf(SetupBottomLine, "0.2 PRESS ENTER"); |
| 2924 | Turbine = TEST_PNT2; |
| 2925 | RunTime = 0; |
| 2926 | DisplayMsg(SetupTopLine, SetupBottomLine); |
| 2927 | printf("%s \n", SetupTopLine); |
| 2928 | printf("%s \n", SetupBottomLine); |
| 2929 | } |
| 2930 | else { |
| 2931 | if (Channel[leadTurbine].PrecTest.Type == TEST_PNT1) |
| 2932 | strcpy(SetupTopLine, ".1 TEST RUNNING "); |
| 2933 | else |
| 2934 | strcpy(SetupTopLine, ".2 TEST RUNNING "); |
| 2935 | sprintf(SetupBottomLine, " CLEAR TO ABORT "); |
| 2936 | RunTime = MS_TIMER; |
| 2937 | printf("%s \n", SetupTopLine); |
| 2938 | printf("%s \n", SetupBottomLine); |
| 2939 | DisplayMsg(SetupTopLine, SetupBottomLine); |
| 2940 | } |
| 2941 | } |
| 2942 | else if (GetKeyEdgeFlag()) { |
| 2943 | aCode = GetKeyCode(); |
| 2944 | leadTurbine = Product[ProductID].LeadTurbine; |
| 2945 | status = Channel[leadTurbine].PrecTest.Status; |
| 2946 | if (aCode == ENTERPB && status == PT_INACTIVE) { |
| 2947 | Channel[leadTurbine].PrecTest.Status = PT_PENDING; |
| 2948 | Channel[leadTurbine].PrecTest.Type = Turbine; |
| 2949 | SetupDone = 1; |
| 2950 | } |
| 2951 | else if (aCode == CLEARPB && status != PT_INACTIVE) { |
| 2952 | if (Channel[leadTurbine].PrecTest.Type == 1) |
| 2953 | strcpy(SetupTopLine, ".1 TEST ABORTED "); |
| 2954 | else |
| 2955 | strcpy(SetupTopLine, ".2 TEST ABORTED "); |
| 2956 | sprintf(SetupBottomLine, blankDisplay); |
| 2957 | RunTime = MS_TIMER; |
| 2958 | TestStop(&Channel[leadTurbine].PrecTest); |
| 2959 | } |
| 2960 | else if (aCode == UPPB && status == PT_INACTIVE) { |
| 2961 | Turbine = TEST_PNT1; |
| 2962 | sprintf(SetupBottomLine, "0.1 PRESS ENTER"); // Beep if first product |
| 2963 | } |
| 2964 | else if (aCode == DOWNPB && status == PT_INACTIVE) { |
| 2965 | Turbine = TEST_PNT2; |
| 2966 | sprintf(SetupBottomLine, "0.2 PRESS ENTER"); // Beep if last product |
| 2967 | } |
| 2968 | else if (aCode == SETUPPB) { |
| 2969 | SetupDone = 1; |
| 2970 | } |
| 2971 | RunTime = MS_TIMER; |
| 2972 | printf("%s \n", SetupBottomLine); |
| 2973 | DisplayMsg(SetupTopLine, SetupBottomLine); |
| 2974 | } |
| 2975 | else if (RunTime > 0 && RunTime + DSP_HOLD * 4 < MS_TIMER) { |
| 2976 | SetupDone = 1; |
| 2977 | } |
| 2978 | } |
| 2979 | |
| 2980 | // Print Menu ****************************************************************** |
| 2981 | |
| 2982 | const char printName[][] = { |
| 2983 | "TEST LOG ", |
| 2984 | "ALARM LOG ", |
| 2985 | "SYSTEM LOG ", |
| 2986 | "SITE CONFIG ", |
| 2987 | "3 GPH PASS LOG " |
| 2988 | }; |
| 2989 | |
| 2990 | void Print(int first) |
| 2991 | { |
| 2992 | #if PRINTER_ON |
| 2993 | int aCode; // Keycode |
| 2994 | // Init no change |
| 2995 | if (first) // If first pass |
| 2996 | { |
| 2997 | Turbine = 0; |
| 2998 | RunTime = MS_TIMER; |
| 2999 | strcpy(SetupTopLine, " PRINT REPORT "); |
| 3000 | sprintf(SetupBottomLine, printName[Turbine]); |
| 3001 | DisplayMsg(SetupTopLine, SetupBottomLine); |
| 3002 | printf("%s \n", SetupTopLine); |
| 3003 | printf("%s \n", SetupBottomLine); |
| 3004 | } |
| 3005 | else if (GetKeyEdgeFlag()) // If key pressed |
| 3006 | { |
| 3007 | aCode = GetKeyCode(); // Grab key |
| 3008 | if (aCode == ENTERPB) // If numeric key |
| 3009 | { |
| 3010 | if (Turbine == 0) PrintTestLog(); |
| 3011 | else if (Turbine == 1) PrintAlarmLog(); |
| 3012 | else if (Turbine == 2) PrintSystemLog(); |
| 3013 | else if (Turbine == 3) PrintConfig(); |
| 3014 | else if (Turbine == 4) PrintTest3P(); |
| 3015 | SetupDone = 1; |
| 3016 | } |
| 3017 | else if (aCode == CLEARPB) // If clear pb |
| 3018 | { |
| 3019 | SetupDone = 1; |
| 3020 | } |
| 3021 | else if (aCode == SETUPPB) // If Setup pb |
| 3022 | { // Setup channels based on config |
| 3023 | SetupDone = 1; // Mark setup done |
| 3024 | } |
| 3025 | else if (aCode == UPPB) // If up pb |
| 3026 | { |
| 3027 | Turbine--; |
| 3028 | if (Turbine < 0) Turbine = 4; |
| 3029 | sprintf(SetupBottomLine, printName[Turbine]); // Beep if first product |
| 3030 | } |
| 3031 | else if (aCode == DOWNPB) // If down pb |
| 3032 | { |
| 3033 | Turbine++; |
| 3034 | if (Turbine > 4) Turbine = 0; |
| 3035 | sprintf(SetupBottomLine, printName[Turbine]); // Beep if last product |
| 3036 | } |
| 3037 | RunTime = MS_TIMER; |
| 3038 | printf("%s \n", SetupBottomLine); // Print data to STDIO |
| 3039 | DisplayMsg(SetupTopLine, SetupBottomLine); // Update dislpay |
| 3040 | |
| 3041 | } |
| 3042 | else if (RunTime > 0 && RunTime + DSP_HOLD * 4 < MS_TIMER) |
| 3043 | { |
| 3044 | SetupDone = 1; |
| 3045 | } |
| 3046 | #endif |
| 3047 | } |
| 3048 | |
| 3049 | |
| 3050 | // Test channel config *************************************************************** |
| 3051 | |
| 3052 | int TestSetup() |
| 3053 | { |
| 3054 | int result; |
| 3055 | int i; |
| 3056 | int accume; |
| 3057 | |
| 3058 | result = 0; |
| 3059 | accume = 0; |
| 3060 | |
| 3061 | for ( i = 0 ; i < N_PROD ; i++) |
| 3062 | accume += Product[i].N_Turbines; |
| 3063 | |
| 3064 | if (accume <= N_ISM) |
| 3065 | result = 1; |
| 3066 | |
| 3067 | return result; |
| 3068 | } |
| 3069 | |
| 3070 | |
| 3071 | /*** BeginHeader */ |
| 3072 | |
| 3073 | #endif |
| 3074 | |
| 3075 | /*** EndHeader */ |