コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="BinaryUDPPackageReader" /> class.
 /// </summary>
 /// <param name="uaDecoder">The ua decoder.</param>
 /// <param name="configuration">The configuration of the reader.</param>
 internal BinaryUDPPackageReader(IUADecoder uaDecoder, UDPReaderConfiguration configuration) : base(uaDecoder)
 {
     UDPMessageHandlerSemanticEventSource.Log.EnteringMethod(nameof(BinaryUDPPackageReader), $"{nameof(BinaryUDPPackageReader)}({configuration.ToString()})");
     State          = new MyState(this);
     m_UDPPort      = configuration.UDPPortNumber;
     MulticastGroup = configuration.DefaultMulticastGroup;
     ReuseAddress   = configuration.ReuseAddress;
 }
コード例 #2
0
        /// <summary>
        /// Gets the message reader.
        /// </summary>
        /// <param name="name">The name of the reader.</param>
        /// <param name="configuration">The configuration of the object implementing the <see cref="T:UAOOI.Networking.SemanticData.MessageHandling.IMessageReader" />.</param>
        /// <param name="uaDecoder">The decoder that provides methods to be used to decode OPC UA Built-in types.</param>
        /// <returns>An object implementing <see cref="T:UAOOI.Networking.SemanticData.MessageHandling.IMessageReader" /> that provides functionality supporting reading the messages from the wire.</returns>
        IMessageReader IMessageHandlerFactory.GetIMessageReader(string name, string configuration, IUADecoder uaDecoder)
        {
            UDPMessageHandlerSemanticEventSource.Log.GetIMessageHandler($"{nameof(IMessageHandlerFactory.GetIMessageReader)}{{ name = {name}, configuration= {configuration} }}");
            UDPReaderConfiguration _configuration = UDPReaderConfiguration.Parse(configuration);
            BinaryUDPPackageReader _ret           = new BinaryUDPPackageReader(uaDecoder, _configuration);

            return(_ret);
        }
コード例 #3
0
        /// <summary>
        /// Gets an instance implementing <see cref="IBinaryDataTransferGraphReceiver" /> interface.
        /// </summary>
        /// <param name="name">The name to be used for identification of the underlying TDG transport channel.</param>
        /// <param name="configuration">The configuration of the object implementing the <see cref="T:UAOOI.Networking.Core.IBinaryDataTransferGraphReceiver" />.</param>
        /// <returns>An object implementing <see cref="IBinaryDataTransferGraphReceiver" /> that provides functionality supporting reading the messages from the wire.</returns>
        IBinaryDataTransferGraphReceiver IMessageHandlerFactory.GetBinaryDTGReceiver(string name, string configuration)
        {
            UDPMessageHandlerSemanticEventSource.Log.GetIMessageHandler($"{nameof(IMessageHandlerFactory.GetBinaryDTGReceiver)}{{ name = {name}, configuration= {configuration} }}");
            UDPReaderConfiguration _configuration = UDPReaderConfiguration.Parse(configuration);
            BinaryUDPPackageReader _ret           = new BinaryUDPPackageReader(_configuration);

            return(_ret);
        }
コード例 #4
0
        /// <summary>
        /// Gets the message reader.
        /// </summary>
        /// <param name="name">The name of the reader.</param>
        /// <param name="configuration">The configuration of the object implementing the <see cref="T:UAOOI.Networking.SemanticData.MessageHandling.IMessageReader" />.</param>
        /// <param name="uaDecoder">The decoder that provides methods to be used to decode OPC UA Built-in types.</param>
        /// <returns>An object implementing <see cref="T:UAOOI.Networking.SemanticData.MessageHandling.IMessageReader" /> that provides functionality supporting reading the messages from the wire.</returns>
        IMessageReader IMessageHandlerFactory.GetIMessageReader(string name, string configuration, IUADecoder uaDecoder)
        {
            UDPReaderConfiguration _configuration = UDPReaderConfiguration.Parse(configuration);
            BinaryUDPPackageReader _ret           = new BinaryUDPPackageReader(uaDecoder, _configuration.UDPPortNumber);

            _ret.MulticastGroup = _configuration.DefaultMulticastGroup;
            _ret.ReuseAddress   = _configuration.ReuseAddress;
            return(_ret);
        }
コード例 #5
0
            internal static UDPReaderConfiguration GetReaderConfiguration()
            {
                bool   _ExclusiveAddressUse  = true;
                int    UDPPortNumber         = 4840;
                bool   JoinMulticastGroup    = true;
                string DefaultMulticastGroup = "239.255.255.1";

                return(UDPReaderConfiguration.Parse($"{UDPPortNumber},{JoinMulticastGroup},{DefaultMulticastGroup},{_ExclusiveAddressUse}"));
            }
コード例 #6
0
        public void UDPMulticastReaderConfigurationTest()
        {
            int    UDPPortNumber                  = 4840;
            bool   JoinMulticastGroup             = true;
            string DefaultMulticastGroup          = "239.255.255.1";
            bool   ReuseAddress                   = true;
            UDPReaderConfiguration _configuration = UDPReaderConfiguration.Parse($"{UDPPortNumber},{JoinMulticastGroup},{DefaultMulticastGroup},{ReuseAddress}");

            Assert.IsNotNull(_configuration);
            Assert.AreEqual <string>("4840,True,239.255.255.1,True", _configuration.ToString());
            Assert.AreEqual <int>(UDPPortNumber, _configuration.UDPPortNumber);
            Assert.AreEqual <string>(DefaultMulticastGroup, _configuration.DefaultMulticastGroup.ToString());
            Assert.AreEqual <bool>(ReuseAddress, _configuration.ReuseAddress);
        }
コード例 #7
0
            internal static UDPReaderConfiguration Parse(string configuration)
            {
                string[] _parameters = configuration.Split(',');
                if (_parameters.Length != 4)
                {
                    throw new ArgumentException($"Wrong number of parameter {_parameters.Length} but expected 4");
                }
                UDPReaderConfiguration _ret = new UDPReaderConfiguration();

                _ret.UDPPortNumber      = int.Parse(_parameters[0]);
                _ret.JoinMulticastGroup = bool.Parse(_parameters[1]);
                if (_ret.JoinMulticastGroup)
                {
                    _ret.DefaultMulticastGroup = IPAddressValidationRule.ValidateIP(_parameters[2]);
                }
                _ret.ReuseAddress = bool.Parse(_parameters[3]);
                return(_ret);
            }