432 lines
12 KiB
C#
432 lines
12 KiB
C#
/*
|
|
* Copyright (c) 2025 LG Electronics Inc.
|
|
* SPDX-License-Identifier: LicenseRef-LGE-Proprietary
|
|
*/
|
|
using Aurora.Api;
|
|
using Aurora.Api.DataType;
|
|
using Aurora.Api.Devices;
|
|
using PropertyTools.DataAnnotations;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.IO.Ports;
|
|
using VisionCommon;
|
|
|
|
namespace VisionLight {
|
|
#region Light Model Def
|
|
/// <summary>
|
|
/// 조명 디바이스 모델 리스트
|
|
/// 이름 형식 : 제조사_모델
|
|
/// </summary>
|
|
///
|
|
public enum eLightModel {
|
|
/// <summary>
|
|
/// TSM사 P12RV2
|
|
/// </summary>
|
|
TSM_P12RV2 = 0,
|
|
/// <summary>
|
|
/// TSM사 I16R
|
|
/// </summary>
|
|
TSM_I16R,
|
|
/// <summary>
|
|
/// TSM사 STM16C
|
|
/// </summary>
|
|
TSM_STM16C,
|
|
/// <summary>
|
|
/// LVS사 PN
|
|
/// </summary>
|
|
LVS_PN,
|
|
/// <summary>
|
|
/// LVS사 PT0105
|
|
/// </summary>
|
|
LVS_PT0105,
|
|
/// <summary>
|
|
/// LVS사 PT0205
|
|
/// </summary>
|
|
LVS_PT0205,
|
|
/// <summary>
|
|
/// LVS사 PT0405
|
|
/// </summary>
|
|
LVS_PT0405,
|
|
/// <summary>
|
|
/// LVS사 EN04
|
|
/// </summary>
|
|
LVS_EN04,
|
|
/// <summary>
|
|
/// LVS사 EN04_SOCKET
|
|
/// </summary>
|
|
LVS_EN04_SOCKET,
|
|
/// <summary>
|
|
/// LVS사 ES08
|
|
/// </summary>
|
|
LVS_ES08,
|
|
/// <summary>
|
|
/// LVS사 ES08_SOCKET
|
|
/// </summary>
|
|
LVS_ES08_SOCKET,
|
|
/// <summary>
|
|
/// LEESOS LPD
|
|
/// </summary>
|
|
LEESOS_LPD,
|
|
/// <summary>
|
|
/// CCS
|
|
/// </summary>
|
|
CCS,
|
|
/// <summary>
|
|
/// IPLUS MODBUS_SERIAL
|
|
/// </summary>
|
|
IPLUS_LED_MODBUS_SERIAL,
|
|
/// <summary>
|
|
/// ERI사 E_MINI
|
|
/// </summary>
|
|
ERI_E_MINI,
|
|
/// <summary>
|
|
/// CAS사 Esamrt series
|
|
/// </summary>
|
|
ESMART,
|
|
/// <summary>
|
|
/// 장비 전용 조명 디바이스 A
|
|
/// </summary>
|
|
MachineLight_A = 50,
|
|
/// <summary>
|
|
/// 장비 전용 조명 디바이스 B
|
|
/// </summary>
|
|
MachineLight_B,
|
|
/// <summary>
|
|
/// 장비 전용 조명 디바이스 C
|
|
/// </summary>,
|
|
MachineLight_C
|
|
}
|
|
|
|
internal static class LightModelDef {
|
|
public static Dictionary<eLightModel, Type> LightModels { get; set; } =
|
|
new Dictionary<eLightModel, Type>() {
|
|
{ eLightModel.TSM_P12RV2, typeof(Light_TSM_P12RV2) },
|
|
{ eLightModel.TSM_I16R, typeof(Light_TSM_I16R) },
|
|
{ eLightModel.TSM_STM16C, typeof(Light_TSM_STM16C) },
|
|
{ eLightModel.LVS_PN, typeof(Light_LVS_PN) },
|
|
{ eLightModel.LVS_PT0105, typeof(Light_LVS_PT0105) },
|
|
{ eLightModel.LVS_PT0205, typeof(Light_LVS_PT0205) },
|
|
{ eLightModel.LVS_PT0405, typeof(Light_LVS_PT0405) },
|
|
{ eLightModel.LVS_EN04, typeof(Light_LVS_EN04) },
|
|
{ eLightModel.LVS_EN04_SOCKET, typeof(Light_LVS_EN04_Socket) },
|
|
{ eLightModel.LVS_ES08, typeof(Light_LVS_ES08) },
|
|
{ eLightModel.LVS_ES08_SOCKET, typeof(Light_LVS_ES08_Socket) },
|
|
{ eLightModel.LEESOS_LPD, typeof(Light_LEESOS_LPD) },
|
|
{ eLightModel.CCS, typeof(Light_CCS) },
|
|
{ eLightModel.IPLUS_LED_MODBUS_SERIAL, typeof(Light_iPulse_ModbusSerial) },
|
|
{ eLightModel.ERI_E_MINI, typeof(Light_ERI_E_MINI) },
|
|
{ eLightModel.ESMART, typeof(Light_Esmart) }
|
|
};
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 조명 구동 방식
|
|
/// </summary>
|
|
public enum eLightType {
|
|
/// <summary> 상시 구동 </summary>
|
|
Continuous,
|
|
/// <summary> 점멸 구동 (짧은 시간 동안 강한 빛을 내는 섬광 방식) </summary>
|
|
Strobe
|
|
}
|
|
|
|
/// <summary>
|
|
/// 조명 컬러 타입
|
|
/// </summary>
|
|
public enum LightColorType {
|
|
/// <summary>
|
|
/// Red
|
|
/// </summary>
|
|
R = 0,
|
|
/// <summary>
|
|
/// Green
|
|
/// </summary>
|
|
G = 1,
|
|
/// <summary>
|
|
/// Blue
|
|
/// </summary>
|
|
B = 2,
|
|
/// <summary>
|
|
/// White
|
|
/// </summary>
|
|
W = 3,
|
|
/// <summary>
|
|
/// None
|
|
/// </summary>
|
|
None = 4
|
|
}
|
|
|
|
/// <summary>
|
|
/// 조명 장치 타입
|
|
/// </summary>
|
|
public enum LightDeviceType {
|
|
/// <summary>
|
|
/// Bar형
|
|
/// </summary>
|
|
Bar = 0,
|
|
/// <summary>
|
|
/// Ring 형
|
|
/// </summary>
|
|
Ring = 1,
|
|
/// <summary>
|
|
/// Half Ring 형
|
|
/// </summary>
|
|
Half_Ring = 2,
|
|
/// <summary>
|
|
/// Side
|
|
/// </summary>
|
|
Side = 3,
|
|
/// <summary>
|
|
/// Spot
|
|
/// </summary>
|
|
Spot = 4,
|
|
/// <summary>
|
|
/// Coaxial
|
|
/// </summary>
|
|
Coaxial = 5,
|
|
/// <summary>
|
|
/// Half Coaxial
|
|
/// </summary>
|
|
Half_Coaxial = 6,
|
|
/// <summary>
|
|
/// BackLight
|
|
/// </summary>
|
|
BackLight = 7,
|
|
/// <summary>
|
|
/// ETC
|
|
/// </summary>
|
|
ETC = 8
|
|
}
|
|
|
|
/// <summary>
|
|
/// 조명 연결 타입
|
|
/// </summary>
|
|
public enum eLightConnType {
|
|
/// <summary>
|
|
/// Serial
|
|
/// </summary>
|
|
Serial,
|
|
/// <summary>
|
|
/// Socket
|
|
/// </summary>
|
|
Socket,
|
|
/// <summary>
|
|
/// ModBus Serial
|
|
/// </summary>
|
|
ModbusSereial,
|
|
/// <summary>
|
|
/// None
|
|
/// </summary>
|
|
None,
|
|
}
|
|
|
|
/// <summary>
|
|
/// 조명 디바이스 컨피그 (베이스)
|
|
/// </summary>
|
|
public class LightConfig : IDeviceConfig {
|
|
/// <summary>
|
|
/// Light Model
|
|
/// </summary>
|
|
[SelectorStyle(SelectorStyle.ComboBox)]
|
|
public eLightModel LightModel { get; set; } = eLightModel.TSM_I16R;
|
|
/// <summary>
|
|
/// Light Type
|
|
/// </summary>
|
|
public eLightType LightType { get; set; } = eLightType.Continuous;
|
|
/// <summary> 미사용 </summary>
|
|
[Browsable(false)]
|
|
public IConnConfig ConnConfig { get; set; }
|
|
/// <summary> 레벨 Min, Max </summary>
|
|
public Range<int> DimRange { get; set; } = (0, 255);
|
|
/// <summary> 총 채널 개수 </summary>
|
|
public Range<int> Channels { get; set; } = (1, 8);
|
|
/// <summary>
|
|
/// Channel Config
|
|
/// </summary>
|
|
public ObservableCollection<ChConfig> ChannelConfigs { get; set; } = new ObservableCollection<ChConfig>();
|
|
|
|
/// <summary>
|
|
/// 디폴트 조명 컨피그 가져오기
|
|
/// </summary>
|
|
/// <param name="lightConnType">조명 연결 타입</param>
|
|
/// <returns>조명 디바이스 컨피그</returns>
|
|
public static IDeviceConfig GetDefaultConfig(eLightConnType lightConnType) {
|
|
if (lightConnType == eLightConnType.Serial) {
|
|
return new LightConfig_Serial();
|
|
}
|
|
else if (lightConnType == eLightConnType.Socket) {
|
|
return new LightConfig_Socket();
|
|
}
|
|
else if (lightConnType == eLightConnType.ModbusSereial) {
|
|
return new LightConnfig_ModbusSerial();
|
|
}
|
|
else {
|
|
Logger.E("Not supported Light connection type!!!");
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 조명 디바이스 컨피그 (시리얼 통신용)
|
|
/// </summary>
|
|
public class LightConfig_Serial : LightConfig {
|
|
/// <summary>
|
|
/// Serial Connection Config
|
|
/// </summary>
|
|
public SerialConnConfig SerialConnConfig { get; set; } = new SerialConnConfig() {
|
|
PortNum = 1,
|
|
BaudRate = 115200,
|
|
Parity = Parity.None,
|
|
StopBits = StopBits.One,
|
|
DataBits = 8
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// 조명 디바이스 컨피그 (소켓 통신용)
|
|
/// </summary>
|
|
public class LightConfig_Socket : LightConfig {
|
|
/// <summary>
|
|
/// Socket Connection 컨피그
|
|
/// </summary>
|
|
public SocketConnConfig SocketConnConfig { get; set; } = new SocketConnConfig() {
|
|
Address = new SocketAddress() {
|
|
IpAddress = "100.100.100.100",
|
|
PortNumber = 6000
|
|
},
|
|
Protocol = SocketProtocol.UDP,
|
|
ResponseTimeMS = 3000
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// 조명 디바이스 컨피그 (모드버스 시리얼 통신용)
|
|
/// </summary>
|
|
public class LightConnfig_ModbusSerial : LightConfig {
|
|
/// <summary>
|
|
/// Light Config(Modbus Serial)
|
|
/// </summary>
|
|
public LightConnfig_ModbusSerial() {
|
|
ModbusSerialConnConfig = new ModbusSerialConnConfig() {
|
|
PortNum = 1,
|
|
BaudRate = 115200,
|
|
Parity = Parity.None,
|
|
StopBits = StopBits.One,
|
|
DataBits = 8,
|
|
Slave = 0
|
|
};
|
|
ConnConfig = ModbusSerialConnConfig;
|
|
}
|
|
private ModbusSerialConnConfig _ModbusSerialConnConfig;
|
|
/// <summary>
|
|
/// Modbus Serial Connection Config
|
|
/// </summary>
|
|
public ModbusSerialConnConfig ModbusSerialConnConfig {
|
|
get => _ModbusSerialConnConfig;
|
|
set {
|
|
_ModbusSerialConnConfig = value;
|
|
ConnConfig = ModbusSerialConnConfig;
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// Light Config Info
|
|
/// LighId | DimRange | ChConfig
|
|
/// </summary>
|
|
public class LightConfigInfo : ICloneCopy<LightConfigInfo> {
|
|
/// <summary>
|
|
/// Light Id
|
|
/// </summary>
|
|
public eLightId LightId { get; set; } = eLightId.None;
|
|
/// <summary>
|
|
/// Dim Ranged (0, 255)
|
|
/// </summary>
|
|
public Range<int> DimRange { get; set; } = (0, 255);
|
|
/// <summary>
|
|
/// Channel Config
|
|
/// </summary>
|
|
public ChConfig ChConfig { get; set; } = new ChConfig();
|
|
|
|
/// <summary>
|
|
/// Clone
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public LightConfigInfo Clone() {
|
|
return ((ICloneable)this).Clone() as LightConfigInfo;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Copy To Target
|
|
/// </summary>
|
|
/// <param name="target"> 복사할 타겟 </param>
|
|
public void CopyTo(LightConfigInfo target) {
|
|
target.LightId = this.LightId;
|
|
target.DimRange = (this.DimRange.Min, this.DimRange.Max);
|
|
target.ChConfig = this.ChConfig.Clone();
|
|
}
|
|
|
|
object ICloneable.Clone() {
|
|
var cloneObj = new LightConfigInfo();
|
|
CopyTo(cloneObj);
|
|
return cloneObj;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 채널 컨피그
|
|
/// </summary>
|
|
public class ChConfig : ICloneCopy<ChConfig> {
|
|
/// <summary>
|
|
/// 채널
|
|
/// </summary>
|
|
public int Ch { get; set; } = 1;
|
|
/// <summary>
|
|
/// On/Off
|
|
/// </summary>
|
|
public bool OnOff { get; set; } = true;
|
|
/// <summary>
|
|
/// 레벨
|
|
/// </summary>
|
|
public int Level { get; set; } = 80;
|
|
/// <summary>
|
|
/// Light 디바이스 종류
|
|
/// </summary>
|
|
public LightDeviceType DeviceType { get; set; } = LightDeviceType.Ring;
|
|
/// <summary>
|
|
/// 컬러 타입
|
|
/// </summary>
|
|
public LightColorType ColorType { get; set; } = LightColorType.W;
|
|
/// <summary>
|
|
/// 캠 ID
|
|
/// </summary>
|
|
public eCamId CamId { get; set; } = eCamId.None;
|
|
|
|
/// <summary>
|
|
/// Clone
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public ChConfig Clone() {
|
|
return ((ICloneable)this).Clone() as ChConfig;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Copy To Target
|
|
/// </summary>
|
|
/// <param name="target">복사할 타겟</param>
|
|
public void CopyTo(ChConfig target) {
|
|
target.CamId = this.CamId;
|
|
target.Ch = this.Ch;
|
|
target.ColorType = this.ColorType;
|
|
target.DeviceType = this.DeviceType;
|
|
target.Level = this.Level;
|
|
target.OnOff = this.OnOff;
|
|
}
|
|
|
|
object ICloneable.Clone() {
|
|
var cloneObj = new ChConfig();
|
|
CopyTo(cloneObj);
|
|
return cloneObj;
|
|
}
|
|
}
|
|
} |