refactor(heater): 优化Heater相关代码
PMHeaterView视图从SicUI移至公共库。 HeatStrategy控温策略枚举增加Display属性,在界面显示中使用Auto、Follow,显示更简洁。 FlowMode、TCModes、HeatStrategy等枚举从DicMode对象中移出至Aitex.Core.RT.Device.PmDevices命名空间。
This commit is contained in:
parent
60e358490b
commit
66c48f5e76
|
@ -412,14 +412,14 @@ namespace Aitex.Core.RT.Device.Devices
|
|||
{
|
||||
reason = "";
|
||||
var iMode = Convert.ToInt32(args[0]);
|
||||
SetHeatMode(ConvertToHeaterMode(iMode), time, TCUnits.PSU);
|
||||
SetHeatMode(ConvertToHeatStrategy(iMode), time, TCUnits.PSU);
|
||||
return true;
|
||||
});
|
||||
OP.Subscribe($"{Module}.{Name}.SetHeaterMode2", (out string reason, int time, object[] args) =>
|
||||
{
|
||||
reason = "";
|
||||
var iMode = Convert.ToInt32(args[0]);
|
||||
SetHeatMode(ConvertToHeaterMode(iMode), time, TCUnits.SCR);
|
||||
SetHeatMode(ConvertToHeatStrategy(iMode), time, TCUnits.SCR);
|
||||
return true;
|
||||
});
|
||||
OP.Subscribe($"{Module}.{Name}.SetRatio", (function, args) =>
|
||||
|
@ -1669,7 +1669,7 @@ namespace Aitex.Core.RT.Device.Devices
|
|||
return HeatStrategy.Power;
|
||||
|
||||
var mode = (int)(ao.Value);
|
||||
return ConvertToHeaterMode(mode);
|
||||
return ConvertToHeatStrategy(mode);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@
|
|||
<HintPath>..\Sicentury.Core\bin\Debug\Sicentury.Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
|
|
|
@ -1,75 +1,80 @@
|
|||
using System;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Aitex.Core.RT.Device.PmDevices
|
||||
{
|
||||
public enum FlowMode
|
||||
{
|
||||
Purge,
|
||||
Vent,
|
||||
Run,
|
||||
Close,
|
||||
}
|
||||
|
||||
public enum ArH2Switch
|
||||
{
|
||||
Ar,
|
||||
H2,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 2704每通道工作模式
|
||||
/// </summary>
|
||||
public enum TCModes
|
||||
{
|
||||
/// <summary>
|
||||
/// 自动模式
|
||||
/// </summary>
|
||||
Auto,
|
||||
|
||||
/// <summary>
|
||||
/// 手动模式
|
||||
/// </summary>
|
||||
Manual
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 温度控制策略。
|
||||
/// </summary>
|
||||
public enum HeatStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// 功率控制
|
||||
/// </summary>
|
||||
[Display(Name = "Power")]
|
||||
Power,
|
||||
|
||||
/// <summary>
|
||||
/// 对于PSU:L2自动控温;L1、L3功率控制,输出功率按比例跟随L2
|
||||
/// 对于SCR:L3自动控温;L1、L2功率控制,输出功率按比例跟随L2
|
||||
/// </summary>
|
||||
[Display(Name = "Follow")]
|
||||
PyroFollow,
|
||||
|
||||
/// <summary>
|
||||
/// L2、L3自动控温;L1功率控制,输出功率按比例跟随L1
|
||||
/// </summary>
|
||||
[Display(Name = "Auto")]
|
||||
PyroAuto
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加热控制单元。
|
||||
/// <para>
|
||||
/// TC1即PSU;TC2即SCR
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public enum TCUnits
|
||||
{
|
||||
PSU,
|
||||
SCR,
|
||||
TC1, // PSU
|
||||
TC2 // SCR
|
||||
}
|
||||
|
||||
|
||||
public class DicMode
|
||||
{
|
||||
public enum FlowMode
|
||||
{
|
||||
Purge,
|
||||
Vent,
|
||||
Run,
|
||||
Close,
|
||||
}
|
||||
|
||||
public enum ArH2Switch
|
||||
{
|
||||
Ar,
|
||||
H2,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 2704每通道工作模式
|
||||
/// </summary>
|
||||
public enum TCModes
|
||||
{
|
||||
/// <summary>
|
||||
/// 自动模式
|
||||
/// </summary>
|
||||
Auto,
|
||||
|
||||
/// <summary>
|
||||
/// 手动模式
|
||||
/// </summary>
|
||||
Manual
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 温度控制策略。
|
||||
/// </summary>
|
||||
public enum HeatStrategy
|
||||
{
|
||||
/// <summary>
|
||||
/// 功率控制
|
||||
/// </summary>
|
||||
Power,
|
||||
|
||||
/// <summary>
|
||||
/// L2、L3自动控温;L1功率控制,输出功率按比例跟随L1
|
||||
/// </summary>
|
||||
PyroAuto,
|
||||
|
||||
/// <summary>
|
||||
/// 对于PSU:L2自动控温;L1、L3功率控制,输出功率按比例跟随L2
|
||||
/// 对于SCR:L3自动控温;L1、L2功率控制,输出功率按比例跟随L2
|
||||
/// </summary>
|
||||
PyroFollow
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 加热控制单元。
|
||||
/// <para>
|
||||
/// TC1即PSU;TC2即SCR
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public enum TCUnits
|
||||
{
|
||||
PSU,
|
||||
SCR,
|
||||
TC1, // PSU
|
||||
TC2 // SCR
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查指定名称的设备是否为PSU。
|
||||
/// </summary>
|
||||
|
@ -128,12 +133,13 @@ namespace Aitex.Core.RT.Device.PmDevices
|
|||
/// </summary>
|
||||
/// <param name="mode"></param>
|
||||
/// <returns></returns>
|
||||
public static HeatStrategy ConvertToHeaterMode(int mode)
|
||||
public static HeatStrategy ConvertToHeatStrategy(int mode)
|
||||
{
|
||||
var strategy = HeatStrategy.Power;
|
||||
if (Enum.IsDefined(typeof(HeatStrategy), mode))
|
||||
return (HeatStrategy)mode;
|
||||
strategy = (HeatStrategy)mode;
|
||||
|
||||
return HeatStrategy.Power;
|
||||
return strategy;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,29 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Documents;
|
||||
using System.Windows.Input;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using System.Windows.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.Modules.PM
|
||||
{
|
||||
/// <summary>
|
||||
/// PMHeaterView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class PMHeaterView : UserControl
|
||||
{
|
||||
public PMHeaterView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -961,8 +961,8 @@ namespace MECF.Framework.UI.Client.CenterViews.Modules.PM
|
|||
|
||||
|
||||
public string TC1Mode =>
|
||||
Enum.IsDefined(typeof(DicMode.HeatStrategy), (int)TC1HeaterMode)
|
||||
? Enum.GetName(typeof(DicMode.HeatStrategy), (int)TC1HeaterMode)
|
||||
Enum.IsDefined(typeof(HeatStrategy), (int)TC1HeaterMode)
|
||||
? Enum.GetName(typeof(HeatStrategy), (int)TC1HeaterMode)
|
||||
: "Power";
|
||||
|
||||
[Subscription("TC2.HeaterModeSetPoint")]
|
||||
|
@ -970,8 +970,8 @@ namespace MECF.Framework.UI.Client.CenterViews.Modules.PM
|
|||
|
||||
|
||||
public string TC2Mode =>
|
||||
Enum.IsDefined(typeof(DicMode.HeatStrategy), (int)TC2HeaterMode)
|
||||
? Enum.GetName(typeof(DicMode.HeatStrategy), (int)TC2HeaterMode)
|
||||
Enum.IsDefined(typeof(HeatStrategy), (int)TC2HeaterMode)
|
||||
? Enum.GetName(typeof(HeatStrategy), (int)TC2HeaterMode)
|
||||
: "Power";
|
||||
|
||||
|
||||
|
|
|
@ -195,7 +195,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Modules.PM
|
|||
{
|
||||
get
|
||||
{
|
||||
return Enum.GetName(typeof(DicMode.HeatStrategy), Convert.ToInt32(TC1HeaterMode));
|
||||
return Enum.GetName(typeof(HeatStrategy), Convert.ToInt32(TC1HeaterMode));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -203,7 +203,7 @@ namespace MECF.Framework.UI.Client.CenterViews.Modules.PM
|
|||
{
|
||||
get
|
||||
{
|
||||
return Enum.GetName(typeof(DicMode.HeatStrategy), Convert.ToInt32(TC2HeaterMode));
|
||||
return Enum.GetName(typeof(HeatStrategy), Convert.ToInt32(TC2HeaterMode));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,9 @@
|
|||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Dependencies\Newtonsoft.Json.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="OpenSEMI.Ctrlib">
|
||||
<HintPath>..\Dependencies\OpenSEMI.Ctrlib.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
<Reference Include="PresentationFramework.Aero" />
|
||||
|
@ -307,6 +310,8 @@
|
|||
<DependentUpon>MaintainView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="CenterViews\Maintain\ViewModels\MaintainViewModel.cs" />
|
||||
<Compile Include="CenterViews\Modules\PM\PMHeaterView.xaml.cs" />
|
||||
<Compile Include="CenterViews\Modules\PM\PMHeaterViewModel.cs" />
|
||||
<Compile Include="CenterViews\Modules\PM\PMProcessView.xaml.cs">
|
||||
<DependentUpon>PMProcessView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
|
@ -1006,6 +1011,7 @@
|
|||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="CenterViews\Modules\PM\PMHeaterView.xaml" />
|
||||
<Page Include="CenterViews\Modules\PM\PMProcessView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
|
|
|
@ -89,10 +89,10 @@ namespace MECF.Framework.UI.Client.RecipeEditorLib.RecipeModel.Params
|
|||
if (ControlName == "TC1.SetHeaterMode" || ControlName == "TC2.SetHeaterMode2")
|
||||
{
|
||||
// 处理TC兼容性问题
|
||||
if (initValue == "Pyro" || initValue == DicMode.HeatStrategy.PyroFollow.ToString())
|
||||
if (initValue == "Pyro" || initValue == HeatStrategy.PyroFollow.ToString())
|
||||
return "Follow";
|
||||
|
||||
if (initValue == DicMode.HeatStrategy.PyroAuto.ToString())
|
||||
if (initValue == HeatStrategy.PyroAuto.ToString())
|
||||
return "Auto";
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace MECF.Framework.UI.Core.Converters;
|
||||
|
||||
public class EnumDescriptionConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var myEnum = (Enum)value;
|
||||
if (myEnum == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var description = GetEnumDescription(myEnum);
|
||||
return !string.IsNullOrEmpty(description) ? description : myEnum.ToString();
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private string GetEnumDescription(Enum enumObj)
|
||||
{
|
||||
if (enumObj == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var fieldInfo = enumObj.GetType().GetField(enumObj.ToString());
|
||||
|
||||
var attribArray = fieldInfo.GetCustomAttributes(false);
|
||||
|
||||
if (attribArray.Length == 0)
|
||||
{
|
||||
return enumObj.ToString();
|
||||
}
|
||||
|
||||
var attrib = attribArray[0] as DescriptionAttribute;
|
||||
return attrib.Description;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace MECF.Framework.UI.Core.Converters;
|
||||
|
||||
public class EnumDisplayConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var myEnum = (Enum)value;
|
||||
if (myEnum == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
var description = GetEnumDisplay(myEnum);
|
||||
return !string.IsNullOrEmpty(description) ? description : myEnum.ToString();
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private string GetEnumDisplay(Enum enumObj)
|
||||
{
|
||||
if (enumObj == null)
|
||||
{
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
var fieldInfo = enumObj.GetType().GetField(enumObj.ToString());
|
||||
|
||||
var attribArray = fieldInfo.GetCustomAttributes(false);
|
||||
|
||||
if (attribArray.Length == 0)
|
||||
{
|
||||
return enumObj.ToString();
|
||||
}
|
||||
|
||||
var attrib = attribArray[0] as DisplayAttribute;
|
||||
return attrib?.Name;
|
||||
}
|
||||
}
|
|
@ -76,6 +76,7 @@
|
|||
<Reference Include="System.Activities" />
|
||||
<Reference Include="System.Activities.Core.Presentation" />
|
||||
<Reference Include="System.Activities.Presentation" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Runtime.Serialization" />
|
||||
|
@ -291,6 +292,8 @@
|
|||
<Compile Include="Converters\CenterBorderGapMaskConverter.cs" />
|
||||
<Compile Include="Converters\ColorConverter_IsTestOK.cs" />
|
||||
<Compile Include="Converters\ColorToBrushConverter.cs" />
|
||||
<Compile Include="Converters\EnumDescriptionConverter.cs" />
|
||||
<Compile Include="Converters\EnumDisplayConverter.cs" />
|
||||
<Compile Include="Converters\GeneralConverter.cs" />
|
||||
<Compile Include="Converters\IntPermissionToIsEnabledConverter.cs" />
|
||||
<Compile Include="Converters\MarkdownToHtmlConverter.cs" />
|
||||
|
|
Loading…
Reference in New Issue