Ejemplo 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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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);
        }