将Feature/XP.Common和Feature/XP.Hardware分支合并至Develop/XP.forHardwareAndCommon,完善XPapp注册和相关硬件类库通用类库功能。
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
namespace XP.Hardware.RaySource.Comet.Messages.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// 全部电压自动定心命令
|
||||
/// </summary>
|
||||
public class AutoCenterCommand : RaySourceCommand
|
||||
{
|
||||
public override string CommandType => "AutoCenter";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace XP.Hardware.RaySource.Comet.Messages.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// 连接 PVI 变量命令
|
||||
/// </summary>
|
||||
public class ConnectVariablesCommand : RaySourceCommand
|
||||
{
|
||||
public override string CommandType => "ConnectVariables";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace XP.Hardware.RaySource.Comet.Messages.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// 断开连接命令
|
||||
/// </summary>
|
||||
public class DisconnectCommand : RaySourceCommand
|
||||
{
|
||||
public override string CommandType => "Disconnect";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace XP.Hardware.RaySource.Comet.Messages.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// 灯丝校准命令
|
||||
/// </summary>
|
||||
public class FilamentCalibrationCommand : RaySourceCommand
|
||||
{
|
||||
public override string CommandType => "FilamentCalibration";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
namespace XP.Hardware.RaySource.Comet.Messages.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// 初始化命令,包含 PVI 连接参数
|
||||
/// </summary>
|
||||
public class InitializeCommand : RaySourceCommand
|
||||
{
|
||||
public override string CommandType => "Initialize";
|
||||
|
||||
/// <summary>
|
||||
/// PLC IP 地址
|
||||
/// </summary>
|
||||
public string IpAddress { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// PLC 端口号
|
||||
/// </summary>
|
||||
public int Port { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// CPU 名称
|
||||
/// </summary>
|
||||
public string CpuName { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 源端口号
|
||||
/// </summary>
|
||||
public int SourcePort { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 源站号
|
||||
/// </summary>
|
||||
public int StationNumber { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
namespace XP.Hardware.RaySource.Comet.Messages.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// 射线源命令抽象基类
|
||||
/// 所有从主进程发往 Host 进程的请求均继承此类
|
||||
/// </summary>
|
||||
public abstract class RaySourceCommand
|
||||
{
|
||||
/// <summary>
|
||||
/// 命令类型标识
|
||||
/// </summary>
|
||||
public abstract string CommandType { get; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace XP.Hardware.RaySource.Comet.Messages.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// 读取电流命令
|
||||
/// </summary>
|
||||
public class ReadCurrentCommand : RaySourceCommand
|
||||
{
|
||||
public override string CommandType => "ReadCurrent";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace XP.Hardware.RaySource.Comet.Messages.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// 读取错误命令
|
||||
/// </summary>
|
||||
public class ReadErrorsCommand : RaySourceCommand
|
||||
{
|
||||
public override string CommandType => "ReadErrors";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace XP.Hardware.RaySource.Comet.Messages.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// 读取系统状态命令
|
||||
/// </summary>
|
||||
public class ReadSystemStatusCommand : RaySourceCommand
|
||||
{
|
||||
public override string CommandType => "ReadSystemStatus";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace XP.Hardware.RaySource.Comet.Messages.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// 读取电压命令
|
||||
/// </summary>
|
||||
public class ReadVoltageCommand : RaySourceCommand
|
||||
{
|
||||
public override string CommandType => "ReadVoltage";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace XP.Hardware.RaySource.Comet.Messages.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// 设置电流命令
|
||||
/// </summary>
|
||||
public class SetCurrentCommand : RaySourceCommand
|
||||
{
|
||||
public override string CommandType => "SetCurrent";
|
||||
|
||||
/// <summary>
|
||||
/// 目标电流值(μA)
|
||||
/// </summary>
|
||||
public float Current { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace XP.Hardware.RaySource.Comet.Messages.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// 设置功率模式命令
|
||||
/// </summary>
|
||||
public class SetPowerModeCommand : RaySourceCommand
|
||||
{
|
||||
public override string CommandType => "SetPowerMode";
|
||||
|
||||
/// <summary>
|
||||
/// 功率模式值:1=Micro Focus,2=High Power
|
||||
/// </summary>
|
||||
public int Mode { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace XP.Hardware.RaySource.Comet.Messages.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// 设置电压命令
|
||||
/// </summary>
|
||||
public class SetVoltageCommand : RaySourceCommand
|
||||
{
|
||||
public override string CommandType => "SetVoltage";
|
||||
|
||||
/// <summary>
|
||||
/// 目标电压值(kV)
|
||||
/// </summary>
|
||||
public float Voltage { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace XP.Hardware.RaySource.Comet.Messages.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// 训机设置命令
|
||||
/// </summary>
|
||||
public class TrainingCommand : RaySourceCommand
|
||||
{
|
||||
public override string CommandType => "Training";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace XP.Hardware.RaySource.Comet.Messages.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// 关闭高压命令
|
||||
/// </summary>
|
||||
public class TurnOffCommand : RaySourceCommand
|
||||
{
|
||||
public override string CommandType => "TurnOff";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace XP.Hardware.RaySource.Comet.Messages.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// 开启高压命令
|
||||
/// </summary>
|
||||
public class TurnOnCommand : RaySourceCommand
|
||||
{
|
||||
public override string CommandType => "TurnOn";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace XP.Hardware.RaySource.Comet.Messages.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// TXI 关闭命令
|
||||
/// </summary>
|
||||
public class TxiOffCommand : RaySourceCommand
|
||||
{
|
||||
public override string CommandType => "TxiOff";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace XP.Hardware.RaySource.Comet.Messages.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// TXI 开启命令
|
||||
/// </summary>
|
||||
public class TxiOnCommand : RaySourceCommand
|
||||
{
|
||||
public override string CommandType => "TxiOn";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
namespace XP.Hardware.RaySource.Comet.Messages.Commands
|
||||
{
|
||||
/// <summary>
|
||||
/// 暖机设置命令
|
||||
/// </summary>
|
||||
public class WarmUpCommand : RaySourceCommand
|
||||
{
|
||||
public override string CommandType => "WarmUp";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
using System;
|
||||
using Newtonsoft.Json;
|
||||
using XP.Hardware.RaySource.Comet.Messages.Commands;
|
||||
using XP.Hardware.RaySource.Comet.Messages.Responses;
|
||||
|
||||
namespace XP.Hardware.RaySource.Comet.Messages
|
||||
{
|
||||
/// <summary>
|
||||
/// 消息序列化工具类
|
||||
/// 封装 Newtonsoft.Json 序列化/反序列化逻辑
|
||||
/// </summary>
|
||||
public static class MessageSerializer
|
||||
{
|
||||
/// <summary>
|
||||
/// JSON 序列化设置
|
||||
/// TypeNameHandling.Auto:保留类型信息以支持多态反序列化
|
||||
/// NullValueHandling.Ignore:忽略 null 值减少传输量
|
||||
/// Formatting.None:单行输出配合行协议
|
||||
/// </summary>
|
||||
private static readonly JsonSerializerSettings Settings = new JsonSerializerSettings
|
||||
{
|
||||
TypeNameHandling = TypeNameHandling.All,
|
||||
NullValueHandling = NullValueHandling.Ignore,
|
||||
Formatting = Formatting.None
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// 将对象序列化为 JSON 字符串
|
||||
/// </summary>
|
||||
/// <typeparam name="T">对象类型</typeparam>
|
||||
/// <param name="obj">要序列化的对象</param>
|
||||
/// <returns>JSON 字符串</returns>
|
||||
public static string Serialize<T>(T obj)
|
||||
{
|
||||
return JsonConvert.SerializeObject(obj, Settings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将 JSON 字符串反序列化为指定类型的对象
|
||||
/// </summary>
|
||||
/// <typeparam name="T">目标类型</typeparam>
|
||||
/// <param name="json">JSON 字符串</param>
|
||||
/// <returns>反序列化后的对象,失败时返回 null</returns>
|
||||
public static T Deserialize<T>(string json) where T : class
|
||||
{
|
||||
try
|
||||
{
|
||||
return JsonConvert.DeserializeObject<T>(json, Settings);
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将 JSON 字符串反序列化为命令对象
|
||||
/// 根据类型信息还原为正确的命令子类实例
|
||||
/// </summary>
|
||||
/// <param name="json">JSON 字符串</param>
|
||||
/// <returns>命令对象,失败时返回 null</returns>
|
||||
public static RaySourceCommand DeserializeCommand(string json)
|
||||
{
|
||||
try
|
||||
{
|
||||
return JsonConvert.DeserializeObject<RaySourceCommand>(json, Settings);
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 将 JSON 字符串反序列化为响应对象
|
||||
/// 根据类型信息还原为正确的响应子类实例
|
||||
/// </summary>
|
||||
/// <param name="json">JSON 字符串</param>
|
||||
/// <returns>响应对象,失败时返回 null</returns>
|
||||
public static RaySourceResponse DeserializeResponse(string json)
|
||||
{
|
||||
try
|
||||
{
|
||||
return JsonConvert.DeserializeObject<RaySourceResponse>(json, Settings);
|
||||
}
|
||||
catch (JsonException)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"runtimeTarget": {
|
||||
"name": ".NETStandard,Version=v2.0/",
|
||||
"signature": ""
|
||||
},
|
||||
"compilationOptions": {},
|
||||
"targets": {
|
||||
".NETStandard,Version=v2.0": {},
|
||||
".NETStandard,Version=v2.0/": {
|
||||
"XP.Hardware.RaySource.Comet.Messages/1.0.0": {
|
||||
"dependencies": {
|
||||
"Newtonsoft.Json": "13.0.3"
|
||||
},
|
||||
"runtime": {
|
||||
"XP.Hardware.RaySource.Comet.Messages.dll": {}
|
||||
}
|
||||
},
|
||||
"Newtonsoft.Json/13.0.3": {
|
||||
"runtime": {
|
||||
"lib/netstandard2.0/Newtonsoft.Json.dll": {
|
||||
"assemblyVersion": "13.0.0.0",
|
||||
"fileVersion": "13.0.3.27908"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"XP.Hardware.RaySource.Comet.Messages/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
},
|
||||
"Newtonsoft.Json/13.0.3": {
|
||||
"type": "package",
|
||||
"serviceable": true,
|
||||
"sha512": "sha512-HrC5BXdl00IP9zeV+0Z848QWPAoCr9P3bDEZguI+gkLcBKAOxix/tLEAAHC+UvDNPv4a2d18lOReHMOagPa+zQ==",
|
||||
"path": "newtonsoft.json/13.0.3",
|
||||
"hashPath": "newtonsoft.json.13.0.3.nupkg.sha512"
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -0,0 +1,28 @@
|
||||
namespace XP.Hardware.RaySource.Comet.Messages.Responses
|
||||
{
|
||||
/// <summary>
|
||||
/// 错误数据响应,包含各类错误信息
|
||||
/// </summary>
|
||||
public class ErrorDataResponse : RaySourceResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 系统错误信息
|
||||
/// </summary>
|
||||
public string SystemError { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// HSG 错误信息
|
||||
/// </summary>
|
||||
public string HSGError { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 管错误信息
|
||||
/// </summary>
|
||||
public string TubeError { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 管真空错误信息
|
||||
/// </summary>
|
||||
public string TubeVacError { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
namespace XP.Hardware.RaySource.Comet.Messages.Responses
|
||||
{
|
||||
/// <summary>
|
||||
/// 日志响应,用于 Host 进程向主进程传递日志消息
|
||||
/// </summary>
|
||||
public class LogResponse : RaySourceResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 日志级别(Debug、Info、Warn、Error、Fatal)
|
||||
/// </summary>
|
||||
public string Level { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 日志消息内容
|
||||
/// </summary>
|
||||
public string Message { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 日志消息参数
|
||||
/// </summary>
|
||||
public string[] Args { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
namespace XP.Hardware.RaySource.Comet.Messages.Responses
|
||||
{
|
||||
/// <summary>
|
||||
/// 通用操作响应,携带返回数据
|
||||
/// </summary>
|
||||
public class OperationResponse : RaySourceResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 操作返回的数据
|
||||
/// </summary>
|
||||
public object Data { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
namespace XP.Hardware.RaySource.Comet.Messages.Responses
|
||||
{
|
||||
/// <summary>
|
||||
/// 射线源响应抽象基类
|
||||
/// 所有从 Host 进程返回主进程的响应均继承此类
|
||||
/// </summary>
|
||||
public abstract class RaySourceResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 操作是否成功
|
||||
/// </summary>
|
||||
public bool Success { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 错误消息(成功时为 null)
|
||||
/// </summary>
|
||||
public string ErrorMessage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否为主动推送消息(区分命令响应和主动推送)
|
||||
/// </summary>
|
||||
public bool IsPush { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 推送类型标识(StatusChanged、XRayStateChanged、ErrorOccurred、ConnectionStateChanged、Log)
|
||||
/// </summary>
|
||||
public string PushType { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
namespace XP.Hardware.RaySource.Comet.Messages.Responses
|
||||
{
|
||||
/// <summary>
|
||||
/// 状态响应,包含与 CometStatusData 一一对应的所有状态字段
|
||||
/// </summary>
|
||||
public class StatusResponse : RaySourceResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 设定电压值(kV)
|
||||
/// </summary>
|
||||
public float SetVoltage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实际电压值(kV)
|
||||
/// </summary>
|
||||
public float ActualVoltage { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 设定电流值(μA)
|
||||
/// </summary>
|
||||
public float SetCurrent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 实际电流值(μA)
|
||||
/// </summary>
|
||||
public float ActualCurrent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 射线开启状态
|
||||
/// </summary>
|
||||
public bool IsXRayOn { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 暖机状态描述
|
||||
/// </summary>
|
||||
public string WarmUpStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 真空状态描述
|
||||
/// </summary>
|
||||
public string VacuumStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 启动状态描述
|
||||
/// </summary>
|
||||
public string StartUpStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 自动定心状态描述
|
||||
/// </summary>
|
||||
public string AutoCenterStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 灯丝调整状态描述
|
||||
/// </summary>
|
||||
public string FilamentAdjustStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 连锁状态
|
||||
/// </summary>
|
||||
public bool IsInterlockActive { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 看门狗状态
|
||||
/// </summary>
|
||||
public string WatchdogStatus { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 功率模式
|
||||
/// </summary>
|
||||
public string PowerMode { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// TXI 状态
|
||||
/// </summary>
|
||||
public string TxiStatus { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netstandard2.0</TargetFramework>
|
||||
<RootNamespace>XP.Hardware.RaySource.Comet.Messages</RootNamespace>
|
||||
<!-- NuGet 包版本 (用于包管理) -->
|
||||
<Version>1.0.0</Version>
|
||||
<!-- 程序集版本 (用于代码引用) -->
|
||||
<AssemblyVersion>1.0.0.0</AssemblyVersion>
|
||||
<!-- 文件版本 (用于 Windows 文件属性显示) -->
|
||||
<FileVersion>1.0.0.0</FileVersion>
|
||||
<!-- 版权声明 -->
|
||||
<Copyright>Copyright © 2026 Hexagon. All rights reserved.</Copyright>
|
||||
<!-- 公司名称 -->
|
||||
<Company>Hexagon Manufacturing Intelligence (Qingdao) Co., Ltd.</Company>
|
||||
<!-- 产品名称 -->
|
||||
<Product>XP.Hardware.RaySource.Comet.Messages</Product>
|
||||
<!-- 标题 -->
|
||||
<AssemblyTitle>XP.Hardware.RaySource.Comet Core Library</AssemblyTitle>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
Reference in New Issue
Block a user