Exemplo n.º 1
0
 /// <summary>
 /// Private constructor - use factory instead
 /// </summary>
 private SsmRecordingLogger(
     ParameterDatabase database,
     string configurationDirectory,
     string portName,
     LogWriterFactory logWriterFactory)
 {
     this.logWriterFactory = logWriterFactory;
     this.database         = database;
     this.filter           = NeverLogFilter.GetInstance(this.logWriterFactory);
     this.logger           = SsmLogger.GetInstance(configurationDirectory, portName);
     this.logger.LogStart += this.Logger_LogStart;
     this.logger.LogEntry += this.Logger_LogEntry;
     this.logger.LogStop  += this.Logger_LogStop;
     this.logger.LogError += this.Logger_LogError;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Factory
        /// </summary>
        public static SsmRecordingLogger GetInstance(
            ParameterDatabase database,
            string configurationDirectory,
            string portName,
            LogWriterFactory factory)
        {
            Trace.WriteLine("SsmRecordingLogger.GetInstance");
            SsmRecordingLogger instance = new SsmRecordingLogger(
                database,
                configurationDirectory,
                portName,
                factory);

            return(instance);
        }
Exemplo n.º 3
0
        /// <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));
            }
        }
Exemplo n.º 4
0
        /// <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));
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Private constructor, use factory instead
        /// </summary>
        /// <param name="profile"></param>
        private InternalLogProfile(LogProfile profile, ParameterDatabase database)
        {
            if (Debugger.IsAttached)
            {
                this.stackTrace = new StackTrace();
            }

            this.profile  = profile;
            this.database = database;

            List <LogColumn> columns = new List <LogColumn>();

            this.AddColumnsAndDependents(columns, this.profile);
            this.addresses = BuildAddressList(columns);

            ReadOnlyCollection <LogColumn> readOnly = columns.AsReadOnly();
            LogRow row = LogRow.GetInstance(readOnly);

            this.logEventArgs = new LogEventArgs(row, profile.UserData);
        }
Exemplo n.º 6
0
        /// <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);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Add the parameter and conversion to the profile, making sure that
        /// the given parameter and conversion exists in the database.
        /// </summary>
        /// <remarks>
        /// TODO: Move the check logic into a new ParameterDatabase.Exists() method.
        /// </remarks>
        public void Add(string id, string units, ParameterDatabase database)
        {
            if (database == null)
            {
                throw new ArgumentNullException("database");
            }

            foreach (Parameter parameter in database.Parameters)
            {
                if (parameter.Id == id)
                {
                    foreach (Conversion conversion in parameter.Conversions)
                    {
                        if (conversion.Units == units)
                        {
                            this.Add(parameter, conversion);
                            return;
                        }
                    }
                    throw new ArgumentException("Conversion " + units + " not supported for parameter " + id);
                }
            }
            throw new ArgumentException("Parameter " + id + " not supported.");
        }
Exemplo n.º 8
0
 /// <summary>
 /// Selects parameters to be logged
 /// </summary>
 public void SetProfile(LogProfile profile, ParameterDatabase database)
 {
     Trace.WriteLine("SsmBasicLogger.SetProfile");
     this.internalProfile = InternalLogProfile.GetInstance(profile, database);
 }
Exemplo n.º 9
0
 /// <summary>
 /// Selects parameters to be logged
 /// </summary>
 public void SetProfile(LogProfile profile, ParameterDatabase database)
 {
     Trace.WriteLine("SsmLogger.SetProfile");
     this.logger.SetProfile(profile, database);
 }
Exemplo n.º 10
0
 /// <summary>
 /// Factory
 /// </summary>
 public static InternalLogProfile GetInstance(LogProfile profile, ParameterDatabase database)
 {
     return(new InternalLogProfile(profile, database));
 }