/// <summary>
        /// Constructor
        /// </summary>
        /// <param name="plc"> The plc object that is used to forward all calls to the <see cref="IPlc"/> interface to. </param>
        /// <param name="plcItemMonitorConfigurations"> <see cref="PlcItemMonitorConfigurations"/> for specifying special polling frequencies for some <see cref="IPlcItem"/>s. </param>
        public PollingMonitorablePlc(IPlc plc, PlcItemMonitorConfigurations plcItemMonitorConfigurations)
        {
            // Save parameters.
            _decoratedPlc = plc;

            // Initialize fields.
            _plcMonitor = new PollingPlcMonitor(plc, plcItemMonitorConfigurations);
        }
Пример #2
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="plc"> <see cref="IPlc"/> instance used to poll for changes in the monitored <see cref="IPlcItem"/>s. </param>
        /// <param name="plcItemMonitorConfigurations"> <see cref="PlcItemMonitorConfigurations"/> for specifying special polling frequencies for some <see cref="IPlcItem"/>s. </param>
        public PollingPlcMonitor(IPlc plc, PlcItemMonitorConfigurations plcItemMonitorConfigurations)
        {
            // Save parameters.
            _plc = plc;
            _plcItemMonitorConfigurations = plcItemMonitorConfigurations ?? new PlcItemMonitorConfigurations();

            // Initialize fields.
            _lock            = new object();
            _plcItemHandlers = new Dictionary <int, PlcItemMonitorHandler>();
        }
        /// <summary>
        /// Gets the polling frequency for the <paramref name="plcItem"/>.
        /// </summary>
        /// <param name="plcItem"> The <see cref="IPlcItem"/> whose polling frequency to get. </param>
        /// <returns> The polling frequency. </returns>
        public TimeSpan GetPollingFrequencyForPlcItem(IPlcItem plcItem)
        {
            // Use the defined value for the item if available.
            if (plcItem.Identifier != null && base.Contains(plcItem.Identifier))
            {
                return(PlcItemMonitorConfigurations.ValidatePollingFrequency(TimeSpan.FromMilliseconds(base[plcItem.Identifier].PollingFrequency)));
            }

            // Otherwise the default polling frequency is used.
            return(PlcItemMonitorConfigurations.DefaultPollingFrequency);
        }