コード例 #1
0
ファイル: FormStart.cs プロジェクト: HongJunJan/Fa1811ths
        /// <summary>
        /// 雷射預設控制開關: 1.LSR雷射狀態,2.SHT遮光閥狀態
        /// </summary>
        private void DefultLaserControll()
        {
            string cmd = string.Empty; string response = string.Empty;

            if (formStartModel.LSR雷射狀態 == "0")
            {
                cmd      = LaserCommand.LSR激光控制設定("1");
                response = LaserExecuteWrite.執行LSR激光控制設定(cmd);
                if (ValidateUtility.DisplayMessage(response))
                {
                    return;
                }
                LaserReady laserReady = new LaserReady();
                laserReady.ShowDialog();
                formStartModel.LSR雷射狀態 = "1";
            }

            if (formStartModel.SHT遮光閥狀態 == "0")
            {
                cmd      = LaserCommand.SHT遮光閥控制設定("1");
                response = LaserExecuteWrite.執行SHT遮光閥控制設定(cmd);
                if (ValidateUtility.DisplayMessage(response))
                {
                    return;
                }
                formStartModel.SHT遮光閥狀態 = "1";
            }
        }
コード例 #2
0
        /// <summary>
        /// 關閉離開
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripbtnExit_Click(object sender, EventArgs e)
        {
            if (GlobalParameter.UseMode.Equals("1"))
            {
                try
                {
                    // 遮光閥開啟
                    if (SHT遮光閥狀態.Equals("0") || SHT遮光閥狀態.Equals("\0"))
                    {
                        string cmd      = LaserCommand.MKM指令接收控制設定("1");
                        string response = LaserExecuteWrite.執行MRK印字觸控制設定(cmd);
                        if (ValidateUtility.DisplayMessage(response))
                        {
                            return;
                        }
                        SHT遮光閥狀態 = "1";
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex, "Error");
                }
            }

            this.Close();
        }
コード例 #3
0
 public LaserSet()
 {
     InitializeComponent();
     SetDefultEvent();
     if (GlobalParameter.UseMode.Equals("1"))
     {
         try
         {
             SerialPortMethod.LaserOpenPort(GlobalParameter.LaserSerialPort);
             if (LaserConnectionPort.LaserPort.IsOpen)
             {
                 ModelSTS modelSTS = LaserExecuteWrite.執行STS狀態請求讀取(LaserCommand.STS狀態請求讀取);
                 SHT遮光閥狀態 = modelSTS.SHTStatus;
                 toolStripbtnSave.Enabled = true;
                 panel1.Enabled           = true;
             }
         }
         catch (Exception ex)
         {
             logger.Error(ex, "Error");
             MessageBox.Show("請檢查雷射是否斷線、未開機、未開啟REMOTE。");
             toolStripbtnSave.Enabled = false;
             panel1.Enabled           = false;
         }
     }
 }
コード例 #4
0
ファイル: LaserPrinting.cs プロジェクト: HongJunJan/Fa1811ths
        public LaserPrinting()
        {
            InitializeComponent();
            SetDefultEvent();
            toolStripbtnSet.Enabled   = false;
            toolStripbtnPoint.Enabled = false;

            if (GlobalParameter.UseMode.Equals("1"))
            {
                #region 測試後不用要刪除

                PLCMethod.PLC_Connect();
                Thread.Sleep(1000);

                #endregion 測試後不用要刪除

                panel1.Enabled = false;
                try
                {
                    if (!GlobalData.PLC初始連線是否成功)
                    {
                        MessageBox.Show("PLC連線失敗:請檢查PLC連線IP、機台是否異常。"); return;
                    }
                    if (!GlobalData.PLC線路異常)
                    {
                        ThreadPool.QueueUserWorkItem(DM8123雷射打印執行緒);
                    }
                    else
                    {
                        MessageBox.Show("PLC線路異常。"); return;
                    }
                    SerialPortMethod.LaserOpenPort(GlobalParameter.LaserSerialPort);
                }
                catch (Exception ex)
                {
                    logger.Error(ex, "Exception錯誤");
                    MessageBox.Show("Exception錯誤:" + ex.Message);
                    return;
                }

                try
                {
                    if (LaserConnectionPort.LaserPort.IsOpen)
                    {
                        ModelSTS modelSTS = LaserExecuteWrite.執行STS狀態請求讀取(LaserCommand.STS狀態請求讀取);
                        formStartModel.LSR雷射狀態 = modelSTS.LSRStatus; formStartModel.SHT遮光閥狀態 = modelSTS.SHTStatus;
                        DefultLaserControll();
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex, "Exception錯誤");
                    MessageBox.Show("請檢查雷射是否斷線、未開機、未開啟REMOTE。");
                }

                panel1.Enabled = true;
            }
        }
