将Feature/XP.Common和Feature/XP.Hardware分支合并至Develop/XP.forHardwareAndCommon,完善XPapp注册和相关硬件类库通用类库功能。
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
using System;
|
||||
|
||||
namespace XP.Hardware.RaySource.Abstractions
|
||||
{
|
||||
/// <summary>
|
||||
/// 射线源抽象基类 | Abstract Base Class for X-Ray Sources
|
||||
/// 提供策略接口的基础实现框架 | Provides foundational implementation framework for strategy interface
|
||||
/// </summary>
|
||||
public abstract class XRaySourceBase : IXRaySource
|
||||
{
|
||||
protected bool _isDisposed = false;
|
||||
protected bool _isInitialized = false;
|
||||
protected bool _isConnected = false;
|
||||
|
||||
/// <summary>
|
||||
/// 射线源名称(用于日志)| X-ray source name (for logging)
|
||||
/// </summary>
|
||||
public virtual string SourceName => "Generic X-Ray Source";
|
||||
|
||||
/// <summary>
|
||||
/// 是否已连接 | Is connected
|
||||
/// </summary>
|
||||
public virtual bool IsConnected => _isConnected && _isInitialized;
|
||||
|
||||
#region IXRaySource Implementation
|
||||
public abstract XRayResult Initialize();
|
||||
public abstract XRayResult ConnectVariables();
|
||||
public abstract XRayResult TurnOn();
|
||||
public abstract XRayResult TurnOff();
|
||||
public abstract XRayResult CloseOff();
|
||||
public abstract XRayResult SetVoltage(float voltage);
|
||||
public abstract XRayResult SetCurrent(float current);
|
||||
public abstract XRayResult SetFocus(float focus);
|
||||
public abstract XRayResult ReadVoltage();
|
||||
public abstract XRayResult ReadCurrent();
|
||||
public abstract XRayResult ReadSystemStatus();
|
||||
public abstract XRayResult CheckErrors();
|
||||
public abstract XRayResult TxiOn();
|
||||
public abstract XRayResult TxiOff();
|
||||
public abstract XRayResult WarmUp();
|
||||
public abstract XRayResult Training();
|
||||
public abstract XRayResult FilamentCalibration();
|
||||
public abstract XRayResult AutoCenter();
|
||||
public abstract XRayResult SetPowerMode(int mode);
|
||||
#endregion
|
||||
|
||||
#region IDisposable Implementation
|
||||
/// <summary>
|
||||
/// 释放资源 | Release resources
|
||||
/// </summary>
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 受保护的释放方法 | Protected dispose method
|
||||
/// </summary>
|
||||
/// <param name="disposing">是否由用户代码调用 | Whether called from user code</param>
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!_isDisposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// 释放托管资源 | Release managed resources
|
||||
try
|
||||
{
|
||||
// 尝试安全关闭 | Attempt safe shutdown
|
||||
if (_isInitialized)
|
||||
{
|
||||
CloseOff();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine(
|
||||
$"[射线源关闭异常 | X-Ray Source Close Exception] {SourceName}: {ex.Message}");
|
||||
}
|
||||
}
|
||||
_isDisposed = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 析构函数(作为安全网)| Finalizer (as safety net)
|
||||
/// </summary>
|
||||
~XRaySourceBase()
|
||||
{
|
||||
Dispose(false);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user