153 lines
5.6 KiB
C#
153 lines
5.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text.Json.Serialization;
|
|
|
|
namespace XplorePlane.Models
|
|
{
|
|
// ── CNC 节点类型枚举 | CNC Node Type Enumeration ──────────────────
|
|
|
|
/// <summary>CNC 节点类型 | CNC node type</summary>
|
|
[JsonConverter(typeof(JsonStringEnumConverter))]
|
|
public enum CncNodeType
|
|
{
|
|
ReferencePoint,
|
|
SaveNodeWithImage,
|
|
SaveNode,
|
|
SavePosition,
|
|
InspectionModule,
|
|
InspectionMarker,
|
|
PauseDialog,
|
|
WaitDelay,
|
|
CompleteProgram
|
|
}
|
|
|
|
// ── CNC 节点基类与派生类型 | CNC Node Base & Derived Types ────────
|
|
|
|
/// <summary>
|
|
/// CNC 节点抽象基类(不可变)| CNC node abstract base (immutable)
|
|
/// 使用 System.Text.Json 多态序列化 | Uses System.Text.Json polymorphic serialization
|
|
/// </summary>
|
|
[JsonDerivedType(typeof(ReferencePointNode), "ReferencePoint")]
|
|
[JsonDerivedType(typeof(SaveNodeWithImageNode), "SaveNodeWithImage")]
|
|
[JsonDerivedType(typeof(SaveNodeNode), "SaveNode")]
|
|
[JsonDerivedType(typeof(SavePositionNode), "SavePosition")]
|
|
[JsonDerivedType(typeof(InspectionModuleNode), "InspectionModule")]
|
|
[JsonDerivedType(typeof(InspectionMarkerNode), "InspectionMarker")]
|
|
[JsonDerivedType(typeof(PauseDialogNode), "PauseDialog")]
|
|
[JsonDerivedType(typeof(WaitDelayNode), "WaitDelay")]
|
|
[JsonDerivedType(typeof(CompleteProgramNode), "CompleteProgram")]
|
|
public abstract record CncNode(
|
|
Guid Id,
|
|
int Index,
|
|
CncNodeType NodeType,
|
|
string Name);
|
|
|
|
/// <summary>参考点节点 | Reference point node</summary>
|
|
public record ReferencePointNode(
|
|
Guid Id,
|
|
int Index,
|
|
string Name,
|
|
[property: JsonPropertyName("XM")] double StageX,
|
|
[property: JsonPropertyName("YM")] double StageY,
|
|
[property: JsonPropertyName("ZT")] double SourceZ,
|
|
[property: JsonPropertyName("ZD")] double DetectorZ,
|
|
[property: JsonPropertyName("TiltD")] double DetectorSwing,
|
|
[property: JsonPropertyName("Dist")] double FDD,
|
|
bool IsRayOn,
|
|
double Voltage,
|
|
double Current,
|
|
double StageRotation = 0,
|
|
double FixtureRotation = 0,
|
|
double FOD = 0,
|
|
double Magnification = 0) : CncNode(Id, Index, CncNodeType.ReferencePoint, Name);
|
|
|
|
/// <summary>保存节点(含图像)| Save node with image</summary>
|
|
public record SaveNodeWithImageNode(
|
|
Guid Id,
|
|
int Index,
|
|
string Name,
|
|
MotionState MotionState,
|
|
RaySourceState RaySourceState,
|
|
DetectorState DetectorState,
|
|
string ImageFileName) : CncNode(Id, Index, CncNodeType.SaveNodeWithImage, Name);
|
|
|
|
/// <summary>保存节点(不含图像)| Save node without image</summary>
|
|
public record SaveNodeNode(
|
|
Guid Id,
|
|
int Index,
|
|
string Name,
|
|
MotionState MotionState,
|
|
RaySourceState RaySourceState,
|
|
DetectorState DetectorState) : CncNode(Id, Index, CncNodeType.SaveNode, Name);
|
|
|
|
/// <summary>保存位置节点 | Save position node</summary>
|
|
public record SavePositionNode(
|
|
Guid Id,
|
|
int Index,
|
|
string Name,
|
|
MotionState MotionState) : CncNode(Id, Index, CncNodeType.SavePosition, Name);
|
|
|
|
/// <summary>检测模块节点 | Inspection module node</summary>
|
|
public record InspectionModuleNode(
|
|
Guid Id,
|
|
int Index,
|
|
string Name,
|
|
PipelineModel Pipeline) : CncNode(Id, Index, CncNodeType.InspectionModule, Name);
|
|
|
|
/// <summary>检测标记节点 | Inspection marker node</summary>
|
|
public record InspectionMarkerNode(
|
|
Guid Id,
|
|
int Index,
|
|
string Name,
|
|
string MarkerType,
|
|
double MarkerX,
|
|
double MarkerY) : CncNode(Id, Index, CncNodeType.InspectionMarker, Name);
|
|
|
|
/// <summary>停顿对话框节点 | Pause dialog node</summary>
|
|
public record PauseDialogNode(
|
|
Guid Id,
|
|
int Index,
|
|
string Name,
|
|
string DialogTitle,
|
|
string DialogMessage) : CncNode(Id, Index, CncNodeType.PauseDialog, Name);
|
|
|
|
/// <summary>等待延时节点 | Wait delay node</summary>
|
|
public record WaitDelayNode(
|
|
Guid Id,
|
|
int Index,
|
|
string Name,
|
|
int DelayMilliseconds) : CncNode(Id, Index, CncNodeType.WaitDelay, Name);
|
|
|
|
/// <summary>完成程序节点 | Complete program node</summary>
|
|
public record CompleteProgramNode(
|
|
Guid Id,
|
|
int Index,
|
|
string Name) : CncNode(Id, Index, CncNodeType.CompleteProgram, Name);
|
|
|
|
// ── CNC 程序 | CNC Program ────────────────────────────────────────
|
|
|
|
/// <summary>CNC 程序(不可变)| CNC program (immutable)</summary>
|
|
public record CncProgram(
|
|
Guid Id,
|
|
string Name,
|
|
DateTime CreatedAt,
|
|
DateTime UpdatedAt,
|
|
IReadOnlyList<CncNode> Nodes
|
|
);
|
|
|
|
// ── 节点执行状态 | Node Execution State ──────────────────────────
|
|
|
|
/// <summary>节点执行状态枚举 | Node execution state enumeration</summary>
|
|
public enum NodeExecutionState
|
|
{
|
|
/// <summary>未执行(默认)| Not yet executed (default)</summary>
|
|
Idle,
|
|
/// <summary>正在执行 | Currently executing</summary>
|
|
Running,
|
|
/// <summary>执行成功 | Execution succeeded</summary>
|
|
Succeeded,
|
|
/// <summary>执行失败 | Execution failed</summary>
|
|
Failed
|
|
}
|
|
}
|