Пример #1
0
 public StationCommandConsumer(OpcClient opcClientManager)
 {
     this.opcClientManager = opcClientManager;
 }
Пример #2
0
 public PumpCollecter(OpcClient opcClientManager, PumpCommandConsumer pumpCommandConsumer)
 {
     this.opcClientManager    = opcClientManager;
     this.pumpCommandConsumer = pumpCommandConsumer;
 }
Пример #3
0
        public void Start(out string errMsg)
        {
            errMsg = "";
            if (IsRuning)
            {
                return;
            }
            try
            {
                // 环境检查
                if (!EnvChecker.CheckForPump(out errMsg))
                {
                    TraceManagerForOPC.AppendErrMsg("PUMP-OPC环境检查未通过:" + errMsg);
                    return;
                }
                TraceManagerForOPC.AppendDebug("PUMP-OPC环境检查通过");


                // OPC 客户端管理服务打开
                if (opcClientManager != null)
                {
                    opcClientManager.Stop();
                }
                opcClientManager = new OpcClient(OPCClientManagerType.Pump);
                opcClientManager.Start();
                if (opcClientManager.IsRuning)
                {
                    TraceManagerForOPC.AppendDebug("OPC客户端管理服务已经打开");
                }
                else
                {
                    TraceManagerForOPC.AppendErrMsg("OPC客户端管理服务打开失败");
                    Stop();
                    return;
                }

                // 命令消费器
                if (commandCustomer != null)
                {
                    commandCustomer.Stop();
                }
                commandCustomer = new PumpCommandConsumer(opcClientManager);
                commandCustomer.Start();
                if (commandCustomer.IsRuning)
                {
                    TraceManagerForOPC.AppendDebug("命令消费器已经打开");
                }
                else
                {
                    TraceManagerForOPC.AppendErrMsg("命令消费器打开失败");
                    Stop();
                    return;
                }

                // 泵房点表采集者服务
                if (pumpCollecter != null)
                {
                    pumpCollecter.Stop();
                }
                pumpCollecter = new PumpCollecter(opcClientManager, commandCustomer);
                pumpCollecter.Start();
                if (pumpCollecter.IsRuning)
                {
                    TraceManagerForOPC.AppendDebug("点表采集管理服务已经打开");
                }
                else
                {
                    TraceManagerForOPC.AppendErrMsg("点表采集管理服务打开失败");
                    Stop();
                    return;
                }
            }
            catch (Exception e)
            {
                errMsg = e.Message;
                TraceManagerForOPC.AppendErrMsg("PUMP_OPC服务启动异常" + e.Message + "堆栈:" + e.StackTrace);
                Stop();
                return;
            }

            IsRuning = true;
        }
Пример #4
0
 public StationCollecter(OpcClient opcClientManager, StationCommandConsumer stationCommandConsumer)
 {
     this.opcClientManager       = opcClientManager;
     this.stationCommandConsumer = stationCommandConsumer;
 }