38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
using System.Globalization;
|
|
using Aitex.Core.RT.DataCollection.HighPerformance;
|
|
using Aitex.Core.Util;
|
|
using MECF.Framework.Common.MECF.Framework.Common.Utilities;
|
|
using MECF.Framework.RT.Core.IoProviders;
|
|
|
|
namespace Aitex.Core.RT.IOCore
|
|
{
|
|
public class AOAccessor : IOAccessor<float>
|
|
{
|
|
public AOAccessor(string name, int index, string address, bool isSimulator = false, bool disImmCache = false)
|
|
: base(name, index, address, IOType.AO, isSimulator, disImmCache)
|
|
{
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void SetValue(int index, float value)
|
|
{
|
|
#if EN_AO_IMM_CACHE
|
|
var oldValue = Buffer[Index];
|
|
#endif
|
|
Buffer[index] = value;
|
|
Singleton<IoProviderManager>.Instance.GetProvider(base.Provider)?.SetValue(this, value);
|
|
|
|
#if EN_AO_IMM_CACHE
|
|
//! NOTE THIS MAY CAUSE OVERRUN-DATA-TRACE ISSUE
|
|
// Check if immediate cache needed
|
|
var needImmCache = DoubleUtil.NotEqual(oldValue, value) & !IsSimulator & !DisableImmediatelyCache;
|
|
if (needImmCache)
|
|
DataTraceManager.Instance.ImmediateCache(this, new CacheDiagnosisInfo("", Name, Type, index,
|
|
value.ToString(CultureInfo.CurrentCulture)));
|
|
|
|
#endif
|
|
|
|
}
|
|
}
|
|
}
|