添加项目文件。

This commit is contained in:
“hsc”
2026-07-29 13:12:27 +08:00
parent d6da766e2d
commit 8cf45d36b9
297 changed files with 35814 additions and 0 deletions

View File

@@ -0,0 +1,27 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model.Entity
{
public abstract class BaseEntity
{
/// <summary>
/// 主键Id
/// </summary>
[SugarColumn(ColumnName = "id", ColumnDescription = "主键Id", IsPrimaryKey = true, CreateTableFieldSort = 0)]
public virtual long Id { get; set; }
/// <summary>
/// 删除状态
/// </summary>
[SugarColumn(ColumnName = "IsDel", ColumnDescription = "删除状态0、未删除1、已删除", ColumnDataType = "tinyint", DefaultValue = "0", CreateTableFieldSort = 106)]
public virtual byte IsDel { get; set; }
[SugarColumn(ColumnName = "CreateTime")]
public DateTime CreateTime { get; set; }
}
}

View File

@@ -0,0 +1,24 @@
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model.Entity
{
public class MonitorValueEntity:BaseEntity
{
/// <summary>监测项名称</summary>
[SugarColumn(ColumnName = "MonitorName")]
public string MonitorName { get; set; } = string.Empty;
/// <summary>监测值</summary>
[SugarColumn(ColumnName = "MonitorValue")]
public double MonitorValue { get; set; }
/// <summary>作用域标识(台架名称)</summary>
[SugarColumn(ColumnName = "Scope")]
public string Scope { get; set; } = string.Empty;
}
}

View File

@@ -0,0 +1,67 @@
using SqlSugar;
using System;
namespace Model.Entity
{
/// <summary>
/// 测试报告记录:每次 ExecuteSteps / ExecuteErrorSteps 中每个步骤的执行结果。
/// 同一次运行的所有步骤共享同一个 TestRoundId。
/// </summary>
public class TestReportEntity : BaseEntity
{
/// <summary>同一次运行的统一标识StepRunning.TestRoundID</summary>
[SugarColumn(ColumnName = "TestRoundId", ColumnDescription = "运行轮次标识")]
public Guid TestRoundId { get; set; }
/// <summary>作用域/台架名称</summary>
[SugarColumn(ColumnName = "Scope", ColumnDescription = "台架名称")]
public string Scope { get; set; } = string.Empty;
/// <summary>测试项名称当前ACP文件路径</summary>
[SugarColumn(ColumnName = "FileName", ColumnDescription = "测试项名称")]
public string FileName { get; set; } = string.Empty;
/// <summary>步骤序号</summary>
[SugarColumn(ColumnName = "StepIndex")]
public int StepIndex { get; set; }
/// <summary>步骤名称</summary>
[SugarColumn(ColumnName = "StepName", Length = 200)]
public string StepName { get; set; } = string.Empty;
/// <summary>步骤类型(普通步骤/循环开始/循环结束)</summary>
[SugarColumn(ColumnName = "StepType", Length = 50)]
public string StepType { get; set; } = string.Empty;
/// <summary>执行的方法名称</summary>
[SugarColumn(ColumnName = "MethodName", Length = 200, IsNullable = true)]
public string? MethodName { get; set; }
/// <summary>方法的完整类型名(实际方法所属类)</summary>
[SugarColumn(ColumnName = "MethodFullName", Length = 500, IsNullable = true)]
public string? MethodFullName { get; set; }
/// <summary>执行结果(成功/失败/未执行/跳过)</summary>
[SugarColumn(ColumnName = "Result", Length = 20)]
public string Result { get; set; } = string.Empty;
/// <summary>执行耗时(毫秒)</summary>
[SugarColumn(ColumnName = "RunTimeMs", IsNullable = true)]
public int? RunTimeMs { get; set; }
/// <summary>输出值(如果有)</summary>
[SugarColumn(ColumnName = "OutputValue", Length = 500, IsNullable = true)]
public string? OutputValue { get; set; }
/// <summary>子程序嵌套深度0=主程序)</summary>
[SugarColumn(ColumnName = "Depth")]
public int Depth { get; set; }
/// <summary>是否异常流程步骤</summary>
[SugarColumn(ColumnName = "IsErrorStep")]
public bool IsErrorStep { get; set; }
/// <summary>循环剩余次数(仅循环步骤有值)</summary>
[SugarColumn(ColumnName = "LoopRemaining", IsNullable = true)]
public int? LoopRemaining { get; set; }
}
}

