Beispiel #1
0
        private void Method_textBox_Click(object sender, EventArgs e)
        {
            if (!Method_textBox.Enabled)
            {
                return;
            }
            ;
            MethodSelectionForm MethodDialog = new MethodSelectionForm();

            MethodDialog.ShowDialog(this);
            Method_textBox.Text = MethodDialog.SelectedMethod;
            Method = MethodDialog.SelectedMethod;
            MethodDialog.Dispose();
        }
Beispiel #2
0
        // =================================================================================
        // This routine places the [index] row from Job data grid view:
        private bool PlaceRow_m(int RowNo)
        {
            DisplayText("PlaceRow_m(" + RowNo.ToString() + ")", KnownColor.Blue);
            // Select the row and keep it visible
            JobData_GridView.Rows[RowNo].Selected = true;
            HandleGridScrolling(false, JobData_GridView);

            string[] Components;  // This array has the list of components to place:
            string NewID = "";
            bool RestoreRow = false;
            // RestoreRow: If we'll replace the jobdata row with new data at the end. 
            // There isn't any new data, unless method is "?".

            // If the Method is "?", ask the user what to do:
            DataGridViewRow tempRow = (DataGridViewRow)JobData_GridView.Rows[RowNo].Clone();
            if (JobData_GridView.Rows[RowNo].Cells["GroupMethod"].Value.ToString() == "?")
            {
                // We'll now get new data from the user. By default, we don't mess with the data we have
                // So, take a copy of current row
                RestoreRow = true;
                for (int i = 0; i < tempRow.Cells.Count; i++)
                {
                    tempRow.Cells[i].Value = JobData_GridView.Rows[RowNo].Cells[i].Value;
                }

                // Display Method selection form:
                bool UserHasNotDecided = false;
                string NewMethod;
                MethodSelectionForm MethodDialog = new MethodSelectionForm();
                do
                {
                    MethodDialog.ShowCheckBox = true;
                    MethodDialog.HeaderString = CurrentGroup_label.Text;
                    MethodDialog.ShowDialog(this);
                    if (Properties.Settings.Default.Placement_UpdateJobGridAtRuntime)
                    {
                        RestoreRow = false;
                    };
                    NewMethod = MethodDialog.SelectedMethod;
                    if ((NewMethod == "Place") || (NewMethod == "Place Fast"))
                    {
                        // show the tape selection dialog
                        NewID = SelectTape("Select tape for " + JobData_GridView.Rows[RowNo].Cells["ComponentType"].Value.ToString());
                        if (!Properties.Settings.Default.Placement_UpdateJobGridAtRuntime)
                        {
                            RestoreRow = true;   // In case user unselected it at the tape selection dialog
                        };

                        if (NewID == "none")
                        {
                            UserHasNotDecided = true; // User did select "Place", but didn't select TapeNumber, we'll ask again.
                        }
                        else if (NewID == "Ignore")
                        {
                            NewMethod = "Ignore";
                            NewID = "";
                        }
                        else if (NewID == "Abort")
                        {
                            NewMethod = "Ignore";
                            NewID = "";
                            AbortPlacement = true;
                            RestoreRow = true;		// something went astray, keep method at "?"
                        }
                    }

                } while (UserHasNotDecided);
                if (NewMethod == "")
                {
                    return false;   // user pressed x
                }
                // Put the values to JobData_GridView
                JobData_GridView.Rows[RowNo].Cells["GroupMethod"].Value = NewMethod;
                JobData_GridView.Rows[RowNo].Cells["MethodParamAllComponents"].Value = NewID;
                Update_GridView(JobData_GridView);
                MethodDialog.Dispose();
            }
            // Method is now selected, even if it was ?. If user quits the operation, PlaceComponent_m() notices.

            // The place operation does not necessarily have any components for it (such as a needle change).
            // Make sure there is valid data at ComponentList anyway.
            if (JobData_GridView.Rows[RowNo].Cells["ComponentList"].Value == null)
            {
                JobData_GridView.Rows[RowNo].Cells["ComponentList"].Value = "--";
            };
            if (JobData_GridView.Rows[RowNo].Cells["ComponentList"].Value.ToString() == "--")
            {
                Components = new string[] { "--" };
            }
            else
            {
                Components = JobData_GridView.Rows[RowNo].Cells["ComponentList"].Value.ToString().Split(',');
            };
            bool ReturnValue = true;

            // Prepare for placement
            bool FirstInRow = true;
            if (JobData_GridView.Rows[RowNo].Cells["GroupMethod"].Value.ToString() == "Place Fast")
            {
                string TapeID = JobData_GridView.Rows[RowNo].Cells["MethodParamAllComponents"].Value.ToString();
                int count;
                if (!int.TryParse(JobData_GridView.Rows[RowNo].Cells["ComponentCount"].Value.ToString(), out count))
                {
                    ShowMessageBox(
                        "Bad data at component count",
                        "Sloppy programmer error",
                        MessageBoxButtons.OK);
                    return false;
                }
                if (!Tapes.PrepareForFastPlacement_m(TapeID, count))
                {
                    return false;
                }
                Tapes.FastParametersOk = true;
            }
            // Place parts:
            foreach (string Component in Components)
            {
                if (!PlaceComponent_m(Component, RowNo, FirstInRow))
                {
                    JobData_GridView.Rows[RowNo].Selected = false;
                    ReturnValue = false;
                    Tapes.FastParametersOk = false;
                    break;
                };
                FirstInRow = false;
            };
            Tapes.FastParametersOk = false;

            // restore the row if needed
            if (RestoreRow)
            {
                for (int i = 0; i < tempRow.Cells.Count; i++)
                {
                    JobData_GridView.Rows[RowNo].Cells[i].Value = tempRow.Cells[i].Value;
                }
                Update_GridView(JobData_GridView);
            };

            JobData_GridView.Rows[RowNo].Selected = false;
            return ReturnValue;
        }
