Beispiel #1
0
    public void LoadWorkout()
    {
        Debug.Log("Loading a Workout");

        // CREATE A WORKOUT
        if (_PM.C2_SetHorizontalDistanceGoal(100))
        {
            Debug.Log("Added Command C2_SetHorizontalDistanceGoal");
        }
        if (_PM.C2_SetSplitDuration(C2TimeDistance.DistanceMeters, 100))
        {
            Debug.Log("Added Command C2_SetSplitDuration");
        }
        if (_PM.C2_SetPowerGoal(100))
        {
            Debug.Log("Added Command C2_SetPowerGoal");
        }
        if (_PM.C2_SetProgram(0))
        {
            Debug.Log("Added Command C2_SetProgram");
        }
        if (_PM.CSAFE_CtrlCmds.cmdGoIdle())
        {
            Debug.Log("Added Command cmdGoIdle");
        }
        _PM.ExecuteCommands(0);
        Debug.Log(_PM.Session.Devices[0].ConfigData.ToString());
    }
Beispiel #2
0
        public void Init()
        {
            //int cntStreams = _PM.OpenStream(0);
            //Console.WriteLine("Opened {0} Streams", cntStreams);

            // RESET EVERYTHING
            //_PM.C2_EnvironmentReset(0);
            //Console.WriteLine(_PM.Session.Devices[0].ConfigData.ToString());

            // GET MACHINE STATUS
            if (_PM.C2_GetMachineStatus(0))
            {
                Console.WriteLine("Executed Command C2_GetMachineStatus");
            }
            Console.WriteLine(_PM.Session.Devices[0].ConfigData.ToString());

            // CREATE A WORKOUT
            if (_PM.C2_SetHorizontalDistanceGoal(100))
            {
                Console.WriteLine("Added Command C2_SetHorizontalDistanceGoal");
            }
            if (_PM.C2_SetSplitDuration(C2TimeDistance.DistanceMeters, 100))
            {
                Console.WriteLine("Added Command C2_SetSplitDuration");
            }
            if (_PM.C2_SetPowerGoal(100))
            {
                Console.WriteLine("Added Command C2_SetPowerGoal");
            }
            if (_PM.C2_SetProgram(0))
            {
                Console.WriteLine("Added Command C2_SetProgram");
            }
            if (_PM.CSAFE_CtrlCmds.cmdGoIdle())
            {
                Console.WriteLine("Added Command cmdGoIdle");
            }
            _PM.ExecuteCommands(0);
            Console.WriteLine(_PM.Session.Devices[0].ConfigData.ToString());

            // START A WORKOUT
            if (_PM.CSAFE_CtrlCmds.cmdGoInUse())
            {
                Console.WriteLine("Added Command cmdGoInUse");
            }
            _PM.ExecuteCommands(0);
            Console.WriteLine(_PM.Session.Devices[0].ConfigData.ToString());

            c2distances = new System.IO.StreamWriter(@"C:\temp\c2dist.csv", false);
            c2distances.WriteLine("Target, Actual, _lastZ, _VelocityZ, tDeltaT, tDeltaD, updatedV");

            ThreadStart threadUnityFrameStart = new ThreadStart(UnityFrame);

            Console.WriteLine("In Main: Creating the Unity thread");
            Thread threadUnity = new Thread(threadUnityFrameStart);


            ThreadStart threadPollingStart = new ThreadStart(PollWorkoutData);

            Console.WriteLine("In Main: Creating the Child thread");
            Thread threadPolling = new Thread(threadPollingStart);


            SandboxInterrupted = false;

            threadUnity.Start();
            threadPolling.Start();
            Console.WriteLine("Press Any Key to Quit");
            Console.ReadKey();
            SandboxInterrupted = true;
            Console.ReadKey();
            Console.WriteLine("Sandbox Complete.");
        }
Beispiel #3
0
        public bool HandleClientRequest(byte[] ClientBytes, out byte[] ReplyMsg)
        {
            Console.WriteLine("[C2ServerHandler] Processing Data");

            Console.WriteLine(DumpHex(ClientBytes));



            switch ((C2ServerMessage)ClientBytes[0])
            {
            case C2ServerMessage.GET_CONFIG_DATA:
                Console.WriteLine("[C2ServerHandler] Returning ConfigData Package");
                ReplyMsg = SerializedConfigData();
                return(true);

            case C2ServerMessage.GET_MACHINE_STATUS:
                Console.WriteLine("[C2ServerHandler] Getting Machine Status");
                if (_PM.C2_GetMachineStatus(0))
                {
                    Console.WriteLine("Executed Command C2_GetMachineStatus");
                }
                Console.WriteLine(_PM.Session.Devices[0].ConfigData.ToString());
                ReplyMsg = SerializedConfigData();
                return(true);


            case C2ServerMessage.GET_WORKOUT_DATA:
                //Console.WriteLine("[C2ServerHandler] Getting Machine Status");
                if (_PM.C2_GetMonitorData(0))
                {
                    //Console.WriteLine("Executed Command C2_GetMonitorData");
                    Console.WriteLine(_PM.Session.Devices[0].ConfigData.OneLine());
                    ReplyMsg = SerializedConfigData();
                    return(true);
                }
                ReplyMsg = new byte[1] {
                    0x00
                };
                return(false);


            case C2ServerMessage.LOAD_DISTANCE_WORKOUT:

                Console.WriteLine("[C2ServerHandler] Loading Distance Workout");
                if (_PM.C2_SetHorizontalDistanceGoal(100))
                {
                    Console.WriteLine("Added Command C2_SetHorizontalDistanceGoal");
                }
                if (_PM.C2_SetSplitDuration(C2TimeDistance.DistanceMeters, 100))
                {
                    Console.WriteLine("Added Command C2_SetSplitDuration");
                }
                if (_PM.C2_SetPowerGoal(100))
                {
                    Console.WriteLine("Added Command C2_SetPowerGoal");
                }
                if (_PM.C2_SetProgram(0))
                {
                    Console.WriteLine("Added Command C2_SetProgram");
                }
                if (_PM.CSAFE_CtrlCmds.cmdGoIdle())
                {
                    Console.WriteLine("Added Command cmdGoIdle");
                }
                _PM.ExecuteCommands(0);

                Console.WriteLine(_PM.Session.Devices[0].ConfigData.ToString());
                ReplyMsg = SerializedConfigData();
                return(true);

            case C2ServerMessage.START_WORKOUT:
                Console.WriteLine("[C2ServerHandler] Starting Workout");
                if (_PM.CSAFE_CtrlCmds.cmdGoInUse())
                {
                    Console.WriteLine("Added Command cmdGoInUse");
                }
                _PM.ExecuteCommands(0);
                Console.WriteLine(_PM.Session.Devices[0].ConfigData.ToString());
                ReplyMsg = SerializedConfigData();
                return(true);

            default:
                ReplyMsg = new byte[1] {
                    0x00
                };
                return(false);
            }
        }