Пример #1
0
        /// <summary>停止运行</summary>
        public virtual bool Stop(out string errorInfo)
        {
            errorInfo = "Unknown Error";
            //if (!IsStationRunning(WorkStatus))
            //{
            //    errorInfo = "Success";
            //    return true;
            //}
            JFStationManager stationMgr = JFHubCenter.Instance.StationMgr;


            string[] allEnableStationNames = stationMgr.AllEnabledStationNames();
            if (null == allEnableStationNames || 0 == allEnableStationNames.Length)
            {
                errorInfo = "Success";
                return(true);
            }

            foreach (string stationName in allEnableStationNames) // 先检查有没有正在运行的工站
            {
                IJFStation station = stationMgr.GetStation(stationName);
                if (IsStationRunning(station.CurrWorkStatus))
                {
                    JFWorkCmdResult ret = station.Stop(1000);
                    if (ret != JFWorkCmdResult.Success)
                    {
                        station.Abort();
                    }
                }
            }

            WorkStatus = JFWorkStatus.CommandExit;
            errorInfo  = "Success";
            return(true);
        }
Пример #2
0
        private void FormManual_VisibleChanged(object sender, EventArgs e)
        {
            if (Visible)
            {
                AdjustStationList();
                if (toolStripMenuItemSysTemDataPool.Checked)
                {
                    fmSysDP.Show();
                }


                ///开始单工站界面刷新
                if (tabControlCF1.SelectedIndex > 0)
                {
                    (tabControlCF1.SelectedTab.Controls[0] as FormSingleStationTest).EnableFlushStationUi = true;
                }
            }
            else
            {
                JFStationManager mgr = JFHubCenter.Instance.StationMgr;
                fmSysDP.Hide(); //隐藏系统数据池显示
                if (tabControlCF1.SelectedIndex > 0)
                {
                    (tabControlCF1.SelectedTab.Controls[0] as FormSingleStationTest).EnableFlushStationUi = false;
                }
            }
        }
Пример #3
0
        /// <summary>
        /// 设备运行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btStart_Click(object sender, EventArgs e)
        {
            IJFMainStation ms = JFHubCenter.Instance.StationMgr.MainStation;

            if (ms.WorkStatus == JFWorkStatus.Running)
            {
                JFTipsDelayClose.Show("无效操作:正在运行中", 2);
                return;
            }
            string errorInfo;

            if (!_isStationWorking(ms.WorkStatus))
            {
                ///先将所有使能工站切换为自动模式
                JFStationManager mgr = JFHubCenter.Instance.StationMgr;
                string[]         allEnableStationNames = mgr.AllEnabledStationNames();
                if (null != allEnableStationNames)
                {
                    foreach (string sn in allEnableStationNames)
                    {
                        IJFStation station = mgr.GetStation(sn);
                        if (!station.SetRunMode(JFStationRunMode.Auto))
                        {
                            MessageBox.Show("启动运行失败,未能将工站:" + sn + "切换为自动运行模式");
                            return;
                        }
                    }
                }


                //// 添加消息回调
                //string[] allEnableStationNames = JFHubCenter.Instance.StationMgr.AllEnabledStationNames();
                bool isOK = ms.Start(out errorInfo);
                if (!isOK)
                {
                    MessageBox.Show("启动失败:" + errorInfo);
                    return;
                }
                else
                {
                    JFTipsDelayClose.Show("设备开始运行", 1);
                }
            }

            if (ms.WorkStatus == JFWorkStatus.Pausing) //当前处于暂停状态
            {
                bool isOK = ms.Resume(out errorInfo);
                if (!isOK)
                {
                    MessageBox.Show("恢复运行失败:" + errorInfo);
                    return;
                }
                else
                {
                    JFTipsDelayClose.Show("设备开始运行", 1);
                }
            }
        }
