Beispiel #1
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();
        }
Beispiel #2
0
        /// <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;
            }
        }
Beispiel #3
0
        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);
            }
        }
Beispiel #4
0
        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,";
            }
        }
Beispiel #5
0
        /// <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 雷射寫入
        }
Beispiel #6
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);
            }
        }