#0050 新增CNC视图

This commit is contained in:
zhengxuan.zhang
2026-03-27 09:54:03 +08:00
parent acc9b11942
commit 08fd25cdd0
32 changed files with 3182 additions and 13 deletions
+116
View File
@@ -0,0 +1,116 @@
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,
double XM, double YM, double ZT, double ZD, double TiltD, double Dist
) : 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
);
}
+45
View File
@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
using System.Text.Json.Serialization;
namespace XplorePlane.Models
{
// ── 矩阵单元格状态枚举 | Matrix Cell Status Enumeration ──────────
/// <summary>矩阵单元格执行状态 | Matrix cell execution status</summary>
[JsonConverter(typeof(JsonStringEnumConverter))]
public enum MatrixCellStatus
{
NotExecuted,
Executing,
Completed,
Error,
Disabled
}
// ── 矩阵数据模型 | Matrix Data Models ────────────────────────────
/// <summary>矩阵单元格(不可变)| Matrix cell (immutable)</summary>
public record MatrixCell(
int Row,
int Column,
double OffsetX,
double OffsetY,
bool IsEnabled,
MatrixCellStatus Status,
string ErrorMessage
);
/// <summary>矩阵布局(不可变)| Matrix layout (immutable)</summary>
public record MatrixLayout(
Guid Id,
int Rows,
int Columns,
double RowSpacing,
double ColumnSpacing,
double StartOffsetX,
double StartOffsetY,
string CncProgramPath,
IReadOnlyList<MatrixCell> Cells
);
}
+25
View File
@@ -0,0 +1,25 @@
using System;
namespace XplorePlane.Models
{
// ── 测量数据模型 | Measurement Data Models ────────────────────────
/// <summary>测量记录 | Measurement record</summary>
public class MeasurementRecord
{
public long Id { get; set; }
public string RecipeName { get; set; } = string.Empty;
public int StepIndex { get; set; }
public DateTime Timestamp { get; set; }
public double ResultValue { get; set; }
public bool IsPass { get; set; }
}
/// <summary>测量统计(不可变)| Measurement statistics (immutable)</summary>
public record MeasurementStatistics(
int TotalCount,
int PassCount,
int FailCount,
double PassRate
);
}