Пример #4
0
        string[] _currStations = null; //当前正在显示的工站


        /// <summary>
        /// 根据当前已激活的工站,布局界面
        /// </summary>
        public void AdjustView()
        {
            if (InvokeRequired)
            {
                Invoke(new Action(AdjustView));
                return;
            }
            JFStationManager stationMgr = JFHubCenter.Instance.StationMgr;

            string[] allEnabledStationName = stationMgr.AllEnabledStationNames();
            if (allEnabledStationName == null || allEnabledStationName.Length == 0)
            {
                _currStations = null;
                pnStations.Controls.Clear();
                return;
            }

            if (_currStations != null)
            {
                if (_currStations.Length == allEnabledStationName.Length)
                {
                    bool isSame = true;
                    for (int i = 0; i < _currStations.Length; i++)
                    {
                        if (_currStations[i] != allEnabledStationName[i])
                        {
                            isSame = false;
                            break;
                        }
                    }
                    if (isSame) //不需要更新界面
                    {
                        return;
                    }
                }
            }
            _currStations = allEnabledStationName;
            //将当前工站界面和消息回调解除绑定
            foreach (Control ui in pnStations.Controls)
            {
                stationMgr.RemoveStationMsgReciever(ui as IJFStationMsgReceiver);
            }
            pnStations.Controls.Clear();
            foreach (string enabledStationName in allEnabledStationName)
            {
                IJFStation station = stationMgr.GetStation(enabledStationName);
                //JFRealtimeUI ui = station.GetRealtimeUI(); //如果station不提供界面,则提供一个默认的
                //if(null == ui)
                UcStationRealtimeUI ui = new UcStationRealtimeUI();
                ui.JfDisplayMode = UcStationRealtimeUI.JFDisplayMode.simple;
                ui.SetStation(station);
                stationMgr.AppendStationMsgReceiver(station, ui);
                pnStations.Controls.Add(ui);
            }
        }
Пример #5
0
        void AdjustStationList() //
        {
            JFStationManager mgr = JFHubCenter.Instance.StationMgr;

            string[] allStationNames = mgr.AllStationNames();
            if (null == allStationNames || 0 == allStationNames.Length)
            {
                _currStationNames = null;
                tabControlCF1.TabPages.Clear();
                toolStripMenuItemStations.DropDownItems.Clear();
                return;
            }

            if (null != _currStationNames && _currStationNames.Length == allStationNames.Length)
            {
                bool isSame = true;
                for (int i = 0; i < _currStationNames.Length; i++)
                {
                    if (_currStationNames[i] != allStationNames[i])
                    {
                        isSame = false;
                        break;
                    }
                }
                if (isSame)
                {
                    _CheckStationNamesInMenu();
                    return;
                }
            }
            _currStationNames = allStationNames;

            tabControlCF1.TabPages.Clear();
            _dctStationForms.Clear();
            foreach (string stationName in allStationNames)
            {
                TabPage tp = new TabPage(stationName);
                FormSingleStationTest fmStationTest = new FormSingleStationTest();
                fmStationTest.SetStation(mgr.GetStation(stationName));
                fmStationTest.FormBorderStyle = FormBorderStyle.None;
                fmStationTest.TopLevel        = false;
                fmStationTest.ShowInTaskbar   = false;
                fmStationTest.Dock            = DockStyle.Fill;
                fmStationTest.Parent          = tp;
                fmStationTest.Show();
                tp.Controls.Add(fmStationTest);
                tabControlCF1.TabPages.Add(tp);
                ToolStripMenuItem tsi = new ToolStripMenuItem(stationName, null, onToolStipItemStationClicked);
                toolStripMenuItemStations.DropDownItems.Add(tsi);
                _dctStationForms.Add(mgr.GetStation(stationName), fmStationTest);
            }
            _CheckStationNamesInMenu();
        }
Пример #6
0
        string[] _currStationNames = null; //当前正在显示的工站列表


        /// <summary>
        /// 检查启动工站列表项
        /// </summary>
        void _CheckStationNamesInMenu() //
        {
            JFStationManager mgr = JFHubCenter.Instance.StationMgr;

            string[] allEnabledStaions = mgr.AllEnabledStationNames();
            if (allEnabledStaions == null || allEnabledStaions.Length == 0)
            {
                toolStripMenuItemStations.DropDownItems.Clear();
                return;
            }
            List <string> currStations = new List <string>(); //当前列表中的工站
            List <string> chkdStations = new List <string>();

            foreach (ToolStripMenuItem mi in toolStripMenuItemStations.DropDownItems)
            {
                currStations.Add(mi.Text);
                if (mi.Checked)
                {
                    chkdStations.Add(mi.Text);
                }
            }
            List <string> checkedStatios = new List <string>(); //当前已选中参与测试的工站

            if (allEnabledStaions.Length == currStations.Count)
            {
                bool isSame = true;
                for (int i = 0; i < allEnabledStaions.Length; i++)
                {
                    if (allEnabledStaions[i] != currStations[i])
                    {
                        isSame = false;
                        break;
                    }
                }
                if (isSame)
                {
                    return;
                }
            }
            toolStripMenuItemStations.DropDownItems.Clear();
            foreach (string s in allEnabledStaions)
            {
                ToolStripMenuItem mi = new ToolStripMenuItem(s, null, onToolStipItemStationClicked);
                toolStripMenuItemStations.DropDownItems.Add(mi);
                if (chkdStations.Contains(s))
                {
                    mi.Checked = true;
                }
            }
        }
