public bool Send(CommandSet cmdSet) { bool success = false; if (cmdSet.CanSend) { int rspDataCount = m_RspReader.Capacity; if (m_Connection.SendCSAFECommand(cmdSet.Buffer, cmdSet.Size, m_RspReader.Buffer, ref rspDataCount)) { // Reset the reader to the correct length m_RspReader.Reset(rspDataCount); // Read the response success = cmdSet.Read(m_RspReader); } } else { Debug.WriteLine("[Commander.Send] Nothing to send"); } return success; }
private void SetupCommandSets() { // Commands m_CadenceCommand = new CadenceCommand(); m_CaloriesCommand = new CaloriesCommand(); m_DistanceCommand = new DistanceCommand(); m_DragFactorCommand = new DragFactorCommand(); m_HeartRateCommand = new HeartRateCommand(); m_PaceCommand = new PaceCommand(); m_PowerCommand = new PowerCommand(); m_StrokeStateCommand = new StrokeStateCommand(); m_TimeCommand = new TimeCommand(); m_WorkDistanceCommand = new WorkDistanceCommand(); m_WorkoutStateCommand = new WorkoutStateCommand(); m_WorkoutTypeCommand = new WorkoutTypeCommand(); m_WorkTimeCommand = new WorkTimeCommand(); // Workout command sets m_100HzCommands = new CommandSet(); m_100HzCommands.Add(m_StrokeStateCommand); m_100HzCommands.Prepare(); m_10HzCommands = new CommandSet(); m_10HzCommands.Add(m_DistanceCommand); m_10HzCommands.Add(m_TimeCommand); m_10HzCommands.Add(m_WorkDistanceCommand); m_10HzCommands.Add(m_WorkTimeCommand); m_10HzCommands.Prepare(); m_2HzCommands = new CommandSet(); m_2HzCommands.Add(m_CadenceCommand); m_2HzCommands.Add(m_CaloriesCommand); m_2HzCommands.Add(m_DragFactorCommand); m_2HzCommands.Add(m_PaceCommand); m_2HzCommands.Add(m_PowerCommand); m_2HzCommands.Add(m_WorkoutStateCommand); m_2HzCommands.Prepare(); m_1HzCommands = new CommandSet(); m_1HzCommands.Add(m_HeartRateCommand); m_1HzCommands.Prepare(); // Idle command sets m_Idle2HzCommands = new CommandSet(); m_Idle2HzCommands.Add(m_WorkoutTypeCommand); m_Idle2HzCommands.Add(m_WorkoutStateCommand); m_Idle2HzCommands.Prepare(); m_Idle1HzCommands = m_1HzCommands; }