Ejemplo n.º 1
0
        private void Cbx_CangeLine_CheckedChanged(object sender, EventArgs e)
        {
            // 生産状態基準線への切り替え
            if (!Cbx_CangeLine.Checked)
            {
                var graphiclist = new List <GikaiLib.Components.DatumGraphics>();

                for (int i = 1; i <= 72; i++)
                {
                    Pen p;
                    if (i % 4 == 0)
                    {
                        p = new Pen(Color.Red);
                    }
                    else
                    {
                        p = new Pen(Color.Blue);
                    }

                    p.DashStyle = System.Drawing.Drawing2D.DashStyle.Dot;
                    graphiclist.Add(new GikaiLib.Components.DatumLineVer(p, i * 8));
                }

                Dpb_RightCamera.GraphicsList = graphiclist;
                Dpb_LeftCamera.GraphicsList  = graphiclist;

                Dpb_RightCamera.DrawDatum();
                Dpb_LeftCamera.DrawDatum();
            }

            // 校正状態基準線への切り替え
            else
            {
                var graphiclist = new List <GikaiLib.Components.DatumGraphics>();


                Pen p = new Pen(Color.Red);
                p.DashStyle = System.Drawing.Drawing2D.DashStyle.Solid;

                Rectangle rect = new Rectangle();
                rect.X      = Pbx_LeftCamera.Width / 5 * 2;
                rect.Y      = Pbx_LeftCamera.Height / 5 * 2;
                rect.Width  = Pbx_LeftCamera.Width / 5;
                rect.Height = Pbx_LeftCamera.Height / 5;

                graphiclist.Add(new GikaiLib.Components.DatumRectangle(p, rect));

                Dpb_RightCamera.GraphicsList = graphiclist;
                Dpb_LeftCamera.GraphicsList  = graphiclist;

                Dpb_RightCamera.DrawDatum();
                Dpb_LeftCamera.DrawDatum();
            }
        }
Ejemplo n.º 2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            timer_focus.Enabled = true;
            this.Location       = new Point(0, 0);
            this.Size           = new System.Drawing.Size(1280, 1024);

            ERROR_COMMON err_com;
            ErrorCode    code;



            // 過去バーコード情報初期化
            _Past_Barcode = "";

            // 進行表示をエラー表示化
            Pnl_Mes.BackColor = Color.Red;
            Lbl_Mes.Text      = SelectMessage.NG_MachineState.ToString();
            Lbl_Sn.Text       = "";


            // Ver表示
            Lbl_Ver.Text = _SOFT_VER;

            //// 基準線描画コンポーネントの関連付け
            Dpb_RightCamera.SetParentControl(Pbx_RightCamera);
            Dpb_LeftCamera.SetParentControl(Pbx_LeftCamera);
            Dpb_RightCamera.GraphicsList = new List <GikaiLib.Components.DatumGraphics>();
            Dpb_LeftCamera.GraphicsList  = new List <GikaiLib.Components.DatumGraphics>();

            // IniFile読み出し
            IniFileSettingObj             = new IniFileSetting();
            IniFileSettingObj.IniFilePath = Application.StartupPath + "\\Setting.ini";

            err_com = ERROR_COMMON.Read_IniFile;
            AddLogMes(true, err_com.ToString(), Color.White);
            if (!IniFileSettingObj.ReadIniFile())
            {
                AddLogErrorCode(new ErrorCode((int)err_com, err_com.ToString(), 0, ""));
            }

            P.PortName = IniFileSettingObj.Barcode_Com;
            //   P.PortName = "COM1";
            P.BaudRate = 9600;
            P.DataBits = 8;
            P.Parity   = Parity.None;
            P.StopBits = StopBits.One;
            if (!P.IsOpen)
            {
                P.Open();
                P.RtsEnable = true;
            }
            // cb_select.SelectedIndex = 2; // che do su dung ca 2 barcode
            switch (IniFileSettingObj.mode)
            {
            case "Fix":
                cb_select.SelectedIndex = 0;
                break;

            case "Handy":
                cb_select.SelectedIndex = 1;
                break;

            case "Both":
                cb_select.SelectedIndex = 2;
                break;
            }

            // IniFile情報を、Setting画面に反映
            Btn_Setting_ClearValue_Click(null, null);

            // Count情報を反映(Ver1.01追加)
            Txt_WorkCount.Text = IniFileSettingObj.WorkCountNo.ToString("0");



            // アプリケーションのStartUpパス取得
            _Picture_Left_FolderPath  = Application.StartupPath + "\\Picture_Left";
            _Picture_Right_FolderPath = Application.StartupPath + "\\Picture_Right";

            // フォルダが無い場合は、フォルダを自動生成
            if (!System.IO.Directory.Exists(_Picture_Left_FolderPath))
            {
                System.IO.Directory.CreateDirectory(_Picture_Left_FolderPath);
            }
            if (!System.IO.Directory.Exists(_Picture_Right_FolderPath))
            {
                System.IO.Directory.CreateDirectory(_Picture_Right_FolderPath);
            }

            // 基準線の初期化
            Cbx_CangeLine_CheckedChanged(null, null);
            Tmr_Timer.Enabled = true;

            // インスタンス初期化

            AccessBarcodeObj = new AccessBarcode();
            AccessCameraObj  = new AccessCamera();



            // モニタタイマ開始
            Tmr_Timer.Enabled = true;


            // バーコードリーダ初期化
            // err_com = ERROR_COMMON.Reader_Open;
            // AddLogMes(true, err_com.ToString(), Color.White);
            // code = AccessBarcodeObj.Open(IniFileSettingObj.Barcode_Com);
            //if (code.ErrorNo != (int)AccessBarcode.ERROR.READER_NONE)
            //{
            //    AddLogErrorCode(code);
            //     return;
            // }

            // カメラObj初期化
            err_com = ERROR_COMMON.Camera_Open;
            AddLogMes(true, err_com.ToString(), Color.White);
            code = AccessCameraObj.Open(this.Handle, IniFileSettingObj.R_Cam_Gain, IniFileSettingObj.L_Cam_Gain);
            if (code.ErrorNo != (int)AccessBarcode.ERROR.READER_NONE)
            {
                AddLogErrorCode(code);
                return;
            }


            // カメラ定期モニタ実行
            new MethodInvoker(CameraWatch_Monitor).BeginInvoke(null, null);

            // 進行表示初期化
            Pnl_Mes.BackColor = Color.PaleGreen;
            // Lbl_Mes.Text = "Hãy ấn Enter";//SelectMessage.Press_Enter.ToString();

            _SavePictureObj = new object();
        }