- 오토런 시작 시 RCC 패턴 폴더 변경 감지 → B2506 ON, PLC ACK(B2409) 수신 시 OFF - 서브 패턴 1~10, 패턴 목록에 서브 썸네일 표시(행 내 좌우 스크롤) - 서브 패턴 등록 직후 활성화 OFF - 패턴 파일이 다른 프로그램에서 열려 있으면 삭제하지 않고 안내 - 현장 소스 반영: Train ROI 슬라이더, KS 조명 밝기 저장/적용, 조명 ID 분리, 스캔 후 카메라 라이브 재시작, 레시피 21 RCC NG 우회, 오토런 상태 판단
156 lines
4.2 KiB
C#
156 lines
4.2 KiB
C#
using Aurora.Api;
|
|
using Aurora.Api.DataType;
|
|
using Aurora.Api.Devices;
|
|
using AuroraLight.ALT;
|
|
using AuroraLight.ERI;
|
|
using AuroraLight.LvsPn;
|
|
using Hermes;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace AuroraLight
|
|
{
|
|
public enum eLight
|
|
{
|
|
LvsPn,
|
|
ALT_4CH,
|
|
ALT_8CH,
|
|
ERI,
|
|
}
|
|
public class LightDevice : Device
|
|
{
|
|
Logger Log;
|
|
internal eLight _lightType;
|
|
internal ILight _light;
|
|
public LightConfig Config { get; private set; }
|
|
|
|
public LightDevice(string deviceId, eLight light)
|
|
{
|
|
DeviceId = deviceId;
|
|
CommType = CommunicationType.Serial; // 추후 필요 시 DoActivate 할때 IConnConfig 에서 처리하게끔 추가 필요.
|
|
Type = DeviceType.Light;
|
|
Log = new Logger(deviceId);
|
|
_lightType = light;
|
|
}
|
|
|
|
protected override int DoActivate(IDeviceConfig config)
|
|
{
|
|
var l_config = config as LightConfig;
|
|
Config = l_config;
|
|
|
|
if (IsSimul) {
|
|
return E1.OK;
|
|
} else {
|
|
switch (_lightType) {
|
|
case eLight.LvsPn:
|
|
_light = new LvsPnLight(DeviceId, IsSimul, l_config);
|
|
break;
|
|
case eLight.ALT_4CH:
|
|
_light = new ALTLight(DeviceId, IsSimul, eALTLightType.Light_4CH);
|
|
break;
|
|
case eLight.ALT_8CH:
|
|
_light = new ALTLight(DeviceId, IsSimul, eALTLightType.Light_8CH);
|
|
break;
|
|
case eLight.ERI:
|
|
_light = new ERILight(DeviceId, IsSimul, 4); // Channel Count 를 config 에 어떻게 넣을 것인가.
|
|
break;
|
|
}
|
|
|
|
bool connected = _light.InitInternal(config.ConnConfig as SerialConnConfig);
|
|
if (connected && l_config != null) {
|
|
int chCount = _lightType == eLight.ALT_8CH ? 8 : 4;
|
|
for (int i = 0; i < chCount; i++) {
|
|
_light.SetLightValueInternal(i, l_config.GetChannelLevel(i));
|
|
}
|
|
}
|
|
|
|
return connected ? E1.OK : E2.NOT_CONNECTED;
|
|
}
|
|
}
|
|
|
|
protected override int DoDeactivate()
|
|
{
|
|
if (IsSimul) {
|
|
return E1.OK;
|
|
} else {
|
|
if (_lightType == eLight.ERI) {
|
|
for (int i = 0; i < 4; i++) {
|
|
_light.SetLightValueInternal(i, 0);
|
|
}
|
|
}
|
|
|
|
return (_light as SerialConn).Close();
|
|
}
|
|
}
|
|
|
|
#region Common
|
|
|
|
bool Init(SerialConnConfig conn)
|
|
{
|
|
return _light.InitInternal(conn);
|
|
}
|
|
|
|
public int SetLightValue(List<int> values)
|
|
{
|
|
return _light.SetLightValueInternal(values);
|
|
}
|
|
|
|
public int SetLightValue(int iChannel, int iValue)
|
|
{
|
|
if (IsSimul) {
|
|
return E1.OK;
|
|
}
|
|
return _light.SetLightValueInternal(iChannel, iValue);
|
|
}
|
|
|
|
int OffLight()
|
|
{
|
|
return _light.OffLightInternal();
|
|
}
|
|
|
|
int OffLight(int iChannel)
|
|
{
|
|
return _light.OffLightInternal(iChannel);
|
|
}
|
|
|
|
bool IsPortError()
|
|
{
|
|
return _light.IsPortErrorInternal();
|
|
}
|
|
|
|
bool IsConnected()
|
|
{
|
|
return (_light as SerialConn).IsConnected();
|
|
}
|
|
#endregion
|
|
|
|
#region LvsPnLight
|
|
|
|
int GetMaxValue()
|
|
{
|
|
if (!TypeCheck(eLight.LvsPn)) {
|
|
throw new NotImplementedException();
|
|
}
|
|
return (_light as ILvsPnLight).GetMaxValueInternal();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Util
|
|
private bool TypeCheck(eLight type)
|
|
{
|
|
if (type == _lightType) {
|
|
return true;
|
|
} else {
|
|
Log.E("This method does not support the assigned light type differently.");
|
|
return false;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|