Пример #1
0
 // 对调度服务实现的接口
 public void ReceiveCommand(RequestCommand command)
 {
     // 已经在入口验证过命令对象
     if (!IsRuning || this.commandCustomer == null || !this.commandCustomer.IsRuning)
     {
         CommandManager.MakeFail("SCADA-OPC命令消费器运行异常", ref command);
         CommandManager.CompleteCommand(command);
         TraceManagerForCommand.AppendWarning("SCADA-OPC命令消费器运行异常");
         return;
     }
     this.commandCustomer.ReceiveCommand(command);
 }
Пример #2
0
 public void ExcuteReload()
 {
     try
     {
         if (!ExcuteReloadHandle(out string errMsg))
         {
             CommandManager.MakeFail(errMsg, ref requestCommand);
             CommandManager.CompleteCommand(requestCommand);
             TraceManagerForCommand.AppendWarning(requestCommand.message);
             return;
         }
         CommandManager.MakeSuccess("重载站点数据命令成功,SCADA-OPC数据已更新", ref requestCommand);
         CommandManager.CompleteCommand(requestCommand);
         TraceManagerForCommand.AppendInfo("重载站点数据命令成功,SCADA-OPC数据已更新");
     }
     catch (Exception e)
     {
         TraceManagerForOPC.AppendErrMsg("站点主动采集任务执行失败--" + e.Message + "堆栈:" + e.StackTrace);
         SendError("站点主动采集任务执行失败--" + e.Message);
     }
 }
Пример #3
0
 public void ExcuteWrite()
 {
     try
     {
         if (!ExcuteWriteHandle(out string errMsg, out string info))
         {
             CommandManager.MakeFail(errMsg, ref requestCommand);
             CommandManager.CompleteCommand(requestCommand);
             TraceManagerForCommand.AppendWarning(requestCommand.message);
             return;
         }
         CommandManager.MakeSuccess(info, ref requestCommand);
         CommandManager.CompleteCommand(requestCommand);
         TraceManagerForCommand.AppendInfo(info);
     }
     catch (Exception e)
     {
         TraceManagerForOPC.AppendErrMsg("机组写值任务执行失败--" + e.Message + "堆栈:" + e.StackTrace);
         SendError("机组写值任务执行失败--" + e.Message);
     }
 }
Пример #4
0
        // 任务执行口--并附带超时功能
        public void Excute()
        {
            ActionTimeout timeoutObj = new ActionTimeout();

            try
            {
                switch (this.type)
                {
                case StationCommandType.Collect:
                {
                    if (opcCommandType == OPCCommandType.Cancle)          //已经在调度被标记放弃了,干要紧的任务
                    {
                        return;
                    }
                    timeoutObj.Do = ExcuteCollect;
                    bool bo = timeoutObj.DoWithTimeout(new TimeSpan(0, 0, 0, Config.scadaConfig.commandTimeoutSeconds));
                    if (bo)
                    {
                        TraceManagerForOPC.AppendWarning("站点定时采集任务执行超时");
                        GC.Collect();
                    }
                }
                break;

                case StationCommandType.Write:
                {
                    timeoutObj.Do = ExcuteWrite;
                    bool bo = timeoutObj.DoWithTimeout(new TimeSpan(0, 0, 0, Config.scadaConfig.commandTimeoutSeconds));
                    if (bo)
                    {
                        CommandManager.MakeTimeout("sensorID:" + requestCommand.sensorID + "执行写值命令超时", ref requestCommand);
                        CommandManager.CompleteCommand(requestCommand);
                        TraceManagerForCommand.AppendWarning(requestCommand.message);
                        GC.Collect();
                    }
                }
                break;

                case StationCommandType.Reload:
                {
                    timeoutObj.Do = ExcuteReload;
                    bool bo = timeoutObj.DoWithTimeout(new TimeSpan(0, 0, 0, Config.scadaConfig.commandTimeoutSeconds));
                    if (bo)
                    {
                        CommandManager.MakeTimeout("执行重载站点数据命令超时", ref requestCommand);
                        CommandManager.CompleteCommand(requestCommand);
                        TraceManagerForCommand.AppendWarning(requestCommand.message);
                        GC.Collect();
                    }
                }
                break;

                default:
                    TraceManagerForOPC.AppendWarning("未知的站点OPC命令类型,无法执行");
                    return;
                }
            }
            catch (Exception e)
            {
                TraceManagerForOPC.AppendErrMsg("执行站点OPC任务失败,未知的任务类型:" + e.Message + "堆栈:" + e.StackTrace);
            }
        }