コード例 #5
0
ファイル: LaserPrinting.cs プロジェクト: HongJunJan/Fa1811ths
        /// <summary>
        /// 雷射打印,[DM_8111允許手動][DM_8214手動打印通知]
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripbtnPoint_Click(object sender, EventArgs e)
        {
            toolStripbtnSet.Enabled   = true;
            toolStripbtnPoint.Enabled = false;

            try
            {
                // 異動紀錄
                AddRecChangeMethod("手動流程:雷射打印執行");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            if (GlobalParameter.UseMode.Equals("0"))
            {
                MessageBox.Show("測試模式,無法雷射打印。"); return;
            }
            try
            {
                if (GlobalData.PLC線路異常)
                {
                    MessageBox.Show("PLC線路異常。"); return;
                }
                if (GlobalData.DM[DmTable.DM_8111允許手動] != "1")
                {
                    MessageBox.Show("PLC讀取異常[DM_8111允許手動]:不允許手動,請檢查PLC參數。");
                    return;
                }

                if (SHT遮光閥狀態 == "0")
                {
                    string cmd      = LaserCommand.MKM指令接收控制設定("1");
                    string response = LaserExecuteWrite.執行MRK印字觸控制設定(cmd);
                    if (ValidateUtility.DisplayMessage(response))
                    {
                        return;
                    }
                    SHT遮光閥狀態 = "1";
                }

                PLCcommand.PLC_Write(PLCcommand.Cmd_Mode.Mode_Write_Single,
                                     PLCcommand.PLC_IO.DM, DmTable.DM_8214手動打印通知, 1, 0, null);
                formStartModel.允許雷射打印Tag = true;
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception錯誤");
                MessageBox.Show("Exception_PLC系統異常錯誤:" + ex.Message);
                return;
            }
        }
コード例 #6
0
ファイル: FormStart.cs プロジェクト: HongJunJan/Fa1811ths
        private void 雷射動作執行緒(object obj)
        {
            while (true)
            {
                if (GlobalData.DM[DmTable.DM_8123雷射打印開始].Equals("1"))
                {
                    if (formStartModel.允許雷射打印Tag)
                    {
                        if (GlobalData.DM[DmTable.DM_8104停止].Equals("1") || GlobalData.DM[DmTable.DM_8110結批].Equals("1"))
                        {
                            lblAutoRun.Text         = "停止運轉";
                            splitContainer1.Enabled = true;
                        }
                        else
                        {
                            string cmd = string.Empty, response = string.Empty;
                            Thread.Sleep(200);
                            if (formStartModel.SHT遮光閥狀態.Equals("0"))
                            {
                                cmd      = LaserCommand.MKM指令接收控制設定("1");
                                response = LaserExecuteWrite.執行MRK印字觸控制設定(cmd);
                                if (ValidateUtility.DisplayMessage(response))
                                {
                                    return;
                                }
                                formStartModel.SHT遮光閥狀態 = "1";
                            }

                            Thread.Sleep(200);
                            cmd      = LaserCommand.MRK印字觸控制設定("1");
                            response = LaserExecuteWrite.執行MRK印字觸控制設定(cmd);
                            int dm = ValidateUtility.DisplayMessage(response).Equals(true) ?
                                     DmTable.DM_8230雷射打印異常 : DmTable.DM_8229雷射打印完畢;
                            PLCMethod.WriteSingle(dm, 1);
                        }
                    }
                    else
                    {
                        PLCMethod.WriteSingle(DmTable.DM_8229雷射打印完畢, 1);
                    }

                    // PLC:DM_8123雷射打印開始,清空點位
                    PLCMethod.WriteSingle(DmTable.DM_8123雷射打印開始, 0);
                }

                Thread.Sleep(100);
            }
        }
コード例 #7
0
ファイル: LaserPrinting.cs プロジェクト: HongJunJan/Fa1811ths
        private void DM8123雷射打印執行緒(object sender)
        {
            string cmd = string.Empty, response = string.Empty;

            while (true)
            {
                if (!GlobalData.PLC線路異常)
                {
                    if (formStartModel.允許雷射打印Tag)
                    {
                        if (GlobalData.DM[DmTable.DM_8123雷射打印開始].Equals("1"))
                        {
                            try
                            {
                                cmd      = LaserCommand.MRK印字觸控制設定("1");
                                response = LaserExecuteWrite.執行MRK印字觸控制設定(cmd);
                                Thread.Sleep(500);
                                if (ValidateUtility.DisplayMessage(response))
                                {
                                    PLCcommand.PLC_Write(PLCcommand.Cmd_Mode.Mode_Write_Single,
                                                         PLCcommand.PLC_IO.DM, DmTable.DM_8230雷射打印異常, 1, 0, null);
                                    MessageBox.Show(response);
                                }
                                else
                                {
                                    PLCcommand.PLC_Write(PLCcommand.Cmd_Mode.Mode_Write_Single,
                                                         PLCcommand.PLC_IO.DM, DmTable.DM_8229雷射打印完畢, 1, 0, null);
                                    MessageBox.Show("打印成功");
                                }
                            }
                            catch (Exception ex)
                            {
                                logger.Error(ex, "Exception錯誤");
                                MessageBox.Show(ex.Message);
                            }

                            PLCcommand.PLC_Write(PLCcommand.Cmd_Mode.Mode_Write_Single,
                                                 PLCcommand.PLC_IO.DM, DmTable.DM_8123雷射打印開始, 0, 0, null);
                            formStartModel.允許雷射打印Tag = false;
                        }
                    }
                }
            }
        }
コード例 #8
0
ファイル: FormStart.cs プロジェクト: HongJunJan/Fa1811ths
        private void Step3寫入Laser資料(PieceResultModel pieceResultModel)
        {
            string cmd = string.Empty, response = string.Empty, record = string.Empty;

            if (formStartModel.允許雷射打印Tag)
            {
                // 設定 MKM
                if (formStartModel.SHT遮光閥狀態.Equals("1"))
                {
                    cmd      = LaserCommand.MKM指令接收控制設定("0");
                    response = LaserExecuteWrite.執行MRK印字觸控制設定(cmd);
                    if (ValidateUtility.DisplayMessage(response))
                    {
                        return;
                    }
                    formStartModel.SHT遮光閥狀態 = "0";
                    record += "1.SHT,";
                }

                // 設定 FNO
                cmd      = LaserCommand.FNO文件變更控制設定(partNoJoinTrayAndLaser.FnoNo);
                response = LaserExecuteWrite.執行FNO文件變更控制設定(cmd);
                if (ValidateUtility.DisplayMessage(response))
                {
                    return;
                }
                record += "2.FNO,";

                // 雷射功率
                cmd = LaserCommand.LPW激光功率控制設定(string.Format("{0:000.0}",
                                                             Convert.ToInt32(partNoJoinTrayAndLaser.Power)));
                response = LaserExecuteWrite.執行LPW激光功率控制設定(cmd);
                if (ValidateUtility.DisplayMessage(response))
                {
                    return;
                }
                record += "3.LPW,";

                // 掃描速度
                cmd = LaserCommand.SSP掃描速度控制設定(string.Format("{0:00000}",
                                                             Convert.ToInt32(partNoJoinTrayAndLaser.Speed)));
                response = LaserExecuteWrite.執行SSP掃描速度控制設定(cmd);
                if (ValidateUtility.DisplayMessage(response))
                {
                    return;
                }
                record += "4.SSP,";

                // 設定座標位置
                List <double> list = new List <double> {
                    { pieceResultModel.X位置 }, { pieceResultModel.Y位置 }
                };
                List <string> laserList = TypeMethod.SetFormatValue(list, "{0:000.000}");
                ModelSPC      modelSPC  = new ModelSPC
                {
                    SonCmd    = "S",
                    Xposition = laserList[0],
                    Yposition = laserList[1]
                };
                cmd      = LaserCommand.SPC文字條件控制設定(modelSPC);
                response = LaserExecuteWrite.執行SPC文字條件控制設定(cmd);
                if (ValidateUtility.DisplayMessage(response))
                {
                    return;
                }
                record += "5.SPC,";

                // 雷射參數儲存
                LaserExecuteWrite.執行FOR文件覆盖保存控制設定(LaserCommand.FOR文件覆盖保存控制設定);
                record += "6.FOR,";
            }
        }
コード例 #9
0
ファイル: FormStart.cs プロジェクト: HongJunJan/Fa1811ths
        public FormStart()
        {
            InitializeComponent();
            SetDefultEvent();

            // 條碼讀取器,預設顯示還是不顯示
            label3.Visible = lblCCD.Visible = liveviewForm1.Visible = false;
            ToolStripMenuItemSW(false, "FormStart");
            DefultListViewInit();
            ThreadPool.QueueUserWorkItem(日期時間執行緒);
            if (GlobalParameter.UseMode.Equals("1"))
            {
                // PLC連線
                PLCMethod.PLC_Connect();
                Thread.Sleep(1000);
                if (GlobalData.PLC初始連線是否成功)
                {
                    ThreadPool.QueueUserWorkItem(警示燈執行緒);
                }
                else
                {
                    MessageBox.Show("PLC連線失敗:請檢查PLC連線IP、機台是否異常。"); return;
                }

                // 雷射功能連線
                try
                {
                    SerialPortMethod.LaserOpenPort(GlobalParameter.LaserSerialPort);
                    if (LaserConnectionPort.LaserPort.IsOpen)
                    {
                        ModelSTS modelSTS = LaserExecuteWrite.執行STS狀態請求讀取(LaserCommand.STS狀態請求讀取);
                        formStartModel.LSR雷射狀態 = modelSTS.LSRStatus; formStartModel.SHT遮光閥狀態 = modelSTS.SHTStatus;
                        DefultLaserControll();
                    }
                }
                catch (Exception ex)
                {
                    MessageBox.Show("請檢查雷射是否斷線、未開機、未開啟REMOTE。" + ex.Message);
                    return;
                }

                // 條碼讀取器連線
                try
                {
                    bool check = LiveviewFormProperty.ReadConnect(liveviewForm1, readerAccessor, GlobalParameter.ReadIP);
                    if (!check)
                    {
                        MessageBox.Show("條碼讀取器連線異常、請確認IP位置。");
                        return;
                    }
                    label3.Visible = lblCCD.Visible = liveviewForm1.Visible = true;
                }
                catch (Exception ex)
                {
                    logger.Error(ex, "Exception錯誤");
                    MessageBox.Show("Exception錯誤:" + ex.Message);
                    return;
                }

                // Hoioke機台連線
                try
                {
                    IPEndPoint ipe = new IPEndPoint(IPAddress.Parse(GlobalParameter.HiokiIP), 32006);
                    this.socket = new Socket(ipe.AddressFamily, SocketType.Stream, ProtocolType.Tcp);
                    Thread tread = new Thread(new ThreadStart(CheckSocketConnect));
                    tread.Start();
                    this.socket.Connect(ipe);
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Hiorki連線: Hiorki機台連線異常,請檢查IP位置或網路線路是否異常。" + ex.Message);
                }
            }
        }
コード例 #10
0
ファイル: LaserPrinting.cs プロジェクト: HongJunJan/Fa1811ths
        /// <summary>
        /// 設定存檔
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripbtnSet_Click(object sender, EventArgs e)
        {
            string cmd = string.Empty, response = string.Empty, record = string.Empty;

            toolStripbtnSet.Enabled   = false;
            toolStripbtnPoint.Enabled = true;
            try
            {
                // 異動紀錄
                AddRecChangeMethod("手動流程:雷射設定存檔");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
                return;
            }

            if (GlobalParameter.UseMode.Equals("0"))
            {
                MessageBox.Show("測試模式,無法設定存檔。"); return;
            }

            // 驗證資料
            List <string> parameter = new List <string> {
                { cbBoxPartNo.Text }, { lblFNO.Text }, { lblPower.Text }, { lblSpeed.Text }
            };

            response = ValidateUtility.CheckParameter(parameter);
            if (ValidateUtility.DisplayMessage(response))
            {
                return;
            }

            // 板子計算方式
            PieceResultModel pieceResultModel = new PieceCalculationMethod()
                                                .PieceCalculation(new PieceRequestModel
            {
                板子X尺寸     = Convert.ToDouble(partNoJoinLaser[0].PieceSizeX),
                板子Y尺寸     = Convert.ToDouble(partNoJoinLaser[0].PieceSizeY),
                X偏移位置     = Convert.ToDouble(lblXoffset.Text),
                Y偏移位置     = Convert.ToDouble(lblYoffset.Text),
                台與雷射中心點差距 = GlobalParameter.VehicleAndPieceCenter
            });

            #region PLC寫入

            try
            {
                if (!GlobalData.PLC線路異常)
                {
                    List <string> data = new List <string>();
                    PLCMethod.SetParameterSplitForPoint(partNoJoinLaser[0].PieceSizeX, data);
                    PLCMethod.SetParameterSplitForPoint(partNoJoinLaser[0].PieceSizeY, data);
                    PLCMethod.SetParameterSplitForPoint(partNoJoinLaser[0].PieceSizeT, data);
                    PLCMethod.SetParameterSplitForPoint(partNoJoinLaser[0].PositionX2D, data);
                    PLCMethod.SetParameterSplitForPoint(partNoJoinLaser[0].PositionY2D, data);
                    PLCMethod.SetDefultParameter("0", 20, data);
                    PLCMethod.SetParameterSplit(dataTray.TrayNo.ToString(), data);
                    PLCMethod.SetParameterSplit(dataTray.DivideNoX.ToString(), data);
                    PLCMethod.SetParameterSplit(dataTray.DivideNoY.ToString(), data);
                    PLCMethod.SetParameterSplitForPoint(dataTray.DividePitchX, data);
                    PLCMethod.SetParameterSplitForPoint(dataTray.DividePitchY, data);
                    PLCMethod.SetParameterSplitForPoint(dataTray.PieceCenterX, data);
                    PLCMethod.SetParameterSplitForPoint(dataTray.PieceCenterY, data);
                    PLCMethod.SetParameterSplitForPoint(dataTray.TrayThickness, data);
                    PLCMethod.SetParameterSplitForPoint(dataTray.TrayCenter, data);
                    PLCMethod.SetParameterSplitForPoint(dataTray.TrayLength, data);
                    PLCMethod.SetDefultParameter("0", 10, data);
                    PLCMethod.SetParameterSplitForPoint(dataTray.TrayOffsetX, data);
                    PLCMethod.SetParameterSplitForPoint(dataTray.TrayOffsetY, data);
                    PLCMethod.SetDefultParameter("0", 6, data);
                    PLCcommand.PLC_Write(PLCcommand.Cmd_Mode.Mode_Write_Multiple,
                                         PLCcommand.PLC_IO.DM, DmTable.DM_8300DWORD_板寬X, 0, data.Count, data);
                }
                else
                {
                    MessageBox.Show("PLC線路異常。");
                    return;
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception錯誤");
                MessageBox.Show("Exception_PLC系統異常錯誤:" + ex.Message);
                return;
            }

            #endregion PLC寫入

            #region 雷射寫入

            try
            {
                if (SHT遮光閥狀態.Equals("1"))
                {
                    cmd      = LaserCommand.MKM指令接收控制設定("0");
                    response = LaserExecuteWrite.執行MRK印字觸控制設定(cmd);
                    if (ValidateUtility.DisplayMessage(response))
                    {
                        return;
                    }
                    SHT遮光閥狀態 = "0";
                    record  += "1.SHT,";
                }

                // 設定 FNO
                cmd      = LaserCommand.FNO文件變更控制設定(lblFNO.Text);
                response = LaserExecuteWrite.執行FNO文件變更控制設定(cmd);
                if (ValidateUtility.DisplayMessage(response))
                {
                    return;
                }
                record += "2.FNO,";

                // 雷射功率
                cmd = LaserCommand.LPW激光功率控制設定(string.Format("{0:000.0}",
                                                             Convert.ToInt32(lblPower.Text)));
                response = LaserExecuteWrite.執行LPW激光功率控制設定(cmd);
                if (ValidateUtility.DisplayMessage(response))
                {
                    return;
                }
                record += "3.LPW,";

                // 掃描速度
                cmd = LaserCommand.SSP掃描速度控制設定(string.Format("{0:00000}",
                                                             Convert.ToInt32(lblSpeed.Text)));
                response = LaserExecuteWrite.執行SSP掃描速度控制設定(cmd);
                if (ValidateUtility.DisplayMessage(response))
                {
                    return;
                }
                record += "4.SSP,";

                // 設定座標位置
                List <double> list = new List <double> {
                    { pieceResultModel.X位置 }, { pieceResultModel.Y位置 }
                };
                List <string> laserList = TypeMethod.SetFormatValue(list, "{0:000.000}");
                ModelSPC      modelSPC  = new ModelSPC
                {
                    SonCmd    = "S",
                    Xposition = laserList[0],
                    Yposition = laserList[1]
                };
                cmd      = LaserCommand.SPC文字條件控制設定(modelSPC);
                response = LaserExecuteWrite.執行SPC文字條件控制設定(cmd);
                if (ValidateUtility.DisplayMessage(response))
                {
                    return;
                }
                record += "5.SPC,";

                // 雷射參數儲存
                LaserExecuteWrite.執行FOR文件覆盖保存控制設定(LaserCommand.FOR文件覆盖保存控制設定);
                record += "6.FOR,";

                // DB資料寫入
                IDataLaserService dataLaserService = new DataLaserService();
                ResponseModel     ResponseModel    = dataLaserService.UpdateData(new DataLaser
                {
                    PartNo  = cbBoxPartNo.Text,
                    FnoNo   = lblFNO.Text,
                    Xoffset = lblXoffset.Text,
                    Yoffset = lblYoffset.Text,
                    Power   = lblPower.Text,
                    Speed   = lblSpeed.Text
                });
                if (ResponseModel.Status.Equals(StatusEnum.Error))
                {
                    logger.Error(ResponseModel.ResponseMsg);
                    MessageBox.Show(ResponseModel.ResponseMsg);
                    return;
                }
                record += "7.DB";

                if (!ValidateUtility.DisplayMessage(response))
                {
                    MessageBox.Show("設定完成,執行紀錄:" + record);
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception_Error:" + record);
                MessageBox.Show("Exception_雷射系統異常錯誤:" + ex.Message + ",執行紀錄:" + record);
            }

            #endregion 雷射寫入
        }
コード例 #11
0
        /// <summary>
        /// 程序確定
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void toolStripbtnSave_Click(object sender, EventArgs e)
        {
            string cmd = string.Empty, response = string.Empty, record = string.Empty;

            try
            {
                // 使用者異動紀錄
                recChangeService.AddData(new RecChange
                {
                    NowTime  = Convert.ToDateTime(DateTime.Now.ToString("yyyy/MM/dd HH:ss:mm")),
                    Message  = "雷射設定",
                    UserName = GlobalParameter.UserName
                });

                // 檢查欄位是否有空白
                List <string> parameter = new List <string> {
                    { txtFNO.Text }, { lblJisCode.Text }, { txtHeight.Text }, { txtWidth.Text }
                };
                response = ValidateUtility.CheckParameter(parameter);
                if (ValidateUtility.DisplayMessage(response))
                {
                    return;
                }
                if (GlobalParameter.UseMode.Equals("1"))
                {
                    // 寫入db
                    ILaserFnoService laserFnoService = new LaserFnoService();
                    LaserFNO         laserFNO        = new LaserFNO {
                        LaserFnoNo = txtFNO.Text
                    };
                    ResponseModel ResponseModel = laserFnoService.AddData(laserFNO);
                    if (ResponseModel.Status != StatusEnum.Ok)
                    {
                        MessageBox.Show(ResponseModel.ResponseMsg);
                        return;
                    }

                    // 寫入雷射
                    if (SHT遮光閥狀態 == "1")
                    {
                        cmd      = LaserCommand.MKM指令接收控制設定("0");
                        response = LaserExecuteWrite.執行MRK印字觸控制設定(cmd);
                        if (ValidateUtility.DisplayMessage(response))
                        {
                            return;
                        }
                        record  += "1.SHT,";
                        SHT遮光閥狀態 = "0";
                    }

                    // 設定 FNO
                    cmd      = LaserCommand.FNO文件變更控制設定(txtFNO.Text);
                    response = LaserExecuteWrite.執行FNO文件變更控制設定(cmd);
                    if (ValidateUtility.DisplayMessage(response))
                    {
                        return;
                    }
                    record += "2.FNO,";

                    // 雷射功率
                    cmd      = LaserCommand.LPW激光功率控制設定(string.Format("{0:000.0}", 40));
                    response = LaserExecuteWrite.執行LPW激光功率控制設定(cmd);
                    if (ValidateUtility.DisplayMessage(response))
                    {
                        return;
                    }
                    record += "3.LPW,";

                    // 掃描速度
                    cmd      = LaserCommand.SSP掃描速度控制設定(string.Format("{0:00000}", 500));
                    response = LaserExecuteWrite.執行SSP掃描速度控制設定(cmd);
                    if (ValidateUtility.DisplayMessage(response))
                    {
                        return;
                    }
                    record += "4.SSP,";

                    // 設定條件 ALC
                    cmd = LaserCommand.ALC整體條件的控制設定(new ModelALC
                    {
                        SonCmd         = "S",
                        Xoffset        = "+000.000",
                        Yoffset        = "+000.000",
                        RotationOffset = "-090.00"
                    });
                    response = LaserExecuteWrite.執行ALC整體條件的控制設定(cmd);
                    if (ValidateUtility.DisplayMessage(response))
                    {
                        return;
                    }
                    record += "5.ALC,";

                    // 設定文字型狀 STR
                    cmd      = LaserCommand.STR印字文字列設定(lblJisCode.Text);
                    response = LaserExecuteWrite.執行STR印字文字列設定(cmd);
                    if (ValidateUtility.DisplayMessage(response))
                    {
                        return;
                    }
                    record += "6.STR,";

                    /* 文字條件控制設定STC
                     * 範例:"STCS010010101006.000006.000+000.000+000.000000.000000.000+100.0011.000100100"; */
                    ModelSTC modelSTC = new ModelSTC
                    {
                        SonCmd    = "S",
                        Height    = string.Format("{0:000.000}", Convert.ToDouble(txtHeight.Text)),
                        Width     = string.Format("{0:000.000}", Convert.ToDouble(txtWidth.Text)),
                        Xposition = "+000.000",
                        Yposition = "+000.000",
                        Bold      = "0.000"
                    };
                    cmd      = LaserCommand.STC文字條件控制設定(modelSTC);
                    response = LaserExecuteWrite.執行STC文字條件控制設定(cmd);
                    if (ValidateUtility.DisplayMessage(response))
                    {
                        return;
                    }
                    record += "7.STC,";

                    // 雷射參數儲存
                    LaserExecuteWrite.執行FOR文件覆盖保存控制設定(LaserCommand.FOR文件覆盖保存控制設定);
                    record += "8.FOR";

                    if (!ValidateUtility.DisplayMessage(response))
                    {
                        MessageBox.Show("設定完成,執行紀錄:" + record);
                    }
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Error");
                MessageBox.Show(ex.Message);
            }
        }