Beispiel #3
0
        // =================================================================================
        // JobData editing
        // =================================================================================
        private void JobData_GridView_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            if (JobData_GridView.CurrentCell.ColumnIndex == 2)
            {
                // For method, show a form with explanation texts
                MethodSelectionForm MethodDialog = new MethodSelectionForm();
                MethodDialog.ShowCheckBox = false;
                MethodDialog.ShowDialog(this);
                if (MethodDialog.SelectedMethod != "")
                {
                    foreach (DataGridViewCell cell in JobData_GridView.SelectedCells)
                    {
                        JobData_GridView.Rows[cell.RowIndex].Cells[2].Value = MethodDialog.SelectedMethod;
                    }
                }
                Update_GridView(JobData_GridView);
                return;
            };

            if (JobData_GridView.CurrentCell.ColumnIndex == 3)
            {
                // For method parameter, show the tape selection form if method is "place" 
                int row = JobData_GridView.CurrentCell.RowIndex;
                if ((JobData_GridView.Rows[row].Cells["GroupMethod"].Value.ToString() == "Place") ||
                     (JobData_GridView.Rows[row].Cells["GroupMethod"].Value.ToString() == "Place Fast"))
                {
                    JobData_GridView.Rows[row].Cells["MethodParamAllComponents"].Value = SelectTape("Select tape for "
                        + JobData_GridView.Rows[row].Cells["ComponentType"].Value.ToString());
                    Update_GridView(JobData_GridView);
                    return;
                }
            }
        }
Beispiel #4
0
     /*   // =================================================================================
        // This routine places selected component(s) from CAD data grid view:
        private void PlaceOne_button_Click(object sender, EventArgs e) {
            var selectedCount = CadData_GridView.SelectedCells.Count;
            if (selectedCount == 0) {
                CleanupPlacement(false);
                ShowSimpleMessageBox("Nothing selected");
                return;
            }

            if (!PrepareToPlace_m()) {
                ShowSimpleMessageBox("Placement operation failed, nothing done.");
                return;
            }
            List<PhysicalComponent> toPlace = new List<PhysicalComponent>();
            for (int i = 0; i < selectedCount; i++) {
                var component = (PhysicalComponent)CadData_GridView.SelectedCells[i].OwningRow.DataBoundItem;
                if (component.JobData == null) {
                    component.JobData = Cad.FindJobDataThatContainsComponent(component);
                    if (component.JobData == null) {
                        ShowSimpleMessageBox("No Job Action Found That Matches This Component - Job File Corrupt");
                        CleanupPlacement(false);
                        return;
                    }
                }
                if (!toPlace.Contains(component)) toPlace.Add(component);
            }

            if (!PlaceComponents(toPlace)) {
                ShowSimpleMessageBox("Placement operation failed. Review job status.");
                CleanupPlacement(false);
                return;
            }

            CleanupPlacement(true);

        }*/

        // =================================================================================
        // This routine places the [index] row from Job data grid view:
        private bool PlaceComponents(List<PhysicalComponent> components) {
            DisplayText("Placing " + string.Join(",", components.Select(x => x.Designator)));

            foreach (var component in components) {
                if (component.JobData.Method == null || component.JobData.Method.Equals("?")) {
                    MethodSelectionForm MethodDialog = new MethodSelectionForm();
                    MethodDialog.ShowCheckBox = true;
                    // MethodDialog.HeaderString = CurrentGroup_label.Text;
                    MethodDialog.ShowDialog(this);

                    switch (MethodDialog.SelectedMethod) {
                        case "Place":
                        case "Place Fast":
                            var NewID = SelectTape("Select tape for " + component.TypePlusFootprint);
                            component.Method = MethodDialog.SelectedMethod;
                            component.MethodParameters = NewID;
                            break;
                        case "": //user pressed x
                            return false;
                        case "none":
                            break;
                        case "Ignore":
                            component.Method = "Ignore";
                            component.MethodParameters = "";
                            break;
                        case "Abort":
                            AbortPlacement = true;
                            component.Method = "Ignore";
                            component.MethodParameters = "";
                            break;
                        default:
                            component.JobData.Method = MethodDialog.SelectedMethod;
                            break;
                    }
                    MethodDialog.Dispose();
                }
            }

            foreach (var component in components) {
                if (AbortPlacement) { return false; }
                if (!PlaceComponent(component)) 
                    if (!ignoreErrors_checkbox.Checked) return false;
            }
            return true;
        }
