#define NO_CTD using System; using System.IO; using Microsoft.VisualStudio.TestTools.UnitTesting; using CPF; using System.Text; using Microsoft.SPOT; using System.Threading; using CPF.Profile_States; using CPF.Surface_States; using HWModules; 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(); // 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(); 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; 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 iModem1.init(); //TODO P1 Probably needs to change to BuoyancyEngine.init //ElmoWhistle.init(); //TODO P1 SBE41CTD has been refactored as a singleton and this needs to change somehow - GM 2017Sep05 //SBE41CTD.init(); //Optode.init(); //EVK7GPS.init(); Moved one line of code from EVK7GPS.init() into EVK7GPS constructor Mission.createMission(Mission.Missions.mission150mNoHold); } } } }