[Common]
优化DataTraceManager的ImmediateCache()方法,允许通过系统设置禁用DO、AO的捕获跳变功能。
This commit is contained in:
parent
88225f4f17
commit
ee0f25e21a
|
@ -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
|
|||
/// <summary>
|
||||
/// 立即缓存所有模组的数据。
|
||||
/// </summary>
|
||||
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)}");
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue