예제 #1
0
파일: Program.cs 프로젝트: rmc00/gsf
 static void Main(string[] args)
 {
     var ser = new XmlSerializer(typeof(MasterConfiguration));
     var stream = new StreamWriter("device.xml");
     try
     {
         var config = new MasterConfiguration();
         ser.Serialize(stream, config);
     }
     finally
     {
         stream.Close();
     }
 }
예제 #2
0
        /// <summary>
        /// Initializes <see cref="DNP3InputAdapter"/>
        /// </summary>
        public override void Initialize()
        {
            Dictionary <string, string> settings = Settings;
            string setting;
            double pollingInterval;
            double timestampDifferentiation;

            base.Initialize();

            if (!settings.TryGetValue("CommsFilePath", out m_commsFilePath) || string.IsNullOrWhiteSpace(m_commsFilePath))
            {
                throw new ArgumentException("The required commsFile parameter was not specified");
            }

            if (!settings.TryGetValue("MappingFilePath", out m_mappingFilePath) || string.IsNullOrWhiteSpace(m_mappingFilePath))
            {
                throw new ArgumentException("The required mappingFile parameter was not specified");
            }

            if (settings.TryGetValue("PollingInterval", out setting) && double.TryParse(setting, out pollingInterval))
            {
                PollingInterval = pollingInterval;
            }

            m_masterConfig   = ReadConfig <MasterConfiguration>(m_commsFilePath);
            m_measurementMap = ReadConfig <MeasurementMap>(m_mappingFilePath);

            m_soeHandler = new TimeSeriesSOEHandler(new MeasurementLookup(m_measurementMap));
            m_soeHandler.NewMeasurements += OnNewMeasurements;

            // The TimestampDifferentiation property is a passthrough to the m_soeHandler.TimestampDifferentiation,
            // so m_soeHandler must be initialized before reading this property from the connection string
            if (settings.TryGetValue("TimestampDifferentiation", out setting) && double.TryParse(setting, out timestampDifferentiation))
            {
                TimestampDifferentiation = timestampDifferentiation;
            }

            lock (s_adapters)
            {
                // Add adapter to list of available adapters
                s_adapters.Add(this);

                // If no adapter has been designated as the status proxy, might as well be this one
                if ((object)s_statusProxy == null)
                {
                    s_statusProxy = this;
                }
            }
        }
예제 #3
0
        /// <summary>
        /// Initializes <see cref="DNP3InputAdapter"/>
        /// </summary>
        public override void Initialize()
        {
            Dictionary <string, string> settings = Settings;

            base.Initialize();

            settings.TryGetValue("CommsFilePath", out m_commsFilePath);

            if (string.IsNullOrWhiteSpace(m_commsFilePath))
            {
                throw new ArgumentException("The required commsFile parameter was not specified");
            }

            settings.TryGetValue("MappingFilePath", out m_mappingFilePath);

            if (string.IsNullOrWhiteSpace(m_mappingFilePath))
            {
                throw new ArgumentException("The required mappingFile parameter was not specified");
            }

            m_masterConfig   = ReadConfig <MasterConfiguration>(m_commsFilePath);
            m_measurementMap = ReadConfig <MeasurementMap>(m_mappingFilePath);

            m_soeHandler = new TimeSeriesSOEHandler(new MeasurementLookup(m_measurementMap));
            m_soeHandler.NewMeasurements += OnNewMeasurements;

            lock (s_adapters)
            {
                // Add adapter to list of available adapters
                s_adapters.Add(this);

                // If no adapter has been designated as the status proxy, might as well be this one
                if ((object)s_statusProxy == null)
                {
                    s_statusProxy = this;
                }
            }
        }