Пример #7
0
        private void FormManual_Load(object sender, EventArgs e)
        {
            fmSysDP.SetDataPool(JFHubCenter.Instance.DataPool);
            fmSysDP.HideWhenClose   = true;
            fmSysDP.TopMost         = true;
            fmSysDP.VisibleChanged += SysDataPoolFormDisabled;
            AdjustStationList();

            //StationManager 消息挂靠
            JFStationManager mgr = JFHubCenter.Instance.StationMgr;

            mgr.EventStationWorkStatusChanged   += OnStationWorkStatusChanged;
            mgr.EventStationCustomStatusChanged += OnStationCustomStatusChanged;
            mgr.EventStationProductFinished     += OnStationProductFinished;
            mgr.EventStationCustomizeMsg        += OnStationCustomizeMsg;
            mgr.EventStationTxtMsg += OnStationTxtMsg;
        }
Пример #8
0
        private void btAuto_Click(object sender, EventArgs e)
        {
            if (IsAutoRunning) //当前处于自动化运行模式
            {
                JustShowSubForm(_autoForm);
            }
            else //非自动运行状态,可能有工站正在运行测试
            {
                JFStationManager stationMgr            = JFHubCenter.Instance.StationMgr;
                string[]         allEnableStationNames = stationMgr.AllEnabledStationNames();
                if (null == allEnableStationNames || allEnableStationNames.Length == 0)
                {
                    JustShowSubForm(_autoForm);
                    statusLabelRunMode.Text = "自动运行";
                    return;
                }


                List <IJFStation> runningStations = new List <IJFStation>();
                foreach (string sn in allEnableStationNames)
                {
                    IJFStation station = stationMgr.GetStation(sn);
                    if (_isStationWorking(station.CurrWorkStatus))
                    {
                        runningStations.Add(station);
                    }
                }

                if (runningStations.Count > 0)
                {
                    StringBuilder sbInfo = new StringBuilder("切换到自动运行模式失败,以下工站未停止:\n");
                    foreach (IJFStation station in runningStations)
                    {
                        sbInfo.AppendLine("工站:" + station.Name + " 当前状态:" + station.CurrWorkStatus.ToString());
                    }
                    JFTipsDelayClose.Show(sbInfo.ToString(), 5);
                    return;
                }
                IsAutoRunning = true;
                JustShowSubForm(_autoForm);
                statusLabelRunMode.Text = "自动运行";
            }
        }
Пример #9
0
        /// <summary>从暂停中恢复运行</summary>
        public virtual bool Resume(out string errorInfo)
        {
            errorInfo = "Unknown Error";
            if (WorkStatus == JFWorkStatus.Running)
            {
                errorInfo = "当前正在运行!恢复运行指令将被忽略";
                return(true);
            }
            if (WorkStatus != JFWorkStatus.Pausing)
            {
                errorInfo = "当前状态 = " + WorkStatus + ",不能响应恢复运行指令";
                return(false);
            }

            JFStationManager stationMgr = JFHubCenter.Instance.StationMgr;

            string[] allEnableStationNames = stationMgr.AllEnabledStationNames();
            if (null == allEnableStationNames || 0 == allEnableStationNames.Length)
            {
                errorInfo = "无使能工站";
                return(false);
            }

            foreach (string sn in allEnableStationNames)
            {
                IJFStation      station = stationMgr.GetStation(sn);
                JFWorkCmdResult ret     = station.Resume(1000);
                if (ret != JFWorkCmdResult.Success)
                {
                    errorInfo = "工站:" + station.Name + "恢复运行失败:" + ret.ToString();
                    return(false);
                }
            }

            errorInfo  = "Success";
            WorkStatus = JFWorkStatus.Running;
            return(true);
        }
