添加 MX-PD-盘古 项目文件

将 MX-PD-盘古 - new 目录下的所有文件添加到主仓库
This commit is contained in:
Shi.Ji
2026-05-18 11:43:09 +08:00
parent 03632a379d
commit e31d3560bb
739 changed files with 99783 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
using MainShell.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MainShell.Recipe.BaseBoard.Model
{
public class Pad
{
public int Row { get; set; }
public int Column { get; set; }
public double X { get; set; }
public double Y { get; set; }
}
}

View File

@@ -0,0 +1,23 @@
using Stylet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MainShell.Models
{
public class BaseScreen : Screen
{
private bool _hideRecipePanel;
/// <summary>
/// 控制配方列表面板的显隐true=隐藏false=显示
/// </summary>
public bool HideRecipePanel
{
get => _hideRecipePanel;
set => SetAndNotify(ref _hideRecipePanel, value);
}
}
}

View File

@@ -0,0 +1,30 @@
using MwFramework.ManagerService;
using Stylet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MainShell.Models
{
public class CameraConfig : PropertyChangedBase, IParameterItem
{
private int _exposureTime;
public int ExposureTime
{
get { return _exposureTime; }
set { SetAndNotify(ref _exposureTime, value); }
}
private int _gain;
public int Gain
{
get { return _gain; }
set { SetAndNotify(ref _gain, value); }
}
public IParameterItem Clone()
{
return this.MemberwiseClone() as IParameterItem;
}
}
}

View File

