[UI.Client]

优化参数时调用方式
This commit is contained in:
hanqiangqiang 2023-05-04 10:08:33 +08:00
parent 94cc390c98
commit 6c4f077410
2 changed files with 16 additions and 131 deletions

View File

@ -20,44 +20,26 @@ namespace Aitex.Core.RT.Device.Devices
{
get
{
return _aoPTOffset == null ? 0 : (_isFloatAioType ? _aoPTOffset.FloatValue : _aoPTOffset.Value);
return _aoOffset == null ? 0 : (_isFloatAioType ? _aoOffset.FloatValue : _aoOffset.Value);
}
set
{
if (_aoPTOffset != null)
if (_aoOffset != null)
{
if (_isFloatAioType)
_aoPTOffset.FloatValue = (float)value;
_aoOffset.FloatValue = (float)value;
else
_aoPTOffset.Value = (short)value;
_aoOffset.Value = (short)value;
}
}
}
public double PTK
{
get
{
return _aoPTK == null ? 0 : (_isFloatAioType ? _aoPTK.FloatValue : _aoPTK.Value);
}
set
{
if (_aoPTK != null)
{
if (_isFloatAioType)
_aoPTK.FloatValue = (float)value;
else
_aoPTK.Value = (short)value;
}
}
}
private AOAccessor _aoPTOffset = null;
private AOAccessor _aoPTK = null;
private AOAccessor _aoOffset = null;
private bool _isFloatAioType = false;
private string _offsetName;
private string _kName;
public IoPTOffsetAndK(string module, XmlElement node, string ioModule = "")
{
@ -65,91 +47,33 @@ namespace Aitex.Core.RT.Device.Devices
Module = string.IsNullOrEmpty(attrModule) ? module : attrModule;
Name = node.GetAttribute("id");
Display = node.GetAttribute("display");
DeviceID = node.GetAttribute("schematicId");
Unit = node.GetAttribute("unit");
_isFloatAioType = !string.IsNullOrEmpty(node.GetAttribute("aioType")) && (node.GetAttribute("aioType") == "float");
_aoPTOffset = ParseAoNode("aoOffset", node, ioModule);
_aoPTK = ParseAoNode("aoK", node, ioModule);
_offsetName = Display + "_Offset";
_kName = Display + "_K";
_aoOffset = ParseAoNode("aoOffset", node, ioModule);
}
public bool Initialize()
{
if (Name.Contains("Water"))
{
DATA.Subscribe($"{Module}.AllOffset.{Name}", () => PTOffset);
}
else
OP.Subscribe($"{Module}.{Display}.{Name}", (function, args) =>
{
DATA.Subscribe($"{Module}.AllOffset.{Name}.PTOffset", () => PTOffset);
DATA.Subscribe($"{Module}.AllOffset.{Name}.PTK", () => PTK);
}
OP.Subscribe($"{Module}.{Display}.SetPTOffset", (function, args) =>
{
SetPTOffset();
Set_Callback();
return true;
});
OP.Subscribe($"{Module}.{Display}.SetPTK", (function, args) =>
{
SetPTK();
return true;
});
OP.Subscribe($"{Module}.{Name}", (function, args) =>
{
SetTempOffset();
return true;
});
SC.RegisterValueChangedCallback($"PM.{Module}.{Display}.{Name}", (o) => { Set_Callback(o.ToString()); });
return true;
}
public void SetTempOffset()
public void Set_Callback(string b ="")
{
try
{
PTOffset = SC.GetValue<double>($"PM.{Module}.WaterTemp.{Name}");
EV.PostInfoLog(Module, $"Set PM.{Module}.WaterTemp.{Name} OK.");
PTOffset = SC.GetValue<double>($"PM.{Module}.{Display}.{Name}");
EV.PostInfoLog(Module, $"Set PM.{Module}.{Display}.{Name} OK.");
}
catch (Exception ex)
{
EV.PostAlarmLog(Module, $"Set PM.{Module}.WaterTemp.{Name} Error:" + ex.Message);
EV.PostAlarmLog(Module, $"Set PM.{Module}.{Display}.{Name} Error:" + ex.Message);
}
}
public void SetPTOffset()
{
try
{
PTOffset = SC.GetValue<double>($"PM.{Module}.PT.{Display}.{_offsetName}");
EV.PostInfoLog(Module, $"Set PM..{Module}.PT.{Display}.{_offsetName} OK.");
}
catch (Exception ex)
{
EV.PostAlarmLog(Module, $"Set PM..{Module}.PT.{Display}.{_offsetName} Error:" + ex.Message);
}
}
public void SetPTK()
{
try
{
PTK = SC.GetValue<double>($"PM.{Module}.PT.{Display}.{_kName}");
EV.PostInfoLog(Module, $"Set PM..{Module}.PT.{Display}.{_kName} OK.");
}
catch (Exception ex)
{
EV.PostAlarmLog(Module, $"Set PM..{Module}.PT.{Display}.{_kName} Error:" + ex.Message);
}
}
public void Terminate()
{

View File

@ -272,8 +272,6 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig
InvokeClient.Instance.Service.DoOperation($"{SystemName}.SetConfig", key, value);
item.TextSaved = true;
ExTrigger(key, value);
}
Reload();
@ -370,46 +368,9 @@ namespace MECF.Framework.UI.Client.CenterViews.Configs.SystemConfig
item.TextSaved = true;
Reload();
//扩展Set触发其他事件
ExTrigger(key, value);
}
#region Set触发其他事件
private void ExTrigger(string key, string value)
{
if (key.Contains("Water"))
{
string[] strArray = key.Split('.');
string STR = $"{strArray[1]}.{strArray[3]}.SetTempOffset";
InvokeClient.Instance.Service.DoOperation($"{strArray[1]}.{strArray[3]}", value);
}
if (key.Contains("_Offset"))
{
string[] strArray = key.Split('.');
string STR = $"{strArray[1]}.{strArray[3]}.SetPTOffset";
InvokeClient.Instance.Service.DoOperation($"{strArray[1]}.{strArray[3]}.SetPTOffset", value);
}
else if (key.Contains("_K"))
{
string[] strArray = key.Split('.');
InvokeClient.Instance.Service.DoOperation($"{strArray[1]}.{strArray[3]}.SetPTK", value);
}
else if (key == "System.RecipePasswordReset")
{
RecipePasswordReset(key, value);
}
}
private void RecipePasswordReset(string sKey, string sValue)
{
if (sValue.Trim() == "0")
{
InvokeClient.Instance.Service.DoOperation("PM1.Recipe.EditorChangePassword", sValue);
}
}
#endregion
public void Reload()
{