public void ShutdownRobotConnection() { if (m_robot != null) { if (SpheroConnected) { try { if (!AccelerometerFiltered.close()) { SpheroName = "ERROR: Consult debug."; Debug.WriteLine("Unable to close stream,/n" + "please close application and manually delete file://" + AccelerometerFiltered.filePath); } if (!GyrometerFiltered.close()) { SpheroName = "ERROR: Consult debug."; Debug.WriteLine("Unable to close stream,/n" + "please close application and manually delete file://" + GyrometerFiltered.filePath); } m_robot.SensorControl.StopAll(); m_robot.SensorControl.AccelerometerUpdatedEvent -= OnAccelerometerUpdated; m_robot.SensorControl.GyrometerUpdatedEvent -= OnGyrometerUpdated; m_robot.Sleep(); m_robot.Disconnect(); Debug.WriteLine("Sphero Disconnected"); } catch (Exception) { throw; } } m_robot = null; } SpheroConnected = false; InitializeSensorReading.IsEnabled = false; SpheroName = kNoSpheroConnected; RobotProvider provider = RobotProvider.GetSharedProvider(); provider.DiscoveredRobotEvent -= OnRobotDiscovered; provider.NoRobotsEvent -= OnNoRobotsEvent; provider.ConnectedRobotEvent -= OnRobotConnected; }
//Завершаем работу с роботом private void ShutdownRobotConnection() { if (m_robot != null) { m_robot.SensorControl.StopAll(); m_robot.Sleep(); m_robot.Disconnect(); ConnectionToggle.OffContent = "Disconnected"; SpheroName.Text = c_noSpheroConnected; m_robot.SensorControl.AccelerometerUpdatedEvent -= OnAccelerometerUpdated; RobotProvider provider = RobotProvider.GetSharedProvider(); provider.DiscoveredRobotEvent -= OnRobotDiscovered; provider.NoRobotsEvent -= OnNoRobotsEvent; provider.ConnectedRobotEvent -= OnRobotConnected; } }
//Завершаем работу с роботом private void ShutdownRobotConnection() { if (m_robot != null && m_robot.ConnectionState == ConnectionState.Connected) { m_robot.SensorControl.StopAll(); m_robot.CollisionControl.StopDetection(); m_robot.Sleep(); m_robot.Disconnect(); ConnectionToggle.OffContent = "Disconnected"; SpheroName.Text = c_noSpheroConnected; SetRedColor(); RobotProvider provider = RobotProvider.GetSharedProvider(); provider.DiscoveredRobotEvent -= OnRobotDiscovered; provider.NoRobotsEvent -= OnNoRobotsEvent; provider.ConnectedRobotEvent -= OnRobotConnected; } }
public void ShutdownRobotConnection() { if (m_robot != null) { try { m_robot.SensorControl.StopAll(); m_robot.Sleep(); m_robot.Disconnect(); m_robot.SensorControl.AccelerometerUpdatedEvent -= OnAccelerometerUpdated; m_robot.SensorControl.GyrometerUpdatedEvent -= OnGyrometerUpdated; RobotProvider provider = RobotProvider.GetSharedProvider(); provider.DiscoveredRobotEvent -= OnRobotDiscovered; provider.NoRobotsEvent -= OnNoRobotsEvent; provider.ConnectedRobotEvent -= OnRobotConnected; } catch (Exception) { throw; } } }