Beispiel #1
0
        public PanoControlForm()
        {
            InitializeComponent();
            PanoramaWorker = new PanoramaAcquisitionClass();

            //Map events with delegates
            PanoramaWorker.OnShowCommentOutput             = ShowCommentOutput;
            PanoramaWorker.OnUpdateServoPosition           = UpdateServoPosition;
            PanoramaWorker.OnUpdateServoPositionWithParams = UpdateServoPosWithParams;

            PanoramaWorker.ShowNewCommentInGUI("PanoControl started");
            drawingBitMap = new Bitmap(panel1.Width, panel1.Height, panel1.CreateGraphics());
            Graphics.FromImage(drawingBitMap).Clear(Color.White);

            scanModeComboBox.SelectedIndex = 0;
            CamSelectCombo.SelectedIndex   = 0;

            //Set Default Parameters
            Params.SetDefaultValues();
            //and read further parameters from Config to make Parameters accessible from anywhere
            Params.readConfigFile();
            SetCameraParameters();
            //Update TextBoxes with parameters

            FocalLengthTextBox.Text        = Convert.ToString(Params.FocalLength, CultureInfo.InvariantCulture);
            ChipHTextBox.Text              = Convert.ToString(Params.ChipHeight, CultureInfo.InvariantCulture);
            ChipWTextBox.Text              = Convert.ToString(Params.ChipWidth, CultureInfo.InvariantCulture);
            OverlapTextBox.Text            = Convert.ToString(Params.Overlap, CultureInfo.InvariantCulture);
            ExpDelayTextBox.Text           = Convert.ToString(Params.ExposureDelay, CultureInfo.InvariantCulture);
            VibDelayTextBox.Text           = Convert.ToString(Params.VibrationDelay, CultureInfo.InvariantCulture);
            CamTriggerDurationTextBox.Text = Convert.ToString(Params.CamTriggerDuration, CultureInfo.InvariantCulture);
            SpeedXTextBox.Text             = Convert.ToString(Params.ServoSpeedX, CultureInfo.InvariantCulture);
            SpeedYTextBox.Text             = Convert.ToString(Params.ServoSpeedY, CultureInfo.InvariantCulture);

            PanoramaWorker.CalcFOV(); //Recalculate the field of view
            FOVxLabel.Text = "FOVx:       " + Params.FOVx.ToString() + "°";
            FOVyLabel.Text = "FOVy:       " + Params.FOVy.ToString() + "°";

            //Make the axes limits accessible to the serialPort-Class
            muControllerInterface.MinPan  = Params.limitX1;
            muControllerInterface.MaxPan  = Params.limitX2;
            muControllerInterface.MinTilt = Params.limitY1;
            muControllerInterface.MaxTilt = Params.limitY2;

            COMcomboBox.Items.Clear();
            var result = muControllerInterface.GetAvailableCOMPorts();

            //In case there are no COMPORTS available

            if (result[0] == "No Port Available")
            {
                return;
            }
            COMcomboBox.Items.Clear();
            COMcomboBox.Items.AddRange(result.ToArray());
            COMcomboBox.SelectedIndex = 0;

            //Set start position
            Params.CurServoPosX = Params.InitPosX / Params.ConvFacX;
            Params.CurServoPosY = Params.InitPosY / Params.ConvFacY;

            //Init  servos and move to start position
            muControllerInterface.InitServo(Params.CurServoPosX, Params.CurServoPosY, Params.ServoSpeedX, Params.ServoSpeedY, Params.COMPortName, Params.BTbaudrate);
            UpdateServoPosition();
            Params.StopAcquisition = false;
        }