Ejemplo n.º 1
0
        private void cmbPTZProfiles_SelectedIndexChanged(object sender, EventArgs e)
        {
            Onvif.Profile          profile = (cmbPTZProfiles.SelectedItem != null) ? (cmbPTZProfiles.SelectedItem as ProfileWrapper).Profile : null;
            Onvif.PTZConfiguration config  = profile != null ? profile.PTZConfiguration : null;
            btnAddPTZConfig.Enabled = (config == null);

            panelAbsoluteMove.Enabled  = (rbAbsoluteMove.Checked || rbRelativeMove.Checked) && !string.IsNullOrEmpty(PTZAddress) && (config != null);
            panelContiniusMove.Enabled = rbContuniousMove.Checked && !string.IsNullOrEmpty(PTZAddress) && (config != null);
            rbAbsoluteMove.Enabled     = !string.IsNullOrEmpty(PTZAddress) && (config != null);
            rbRelativeMove.Enabled     = !string.IsNullOrEmpty(PTZAddress) && (config != null);
            rbContuniousMove.Enabled   = !string.IsNullOrEmpty(PTZAddress) && (config != null);
        }
Ejemplo n.º 2
0
        public void EnableControls(bool enable)
        {
            Invoke(new Action(() =>
            {
                DiscoveredDevices devices = ContextController.GetDiscoveredDevices();
                string address            = devices != null ? devices.ServiceAddress : string.Empty;

                Onvif.Profile profile         = (cmbPTZProfiles.SelectedItem != null) ? (cmbPTZProfiles.SelectedItem as ProfileWrapper).Profile : null;
                Onvif.PTZConfiguration config = profile != null ? profile.PTZConfiguration : null;

                btnGetPtzUrl.Enabled       = enable && !string.IsNullOrEmpty(address);
                btnGetProfiles.Enabled     = enable && !string.IsNullOrEmpty(MediaAddress);
                btnVideo.Enabled           = (enable && !string.IsNullOrEmpty(MediaAddress)) || (_videoWindow != null);
                rbAbsoluteMove.Enabled     = enable && !string.IsNullOrEmpty(PTZAddress) && (config != null);
                rbRelativeMove.Enabled     = enable && !string.IsNullOrEmpty(PTZAddress) && (config != null);
                rbContuniousMove.Enabled   = enable && !string.IsNullOrEmpty(PTZAddress) && (config != null);
                panelAbsoluteMove.Enabled  = enable && (rbAbsoluteMove.Checked || rbRelativeMove.Checked) && !string.IsNullOrEmpty(PTZAddress) && (config != null);
                panelContiniusMove.Enabled = enable && rbContuniousMove.Checked && !string.IsNullOrEmpty(PTZAddress) && (config != null);
                btnAddPTZConfig.Enabled    = enable && (profile != null) && (config == null);

                cmbPTZProfiles.Enabled = enable;
            }));
        }
        public void ProfilesAndPTZConfigurationConsistencyTest()
        {
            RunTest(() =>
            {
                Profile[] profiles = GetProfiles();

                Assert(profiles != null,
                       "DUT did not return any profile",
                       "Check if the DUT returned media profiles");

                TestTool.Proxies.Onvif.PTZConfiguration[] ptzConfigurations = GetPtzConfigurations();

                Assert(ptzConfigurations != null,
                       "DUT did not return any configuration",
                       "Check if the DUT returned configurations");


                // check that configurations have unique names
                List <string> tokens     = new List <string>();
                List <string> duplicates = new List <string>();
                foreach (TestTool.Proxies.Onvif.PTZConfiguration configuration in ptzConfigurations)
                {
                    if (!tokens.Contains(configuration.token))
                    {
                        tokens.Add(configuration.token);
                    }
                    else
                    {
                        if (!duplicates.Contains(configuration.token))
                        {
                            duplicates.Add(configuration.token);
                        }
                    }
                }
                if (duplicates.Count > 0)
                {
                    StringBuilder sb = new StringBuilder("The following tokens are not unique: ");
                    bool first       = true;
                    foreach (string token in duplicates)
                    {
                        sb.Append(first ? token : string.Format(", {0}", token));
                        first = false;
                    }

                    Assert(false, sb.ToString(), "Validate PTZ configurations");
                }

                foreach (Profile profile in profiles)
                {
                    if (profile.PTZConfiguration != null)
                    {
                        Assert(tokens.Contains(profile.PTZConfiguration.token),
                               string.Format("PTZ configuration '{0}' not found", profile.PTZConfiguration.token),
                               string.Format("Check if PTZ configuration for profile '{0}' exists", profile.token));

                        TestTool.Proxies.Onvif.PTZConfiguration config =
                            ptzConfigurations.Where(c => c.token == profile.PTZConfiguration.token).FirstOrDefault();

                        CompareConfigurations(config, profile.PTZConfiguration);
                    }
                }
            });
        }