Esempio n. 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);
        }
Esempio n. 2
0
        void LoadCfg()
        {
            JFStationManager mgr = JFHubCenter.Instance.StationMgr;

            foreach (CheckBox cb in tableLayoutPanel1.Controls)
            {
                cb.Checked = mgr.GetStationEnabled(cb.Text);
            }
        }
Esempio n. 3
0
        void SaveCfg()
        {
            JFStationManager mgr = JFHubCenter.Instance.StationMgr;

            foreach (CheckBox cb in tableLayoutPanel1.Controls)
            {
                mgr.SetStationEnabled(cb.Text, cb.Checked);
            }
        }
Esempio n. 4
0
        private void FormStationsRunInfo_Load(object sender, EventArgs e)
        {
            IsHideWhenFormClose = true;
            AdjustStationList();
            JFStationManager mgr = JFHubCenter.Instance.StationMgr;

            mgr.EventStationWorkStatusChanged   += OnStationWorkStatusChanged;
            mgr.EventStationCustomStatusChanged += OnStationCustomStatusChanged;
            mgr.EventStationTxtMsg          += OnStationTxtMsg;
            mgr.EventStationProductFinished += OnStationProductFinished;
            mgr.EventStationCustomizeMsg    += OnStationCustomizeMsg;
        }
Esempio n. 5
0
        void AdjustStationList()
        {
            _isAdjusting = true;
            while (tabControl1.TabCount > 1)
            {
                tabControl1.TabPages.RemoveAt(1);
            }
            _dctStationInfos.Clear();
            JFStationManager mgr = JFHubCenter.Instance.StationMgr;

            string[] stationNames = mgr.AllStationNames();
            if (null == stationNames)
            {
                return;
            }
            foreach (string sn in stationNames)
            {
                TabPage tp = new TabPage(sn);
                tabControl1.TabPages.Add(tp);

                IJFStation  station  = mgr.GetStation(sn);
                RichTextBox rchInfos = new RichTextBox();
                rchInfos.Tag = sn;
                _dctStationInfos.Add(station, rchInfos);
                Button btClear = new Button();
                btClear.Text      = "清空信息";
                btClear.Click    += OnBtStationClear_Click;
                btClear.Tag       = rchInfos;
                btClear.Location  = new Point(tp.Width - 3 - btClear.Width, 3);
                btClear.Anchor    = AnchorStyles.Top | AnchorStyles.Right;
                rchInfos.Location = new Point(3, btClear.Bottom + 3);
                rchInfos.Width    = tp.Width - 6;
                rchInfos.Height   = tp.Height - 3 - rchInfos.Top;
                rchInfos.ReadOnly = true;
                rchInfos.Anchor   = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right | AnchorStyles.Left;
                tp.Controls.Add(btClear);
                tp.Controls.Add(rchInfos);
            }

            _isAdjusting = false;
        }
Esempio n. 6
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);
        }
Esempio n. 7
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);
        }
Esempio n. 8
0
        public virtual bool Start(out string errorInfo)//开始运行
        {
            errorInfo = "Unknown Error";
            if (IsAlarming)
            {
                errorInfo = "当前处于报警状态";
                return(false);
            }
            if (IsStationRunning(WorkStatus))
            {
                errorInfo = "Success";
                return(true);
            }
            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);
                }
            }

            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);
        }