2023-04-13 11:51:03 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Xml;
|
|
|
|
|
using Aitex.Core.Common.DeviceData;
|
|
|
|
|
using Aitex.Core.RT.DataCenter;
|
|
|
|
|
using Aitex.Core.RT.Device;
|
|
|
|
|
using Aitex.Core.RT.Device.Unit;
|
|
|
|
|
using Aitex.Core.RT.Event;
|
|
|
|
|
using Aitex.Core.RT.IOCore;
|
|
|
|
|
using Aitex.Core.RT.OperationCenter;
|
|
|
|
|
using Aitex.Core.RT.SCCore;
|
|
|
|
|
using Aitex.Core.RT.Tolerance;
|
|
|
|
|
using Aitex.Core.Util;
|
|
|
|
|
using MECF.Framework.Common.Event;
|
|
|
|
|
|
|
|
|
|
namespace Aitex.Core.RT.Device.Devices
|
|
|
|
|
{
|
|
|
|
|
public partial class IoPTOffsetAndK : BaseDevice, IDevice, IPressureMeter
|
2023-04-21 13:54:59 +08:00
|
|
|
|
{
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public double PTOffset
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2023-05-04 10:08:33 +08:00
|
|
|
|
return _aoOffset == null ? 0 : (_isFloatAioType ? _aoOffset.FloatValue : _aoOffset.Value);
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
set
|
|
|
|
|
{
|
2023-05-04 10:08:33 +08:00
|
|
|
|
if (_aoOffset != null)
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
|
|
|
|
if (_isFloatAioType)
|
2023-05-04 10:08:33 +08:00
|
|
|
|
_aoOffset.FloatValue = (float)value;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
else
|
2023-05-04 10:08:33 +08:00
|
|
|
|
_aoOffset.Value = (short)value;
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2023-05-04 10:08:33 +08:00
|
|
|
|
private AOAccessor _aoOffset = null;
|
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
private bool _isFloatAioType = false;
|
|
|
|
|
|
2023-05-04 10:08:33 +08:00
|
|
|
|
|
2023-04-21 13:54:59 +08:00
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
public IoPTOffsetAndK(string module, XmlElement node, string ioModule = "")
|
|
|
|
|
{
|
|
|
|
|
var attrModule = node.GetAttribute("module");
|
|
|
|
|
Module = string.IsNullOrEmpty(attrModule) ? module : attrModule;
|
|
|
|
|
Name = node.GetAttribute("id");
|
|
|
|
|
Display = node.GetAttribute("display");
|
|
|
|
|
_isFloatAioType = !string.IsNullOrEmpty(node.GetAttribute("aioType")) && (node.GetAttribute("aioType") == "float");
|
2023-05-04 10:08:33 +08:00
|
|
|
|
_aoOffset = ParseAoNode("aoOffset", node, ioModule);
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public bool Initialize()
|
|
|
|
|
{
|
2023-05-04 10:08:33 +08:00
|
|
|
|
DATA.Subscribe($"{Module}.AllOffset.{Name}", () => PTOffset);
|
|
|
|
|
OP.Subscribe($"{Module}.{Display}.{Name}", (function, args) =>
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
2023-05-04 10:08:33 +08:00
|
|
|
|
Set_Callback();
|
2023-04-13 11:51:03 +08:00
|
|
|
|
return true;
|
|
|
|
|
});
|
2023-05-04 10:08:33 +08:00
|
|
|
|
SC.RegisterValueChangedCallback($"PM.{Module}.{Display}.{Name}", (o) => { Set_Callback(o.ToString()); });
|
2023-04-13 11:51:03 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
2023-05-04 10:08:33 +08:00
|
|
|
|
public void Set_Callback(string b ="")
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
2023-05-04 10:08:33 +08:00
|
|
|
|
PTOffset = SC.GetValue<double>($"PM.{Module}.{Display}.{Name}");
|
|
|
|
|
EV.PostInfoLog(Module, $"Set PM.{Module}.{Display}.{Name} OK.");
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
2023-04-21 13:54:59 +08:00
|
|
|
|
catch (Exception ex)
|
2023-04-13 11:51:03 +08:00
|
|
|
|
{
|
2023-05-04 10:08:33 +08:00
|
|
|
|
EV.PostAlarmLog(Module, $"Set PM.{Module}.{Display}.{Name} Error:" + ex.Message);
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void Terminate()
|
|
|
|
|
{
|
2023-04-21 13:54:59 +08:00
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
public void Monitor()
|
|
|
|
|
{
|
2023-04-21 13:54:59 +08:00
|
|
|
|
|
2023-04-13 11:51:03 +08:00
|
|
|
|
}
|
|
|
|
|
public void Reset()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|