private void Initialize() { bool originalMode = s_automaticRoundRobinEnabled; SetAutomaticMode(false); lock (s_syncRoot) { s_currentSensors.Add(this); } m_counter = new Counter { MaxPeriod = 1.0 }; m_counter.SetSemiPeriodMode(true); m_counter.Reset(); Enabled = true; SetAutomaticMode(originalMode); ++s_instances; HAL.Base.HAL.Report(ResourceType.kResourceType_Ultrasonic, s_instances); LiveWindow.LiveWindow.AddSensor("Ultrasonic", m_echoChannel.Channel, this); }
/// <summary> /// Ping a single ultrasonic sensor. /// </summary> /// <remarks>This only work if automatic mode is disabled. A single ping is sent out, and the counter /// should count the semi-period when it comes in. The counter is reset to make the current /// value invalid.</remarks> public void Ping() { SetAutomaticMode(false); m_counter.Reset(); m_pingChannel.Pulse(PingTime); }