* 新增管理员解锁弹窗、手动操作权限控制与倒计时状态 * 支持系统设置页测试 SFTP 连接,并在启动时执行探活 * 补充设计时服务、全局异常兜底与相关单元测试
129 lines
4.1 KiB
C#
129 lines
4.1 KiB
C#
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;
|
|
_config.Security = config.Security;
|
|
}
|
|
|
|
/// <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 = "https://shp.prod.aliyun.mit.uaes.com/api/mit/MAE/Station/Status/alarm",
|
|
Method = "POST",
|
|
TimeoutMs = 3000,
|
|
AndonTheme = "SS7_Auto_Andon",
|
|
Eid = "PR1965269806334783488",
|
|
FromSign = "IOT",
|
|
ServiceId = "4dccd822-86b2-47dd-89bd-ca472ba0d14d",
|
|
EnableScanFailAlarm = true,
|
|
EnableFileNotFoundAlarm = true
|
|
},
|
|
Workflow = new WorkflowOptions
|
|
{
|
|
RequirePlcReady = true,
|
|
RequireAutoMode = true,
|
|
RequireStationEnable = true,
|
|
RequireManualResetAfterFault = true,
|
|
MaxUiLogEntries = 200,
|
|
MaxBoardRecords = 100
|
|
},
|
|
Security = new SecurityOptions
|
|
{
|
|
AdminPassword = "AxiOmron@123",
|
|
AdminSessionTimeoutMinutes = 15
|
|
}
|
|
};
|
|
}
|
|
}
|