protected SoapMessage <WSD.ProbeMatchesType> ProbeDevice(
            bool multicast,
            DiscoveryUtils.DiscoveryType[][] types,
            string[] scopes,
            string matchRule,
            Discovery.ProcessMessage processMessageMethod)
        {
            System.Diagnostics.Trace.WriteLine(string.Format("ProbeDevice: entry point"));
            System.Diagnostics.Trace.Flush();

            SoapMessage <WSD.ProbeMatchesType> response = null;
            Discovery discovery = new Discovery(_nic.IP, processMessageMethod);

            discovery.Discovered        += OnDiscovered;
            discovery.DiscoveryFinished += OnDiscoveryFinished;
            discovery.SoapFaultReceived += OnSoapFault;
            discovery.ReceiveError      += OnDiscoveryError;

            discovery.MessageSent += OnMessageSent;

            _eventProbeMatchReceived = new AutoResetEvent(false);
            _eventTimeout            = new AutoResetEvent(false);
            _eventFaultReceived      = new AutoResetEvent(false);
            _eventDiscoveryError     = new AutoResetEvent(false);
            int res = -1;

            try
            {
                discovery.Probe(multicast, _cameraIp, null, _messageTimeout, types, scopes, matchRule);
                res = WaitForResponse(new WaitHandle[] { _eventProbeMatchReceived, _eventTimeout, _eventFaultReceived, _eventDiscoveryError });
                if (res == 0)
                {
                    response = _message.ToSoapMessage <WSD.ProbeMatchesType>();
                }
                else if (res == 2)
                {
                    throw new SoapFaultException(_soapFault);
                }
                else if (res == 3)
                {
                    string message = _error.Message + _error.InnerException ?? " " + _error.InnerException.Message;
                    throw new AssertException(message);
                }
            }
            finally
            {
                System.Diagnostics.Trace.WriteLine(string.Format("ProbeDevice: discovery.Dispose, res = {0}", res));
                System.Diagnostics.Trace.Flush();
                discovery.Dispose();
            }
            return(response);
        }
Exemple #2
0
        protected SoapMessage <HelloType> ReceiveHelloMessage()
        {
            SoapMessage <object> res = ReceiveHelloMessage(
                Resources.StepWaitHello_Title,
                Resources.ErrorNoHelloMessage_Text,
                _rebootTimeout + _messageTimeout);

            if (res != null)
            {
                RunStep(() => { Thread.Sleep(5000); }, "5 seconds timeout after Hello");
            }
            return(res != null?res.ToSoapMessage <HelloType>() : null);
        }
Exemple #3
0
        /// <summary>
        /// Receives Bye or Hello message from DUT
        /// </summary>
        /// <param name="checkIP">if true wait from current device IP</param>
        /// <param name="checkDeviceId">if true wait for current device uuid</param>
        /// <param name="action">additional action after begin waiting</param>
        /// <param name="timeout">time to wait</param>
        /// <returns>Bye message</returns>
        protected SoapMessage <WSD.ByeType> ReceiveByeOrHelloMessage(bool checkIP, bool checkDeviceId, Action action, Action <SoapMessage <object> > validation)
        {
            SoapMessage <object> res = ReceiveMessageInternal(
                WaitMessageType.Bye | WaitMessageType.Hello,
                Resources.StepWaitByeOrHello_Title,
                null,
                checkIP,
                checkDeviceId,
                action,
                validation,
                _rebootTimeout + _messageTimeout);

            return(res != null?res.ToSoapMessage <WSD.ByeType>() : null);
        }
Exemple #4
0
        /// <summary>
        /// Receives Bye message from DUT
        /// </summary>
        /// <param name="checkIP">if true wait from current device IP</param>
        /// <param name="checkDeviceId">if true wait for current device uuid</param>
        /// <param name="action">additional action after begin waiting</param>
        /// <param name="timeout">time to wait</param>
        /// <returns>Bye message</returns>
        protected SoapMessage <WSD.ByeType> ReceiveByeMessage(bool checkIP, bool checkDeviceId, Action action, int timeout)
        {
            SoapMessage <object> res = ReceiveMessageInternal(
                WaitMessageType.Bye,
                Resources.StepWaitBye_Title,
                Resources.ErrorNoByeMessage_Text,
                checkIP,
                checkDeviceId,
                action,
                null,
                timeout);

            return(res != null?res.ToSoapMessage <WSD.ByeType>() : null);
        }
Exemple #5
0
        /// <summary>
        /// Receives Hello message from DUT
        /// </summary>
        /// <param name="checkIP">if true wait from current device IP</param>
        /// <param name="checkDeviceId">if true wait for current device uuid</param>
        /// <param name="action">additional action after begin waiting</param>
        /// <param name="timeout">time to wait</param>
        /// <returns>Hello message</returns>
        protected SoapMessage <WSD.HelloType> ReceiveHelloMessage(bool checkIP, bool checkDeviceId, Action action, int timeout)
        {
            SoapMessage <object> res = ReceiveMessageInternal(
                WaitMessageType.Hello,
                Resources.StepWaitHello_Title,
                Resources.ErrorNoHelloMessage_Text,
                checkIP,
                checkDeviceId,
                action,
                null,
                timeout);

            if (res != null)
            {
                RunStep(() => { Thread.Sleep(5000); }, "5 seconds timeout after Hello");
            }
            return(res != null?res.ToSoapMessage <WSD.HelloType>() : null);
        }
Exemple #6
0
        /// <summary>
        /// Receives Hello message from DUT
        /// </summary>
        /// <param name="checkIP">if true wait from current device IP</param>
        /// <param name="checkDeviceId">if true wait for current device uuid</param>
        /// <param name="afterStartAction">additional afterStartAction after begin waiting</param>
        /// <param name="timeout">time to wait</param>
        /// <returns>Hello message</returns>
        public SoapMessage <WSD.HelloType> ReceiveHelloMessage(bool checkIP, bool checkDeviceId, Action afterStartAction, Discovery.MessageFilterFunction messageFilter, int timeout)
        {
            SoapMessage <object> res = ReceiveMessageInternal(WaitMessageType.Hello,
                                                              Resources.StepWaitHello_Title,
                                                              Resources.ErrorNoHelloMessage_Text,
                                                              checkIP,
                                                              checkDeviceId,
                                                              afterStartAction,
                                                              messageFilter,
                                                              null,
                                                              timeout);

            //string dump = System.Text.Encoding.UTF8.GetString(res.Raw);
            //LogResponse(dump);

            if (res != null)
            {
                RunStep(() => Thread.Sleep(5000), "5 seconds timeout after Hello");
            }
            return(res != null?res.ToSoapMessage <WSD.HelloType>() : null);
        }