using System; using Microsoft.SPOT; namespace SimplePowerUp { public class ABRetractSlow : StateBase { public ABRetractSlow(string name) { stateName.Clear(); stateName.Append(name); ECTimeout = 5 * 60 * 1000; //5 min } private enum Action : int { setBellows = 1, lastAction, size = lastAction } private static Action currentAction; public override int doStateEntryActions() { basicStateEntry(); sbTemp.Clear(); sbTemp.Append("Retractring bellows slow to pressure = "); sbTemp.Append(missionConfig.ABPressureThreshold.ToString()); sbTemp.Append(" at "); sbTemp.Append(missionConfig.ABRetractJV.ToString()); sbTemp.Append(" cps"); EngrLogger.writeToColumns(sbTemp); ABRetractThresholdCount = 0; currentAction = (Action)1; return (1); } public override int doStateActions() { switch (currentAction) { case (Action.setBellows): nextAction = retractBellowsSlow(); break; case (Action.lastAction): //do nothing here break; default: break; } currentAction = (Action)checkReturn(nextAction, (int)currentAction); return (1); } public override CPFStates checkEvents() { //TODO P1 use the same exceedABRetractPressureThreshold method that retractFast uses //Increment threshold counter on successive tests otherwise reset counter to 0 if (ctd1.SBE41LPF.RawPressure>= missionConfig.ABPressureThreshold) ABRetractThresholdCount = ABRetractThresholdCount + 1; else ABRetractThresholdCount = 0; //if 3 sucessive counts below threshold have been recorded, transistion to descend if (ABRetractThresholdCount >= 3) { return (CPFStates.descend); } //otherwise stay else { return (CPFStates.ABRetractSlow); } } public override int doExitActions(bool timedOut) { if (timedOut) { basicStateExit(true); //reset privates ABRetractThresholdCount = 0; } else { basicStateExit(false); ABRetractThresholdCount = 0; } return (1); } public override CPFStates doTimeoutAction() { return (CPFStates.descend); } private int retractBellowsSlow() { if (!buoyancyEngine.retracting) { buoyancyEngine.retractBellows(missionConfig.ABRetractJV); } return ((int)Action.setBellows); } } }