IEnumerator setControlsOnTimer() { int curValue = 0; while (true) { Debug.Log("Setting to " + curValue); myDevice.SetControlByID(1, curValue); yield return(new WaitForSeconds(2)); if (curValue == 0) { curValue = 1; } else { curValue = 0; } } }
// Specify what you want to happen when the Elapsed event is raised. private static void OnTimedEvent(object source, ElapsedEventArgs e) { DateTime curTime = DateTime.Now; double totalSecondsBetween = ((curTime - startEngagement).TotalSeconds); if (totalSecondsBetween < allowableDownTime) { Console.WriteLine("Is Engaged " + totalSecondsBetween); if (myDevice.GetControlValueByID(0) == 0) { myDevice.SetControlByID(0, 1); } } else { Console.WriteLine("Not Engaged " + totalSecondsBetween); if (myDevice.GetControlValueByID(0) == 1) { myDevice.SetControlByID(0, 0); } } }