@@ -0,0 +1,181 @@
using MainShell.Recipe.Models;
using MainShell.Recipe.Models.SubstrateParameter;
using MaxwellFramework.Core.Attributes;
using System;
using System.Linq;
namespace MainShell.Models
{
[Singleton]
public sealed class CurrentSubstrateTheoryCoordinateProvider
{
private readonly RecipeManager _recipeManager;
public CurrentSubstrateTheoryCoordinateProvider(RecipeManager recipeManager)
{
_recipeManager = recipeManager ?? throw new ArgumentNullException(nameof(recipeManager));
}
public SubstratePoint GetCoordinate(int row, int column)
{
SubstratePoint substratePoint;
if (!TryGetCoordinate(row, column, out substratePoint))
{
throw new InvalidOperationException(
$"Current substrate theory coordinate was not found for row {row}, column {column}.");
}
return substratePoint;
}
public SubstratePoint[,] GetCoordinateArray()
{
SubstratePoint[,] substratePoints;
if (!TryGetCoordinateArray(out substratePoints))
{
throw new InvalidOperationException("Current substrate theory coordinate array was not found.");
}
return substratePoints;
}
public bool TryGetCoordinate(int row, int column, out SubstratePoint substratePoint)
{
substratePoint = default(SubstratePoint);
if (row <= 0 || column <= 0)
{
return false;
}
SubstrateRecipe currentSubstrateRecipe = _recipeManager.CurrentSubstrateRecipe;
if (currentSubstrateRecipe == null)
{
return false;
}
MarkCoordinatePoint theoryPoint = GetTheoryPoint(currentSubstrateRecipe, row, column);
if (theoryPoint == null)
{
return false;
}
double offsetX;
double offsetY;
GetCoordinateOffsets(currentSubstrateRecipe, out offsetX, out offsetY);
substratePoint = CreateSubstratePoint(theoryPoint, offsetX, offsetY);
return true;
}
public bool TryGetCoordinateArray(out SubstratePoint[,] substratePoints)
{
substratePoints = null;
SubstrateRecipe currentSubstrateRecipe = _recipeManager.CurrentSubstrateRecipe;
if (currentSubstrateRecipe == null)
{
return false;
}
MarkCoordinateGenerationState coordinateGenerationState = GetCoordinateGenerationState(currentSubstrateRecipe);
if (coordinateGenerationState == null ||
coordinateGenerationState.Rows <= 0 ||
coordinateGenerationState.Cols <= 0)
{
return false;
}
double offsetX;
double offsetY;
GetCoordinateOffsets(currentSubstrateRecipe, out offsetX, out offsetY);
SubstratePoint[,] currentSubstratePoints = new SubstratePoint[coordinateGenerationState.Rows, coordinateGenerationState.Cols];
for (int row = 1; row <= coordinateGenerationState.Rows; row++)
{
for (int column = 1; column <= coordinateGenerationState.Cols; column++)
{
MarkCoordinatePoint theoryPoint = GetTheoryPoint(currentSubstrateRecipe, row, column);
if (theoryPoint == null)
{
return false;
}
currentSubstratePoints[row - 1, column - 1] = CreateSubstratePoint(theoryPoint, offsetX, offsetY);
}
}
substratePoints = currentSubstratePoints;
return true;
}
private static MarkCoordinatePoint GetTheoryPoint(SubstrateRecipe currentSubstrateRecipe, int row, int column)
{
MarkCoordinateGenerationState coordinateGenerationState = GetCoordinateGenerationState(currentSubstrateRecipe);
if (coordinateGenerationState == null || coordinateGenerationState.Points == null)
{
return null;
}
return coordinateGenerationState.Points
.FirstOrDefault(point => point != null && point.Row == row && point.Col == column);
}
private static MarkCoordinateGenerationState GetCoordinateGenerationState(SubstrateRecipe currentSubstrateRecipe)
{
if (currentSubstrateRecipe == null || currentSubstrateRecipe.SubtrateMarkParameterInfo == null)
{
return null;
}
return currentSubstrateRecipe.SubtrateMarkParameterInfo.CoordinateGenerationState;
}
private static SubstratePoint CreateSubstratePoint(MarkCoordinatePoint theoryPoint, double offsetX, double offsetY)
{
return new SubstratePoint(
theoryPoint.TheoryX + offsetX,
theoryPoint.TheoryY + offsetY);
}
private void GetCoordinateOffsets(SubstrateRecipe currentSubstrateRecipe, out double offsetX, out double offsetY)
{
WaferSelectInfo currentWaferSelectInfo = GetCurrentWaferSelectInfo(currentSubstrateRecipe);
offsetX = currentWaferSelectInfo != null ? currentWaferSelectInfo.OffsetX : 0d;
offsetY = currentWaferSelectInfo != null ? currentWaferSelectInfo.OffsetY : 0d;
}
private WaferSelectInfo GetCurrentWaferSelectInfo(SubstrateRecipe currentSubstrateRecipe)
{
if (currentSubstrateRecipe.WaferSelectInfos == null || currentSubstrateRecipe.WaferSelectInfos.Count == 0)
{
return null;
}
string currentWaferRecipeName = _recipeManager.CurrentWaferRecipe != null
? _recipeManager.CurrentWaferRecipe.RecipeName
: null;
if (!string.IsNullOrWhiteSpace(currentWaferRecipeName))
{
WaferSelectInfo matchedWaferSelectInfo = currentSubstrateRecipe.WaferSelectInfos
.FirstOrDefault(info =>
info != null &&
string.Equals(info.WaferRecipeName, currentWaferRecipeName, StringComparison.Ordinal));
if (matchedWaferSelectInfo != null)
{
return matchedWaferSelectInfo;
}
}
WaferSelectInfo inUseWaferSelectInfo = currentSubstrateRecipe.WaferSelectInfos
.FirstOrDefault(info => info != null && info.IsUse);
if (inUseWaferSelectInfo != null)
{
return inUseWaferSelectInfo;
}
return currentSubstrateRecipe.WaferSelectInfos
.FirstOrDefault(info => info != null && !string.IsNullOrWhiteSpace(info.WaferRecipeName));
}
}
}

View File

