You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

142 lines
3.6 KiB

2 years ago
namespace EC.Util.CameraSDK;
/// <summary>
/// 相机信息
/// </summary>
public class CameraInfo
{
#region Fields
2 years ago
/// <summary>
/// id
2 years ago
/// </summary>
public string Id { get; set; } = string.Empty;
2 years ago
public string Name { get; set; } = string.Empty;
/// <summary>
/// 相机厂商
/// </summary>
public CameraManufactor Manufactor { get; set; }
2 years ago
/// <summary>
/// ip 地址
/// </summary>
public string Ip { get; set; } = string.Empty;
/// <summary>
/// 端口
/// </summary>
public int Port { get; set; }
/// <summary>
/// 账号
/// </summary>
public string UserName { get; set; } = string.Empty;
/// <summary>
/// 密码
/// </summary>
public string Password { get; set; } = string.Empty;
#endregion Fields
public static CameraInfo New(CameraManufactor manufactor, string ip, int port, string username, string password)
{
CameraInfo info = new() { Manufactor = manufactor, Ip = ip, Port = port, UserName = username, Password = password };
if (port <= 0) throw new Exception("Camera manufactor not support.");
return info;
}
public static CameraInfo New(CameraManufactor manufactor, string ip, string username, string password)
{
CameraInfo info = new() { Manufactor = manufactor, Ip = ip, UserName = username, Password = password };
int port = manufactor switch
{
CameraManufactor.HiK => (int)CameraPort.HiK,
CameraManufactor.DaHua => (int)CameraPort.DaHua,
CameraManufactor.YuShi => (int)CameraPort.YuShi,
_ => -1,
};
if (port <= 0) throw new Exception("Camera manufactor not support.");
info.Port = port;
return info;
}
2 years ago
public static CameraInfo New(int manufactor, string ip, int port, string username, string password)
2 years ago
{
CameraManufactor cm = (CameraManufactor)manufactor;
CameraInfo info = new() { Manufactor = cm, Ip = ip, Port = port, UserName = username, Password = password };
if (port <= 0) throw new Exception("Camera manufactor not support.");
2 years ago
return info;
}
public static CameraInfo New(int manufactor, string ip, string username, string password)
2 years ago
{
CameraManufactor cm = (CameraManufactor)manufactor;
CameraInfo info = new() { Manufactor = cm, Ip = ip, UserName = username, Password = password };
int port = cm switch
2 years ago
{
CameraManufactor.HiK => (int)CameraPort.HiK,
CameraManufactor.DaHua => (int)CameraPort.DaHua,
CameraManufactor.YuShi => (int)CameraPort.YuShi,
_ => -1,
};
if (port <= 0) throw new Exception("Camera manufactor not support.");
2 years ago
info.Port = port;
return info;
}
}
/// <summary>
/// 相机厂商
/// </summary>
public enum CameraManufactor : int
{
HiK = 1,
DaHua = 2,
YuShi = 3,
2 years ago
}
/// <summary>
/// 相机默认连接端口
/// </summary>
public enum CameraPort : int
{
HiK = 8000,
DaHua = 37777,
YuShi = 80,
2 years ago
}
/// <summary>
/// Ptz 信息
/// </summary>
public class PtzInfo
{
#region Fields
2 years ago
public double Pan { get; set; }
2 years ago
public double Tilt { get; set; }
2 years ago
public double Zoom { get; set; }
#endregion Fields
2 years ago
public PtzInfo(double pan, double tilt, double zoom)
{
Pan = pan;
Tilt = tilt;
Zoom = zoom;
}
public static PtzInfo Default
{
get { return new(0, 0, 0); }
}
public static PtzInfo New(double pan, double tilt, double zoom)
{
return new PtzInfo(pan, tilt, zoom);
}
}