private TesterBase CreateTester(NetworkFunction networkFunction, DCSDataElement dataElement) { // specific types we want to test a certain way switch (networkFunction) { case PushButton button: _ = button; return(new BooleanTester(dataElement)); case Switch switchFunction: return(new SwitchTester(dataElement, switchFunction)); } // infer based on format switch (dataElement.Format) { case "%1d": // only testing 0 and 1 even if this is a switch with multiple values return(new BooleanTester(dataElement)); case null: if (networkFunction is NetworkValue) { // at least simulate 0..1 for generic values return(new NumericTester(dataElement, 3)); } // no tester for values created manually in script (yet) return(new UnsupportedTester(dataElement)); default: Match match = FloatFormat.Match(dataElement.Format); if (match.Success && match.Groups[1].Success && int.TryParse(match.Groups[1].Value, out int precision)) { return(new NumericTester(dataElement, precision)); } break; } return(new UnsupportedTester(dataElement)); }
public double Process(double value) { return(NetworkFunction.Process(value)); }
internal void RegisterNewNetworkFunction(string name, NetFuncType type) { NetworkFunction fun = new NetworkFunction(name, networkFunctions.Count, type); networkFunctions.Add(fun); }