/*************************************************************************************************************** * Custom Methods for our program. Best practice says these SHOULD be in their own class files for * orginization and readability ***************************************************************************************************************/ // Create a Method to do our interlock for us // This method is passed the input collection so we can work on it directly. // we pass the Object specifically the Tri-list objects inputs, //then a number for the first and the last, and then finally the one we want selected // we pass the whole collection so this can be usable for any range and size. Make your code reusable private void Interlock(DeviceBooleanInputCollection input, uint from, uint to, uint selected) { if (selected >= from && selected <= to) // Validate our data { for (uint i = from; i <= to; i++) // Iterate through our items { if (i == selected) { input[i].BoolValue = true; // This is the one we want? set it high } else { input[i].BoolValue = false; // Not what we want set it low } // NOTE: This is NOT a Break Before Make. It has the potential of having two outputs high // at the same time for a very short amount of time // HIDDEN CHALLENGE: Modify this code to become Break Before Make and properly act exactly like a Simpl Interlock } } }
public static bool GetBoolValue(this DeviceBooleanInputCollection inputs, string name) { return(inputs[name].BoolValue); }
public static void Pulse(this DeviceBooleanInputCollection inputs, string name, int msTimeBetweenTransition) { inputs[name].Pulse(msTimeBetweenTransition); }
public static bool GetBoolValue(this DeviceBooleanInputCollection inputs, uint index) { return(inputs[index].BoolValue); }
public static void Pulse(this DeviceBooleanInputCollection inputs, string name) { inputs[name].Pulse(); }
public static void Pulse(this DeviceBooleanInputCollection inputs, uint index, int msTimeBetweenTransition) { inputs[index].Pulse(msTimeBetweenTransition); }
public static void Pulse(this DeviceBooleanInputCollection inputs, uint index) { inputs[index].Pulse(); }
public static void SetFalse(this DeviceBooleanInputCollection inputs, string name) { inputs[name].BoolValue = false; }
public static void SetFalse(this DeviceBooleanInputCollection inputs, uint index) { inputs[index].BoolValue = false; }
public static void SetValue(this DeviceBooleanInputCollection inputs, string name, bool value) { inputs[name].BoolValue = value; }
public static void SetValue(this DeviceBooleanInputCollection inputs, uint index, bool value) { inputs[index].BoolValue = value; }