Пример #1
0
        /// <summary>
        /// 显示错误信息
        /// </summary>
        /// <param name="str"></param>
        public static void ShowMessage(string str)
        {
            MsgHelper.Instance.WriteLog(MsgLevel.Warn, str);
            frm_MessageBox frmmess = new frm_MessageBox(str, false, false);

            frmmess.ShowDialog();
        }
        private void StateMachine_AlarmEvent(Module arg1, string arg2)
        {
            frm_MessageBox fm = new frm_MessageBox($"{CommonHelper.GetEnumDescription(arg1.GetType(), arg1)}:{arg2}", true, true);

            if (fm.ShowDialog() != DialogResult.Yes)
            {
                SystemEntiy.Instance.FlowMachine[arg1].Pause();
            }
        }
Пример #3
0
        /// <summary>
        /// 报警 OK 取消
        /// </summary>
        /// <param name="str"></param>
        public static DialogResult ShowMessage_Alarm_OKCancel(string str)
        {
            frm_MessageBox frmmess = new frm_MessageBox(str, true, true);

            return(frmmess.ShowDialog());
        }
        private void bStart_Click(object sender, EventArgs e)
        {
            if (Variable.AlmProgram.ALMProName == string.Empty || Variable.AlmProgram.ALMProName == null)
            {
                MessageBox.Show("请先导入程式后再运行!!!");
                return;
            }

            if (GeneralSystem.Instance.Machines[0].IsRunning || GeneralSystem.Instance.Machines[1].IsRunning)
            {
                MessageBox.Show("机器正在运行");
                return;
            }

            this.cB_EN.Enabled        = false;
            this.bClearOut.Enabled    = false;
            this.bReset.Enabled       = false;
            this.cb_EnModule1.Enabled = false;
            this.cb_EnModule2.Enabled = false;

            this.bHalt.BackColor  = Color.White;
            this.bStart.BackColor = Color.Green;
            ErrorHelper.Instance.WriteLog(LogType.MachineStart);

            if (!GeneralSystem.Instance.Machines[0].IsSafeHeight ||
                !GeneralSystem.Instance.Machines[1].IsSafeHeight)
            {
                MessageBox.Show("机器不在安全高度!!!");
                GeneralSystem.Instance.Machines[0].ZGoSafeHeight(Definition.SpeedMode.Manual_Normal);
                GeneralSystem.Instance.Machines[1].ZGoSafeHeight(Definition.SpeedMode.Manual_Normal);
                return;
            }

            GeneralSystem.Instance.Machines[0].XYGoPos(GeneralSystem.Instance.Machines[0].Config.ReadyPoint, Definition.SpeedMode.Manual_Normal);
            GeneralSystem.Instance.Machines[1].XYGoPos(GeneralSystem.Instance.Machines[1].Config.ReadyPoint, Definition.SpeedMode.Manual_Normal);

            Thread.Sleep(100);
            while (!GeneralSystem.Instance.Machines[0].XYReach(GeneralSystem.Instance.Machines[0].Config.ReadyPoint) ||
                   !GeneralSystem.Instance.Machines[1].XYReach(GeneralSystem.Instance.Machines[1].Config.ReadyPoint))
            {
                Application.DoEvents();
                Thread.Sleep(100);
            }

            try
            {
                GeneralSystem.Instance.Machines[0].RUN_PasteInfo = new Definition.MutiBaseInfo();
                GeneralSystem.Instance.Machines[1].RUN_PasteInfo = new Definition.MutiBaseInfo();

                GeneralSystem.Instance.Machines[0].FeederList = Variable.AlmProgram.FeederInfo_Module1.Values.ToList();
                GeneralSystem.Instance.Machines[1].FeederList = Variable.AlmProgram.FeederInfo_Module2.Values.ToList();
                GeneralSystem.Instance.Machines[0].RUN_PasteInfo.BaseInfoList = new List <Definition.BaseInfo>();
                GeneralSystem.Instance.Machines[1].RUN_PasteInfo.BaseInfoList = new List <Definition.BaseInfo>();
                GeneralSystem.Instance.Machines[0].DownParam = Variable.AlmProgram.DownCapture_Module1;
                GeneralSystem.Instance.Machines[1].DownParam = Variable.AlmProgram.DownCapture_Module2;

                GeneralSystem.Instance.Machines[0].RUN_PasteInfo.OffsetX = new SerializableDictionary <int, List <double> >();
                GeneralSystem.Instance.Machines[0].RUN_PasteInfo.OffsetX.Add(0, new List <double>());

                GeneralSystem.Instance.Machines[0].RUN_PasteInfo.OffsetY = new SerializableDictionary <int, List <double> >();
                GeneralSystem.Instance.Machines[0].RUN_PasteInfo.OffsetY.Add(0, new List <double>());

                GeneralSystem.Instance.Machines[0].RUN_PasteInfo.OffsetR = new SerializableDictionary <int, List <double> >();
                GeneralSystem.Instance.Machines[0].RUN_PasteInfo.OffsetR.Add(0, new List <double>());
                GeneralSystem.Instance.Machines[0].RUN_PasteInfo.OffsetFly = new List <double>();

                GeneralSystem.Instance.Machines[1].RUN_PasteInfo.OffsetX = new SerializableDictionary <int, List <double> >();
                GeneralSystem.Instance.Machines[1].RUN_PasteInfo.OffsetX.Add(0, new List <double>());

                GeneralSystem.Instance.Machines[1].RUN_PasteInfo.OffsetY = new SerializableDictionary <int, List <double> >();
                GeneralSystem.Instance.Machines[1].RUN_PasteInfo.OffsetY.Add(0, new List <double>());

                GeneralSystem.Instance.Machines[1].RUN_PasteInfo.OffsetR = new SerializableDictionary <int, List <double> >();
                GeneralSystem.Instance.Machines[1].RUN_PasteInfo.OffsetR.Add(0, new List <double>());
                GeneralSystem.Instance.Machines[1].RUN_PasteInfo.OffsetFly = new List <double>();

                try
                {
                    GeneralSystem.Instance.Machines[0]._session_Up.Acquisition.Unconfigure();
                    GeneralSystem.Instance.Machines[0]._session_Up.ConfigureGrab();

                    GeneralSystem.Instance.Machines[1]._session_Up.Acquisition.Unconfigure();
                    GeneralSystem.Instance.Machines[1]._session_Up.ConfigureGrab();

                    GeneralSystem.Instance.Machines[0]._session_Down.Acquisition.Unconfigure();
                    GeneralSystem.Instance.Machines[0]._session_Down.ConfigureGrab();

                    GeneralSystem.Instance.Machines[1]._session_Down.Acquisition.Unconfigure();
                    GeneralSystem.Instance.Machines[1]._session_Down.ConfigureGrab();
                }
                catch { }

                // 分配板子
                for (int i = 0; i < Variable.AlmProgram.MutiBaseInfo.VisionProName_Base.Count; ++i)
                {
                    if (Variable.AlmProgram.MutiBaseInfo.BaseInfoList[i].Base_Module[0] == 1)
                    {
                        GeneralSystem.Instance.Machines[0].RUN_PasteInfo.FOVCount_Base.Add(Variable.AlmProgram.MutiBaseInfo.FOVCount_Base[i]);
                        GeneralSystem.Instance.Machines[0].RUN_PasteInfo.BaseInfoList.Add(Variable.AlmProgram.MutiBaseInfo.BaseInfoList[i]);
                        GeneralSystem.Instance.Machines[0].RUN_PasteInfo.Cam_Mark1Point.Add(Variable.AlmProgram.MutiBaseInfo.Cam_Mark1Point[i]);
                        GeneralSystem.Instance.Machines[0].RUN_PasteInfo.Cam_Mark2Point.Add(Variable.AlmProgram.MutiBaseInfo.Cam_Mark2Point[i]);
                        GeneralSystem.Instance.Machines[0].RUN_PasteInfo.VisionProName_Base.Add(Variable.AlmProgram.MutiBaseInfo.VisionProName_Base[i]);

                        GeneralSystem.Instance.Machines[0].RUN_PasteInfo.OffsetX[0].Add(Variable.AlmProgram.MutiBaseInfo.OffsetX[0][i]);
                        GeneralSystem.Instance.Machines[0].RUN_PasteInfo.OffsetY[0].Add(Variable.AlmProgram.MutiBaseInfo.OffsetY[0][i]);
                        GeneralSystem.Instance.Machines[0].RUN_PasteInfo.OffsetR[0].Add(Variable.AlmProgram.MutiBaseInfo.OffsetR[0][i]);
                        GeneralSystem.Instance.Machines[0].RUN_PasteInfo.OffsetFly.Add(Variable.AlmProgram.MutiBaseInfo.OffsetFly[i]);
                    }
                    else
                    {
                        GeneralSystem.Instance.Machines[1].RUN_PasteInfo.FOVCount_Base.Add(Variable.AlmProgram.MutiBaseInfo.FOVCount_Base[i]);
                        GeneralSystem.Instance.Machines[1].RUN_PasteInfo.BaseInfoList.Add(Variable.AlmProgram.MutiBaseInfo.BaseInfoList[i]);
                        GeneralSystem.Instance.Machines[1].RUN_PasteInfo.Cam_Mark1Point.Add(Variable.AlmProgram.MutiBaseInfo.Cam_Mark1Point[i]);
                        GeneralSystem.Instance.Machines[1].RUN_PasteInfo.Cam_Mark2Point.Add(Variable.AlmProgram.MutiBaseInfo.Cam_Mark2Point[i]);
                        GeneralSystem.Instance.Machines[1].RUN_PasteInfo.VisionProName_Base.Add(Variable.AlmProgram.MutiBaseInfo.VisionProName_Base[i]);

                        GeneralSystem.Instance.Machines[1].RUN_PasteInfo.OffsetX[0].Add(Variable.AlmProgram.MutiBaseInfo.OffsetX[1][i]);
                        GeneralSystem.Instance.Machines[1].RUN_PasteInfo.OffsetY[0].Add(Variable.AlmProgram.MutiBaseInfo.OffsetY[1][i]);
                        GeneralSystem.Instance.Machines[1].RUN_PasteInfo.OffsetR[0].Add(Variable.AlmProgram.MutiBaseInfo.OffsetR[1][i]);
                        GeneralSystem.Instance.Machines[1].RUN_PasteInfo.OffsetFly.Add(Variable.AlmProgram.MutiBaseInfo.OffsetFly[i]);
                    }
                }

                GeneralSystem.Instance.Machines[0].IsMain = true;
                GeneralSystem.Instance.Machines[1].IsMain = true;

                lock (ConveryManager.Instance.lockobj)
                {
                    if (ConveryManager.Instance.CurrentStatus == ConveryManager.ConveryStatus.Idle)
                    {
                        ConveryManager.Instance.FlowInit      = false;
                        ConveryManager.Instance.CurrentStatus = ConveryManager.ConveryStatus.Input;
                    }
                }

                if (!GeneralSystem.Instance.Machines[0].Config.EN_Runing &&
                    !GeneralSystem.Instance.Machines[1].Config.EN_Runing)
                {
                    frm_MessageBox fm = new frm_MessageBox(frm_Main, "两个模组都被屏蔽,请开启!!!", false, true);
                    fm.ShowDialog();
                    return;
                }

                if (GeneralSystem.Instance.Machines[0].Config.EN_Runing)
                {
                    GeneralSystem.Instance.Machines[0].StartMachine();
                }
                else
                {
                    GeneralSystem.Instance.Machines[0].PasueMachine();
                }

                if (GeneralSystem.Instance.Machines[1].Config.EN_Runing)
                {
                    GeneralSystem.Instance.Machines[1].StartMachine();
                }
                else
                {
                    GeneralSystem.Instance.Machines[1].PasueMachine();
                }

                ConveryManager.Instance.StartConvery();
                this.timerRefresh.Start();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"程序自动运行失败{ex.Message}");
                return;
            }
        }