Exemplo n.º 1
0
        public void SelectCamera(Camera cam)
        {
            if (null == cam)
            {
                log.Warn("SelectCamera(null)");
                return;
            }
            log.DebugFormat("SelectCamera({0})", cam.Name);

            Camera myCam = null;
            string dummy;

            try
            {
                myCam = CameraManagement.GetCameraInstanceByName(cam.Name, out dummy);
            }
            catch (ArgumentException)
            {
                string cameraTypeName = cam.GetType().ToString();
                log.DebugFormat("    camera with name {0} not found, trying {1}", cam.Name, cameraTypeName);
                try
                {
                    myCam = CameraManagement.GetCameraInstanceByName(cameraTypeName, out dummy);
                }
                catch (ArgumentException)
                {
                    log.WarnFormat("    camera with names {0} or {1} not found", cam.Name, cameraTypeName);
                    throw;
                }
            }

            this.SelectedCameras.Add(myCam);
            if (SelectedCamerasChanged != null)
            {
                SelectedCamerasChanged(this, new SelectedCamerasChangedArgs(myCam, false));
            }
        }
Exemplo n.º 2
0
        private void AddChannel(string channelName, Type imageType)
        {
            // Ignore if a channel with same name and type already exists.
            // This is the case when a new object of a previously instanciated camera type is created.
            if (registeredChannels.ContainsKey(channelName) && registeredChannels[channelName] == imageType)
            {
                return;
            }

            try
            {
                registeredChannels.Add(channelName, imageType);
            }
            catch (ArgumentException)
            {
                // TODO: Overthink channel registration best practices. This warning is always issued when a new object of a previously instanciated camera type is created. Possible solution: Do channel registration in Camera base-class and provide a virtual property which is overriden to supply all possible camera channels.
                // if a channel of that name has been added before, ignore this one.
                log.WarnFormat("A channel with the name '{0}' already existed (maybe you used a default channel name of MetriCam 2). Ignoring the new channel.", channelName);
            }
        }