You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.5 KiB
81 lines
2.5 KiB
using System.Reflection; |
|
|
|
namespace BrilliantSightClient.Model.Entity.ApiEntity |
|
{ |
|
/// <summary> |
|
/// 存储状态码及其描述信息的常量类。 |
|
/// </summary> |
|
public static class StatusCodes |
|
{ |
|
// 成功 |
|
public const string Ok = "ok"; |
|
// 成功 |
|
public const string Success = "S000"; |
|
|
|
// 采图正在进行中 |
|
public const string InProgress = "S001"; |
|
|
|
// 缓存图片被清理(读取不够及时) |
|
public const string CacheCleared = "S002"; |
|
|
|
// 无法向单片机发送指令 |
|
public const string CannotSendCommand = "S003"; |
|
|
|
// 单片机访问超时 |
|
public const string MicrocontrollerTimeout = "S004"; |
|
|
|
// 单片机返回错误码 |
|
public const string MicrocontrollerError = "S005"; |
|
|
|
// 摄像头未连接 |
|
public const string CameraNotConnected = "S006"; |
|
|
|
// 切工仪舱门未关闭 |
|
public const string OpenOfTheHatch = "S007"; |
|
|
|
/// <summary> |
|
/// 输出参数错误或者未定义 |
|
/// </summary> |
|
public const string OutputParameterNotProvidedOrIncorrect = "S008"; |
|
public const string PreviousTaskIncomplete = "S009"; |
|
|
|
// 未找到切工仪 |
|
public const string DeviceNotFound = "P001"; |
|
|
|
// 算法调用失败 |
|
public const string AlgorithmFailed = "P002"; |
|
|
|
// 图片文件读取失败 |
|
public const string ImageFileReadFailure = "P003"; |
|
|
|
// JSON解析失败 |
|
public const string JsonParseFailure = "P004"; |
|
|
|
// 未检测到钻石 |
|
public const string NoDiamond = "P011"; |
|
|
|
// 检测到钻石需进行清洁 |
|
public const string Recheck = "P021"; |
|
|
|
public static string GetConstantNameByValue(string value) |
|
{ |
|
// 获取 StatusCodes 类型信息 |
|
var type = typeof(StatusCodes); |
|
|
|
// 遍历所有公共静态常量字段 |
|
foreach (var field in type.GetFields(BindingFlags.Public | BindingFlags.Static | BindingFlags.FlattenHierarchy)) |
|
{ |
|
// 确保是字符串类型的常量 |
|
if (field.IsLiteral && !field.IsInitOnly && field.FieldType == typeof(string)) |
|
{ |
|
// 获取字段值并比较 |
|
if ((string)field.GetValue(null) == value) |
|
{ |
|
return field.Name; |
|
} |
|
} |
|
} |
|
return null; // 未找到时返回 null |
|
} |
|
} |
|
} |