规范类名及命名空间名称

This commit is contained in:
李伟
2026-04-13 14:35:37 +08:00
parent c430ec229b
commit ace1c70ddf
217 changed files with 1271 additions and 1384 deletions
@@ -1,8 +1,8 @@
using Prism.Mvvm;
using System;
using System.Threading;
using System.Windows;
using System.Windows.Threading;
using Prism.Mvvm;
using XP.Common.Logging.Interfaces;
using XP.Hardware.RaySource.Services;
using XplorePlane.Models;
@@ -23,6 +23,7 @@ namespace XplorePlane.Services.AppState
// ── 状态字段(通过 Interlocked.Exchange 原子替换)──
private MotionState _motionState = MotionState.Default;
private RaySourceState _raySourceState = RaySourceState.Default;
private DetectorState _detectorState = DetectorState.Default;
private SystemState _systemState = SystemState.Default;
@@ -33,16 +34,24 @@ namespace XplorePlane.Services.AppState
// ── 类型化状态变更事件 ──
public event EventHandler<StateChangedEventArgs<MotionState>> MotionStateChanged;
public event EventHandler<StateChangedEventArgs<RaySourceState>> RaySourceStateChanged;
public event EventHandler<StateChangedEventArgs<DetectorState>> DetectorStateChanged;
public event EventHandler<StateChangedEventArgs<SystemState>> SystemStateChanged;
public event EventHandler<StateChangedEventArgs<CameraState>> CameraStateChanged;
public event EventHandler<StateChangedEventArgs<LinkedViewState>> LinkedViewStateChanged;
public event EventHandler<StateChangedEventArgs<RecipeExecutionState>> RecipeExecutionStateChanged;
public event EventHandler<LinkedViewRequestEventArgs> LinkedViewRequested;
// ── 状态属性(只读)──
public MotionState MotionState => _motionState;
public RaySourceState RaySourceState => _raySourceState;
public DetectorState DetectorState => _detectorState;
public SystemState SystemState => _systemState;
@@ -226,4 +235,4 @@ namespace XplorePlane.Services.AppState
_logger.Info("AppStateService 已释放");
}
}
}
}
@@ -24,12 +24,19 @@ namespace XplorePlane.Services.AppState
// ── 状态更新方法(线程安全,可从任意线程调用)──
void UpdateMotionState(MotionState newState);
void UpdateRaySourceState(RaySourceState newState);
void UpdateDetectorState(DetectorState newState);
void UpdateSystemState(SystemState newState);
void UpdateCameraState(CameraState newState);
void UpdateCalibrationMatrix(CalibrationMatrix newMatrix);
void UpdateLinkedViewState(LinkedViewState newState);
void UpdateRecipeExecutionState(RecipeExecutionState newState);
// ── 画面联动 ──
@@ -40,15 +47,21 @@ namespace XplorePlane.Services.AppState
// ── 类型化状态变更事件 ──
event EventHandler<StateChangedEventArgs<MotionState>> MotionStateChanged;
event EventHandler<StateChangedEventArgs<RaySourceState>> RaySourceStateChanged;
event EventHandler<StateChangedEventArgs<DetectorState>> DetectorStateChanged;
event EventHandler<StateChangedEventArgs<SystemState>> SystemStateChanged;
event EventHandler<StateChangedEventArgs<CameraState>> CameraStateChanged;
event EventHandler<StateChangedEventArgs<LinkedViewState>> LinkedViewStateChanged;
event EventHandler<StateChangedEventArgs<RecipeExecutionState>> RecipeExecutionStateChanged;
// ── 画面联动请求事件 ──
event EventHandler<LinkedViewRequestEventArgs> LinkedViewRequested;
}
}
}
@@ -29,4 +29,4 @@ namespace XplorePlane.Services.AppState
TargetZ = targetZ;
}
}
}
}
+11 -1
View File
@@ -28,6 +28,7 @@ namespace XplorePlane.Services.Camera
public bool IsLiveView => _liveViewRunning;
public event EventHandler<BitmapSource> FrameArrived;
public event EventHandler ConnectionLost;
public CameraService(
@@ -109,14 +110,23 @@ namespace XplorePlane.Services.Camera
// ── 参数读写(直接委托给 controller)──
public double GetExposureTime() => _controller.GetExposureTime();
public void SetExposureTime(double microseconds) => _controller.SetExposureTime(microseconds);
public double GetGain() => _controller.GetGain();
public void SetGain(double value) => _controller.SetGain(value);
public int GetWidth() => _controller.GetWidth();
public void SetWidth(int value) => _controller.SetWidth(value);
public int GetHeight() => _controller.GetHeight();
public void SetHeight(int value) => _controller.SetHeight(value);
public string GetPixelFormat() => _controller.GetPixelFormat();
public void SetPixelFormat(string format) => _controller.SetPixelFormat(format);
// ── 事件处理 ──
@@ -191,4 +201,4 @@ namespace XplorePlane.Services.Camera
_logger.Info("CameraService 已释放");
}
}
}
}
+10 -1
View File
@@ -36,14 +36,23 @@ namespace XplorePlane.Services.Camera
// ── 参数读写 ──
double GetExposureTime();
void SetExposureTime(double microseconds);
double GetGain();
void SetGain(double value);
int GetWidth();
void SetWidth(int value);
int GetHeight();
void SetHeight(int value);
string GetPixelFormat();
void SetPixelFormat(string format);
/// <summary>最新一帧图像(已 Freeze,可跨线程)。</summary>
@@ -52,4 +61,4 @@ namespace XplorePlane.Services.Camera
/// <summary>相机连接断开事件。</summary>
event EventHandler ConnectionLost;
}
}
}
@@ -383,4 +383,4 @@ namespace XplorePlane.Services.Cnc
MotionState: _appStateService.MotionState);
}
}
}
}
@@ -36,4 +36,4 @@ namespace XplorePlane.Services.Cnc
/// <summary>从 JSON 字符串反序列化 CNC 程序 | Deserialize CNC program from JSON string</summary>
CncProgram Deserialize(string json);
}
}
}
@@ -3,16 +3,20 @@ using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
using ImageProcessing.Core;
using XP.ImageProcessing.Core;
namespace XplorePlane.Services
{
public interface IImageProcessingService : IDisposable
{
IReadOnlyList<string> GetAvailableProcessors();
IReadOnlyList<ProcessorParameter> GetProcessorParameters(string processorName);
ImageProcessorBase GetProcessor(string processorName);
string GetProcessorDisplayName(string processorName);
void RegisterProcessor(string name, ImageProcessorBase processor);
Task<BitmapSource> ProcessImageAsync(
@@ -21,6 +25,5 @@ namespace XplorePlane.Services
IDictionary<string, object> parameters,
IProgress<double> progress = null,
CancellationToken cancellationToken = default);
}
}
}
@@ -1,10 +1,8 @@
using System;
using System.Runtime.InteropServices;
using System.Windows;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using Emgu.CV;
using Emgu.CV.Structure;
using System;
using System.Windows.Media;
using System.Windows.Media.Imaging;
namespace XplorePlane.Services
{
@@ -57,6 +55,5 @@ namespace XplorePlane.Services
return BitmapSource.Create(width, height, 96, 96, PixelFormats.Gray8, null, pixels, stride);
}
}
}
}
@@ -4,7 +4,12 @@ namespace XplorePlane.Services
{
public class ImageProcessingException : Exception
{
public ImageProcessingException(string message) : base(message) { }
public ImageProcessingException(string message, Exception innerException) : base(message, innerException) { }
public ImageProcessingException(string message) : base(message)
{
}
public ImageProcessingException(string message, Exception innerException) : base(message, innerException)
{
}
}
}
}
@@ -4,11 +4,9 @@ using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
using Emgu.CV;
using Emgu.CV.Structure;
using ImageProcessing.Core;
using ImageProcessing.Processors;
using XP.Common.Logging.Interfaces;
using XP.ImageProcessing.Core;
using XP.ImageProcessing.Processors;
namespace XplorePlane.Services
{
@@ -134,7 +132,6 @@ namespace XplorePlane.Services
disposable.Dispose();
}
_processorRegistry.Clear();
}
}
}
@@ -1,5 +1,5 @@
using System;
using Serilog;
using System;
using XP.Common.Logging.Interfaces;
namespace XplorePlane.Services
@@ -136,4 +136,4 @@ namespace XplorePlane.Services
GetLogger().Fatal(exception, messageTemplate, propertyValues);
}
}
}
}
@@ -36,4 +36,4 @@ namespace XplorePlane.Services.Matrix
/// <summary>从 JSON 字符串反序列化矩阵布局 | Deserialize matrix layout from JSON string</summary>
MatrixLayout Deserialize(string json);
}
}
}
+1 -1
View File
@@ -277,4 +277,4 @@ namespace XplorePlane.Services.Matrix
$"列索引超出范围 | Column index out of range: {column}, Columns={layout.Columns}");
}
}
}
}
@@ -23,4 +23,4 @@ namespace XplorePlane.Services.Measurement
/// <summary>按配方名称和时间范围获取统计数据 | Get statistics by recipe name and time range</summary>
Task<MeasurementStatistics> GetStatisticsAsync(string recipeName, DateTime? from, DateTime? to);
}
}
}
@@ -74,11 +74,11 @@ VALUES (@recipe_name, @step_index, @timestamp, @result_value, @is_pass)";
var parameters = new Dictionary<string, object>
{
["@recipe_name"] = record.RecipeName,
["@step_index"] = record.StepIndex,
["@timestamp"] = record.Timestamp.ToString("o"), // ISO 8601 往返格式 | ISO 8601 round-trip format
["@recipe_name"] = record.RecipeName,
["@step_index"] = record.StepIndex,
["@timestamp"] = record.Timestamp.ToString("o"), // ISO 8601 往返格式 | ISO 8601 round-trip format
["@result_value"] = record.ResultValue,
["@is_pass"] = record.IsPass ? 1 : 0
["@is_pass"] = record.IsPass ? 1 : 0
};
var result = await _db.ExecuteNonQueryAsync(InsertSql, parameters).ConfigureAwait(false);
@@ -147,8 +147,8 @@ VALUES (@recipe_name, @step_index, @timestamp, @result_value, @is_pass)";
var row = data[0];
int total = row.total_count;
int pass = row.pass_count;
int fail = total - pass;
int pass = row.pass_count;
int fail = total - pass;
double passRate = total > 0 ? (double)pass / total : 0.0;
_logger.Debug("统计结果 | Statistics: Total={Total}, Pass={Pass}, Fail={Fail}, PassRate={PassRate:P2}",
@@ -220,12 +220,12 @@ VALUES (@recipe_name, @step_index, @timestamp, @result_value, @is_pass)";
{
return new MeasurementRecord
{
Id = row.id,
RecipeName = row.recipe_name,
StepIndex = row.step_index,
Timestamp = DateTime.Parse(row.timestamp, null, System.Globalization.DateTimeStyles.RoundtripKind),
Id = row.id,
RecipeName = row.recipe_name,
StepIndex = row.step_index,
Timestamp = DateTime.Parse(row.timestamp, null, System.Globalization.DateTimeStyles.RoundtripKind),
ResultValue = row.result_value,
IsPass = row.is_pass != 0
IsPass = row.is_pass != 0
};
}
@@ -249,4 +249,4 @@ VALUES (@recipe_name, @step_index, @timestamp, @result_value, @is_pass)";
public int pass_count { get; set; }
}
}
}
}
@@ -17,4 +17,4 @@ namespace XplorePlane.Services
IProgress<PipelineProgress> progress = null,
CancellationToken cancellationToken = default);
}
}
}
@@ -7,7 +7,9 @@ namespace XplorePlane.Services
public interface IPipelinePersistenceService
{
Task SaveAsync(PipelineModel pipeline, string filePath);
Task<PipelineModel> LoadAsync(string filePath);
Task<IReadOnlyList<PipelineModel>> LoadAllAsync(string directory);
}
}
}
@@ -21,4 +21,4 @@ namespace XplorePlane.Services
FailedOperatorKey = failedOperatorKey;
}
}
}
}
@@ -98,4 +98,4 @@ namespace XplorePlane.Services
return scaled;
}
}
}
}
@@ -108,4 +108,4 @@ namespace XplorePlane.Services
throw new UnauthorizedAccessException($"不允许路径遍历:{directory}");
}
}
}
}
@@ -28,4 +28,4 @@ namespace XplorePlane.Services.Recipe
/// <summary>恢复已暂停的配方执行</summary>
void Resume();
}
}
}
+1 -1
View File
@@ -277,4 +277,4 @@ namespace XplorePlane.Services.Recipe
await Task.CompletedTask;
}
}
}
}