14
Model/Model.csproj Normal file
View File

@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SqlSugarCore" Version="5.1.4.215-preview13" />
<PackageReference Include="System.IO.Ports" Version="11.0.0-preview.4.26230.115" />
</ItemGroup>
</Project>

View File

@@ -0,0 +1,23 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace Model.Models
{
/// <summary>
/// 可用设备方法项(供用户选择添加为监测通道)
/// </summary>
public class AvailableMethodItem
{
public string DeviceName { get; set; } = string.Empty;
/// <summary>硬件指纹(物理设备唯一标识)</summary>
public string Fingerprint { get; set; } = string.Empty;
public string MethodName { get; set; } = string.Empty;
public string DisplayName { get; set; } = string.Empty;
public MethodInfo MethodInfo { get; set; } = null!;
public object Device { get; set; } = null!;
}
}

View File

@@ -0,0 +1,24 @@
namespace Model.Models
{
/// <summary>
/// CAN 报文展示纯数据类(对应 UIShare.UIViewModel.CanMessageShowModel
/// </summary>
public class CanMessageShow
{
public byte { get; set; }
public int ID { get; set; }
public ulong { get; set; }
public byte { get; set; }
public bool FD { get; set; }
public bool IsTx { get; set; }
public byte[] Bytes { get; set; } = new byte[64];
public string? { get; set; }
}
}

View File

@@ -0,0 +1,18 @@
namespace Model.Models
{
/// <summary>
/// 设备信息纯数据类(对应 UIShare.UIViewModel.DeviceInfoModel
/// </summary>
public class DeviceInfo
{
public string? DeviceName { get; set; }
public string? DeviceType { get; set; }
public string? Remark { get; set; }
public bool IsEnabled { get; set; }
public bool IsConnected { get; set; }
}
}

View File

@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model.Models
{
public class HardwareReportArgs
{
/// <summary>作用域标识(台架名称)</summary>
public string Scope { get; set; } = string.Empty;
/// <summary>硬件指纹(物理设备唯一标识,如 "Tcp:192.168.1.1:5000"</summary>
public string HardwareFingerprint { get; set; } = string.Empty;
/// <summary>方法名</summary>
public string MethodName { get; set; } = string.Empty;
/// <summary>采样值</summary>
public double Value { get; set; }
/// <summary>采样时间</summary>
public DateTime Time { get; set; } = DateTime.Now;
}
}

View File

@@ -0,0 +1,16 @@
using System.Collections.Generic;
namespace Model.Models
{
/// <summary>
/// 指令节点纯数据类(对应 UIShare.UIViewModel.InstructionNode
/// </summary>
public class InstructionNode
{
public string? Name { get; set; }
public IList<InstructionNode> Children { get; set; } = new List<InstructionNode>();
public object? Tag { get; set; }
}
}

16
Model/Models/Method.cs Normal file
View File

@@ -0,0 +1,16 @@
using System.Collections.Generic;
namespace Model.Models
{
/// <summary>
/// 方法纯数据类(对应 UIShare.UIViewModel.MethodModel
/// </summary>
public class Method
{
public string? Name { get; set; }
public string? FullName { get; set; }
public IList<Parameter> Parameters { get; set; } = new List<Parameter>();
}
}

43
Model/Models/Parameter.cs Normal file
View File

