2024-01-08 16:29:53 +08:00
|
|
|
using System.Globalization;
|
2024-01-07 11:29:22 +08:00
|
|
|
using Aitex.Core.RT.DataCollection.HighPerformance;
|
2023-04-13 11:51:03 +08:00
|
|
|
using Aitex.Core.Util;
|
2024-01-12 18:14:32 +08:00
|
|
|
using MECF.Framework.Common.MECF.Framework.Common.Utilities;
|
2023-04-13 11:51:03 +08:00
|
|
|
using MECF.Framework.RT.Core.IoProviders;
|
|
|
|
|
|
|
|
namespace Aitex.Core.RT.IOCore
|
|
|
|
{
|
2023-12-18 16:39:16 +08:00
|
|
|
public class AOAccessor : IOAccessor<float>
|
2023-04-13 11:51:03 +08:00
|
|
|
{
|
2024-01-11 15:19:20 +08:00
|
|
|
public AOAccessor(string name, int index, string address, bool isSimulator = false, bool disImmCache = false)
|
|
|
|
: base(name, index, address, IOType.AO, isSimulator, disImmCache)
|
2023-04-13 11:51:03 +08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-12-18 16:39:16 +08:00
|
|
|
/// <inheritdoc />
|
|
|
|
protected override void SetValue(int index, float value)
|
2023-04-13 11:51:03 +08:00
|
|
|
{
|
2024-01-12 18:14:32 +08:00
|
|
|
#if EN_AO_IMM_CACHE
|
|
|
|
var oldValue = Buffer[Index];
|
|
|
|
#endif
|
2023-12-18 16:39:16 +08:00
|
|
|
Buffer[index] = value;
|
2024-01-12 18:14:32 +08:00
|
|
|
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)
|
2024-01-08 16:29:53 +08:00
|
|
|
DataRecorderManager.Instance.ImmediateCache(new CacheDiagnosisInfo("", Name, Type, index,
|
|
|
|
value.ToString(CultureInfo.CurrentCulture)));
|
2024-01-12 18:14:32 +08:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|