int main(void) { int errorCode = 0; unsigned char state = STOP; unsigned char snapshot = 0x00; errorCode = initIOPorts(); errorCode = initAC(); switchMotor(STOP); selectInitialState(&state); FOREVER { snapshotOfInputs(&snapshot); if(snapshot & S1) { //Automatikbetrieb switch(state) { case BOTTOM: switchMotor(STOP); if(!(snapshot & BIT_ACO)) state = UP; break; case TOP: switchMotor(STOP); if(snapshot & BIT_ACO) state = DOWN; break; case UP: switchMotor(UP); if(!(snapshot & B1)) state = TOP; break; case DOWN: switchMotor(DOWN); if(!(snapshot & B2)) state = BOTTOM; break; case STOP: if(!(snapshot & BIT_ACO)) state = UP; else state = DOWN; break; } } else { //Manueller Betrieb switch(state) { case BOTTOM: switchMotor(STOP); if(!(snapshot & S2)) state = UP; break; case TOP: switchMotor(STOP); if(!(snapshot & S3)) state = DOWN; break; case UP: switchMotor(UP); if(!(snapshot & B1)) state = TOP; else if(snapshot & S2) state = STOP; break; case DOWN: switchMotor(DOWN); if(!(snapshot & B2)) state = BOTTOM; else if(snapshot & S3) state = STOP; break; case STOP: switchMotor(STOP); if(!(snapshot & S2)) state = UP; else if(!(snapshot & S3)) state = DOWN; break; } } } return 0; }
void capacitor::initHB (void) { initAC (); }
void strafo::initTR (void) { initAC (); }