Ejemplo n.º 1
0
        void m_Coord_OnDeviceFocus(VsDevice objDevice)
        {
            // Get handle to the Device
            m_Dev = objDevice;
            // Connect the IO control to the device. Only do this once.
            m_IO.Connect(m_Dev);

            // Create an event so that we see when IO on camera changes
            // m_IO.IOTransition += new EventHandler<IOConnectionEventArgs>(m_IO_IOTransition);

            // Initialize all IO to low, in this case Virtual 1
            m_IO.PointWrite(VsIoType.Virtual, 0, false);


            // Load our job from disk
            m_Job.Load("C:\\Microscan\\Vscape\\Jobs\\test.avp");

            // Get the first VisionSystemStep in the job
            vs = m_Job.VisionSystemStep();

            // Connect the VisionSystemStep to our device
            vs.SelectSystem(m_Dev.Name);
            //Now we can download to the device(vision system) and run the job on that device
            m_Dev.Download(vs, true);

            // Connect reports to the inspection on the device
            m_RepCon1.Connect(DEVICENAME, 1, ReportConnection.ConnectOptions.DEFAULT);

            // Make images part of the report
            m_RepCon1.AddSnapBuffers((Visionscape.Steps.InspectionStep)m_Job.FindBySymName("Insp1"));
            // Now start the device
            m_Dev.StartAll();
        }
Ejemplo n.º 2
0
 private void vsCoordinator_OnDeviceDiscovered(VsDevice newDevice)
 {
     // When new camera detected
     if (newDevice.Name == _cameraName && vsDevice != newDevice)
     {
         vsDevice = newDevice;
         if (ConnectionEventCallback != null)
         {
             ConnectionEventCallback.Invoke(Enum_ConnectionEvent.DISCOVERED_CAMERA, newDevice);
         }
     }
     if (ConnectionEventCallback != null)
     {
         ConnectionEventCallback.Invoke(Enum_ConnectionEvent.DISCOVERED_NEW_CAMERA, newDevice);
     }
 }
Ejemplo n.º 3
0
        public void ConnectCamera(string cameraName)
        {
            if (_cameraName == cameraName || cameraName == "None")
            {
                return;
            }
            _cameraName = cameraName;

            // If camera already found
            foreach (VsDevice dev in vsCoordinator.Devices)
            {
                if (dev.Name == cameraName && vsDevice != dev)
                {
                    vsDevice = dev;
                    if (ConnectionEventCallback != null)
                    {
                        ConnectionEventCallback.Invoke(Enum_ConnectionEvent.DISCOVERED_CAMERA, dev);
                    }
                    return;
                }
            }
        }
Ejemplo n.º 4
0
        private void DisconnectDevice()
        {
            if (vsDevice != null)
            {
                if (vsDevice.IsAnyInspectionRunning)
                {
                    vsDevice.StopAll();
                }
                if (vsDevice.IsConnected)
                {
                    vsDevice.Disconnect();
                }
            }

            vsDevice    = null;
            _cameraName = null;

            if (ConnectionEventCallback != null)
            {
                ConnectionEventCallback.Invoke(Enum_ConnectionEvent.DISCONNECTED_DEVICE, null);
            }
        }
Ejemplo n.º 5
0
        private void Microscan_App_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            // Stop all inspections
            if (m_Dev != null)
            {
                m_Dev.StopAll();
            }

            // Disconnect the reports
            if (m_RepCon1 != null)
            {
                m_RepCon1.Disconnect();
            }
            m_RepCon1 = null;

            // Disconnect the IO
            if (m_IO != null)
            {
                m_IO.Disconnect();
            }
            m_IO = null;

            // Disconnect from the camera
            if (m_Dev != null)
            {
                m_Dev.Disconnect();
            }
            m_Dev = null;

            // Set the RootStep of setup manager to null
            SetupManager1.RootStep = null;

            // Clear the job from pc memory
            while (m_Job.Count > 0)
            {
                m_Job.Remove(1);
            }
            m_Job = null;
        }