将Feature/XP.Common和Feature/XP.Hardware分支合并至Develop/XP.forHardwareAndCommon,完善XPapp注册和相关硬件类库通用类库功能。
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
using XP.Common.Localization.Interfaces;
|
||||
|
||||
namespace XP.Hardware.RaySource.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// 设备状态码多语言映射工具 | Device status code localization mapper
|
||||
/// 将 Comet.Host 传递的原始 code 码映射为多语言显示文本
|
||||
/// </summary>
|
||||
public static class StatusCodeMapper
|
||||
{
|
||||
/// <summary>
|
||||
/// 暖机状态码映射 | Warm-up status code mapping
|
||||
/// </summary>
|
||||
public static string MapWarmUpStatus(string code, ILocalizationService loc)
|
||||
{
|
||||
return code switch
|
||||
{
|
||||
"0" => loc.GetString("RaySource_Status_WarmUp_0") ?? "初始状态",
|
||||
"1" => loc.GetString("RaySource_Status_WarmUp_1") ?? "暖机中",
|
||||
"2" => loc.GetString("RaySource_Status_WarmUp_2") ?? "暖机完成",
|
||||
"3" => loc.GetString("RaySource_Status_WarmUp_3") ?? "暖机失败",
|
||||
"33" => loc.GetString("RaySource_Status_WarmUp_33") ?? "需要暖机",
|
||||
_ => loc.GetString("RaySource_Status_Unknown") ?? "未知状态"
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 真空状态码映射 | Vacuum status code mapping
|
||||
/// </summary>
|
||||
public static string MapVacuumStatus(string code, ILocalizationService loc)
|
||||
{
|
||||
return code switch
|
||||
{
|
||||
"0" => loc.GetString("RaySource_Status_Vacuum_0") ?? "初始状态",
|
||||
"1" => loc.GetString("RaySource_Status_Vacuum_1") ?? "抽真空中",
|
||||
"2" => loc.GetString("RaySource_Status_Vacuum_2") ?? "真空准备好",
|
||||
"22" => loc.GetString("RaySource_Status_Vacuum_22") ?? "真空值<1e-5mbar",
|
||||
"30" => loc.GetString("RaySource_Status_Vacuum_30") ?? "真空泵未使能",
|
||||
"40" => loc.GetString("RaySource_Status_Vacuum_40") ?? "真空泵通风",
|
||||
_ => loc.GetString("RaySource_Status_Unknown") ?? "未知状态"
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 训机状态码映射 | Training status code mapping
|
||||
/// </summary>
|
||||
public static string MapStartUpStatus(string code, ILocalizationService loc)
|
||||
{
|
||||
return code switch
|
||||
{
|
||||
"0" => loc.GetString("RaySource_Status_StartUp_0") ?? "初始状态",
|
||||
"1" => loc.GetString("RaySource_Status_StartUp_1") ?? "训机中",
|
||||
"2" => loc.GetString("RaySource_Status_StartUp_2") ?? "训机完成",
|
||||
"3" => loc.GetString("RaySource_Status_StartUp_3") ?? "训机失败",
|
||||
_ => loc.GetString("RaySource_Status_Unknown") ?? "未知状态"
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 自动定心状态码映射 | Auto-center status code mapping
|
||||
/// </summary>
|
||||
public static string MapAutoCenterStatus(string code, ILocalizationService loc)
|
||||
{
|
||||
return code switch
|
||||
{
|
||||
"0" => loc.GetString("RaySource_Status_AutoCenter_0") ?? "初始状态",
|
||||
"1" => loc.GetString("RaySource_Status_AutoCenter_1") ?? "自动定心中",
|
||||
"2" => loc.GetString("RaySource_Status_AutoCenter_2") ?? "自动定心完成",
|
||||
"3" => loc.GetString("RaySource_Status_AutoCenter_3") ?? "定心失败",
|
||||
_ => loc.GetString("RaySource_Status_Unknown") ?? "未知状态"
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 灯丝调整状态码映射 | Filament adjust status code mapping
|
||||
/// </summary>
|
||||
public static string MapFilamentAdjustStatus(string code, ILocalizationService loc)
|
||||
{
|
||||
return code switch
|
||||
{
|
||||
"0" => loc.GetString("RaySource_Status_Filament_0") ?? "初始状态",
|
||||
"1" => loc.GetString("RaySource_Status_Filament_1") ?? "灯丝校准中",
|
||||
"2" => loc.GetString("RaySource_Status_Filament_2") ?? "灯丝校准完成",
|
||||
"3" => loc.GetString("RaySource_Status_Filament_3") ?? "灯丝校准失败",
|
||||
"33" => loc.GetString("RaySource_Status_Filament_33") ?? "需要灯丝校准",
|
||||
_ => loc.GetString("RaySource_Status_Unknown") ?? "未知状态"
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 功率模式码映射 | Power mode code mapping
|
||||
/// </summary>
|
||||
public static string MapPowerMode(string code, ILocalizationService loc)
|
||||
{
|
||||
var trimmed = (code ?? "").Trim();
|
||||
if (int.TryParse(trimmed, out var intVal))
|
||||
{
|
||||
return intVal switch
|
||||
{
|
||||
1 => loc.GetString("RaySource_Status_PowerMode_1") ?? "Micro Focus",
|
||||
2 => loc.GetString("RaySource_Status_PowerMode_2") ?? "High Power",
|
||||
_ => loc.GetString("RaySource_Status_Unknown") ?? "未知状态"
|
||||
};
|
||||
}
|
||||
if (string.IsNullOrEmpty(trimmed))
|
||||
return "--";
|
||||
return loc.GetString("RaySource_Status_Unknown") ?? "未知状态";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// TXI 状态码映射 | TXI status code mapping
|
||||
/// </summary>
|
||||
public static string MapTxiStatus(string code, ILocalizationService loc)
|
||||
{
|
||||
return code switch
|
||||
{
|
||||
"True" => loc.GetString("RaySource_Status_TXI_On") ?? "TXI 开启",
|
||||
"False" => loc.GetString("RaySource_Status_TXI_Off") ?? "TXI 关闭",
|
||||
_ => loc.GetString("RaySource_Status_Unknown") ?? "未知状态"
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user