diff --git a/MECF.Framework.Common/Aitex/Core/RT/DataCollection/HighPerformance/DataTraceManager.cs b/MECF.Framework.Common/Aitex/Core/RT/DataCollection/HighPerformance/DataTraceManager.cs index 830fb2a..54ba543 100644 --- a/MECF.Framework.Common/Aitex/Core/RT/DataCollection/HighPerformance/DataTraceManager.cs +++ b/MECF.Framework.Common/Aitex/Core/RT/DataCollection/HighPerformance/DataTraceManager.cs @@ -5,6 +5,7 @@ using System.Linq; using System.Threading; using Aitex.Core.RT.DataCenter; using Aitex.Core.RT.DBCore; +using Aitex.Core.RT.IOCore; using Aitex.Core.RT.Log; using Aitex.Core.RT.SCCore; using Aitex.Core.Util; @@ -32,8 +33,9 @@ namespace Aitex.Core.RT.DataCollection.HighPerformance private readonly Thread _threadCache; private readonly Thread _threadPersist; - + private bool isAllowTraceAOHopping = false; + private bool isAllowTraceDOHopping = false; #endregion @@ -86,6 +88,23 @@ namespace Aitex.Core.RT.DataCollection.HighPerformance #if CHECK_DATA_TRACE_OVERRUN_ISSUE DATA.Subscribe($"{ModuleHelper.GetDiagnosisPath(ModuleName.System)}.DTOverrunDuration", () => _statCacheOverrunDuration); #endif + + const string SC_ALLOW_TRACE_AO_HOPPING = "System.AllowTraceAOHopping"; + const string SC_ALLOW_TRACE_DO_HOPPING = "System.AllowTraceDOHopping"; + isAllowTraceAOHopping = SC.GetValue(SC_ALLOW_TRACE_AO_HOPPING, true); + SC.RegisterValueChangedCallback(SC_ALLOW_TRACE_AO_HOPPING, o => + { + if(!bool.TryParse(o.ToString(), out isAllowTraceAOHopping)) + LOG.Error($"Unable to convert value {o} of [{SC_ALLOW_TRACE_AO_HOPPING}] to boolean."); + }); + + isAllowTraceDOHopping = SC.GetValue(SC_ALLOW_TRACE_DO_HOPPING, true); + SC.RegisterValueChangedCallback(SC_ALLOW_TRACE_DO_HOPPING, o => + { + if(!bool.TryParse(o.ToString(), out isAllowTraceDOHopping)) + LOG.Error($"Unable to convert value {o} of [{SC_ALLOW_TRACE_DO_HOPPING}] to boolean."); + }); + _dataTableCategory = dataTableCategory; _threadCache.Start(); } @@ -93,8 +112,14 @@ namespace Aitex.Core.RT.DataCollection.HighPerformance /// /// 立即缓存所有模组的数据。 /// - public void ImmediateCache(CacheDiagnosisInfo diagnosisInfo = null) + public void ImmediateCache(IIOAccessor io = null, CacheDiagnosisInfo diagnosisInfo = null) { + if (io is AOAccessor && !isAllowTraceAOHopping) + return; + + if (io is DOAccessor && !isAllowTraceDOHopping) + return; + if (diagnosisInfo != null) Debug.WriteLine($"{diagnosisInfo.Module}.{diagnosisInfo.IoName} changed to {diagnosisInfo.Value}", $"{nameof(DataTraceManager)} - {nameof(ImmediateCache)}"); diff --git a/MECF.Framework.Common/Aitex/Core/RT/IOCore/AOAccessor.cs b/MECF.Framework.Common/Aitex/Core/RT/IOCore/AOAccessor.cs index 695a761..fc434f0 100644 --- a/MECF.Framework.Common/Aitex/Core/RT/IOCore/AOAccessor.cs +++ b/MECF.Framework.Common/Aitex/Core/RT/IOCore/AOAccessor.cs @@ -27,7 +27,7 @@ namespace Aitex.Core.RT.IOCore // Check if immediate cache needed var needImmCache = DoubleUtil.NotEqual(oldValue, value) & !IsSimulator & !DisableImmediatelyCache; if (needImmCache) - DataTraceManager.Instance.ImmediateCache(new CacheDiagnosisInfo("", Name, Type, index, + DataTraceManager.Instance.ImmediateCache(this, new CacheDiagnosisInfo("", Name, Type, index, value.ToString(CultureInfo.CurrentCulture))); #endif diff --git a/MECF.Framework.Common/Aitex/Core/RT/IOCore/DOAccessor.cs b/MECF.Framework.Common/Aitex/Core/RT/IOCore/DOAccessor.cs index b2615fd..b0adce7 100644 --- a/MECF.Framework.Common/Aitex/Core/RT/IOCore/DOAccessor.cs +++ b/MECF.Framework.Common/Aitex/Core/RT/IOCore/DOAccessor.cs @@ -40,7 +40,7 @@ namespace Aitex.Core.RT.IOCore // Check if immediate cache needed var needImmCache = oldValue != value & !IsSimulator & !DisableImmediatelyCache; if (needImmCache) - DataTraceManager.Instance.ImmediateCache(new CacheDiagnosisInfo("", Name, Type, Index, + DataTraceManager.Instance.ImmediateCache(this, new CacheDiagnosisInfo("", Name, Type, Index, value.ToString())); return true; } @@ -70,7 +70,7 @@ namespace Aitex.Core.RT.IOCore // Check if immediate cache needed needImmCache &= oldValue != value; if (needImmCache) - DataTraceManager.Instance.ImmediateCache(new CacheDiagnosisInfo("", Name, Type, Index, + DataTraceManager.Instance.ImmediateCache(this, new CacheDiagnosisInfo("", Name, Type, Index, value.ToString())); Thread.Sleep(delayMillisecond); @@ -81,7 +81,7 @@ namespace Aitex.Core.RT.IOCore // Check if immediate cache needed needImmCache &= oldValue != value; if (needImmCache) - DataTraceManager.Instance.ImmediateCache(new CacheDiagnosisInfo("", Name, Type, Index, + DataTraceManager.Instance.ImmediateCache(this, new CacheDiagnosisInfo("", Name, Type, Index, value.ToString())); } else