コード例 #1
0
        private void Form_FormClosed(object pSender, FormClosedEventArgs pFormClosedEventArgs)
        {
            try

            {
                //  _pCoFAS_Serial.Dispose();
                _pCoFAS_Serial.Close();
                //화면 레이아웃 저장 ?
            }
            catch (ExceptionManager pExceptionManager)
            {
                CoFAS_DevExpressManager.ShowErrorMessage(string.Format("{0}\n{1}", pExceptionManager.Exception.Message.ToString(), pExceptionManager.TargetSite.ToString()));
            }
        }
コード例 #2
0
        private void InputData_Save()
        {
            _pPOPSelect_INSPECT_MIXEntity.PRINT_CODE = "BAR000001";

            _dtList_print = new frmPOPMain_PRODUCT_MIXBusiness().frmPOPMain_PRODUCT_MIX_barcode_Info(_pPOPSelect_INSPECT_MIXEntity);

            // 시리얼 연결 여부 확인
            if (_pCoFAS_Serial.IsOpen)
            {
                try
                {
                    //라벨 공정에서 가져오기
                    string _Barcode = string.Empty;

                    //byte[] bytes = Encoding.Default.GetBytes(_Barcode);
                    //_Barcode = Encoding.Default.GetString(bytes);

                    string cmd = null;

                    for (int j = 0; j < Convert.ToInt32(_pP_SEQ); j++)
                    {
                        _Barcode = _dtList_print.Rows[0]["PRINT_CMD"].ToString();
                        cmd      = (j + 1).ToString("D3");

                        // 푸른들식품 기준 10x5 라벨
                        _Barcode = _Barcode.Replace("@PNAME", _pP_Name);                                                       // 제품명
                        _Barcode = _Barcode.Replace("@PQTY", _pP_QTY);                                                         // 목표수량
                        _Barcode = _Barcode.Replace("@PDATE", DateTime.Now.ToString("yyyy-MM-dd"));                            // 날짜
                        _Barcode = _Barcode.Replace("@PBARCODE", _pP_Vend + cmd + DateTime.Now.ToString("yyMMdd").ToString()); // 바코드
                        _Barcode = _Barcode.Replace("@PCODE", _pP_Code);                                                       // 제품코드

                        byte[] bytes = Encoding.Default.GetBytes(_Barcode);
                        _pCoFAS_Serial.Write(bytes, 0, bytes.Length);
                    }
                }
                catch (Exception ex)
                {
                    CoFAS_DevExpressManager.ShowInformationMessage("라벨발행 오류");

                    _pCoFAS_Serial.Dispose();
                    _pCoFAS_Serial.Close();
                }
            }
            else  //연결 끊긴 여부
            {
                CoFAS_DevExpressManager.ShowInformationMessage("시리얼 확인");
            }
        }
コード例 #3
0
        private void SetHardware()
        {
            try
            {
                // 연결 표기 부분 초기화
                //pnlDeviceConnect.Controls.Clear();

                // 연결할 H/W 갯수만큼 돌린다. (연동시 변경)
                //for (int i = 0; i < 5; i++)
                for (int i = 0; i < _rt_dtList.Rows.Count; i++)
                {
                    LabelControl lc = new LabelControl();
                    //lc.Name = "lc_" + i.ToString();
                    lc.Name = "lc_" + _rt_dtList.Rows[i]["PORT_NAME"].ToString().ToString();
                    lc.Font = new Font("Tahoma", 9, FontStyle.Bold); // Font 설정
                    // lc.Text = "프린터" + i.ToString();
                    lc.Text = (_rt_dtList.Rows[i]["PORT_NAME"].ToString() + "_" + _rt_dtList.Rows[i]["COM_PORT"].ToString()).ToString();

                    lc.Padding          = new Padding(10, 0, 10, 0);
                    lc.Margin           = new Padding(0);
                    lc.Appearance.Image = global::CoFAS_MES.POP.Properties.Resources.plug_Gray;
                    lc.ImageAlignToText = ImageAlignToText.LeftCenter;
                    lc.Dock             = DockStyle.Right;


                    pnlDeviceConnect.Controls.Add(lc);

                    DisplayMessage(lc.Text + " OK");

                    DisplayMessage("POP Start Complete");
                }

                //_pCoFAS_Serial = new CoFAS_Serial(_dtList_terminal.Rows[0]["INFO_PORTNAME"].ToString(), Convert.ToInt32(_dtList_terminal.Rows[0]["INFO_BAUDRATE"].ToString()), _dtList_terminal.Rows[0]["INFO_PARITY"].ToString(), Convert.ToInt32(_dtList_terminal.Rows[0]["INFO_DATABITS"].ToString()), _dtList_terminal.Rows[0]["INFO_STOPBITS"].ToString());
                //_pBarcode_Serial = new CoFAS_Serial("COM3", 9600, "NONE", 8, "ONE");
                //                _pBarcode_Serial = new CoFAS_Serial(COM_PORT, 9600, "NONE", 8, "ONE");
                //포트1 : 바코드포트가 존재하는지
                if (Array.Exists(PC_serial_port, port => port == COM_PORT))
                {
                    _pBarcode_Serial = new CoFAS_Serial(COM_PORT, 9600, "NONE", 8, "ONE");
                    if (!_pBarcode_Serial.IsOpen)
                    {
                        _pBarcode_Serial.Open();
                    }
                    // _pBarcode_Serial.evtReceived += new CoFAS_Serial.delReceive(_Barcode_Received_Data);
                }
                if (_pBarcode_Serial.IsOpen)
                {
                    LabelControl xlb = this.Controls.Find("lc_" + _rt_dtList.Rows[0]["PORT_NAME"].ToString(), true).FirstOrDefault() as LabelControl;
                    xlb.Appearance.Image = global::CoFAS_MES.POP.Properties.Resources.plug_Green;
                    _pBarcode_Serial.Close();
                }
                else
                {
                    LabelControl xlb = this.Controls.Find("lc_" + _rt_dtList.Rows[0]["PORT_NAME"].ToString(), true).FirstOrDefault() as LabelControl;
                    xlb.Appearance.Image = global::CoFAS_MES.POP.Properties.Resources.plug_Gray;
                }
                // _pBarcode_Serial.Open();
                // _pBarcode_Serial.evtReceived += new CoFAS_Serial.delReceive(_Barcode_Received_Data);
                // _pBarcode_Serial.Close();
            }
            catch (Exception ex)
            {
                CoFAS_DevExpressManager.ShowInformationMessage("포트 연결을 실패했습니다.");
                _pBarcode_Serial = new CoFAS_Serial();
            }
        }