@@ -0,0 +1,83 @@
using Stylet;
namespace MainShell.Models
{
public class DieStatisticsModel : PropertyChangedBase
{
private int _totalDieCount;
public int TotalDieCount
{
get => _totalDieCount;
set
{
if (SetAndNotify(ref _totalDieCount, value))
{
UpdatePassRate();
}
}
}
private int _okDieCount;
public int OkDieCount
{
get => _okDieCount;
set
{
if (SetAndNotify(ref _okDieCount, value))
{
UpdatePassRate();
}
}
}
private double _passRate;
public double PassRate
{
get => _passRate;
private set => SetAndNotify(ref _passRate, value);
}
private void UpdatePassRate()
{
if (TotalDieCount > 0)
{
PassRate = (double)OkDieCount / TotalDieCount * 100;
}
else
{
PassRate = 0;
}
}
private int _ngDieCount;
public int NgDieCount
{
get => _ngDieCount;
set => SetAndNotify(ref _ngDieCount, value);
}
private double _averageSpacingX;
public double AverageSpacingX
{
get => _averageSpacingX;
set => SetAndNotify(ref _averageSpacingX, value);
}
private double _averageSpacingY;
public double AverageSpacingY
{
get => _averageSpacingY;
set => SetAndNotify(ref _averageSpacingY, value);
}
public void Reset()
{
TotalDieCount = 0;
OkDieCount = 0;
NgDieCount = 0;
AverageSpacingX = 0;
AverageSpacingY = 0;
PassRate = 0;
}
}
}

View File

@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MainShell.Models
{
public interface IGridItem
{
/// <summary>
/// 网格行索引(可用于行列映射)
/// </summary>
int Row { get; set; }
/// <summary>
/// 网格列索引(可用于行列映射)
/// </summary>
int Column { get; set; }
}
}

View File

@@ -0,0 +1,49 @@
using MainShell.Models.LightConfig;
using MwFramework.ManagerService;
using Stylet;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MainShell.Models
{
public class DownCamLightConfig : PropertyChangedBase, IParameterItem , ILightConfig
{
private int _pointRedLight;
[Description("点红光")]
public int PointRedLight
{
get { return _pointRedLight; }
set { SetAndNotify(ref _pointRedLight, value); }
}
private int _ringRedLight;
[Description("环红光")]
public int RingRedLight
{
get { return _ringRedLight; }
set { SetAndNotify(ref _ringRedLight, value); }
}
private int _pointBlueLight;
[Description("点蓝光")]
public int PointBlueLight
{
get { return _pointBlueLight; }
set { SetAndNotify(ref _pointBlueLight, value); }
}
private int _ringBlueLight;
[Description("环蓝光")]
public int RingBlueLight
{
get { return _ringBlueLight; }
set { SetAndNotify(ref _ringBlueLight, value); }
}
public IParameterItem Clone()
{
return this.MemberwiseClone() as IParameterItem;
}
}
}

View File

@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MainShell.Models.LightConfig
{
public interface ILightConfig
{
}
}

View File

@@ -0,0 +1,34 @@
using MainShell.Models.LightConfig;
using MwFramework.ManagerService;
using Stylet;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MainShell.Models
{
public class MapCamLightConfig : PropertyChangedBase, IParameterItem , ILightConfig
{
private int _redLight;
[Description("红光")]
public int RedLight
{
get { return _redLight; }
set { SetAndNotify(ref _redLight, value); }
}
private int _blueLight;
[Description("蓝光")]
public int BlueLight
{
get { return _blueLight; }
set { SetAndNotify(ref _blueLight, value); }
}
public IParameterItem Clone()
{
throw new NotImplementedException();
}
}
}

View File

@@ -0,0 +1,56 @@
using MainShell.Models.LightConfig;
using MwFramework.ManagerService;
using Stylet;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MainShell.Models
{
public class UpCamLightConfig : PropertyChangedBase, IParameterItem , ILightConfig
{
private int _pointRedLight;
[Description("点红光")]
public int PointRedLight
{
get { return _pointRedLight; }
set { SetAndNotify(ref _pointRedLight, value); }
}
private int _ringRedLight;
[Description("环红光")]
public int RingRedLight
{
get { return _ringRedLight; }
set { SetAndNotify(ref _ringRedLight, value); }
}
private int _pointBlueLight;
[Description("点蓝光")]
public int PointBlueLight
{
get { return _pointBlueLight; }
set { SetAndNotify(ref _pointBlueLight, value); }
}
private int _ringBlueLight;
[Description("环蓝光")]
public int RingBlueLight
{
get { return _ringBlueLight; }
set { SetAndNotify(ref _ringBlueLight, value); }
}
private int _redBackLight;
[Description("红背光")]
public int RedBackLight
{
get { return _redBackLight; }
set { SetAndNotify(ref _redBackLight, value); }
}
public IParameterItem Clone()
{
return this.MemberwiseClone() as IParameterItem;
}
}
}

