#define NO_CTD using System; using Microsoft.VisualStudio.TestTools.UnitTesting; using CPF; using Microsoft.SPOT; using CPF.Profile_States; using CPF.Surface_States; using HWModules; using SensorModules; using SWModules; namespace CPFUnitTests { [TestClass] public class UnitTestFileTransferWithStateMachine { StateBase[] cpfState = new StateBase[(int)CPFStates.cpfStatesLength]; private static CPFStates currentState; public static CPFStates CurrentState { get { return currentState; } protected set { currentState = value; } } public static CPFStates PastState { get; protected set; } public static CPFStates NextState { get; protected set; } /// /// /// [TestMethod] public void TestRUDICSwithinThread() { Init(); var mq = MessageQueue.Instance; // Now run the state machine but jump to surface ops, where we are going to make changes // for using our rudics thread. CurrentState = CPFStates.surfaceOps; NextState = CurrentState; PastState = CPFStates.SMNotRunning; do { if (SV.DoStateEntry) cpfState[(int)currentState].doStateEntryActions(); mq.processQMaxLimit(); cpfState[(int)currentState].doStateActions(); NextState = cpfState[(int)currentState].checkEvents(); if (NextState != CurrentState) cpfState[(int)CurrentState].doExitActions(false); } while (NextState == CurrentState); } static bool runonce = false; private IridiumModem1 iModem1; private CTD1 ctd1; private GPS1 gps; private Optode1 optode; private MSC1 msc; private BTConsole btConsole; public void Init() { if (!runonce) { runonce = true; Debug.Print("Initializing Iridium Modem"); // Start by mimicing the main thread of the CPF Debug.Print("Program Started"); #region STATES cpfState[(int)CPFStates.SMNotRunning] = new InitMission("SM Not Running"); cpfState[(int)CPFStates.initMission] = new InitMission("Init Mission"); cpfState[(int)CPFStates.initProfile] = new InitProfile("Init Profile"); cpfState[(int)CPFStates.descend] = new Descend("Descend"); cpfState[(int)CPFStates.ascend] = new Ascend("Ascend"); cpfState[(int)CPFStates.surfaceOpsSetBellows] = new SurfaceOpsSetBellows("Surface Ops Set Bellows"); cpfState[(int)CPFStates.surfaceOps] = new SurfaceOps("Surface Ops"); cpfState[(int)CPFStates.preMissionDelay] = new PreMissionDelay("Pre-Mission Delay"); cpfState[(int)CPFStates.dumpCPData] = new DumpCPData("Dump CP Data"); cpfState[(int)CPFStates.ABDecBuocyFast] = new ABDecreaseBuoyancyFast("Dec Buocy Fast"); cpfState[(int)CPFStates.ABDecBuocySlow] = new ABDecreaseBuoyancySlow("Dec Buocy Slow"); cpfState[(int)CPFStates.park] = new Park("Park"); cpfState[(int)CPFStates.anchor] = new Anchor("Anchor", new TimeSpan(0, 10, 0)); cpfState[(int)CPFStates.deAnchor] = new Deanchor("DeAnchor"); cpfState[(int)CPFStates.startCP] = new StartCPMode("Start CP Mode"); cpfState[(int)CPFStates.recovery] = new Recovery("RecoveryMode"); cpfState[(int)CPFStates.exit] = new Exit("Exit"); CurrentState = CPFStates.SMNotRunning; NextState = CurrentState; PastState = (CPFStates)0; #endregion btConsole = BTConsole.Instance; btConsole.init(); btConsole.powerUp(); iModem1 = IridiumModem1.Instance; iModem1.init(); ctd1 = CTD1.Instance; ctd1.powerUp(); ctd1.init(); gps = GPS1.Instance; gps.powerUp(); optode = Optode1.Instance; optode.init(); optode.powerUp(); msc = MSC1.Instance; msc.powerUp(); //Moved one line of code from EVK7GPS.init() into EVK7GPS constructor //Mission.createMission(Mission.Missions.mission150mNoHold); } } } }