/// <summary> /// Factory /// </summary> public static LogFilter GetInstance( LogWriterFactory factory, ParameterDatabase database) { Parameter parameter; Conversion conversion; if ((database.TryGetParameterById("E3", out parameter) || database.TryGetParameterById("E33", out parameter)) && parameter.TryGetConversionByUnits("status", out conversion)) { return(new ClosedLoopLogFilter(factory, parameter, conversion)); } else { return(new LogFilter(factory, null, null)); } }
/// <summary> /// Factory /// </summary> public static LogFilter GetInstance( LogWriterFactory factory, ParameterDatabase database) { Parameter parameter; Conversion conversion; if (database.TryGetParameterById("E114", out parameter) && parameter.TryGetConversionByUnits("%", out conversion)) { return(new KnockLogFilter(factory, parameter, conversion)); } else { return(new LogFilter(factory, null, null)); } }
/// <summary> /// Load parameter list from file. /// </summary> /// <remarks> /// TODO: indicate what parameters in the file are not supported by the current database. /// </remarks> public static LogProfile Load(string path, ParameterDatabase database) { Trace.WriteLine("LogProfile.Load"); if (database == null) { Trace.WriteLine("LogProfile.Load: no database? WTF?"); return(LogProfile.CreateInstance()); } LogProfile profile = null; using (Stream stream = File.OpenRead(path)) { XmlSerializer serializer = new XmlSerializer(typeof(SerializedColumn[])); SerializedColumn[] serializedColumns = (SerializedColumn[])serializer.Deserialize(stream); profile = LogProfile.CreateInstance(); foreach (SerializedColumn serializedColumn in serializedColumns) { Parameter parameter; Conversion conversion; if (serializedColumn == null) { Trace.WriteLine("LogProfile.Load: serializedColumn == null? WTF?"); continue; } if (database.TryGetParameterById(serializedColumn.ParameterId, out parameter) && parameter.TryGetConversionByUnits(serializedColumn.ConversionUnits, out conversion)) { profile.Add(parameter, conversion); } } } Trace.WriteLine("LogProfile.Load: done"); return(profile); }