View File

@@ -0,0 +1,41 @@
using Stylet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MainShell.Models
{
public class MPoint : PropertyChangedBase
{
private double _x;
public double X
{
get { return _x; }
set { SetAndNotify(ref _x, value); }
}
private double _y;
public double Y
{
get { return _y; }
set { SetAndNotify(ref _y, value); }
}
public MPoint() { }
public MPoint(double x, double y)
{
_x = x;
_y = y;
}
public override string ToString() => $"({X}, {Y})";
public MPoint Clone()
{
return new MPoint(X, Y);
}
}
}

View File

@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MainShell.Models
{
public class MeasureMPoint : MPoint
{
private double _z1;
public double Z1
{
get { return _z1; }
set { SetAndNotify(ref _z1, value); }
}
private double _measureZ;
public double MeasureZ
{
get { return _measureZ; }
set { SetAndNotify(ref _measureZ, value); }
}
public MeasureMPoint() : base() { }
public MeasureMPoint(double x, double y, double z1, double measureZ) : base(x, y)
{
_z1 = z1;
_measureZ = measureZ;
}
public override string ToString() => $"({X}, {Y}, {Z1}, {MeasureZ})";
}
}

View File

@@ -0,0 +1,29 @@
using Stylet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MainShell.Models
{
public class MenuItemWrap : PropertyChangedBase
{
private string _header;
public string Header
{
get { return _header; }
set { SetAndNotify(ref _header, value); }
}
private object _tag;
public object Tag
{
get { return _tag; }
set { SetAndNotify(ref _tag, value); }
}
}
}

View File

@@ -0,0 +1,71 @@
using Maxwell.SemiFramework.DefaultConfig.Vision;
using MwFramework.Device.Model;
using SemiconductorVisionAlgorithm.SemiParams;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace MainShell.Models
{
public sealed class MxImage : IDisposable
{
private readonly Camera _image = null;
public Camera Image => _image;
public MxImage(Camera image)
{
_image = image;
}
public MxImage(CameraData cameraData)
{
_image = new Camera
{
Ptr = ImageHelper.GetImageHandle(cameraData),
Height = (int)cameraData.Height,
Width = (int)cameraData.Width,
Type = "byte"
};
}
private bool disposedValue;
private void Dispose(bool disposing)
{
if (!disposedValue)
{
if (disposing)
{
// TODO: 释放托管状态(托管对象)
}
// TODO: 释放未托管的资源(未托管的对象)并重写终结器
// TODO: 将大型字段设置为 null
if (_image.Ptr != null)
{
Marshal.FreeHGlobal(_image.Ptr);
_image.Ptr = IntPtr.Zero;
}
disposedValue = true;
}
}
// // TODO: 仅当“Dispose(bool disposing)”拥有用于释放未托管资源的代码时才替代终结器
// ~MxImage()
// {
// // 不要更改此代码。请将清理代码放入“Dispose(bool disposing)”方法中
// Dispose(disposing: false);
// }
public void Dispose()
{
// 不要更改此代码。请将清理代码放入“Dispose(bool disposing)”方法中
Dispose(disposing: true);
GC.SuppressFinalize(this);
}
}
}

View File

@@ -0,0 +1,27 @@
using Stylet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MainShell.Models
{
public class MxSize : PropertyChangedBase
{
private double _width;
public double Width
{
get { return _width; }
set { _width = value; }
}
private double _height;
public double Height
{
get { return _height; }
set { SetAndNotify(ref _height, value); }
}
}
}

View File

