コード例 #1
0
 private void PollWorkoutData()
 {
     Console.WriteLine("Polling Workout Data");
     Console.WriteLine(_PM.Session.Devices[0].ConfigData.Data.SlaveState);
     while (!SandboxInterrupted && (_PM.Session.Devices[0].ConfigData.Data.SlaveState == MachineState.InUse))
     {
         _PM.C2_GetMonitorData(0);
         //Console.WriteLine(_PM.C2_Data(0).OneLine());
         _WorkoutDistanceMeters = _PM.Session.Devices[0].ConfigData.Data.WorkoutDistanceMeters;
         Thread.Sleep(50);
     }
     Console.WriteLine("Polling Done");
 }
コード例 #2
0
ファイル: C2ServerHandler.cs プロジェクト: RandyF/Concept2api
        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);
            }
        }
コード例 #3
0
 void PollMonitorData()
 {
     _PM.C2_GetMonitorData(0);
     _PollCount++;
 }