✨ feat: 初始化 PCB 检测 WPF 应用程序
* 创建 AxiOmron.PcbCheck 项目主框架及解决方案 * 添加 Dashboard 和系统设置页面 * 实现 Modbus TCP PLC、扫码枪、SFTP 查询等核心服务 * 集成 Andon 报警、工作流托管服务与日志配置 * 补充项目文档和 UI 设计规范
This commit is contained in:
120
src/AxiOmron.PcbCheck/DesignTime/DesignTimeAppConfigService.cs
Normal file
120
src/AxiOmron.PcbCheck/DesignTime/DesignTimeAppConfigService.cs
Normal file
@@ -0,0 +1,120 @@
|
||||
using AxiOmron.PcbCheck.Options;
|
||||
using AxiOmron.PcbCheck.Services.Interfaces;
|
||||
|
||||
namespace AxiOmron.PcbCheck.DesignTime;
|
||||
|
||||
/// <summary>
|
||||
/// 提供设计时配置服务,返回固定的示例配置数据。
|
||||
/// </summary>
|
||||
public sealed class DesignTimeAppConfigService : IAppConfigService
|
||||
{
|
||||
private readonly AppConfig _config;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化设计时配置服务。
|
||||
/// </summary>
|
||||
public DesignTimeAppConfigService()
|
||||
{
|
||||
_config = CreateSampleConfig();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取设计时配置副本。
|
||||
/// </summary>
|
||||
/// <returns>示例根配置对象。</returns>
|
||||
public AppConfig Load()
|
||||
{
|
||||
return CreateSampleConfig();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存设计时配置,占位实现,仅更新内存中的副本。
|
||||
/// </summary>
|
||||
/// <param name="config">待保存的配置对象。</param>
|
||||
/// <exception cref="ArgumentNullException">当 <paramref name="config"/> 为 <see langword="null"/> 时抛出。</exception>
|
||||
public void Save(AppConfig config)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(config);
|
||||
_config.Plc = config.Plc;
|
||||
_config.Scanner = config.Scanner;
|
||||
_config.Sftp = config.Sftp;
|
||||
_config.Andon = config.Andon;
|
||||
_config.Workflow = config.Workflow;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取设计时展示用的示例配置路径。
|
||||
/// </summary>
|
||||
/// <returns>固定的设计时配置路径文本。</returns>
|
||||
public string GetConfigPath()
|
||||
{
|
||||
return @"D:\DesignTime\appConfig.Development.json";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建设计器使用的示例配置对象。
|
||||
/// </summary>
|
||||
/// <returns>填充默认值后的配置对象。</returns>
|
||||
private static AppConfig CreateSampleConfig()
|
||||
{
|
||||
return new AppConfig
|
||||
{
|
||||
Plc = new PlcOptions
|
||||
{
|
||||
Host = "192.168.10.25",
|
||||
Port = 502,
|
||||
UnitId = 1,
|
||||
PollIntervalMs = 200,
|
||||
ConnectTimeoutMs = 3000,
|
||||
HeartbeatIntervalMs = 500,
|
||||
ReleasePulseMs = 450,
|
||||
ReleaseAckTimeoutMs = 2500
|
||||
},
|
||||
Scanner = new ScannerOptions
|
||||
{
|
||||
PortName = "COM3",
|
||||
BaudRate = 9600,
|
||||
DataBits = 8,
|
||||
Parity = "None",
|
||||
StopBits = "One",
|
||||
ReadTimeoutMs = 2500,
|
||||
TriggerCommand = "SCAN\\r",
|
||||
ResponseTerminator = "\\r",
|
||||
MaxScanAttempts = 3
|
||||
},
|
||||
Sftp = new SftpOptions
|
||||
{
|
||||
Host = "10.10.20.35",
|
||||
Port = 22,
|
||||
Username = "pcb_user",
|
||||
Password = "******",
|
||||
PrivateKeyPath = @"C:\Keys\pcb-check.ppk",
|
||||
RootPath = "/data/pcb",
|
||||
FileNamePattern = "${barcode}.txt",
|
||||
RetryIntervalSeconds = 2,
|
||||
MaxRetryCount = 3,
|
||||
ConnectTimeoutMs = 3000
|
||||
},
|
||||
Andon = new AndonOptions
|
||||
{
|
||||
Enable = true,
|
||||
Url = "http://10.10.20.50/api/andon/alarm",
|
||||
Method = "POST",
|
||||
TimeoutMs = 3000,
|
||||
StationCode = "OMRON-L01",
|
||||
StationName = "欧姆龙 PCB 检测",
|
||||
EnableScanFailAlarm = true,
|
||||
EnableFileNotFoundAlarm = true
|
||||
},
|
||||
Workflow = new WorkflowOptions
|
||||
{
|
||||
RequirePlcReady = true,
|
||||
RequireAutoMode = true,
|
||||
RequireStationEnable = true,
|
||||
RequireManualResetAfterFault = true,
|
||||
MaxUiLogEntries = 200,
|
||||
MaxBoardRecords = 100
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user