@@ -0,0 +1,51 @@
using MwFramework.ManagerService;
using Stylet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MainShell.Models
{
public class RegionModel : PropertyChangedBase , IParameterItem
{
private int _startRow = 1;
private int _startCol = 1;
private int _endRow = 1;
private int _endCol = 1;
public int StartRow
{
get => _startRow;
set { if (SetAndNotify(ref _startRow, value)) OnPropertyChanged(nameof(RowCount)); }
}
public int StartCol
{
get => _startCol;
set { if (SetAndNotify(ref _startCol, value)) OnPropertyChanged(nameof(ColCount)); }
}
public int EndRow
{
get => _endRow;
set { if (SetAndNotify(ref _endRow, Math.Max(_startRow, value))) OnPropertyChanged(nameof(RowCount)); }
}
public int EndCol
{
get => _endCol;
set { if (SetAndNotify(ref _endCol, Math.Max(_startCol, value))) OnPropertyChanged(nameof(ColCount)); }
}
// 只读属性,方便 UI 显示占用规模
public int RowCount => EndRow - StartRow + 1;
public int ColCount => EndCol - StartCol + 1;
public IParameterItem Clone()
{
return MemberwiseClone() as IParameterItem;
}
}
}

View File

@@ -0,0 +1,16 @@
using MaxwellFramework.Core.Attributes;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MainShell.Models.RunTime
{
[Singleton]
public class BaseBoardRunTime
{
}
}

View File

@@ -0,0 +1,53 @@
using MainShell.Common;
using MaxwellFramework.Core.Attributes;
using Stylet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MainShell
{
[Singleton]
public class MachineState : PropertyChangedBase
{
private readonly object _sync = new object();
private MachineMode _currentMode = MachineMode.Manual;
private bool _isExiting = false;
public MachineMode CurrentMode
{
get { lock (_sync) { return _currentMode; } }
set
{
bool changed;
lock (_sync)
{
changed = _currentMode != value;
_currentMode = value;
}
// 在锁外触发通知,避免死锁
if (changed)
NotifyOfPropertyChange(nameof(CurrentMode));
}
}
public bool IsExiting
{
get { lock (_sync) { return _isExiting; } }
set
{
bool changed;
lock (_sync)
{
changed = _isExiting != value;
_isExiting = value;
}
if (changed)
NotifyOfPropertyChange(nameof(IsExiting));
}
}
}
}

View File

@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MainShell.Models
{
public struct SubstratePoint
{
public double X { get; set; }
public double Y { get; set; }
public SubstratePoint(double x, double y)
{
X = x;
Y = y;
}
}
}

View File

@@ -0,0 +1,60 @@
using Stylet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media;
namespace MainShell.Models
{
public class ToolNavItem : PropertyChangedBase
{
private string _title;
public string Title
{
get => _title;
set
{
SetAndNotify(ref _title, value);
}
}
private string _subtitle;
public string Subtitle
{
get => _subtitle;
set
{
SetAndNotify(ref _subtitle, value);
}
}
private string _icon = "🛠";
public string Icon
{
get => _icon;
set
{
SetAndNotify(ref _icon, value);
}
}
private object _viewModel;
public object ContentViewModel
{
get => _viewModel;
set
{
SetAndNotify(ref _viewModel, value);
}
}
private Brush _foreground = Brushes.Black;
public Brush Foreground
{
get { return _foreground; }
set { SetAndNotify(ref _foreground, value); }
}
}
}

View File

@@ -0,0 +1,114 @@
using MainShell.Common;
using MainShell.Process;
using Stylet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MainShell.Models
{
public class DieTransferPathItem : PropertyChangedBase
{
private int _stepIndex;
public int StepIndex
{
get { return _stepIndex; }
set { SetAndNotify(ref _stepIndex, value); }
}
private int _padRow;
public int PadRow
{
get { return _padRow; }
set { SetAndNotify(ref _padRow, value); }
}
private int _padColumn;
public int PadColumn
{
get { return _padColumn; }
set { SetAndNotify(ref _padColumn, value); }
}
private int _dieRow;
public int DieRow
{
get { return _dieRow; }
set { SetAndNotify(ref _dieRow, value); }
}
private int _dieColumn;
public int DieColumn
{
get { return _dieColumn; }
set { SetAndNotify(ref _dieColumn, value); }
}
private double _x1Pos;
public double X1Pose
{
get { return _x1Pos; }
set { SetAndNotify(ref _x1Pos, value); }
}
private double _y1Pos;
public double Y1Pos
{
get { return _y1Pos; }
set { SetAndNotify(ref _y1Pos, value); }
}
private double _x2Pos;
public double X2Pos
{
get { return _x2Pos; }
set { SetAndNotify(ref _x2Pos, value); }
}
private double _y2Pos;
public double Y2Pos
{
get { return _y2Pos; }
set { SetAndNotify(ref _y2Pos, value); }
}
private TransPathType _transPathType = TransPathType.Nearest;
public TransPathType TransPathType
{
get { return _transPathType; }
set { SetAndNotify(ref _transPathType, value); }
}
public static DieTransferPathItem FromPathStep(DieTransferPathStep pathStep)
{
if (pathStep == null)
{
return null;
}
DieTransferPathItem item = new DieTransferPathItem();
item.StepIndex = pathStep.StepIndex;
item.DieRow = pathStep.DieRow;
item.DieColumn = pathStep.DieColumn;
item.PadRow = pathStep.PadRow;
item.PadColumn = pathStep.PadColumn;
item.X1Pose = pathStep.DieX;
item.Y1Pos = pathStep.DieY;
item.X2Pos = pathStep.PadX;
item.Y2Pos = pathStep.PadY;
item.TransPathType = pathStep.TransPathType;
return item;
}
}
}

