Ejemplo n.º 1
0
        public static PartLocation DownCamera_Calibration(CameraView cv, double moveDistance)
        {
            var cnc = Global.Instance.cnc;
            cnc.Zup();
            cv.SetDownCameraFunctionSet("Homing");

            // do calibration
            var ret = DoCameraCalibration(cv.downVideoProcessing, new PartLocation(moveDistance, moveDistance));
            cnc.Zup();

            cv.DownCameraReset();
            return ret;
        }
        public static PartLocation DownCamera_Calibration(CameraView cv, double moveDistance)
        {
            var cnc = Global.Instance.cnc;

            cnc.Zup();
            cv.SetDownCameraFunctionSet("Homing");

            // do calibration
            var ret = DoCameraCalibration(cv.downVideoProcessing, new PartLocation(moveDistance, moveDistance));

            cnc.Zup();

            cv.DownCameraReset();
            return(ret);
        }
Ejemplo n.º 3
0
        public static PartLocation UpCamera_Calibration(CameraView cv, double moveDistance)
        {
            var cnc = Global.Instance.cnc;

            cv.SetUpCameraFunctionSet("Needle");
            // move to upcamera position
            cnc.Zup();
            Global.GoTo("Up Camera");
            cnc.Zdown(Settings.Default.focus_height, true);
            // do calibration
            var ret = DoCameraCalibration(cv.upVideoProcessing, new PartLocation(moveDistance, moveDistance));
            cnc.Zup();
            cv.UpCameraReset();
            return ret;
        }
        public static PartLocation UpCamera_Calibration(CameraView cv, double moveDistance)
        {
            var cnc = Global.Instance.cnc;

            cv.SetUpCameraFunctionSet("Needle");
            // move to upcamera position
            cnc.Zup();
            Global.GoTo("Up Camera");
            cnc.Zdown(Settings.Default.focus_height, true);
            // do calibration
            var ret = DoCameraCalibration(cv.upVideoProcessing, new PartLocation(moveDistance, moveDistance));

            cnc.Zup();
            cv.UpCameraReset();
            return(ret);
        }
        public static void UpCamera_MultiCalibration(CameraView cv, double moveDistance)
        {
            var cnc = Global.Instance.cnc;

            cv.SetUpCameraFunctionSet("Needle");
            // move to upcamera position

            for (int z = 0; z < 30; z += 5)
            {
                Global.GoTo("Up Camera");
                cnc.ZGuardOff();
                cnc.CNC_Z(z);
                var ret = DoCameraCalibration(cv.upVideoProcessing, new PartLocation(moveDistance, .1));
                Global.Instance.mainForm.ShowSimpleMessageBox(String.Format("z={0}  dx={1}  dy={2}", z, ret.X, ret.Y));
            }

            cnc.Zup();
            cv.UpCameraReset();
        }