コード例 #4
0
        private void SetHardware()
        {
            try
            {
                if (serial_check == "")
                {
                    //_pCoFAS_Serial = new CoFAS_Serial(_dtList_terminal.Rows[0]["INFO_PORTNAME"].ToString(), Convert.ToInt32(_dtList_terminal.Rows[0]["INFO_BAUDRATE"].ToString()), _dtList_terminal.Rows[0]["INFO_PARITY"].ToString(), Convert.ToInt32(_dtList_terminal.Rows[0]["INFO_DATABITS"].ToString()), _dtList_terminal.Rows[0]["INFO_STOPBITS"].ToString());
                    _pCoFAS_Serial = new CoFAS_Serial(_luCOM_TYPE.SelectedItem.ToString(), 9600, "NONE", 8, "ONE");
                    _pCoFAS_Serial.Open();

                    // 연결할 H/W 연결상태 표시. (연동시 변경)
                    //lc_0.Appearance.Image = global::CoFAS_MES.UI.QC.Properties.Resources.plug_Green;
                    _ucbtCONNECTION.Image = global::CoFAS_MES.UI.PM.Properties.Resources.plug_Green;

                    //serial_check = _dtList_terminal.Rows[0]["INFO_PORTNAME"].ToString();
                    serial_check = _luCOM_TYPE.SelectedItem.ToString();

                    // CoFAS_DevExpressManager.ShowInformationMessage("연결 되었습니다.");
                    _COM_STATUS.Text      = "연결 되었습니다.";
                    _COM_STATUS.ForeColor = Color.Green;
                }
                else //값이 있으면
                {
                    //컴포트값이 다르면
                    //if (serial_check != _dtList_terminal.Rows[0]["INFO_PORTNAME"].ToString())
                    if (serial_check != _luCOM_TYPE.SelectedItem.ToString())
                    {
                        //연결 끊고 새로운거로 연결

                        _pCoFAS_Serial.Dispose();
                        _pCoFAS_Serial.Close();

                        //_pCoFAS_Serial = new CoFAS_Serial(_dtList_terminal.Rows[0]["INFO_PORTNAME"].ToString(), Convert.ToInt32(_dtList_terminal.Rows[0]["INFO_BAUDRATE"].ToString()), _dtList_terminal.Rows[0]["INFO_PARITY"].ToString(), Convert.ToInt32(_dtList_terminal.Rows[0]["INFO_DATABITS"].ToString()), _dtList_terminal.Rows[0]["INFO_STOPBITS"].ToString());
                        _pCoFAS_Serial = new CoFAS_Serial(_luCOM_TYPE.SelectedItem.ToString(), 9600, "NONE", 8, "ONE");

                        _pCoFAS_Serial.Dispose();

                        //_pCoFAS_Serial = new CoFAS_Serial("com3", 9600, "NONE", 8, "ONE");
                        _pCoFAS_Serial.Open();

                        // 연결할 H/W 연결상태 표시. (연동시 변경)
                        //lc_0.Appearance.Image = global::CoFAS_MES.UI.QC.Properties.Resources.plug_Green;
                        _ucbtCONNECTION.Image = global::CoFAS_MES.UI.PM.Properties.Resources.plug_Green;

                        serial_check = _luCOM_TYPE.SelectedItem.ToString();

                        //CoFAS_DevExpressManager.ShowInformationMessage("연결 되었습니다.");
                        _COM_STATUS.Text      = "연결 되었습니다.";
                        _COM_STATUS.ForeColor = Color.Green;
                    }
                    else
                    {
                        //연결되어있는 상태니 재연결 할 필요 없음
                        //CoFAS_DevExpressManager.ShowInformationMessage("이미 연결된 포트입니다.");
                        _COM_STATUS.Text      = "이미 연결된 포트입니다.";
                        _COM_STATUS.ForeColor = Color.Blue;
                    }
                }
            }
            catch (Exception ex)
            {
                CoFAS_DevExpressManager.ShowInformationMessage("포트 연결을 실패했습니다.");
                _pCoFAS_Serial        = new CoFAS_Serial();
                _COM_STATUS.Text      = "포트 연결 실패.";
                _COM_STATUS.ForeColor = Color.Red;
                _ucbtCONNECTION.Image = global::CoFAS_MES.UI.PM.Properties.Resources.plug_Gray;
            }
        }