Пример #10
0
        /// <summary>暂停</summary>
        public virtual bool Pause(out string errorInfo)
        {
            errorInfo = "Unknown Error";
            if (WorkStatus != JFWorkStatus.Running)
            {
                errorInfo = "设备当前状态:" + WorkStatus.ToString();
                return(false);
            }
            if (WorkStatus == JFWorkStatus.Pausing)
            {
                errorInfo = "Success";
                return(true);
            }
            JFStationManager stationMgr = JFHubCenter.Instance.StationMgr;

            string[] allEnableStationNames = stationMgr.AllEnabledStationNames();
            if (null == allEnableStationNames || 0 == allEnableStationNames.Length)
            {
                errorInfo = "无使能工站";
                return(false);
            }

            foreach (string sn in allEnableStationNames)
            {
                IJFStation      station = stationMgr.GetStation(sn);
                JFWorkCmdResult ret     = station.Pause(-1);
                if (ret != JFWorkCmdResult.Success)
                {
                    errorInfo = "工站:" + station.Name + " 暂停失败:" + ret.ToString();
                    return(false);
                }
            }

            WorkStatus = JFWorkStatus.Pausing;
            errorInfo  = "Success";
            return(true);
        }
Пример #11
0
        Dictionary <IJFStation, FormSingleStationTest> _dctTestingForms = new Dictionary <IJFStation, FormSingleStationTest>(); //参与当前测试的

        /// <summary>
        /// 启动所有选中的工站
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btStart_Click(object sender, EventArgs e)
        {
            if (_isTesting)
            {
                MessageBox.Show("无效操作,当前测试正在运行");
                return;
            }

            string[] willTestStationNames = TestStationNames();
            if (null == willTestStationNames || 0 == willTestStationNames.Length)
            {
                MessageBox.Show("请先选择参与测试运行的工站!\n菜单->启动测试");
                return;
            }

            JFStationManager mgr = JFHubCenter.Instance.StationMgr;

            string[]      allStationNames     = mgr.AllStationNames();
            List <string> runningStationNames = new List <string>(); //当前正在运行的工站

            foreach (string s in allStationNames)
            {
                if (JFStationBase.IsWorkingStatus(mgr.GetStation(s).CurrWorkStatus))
                {
                    runningStationNames.Add(s);
                }
            }
            if (runningStationNames.Count > 0)
            {
                string info = "以下工站正在运行:\n";
                foreach (string s in runningStationNames)
                {
                    info += s + "\n";
                }
                info += "是否继续?";
                if (DialogResult.Cancel == MessageBox.Show(info, "警告", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning))
                {
                    return;
                }
            }
            _isTesting = true;
            //mgr.EventStationWorkStatusChanged += OnStationWorkStatusChanged;
            _dctTestingForms.Clear();

            string Tipsinfo = "已启动工站:\n";

            foreach (string s in willTestStationNames)
            {
                IJFStation station = mgr.GetStation(s);
                _dctTestingForms.Add(station, _dctStationForms[station]);
                //_dctStationForms[station].EnableStationMsgReceive = true;
                JFWorkCmdResult ret = station.Start();
                if (ret != JFWorkCmdResult.Success) //启动工站失败
                {
                    //_dctStationForms[station].EnableStationMsgReceive = false;
                    foreach (KeyValuePair <IJFStation, FormSingleStationTest> kv in _dctTestingForms)
                    {
                        if (kv.Key.Stop(500) != JFWorkCmdResult.Success)
                        {
                            kv.Key.Abort();
                        }
                    }
                    _isTesting = false;
                    MessageBox.Show("启动工站:" + station.Name + "失败,ErrorCode = " + ret);
                    return;
                }

                Tipsinfo += s + "\n";

                JFTipsDelayClose.Show(Tipsinfo, 2);
                btReset.Enabled  = false;
                btResume.Enabled = true;
                btPause.Enabled  = true;
            }
        }