View File

@@ -0,0 +1,202 @@
using MainShell.Common;
using MainShell.Hardware;
using MaxwellFramework.Core.Attributes;
using MwFramework.Device;
using System;
namespace MainShell.Models
{
[Singleton]
public class VisionParController
{
private readonly HardwareManager _hardwareManager;
public VisionParController(HardwareManager hardwareManager)
{
_hardwareManager = hardwareManager ?? throw new ArgumentNullException(nameof(hardwareManager));
}
public void SetTopPositionVisionPars(CameraConfig cameraConfig, UpCamLightConfig upCamLightConfig)
{
SetTopPositionCameraPars(cameraConfig);
SetUpCamLightPars(upCamLightConfig);
}
public void SetBottomPositionVisionPars(CameraConfig cameraConfig, DownCamLightConfig downCamLightConfig)
{
SetBottomPositionCameraPars(cameraConfig);
SetDownCamLightPars(downCamLightConfig);
}
public void SetMapVisionPars(CameraConfig cameraConfig, MapCamLightConfig mapCamLightConfig)
{
SetMapCameraPars(cameraConfig);
SetMapCamLightPars(mapCamLightConfig);
}
public void SetTopPositionCameraPars(CameraConfig config)
{
MwCamera camera = GetCamera(CameraType.TopPositionCamera);
SetCameraPars(camera, config);
}
public void SetBottomPositionCameraPars(CameraConfig config)
{
MwCamera camera = GetCamera(CameraType.MapCamera);
SetCameraPars(camera, config);
}
public void SetMapCameraPars(CameraConfig config)
{
MwCamera camera = GetCamera(CameraType.MapCamera);
SetCameraPars(camera, config);
}
public void ConfigureCameraForStream(CameraType cameraType)
{
MwCamera camera = GetCamera(cameraType);
EnsureCameraAvailable(camera, cameraType);
RetryMechanism.RetryIfNeeded(
() => camera.SetTriggerMode(CameraTriggerMode.Off) == DriverLibResult.DriverLibNoError,
string.Format("{0} 设置连续流触发模式失败", camera.ConnectId.CategoryName));
}
public void ConfigureCameraForSoftTrigger(CameraType cameraType, double? triggerDelay = null)
{
MwCamera camera = GetCamera(cameraType);
EnsureCameraAvailable(camera, cameraType);
RetryMechanism.RetryIfNeeded(
() => camera.SetTriggerMode(CameraTriggerMode.On) == DriverLibResult.DriverLibNoError,
string.Format("{0} 设置软触发模式失败", camera.ConnectId.CategoryName));
RetryMechanism.RetryIfNeeded(
() => camera.SetTriggerSource(CameraTriggerSource.Software) == DriverLibResult.DriverLibNoError,
string.Format("{0} 设置软触发源失败", camera.ConnectId.CategoryName));
if (triggerDelay.HasValue)
{
RetryMechanism.RetryIfNeeded(
() => camera.SetTriggerDelay(triggerDelay.Value) == DriverLibResult.DriverLibNoError,
string.Format("{0} 设置触发延时失败", camera.ConnectId.CategoryName));
}
}
public void StartCameraGrabbing(CameraType cameraType)
{
MwCamera camera = GetCamera(cameraType);
EnsureCameraAvailable(camera, cameraType);
RetryMechanism.RetryIfNeeded(
() =>
{
DriverLibResult result = camera.StartGrabbing();
return result == DriverLibResult.DriverLibNoError || result == DriverLibResult.DriverLibDeviceAlreadyGrabbing;
},
string.Format("{0} 启动抓流失败", camera.ConnectId.CategoryName));
}
public void StopCameraGrabbing(CameraType cameraType)
{
MwCamera camera = GetCamera(cameraType);
EnsureCameraAvailable(camera, cameraType);
RetryMechanism.RetryIfNeeded(
() =>
{
DriverLibResult result = camera.StopGrabbing();
return result == DriverLibResult.DriverLibNoError || result == DriverLibResult.DriverLibDeviceNotGrabbing;
},
string.Format("{0} 停止抓流失败", camera.ConnectId.CategoryName));
}
public void EnsureCameraGrabbing(CameraType cameraType)
{
MwCamera camera = GetCamera(cameraType);
EnsureCameraAvailable(camera, cameraType);
if (!camera.IsGrabbing)
{
throw new InvalidOperationException(string.Format("相机 '{0}' 当前未处于抓流状态。", cameraType));
}
}
public void SetCameraPars(MwCamera camera, CameraConfig config)
{
if (camera == null)
{
throw new ArgumentNullException(nameof(camera));
}
if (config == null)
{
throw new ArgumentNullException(nameof(config));
}
RetryMechanism.RetryIfNeeded(
() => camera.SetExposureTime(config.ExposureTime) == DriverLibResult.DriverLibNoError,
string.Format("{0} 设置曝光失败", camera.ConnectId.CategoryName));
RetryMechanism.RetryIfNeeded(
() => camera.SetGain(config.Gain) == DriverLibResult.DriverLibNoError,
string.Format("{0} 设置增益失败", camera.ConnectId.CategoryName));
}
public void SetDownCamLightPars(DownCamLightConfig config)
{
if (config == null)
{
throw new ArgumentNullException(nameof(config));
}
_hardwareManager.SetDownPointBlueLightIntensity(config.PointBlueLight);
_hardwareManager.SetDownRingBlueLightIntensity(config.RingBlueLight);
_hardwareManager.SetDownPointRedLightIntensity(config.PointRedLight);
_hardwareManager.SetDownRingRedLightIntensity(config.RingRedLight);
}
public void SetUpCamLightPars(UpCamLightConfig config)
{
if (config == null)
{
throw new ArgumentNullException(nameof(config));
}
_hardwareManager.SetUpPointBlueLightIntensity(config.PointBlueLight);
_hardwareManager.SetUpRingBlueLightIntensity(config.RingBlueLight);
_hardwareManager.SetUpPointRedLightIntensity(config.PointRedLight);
_hardwareManager.SetUpRingRedLightIntensity(config.RingRedLight);
_hardwareManager.SetUpRedBackLightIntensity(config.RedBackLight);
}
public void SetMapCamLightPars(MapCamLightConfig config)
{
if (config == null)
{
throw new ArgumentNullException(nameof(config));
}
_hardwareManager.SetMapBlueLightIntensity(config.BlueLight);
_hardwareManager.SetMapRedLightIntensity(config.RedLight);
}
private MwCamera GetCamera(CameraType cameraType)
{
return _hardwareManager.GetCamera(cameraType).Camera;
}
private static void EnsureCameraAvailable(MwCamera camera, CameraType cameraType)
{
if (camera == null)
{
throw new InvalidOperationException(string.Format("相机 '{0}' 不存在。", cameraType));
}
if (!camera.IsOpen)
{
throw new InvalidOperationException(string.Format("相机 '{0}' 未打开。", cameraType));
}
}
}
}

View File

@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MainShell.Models.Wafer
{
public enum DieStatus
{
Normal = 0,
Ng = 1,
}
public class Die
{
public int Row { get; set; }
public int Column { get; set; }
public double X { get; set; }
public double Y { get; set; }
public double Angle { get; set; }
public DieStatus Status { get; set; } = DieStatus.Normal;
}
}