#include #include #include #include #include #include static long subBackingPumpStateInit(struct subRecord *psub) { return 0; } static long subBackingPumpState(struct subRecord *psub) { /* Pump State 0 : Error (Check Pump) 1 : Off (Shutdown) 2 : Off (Idle) 3 : Running */ int cart_mode, pump_run, state = 0; cart_mode = (int) psub->a; /* Cart Mode */ pump_run = (int) psub->b; /* Pump Running */ if(cart_mode == 0) { state = 1; } else if(cart_mode == 1) { state = 2; } else if(pump_run == 1) { state = 3; } else { state = 0; } psub->val = state; return 0; } static long subForeValveStateInit(struct subRecord *psub) { return 0; } static long subForeValveState(struct subRecord *psub) { /* Valve State 0 : Error (Check Valve) 1 : Open 2 : Closed 3 : Closed (Shutdown) 4 : Closed (Idle) 5 : Closed (Interlock) 6 : Moving 7 : Inconsistent */ int cart_mode, valve_inltk, valve_pos, valve_cmd, state = 0; cart_mode = (int) psub->a; /* Cart Mode */ valve_inltk = (int) psub->b; /* Valve Interlock Sum */ valve_pos = (int) psub->c; /* Valve Position */ valve_cmd = (int) psub->d; /* PLC valve command */ switch (valve_pos) { case 0 : /* Valve Open */ if((cart_mode == 2 || cart_mode == 3) && valve_inltk && valve_cmd) /* Cart in Pumpdown or Running and Interlocks Ok */ { state = 1; } else { state = 0; } break; case 1 : /* Valve Closed */ if(!cart_mode) /* Cart in Shutdown */ { state = 3; } else if(cart_mode == 1) { state = 4; } else if(!valve_inltk) { state = 5; } else if(!valve_cmd) { state = 2; } else { state = 0; } break; case 2 : /* Valve Moving */ state = 6; break; case 3 : /* Valve Inconsistent */ state = 7; break; default : state = 0; } psub->val = state; return 0; } static long subTurboPumpStateInit(struct subRecord *psub) { return 0; } static long subTurboPumpState(struct subRecord *psub) { /* Pump State 0 : Error (Check Pump) 1 : Off (Shutdown) 2 : Off (Idle) 3 : Off (Roughing) 4 : Run-Up Test 5 : Ramping 6 : Running */ int cart_mode, pump_run, pump_test, back_pump, state = 0; double pump_speed; cart_mode = (int) psub->a; /* Cart Mode */ pump_run = (int) psub->b; /* Pump Running */ pump_speed = psub->c; /* Pump Speed */ pump_test = (int) psub->d; /* Pump Run-up Complete */ back_pump = (int) psub->e; /* Backing Pump Running */ switch (pump_run) { case 0 : /* Pump Off */ if(cart_mode == 0) { state = 1; } else if(cart_mode == 1) { state = 2; } else if(back_pump) { state = 3; } else { state = 0; } break; case 1 : /* Pump On */ if(!pump_test) { state = 4; } else if(pump_test && pump_speed < 900) { state = 5; } else if(pump_test && pump_speed > 900) { state = 6; } else { state = 0; } break; default : state = 0; } psub->val = state; return 0; } static long subHiVacValveStateInit(struct subRecord *psub) { return 0; } static long subHiVacValveState(struct subRecord *psub) { /* Valve State 0 : Error (Check Valve) 1 : Open 2 : Open (HiLoad Bypass) 3 : Closed 4 : Closed (Shutdown) 5 : Closed (Idle) 6 : Closed (Interlock) 7 : Closed (HiLoad Wait) 8 : Moving 9 : Inconsistent */ int cart_mode, valve_intlk, valve_pos, valve_cmd, state = 0; double hiload_byp, hiload_wait; cart_mode = (int) psub->a; /* Cart Mode */ valve_intlk = (int) psub->b; /* Valve Interlock Sum */ valve_pos = (int) psub->c; /* Valve Position */ valve_cmd = (int) psub->d; /* PLC valve command */ hiload_byp = psub->e; /* HiLoad Bypass Timer */ hiload_wait = psub->f; /* HiLoad Wait Timer */ switch (valve_pos) { case 0 : /* Valve Open */ if((cart_mode == 2 || cart_mode == 3) && valve_cmd) /* Cart in Pumpdown or Running and PLC issuing open command */ { if(hiload_byp > 0) /* Valve HiLoad Bypass */ { state = 2; } else if(valve_intlk) /* Valve Interlocks Ok */ { state = 1; } else { state = 0; } } else { state = 0; } break; case 1 : /* Valve Closed */ if(!cart_mode) /* Cart in Shutdown */ { state = 4; } else if(cart_mode == 1) /* Cart in Idle */ { state = 5; } else if(!valve_intlk) /* Valve interlock faulted */ { state = 6; } else if(hiload_wait > 0) /* Valve in HiLoad Wait */ { state = 7; } else if (!valve_cmd) /* PLC Valve Closed */ { state = 3; } else { state = 0; } break; case 2 : /* Valve Moving */ state = 8; break; case 3 : /* Valve Inconsistent */ state = 9; break; default : state = 0; } psub->val = state; return 0; } /* Register these symbols for use by IOC code: */ epicsRegisterFunction(subBackingPumpStateInit); epicsRegisterFunction(subBackingPumpState); epicsRegisterFunction(subForeValveStateInit); epicsRegisterFunction(subForeValveState); epicsRegisterFunction(subTurboPumpStateInit); epicsRegisterFunction(subTurboPumpState); epicsRegisterFunction(subHiVacValveStateInit); epicsRegisterFunction(subHiVacValveState);