Beispiel #1
0
 private void Login()
 {
     try
     {
         using (JobNumber.JobNumber frm = new JobNumber.JobNumber())
         {
             frm.ShowDialog();
             frm.Hide();
             if (frm.IsAdmin)
             {
                 Global.userLevel = UserLevel.工程师;
                 OnUserLevelChange(Global.userLevel);
             }
             else if (frm.OperatorID == "10S88888")
             {
                 Global.userLevel = UserLevel.设计者;
                 OnUserLevelChange(Global.userLevel);
             }
             else
             {
                 Global.userLevel = UserLevel.操作员;
                 OnUserLevelChange(Global.userLevel);
             }
             lbJobnumber.Text = frm.OperatorID;
             LogHelper.Info("用户登录:" + frm.OperatorID);
         };
     }
     catch (Exception ex)
     {
         LogHelper.Error("用户登录异常", ex);
     }
 }
Beispiel #2
0
 private void 串口设置ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     LogHelper.Debug("串口设置");
     using (frmSerialPort frm = new frmSerialPort(DM50S, typeof(DM50S)))
     {
         frm.ShowDialog();
         Config.Instance.ReadCodePortConnectParam = DM50S.ConnectionParam;
     };
 }
Beispiel #3
0
 private void toolStripButton1_Click(object sender, EventArgs e)
 {
     if (ManualAutoMode)
     {
         return;
     }
     LogHelper.Debug("扫描换型操作");
     SelectMode();
 }
Beispiel #4
0
 private void tlUseLoad_Click(object sender, EventArgs e)
 {
     if (ManualAutoMode)
     {
         return;
     }
     LogHelper.Debug("登陆操作");
     this.Maximized();
     Login();
     SelectMode();
 }
Beispiel #5
0
 /// <summary>
 /// 使用委托方式更新AppendText显示
 /// </summary>
 /// <param name="txt">消息</param>
 public void AppendText(string txt)
 {
     if (InvokeRequired)
     {
         this.Invoke(new Action <string>(AppendText), txt);
     }
     else
     {
         listBox1.Items.Insert(0, string.Format("{0}-{1}" + Environment.NewLine, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), txt));
         LogHelper.Debug(txt);
     }
 }
