/// <summary> /// Opens connection to Plathosys device and /// initialize it to get correct hook status /// </summary> /// <param name="sender"></param> private void TimerInitPlathosys_Tick(object sender) { try { OpenPlathosys(); // If initializing the Plathosys device to get correct hook status // and turning off all accessories is successful if (InitPlathosys() && Plathosys.SetHeadsetActive(false) && Plathosys.SetByListening(false) && Plathosys.SetHeadsetEar(2)) { // Stop this timmer _timerInitPlathosys.Change(Timeout.Infinite, Timeout.Infinite); // Start timer to monitor hook status _timerHook.Change(10, 100); _deviceWorking = true; // Raise PlathosysDeviceRead Event OnPlathosysDeviceReady(); } } catch (Exception) { // Try again in one second } }
/// <summary> /// Set training function to given state /// </summary> /// <param name="activate">true for on and false for off</param> public void SetTraining(bool activate) { if (_deviceWorking == false) { throw new Exception("No Plathosys device detected!"); } if ((Plathosys.SetHeadsetActive(false) && Plathosys.SetHeadsetEar((activate) ? 1 : 2)) == false) { ReconnectDevice(); throw new Exception("Setting training function failed! Please check if Plathosys device is attached and try again."); } }
/// <summary> /// Set headset port to given state /// </summary> /// <param name="activate">true for on an false for off</param> public void SetHeadset(bool activate) { if (_deviceWorking == false) { throw new Exception("No Plathosys device detected!"); } if ((Plathosys.SetHeadsetEar(2) && Plathosys.SetHeadsetActive(activate) == false)) { ReconnectDevice(); throw new Exception("Setting headset port failed! Please check if Plathosys device is attached and try again."); } }