void ChangeRelayOutputProperties(string token, string delayTime, RelayIdleState idleState, RelayMode mode)
        {
            RelayOutputSettings testSettings = new RelayOutputSettings();

            testSettings.DelayTime = delayTime;
            testSettings.IdleState = idleState;
            testSettings.Mode      = mode;

            RelayOutput output = new RelayOutput();

            output.token      = token;
            output.Properties = testSettings;

            SetRelayOutputSettings(output);

            RelayOutput[] actualOutputs = GetRelayOutputs();

            Assert(actualOutputs != null, "No relay outputs received via GetRelayOutputs", "Check that the DUT sent relay outputs information");

            RelayOutput actualOutput =
                actualOutputs.Where(o => o.token == token).FirstOrDefault();

            Assert(actualOutput != null,
                   string.Format("Relay output with token {0} not found", token),
                   "Find current output settings");

            ValidateRelayOutputSettings(testSettings, actualOutput.Properties);
        }
        public void SetRelayOutputInvalidTokenTest()
        {
            RunTest(
                () =>
            {
                RelayOutput[] outputs = GetRelayOutputs();

                Assert(outputs != null, "No relay outputs received via GetRelayOutputs", "Check that the DUT sent relay outputs information");

                List <string> tokens = new List <string>();

                foreach (RelayOutput output in outputs)
                {
                    tokens.Add(output.token);
                }

                string token = tokens.GetNonMatchingString();

                RelayOutputSettings testSettings = new RelayOutputSettings();
                testSettings.DelayTime           = "PT10S";
                testSettings.IdleState           = RelayIdleState.open;
                testSettings.Mode = RelayMode.Bistable;

                RelayOutput testOutput = new RelayOutput();
                testOutput.token       = token;
                testOutput.Properties  = testSettings;

                RunStep(
                    () => { Client.SetRelayOutputSettings(testOutput); },
                    "Set relay output settings - negative test",
                    "Sender/InvalidArgVal/RelayToken",
                    true);
                DoRequestDelay();
            });
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ModifyRelayOutputForm" /> class.
 /// </summary>
 /// <param name="relayOutput">The <paramref name="relayOutput"/> parameter.</param>
 public ModifyRelayOutputForm(RelayOutput relayOutput)
 {
     InitializeComponent();
     SelectedRelayOutput = relayOutput;
     tbxName.Text        = relayOutput.Name;
     tbxDescription.Text = relayOutput.Description;
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ModifyRelayOutputForm" /> class.
 /// </summary>
 /// <param name="relayOutput">The <paramref name="relayOutput"/> parameter.</param>
 public ModifyRelayOutputForm(RelayOutput relayOutput)
 {
     InitializeComponent();
     SelectedRelayOutput = relayOutput;
     tbxName.Text        = relayOutput.Name;
     tbxDescription.Text = relayOutput.Description;
     ckbxEnabled.Checked = relayOutput.IsEnabled;
 }
        public override void SetRelayOutputSettings(RelayOutput RelayOutput)
        {
            int           timeOut;
            SoapException ex;

            StepType stepType = DeviceIO10ServiceTest.SetRelayOutputSettingsTest(out ex, out timeOut, RelayOutput);

            StepTypeProcessing(stepType, ex, timeOut);
        }
        public void SetRelayOutputClosedIdleStateTest()
        {
            RelayOutputSettings initialSettings = null;
            string token = string.Empty;

            RunTest(
                () =>
            {
                RelayOutput[] outputs = GetRelayOutputs();

                Assert(outputs != null && outputs.Length > 0, "No relay outputs received via GetRelayOutputs", "Check that the DUT sent relay outputs information");

                string testTime = string.Format("PT{0}S", _relayOutputDelayTimeBistable);

                token = outputs[0].token;

                RelayOutputSettings testSettings = new RelayOutputSettings();
                testSettings.DelayTime           = testTime;
                testSettings.IdleState           = RelayIdleState.closed;
                testSettings.Mode = RelayMode.Bistable;

                RelayOutput output = new RelayOutput();
                output.token       = token;
                output.Properties  = testSettings;

                SetRelayOutputSettings(output);
                initialSettings = outputs[0].Properties;

                SetRelayOutputState(token, RelayLogicalState.active);

                // get answer
                CheckRelayOutputOpen(token);

                SetRelayOutputState(token, RelayLogicalState.inactive);

                // get answer
                CheckRelayOutputClosed(token);
            },
                () =>
            {
                if (initialSettings != null)
                {
                    RelayOutput output = new RelayOutput();
                    output.token       = token;
                    output.Properties  = initialSettings;

                    SetRelayOutputSettings(output, "Restore output settings");
                }
            });
        }
        public void SetRelayOutputMonostableOpenIdleStateTimeoutTest()
        {
            RelayOutputSettings initialSettings = null;
            string token = string.Empty;

            RunTest(
                () =>
            {
                RelayOutput[] outputs = GetRelayOutputs();

                Assert(outputs != null && outputs.Length > 0, "No relay outputs received via GetRelayOutputs", "Check that the DUT sent relay outputs information");

                int testTime = 60;
                bool ok      = _operator.GetDelayTime("Enter Delay Time value for test", ref testTime);

                Assert(ok, "Operator cancelled the test", "Get test parameter from operator");

                token = outputs[0].token;

                RelayOutputSettings testSettings = new RelayOutputSettings();
                testSettings.DelayTime           = string.Format("PT{0}S", testTime);
                testSettings.IdleState           = RelayIdleState.open;
                testSettings.Mode = RelayMode.Monostable;

                RelayOutput output = new RelayOutput();
                output.token       = token;
                output.Properties  = testSettings;

                SetRelayOutputSettings(output);
                initialSettings = outputs[0].Properties;

                System.DateTime dtSend = System.DateTime.Now;

                SetRelayOutputState(token, RelayLogicalState.active);

                System.DateTime dtReceived = System.DateTime.Now;

                double delay = (dtSend - dtReceived).TotalMilliseconds;

                System.DateTime dtSet      = dtSend.AddMilliseconds(delay / 2);
                System.DateTime expireTime = dtSet.AddSeconds(testTime);

                Assert(expireTime > System.DateTime.Now, "Timeout expired already",
                       "Check if timeout has not expired");

                SetRelayOutputState(token, RelayLogicalState.inactive);

                Assert(expireTime > System.DateTime.Now, "Timeout expired already",
                       "Check if timeout has not expired");

                int timeLeft = (int)((expireTime - System.DateTime.Now).TotalSeconds);

                // get answer
                CheckRelayOutputOpen(token, timeLeft);

                timeLeft = (int)((expireTime - System.DateTime.Now).TotalSeconds);

                // Wait
                BeginStep("Check if timeout expired");
                if (timeLeft > 0)
                {
                    LogStepEvent(string.Format("Wait {0} seconds more", timeLeft));
                    Sleep(timeLeft * 1000);
                }
                StepPassed();
                // second part

                testSettings.IdleState = RelayIdleState.closed;

                output            = new RelayOutput();
                output.token      = token;
                output.Properties = testSettings;

                SetRelayOutputSettings(output);
                initialSettings = outputs[0].Properties;

                dtSend = System.DateTime.Now;
                SetRelayOutputState(token, RelayLogicalState.active);
                dtReceived = System.DateTime.Now;

                delay      = (dtSend - dtReceived).TotalMilliseconds;
                dtSet      = dtSend.AddMilliseconds(delay / 2);
                expireTime = dtSet.AddSeconds(testTime);

                Assert(expireTime > System.DateTime.Now, "Timeout expired already",
                       "Check if timeout has not expired");

                SetRelayOutputState(token, RelayLogicalState.inactive);

                Assert(expireTime > System.DateTime.Now, "Timeout expired already",
                       "Check if timeout has not expired");

                timeLeft = (int)((expireTime - System.DateTime.Now).TotalSeconds);

                // get answer
                CheckRelayOutputClosed(token, timeLeft);

                timeLeft = (int)((expireTime - System.DateTime.Now).TotalSeconds);

                // Wait
                BeginStep("Check if timeout expired");
                if (timeLeft > 0)
                {
                    LogStepEvent(string.Format("Wait {0} seconds more", timeLeft));
                    Sleep(timeLeft * 1000);
                }
                StepPassed();
            },
                () =>
            {
                if (initialSettings != null)
                {
                    RelayOutput output = new RelayOutput();
                    output.token       = token;
                    output.Properties  = initialSettings;

                    SetRelayOutputSettings(output, "Restore output settings");
                }
            });
        }
        public void SetRelayOutputMonostableClosedIdleStateTest()
        {
            RelayOutputSettings initialSettings = null;
            string token = string.Empty;

            RunTest(
                () =>
            {
                RelayOutput[] outputs = GetRelayOutputs();

                Assert(outputs != null && outputs.Length > 0, "No relay outputs received via GetRelayOutputs", "Check that the DUT sent relay outputs information");

                int testTime = 60;
                bool ok      = _operator.GetDelayTime("Enter Delay Time value for test", ref testTime);

                Assert(ok, "Operator cancelled the test", "Get test parameter from operator");

                token = outputs[0].token;

                RelayOutputSettings testSettings = new RelayOutputSettings();
                testSettings.DelayTime           = string.Format("PT{0}S", testTime);
                testSettings.IdleState           = RelayIdleState.closed;
                testSettings.Mode = RelayMode.Monostable;

                RelayOutput output = new RelayOutput();
                output.token       = token;
                output.Properties  = testSettings;

                SetRelayOutputSettings(output);
                initialSettings = outputs[0].Properties;

                SetRelayOutputState(token, RelayLogicalState.active);

                System.DateTime setTime = System.DateTime.Now;

                // get answer
                CheckRelayOutputOpen(token);

                System.DateTime answerTime = System.DateTime.Now;

                // wait
                int diff = testTime - (int)((answerTime - setTime).TotalSeconds);
                BeginStep("Check if timeout expired");
                if (diff > 0)
                {
                    LogStepEvent(string.Format("Wait {0} seconds more", diff));
                    Sleep(diff * 1000);
                }
                StepPassed();

                // get answer

                CheckRelayOutputClosed(token);
            },
                () =>
            {
                if (initialSettings != null)
                {
                    RelayOutput output = new RelayOutput();
                    output.token       = token;
                    output.Properties  = initialSettings;

                    SetRelayOutputSettings(output, "Restore output settings");
                }
            });
        }
        internal StepType SetRelayOutputSettingsTest(out SoapException ex, out int Timeout, RelayOutput RelayOutput)
        {
            StepType res = StepType.None;

            Timeout = 0;
            ex      = null;
            bool   passed     = true;
            string logMessage = "";

            //Get step list for command
            XmlNodeList m_testList = TestCommon.GetStepsForCommand("DeviceIO10.SetRelayOutputSettings");

            if (m_testList != null)
            {
                //Get current step
                XmlNode test = m_testList[m_commandCount[SetRelayOutputSettings]];

                #region Analize request

                //RelayOutput
                CommonCompare.Exist("RequestParameters/RelayOutputToken", "RelayOutput", RelayOutput, ref logMessage, ref passed, test);

                if (passed)
                {
                    //RelayOutputToken
                    if (CommonCompare.IgnoreCheck("RequestParameters/RelayOutputToken", test))
                    {
                        logMessage = logMessage + " RelayOutputToken = " + RelayOutput.token + "; ";
                    }
                    else
                    {
                        CommonCompare.StringCompare("RequestParameters/RelayOutputToken", "RelayOutputToken", RelayOutput.token, ref logMessage, ref passed, test);
                    }

                    //Properties
                    if (RelayOutput.Properties != null)
                    {
                        //Mode
                        CommonCompare.StringCompare("RequestParameters/Properties/Mode", "Properties.Mode", RelayOutput.Properties.Mode.ToString(), ref logMessage, ref passed, test);

                        //DelayTime
                        CommonCompare.StringCompare("RequestParameters/Properties/DelayTime", "Properties.DelayTime", RelayOutput.Properties.DelayTime, ref logMessage, ref passed, test);

                        //IdleState
                        CommonCompare.StringCompare("RequestParameters/Properties/IdleState", "Properties.IdleState", RelayOutput.Properties.IdleState.ToString(), ref logMessage, ref passed, test);
                    }
                    else
                    {
                        passed     = false;
                        logMessage = logMessage + "No required tag Properties.";
                    }
                }

                #endregion //Analize request

                //Generate response
                res = TestCommon.GenerateResponseStepTypeVoid(test, out ex, out Timeout);

                string typeRes = test.SelectNodes("Response")[0].InnerText;

                //Log message
                TestCommon.writeToLog(test, logMessage, passed);

                Increment(m_testList.Count, SetRelayOutputSettings);
            }
            else
            {
                res     = StepType.None;
                Timeout = 0;
                ex      = null;
                res     = StepType.None;
            }
            return(res);
        }
Ejemplo n.º 10
0
 protected void SetRelayOutputSettings(RelayOutput output, string stepName)
 {
     RunStep(() => { Client.SetRelayOutputSettings(output); }, stepName);
     DoRequestDelay();
 }
Ejemplo n.º 11
0
 protected void SetRelayOutputSettings(RelayOutput output)
 {
     SetRelayOutputSettings(output, "Set relay output settings");
 }