Beispiel #5
0
		private void Method_textBox_Click(object sender, EventArgs e)
		{
			if (!Method_textBox.Enabled)
			{
				return;
			};
			MethodSelectionForm MethodDialog = new MethodSelectionForm();
			MethodDialog.ShowDialog(this);
			Method_textBox.Text = MethodDialog.SelectedMethod;
			Method = MethodDialog.SelectedMethod;
			MethodDialog.Dispose();
		}
Beispiel #6
0
     /*   // =================================================================================
        // This routine places selected component(s) from CAD data grid view:
        private void PlaceOne_button_Click(object sender, EventArgs e) {
            var selectedCount = CadData_GridView.SelectedCells.Count;
            if (selectedCount == 0) {
                CleanupPlacement(false);
                ShowSimpleMessageBox("Nothing selected");
                return;
            }

            if (!PrepareToPlace_m()) {
                ShowSimpleMessageBox("Placement operation failed, nothing done.");
                return;
            }
            List<PhysicalComponent> toPlace = new List<PhysicalComponent>();
            for (int i = 0; i < selectedCount; i++) {
                var component = (PhysicalComponent)CadData_GridView.SelectedCells[i].OwningRow.DataBoundItem;
                if (component.JobData == null) {
                    component.JobData = Cad.FindJobDataThatContainsComponent(component);
                    if (component.JobData == null) {
                        ShowSimpleMessageBox("No Job Action Found That Matches This Component - Job File Corrupt");
                        CleanupPlacement(false);
                        return;
                    }
                }
                if (!toPlace.Contains(component)) toPlace.Add(component);
            }

            if (!PlaceComponents(toPlace)) {
                ShowSimpleMessageBox("Placement operation failed. Review job status.");
                CleanupPlacement(false);
                return;
            }

            CleanupPlacement(true);

        }*/

        // =================================================================================
        // This routine places the [index] row from Job data grid view:
        private bool PlaceComponents(List<PhysicalComponent> components) {
            DisplayText("Placing " + string.Join(",", components.Select(x => x.Designator)));

            foreach (var component in components) {
                if (component.JobData.Method == null || component.JobData.Method.Equals("?")) {
                    MethodSelectionForm MethodDialog = new MethodSelectionForm();
                    MethodDialog.ShowCheckBox = true;
                    // MethodDialog.HeaderString = CurrentGroup_label.Text;
                    MethodDialog.ShowDialog(this);

                    switch (MethodDialog.SelectedMethod) {
                        case "Place":
                        case "Place Fast":
                            var NewID = SelectTape("Select tape for " + component.TypePlusFootprint);
                            component.Method = MethodDialog.SelectedMethod;
                            component.MethodParameters = NewID;
                            break;
                        case "": //user pressed x
                            return false;
                        case "none":
                            break;
                        case "Ignore":
                            component.Method = "Ignore";
                            component.MethodParameters = "";
                            break;
                        case "Abort":
                            AbortPlacement = true;
                            component.Method = "Ignore";
                            component.MethodParameters = "";
                            break;
                        default:
                            component.JobData.Method = MethodDialog.SelectedMethod;
                            break;
                    }
                    MethodDialog.Dispose();
                }
            }

            foreach (var component in components) {
                if (AbortPlacement) { return false; }

                if (component.MethodParameters == null) { return false; }
                string tapeNozzle = Tapes.GetTapeObjByID(component.MethodParameters).Nozzle;

                if (nozzleChanger.Enabled && (tapeNozzle == null))
                {
                    ShowSimpleMessageBox("No nozzle specified for tape, aborting.");
                    return false;
                }

                if ((component.Method == "Place" || component.Method == "Place Fast") && nozzleChanger.Enabled && 
                    (nozzleChanger.GetLoadedNozzle() == null || tapeNozzle != nozzleChanger.GetLoadedNozzle().Id))
                {
                    nozzleChanger.LoadNozzle(tapeNozzle);
                    if (!CalibrateNeedle_m()) { return false;  }
                }

                if (!PlaceComponent(component)) {
                    if (component.IsError)
                    {
                        foreach (var comp in components)
                        {
                            if (comp.MethodParameters == component.MethodParameters)
                            {
                                comp.IsError = true;
                            }
                        }
                        for (int i = 0; i < JobData_GridView.Rows.Count; i++)
                        {
                            if (((JobData) JobData_GridView.Rows[i].DataBoundItem).MethodParameters == component.MethodParameters)
                            {
                                ((JobData)JobData_GridView.Rows[i].DataBoundItem).Method = "ERROR";
                            }
                        }
                    }
                    if (!ignoreErrors_checkbox.Checked) return false;
                }
            }
            return true;
        }