MoS2/Framework/MECF.Framework.RT.EquipmentLibrary/PmDevices/ValveActionData.cs
2026-06-15 10:56:30 +08:00

65 lines
2.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using Aitex.Core.RT.Device.Devices;
using System.Collections.Generic;
namespace Aitex.Core.RT.Device.PmDevices
{
/// <summary>
/// Recipe使用枚举设置模式时气阀需要对应操作
/// 当前对象包含阀DI对应模式下操作气阀设置相应的状态
/// </summary>
public class ValveActionData
{
/// <summary>
/// 气阀对应的PM
/// </summary>
public string Module { get; private set; }
/// <summary>
/// 气阀对应Device中的ID
/// </summary>
public string Id { get; private set; }
/// <summary>
/// 气阀名称
/// </summary>
public string Name { get; private set; }
private readonly IValve _valve;
/// <summary>
/// 存储对应枚举中,需要设置气阀状态
/// </summary>
private readonly Dictionary<string, bool> _valveActionDic = new Dictionary<string, bool>();
public ValveActionData(string module, string id, string name)
{
Module = module;
Id = id;
Name = name;
_valve = DEVICE.GetDevice($"{Module}.{Name}") as IValve;
System.Diagnostics.Debug.Assert(_valve != null,
$"{Module} {Id} {Name} valve setting not valid : ValveActionData");
}
public void AddDictionary(string key, bool value)
{
if (_valveActionDic.ContainsKey(key))
System.Diagnostics.Debug.Assert(false, $"{Module} {Id} {Name} Dictionary contains key:ValveActionData");
else
_valveActionDic.Add(key, value);
}
public bool SetValve(string module, out string reson)
{
if (_valveActionDic.TryGetValue(module, out bool value))
{
_valve.TurnValve(value, out reson);
return true;
}
//System.Diagnostics.Debug.Assert(false, $"Valve not configuration:{Name}");
reson = $"Valve no need to set:{Name}";
return true;
}
}
}