Exemplo n.º 1
0
        private void InitialHal()
        {
            m_objComPort = new clsFixture.stComPort();
            if (Properties.Settings.Default.PLC_ComNum == "")
            {
                MessageBox.Show("Com Number 输入错误!");
                return;
            }
            m_objComPort.strComPortNumber = Properties.Settings.Default.PLC_ComNum;
            m_objComPort.iBaundRate       = Properties.Settings.Default.PLC_BaudRate;
            m_objComPort.iDataBit         = Properties.Settings.Default.PLC_DataBit;
            m_objComPort.iStopBit         = Properties.Settings.Default.PLC_StopBit;
            m_objComPort.strParity        = Properties.Settings.Default.PLC_Parity;

            //m_objFixtureAMP204 = new clsFixtureAMP204();
            //if (m_objFixtureAMP204.InitialFixture(Properties.Settings.Default.Card204, 0) == false)
            //{
            //    MessageBox.Show("APM 204 card initial fail 通信初始化失败!!!");
            //    ShowLog("APM 204 初始化失败");
            //    //return;
            //}
            //else
            //{
            //    ShowLog("APM 204 初始化成功");
            //}

            //m_objFixtureAMP204.ServoOn(true);
            //m_objFixtureAMP204.HomeXY();

            //scanner
            try
            {
                clsScanner.Callback += new clsScanner.OnMessageCallback(ShowLog);
                m_objScanner         = new clsScanner();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }

            m_objFixture8338 = new clsFixture8338();
            if (m_objFixture8338.InitialFixture(Properties.Settings.Default.Card8338ID) == false)
            {
                MessageBox.Show("card 8338  initial fail 通信初始化失败!!!");
                ShowLog("PCIE-8338 初始化失败");
                //return;
            }
            else
            {
                ShowLog("PCIE-8338 初始化成功");
            }

            m_objFixture8338.SickLaserPowerOnOff(true);
            m_objFixture8338.Scanner = m_objScanner;
            m_objFixture8338.ServoOn(true);
            m_objFixture8338.HomeXY();

            //frmShowImage objImageShowFromLocal = new frmShowImage();
            //pbxLocal = objImageShowFromLocal.PbxShowImage;
            m_objCameraLocl = new CCBasler();


            List <ICameraInfo> listCam = CCBasler.GetDeviceList();

            bool findLocalCam = false;

            foreach (ICameraInfo cam in listCam)
            {
                if (cam[CameraInfoKey.FriendlyName].Contains(Properties.Settings.Default.Camera_LocalSN))
                {
                    findLocalCam = true;
                    m_objCameraLocl.SetDeviceInfo(cam);
                    m_objCameraLocl.ConnectToDevice();
                    m_objCameraLocl.SetExposure(Properties.Settings.Default.Camera_LocalExp);

                    break;
                }
            }

            if (findLocalCam == false)
            {
                MessageBox.Show("局部相机 通信初始化失败!!!");
                ShowLog("未能找到局部相机 ID:" + Properties.Settings.Default.Camera_LocalSN);
                //return;
            }


            //remove plc
            //m_objFixture = new clsFixture();
            //m_objFixture.ComPort = m_objComPort;
            //if (m_objFixture.InitFixture() == false)
            //{
            //    MessageBox.Show("PLC 通信初始化失败!!!");
            //    ShowLog("PLC 通信失败");
            //    //return;
            //}
        }