Beispiel #6
0
        private void Msg(string str, bool value)
        {
            string tempstr = null;
            bool   sign    = false;

            try
            {
                var arrRight = new List <object>();
                foreach (var tmpist in listBox2.Items)
                {
                    arrRight.Add(tmpist);
                }
                if (value)
                {
                    foreach (string tmplist in arrRight)
                    {
                        if (tmplist.IndexOf("-") > -1)
                        {
                            tempstr = tmplist.Substring(tmplist.IndexOf("-") + 1, tmplist.Length - tmplist.IndexOf("-") - 1);
                        }
                        if (tempstr == (str + "\r\n"))
                        {
                            sign = true;
                            break;
                        }
                    }
                    if (!sign)
                    {
                        listBox2.Items.Insert(0, (string.Format("{0}-{1}" + Environment.NewLine, DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss"), str)));
                        LogHelper.Error(str);
                    }
                }
                else
                {
                    foreach (string tmplist in arrRight)
                    {
                        if (tmplist.IndexOf("-") > -1)
                        {
                            tempstr = tmplist.Substring(tmplist.IndexOf("-") + 1, tmplist.Length - tmplist.IndexOf("-") - 1);
                            if (tempstr == (str + "\r\n"))
                            {
                                listBox2.Items.Remove(tmplist);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                AppendText("消息显示异常:" + ex.ToString());
            }
        }
Beispiel #7
0
        /// <summary>
        /// 扫描事件
        /// </summary>
        /// <param name="isCloseWhenCancel">是否换型</param>
        private void SelectMode()
        {
            try
            {
                bool isAdmin = Global.userLevel == UserLevel.设计者 || Global.userLevel == UserLevel.工程师;
                using (svfrmScanAndSelectMode frm = new svfrmScanAndSelectMode(AppConfig.ProductIntrinsicConfigModel, isAdmin))
                {
                    frm.ShowDialog();
                    if (string.IsNullOrEmpty(frm.A2C))
                    {
                        Close();
                        return;
                    }
                    AppConfig.ProductPath      = frm.A2C;
                    interLockingParam.Instance = SerializerManager <interLockingParam> .Instance.Load(AppConfig.MesConfigPathName);

                    locking = new Locking();
                    interLockingParam.Instance.EvData.DeviceA2C = frm.A2C;
                    interLockingParam.Instance.EvData.LoginName = lbJobnumber.Text;
                    lbA2C.Text         = AppConfig.ProductPath;
                    lbModel.Text       = interLockingParam.Instance.EvData.ModelName = frm.Model;
                    lb.Text            = interLockingParam.Instance.EvData.StationID = Config.Instance.StationID;
                    lbCustomer.Text    = frm.Customer;
                    lbStationName.Text = frm.Line;
                    Delay.Instance     = SerializerManager <Delay> .Instance.Load(AppConfig.ConfigDelayName);

                    Position.Instance = SerializerManager <Position> .Instance.Load(AppConfig.ConfigPositionName);

                    ProductConfig.Instance = SerializerManager <ProductConfig> .Instance.Load(AppConfig.ConfigOtherParamName);

                    interlock = new InterlockingClass();
                    lbInterlockingModel.Text = ProductConfig.Instance.switchCom.ToString();
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error("扫描调取程序异常", ex);
            }
        }
Beispiel #8
0
        private void FrmMain_FormClosing(object sender, FormClosingEventArgs e)
        {
            IoPoints.Y16.Value = false;

            DialogResult result = MessageBox.Show("是否保存配置文件再退出?", "退出", MessageBoxButtons.YesNoCancel);

            if (result == DialogResult.Yes)
            {
                threadStatusCheck?.Abort();
                threadMachineRun?.Abort();
                threadAlarmCheck?.Abort();
                SerializerManager <Config> .Instance.Save(AppConfig.ConfigIntrinsicProductPathdName, Config.Instance);

                SerializerManager <AxisParameter> .Instance.Save(AppConfig.ConfigIntrinsicParamAxisCardName, AxisParameter.Instance);

                SerializerManager <Position> .Instance.Save(AppConfig.ConfigPositionName, Position.Instance);

                SerializerManager <Delay> .Instance.Save(AppConfig.ConfigDelayName, Delay.Instance);

                SerializerManager <ProductConfig> .Instance.Save(AppConfig.ConfigOtherParamName, ProductConfig.Instance);

                SerializerManager <interLockingParam> .Instance.Save(AppConfig.MesConfigPathName, interLockingParam.Instance);

                Thread.Sleep(200);
                LogHelper.Debug("配置文件已保存");
            }
            else if (result == DialogResult.No)
            {
                threadStatusCheck?.Abort();
                threadMachineRun?.Abort();
                threadAlarmCheck?.Abort();
                LogHelper.Debug("配置文件不保存");
            }
            else
            {
                e.Cancel = true;
            }
        }
Beispiel #9
0
 private void 工位操作ToolStripMenuItem_Click_1(object sender, EventArgs e)
 {
     LogHelper.Debug("参数设置操作");
     new frmParameter(m_station1).ShowDialog();
 }
Beispiel #10
0
 private void 图像学习ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     LogHelper.Debug("示教操作");
     new frmTeach(m_station1).ShowDialog();
 }
Beispiel #11
0
 private void toolCleanData_Click(object sender, EventArgs e)
 {
     LogHelper.Debug("数据清除操作");
 }
Beispiel #12
0
        private void frmMain_Load(object sender, EventArgs e)
        {
            UserLevelChangeEvent += UserLevelChange;
            Global.userLevel      = UserLevel.操作员;
            OnUserLevelChange(Global.userLevel);

            new Thread(new ThreadStart(() =>
            {
                frmStarting loading = new frmStarting(8);
                LoadingMessage     += new Action <string>(loading.ShowMessage);
                loading.ShowDialog();
            })).Start();
            Thread.Sleep(500);

            Config.Instance = SerializerManager <Config> .Instance.Load(AppConfig.ConfigIntrinsicProductPathdName);

            AxisParameter.Instance = SerializerManager <AxisParameter> .Instance.Load(AppConfig.ConfigIntrinsicParamAxisCardName);

            #region  加载板卡

            LoadingMessage("加载板卡信息");
            try
            {
                IoPoints.ApsController.Initialize();
                if (!IoPoints.ApsController.LoadParamFromFile(AppConfig.ConfigAxisCardName("Param0.cfg")))
                {
                    AppendText("配置文件失败:请将轴卡的配置文件" + ".cfg " + "拷贝到当前型号的路径下" + AppConfig.ConfigAxisCardName("Param0.cfg"));
                }
            }
            catch (Exception ex)
            {
                LogHelper.Error(ex.Message);
                AppendText("板卡初始化失败!请检查硬件!");
                timer1.Enabled = false;
            }
            #endregion

            #region 气缸信息

            LoadingMessage("加载气缸资源");
            var SwichCylinder = new DoubleCylinder(IoPoints.S15, IoPoints.S16, IoPoints.Y13, IoPoints.Y14)
            {
                Name      = "切换气缸",
                Delay     = Delay.Instance.SwitchCylinderDelay,
                Condition = new CylinderCondition(() => { return(true); }, () => { return(true); })
                {
                    External = m_External
                }
            };
            var LeftCylinder = new DoubleCylinder(IoPoints.S15, IoPoints.S16, IoPoints.Y13, IoPoints.Y14)
            {
                Name      = "左负压",
                Delay     = Delay.Instance.LeftCylinderDelay,
                Condition = new CylinderCondition(() => { return(true); }, () => { return(true); })
                {
                    External = m_External
                }
            };
            var RightCylinder = new DoubleCylinder(IoPoints.S15, IoPoints.S16, IoPoints.Y13, IoPoints.Y14)
            {
                Name      = "右负压",
                Delay     = Delay.Instance.RightCylinderDelay,
                Condition = new CylinderCondition(() => { return(true); }, () => { return(true); })
                {
                    External = m_External
                }
            };
            #endregion
            DM50S = new DM50S()
            {
                Name = "扫描枪"
            };
            try
            {
                DM50S.SetConnectionParam(Config.Instance.ReadCodePortConnectParam);
                DM50S.DeviceDataReceiveCompelete += new DataReceiveCompleteEventHandler(DealWithScrewDeviceReceiveData);
                DM50S.DeviceOpen();
            }
            catch (Exception ex)
            {
                MessageBox.Show(string.Format("{0}连接失败:{1}", DM50S.Name, ex.Message));
            }

            #region 轴信息

            LoadingMessage("加载轴控制资源");

            var XaxisServo = new StepAxis(IoPoints.ApsController)
            {
                NoId              = 0,
                Transmission      = AxisParameter.Instance.XTransParams,
                VelocityCurveHome = AxisParameter.Instance.HomeXVelocityCurve,
                VelocityCurveRun  = AxisParameter.Instance.XVelocityCurve,
                Speed             = 11,
                Name              = "相机X轴"
            };
            XaxisServo._condition = new Func <bool>(() =>
            {
                return(true);
            });
            var YaxisServo = new StepAxis(IoPoints.ApsController)
            {
                NoId              = 1,
                Transmission      = AxisParameter.Instance.YTransParams,
                VelocityCurveHome = AxisParameter.Instance.HomeYVelocityCurve,
                VelocityCurveRun  = AxisParameter.Instance.YVelocityCurve,
                Speed             = 11,
                Name              = "治具Y轴"
            };
            YaxisServo._condition = new Func <bool>(() => { return(true); });

            var ZaxisServo = new StepAxis(IoPoints.ApsController)
            {
                NoId              = 2,
                Transmission      = AxisParameter.Instance.ZTransParams,
                VelocityCurveHome = AxisParameter.Instance.HomeZVelocityCurve,
                VelocityCurveRun  = AxisParameter.Instance.ZVelocityCurve,
                Speed             = 11,
                Name              = "升降Z轴"
            };
            ZaxisServo._condition = new Func <bool>(() => { return(true); });
            var LFXaxisServo = new StepAxis(IoPoints.ApsController)
            {
                NoId              = 3,
                Transmission      = AxisParameter.Instance.LFXTransParams,
                VelocityCurveHome = AxisParameter.Instance.HomeLFXVelocityCurve,
                VelocityCurveRun  = AxisParameter.Instance.LFXVelocityCurve,
                Speed             = 11,
                Name              = "相机左前X轴"
            };
            LFXaxisServo._condition = new Func <bool>(() => { return(true); });
            var LFYaxisServo = new StepAxis(IoPoints.ApsController)
            {
                NoId              = 4,
                Transmission      = AxisParameter.Instance.LFYTransParams,
                VelocityCurveHome = AxisParameter.Instance.HomeLFYVelocityCurve,
                VelocityCurveRun  = AxisParameter.Instance.LFYVelocityCurve,
                Speed             = 11,
                Name              = "相机左前Y轴"
            };
            LFYaxisServo._condition = new Func <bool>(() => { return(true); });
            var LRXaxisServo = new StepAxis(IoPoints.ApsController)
            {
                NoId              = 5,
                Transmission      = AxisParameter.Instance.LRXTransParams,
                VelocityCurveHome = AxisParameter.Instance.HomeLRXVelocityCurve,
                VelocityCurveRun  = AxisParameter.Instance.LRXVelocityCurve,
                Speed             = 11,
                Name              = "相机左后X轴"
            };
            LRXaxisServo._condition = new Func <bool>(() => { return(true); });
            var LRYaxisServo = new StepAxis(IoPoints.ApsController)
            {
                NoId              = 6,
                Transmission      = AxisParameter.Instance.LRYTransParams,
                VelocityCurveHome = AxisParameter.Instance.HomeLRYVelocityCurve,
                VelocityCurveRun  = AxisParameter.Instance.LRYVelocityCurve,
                Speed             = 11,
                Name              = "相机左后Y轴"
            };
            LRYaxisServo._condition = new Func <bool>(() => { return(true); });
            var RYaxisServo = new StepAxis(IoPoints.ApsController)
            {
                NoId              = 7,
                Transmission      = AxisParameter.Instance.RYTransParams,
                VelocityCurveHome = AxisParameter.Instance.HomeRYVelocityCurve,
                VelocityCurveRun  = AxisParameter.Instance.RYVelocityCurve,
                Speed             = 11,
                Name              = "相机右Y轴"
            };
            RYaxisServo._condition = new Func <bool>(() => { return(true); });
            #endregion


            #region 工站模组操作

            LoadingMessage("加载模组操作资源");

            var Station1Initialize = new StationInitialize(
                () => { return(!ManualAutoMode); },
                () => { return(Station1IsAlarm.IsAlarm); });
            var Station1Operate = new StationOperate(
                () => { return(Station1Initialize.InitializeDone); },
                () => { return(Station1IsAlarm.IsAlarm); });



            MachineOperation = new MachineOperate(() =>
            {
                return(Station1Initialize.InitializeDone);
            }, () =>
            {
                return(Station1IsAlarm.IsAlarm | MachineIsAlarm.IsAlarm);
            });
            #endregion

            #region 雅马哈机器人
            yamaha = new Yamaha();
            if (!yamaha.Connect(Config.Instance.YamahaIP, Config.Instance.Port))
            {
                AppendText("机器人连接失败!");
            }
            #endregion

            #region 模组信息加载、启动

            LoadingMessage("加载模组信息");
            m_station1 = new Station1(m_External, Station1Initialize, Station1Operate)
            {
                mAlarmManage  = mAlarmManage,
                XaxisServo    = XaxisServo,
                YaxisServo    = YaxisServo,
                ZaxisServo    = ZaxisServo,
                LFXaxisServo  = LFXaxisServo,
                LFYaxisServo  = LFYaxisServo,
                LRXaxisServo  = LRXaxisServo,
                LRYaxisServo  = LRYaxisServo,
                RYaxisServo   = RYaxisServo,
                YAMAHA        = yamaha,
                SwichCylinder = SwichCylinder,
                LeftVacuum    = LeftCylinder,
                RightVacuum   = RightCylinder
            };
            m_station1.AddPart();
            m_station1.Run(RunningModes.Online);

            #endregion

            LoadingMessage("加载MES资源");
            #region 加载信号灯资源
            StartButton = new LightButton(IoPoints.S1, IoPoints.Y1);
            ResetButton = new LightButton(IoPoints.S2, IoPoints.Y10);
            PauseButton = new LightButton(IoPoints.S5, IoPoints.Y11);
            EstopButton = new EventButton(IoPoints.S3);
            StopButton  = new LightButton(IoPoints.S4, IoPoints.Y12);


            layerLight = new LayerLight(IoPoints.Y11, IoPoints.Y10, IoPoints.Y9, IoPoints.Y12);

            StartButton.Pressed  += btnStart_MouseDown;
            StartButton.Released += btnStart_MouseUp;
            PauseButton.Pressed  += btnPause_MouseDown;
            PauseButton.Released += btnPause_MouseUp;
            ResetButton.Pressed  += btnReset_MouseDown;
            ResetButton.Released += btnReset_MouseUp;

            MachineOperation.StartButton = StartButton;
            MachineOperation.PauseButton = PauseButton;
            MachineOperation.StopButton  = StopButton;
            MachineOperation.ResetButton = ResetButton;
            MachineOperation.EstopButton = EstopButton;
            #endregion
            ManualAutoMode = false;
            LoadingMessage("加载线程资源");
            SerialStart();

            timer1.Enabled = true;
        }