示例#1
0
        static void Main(string[] args)
        {
            log.SetLogLevel(log4net.Core.Level.Debug);

            SVS cam = new SVS();

            try
            {
                cam.Connect();
            }
            catch (MetriCam2.Exceptions.ConnectionFailedException e)
            {
                log.FatalFormat("Could not connect to camera: {0}", e.Message);
                return;
            }
            log.InfoFormat("Camera connected: {0} (S/N {1})", cam.Name, cam.SerialNumber);

            //log.DebugFormat("activating software trigger (current setting: {0})", cam.AcquisitionMode);
            cam.SetParameter("AutoGain", false);
            //log.DebugFormat("activated software trigger (current setting: {0})", cam.AcquisitionMode);

            cam.SetParameter("Exposure", 5.0f * 1000f);
            log.DebugFormat("exposure: {0}", cam.Exposure);

            log.DebugFormat("activating software trigger (current setting: {0})", cam.AcquisitionMode);
            cam.AcquisitionMode = MetriCam2.Cameras.Internal.SVS.GigeApi.ACQUISITION_MODE.ACQUISITION_MODE_SOFTWARE_TRIGGER;
            log.DebugFormat("activated software trigger (current setting: {0})", cam.AcquisitionMode);

            Console.WriteLine("Press Esc to quit. Press any other key to capture a frame.");
            while (true)
            {
                ConsoleKeyInfo key = Console.ReadKey();
                if (key.Key == ConsoleKey.Escape)
                {
                    break;
                }

                cam.Update();
                log.InfoFormat("Updated camera. Frame number is {0}", cam.FrameNumber);
                //cam.CalcChannel()
            }

            cam.Disconnect();
            log.Info("Camera disconnected");
        }
        private void CameraConfigurationDialog_KeyDown(object sender, KeyEventArgs e)
        {
            if (Keys.Escape == e.KeyCode)
            {
                log.DebugFormat("{0} key pressed. Closing dialog.", e.KeyCode.ToString());

                CancelDialog();
                return;
            }
        }
示例#3
0
 private void RunTest(String title, Action testMethod)
 {
     cameras.Clear();
     log.DebugFormat("\n"
                     + "=========================\n"
                     + "Test: {0}\n"
                     + "=========================\n",
                     title
                     );
     testMethod.Method.Invoke(this, new object[] { });
 }
示例#4
0
        private AccessModes GetAccessMode()
        {
            SendCommand("sMN GetAccessMode");

            bool success = ReceiveResponse(out byte[] payload, out byte checkSum);

            if (!success)
            {
                throw new InvalidOperationException("Failed to get access mode.");
            }

            byte value = payload[payload.Length - 1];

            log.DebugFormat("Got access mode: {0}", (AccessModes)value);
            return((AccessModes)value);
        }
示例#5
0
        /// <summary>
        /// Tells the device that there is a streaming channel.
        /// </summary>
        public void Control_InitStream()
        {
            log.Debug("Initializing streaming");
            byte[] toSend  = AddFraming("sMN GetBlobClientConfig");
            byte[] receive = new byte[50];

            // send ctrl message
            streamControl.Write(toSend, 0, toSend.Length);

            // get response
            if (streamControl.Read(receive, 0, receive.Length) == 0)
            {
                log.Error("Got no answer from camera");
                ExceptionBuilder.Throw(typeof(InvalidOperationException), cam, "error_setParameter", "Failed to init stream.");
            }
            else
            {
                string response = Encoding.ASCII.GetString(receive);
                log.DebugFormat("Got response: {0}", response);
            }
            log.Debug("Done: Initializing streaming");
        }
示例#6
0
 /// <summary>
 /// Scans an assembly and adds contained camera implementations known list.
 /// </summary>
 /// <param name="filename">Filename of the assembly (relative or absolute).</param>
 public void AddCamerasFromDLL(string filename)
 {
     log.DebugFormat("AddCamerasFromDLL({0})", filename);
     ScanAssembly(filename);
     InitializeCameras(false);
 }