@@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
namespace Model.Models
{
/// <summary>
/// 参数纯数据类(对应 UIShare.UIViewModel.ParameterModel
/// </summary>
public class Parameter
{
public Guid ID { get; set; } = Guid.NewGuid();
public bool IsVisible { get; set; } = true;
public string? Name { get; set; }
/// <summary>
/// 类型全名(对应 ParameterModel.Type 的 FullName
/// </summary>
public string? TypeName { get; set; }
/// <summary>
/// 参数类别Input / Output / Temp
/// </summary>
public string? Category { get; set; }
public object? Value { get; set; }
public object? LowerLimit { get; set; }
public object? UpperLimit { get; set; }
public bool Result { get; set; } = true;
public bool IsUseVar { get; set; }
public string? VariableName { get; set; }
public Guid? VariableID { get; set; }
}
}

19
Model/Models/Program.cs Normal file
View File

@@ -0,0 +1,19 @@
using System;
using System.Collections.Generic;
namespace Model.Models
{
/// <summary>
/// 程序纯数据类(对应 UIShare.UIViewModel.ProgramModel
/// </summary>
public class Program
{
public Guid ID { get; set; } = Guid.NewGuid();
public IList<Step> StepCollection { get; set; } = new List<Step>();
public IList<Step> ErrorStepCollection { get; set; } = new List<Step>();
public IList<Parameter> Parameters { get; set; } = new List<Parameter>();
}
}

View File

@@ -0,0 +1,27 @@
using System.IO.Ports;
namespace Model.Models
{
/// <summary>
/// 串口通信参数DeviceCommand 内部纯数据类,供设备类构造函数使用)。
/// 与 UIShare.UIViewModel.SerialPortConfigVM 字段一一对应,
/// StopBits / Parity 在此处使用 System.IO.Ports 强类型枚举,
/// 由 DeviceManager 从字符串解析后填入。
/// </summary>
public class SerialPortConfig
{
public string PortName { get; set; } = "COM1";
public int BaudRate { get; set; } = 9600;
public int DataBits { get; set; } = 8;
public StopBits StopBits { get; set; } = StopBits.One;
public Parity Parity { get; set; } = Parity.None;
public int ReadTimeout { get; set; } = 3000;
public int WriteTimeout { get; set; } = 3000;
}
}

45
Model/Models/Step.cs Normal file
View File

@@ -0,0 +1,45 @@
using System;
using System.Collections.Generic;
namespace Model.Models
{
/// <summary>
/// 步骤纯数据类(对应 UIShare.UIViewModel.StepModel
/// </summary>
public class Step
{
public Guid ID { get; set; } = Guid.NewGuid();
public bool IsUsed { get; set; } = true;
public int Index { get; set; }
public string? Name { get; set; }
public string? StepType { get; set; }
public Method? Method { get; set; }
public Program? SubProgram { get; set; }
public int? LoopCount { get; set; }
public int? CurrentLoopCount { get; set; }
public Guid? LoopStartStepId { get; set; }
public int Result { get; set; } = -1;
public int? RunTime { get; set; }
public string? OKExpression { get; set; }
public string GotoSettingString { get; set; } = "";
public Guid? OKGotoStepID { get; set; }
public Guid? NGGotoStepID { get; set; }
public string? Description { get; set; }
}
}

View File

@@ -0,0 +1,12 @@
namespace Model.Models
{
/// <summary>
/// 子程序项纯数据类(对应 UIShare.UIViewModel.SubProgramItem
/// </summary>
public class SubProgramItem
{
public string Name { get; set; } = "";
public string FilePath { get; set; } = "";
}
}

17
Model/Models/TcpConfig.cs Normal file
View File

@@ -0,0 +1,17 @@
namespace Model.Models
{
/// <summary>
/// TCP 通信参数DeviceCommand 内部纯数据类,供设备类构造函数使用)。
/// 与 UIShare.UIViewModel.TcpConfigVM 字段一一对应,由 DeviceManager 在实例化时填充。
/// </summary>
public class TcpConfig
{
public string IPAddress { get; set; } = "127.0.0.1";
public int Port { get; set; } = 502;
public int SendTimeout { get; set; } = 3000;
public int ReceiveTimeout { get; set; } = 3000;
}
}