Пример #12
0
        private void FormMain_Load(object sender, EventArgs e)
        {
            ///检查APP运行的条件
            //1.检查主工站是否注册
            //if(JFHubCenter.Instance.StationMgr.MainStation == null)
            //{
            //    MessageBox.Show("Main-Station is not regist ,App will Exit!");
            //    Application.Exit();
            //}

            ////功能窗口初始化
            _autoForm          = new FormAuto();
            _autoForm.TopLevel = false;
            _autoForm.Parent   = subFormPanel;
            _autoForm.Dock     = DockStyle.Fill;

            _manualForm      = new FormManual();
            _manualForm.Dock = DockStyle.Fill;
            //_manualForm.Visible = false;
            _manualForm.TopLevel = false;
            _manualForm.Parent   = subFormPanel;
            _cfgForm             = new FormCfg(); //设置窗口
            _cfgForm.Dock        = DockStyle.Fill;
            //_cfgForm.Visible = false;
            _cfgForm.TopLevel = false;
            _cfgForm.Parent   = subFormPanel;
            _logForm          = new FormLog(); //日志窗口
            _logForm.Dock     = DockStyle.Fill;
            _logForm.TopLevel = false;
            //_logForm.Visible = false;
            _logForm.Parent     = subFormPanel;
            _briefForm          = new FormBrief(); //机器简介窗口
            _briefForm.Dock     = DockStyle.Fill;
            _briefForm.TopLevel = false;
            // _briefForm.Visible = false;
            _briefForm.Parent = subFormPanel;
            _userForm         = new FormUser(); //用户权限管理窗口
            _userForm.Dock    = DockStyle.Fill;
            // _userForm.Visible = false;
            _userForm.TopLevel = false;
            _userForm.Parent   = subFormPanel;
            _visionForm        = new FormVision(); //视觉调试窗口
            _visionForm.Dock   = DockStyle.Fill;
            //_visionForm.Visible = false;
            _visionForm.TopLevel = false;
            _visionForm.Parent   = subFormPanel;


            base.OnResize(e);

            //控件根据窗体的大小变化而变化,等比例放大缩小
            this.Resize += new EventHandler(FormResize);
            oldX         = this.Width;
            oldY         = this.Height;
            SetTag(this);
            FormResize(new object(), new EventArgs());
            this.WindowState = System.Windows.Forms.FormWindowState.Maximized;//窗体全屏打开


            _autoForm.Show();


            //StationManager 消息挂靠
            JFStationManager mgr = JFHubCenter.Instance.StationMgr;

            mgr.EventStationWorkStatusChanged   += OnStationWorkStatusChanged;
            mgr.EventStationCustomStatusChanged += OnStationCustomStatusChanged;
            mgr.EventStationProductFinished     += OnStationProductFinished;

            _sriForm.TopMost = true;
        }
Пример #13
0
        public virtual bool Start(out string errorInfo)//开始运行
        {
            errorInfo = "Unknown Error";
            if (IsAlarming)
            {
                errorInfo = "当前处于报警状态";
                return(false);
            }
            if (IsStationRunning(WorkStatus))
            {
                errorInfo = "Success";
                return(true);
            }

            JFDLAFRecipeManager rm = JFHubCenter.Instance.RecipeManager as JFDLAFRecipeManager;

            if (null == rm)
            {
                errorInfo = "配方管理器未创建!";
                return(false);
            }
            if (!rm.IsInitOK)
            {
                errorInfo = "配方管理器初始化未完成,ErrorInfo:" + rm.GetInitErrorInfo();
                return(false);
            }



            JFStationManager stationMgr = JFHubCenter.Instance.StationMgr;


            string[] allEnableStationNames = stationMgr.AllEnabledStationNames();
            if (null == allEnableStationNames || 0 == allEnableStationNames.Length)
            {
                errorInfo = "不存在使能的工站";
                return(false);
            }

            foreach (string stationName in allEnableStationNames) // 先检查有没有正在运行的工站
            {
                IJFStation station = stationMgr.GetStation(stationName);
                if (IsStationRunning(station.CurrWorkStatus))
                {
                    errorInfo = "启动失败,工站:" + station.Name + " 当前状态:" + station.CurrWorkStatus.ToString();
                    return(false);
                }
            }

            ///检查当前RecipeID 和 LotID
            if (string.IsNullOrEmpty(CurrRecipeID))
            {
                errorInfo = "启动失败:当前产品ID未设置";
                return(false);
            }

            string[] allRecipeIDs = rm.AllRecipeIDsInCategoty(SCN_CategotyProd);
            if (null == allRecipeIDs || !allRecipeIDs.Contains(CurrRecipeID))
            {
                errorInfo = "启动失败,当前产品ID:" + CurrRecipeID + " 在配方管理器中不存在";
                return(false);
            }


            if (string.IsNullOrEmpty(CurrLotID))
            {
                errorInfo = "启动失败:当前批次号未设置!";
                return(false);
            }



            int failedIndex = -1; //启动失败的工站号

            foreach (string stationName in allEnableStationNames)
            {
                IJFStation      station = stationMgr.GetStation(stationName);
                JFWorkCmdResult ret     = station.Start();
                if (ret != JFWorkCmdResult.Success)
                {
                    errorInfo = "工站:" + station.Name + " 启动失败,Error:" + ret.ToString();
                    break;
                }
            }

            if (failedIndex > -1)
            {
                for (int i = 0; i < failedIndex + 1; i++)
                {
                    IJFStation station = stationMgr.GetStation(allEnableStationNames[i]);
                    if (JFWorkCmdResult.Success != station.Stop(100))
                    {
                        station.Abort();
                    }
                }
                return(false);
            }
            WorkStatus = JFWorkStatus.Running;
            errorInfo  = "Success";
            return(true);
        }