Ejemplo n.º 6
0
        public FormMain() {
            InitializeComponent();
            setupQueuedMessages(); //error handling

            Do_Upgrade();

            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

            // setup objects
            Cnc = new CNC(this);
            CNC.SquareCorrection = Properties.Settings.Default.CNC_SquareCorrection;

            Needle = new NeedleClass(this);
            Tapes = new TapesClass(Tapes_dataGridView, Needle, Cnc, this);
            Cad = new CAD(this);
            Locations = new LocationManager();

            Global.Instance.cnc = Cnc;
            Global.Instance.needle = Needle;
            Global.Instance.mainForm = this;
            Global.Instance.Locations = Locations;

            // open camera form
            // show the camera view stuff right away
            cameraView = new CameraView();
            cameraView.Show();
            cameraView.SetDownCameraDefaults();
            cameraView.SetUpCameraDefaults();
            cameraView.downClickDelegate = DownClickDelegate;
            cameraView.upClickDelegate = UpClickDelegate;

            //setup location jumps
            UpdateGoToPulldownMenu();
            Locations.GetList().ListChanged += delegate { 
                UpdateGoToPulldownMenu();
                Locations.Save();
            }; //update if list changed
            Locations.LocationChangeEvent += (s, e) => {
                if (e.PropertyName.Equals("Name")) UpdateGoToPulldownMenu();
                Locations.Save();
            }; //update if name on list changes

            //setup table entry dragging
            componentDrag = new DataGridDrag(CadData_GridView);
            locationDrag = new DataGridDrag(locations_dataGridView);
            tapeDrag = new DataGridDrag(Tapes_dataGridView);
            jobDrag = new DataGridDrag(JobData_GridView);

            //setup table bindings
            CadData_GridView.DataSource = Cad.ComponentData;
            locations_dataGridView.DataSource = Locations.GetList();            
            Tapes_dataGridView.DataSource = Tapes.tapeObjs;
            OriginalPartOrientation.DataSource = TapeObj.Orientation;
            OriginalTapeOrientation.DataSource = TapeObj.Orientation;
            UpdateTapeTypesBinding();
            PartType.DataSource = Enum.GetNames(typeof(ComponentType));

            //jobs table
            JobData_GridView.DataSource = Cad.JobData;
            methodDataGridViewComboBoxColumn.DataSource = new[] {"?", "Place", "LoosePlace", "Change Needle", "Recalibrate", "Ignore", "Pause", "Fiducial", "Place With UpCam"};
            // apply changes to multiple placement types at once
            JobData_GridView.CellValueChanged += (o, e) => {
                if (e.ColumnIndex != 3) return;
                for (int i = 0; i < JobData_GridView.SelectedCells.Count; i++) {
                    if (JobData_GridView.SelectedCells[i].ColumnIndex == 3) {
                        ((JobData)JobData_GridView.SelectedCells[i].OwningRow.DataBoundItem).Method =
                            ((JobData)JobData_GridView.Rows[e.RowIndex].DataBoundItem).Method;

                    }
                }
            };

            // right click context menu
            CadData_GridView.CellMouseDown += CadData_CellMouseDown;
            JobData_GridView.CellMouseDown += JobData_CellMouseDown;
            Tapes_dataGridView.CellMouseDown += Tapes_CellMouseDown;

            // setup key handling
            KeyPreview = true;
            SetupCursorNavigation(Controls);
            KeyUp += My_KeyUp;

            instructions_label.Text = "";
            instructions_label.Visible = false;

            // setup a bunch of stuff on the forms
            LightPlacerFormsSetup();
        }
