// compares the current measured quantity to a given value // returns true if the measured quantity is less than / more than [comparator] the given value private bool valueComparer(double value, WDandSkipMode mode, Comparison comparator) { switch (mode) { case WDandSkipMode.Current: { return((comparator == Comparison.LessThan) == (Current < value)); } case WDandSkipMode.Voltage: { return((comparator == Comparison.LessThan) == (Voltage < value)); } case WDandSkipMode.Power: { return((comparator == Comparison.LessThan) == (Power < value)); } case WDandSkipMode.Resistance: { return((comparator == Comparison.LessThan) == (Resistance < value)); } case WDandSkipMode.Temperature: { return((comparator == Comparison.LessThan) == (Temperature < value)); } } throw new NotImplementedException(); }
public static string Symbol(this WDandSkipMode mode) { return(WDandSkipModeSymbols[(int)mode]); }
public static string Name(this WDandSkipMode mode) { return(WDandSkipModeNames[(int)mode]); }
// constructor for ramp mode with skip public ProgramItem(RampMode mode, double?startingValue, double finalValue, string durationString, TimeUnits timeUnit, WDandSkipMode skipMode, Comparison skipComparator, double skipValue) { ramp(mode, startingValue, finalValue, durationString, timeUnit); skip(skipMode, skipComparator, skipValue); }
// adds skip condition to program item private void skip(WDandSkipMode skipMode, Comparison skipComparator, double skipValue) { this.skipMode = skipMode; this.skipComparator = skipComparator; this.skipValue = skipValue; this.name += "; skip if "; this.skipEnabled = true; switch (this.skipMode) { case WDandSkipMode.Current: { if (this.skipComparator == Comparison.LessThan) { this.name += "current < "; } else { this.name += "current > "; } this.name += skipValue.ToString(NUMBER_FORMAT) + " A"; break; } case WDandSkipMode.Power: { if (this.skipComparator == Comparison.LessThan) { this.name += "power < "; } else { this.name += "power > "; } this.name += skipValue.ToString(NUMBER_FORMAT) + " W"; break; } case WDandSkipMode.Resistance: { if (this.skipComparator == Comparison.LessThan) { this.name += "resistance < "; } else { this.name += "resistance > "; } this.name += skipValue.ToString(NUMBER_FORMAT) + " Ω"; break; } case WDandSkipMode.Voltage: { if (this.skipComparator == Comparison.LessThan) { this.name += "voltage < "; } else { this.name += "voltage > "; } this.name += skipValue.ToString(NUMBER_FORMAT) + " V"; break; } case WDandSkipMode.Temperature: { if (this.skipComparator == Comparison.LessThan) { this.name += "temperature < "; } else { this.name += "temperature > "; } this.name += skipValue.ToString(NUMBER_FORMAT) + " °C"; break; } } }
// constructor for constant mode with skip public ProgramItem(RunMode mode, double?value, string durationString, TimeUnits timeUnit, WDandSkipMode skipMode, Comparison skipComparator, double skipValue) { constant(mode, value, durationString, timeUnit); skip(skipMode, skipComparator, skipValue); }