代码拉取完成,页面将自动刷新
同步操作将从 老毛鸪/MG.CamCtrl 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
using MG.CamCtrl.Common.Enum;
using MG.CamCtrl.Mode;
using System.Collections.Generic;
namespace MG.CamCtrl
{
public class CamFactory
{
public CamFactory() { if (CameraList == null) CameraList = new List<ICamera>(); }
private static List<ICamera> CameraList { get; set; } = new List<ICamera>() { };
/// <summary>
/// 按相机品牌获取相近SN枚举
/// </summary>
/// <param name="brand"></param>
/// <returns></returns>
public static List<string> GetDeviceEnum(CameraBrand brand)
{
ICamera camera = null;
switch (brand)
{
case CameraBrand.DaHeng:
camera = new DHCamera();
break;
case CameraBrand.HIK:
camera = new HKCamera();
break;
case CameraBrand.Basler:
break;
default: break;
}
return camera?.GetListEnum();
}
/// <summary>
/// 按品牌创建相机
/// </summary>
/// <param name="brand"></param>
/// <returns></returns>
public static ICamera CreatCamera(CameraBrand brand)
{
ICamera returncamera = null;
switch (brand)
{
case CameraBrand.DaHeng:
returncamera = new DHCamera();
break;
case CameraBrand.HIK:
returncamera = new HKCamera();
break;
case CameraBrand.Basler:
break;
default:
break;
}
CameraList.Add(returncamera);
return returncamera;
}
/// <summary>
/// 获取对应SN的相机实例
/// </summary>
/// <param name="CamSN"></param>
/// <returns></returns>
public static ICamera GetItem(string CamSN)
{
ICamera cameraStandard = null;
if (CameraList.Count < 1) return cameraStandard;
foreach (var item in CameraList)
{
if ((item as BaseCamera).SN.Equals(CamSN))
{
cameraStandard = item;
break;
}
}
return cameraStandard;
}
/// <summary>
/// 注销相机
/// </summary>
/// <param name="decamera"></param>
public static void DestroyCamera(ICamera decamera)
{
CameraList?.Remove(decamera);
decamera?.CloseDevice();
}
/// <summary>
/// 注销所有相机
/// </summary>
public static void DestroyAll()
{
if (CameraList.Count < 1) return;
foreach (var camereaitem in CameraList)
{
camereaitem?.CloseDevice();
}
CameraList?.Clear();
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。