private void ShutterTestButton_Click(object sender, EventArgs e) { Thread.Sleep(200); PanoramaWorker.CamShutter(); //Wait until we get an answer from the camera - that the flash has fired - or until the waitTime is over var totalDelayTime = 0; var waitTime = Convert.ToInt32((Params.ExposureDelay) * 1000); var camStatus = muControllerInterface.ReqCameraStatus(); if (camStatus) { CommentRTB.AppendText("CamStatus=false " + "\n"); } else { CommentRTB.AppendText("CamStatus is true " + "\n"); } while (!muControllerInterface.ReqCameraStatus()) { CommentRTB.AppendText("Waiting for Camera response... " + "\n"); Thread.Sleep(100); totalDelayTime = totalDelayTime + 100; if (totalDelayTime >= waitTime) { CommentRTB.AppendText("Warning: Timeout - no exposure response from camera (is the flash activated!?)" + "\n"); CommentRTB.Focus(); CommentRTB.ScrollToCaret(); break; } } }
private void StopButton_Click(object sender, EventArgs e) { Params.StopAcquisition = true; SystemSounds.Beep.Play(); CommentRTB.AppendText("Pano acquisition stopped" + "\n"); CommentRTB.Focus(); CommentRTB.ScrollToCaret(); PapyWizardHelper.ClosePositionDataXMLFiles(); }
//Calculate the new acquisition grid private void UpdateAcquisitionGrid() { double endX, endY; CommentRTB.AppendText("Model update" + "\n"); CommentRTB.Focus(); CommentRTB.ScrollToCaret(); //if mode ==1 then the grid is determined by start point,end point and FOV if (Params.PanoModus == 1) { Params.deltaX = Params.FOVx * (100 - Params.Overlap) / 100; Params.deltaY = Params.FOVy * (100 - Params.Overlap) / 100; Params.numX = 1 + Math.Abs(Convert.ToInt32((Params.EndPosX - Params.StartPosX) / Params.deltaX)); Params.numY = 1 + Math.Abs(Convert.ToInt32((Params.EndPosY - Params.StartPosY) / Params.deltaY)); //Give the delta-values a sign if (Params.EndPosX < Params.StartPosX) { Params.deltaX = Params.deltaX * (-1); } if (Params.EndPosY < Params.StartPosY) { Params.deltaY = Params.deltaY * (-1); } Params.validModel = true; } //if mode == 2 then the grid is determined by start point and NumImages else if (Params.PanoModus == 2) { Params.deltaX = Params.FOVx * (100 - Params.Overlap) / 100; Params.deltaY = Params.FOVy * (100 - Params.Overlap) / 100; endX = Params.ConvFacX * (Params.StartPosX + Params.numX * Params.deltaX); //End position in servo units endY = Params.ConvFacY * (Params.StartPosY + Params.numY * Params.deltaY); //Check if the end position is within the servo limits if ((endX < Params.limitX1) || (endX > Params.limitX2) || (endY < Params.limitY1) || (endY > Params.limitY2)) { //Warning: out of Servo range Params.validModel = false; CommentRTB.AppendText("Error in UpdateAcquisitionGrid: calculated end position beyond servo limits!\n"); CommentRTB.Focus(); CommentRTB.ScrollToCaret(); return; } Params.validModel = true; //ready to go } //Update output of the panorama size NumXTextBox.Text = Params.numX.ToString(); NumYTextBox.Text = Params.numY.ToString(); }
private void ChipHTextBox_Leave(object sender, EventArgs e) { ChipHTextBox.Text = ValidateDouble(ChipHTextBox.Text, 26, 1, 100).ToString(CultureInfo.InvariantCulture); Params.changeParam = 6; Params.ChipHeight = Convert.ToDouble(ChipHTextBox.Text, CultureInfo.InvariantCulture); var fovCheck = CalculationsHelper.CalcFOV(); CommentRTB.AppendText(fovCheck + "\n"); CommentRTB.Focus(); CommentRTB.ScrollToCaret(); FOVxLabel.Text = "FOVx: " + Params.FOVx.ToString() + "°"; FOVyLabel.Text = "FOVy: " + Params.FOVy.ToString() + "°"; }
private void DisconnectButton_Click(object sender, EventArgs e) { //Close serial port ConnectButton.Enabled = true; DisconnectButton.Enabled = false; Params.connected = false; if (muControllerInterface.myPort.IsOpen == true) { muControllerInterface.ClosePort(); CommentRTB.AppendText("COM-Port closed" + "\n"); CommentRTB.Focus(); CommentRTB.ScrollToCaret(); } }
private void MoveDownButton_Click(object sender, EventArgs e) { if (Params.AcquisitionRunning == true) { return; } Params.CurServoPosY = Params.CurServoPosY + Params.MoveStepDeltaY; muControllerInterface.MoveServo(Params.COMPortName, Params.BTbaudrate, 1, Params.CurServoPosY); CommentRTB.AppendText("ServoPosY " + Params.CurServoPosY.ToString() + "\n"); CommentRTB.Focus(); CommentRTB.ScrollToCaret(); Thread.Sleep(100); UpdateServoPosition(); }
private void FocalLengthTextBox_Leave(object sender, EventArgs e) { //A new focal length was entered //if there was a valid solution - calculate a new solution FocalLengthTextBox.Text = ValidateDouble(FocalLengthTextBox.Text, 420, 1, 2000).ToString(CultureInfo.InvariantCulture); Params.changeParam = 3; Params.FocalLength = Convert.ToDouble(FocalLengthTextBox.Text, CultureInfo.InvariantCulture); var fovCheck = CalculationsHelper.CalcFOV(); CommentRTB.AppendText(fovCheck + "\n"); CommentRTB.Focus(); CommentRTB.ScrollToCaret(); FOVxLabel.Text = "FOVx: " + Params.FOVx.ToString() + "°"; FOVyLabel.Text = "FOVy: " + Params.FOVy.ToString() + "°"; }
private void StopButton_Click(object sender, EventArgs e) { Params.StopAcquisition = true; SystemSounds.Beep.Play(); CommentRTB.AppendText("Pano acquisition stopped" + "\n"); CommentRTB.Focus(); CommentRTB.ScrollToCaret(); PapyWizardHelper.ClosePositionDataXMLFiles(); if (backgroundWorker.IsBusy) { backgroundWorker.CancelAsync(); } StartButton.Enabled = true; StopButton.Enabled = false; PauseButton.Enabled = false; ContinueButton.Enabled = false; }
private void CamSelectCombo_SelectedIndexChanged(object sender, EventArgs e) { SetCameraParameters(); 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); VibDelayTextBox.Text = Convert.ToString(Params.VibrationDelay, CultureInfo.InvariantCulture); ExpDelayTextBox.Text = Convert.ToString(Params.ExposureDelay, CultureInfo.InvariantCulture); var fovCheck = CalculationsHelper.CalcFOV(); CommentRTB.AppendText(fovCheck + "\n"); CommentRTB.Focus(); CommentRTB.ScrollToCaret(); FOVxLabel.Text = "FOVx: " + Params.FOVx.ToString() + "°"; FOVyLabel.Text = "FOVy: " + Params.FOVy.ToString() + "°"; }
private void SetEndPointButton_Click(object sender, EventArgs e) { //set end point for the panorama acquisition Params.EndPosX = Params.CurServoPosX; Params.EndPosY = Params.CurServoPosY; double x = Math.Round(GetShowCoordinate(Params.EndPosX, 0), 2); double y = Math.Round(GetShowCoordinate(Params.EndPosY, 1), 2); EndPosXlabel.Text = x.ToString(); EndPosYlabel.Text = y.ToString(); Params.ValidEndPosSet = true; Params.changeParam = 2; if (Params.ValidStartPosSet == true) //Start and Endpoint set - > Panorama is Made from these two points { Params.PanoModus = 1; UpdateAcquisitionGrid(); //Update the PanoramaModel } CommentRTB.AppendText("End Point set" + "\n"); CommentRTB.Focus(); CommentRTB.ScrollToCaret(); }
private void ConnectButton_Click(object sender, EventArgs e) { String COMName; try { //Open serial port ConnectButton.Enabled = false; DisconnectButton.Enabled = true; Params.connected = true; if (muControllerInterface.myPort.IsOpen == true) { muControllerInterface.ClosePort(); } //if we selected something with COM than change the name, otherwise keep the old name COMName = COMcomboBox.Text; if (COMName.Contains("COM")) { Params.COMPortName = COMName; } if (muControllerInterface.myPort.IsOpen == false) { muControllerInterface.OpenPort(Params.COMPortName, Params.BTbaudrate); } } catch { CommentRTB.AppendText("Problem while opening COM Port" + "\n"); CommentRTB.Focus(); CommentRTB.ScrollToCaret(); } }
private void StartButton_Click(object sender, EventArgs e) { UpdateAcquisitionGrid(); //AcquirePanorama(Params.StartPosX, Params.StartPosX + Params.numX * Params.deltaX, Params.deltaX, Params.StartPosY, Params.StartPosY + Params.numY * Params.deltaY, Params.deltaY, Params.MoveModus); if (Params.AcquisitionProcessExists == true) { return; } if (backgroundWorker.IsBusy) { return; } Params.AcquisitionProcessExists = true; //Now we have an AcquisitionProcess backgroundWorker.DoWork += Worker_AcquirePanorama; backgroundWorker.ProgressChanged += Worker_ProgressChanged; backgroundWorker.WorkerReportsProgress = true; backgroundWorker.RunWorkerCompleted += Worker_RunWorkerCompleted; //Then, we set the Worker off. //This triggers the DoWork event. //Notice the word Async - it means that Worker gets its own thread, //and the main thread will carry on with its own calculations separately. //We can pass any data that the worker needs as a parameter. backgroundWorker.RunWorkerAsync(); StartButton.Enabled = false; StopButton.Enabled = true; PauseButton.Enabled = true; ContinueButton.Enabled = false; CommentRTB.AppendText("Pano acquisition started" + "\n"); CommentRTB.Focus(); CommentRTB.ScrollToCaret(); // PanoramaWorker.AcquirePanorama(Params.StartPosX, Params.StartPosX + Params.numX * Params.deltaX, Params.deltaX, Params.StartPosY, Params.StartPosY + Params.numY * Params.deltaY, Params.deltaY, Params.MoveModus); // PapyWizardHelper.ClosePositionDataXMLFiles(); }
//ShowCommentOutput shows Infotext and can subscribes to events from other classes public void ShowCommentOutput(String CommentText) { CommentRTB.AppendText(CommentText); CommentRTB.Focus(); CommentRTB.ScrollToCaret(); }
public PanoControlForm() { InitializeComponent(); this.backgroundWorker = new BackgroundWorker(); this.backgroundWorker.WorkerSupportsCancellation = true; 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); var fovCheck = CalculationsHelper.CalcFOV(); CommentRTB.AppendText(fovCheck + "\n"); CommentRTB.Focus(); CommentRTB.ScrollToCaret(); 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; }