Ejemplo n.º 7
0
        public FormMain() {
            InitializeComponent();
            setupQueuedMessages(); //error handling

            Do_Upgrade();

            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");

            // setup objects
            Cnc = new CNC(this);
            CNC.SquareCorrection = Properties.Settings.Default.CNC_SquareCorrection;

            Needle = new NeedleClass(this);
            Tapes = new TapesClass(Tapes_dataGridView, Needle, Cnc, this);
            Cad = new CAD(this);
            Locations = new LocationManager();

            Global.Instance.cnc = Cnc;
            Global.Instance.needle = Needle;
            Global.Instance.mainForm = this;
            Global.Instance.Locations = Locations;

            // open camera form
            // show the camera view stuff right away
            cameraView = new CameraView();
            cameraView.Show();
            cameraView.SetDownCameraDefaults();
            cameraView.SetUpCameraDefaults();
            cameraView.downClickDelegate = DownClickDelegate;
            cameraView.upClickDelegate = UpClickDelegate;

            nozzleChanger = new NozzleChanger();
            nozzleChanger.InitializeObject(dataGridNozzes, datagridLoadSequence, Needle, Cnc, this);
            //listNozzles.DataSource = nozzleChanger.nozzles;
            nozzleChanger.ReLoad();
            dataGridNozzes.DataSource = nozzleChanger.nozzles;
            textBoxNozzleSpeed.Text = nozzleChanger.Speed;

            (dataGridNozzes.Columns[2] as DataGridViewComboBoxColumn).DataSource =
                new BindingSource { DataSource = cameraView.upSet.GetNames() };
            Needle.nozzleChanger = nozzleChanger;
            nozzleChangerEnabled.Checked = nozzleChanger.Enabled;

            //setup location jumps
            UpdateGoToPulldownMenu();
            Locations.GetList().ListChanged += delegate { 
                UpdateGoToPulldownMenu();
                Locations.Save();
            }; //update if list changed
            Locations.LocationChangeEvent += (s, e) => {
                if (e.PropertyName.Equals("Name")) UpdateGoToPulldownMenu();
                Locations.Save();
            }; //update if name on list changes

            //setup table entry dragging
            componentDrag = new DataGridDrag(CadData_GridView);
            locationDrag = new DataGridDrag(locations_dataGridView);
            tapeDrag = new DataGridDrag(Tapes_dataGridView);
            jobDrag = new DataGridDrag(JobData_GridView);

            //setup table bindings
            CadData_GridView.DataSource = Cad.ComponentData;
            locations_dataGridView.DataSource = Locations.GetList();            
            Tapes_dataGridView.DataSource = Tapes.tapeObjs;
            OriginalPartOrientation.DataSource = TapeObj.Orientation;
            OriginalTapeOrientation.DataSource = TapeObj.Orientation;
            UpdateTapeTypesBinding();
            PartType.DataSource = Enum.GetNames(typeof(ComponentType));

            (Tapes_dataGridView.Columns["Nozzle"] as DataGridViewComboBoxColumn).DataSource =
                new BindingSource { DataSource = nozzleChanger.getIDs() };

            //jobs table
            JobData_GridView.DataSource = Cad.JobData;
            methodDataGridViewComboBoxColumn.DataSource = new[] {"?", "Place", "LoosePlace", "Change Needle", "Recalibrate", "Ignore", "Pause", "Fiducial", "Place With UpCam", "Change nozzle", "ERROR" };
            // apply changes to multiple placement types at once
            JobData_GridView.CellValueChanged += (o, e) => {
                if (e.ColumnIndex != 3) return;
                for (int i = 0; i < JobData_GridView.SelectedCells.Count; i++) {
                    if (JobData_GridView.SelectedCells[i].ColumnIndex == 3) {
                        ((JobData)JobData_GridView.SelectedCells[i].OwningRow.DataBoundItem).Method =
                            ((JobData)JobData_GridView.Rows[e.RowIndex].DataBoundItem).Method;

                    }
                }
            };

            // right click context menu
            CadData_GridView.CellMouseDown += CadData_CellMouseDown;
            JobData_GridView.CellMouseDown += JobData_CellMouseDown;
            Tapes_dataGridView.CellMouseDown += Tapes_CellMouseDown;

            // setup key handling
            KeyPreview = true;
            SetupCursorNavigation(Controls);
            KeyUp += My_KeyUp;

            instructions_label.Text = "";
            instructions_label.Visible = false;

            // setup a bunch of stuff on the forms
            LightPlacerFormsSetup();

            VisibilityGraph = new visibilitygraph();
            VisibilityGraph = VisibilityGraph.ReLoad();
            if (VisibilityGraph == null) { VisibilityGraph = new visibilitygraph(); }
            VisibilityGraph.drawingSurface = this.pictureBox1;
            VisibilityGraph.setBounds(0, 0, Locations.GetLocation("Max Machine").X, Locations.GetLocation("Max Machine").Y);
            /*
            VisibilityGraph.insertGuard(50, 0, 50, 50);
            VisibilityGraph.insertGuard(50, 50, Locations.GetLocation("Max Machine").X, 50);

            VisibilityGraph.insertGuard(200, 200, 200, 150);
            VisibilityGraph.insertGuard(200, 150, 500, 150);
            VisibilityGraph.insertGuard(500, 150, 500, 200);
            VisibilityGraph.insertGuard(500, 200, 200, 200);
            */
            dataGridGuards.DataSource = VisibilityGraph.Guards;
            checkBoxUseGuards.Checked = VisibilityGraph.Enabled;
            updateDataGridGuard();

            Cnc.RawWrite("{\"gc\":\"G1 F100 Y0\"}");
            Thread.Sleep(100);
            Cnc.RawWrite("!%");
            
        }
Ejemplo n.º 8
0
        public static void UpCamera_MultiCalibration(CameraView cv, double moveDistance)
        {
            var cnc = Global.Instance.cnc;

            cv.SetUpCameraFunctionSet("Needle");
            // move to upcamera position

            for (int z = 0; z < 30; z += 5) {
                Global.GoTo("Up Camera");
                cnc.ZGuardOff();
                cnc.CNC_Z(z);
                var ret = DoCameraCalibration(cv.upVideoProcessing, new PartLocation(moveDistance, .1));
                Global.Instance.mainForm.ShowSimpleMessageBox(String.Format("z={0}  dx={1}  dy={2}", z, ret.X, ret.Y));
            }

            cnc.Zup();
            cv.UpCameraReset();
        }