提交
This commit is contained in:
parent
8aec9ba7fa
commit
447cf4326b
@ -930,6 +930,7 @@ namespace DH.Commons.Base
|
|||||||
public class DetectionLable : NotifyProperty
|
public class DetectionLable : NotifyProperty
|
||||||
{
|
{
|
||||||
private bool _selected = false;
|
private bool _selected = false;
|
||||||
|
|
||||||
private string _labelId;
|
private string _labelId;
|
||||||
private string _labelName;
|
private string _labelName;
|
||||||
private double _maxScore;
|
private double _maxScore;
|
||||||
|
@ -18,7 +18,7 @@ namespace DH.Commons.Base
|
|||||||
private int _dataBit = 8;
|
private int _dataBit = 8;
|
||||||
private StopBits _stopBit = StopBits.One;
|
private StopBits _stopBit = StopBits.One;
|
||||||
private Parity _parity = Parity.None;
|
private Parity _parity = Parity.None;
|
||||||
private string _ip = "192.168.6.6";
|
private string _ip = "192.168.6.61";
|
||||||
private int _port = 502;
|
private int _port = 502;
|
||||||
private AntList<PLCItem> _PLCItemList = new AntList<PLCItem>();
|
private AntList<PLCItem> _PLCItemList = new AntList<PLCItem>();
|
||||||
[Category("设备配置")]
|
[Category("设备配置")]
|
||||||
|
@ -45,12 +45,19 @@ namespace DH.Devices.PLC
|
|||||||
TcpNet.DataFormat = HslCommunication.Core.DataFormat.ABCD;
|
TcpNet.DataFormat = HslCommunication.Core.DataFormat.ABCD;
|
||||||
TcpNet.Station = 1;
|
TcpNet.Station = 1;
|
||||||
TcpNet.Series = XinJESeries.XD;
|
TcpNet.Series = XinJESeries.XD;
|
||||||
|
|
||||||
|
PLCItem itemSpeed = PLCItemList.FirstOrDefault(u => u.Name == "转盘速度");
|
||||||
|
if(itemSpeed== null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
OperateResult ret = TcpNet.ConnectServer();
|
OperateResult ret = TcpNet.ConnectServer();
|
||||||
if (ret.IsSuccess)
|
if (ret.IsSuccess)
|
||||||
{
|
{
|
||||||
Connected = true;
|
Connected = true;
|
||||||
MonitorPieces();
|
MonitorPieces();
|
||||||
TurntableOpen(12000,true);
|
|
||||||
|
TurntableOpen(Convert.ToInt32(itemSpeed.Value) , true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -58,6 +65,8 @@ namespace DH.Devices.PLC
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
@ -438,6 +447,9 @@ namespace DH.Devices.PLC
|
|||||||
private void MonitorPiecesImpl()
|
private void MonitorPiecesImpl()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
PLCItem pLCItem= PLCItemList.FirstOrDefault(u => u.Name == "产品计数");
|
||||||
|
if (pLCItem == null)
|
||||||
|
return;
|
||||||
DateTime startTime = DateTime.Now;
|
DateTime startTime = DateTime.Now;
|
||||||
DateTime endTime = startTime;
|
DateTime endTime = startTime;
|
||||||
TimeSpan timeSpan = endTime - startTime;
|
TimeSpan timeSpan = endTime - startTime;
|
||||||
@ -448,7 +460,7 @@ namespace DH.Devices.PLC
|
|||||||
Stopwatch sw = new Stopwatch();
|
Stopwatch sw = new Stopwatch();
|
||||||
uint tmpPieceNumber = 0;
|
uint tmpPieceNumber = 0;
|
||||||
sw.Start();
|
sw.Start();
|
||||||
|
|
||||||
var ret = TcpNet.ReadUInt16("D1016");
|
var ret = TcpNet.ReadUInt16("D1016");
|
||||||
|
|
||||||
sw.Stop();
|
sw.Stop();
|
||||||
|
@ -136,9 +136,8 @@ namespace DH.Devices.Vision
|
|||||||
// json = "{\"FastDetResult\":[{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654843,\"rect\":[175,99,110,594]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654589,\"rect\":[2608,19,104,661]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654285,\"rect\":[1275,19,104,662]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.620762,\"rect\":[1510,95,107,600]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.617812,\"rect\":[2844,93,106,602]}]}";
|
// json = "{\"FastDetResult\":[{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654843,\"rect\":[175,99,110,594]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654589,\"rect\":[2608,19,104,661]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654285,\"rect\":[1275,19,104,662]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.620762,\"rect\":[1510,95,107,600]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.617812,\"rect\":[2844,93,106,602]}]}";
|
||||||
//
|
//
|
||||||
Console.WriteLine("检测结果JSON:" + json);
|
Console.WriteLine("检测结果JSON:" + json);
|
||||||
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
|
||||||
SegResult detResult = JsonConvert.DeserializeObject<SegResult>(json);
|
SegResult detResult = JsonConvert.DeserializeObject<SegResult>(json);
|
||||||
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
|
||||||
if (detResult == null)
|
if (detResult == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -176,7 +175,6 @@ namespace DH.Devices.Vision
|
|||||||
MLResult mlResult = new MLResult();
|
MLResult mlResult = new MLResult();
|
||||||
Mat originMat=new Mat() ;
|
Mat originMat=new Mat() ;
|
||||||
Mat detectMat= new Mat();
|
Mat detectMat= new Mat();
|
||||||
#pragma warning disable CS0168 // 声明了变量,但从未使用过
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (req.mImage == null)
|
if (req.mImage == null)
|
||||||
@ -266,18 +264,17 @@ namespace DH.Devices.Vision
|
|||||||
// 释放 Mat 资源
|
// 释放 Mat 资源
|
||||||
if (detectMat != null)
|
if (detectMat != null)
|
||||||
{
|
{
|
||||||
detectMat.Dispose();
|
|
||||||
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
|
||||||
detectMat = null;
|
detectMat = null;
|
||||||
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (originMat != null)
|
if (originMat != null)
|
||||||
{
|
{
|
||||||
originMat.Dispose();
|
originMat.Dispose();
|
||||||
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
|
||||||
originMat = null;
|
originMat = null;
|
||||||
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -206,60 +206,47 @@ namespace DH.Devices.Vision
|
|||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
//当前检测项的 过滤条件
|
// 当前检测项的 过滤条件
|
||||||
//var conditionList = detectConfig.DetectionFilterList
|
var conditionList = detectConfig.DetectionLableList
|
||||||
// .Where(u => u.IsEnabled && u.LabelName == d.LabelName)
|
.Where(u=>u.LabelName == d.LabelName)
|
||||||
// .GroupBy(u => u.ResultState)
|
.GroupBy(u => u.ResultState)
|
||||||
// .OrderBy(u => u.Key)
|
.OrderBy(u => u.Key)
|
||||||
// .ToList();
|
.ToList();
|
||||||
//当前检测项的 过滤条件
|
|
||||||
//var conditionList = detectConfig.DetectionFilterList
|
|
||||||
// .Where(u => u.IsEnabled && u.LabelName == d.LabelName)
|
|
||||||
// .GroupBy(u => u.ResultState)
|
|
||||||
// .OrderBy(u => u.Key)
|
|
||||||
// .ToList();
|
|
||||||
|
|
||||||
//if (conditionList.Count == 0)
|
if (conditionList.Count == 0)
|
||||||
//{
|
{
|
||||||
|
|
||||||
// d.FinalResult = d.LabelName.ToLower() == "ok"
|
d.FinalResult = d.LabelName.ToLower() == "ok"
|
||||||
// ? ResultState.OK
|
? ResultState.OK
|
||||||
// : ResultState.DetectNG;
|
: ResultState.DetectNG;
|
||||||
//}
|
}
|
||||||
//else
|
else
|
||||||
//{
|
{
|
||||||
// d.FinalResult = detectConfig.IsMixModel
|
d.FinalResult = detectConfig.IsMixModel
|
||||||
// ? ResultState.A_NG
|
? ResultState.A_NG
|
||||||
// : ResultState.OK;
|
: ResultState.OK;
|
||||||
|
|
||||||
|
|
||||||
//}
|
}
|
||||||
|
|
||||||
|
|
||||||
//foreach (IGrouping<ResultState, DetectionFilter> group in conditionList)
|
foreach (IGrouping<ResultState, DetectionFilter> group in conditionList)
|
||||||
//{
|
{
|
||||||
// //bool b = group.ToList().Any(f =>
|
bool b = group.ToList().Any(f =>
|
||||||
// //{
|
{
|
||||||
// // return f.FilterOperation(d);
|
return f.FilterOperation(d);
|
||||||
// //});
|
});
|
||||||
|
|
||||||
|
|
||||||
// //if (b)
|
if (b)
|
||||||
// //{
|
{
|
||||||
// // d.FinalResult = group.Key;
|
d.FinalResult = group.Key;
|
||||||
// // break;
|
break;
|
||||||
// //}
|
}
|
||||||
|
|
||||||
// if (group.Any(f => f.FilterOperation(d)))
|
|
||||||
// {
|
}
|
||||||
// d.FinalResult = group.Key;
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
// //else
|
|
||||||
// //{
|
|
||||||
// // d.FinalResult = d.InferenceResult = ResultState.OK;
|
|
||||||
// //}
|
|
||||||
//}
|
|
||||||
});
|
});
|
||||||
#endregion
|
#endregion
|
||||||
#region 5.统计缺陷过滤结果或预处理直接NG
|
#region 5.统计缺陷过滤结果或预处理直接NG
|
||||||
|
@ -30,7 +30,9 @@ using System.Threading.Tasks;
|
|||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using XKRS.UI.Device.Winform;
|
using XKRS.UI.Device.Winform;
|
||||||
using static AntdUI.Math3D;
|
using static AntdUI.Math3D;
|
||||||
|
using static DH.Commons.Enums.EnumHelper;
|
||||||
using Camera = DHSoftware.Models.Camera;
|
using Camera = DHSoftware.Models.Camera;
|
||||||
|
using ResultState = DH.Commons.Base.ResultState;
|
||||||
|
|
||||||
namespace DHSoftware
|
namespace DHSoftware
|
||||||
{
|
{
|
||||||
@ -242,10 +244,10 @@ namespace DHSoftware
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public List<Camera> HKCameras { get; } = new List<Camera>();
|
public List<HikVisionCamera> HKCameras { get; } = new List<HikVisionCamera>();
|
||||||
public List<Do3ThinkCamera> Cameras { get; } = new List<Do3ThinkCamera>();
|
public List<Do3ThinkCamera> Cameras { get; } = new List<Do3ThinkCamera>();
|
||||||
public Dictionary<string, SimboObjectDetection> Dectection { get; } = new Dictionary<string, SimboObjectDetection>();
|
public Dictionary<string, SimboObjectDetection> Dectection { get; } = new Dictionary<string, SimboObjectDetection>();
|
||||||
public XinJEPLCTcpNet PLC { get; } = new XinJEPLCTcpNet();
|
public XinJEPLCTcpNet PLC { get; } = XinJEPLCTcpNet.Instance;
|
||||||
SLDMotion sLDMotion = new SLDMotion();
|
SLDMotion sLDMotion = new SLDMotion();
|
||||||
private void MainWindow_Load(object sender, EventArgs e)
|
private void MainWindow_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
@ -261,7 +263,7 @@ namespace DHSoftware
|
|||||||
foreach (var camera in HKCameras)
|
foreach (var camera in HKCameras)
|
||||||
{
|
{
|
||||||
//var hk as HikVisionCamera;
|
//var hk as HikVisionCamera;
|
||||||
//camera.CameraDisConnect();
|
camera.CameraDisConnect();
|
||||||
}
|
}
|
||||||
PLC.PLCDisConnect();
|
PLC.PLCDisConnect();
|
||||||
}
|
}
|
||||||
@ -299,6 +301,8 @@ namespace DHSoftware
|
|||||||
public volatile int ProductNum_OK = 0;
|
public volatile int ProductNum_OK = 0;
|
||||||
private readonly object _cameraSummaryLock = new object();
|
private readonly object _cameraSummaryLock = new object();
|
||||||
public SimboVisionDriver? _visionEngine = null;
|
public SimboVisionDriver? _visionEngine = null;
|
||||||
|
|
||||||
|
public PLCBase? _PLCConfig = null;
|
||||||
List<DetectionConfig> DetectionConfigs = new List<DetectionConfig>();
|
List<DetectionConfig> DetectionConfigs = new List<DetectionConfig>();
|
||||||
List<SimboStationMLEngineSet> SimboStationMLEngineList = new List<SimboStationMLEngineSet>();
|
List<SimboStationMLEngineSet> SimboStationMLEngineList = new List<SimboStationMLEngineSet>();
|
||||||
Dictionary<string, HDevEngineTool> HalconToolDict = new Dictionary<string, HDevEngineTool>();
|
Dictionary<string, HDevEngineTool> HalconToolDict = new Dictionary<string, HDevEngineTool>();
|
||||||
@ -306,8 +310,297 @@ namespace DHSoftware
|
|||||||
public DateTime startTime;
|
public DateTime startTime;
|
||||||
private void HandleStartButton()
|
private void HandleStartButton()
|
||||||
{
|
{
|
||||||
|
Cameras.Clear();
|
||||||
|
HKCameras.Clear();
|
||||||
|
Dectection.Clear();
|
||||||
|
_cameraRelatedDetectionDict = new();
|
||||||
|
//初始化相机 链接相机
|
||||||
|
if (ConfigModel.CameraBaseList.Count > 0)
|
||||||
|
{
|
||||||
|
for (int i = 0; i <ConfigModel.CameraBaseList.Count; i++)
|
||||||
|
{
|
||||||
|
var cameraBase = ConfigModel.CameraBaseList[i];
|
||||||
|
if(cameraBase.CamType == EnumCamType.度申Do3think)
|
||||||
|
{
|
||||||
|
Do3ThinkCamera cam = new Do3ThinkCamera();
|
||||||
|
|
||||||
|
cam.CameraName = cameraBase.CameraName;
|
||||||
|
cam.CameraIP = cameraBase.CameraIP;
|
||||||
|
cam.IsEnabled = cameraBase.IsEnabled;
|
||||||
|
Cameras.Add(cam);
|
||||||
|
//cam.CameraConnect();
|
||||||
|
cam.OnHImageOutput += OnCameraHImageOutput;
|
||||||
|
}
|
||||||
|
else if(cameraBase.CamType == EnumCamType.海康hik)
|
||||||
|
{
|
||||||
|
HikVisionCamera cam = new HikVisionCamera();
|
||||||
|
cam.CameraName = cameraBase.CameraName;
|
||||||
|
cam.CameraIP = cameraBase.CameraIP;
|
||||||
|
cam.IsEnabled=cameraBase.IsEnabled;
|
||||||
|
HKCameras.Add(cam);
|
||||||
|
// cam.CameraConnect();
|
||||||
|
cam.OnHImageOutput += OnCameraHImageOutput;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ConfigModel.PLCBaseList.Count > 0)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < ConfigModel.PLCBaseList.Count; i++)
|
||||||
|
{
|
||||||
|
var plcBase = ConfigModel.PLCBaseList[i];
|
||||||
|
if(plcBase.PLCType==EnumPLCType.信捷XC网口)
|
||||||
|
{
|
||||||
|
|
||||||
|
PLC.IP = plcBase.IP;
|
||||||
|
PLC.Enable = plcBase.Enable;
|
||||||
|
PLC.PLCName = plcBase.PLCName;
|
||||||
|
PLC.PLCItemList=plcBase.PLCItemList;
|
||||||
|
PLC.Port= plcBase.Port;
|
||||||
|
PLC.PLCConnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
if (ConfigModel.DetectionList.Count > 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
for (int i = 0; i < ConfigModel.DetectionList.Count; i++)
|
||||||
|
{
|
||||||
|
DetectionConfig detectionConfig = ConfigModel.DetectionList[i];
|
||||||
|
var detection = ConfigModel.DetectionList[i];
|
||||||
|
detectionConfig.CameraCollects = detection.CameraCollects;
|
||||||
|
detectionConfig.ModelconfThreshold = detection.ModelconfThreshold;
|
||||||
|
detectionConfig.ModelWidth = detection.ModelWidth;
|
||||||
|
detectionConfig.ModelHeight = detection.ModelHeight;
|
||||||
|
detectionConfig.In_lable_path = detection.In_lable_path;
|
||||||
|
detectionConfig.IsEnabled = detection.IsEnabled;
|
||||||
|
detectionConfig.ShowLocation.X = detection.ShowLocation.X;
|
||||||
|
detectionConfig.ShowLocation.Y = detection.ShowLocation.Y;
|
||||||
|
DetectionConfigs.Add(detectionConfig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
DetectionConfigs.ForEach(detection =>
|
||||||
|
{
|
||||||
|
|
||||||
|
detection.CameraCollects.ForEach(cam =>
|
||||||
|
{
|
||||||
|
List<string> Dets = new List<string>
|
||||||
|
{
|
||||||
|
detection.Id
|
||||||
|
};
|
||||||
|
if (!_cameraRelatedDetectionDict.ContainsKey(cam.CameraSourceId))
|
||||||
|
{
|
||||||
|
_cameraRelatedDetectionDict.Add(cam.CameraSourceId, Dets);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_cameraRelatedDetectionDict[cam.CameraSourceId].Add(detection.Id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
);
|
||||||
|
});
|
||||||
|
string inferenceDevice = "CPU";
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
_visionEngine = new SimboVisionDriver();
|
||||||
|
_visionEngine.DetectionConfigs = DetectionConfigs;
|
||||||
|
|
||||||
|
//初始化模型 加载模型
|
||||||
|
_visionEngine.Init();
|
||||||
|
CtrlVisionRunBase ctrlVisionRun = new CtrlVisionRunBase(_visionEngine);
|
||||||
|
tabImgDisplay.Controls.Add(ctrlVisionRun);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
private static int currentRegister = 411; // 初始为 D411
|
||||||
|
private void StartProcess()
|
||||||
|
{
|
||||||
|
//计数清零
|
||||||
|
PieceCount = 0;
|
||||||
|
//吹气点位归置
|
||||||
|
currentRegister = 411;
|
||||||
|
|
||||||
|
|
||||||
|
if (_PLCConfig?.Enable == true)
|
||||||
|
{
|
||||||
|
PLC.CountToZero();
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigModel.CameraBaseList.ForEach(d =>
|
||||||
|
{
|
||||||
|
if (d is CameraBase cam)
|
||||||
|
{
|
||||||
|
cam.SnapshotCount = 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//PrepareBatchNO();
|
||||||
|
// isInPositionChecking = false;
|
||||||
|
//isFullTrayChecking = false;
|
||||||
|
//队列清空
|
||||||
|
// var temp = new List<ITriggerSet>();
|
||||||
|
// temp.AddRange(XKRSPLCConfig.TriggerConfigCollection);
|
||||||
|
// temp.AddRange(XKRSPLCConfig.SnapshotTriggerConfigCollection);
|
||||||
|
|
||||||
|
//temp.ForEach(t =>
|
||||||
|
//{
|
||||||
|
// var diskInfo = XKRSPLCConfig.DiskInfoList.FirstOrDefault(u => u.DiskName == t.DiskName);
|
||||||
|
// if (diskInfo != null)
|
||||||
|
// {
|
||||||
|
// t.AxisNum = diskInfo.DiskAxisNum;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// t.AxisNum = -1;
|
||||||
|
// }
|
||||||
|
//});
|
||||||
|
|
||||||
|
//if (temp.Any(u => u.AxisNum < 0))
|
||||||
|
//{
|
||||||
|
// LogAsync(DateTime.Now, LogLevel.Error, "触发信号归属转盘未确认");
|
||||||
|
// return new ProcessResponse(false);
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
// _diskInfoListInOrder = XKRSPLCConfig.DiskInfoList.OrderBy(u => u.DiskSequence).ToList();
|
||||||
|
// var axisNumList = _diskInfoListInOrder.Select(u => u.DiskAxisNum).ToList();
|
||||||
|
|
||||||
|
/// PrepareMLEngine();
|
||||||
|
|
||||||
|
|
||||||
|
// if (_PLCConfig?.Enable == true)
|
||||||
|
//挡料电机操作
|
||||||
|
// _PLC.FeedingMotor(_PLCConfig.CunToZeroSpeed, _PLCConfig.CunPos, _PLCConfig.CunSpeed, _PLCConfig.CunDirection);
|
||||||
|
|
||||||
|
//流程开启操作配置
|
||||||
|
// ProcessInitialAction();
|
||||||
|
// if (_PLC?Enabled == true)
|
||||||
|
//皮带
|
||||||
|
// _PLC.Belt(true);
|
||||||
|
|
||||||
|
//DeviceCollection.ForEach(d =>
|
||||||
|
//{
|
||||||
|
// if (d is CameraBase c)
|
||||||
|
// {
|
||||||
|
// c.OnHImageOutput -= OnCameraHImageOutput;
|
||||||
|
// c.OnHImageOutput += OnCameraHImageOutput;
|
||||||
|
// c.SnapshotCount = 0;
|
||||||
|
// }
|
||||||
|
//});
|
||||||
|
_productLists.Clear();
|
||||||
|
#region 虚拟相机
|
||||||
|
//mOfflineImageTimer = new System.Timers.Timer();
|
||||||
|
|
||||||
|
//mOfflineImageTimer.Elapsed += OnEmitSerialPortAsync;
|
||||||
|
//mOfflineImageTimer.Interval = 1000;
|
||||||
|
//mOfflineImageTimer.Start();
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
var settings = _visionEngine.DetectionConfigs.Where(u => u.IsEnabled && u.IsAddStation ).ToList();
|
||||||
|
if (settings != null)
|
||||||
|
{
|
||||||
|
settings = settings.Where(s => s.IsEnabled).ToList();
|
||||||
|
ProductBaseCount = settings.Count;
|
||||||
|
|
||||||
|
for (int i = 0; i < ProductBaseCount * ProductListMulti; i++)
|
||||||
|
{
|
||||||
|
ConcurrentDictionary<uint, ProductData> products = new ConcurrentDictionary<uint, ProductData>();
|
||||||
|
_productLists.Add(products);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// _MGSCameraList = DeviceCollection
|
||||||
|
//.OfType<MGSCameraDriver>() // 直接筛选出 MGSCameraDriver 类型的元素
|
||||||
|
//.Where(camera => camera.IConfig != null && camera.IConfig.IsEnabled) // 进一步筛选 IConfig 不为 null 且 IsEnabled 为 true
|
||||||
|
//.ToList();
|
||||||
|
|
||||||
|
// ProductBaseCount = _MGSCameraList.Count;
|
||||||
|
|
||||||
|
for (int i = 0; i < ProductBaseCount * ProductListMulti; i++)
|
||||||
|
{
|
||||||
|
ConcurrentDictionary<uint, ProductData> products = new ConcurrentDictionary<uint, ProductData>();
|
||||||
|
_productLists.Add(products);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 转盘操作
|
||||||
|
// if (_PLC?.IIConfig?.IsEnabled == true)
|
||||||
|
|
||||||
|
// _PLC.TurntableOpen(XKRSPLCConfig.TurnSpeed, XKRSPLCConfig.TurnDirection);
|
||||||
|
|
||||||
|
Thread.Sleep(500);
|
||||||
|
|
||||||
|
//振动盘
|
||||||
|
//if (XKRSPLCConfig.IsEnableVibratory)
|
||||||
|
//{
|
||||||
|
// if (_PLC.IIConfig.IsEnabled)
|
||||||
|
// _PLC.Vibratory(true);
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
//InitialOEEStatistic();
|
||||||
|
|
||||||
|
// MachineState = MachineState.Running;
|
||||||
|
|
||||||
|
}
|
||||||
|
private void PrepareMLEngine()
|
||||||
|
{
|
||||||
|
//if (_visionEngine == null)
|
||||||
|
//{
|
||||||
|
// _visionEngine = DeviceCollection.FirstOrDefault(u => u is VisionEngineBase) as VisionEngineBase;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//if (_visionEngine == null)
|
||||||
|
//{
|
||||||
|
// throw new ProcessException($"未能获取检测设备");
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//相机模组
|
||||||
|
//_cameraRelatedDetectionDict = new();
|
||||||
|
|
||||||
|
//detectionList.ForEach(detection =>
|
||||||
|
//{
|
||||||
|
// detection.CameraCollects.ForEach(cam =>
|
||||||
|
// {
|
||||||
|
// List<string> Dets = new List<string>
|
||||||
|
// {
|
||||||
|
// detection.Id
|
||||||
|
// };
|
||||||
|
// if (!_cameraRelatedDetectionDict.ContainsKey(cam.CameraSourceId))
|
||||||
|
// {
|
||||||
|
// _cameraRelatedDetectionDict.Add(cam.CameraSourceId, Dets);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// _cameraRelatedDetectionDict[cam.CameraSourceId].Add(detection.Id);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// });
|
||||||
|
//});
|
||||||
|
|
||||||
|
//_visionEngine.OnDetectionWarningStop += VisionEngine_OnDetectionWarningStopAsync;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if false
|
||||||
|
private void HandleStartButton2()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
CurrentMachine = true;
|
CurrentMachine = true;
|
||||||
|
|
||||||
//_visionEngine.Start();
|
//_visionEngine.Start();
|
||||||
//[Category("深度学习检测配置")]
|
//[Category("深度学习检测配置")]
|
||||||
//[DisplayName("检测标签定义集合")]
|
//[DisplayName("检测标签定义集合")]
|
||||||
@ -502,22 +795,22 @@ namespace DHSoftware
|
|||||||
{
|
{
|
||||||
|
|
||||||
detection.CameraCollects.ForEach(cam =>
|
detection.CameraCollects.ForEach(cam =>
|
||||||
{
|
{
|
||||||
List<string> Dets = new List<string>
|
List<string> Dets = new List<string>
|
||||||
{
|
{
|
||||||
detection.Id
|
detection.Id
|
||||||
};
|
};
|
||||||
if (!_cameraRelatedDetectionDict.ContainsKey(cam.CameraSourceId))
|
if (!_cameraRelatedDetectionDict.ContainsKey(cam.CameraSourceId))
|
||||||
{
|
{
|
||||||
_cameraRelatedDetectionDict.Add(cam.CameraSourceId, Dets);
|
_cameraRelatedDetectionDict.Add(cam.CameraSourceId, Dets);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_cameraRelatedDetectionDict[cam.CameraSourceId].Add(detection.Id);
|
_cameraRelatedDetectionDict[cam.CameraSourceId].Add(detection.Id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
string inferenceDevice = "CPU";
|
string inferenceDevice = "CPU";
|
||||||
@ -650,6 +943,8 @@ namespace DHSoftware
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
private uint PieceCount = 0;
|
private uint PieceCount = 0;
|
||||||
private List<ConcurrentDictionary<uint, ProductData>> _productLists = new List<ConcurrentDictionary<uint, ProductData>>();
|
private List<ConcurrentDictionary<uint, ProductData>> _productLists = new List<ConcurrentDictionary<uint, ProductData>>();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user