Esempio n. 1
0
 private void syncToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (MSLink == null)
     {
         MSLink = new List <long[]>();
     }
     if (linkMS == null)
     {
         linkMS = new comparator();
     }
     linkMS.Compare(bvMaster.Blobs, bvSlave.Blobs, MSLink);
     refreshExperiment();
 }
Esempio n. 2
0
        private void start(bool isCameraStart = true)
        {
            labelMsg.Visible = true;

#if (TRACE)
            ds     = new DataSet("trace");
            dtBlow = new DataTable("blow");
            dtBlow.Columns.Add("id", typeof(int));
            dtBlow.Columns.Add("valve", typeof(int));
            dtBlow.Columns.Add("sec", typeof(int));
            dtBlow.Columns.Add("milisec", typeof(int));

            dtSensor = new DataTable("sensor");
            dtSensor.Columns.Add("id", typeof(int));
            dtSensor.Columns.Add("valve", typeof(int));
            dtSensor.Columns.Add("sec", typeof(int));
            dtSensor.Columns.Add("milisec", typeof(int));

            ds.Tables.Add(dtBlow);
            ds.Tables.Add(dtSensor);

//            ds.Relations.Add("relation_id", dtBlow.Columns["id"], dtSensor.Columns["id"]);/**/
#endif

            // detectors
            {
                valves.init();

                if (true)
                {
                    detectorMaster =
                        new detect_blobs(new ColorRange("Red"), (ThresholdType)cbBinMethodMaster.SelectedIndex,
                                         (byte)trBinValMaster.Value, 255, 2, true);
                    if (!checkBoxIsUseCore.Checked)
                    {
                        detectorMaster.NewBlobs += new detect_blobs.DetectNewBlobHandle(masterBlobsHaveAdded);
                        emulationZeroSample4Master(); // first sample detected long time -> emulate firs/t sample & delete  it .................

                        if (cfg.isShowFrameRgb)
                        {
                            detectorMaster.ShowFrameRgb +=
                                new detect_blobs.ShowImageHandle(masterShowFrameRgb); // slowing - don't use
                        }
                        if (cfg.isShowFrameBin)
                        {
                            detectorMaster.ShowFrameBin += new detect_blobs.ShowImageHandle(masterShowFrameBin);
                        }

                        timerM.Start();
                    }
                }

#if (DEMO)
                cbCamMS.Checked = true;
#endif

                if (cbCamMS.Checked)
                {
                    if (MSLink == null)
                    {
                        MSLink = new List <long[]>();
                    }
                    linkMS = new comparator();
                    linkMS.ComplitParticle += new comparator.ComplitReorddHandle(complectMSCompare);

                    detectorSlave =
                        new detect_blobs(new ColorRange("Red"), (ThresholdType)cbBinMethodMaster.SelectedIndex,
                                         (byte)trBinValMaster.Value, 255, 2, false);
                    if (!checkBoxIsUseCore.Checked)
                    {
                        detectorSlave.NewBlobs += new detect_blobs.DetectNewBlobHandle(slaveBlobsHaveAdded);
                        emulationZeroSample4Slave(); // first sample detected long time -> emulate first sample & delete  it .................

                        if (cfg.isShowFrameRgb)
                        {
                            detectorSlave.ShowFrameRgb +=
                                new detect_blobs.ShowImageHandle(slaveShowFrameRgb); // slowing - don't use
                        }
                        if (cfg.isShowFrameBin)
                        {
                            detectorSlave.ShowFrameBin += new detect_blobs.ShowImageHandle(slaveShowFrameBin);
                        }

                        timerS.Start();
                    }
                }
            }

            cbBinMethodMaster.SelectedItem = detectorMaster.ThresholdType_METHOD;
            trBinValMaster.Value           = detectorMaster.ThresholdType_VAL;

            if (isCameraStart)
            {
#if (DEMO)
                cbCamOne.Checked = true;
#endif
                // camera engine
                if (cbCamOne.Checked)
                {
                    drv = new IDS();
                    drv.Init(((IDS)drv).GetNoInDeviceList(cfg.CameraMaster), -1, -1, 24, dpsMaster.pbLife, IntPtr.Zero);
                }
                else
                {
                    drv = new IDSMS();
                    ((IDSMS)drv).SetCameraID(cfg.CameraMaster, 1);
                    drv.Init(0, -1, -1, 24, dpsSlave.pbLife, dpsMaster.pbLife.Handle);
                    ((IDSMS)drv).ImageCapturedSlave += new CameraBridgeEventHandler(cameraSlaveCapture);
                }

                // device
                HidController.Controller.Start(cfg.FrontLight, (int)cfg.BackLigth,
                                               cfg.VibroVal, cfg.VibroVal2);
                HidController.Controller.BlowSetTime(cfg.BlowInterval);
                HidController.Controller.SensorsClear();

                drv.TurnON();
                drv.ImageCaptured += new CameraBridgeEventHandler(cameraMasterCapture);

                if (cbCamOne.Checked)
                {
                    valves.init(((IDS)drv).GetWidth(), ((IDS)drv).GetWidth());
                }
                else
                {
                    valves.init(((IDSMS)drv).GetMasterWidth(), ((IDSMS)drv).GetSlaveWidth());
                }

#if (DEMO)
                cbCamMS.Checked = true;
                timerDEMO.Start();
#endif


                labelMsg.Visible = false;
                clearCounters();
#if (TRACE)
                dtSensor.Rows.Clear();
                dtBlow.Rows.Clear();
                cntBlow = 0;
#endif
            }
        }