Пример #1
0
        protected BaseOnvifTest(TestLaunchParam param) : base(param)
        {
            _features.Mode = param.FeatureDefinitionMode;
            if (param.FeatureDefinitionMode == FeatureDefinitionMode.Default)
            {
                _features.AddRange(param.Features);
            }

            _cameraAddress   = param.ServiceAddress;
            _cameraIp        = param.CameraIp;
            _cameraId        = param.CameraUUID;
            _nic             = param.NIC;
            _username        = param.UserName;
            _password        = param.Password;
            _useUTCTimestamp = param.UseUTCTimestamp;
            Operator         = param.Operator;

            if (param.VideoForm != null)
            {
                _videoForm = param.VideoForm;
                // reinitialize video window
                _videoForm.Reset();
                _videoForm.NICIndex  = param.NIC.Index;
                _videoForm.StopEvent = _semaphore.StopEvent;
            }

            _declaredScopes.AddRange(param.DeclaredScopes);

            _environmentSettings = param.EnvironmentSettings;

            _messageTimeout = param.MessageTimeout;

            _operationDelay = param.OperationDelay;
            _recoveryDelay  = param.RecoveryDelay;

            _rebootTimeout = param.RebootTimeout;

            // should be done in BaseTest.Initialize();
            //_trafficListener = new TrafficListener();
            //_trafficListener.RequestSent += LogRequest;
            //_trafficListener.ResponseReceived += LogResponse;

            _endpointController = new EndpointController(new EndpointAddress(_cameraAddress));

            _credentialsProvider          = new CredentialsProvider();
            _credentialsProvider.Username = param.UserName;
            _credentialsProvider.Password = param.Password;
            _credentialsProvider.Security = param.Security;
        }
Пример #2
0
        protected BaseOnvifTest(TestLaunchParam param) : base(param)
        {
            _features.Mode = param.FeatureDefinitionMode;
            if (param.FeatureDefinitionMode == FeatureDefinitionMode.Default)
            {
                _features.AddRange(param.Features);
            }

            //_cameraAddress = param.ServiceAddress;
            FirmwareFilePath = param.FirmwareFilePath;

            CredentialIdentifierValueFirst  = param.CredentialIdentifierValueFirst;
            CredentialIdentifierValueSecond = param.CredentialIdentifierValueSecond;
            CredentialIdentifierValueThird  = param.CredentialIdentifierValueThird;

            _cameraIp = param.CameraIp;
            _cameraId = param.CameraUUID;
            _nic      = param.NIC;
            TestTool.HttpTransport.RequestNetworkStream.EndpointFrom = new IPEndPoint(_nic.IP, 0);
            _username        = param.UserName;
            _password        = param.Password;
            _useUTCTimestamp = param.UseUTCTimestamp;
            Operator         = param.Operator;

            if (param.VideoForm != null)
            {
                _videoForm = param.VideoForm;
                // reinitialize video window
                _videoForm.Reset();
                _videoForm.NICIndex  = param.NIC.Index;
                _videoForm.StopEvent = _semaphore.StopEvent;
            }

            _declaredScopes.AddRange(param.DeclaredScopes);

            _environmentSettings = param.EnvironmentSettings;

            _messageTimeout = param.MessageTimeout;

            _operationDelay = param.OperationDelay;
            _recoveryDelay  = param.RecoveryDelay;

            _rebootTimeout = param.RebootTimeout;

            // should be done in BaseTest.Initialize();
            //_trafficListener = new TrafficListener();
            //_trafficListener.RequestSent += LogRequest;
            //_trafficListener.ResponseReceived += LogResponse;

            _endpointController = new EndpointController(new EndpointAddress(param.ServiceAddress));

            _credentialsProvider = new CredentialsProvider
            {
                Username = param.UserName,
                Password = param.Password,
                Security = param.Security
            };

            NetworkSettingsChangedEvent += address =>
            {
                var uri = new EndpointAddress(address);

                var       addresses = Dns.GetHostAddresses(uri.Uri.Host);
                IPAddress newAddr   = null;
                switch (uri.Uri.HostNameType)
                {
                case UriHostNameType.IPv4:
                    newAddr = addresses.FirstOrDefault(u => u.AddressFamily == AddressFamily.InterNetwork);
                    break;

                case UriHostNameType.IPv6:
                    newAddr = addresses.FirstOrDefault(u => u.AddressFamily == AddressFamily.InterNetworkV6);
                    break;

                case UriHostNameType.Dns:
                    newAddr = addresses.FirstOrDefault(u => u.AddressFamily == AddressFamily.InterNetwork);
                    if (null == _cameraIp)
                    {
                        newAddr = addresses.FirstOrDefault(u => u.AddressFamily == AddressFamily.InterNetworkV6);
                    }
                    break;
                }

                if (null != newAddr)
                {
                    _endpointController.UpdateAddress(uri);
                    _cameraIp = newAddr;
                }
            };
        }