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
        void OnStationWorkStatusChanged(object sender, JFWorkStatus currWorkStatus)
        {
            if (InvokeRequired)
            {
                Invoke(new dgWorkStatusChanged(OnStationWorkStatusChanged), new object[] { sender, currWorkStatus });
                return;
            }

            IJFStation station = sender as IJFStation;

            _dctStationForms[station].OnWorkStatusChanged(sender, currWorkStatus);
            if (_dctTestingForms.ContainsKey(station))
            {
                JFWorkStatus ws = station.CurrWorkStatus;
                if (!JFStationBase.IsWorkingStatus(ws) &&
                    ws != JFWorkStatus.CommandExit &&
                    ws != JFWorkStatus.AbortExit)
                {
                    _dctTestingForms.Remove(station);
                    StopTest();
                    JFTipsDelayClose.Show("工站:" + station.Name + " " + JFStationBase.WorkStatusName(ws) + "  ,停止测试运行!", -1);
                    return;
                }
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 关闭工站/设备,释放各种资源
        /// </summary>
        public void Close()
        {
            string errInfo = "";
            ///关闭工站
            IJFMainStation mainStation = StationMgr.MainStation;

            if (null != mainStation)
            {
                mainStation.Stop(out errInfo);
            }
            string[] stationNames = StationMgr.AllStationNames();
            if (null != stationNames && stationNames.Length > 0)
            {
                foreach (string stationName in stationNames)
                {
                    IJFStation station = StationMgr.GetStation(stationName);
                    station.Stop();
                }
            }
            ///关闭所有设备
            string[] deviceIDs = InitorManager.GetIDs(typeof(IJFDevice));
            if (null != deviceIDs && deviceIDs.Length > 0)
            {
                foreach (string devID in deviceIDs)
                {
                    IJFDevice dev = InitorManager.GetInitor(devID) as IJFDevice;
                    dev.CloseDevice();
                }
            }

            ///释放其他对象
            ///添加代码 ...
        }
Ejemplo n.º 4
0
 /// <summary>
 ///  处理工站的业务状态发生改变
 /// 未提供JustRealTimeUI的工站通过此函数刷新界面
 /// 以提供JustRealTimeUI的工站 只是通过此函数向MainStation发送消息,相关界面更新功能由工站自身维护
 /// </summary>
 /// <param name="station"></param>
 /// <param name="currCustomStatus"></param>
 void _StationCustomStatusChanged(IJFStation station, int currCustomStatus, bool isSynchMode = true)//异步模式有问题(异步线程未运行'),待日后改进
 {
     if (isSynchMode)
     {
         if (_StationMsgReciever.ContainsKey(station))
         {
             List <IJFStationMsgReceiver> uis = _StationMsgReciever[station];
             foreach (IJFStationMsgReceiver ui in uis)
             {
                 ui.OnCustomStatusChanged(currCustomStatus);
             }
         }
         MainStation.OnStationCustomStatusChanged(station, currCustomStatus);
         EventStationCustomStatusChanged?.Invoke(station, currCustomStatus);
     }
     else
     {
         Task t = new Task(() =>
         {
             ///添加代码,界面显示
             if (_StationMsgReciever.ContainsKey(station))
             {
                 List <IJFStationMsgReceiver> uis = _StationMsgReciever[station];
                 foreach (IJFStationMsgReceiver ui in uis)
                 {
                     ui.OnCustomStatusChanged(currCustomStatus);
                 }
             }
             MainStation.OnStationCustomStatusChanged(station, currCustomStatus);
             EventStationCustomStatusChanged?.Invoke(station, currCustomStatus);
         });
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// 处理工站状态改变
 /// 未提供JustRealTimeUI的工站通过此函数刷新界面
 /// 以提供JustRealTimeUI的工站 只是通过此函数向MainStation发送消息,相关界面更新功能由工站自身维护
 /// </summary>
 /// <param name="station"></param>
 /// <param name="currWorkStatus"></param>
 void _StationWorkStatusChanged(IJFStation station, JFWorkStatus currWorkStatus, bool isSynchMode = true) //异步模式有问题(异步线程未运行'),待日后改进
 {
     if (isSynchMode)
     {
         if (_StationMsgReciever.ContainsKey(station))
         {
             List <IJFStationMsgReceiver> uis = _StationMsgReciever[station];
             foreach (IJFStationMsgReceiver ui in uis)
             {
                 ui.OnWorkStatusChanged(currWorkStatus);
             }
         }
         ///将消息发送到MainStaion处理
         MainStation.OnStationWorkStatusChanged(station, currWorkStatus);
         EventStationWorkStatusChanged?.Invoke(station, currWorkStatus);
     }
     else
     {
         Task t = new Task(() => /*日后可能改成固定线程,性能是否可优化存疑*/
         {
             if (_StationMsgReciever.ContainsKey(station))
             {
                 List <IJFStationMsgReceiver> uis = _StationMsgReciever[station];
                 foreach (IJFStationMsgReceiver ui in uis)
                 {
                     ui.OnWorkStatusChanged(currWorkStatus);
                 }
             }
             ///将消息发送到MainStaion处理
             MainStation.OnStationWorkStatusChanged(station, currWorkStatus);
             EventStationWorkStatusChanged?.Invoke(station, currWorkStatus);
         });
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// 处理工站发来的其他定制化的消息
 /// </summary>
 /// <param name="station"></param>
 /// <param name="msg"></param>
 public virtual void OnStationCustomizeMsg(IJFStation station, string msgCategory, object[] msgParams)
 {
     if (station.GetType().Name.Contains("DLAFDetectStation"))
     {
         _uiPanel.OnCustomizeMsg(msgCategory, msgParams);
     }
 }
Ejemplo n.º 7
0
 public void OnStationTxtMsg(IJFStation station, string msgInfo)
 {
     if (station.GetType().Name.Contains("DLAFDetectStation"))
     {
         _uiPanel.OnTxtMsg(msgInfo);
     }
 }
Ejemplo n.º 8
0
 /// <summary>
 /// 产品加工完成消息
 /// </summary>
 /// <param name="station">消息发送者</param>
 /// <param name="PassCount">本次生产完成的成品数量</param>
 /// <param name="NGCount">本次生产的次品数量</param>
 /// <param name="NGInfo">次品信息</param>
 public virtual void OnStationProductFinished(IJFStation station, int passCount, string[] passIDs, int ngCount, string[] ngIDs, string[] ngInfo)
 {
     if (station.GetType().Name.Contains("DLAFDetectStation"))
     {
         _uiPanel.OnProductFinished(passCount, passIDs, ngCount, ngIDs, ngInfo);
     }
 }
Ejemplo n.º 9
0
 /// <summary>
 /// 产品加工完成消息
 /// 未提供JustRealTimeUI的工站通过此函数刷新界面
 /// 以提供JustRealTimeUI的工站 只是通过此函数向MainStation发送消息,相关界面更新功能由工站自身维护
 /// </summary>
 /// <param name="station">消息发送者</param>
 /// <param name="PassCount">本次生产完成的成品数量</param>
 /// <param name="NGCount">本次生产的次品数量</param>
 /// <param name="NGInfo">次品信息</param>
 void _StationProductFinished(IJFStation station, int passCount, string[] passIDs, int ngCount, string[] ngIDs, string[] ngInfo, bool isSynchMode = true)//异步模式有问题(异步线程未运行'),待日后改进
 {
     if (isSynchMode)
     {
         if (_StationMsgReciever.ContainsKey(station))
         {
             List <IJFStationMsgReceiver> uis = _StationMsgReciever[station];
             foreach (IJFStationMsgReceiver ui in uis)
             {
                 ui.OnProductFinished(passCount, passIDs, ngCount, ngIDs, ngInfo);
             }
         }
         MainStation.OnStationProductFinished(station, passCount, passIDs, ngCount, ngIDs, ngInfo);
         EventStationProductFinished?.Invoke(station, passCount, passIDs, ngCount, ngIDs, ngInfo);
     }
     else
     {
         Task t = new Task(() =>
         {
             if (_StationMsgReciever.ContainsKey(station))
             {
                 List <IJFStationMsgReceiver> uis = _StationMsgReciever[station];
                 foreach (IJFStationMsgReceiver ui in uis)
                 {
                     ui.OnProductFinished(passCount, passIDs, ngCount, ngIDs, ngInfo);
                 }
             }
             MainStation.OnStationProductFinished(station, passCount, passIDs, ngCount, ngIDs, ngInfo);
             EventStationProductFinished?.Invoke(station, passCount, passIDs, ngCount, ngIDs, ngInfo);
         });
     }
 }
Ejemplo n.º 10
0
        internal JFStationManager(string cfgPath)
        {
            _cfg.Load(cfgPath, true);
            if (!_cfg.ContainsItem("StationEnabled"))
            {
                _dictStationEnabled = new JFXmlDictionary <string, bool>();
                _cfg.AddItem("StationEnabled", _dictStationEnabled);
            }
            else
            {
                _dictStationEnabled = _cfg.GetItemValue("StationEnabled") as JFXmlDictionary <string, bool>;
            }

            List <string> existedStationNames = _initorStationNames();
            List <string> stationNamesInCfg   = _dictStationEnabled.Keys.ToList();

            if (null == existedStationNames)
            {
                _dictStationEnabled.Clear();
            }
            else
            {
                foreach (string cfgName in stationNamesInCfg) //去除多余的项
                {
                    if (!existedStationNames.Contains(cfgName))
                    {
                        _dictStationEnabled.Remove(cfgName);
                    }
                }
                foreach (string exsitedName in existedStationNames) //添加缺少的项
                {
                    if (!_dictStationEnabled.ContainsKey(exsitedName))
                    {
                        _dictStationEnabled.Add(exsitedName, true);
                        //SetStationEnabled(exsitedName, true);
                    }
                }
            }

            ///添加默认的消息回调
            foreach (string stationName in _dictStationEnabled.Keys)
            {
                IJFStation station = GetStation(stationName);
                station.WorkStatusChanged   += StationWorkStatusChanged;
                station.CustomStatusChanged += StationCustomStatusChanged;
                if (station is JFCmdWorkBase)
                {
                    (station as JFCmdWorkBase).WorkMsg2Outter += StationTxtMsg;
                }
                if (station is JFStationBase)
                {
                    (station as JFStationBase).EventCustomizeMsg    += StationCustomizeMsg;
                    (station as JFStationBase).EventProductFinished += StationProductFinished;
                }
            }

            _cfg.Save();
            DeclearedStationNames = new List <string>();
            StartShowStationLog();
        }
Ejemplo n.º 11
0
        void OnBtShowStationCfgUI(object sender, EventArgs e)
        {
            Button     bt          = sender as Button;
            string     stationName = bt.Tag as string;
            IJFStation station     = JFHubCenter.Instance.StationMgr.GetStation(stationName);

            station.ShowCfgDialog();
        }
Ejemplo n.º 12
0
 public void SetStation(IJFStation station)
 {
     _station = station;
     if (_isFormLoaded)
     {
         AdjustStationView();
     }
 }
Ejemplo n.º 13
0
        //void HandleStationMsg(IJFStation station,object msg )

        /// <summary>
        ///  处理工站的业务状态发生改变
        /// </summary>
        /// <param name="station"></param>
        /// <param name="currCustomStatus"></param>
        public virtual void OnStationCustomStatusChanged(IJFStation station, int currCustomStatus)
        {
            if (station.GetType().Name.Contains("DLAFDetectStation"))
            {
                string custonStatusTxt = station.GetCustomStatusName(currCustomStatus);
                _uiPanel.OnCustomStatusChanged(custonStatusTxt);
            }
        }
Ejemplo n.º 14
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);
                }
            }
        }
Ejemplo n.º 15
0
        /// <summary>
        /// 处理工站状态改变
        /// </summary>
        /// <param name="station"></param>
        /// <param name="currWorkStatus"></param>
        public virtual void OnStationWorkStatusChanged(IJFStation station, JFWorkStatus currWorkStatus)
        {
            if (station.GetType().Name.Contains("DLAFDetectStation"))
            {
                _uiPanel.OnWorkStatusChanged(currWorkStatus);
            }

            ///继续添加其他工站发过来的消息
        }
Ejemplo n.º 16
0
 void OnCustomizeMsg(IJFStation station, string msgCategory, object[] msgParams)
 {
     if (InvokeRequired)
     {
         Invoke(new dgCustomizeMsg(OnCustomizeMsg), new object[] { station, msgCategory, msgParams });
         return;
     }
     string info = "专属消息:Category = " + msgCategory + " ParamCount = " + (msgParams == null ? 0 : msgParams.Length);
     //ShowTips(info);
 }
Ejemplo n.º 17
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);
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 为工站附加一个ui , 一般情况下由App中的架构功能调用
        /// 如:不提供RealtimeUI的工站,系统会自动指派一个ui
        /// </summary>
        /// <param name="station"></param>
        /// <param name="ui"></param>
        public void AppendStationMsgReceiver(IJFStation station, IJFStationMsgReceiver rcver)
        {
            if (!_StationMsgReciever.ContainsKey(station))
            {
                _StationMsgReciever.Add(station, new List <IJFStationMsgReceiver>());
            }

            List <IJFStationMsgReceiver> uis = _StationMsgReciever[station];

            if (!uis.Contains(rcver))
            {
                uis.Add(rcver);
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 设置工站使能
        /// </summary>
        /// <param name="stationName"></param>
        /// <param name="enable"></param>
        public void SetStationEnabled(string stationName, bool enable)
        {
            if (!_initorStationNames().Contains(stationName))
            {
                throw new ArgumentException("stationName = \"" + stationName + "\" is not included by Station-Name List");
            }
            if (!_dictStationEnabled.ContainsKey(stationName))
            {
                _dictStationEnabled.Add(stationName, enable);
                return;
            }
            else
            {
                _dictStationEnabled[stationName] = enable;
            }
            IJFStation station = GetStation(stationName);

            if (enable)
            {
                station.WorkStatusChanged   += StationWorkStatusChanged;
                station.CustomStatusChanged += StationCustomStatusChanged;
                if (station is JFCmdWorkBase)
                {
                    (station as JFCmdWorkBase).WorkMsg2Outter += StationTxtMsg;
                }
                if (station is JFStationBase)
                {
                    (station as JFStationBase).EventCustomizeMsg    += StationCustomizeMsg;
                    (station as JFStationBase).EventProductFinished += StationProductFinished;
                }
            }
            else
            {
                station.WorkStatusChanged   -= StationWorkStatusChanged;
                station.CustomStatusChanged -= StationCustomStatusChanged;
                if (station is JFCmdWorkBase)
                {
                    (station as JFCmdWorkBase).WorkMsg2Outter -= StationTxtMsg;
                }

                if (station is JFStationBase)
                {
                    (station as JFStationBase).EventCustomizeMsg    -= StationCustomizeMsg;
                    (station as JFStationBase).EventProductFinished -= StationProductFinished;
                }
            }
            _cfg.Save();
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 工站测试
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void button2_Click(object sender, EventArgs e)
        {
            string[] stationNames = JFHubCenter.Instance.InitorManager.GetIDs(typeof(IJFStation));
            if (null == stationNames || 0 == stationNames.Length)
            {
                MessageBox.Show("系统中没有工站");
                return;
            }
            IJFStation station     = JFHubCenter.Instance.InitorManager.GetInitor(stationNames[0]) as IJFStation;
            Form       stationForm = station.GenForm();

            if (null != stationForm)
            {
                stationForm.Show();
            }
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 停止工站日志记录/显示
        /// 在程序退出前调用
        /// </summary>
        public void Stop()
        {
            string errorInfo;

            MainStation.Stop(out errorInfo);
            string[] stationNames = AllStationNames();
            if (null != stationNames)
            {
                foreach (string stationName in stationNames)
                {
                    IJFStation station = GetStation(stationName);
                    if (IsStationRunning(station))
                    {
                        JFWorkCmdResult ret = station.Stop(1000);
                        if (ret != JFWorkCmdResult.Success)
                        {
                            //日后可能添加强制关闭的系统日志...
                            station.Abort();
                        }
                    }
                }
            }
            JFLoggerManager.Instance.Stop();
            StopShowStationLog();
            if (null != stationNames)
            {
                foreach (string stationName in stationNames)
                {
                    IJFStation station = GetStation(stationName);
                    station.WorkStatusChanged   -= StationWorkStatusChanged;
                    station.CustomStatusChanged -= StationCustomStatusChanged;
                    if (station is JFCmdWorkBase)
                    {
                        (station as JFCmdWorkBase).WorkMsg2Outter -= StationTxtMsg;
                    }

                    if (station is JFStationBase)
                    {
                        (station as JFStationBase).EventCustomizeMsg    -= StationCustomizeMsg;
                        (station as JFStationBase).EventProductFinished -= StationProductFinished;
                    }
                }
            }

            Thread.Sleep(2000);
        }
Ejemplo n.º 22
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 = "自动运行";
            }
        }
Ejemplo n.º 23
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;
        }
Ejemplo n.º 24
0
        public void StationTxtMsg(object sender, string msgInfo)
        {
            IJFStation station = sender as IJFStation;

            if (_StationMsgReciever.ContainsKey(station))
            {
                List <IJFStationMsgReceiver> uis = _StationMsgReciever[station];
                foreach (IJFStationMsgReceiver ui in uis)
                {
                    ui.OnTxtMsg(msgInfo);
                }
            }

            //Task t = new Task(() => /*日后可能改成固定线程,性能是否可优化存疑*/
            //{

            ///将消息发送到MainStaion处理
            MainStation.OnStationTxtMsg(sender as IJFStation, msgInfo);
            EventStationTxtMsg?.Invoke(sender, msgInfo);
            //});
        }
Ejemplo n.º 25
0
        /// <summary>
        /// 注册一个工站(不可删除),
        /// 在Application.Run()运行之前调用
        /// </summary>
        /// <param name="station"></param>
        public void DeclearStation(IJFStation station)
        {
            if (station == null)
            {
                throw new ArgumentNullException("StationManager.DeclearStation(IJFStation station) failed by station = null");
            }
            //if (_lstDeclearStations.Contains(station))
            //    throw new ArgumentException("StationManager.DeclearStation(IJFStation station) failed by station is already decleared!");
            string name = station.Name;

            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("StationManager.DeclearStation(IJFStation station) failed by station's Name null or empty");
            }
            if (_initorStationNames().Contains(name))
            {
                IJFInitializable existedStation = JFHubCenter.Instance.InitorManager.GetInitor(name);
                if (existedStation.GetType() != station.GetType())
                {
                    throw new Exception("StationManager.DeclearStation(IJFStation station) failed by:Exist a station with same name and type unmatched: Decleared Type = " + station.GetType() + " ; Existed Type = " + existedStation.GetType());
                }
                (existedStation as IJFStation).Name = name;
                DeclearedStationNames.Add(station.Name);
                //station.WorkStatusChanged += StationWorkStatusChanged;
                //station.CustomStatusChanged += StationCustomStatusChanged;
                //if(station is JFCmdWorkBase)
                //    (station as JFCmdWorkBase).WorkMsg2Outter += StationTxtMsg;
                return;
                //throw new ArgumentException("StationManager.DeclearStation(IJFStation station) failed by station's Name = \"" + name + "\" is exsited in InitorStation-List!");
            }

            JFHubCenter.Instance.InitorManager.Add(station.Name, station);
            DeclearedStationNames.Add(station.Name);
            //station.WorkStatusChanged += StationWorkStatusChanged;
            //station.CustomStatusChanged += StationCustomStatusChanged;
            //if (station is JFCmdWorkBase)
            //    (station as JFCmdWorkBase).WorkMsg2Outter += StationTxtMsg;
        }
Ejemplo n.º 26
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.º 27
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.º 28
0
        Dictionary <string, IJFLogger> _stationLoggers = new Dictionary <string, IJFLogger>(); //各工站的日志记录对象

        /// <summary>
        /// 接收一条工站日志记录,保存
        /// 如果工站自身未提供UI,则会在架构附加的StationUI上显示
        /// 如果工站自身有UI,则忽略显示功能
        /// </summary>
        /// <param name="info"></param>
        public void OnStationLog(IJFStation station, string info, JFLogLevel level, LogMode mode)
        {
            ///添加界面显示
            ///向日志线程中添加一条记录

            if (null == station)
            {
                throw new ArgumentNullException("Station is null in JFStationManeger.StationLog(station, ...");
            }
            string stationName = station.Name;

            if (string.IsNullOrEmpty(stationName))
            {
                throw new ArgumentNullException("Station's Name is null or empty in JFStationManeger.StationLog(station, ...");
            }

            if ((mode & LogMode.Record) == LogMode.Record)
            {
                if (!_stationLoggers.ContainsKey(stationName))
                {
                    _stationLoggers.Add(stationName, JFLoggerManager.Instance.GetLogger(stationName));
                }
                _stationLoggers[stationName].Log(level, info);
            }
            if (_isShowLogThreadRunning)
            {
                if ((mode & LogMode.Show) == LogMode.Show)
                {
                    if (_StationMsgReciever.ContainsKey(station))
                    {
                        _log2Shows.Enqueue(new KeyValuePair <IJFStation, string>(station, level.ToString() + ":" + info));
                        _semaphoreShowLog.Release(1);
                    }
                }
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 处理工站发来的其他定制化的消息
        /// 只是向MainStation发送消息,定制化的界面显示由工站通过自身提供的JustRealTimeUI完成
        /// </summary>
        /// <param name="station"></param>
        /// <param name="msg"></param>
        void _StationCustomizeMsg(IJFStation station, string msgCategory, object[] msgParams, bool isSynchMode = true)//异步模式有问题(异步线程未运行'),待日后改进
        {
            if (isSynchMode)
            {
                if (_StationMsgReciever.ContainsKey(station))
                {
                    List <IJFStationMsgReceiver> uis = _StationMsgReciever[station];
                    foreach (IJFStationMsgReceiver ui in uis)
                    {
                        ui.OnCustomizeMsg(msgCategory, msgParams);
                    }
                }


                MainStation.OnStationCustomizeMsg(station, msgCategory, msgParams);
                EventStationCustomizeMsg?.Invoke(station, msgCategory, msgParams);
            }
            else
            {
                Task t = new Task(() =>
                {
                    if (_StationMsgReciever.ContainsKey(station))
                    {
                        List <IJFStationMsgReceiver> uis = _StationMsgReciever[station];
                        foreach (IJFStationMsgReceiver ui in uis)
                        {
                            ui.OnCustomizeMsg(msgCategory, msgParams);
                        }
                    }


                    MainStation.OnStationCustomizeMsg(station, msgCategory, msgParams);
                    EventStationCustomizeMsg?.Invoke(station, msgCategory, msgParams);
                });
            }
        }
Ejemplo n.º 30
0
 public void SetStation(IJFStation station)
 {
     _station = station;
     InitParam();
 }