View File

@@ -0,0 +1,17 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model.Models
{
public class TestReportModel
{
public Guid TestRoundId { get; set; }
public string Scope { get; set; }
public DateTime StartTime { get; set; }
public DateTime EndTime { get; set; }
public string FileName { get; set; }
}
}

180
Model/Result.cs Normal file
View File

@@ -0,0 +1,180 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Model
{
public class Result
{
public Result()
{
}
private int _code;
private readonly string _msg;
/// <summary>
/// 结果是否成功
/// </summary>
public bool IsSuccess => _code == 0;
/// <summary>
/// 结果代码
/// </summary>
public int Code { set => _code = value; get => _code; }
/// <summary>
/// 结果消息
/// </summary>
public string Msg => _msg;
/// <summary>
/// 构造方法
/// </summary>
/// <param name="code"></param>
/// <param name="msg"></param>
/// <param name="exception"></param>
protected Result(int code, string msg, Exception? exception = null)
{
if (exception != null)
{
var listMoreMsg = new List<string>();
if (exception is ResultException resultException)
{
listMoreMsg.AddRange(resultException.MessageList);
}
//else if (exception is DeviceControlException deviceControlException)
//{
// listMoreMsg.Add(deviceControlException.ErrorInfo);
//}
else
{
listMoreMsg.Add(exception.Message);
}
var strMoreMsg = string.Join("、", listMoreMsg.Where(it => !string.IsNullOrWhiteSpace(it)));
if (!string.IsNullOrWhiteSpace(strMoreMsg))
{
msg += $"{strMoreMsg}";
}
}
_code = code;
_msg = msg;
}
/// <summary>
/// 返回成功结果
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public static Result Success()
{
return new Result(0, "");
}
/// <summary>
/// 返回错误结果
/// </summary>
/// <param name="msg"></param>
/// <param name="exception"></param>
/// <returns></returns>
public static Result Error(string msg, Exception? exception = null)
{
return new Result(-1, msg, exception);
}
}
public class Result<T> : Result
{
public Result()
{
}
private T? _data;
/// <summary>
/// 结果数据
/// </summary>
public T? Data { set => _data = value; get => _data; }
/// <summary>
/// 构造方法
/// </summary>
/// <param name="code"></param>
/// <param name="msg"></param>
/// <param name="data"></param>
/// <param name="exception"></param>
private Result(int code, string msg, T? data, Exception? exception = null) : base(code, msg, exception)
{
_data = data;
}
/// <summary>
/// 返回成功数据
/// </summary>
/// <param name="data"></param>
/// <returns></returns>
public static Result<T> Success(T data)
{
return new Result<T>(0, "", data);
}
/// <summary>
/// 返回失败信息
/// </summary>
/// <param name="msg"></param>
/// <param name="exception"></param>
/// <returns></returns>
public new static Result<T> Error(string msg, Exception? exception = null)
{
return new Result<T>(-1, msg, default, exception);
}
/// <summary>
/// 返回失败信息和数据
/// </summary>
/// <param name="msg"></param>
/// <param name="data"></param>
/// <param name="exception"></param>
/// <returns></returns>
public static Result<T> Error(string msg, T data, Exception? exception = null)
{
return new Result<T>(-1, msg, data, exception);
}
}
public class ResultException : Exception
{
private List<string>? _messageList;
public List<string> MessageList
{
get
{
List<string> messages = new();
if (_messageList != null)
{
messages.AddRange(_messageList.Where(it => !string.IsNullOrWhiteSpace(it)));
}
return messages;
}
}
public override string Message => string.Join(", ", MessageList);
public ResultException() : base(null)
{
}
public void AddAdditionMessage(string message)
{
_messageList ??= new();
_messageList.Add(message);
}
}
}