using Aurora.Api; using Hermes; using LightControlCCS_Library; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using VisionCommon; namespace VisionLight { /// /// LightControlCCS_Library 사용 (Socket) /// Inkjet Oledos 향 검증 완료 /// public class Light_CCS : LightBase_Socket { ManagementMain managementMain; /// /// Light CCS 생성자 /// /// Device Id /// Simulation Mode public Light_CCS(string deviceId, bool isSimul) : base(deviceId, isSimul) { DeviceId = deviceId; IsSimul = isSimul; try { managementMain = new ManagementMain(); } catch (Exception ex) { LOG.W("Warning : " + ex.Message, ".ctor"); } } /// /// Light CCS 생성자 /// /// 디바이스 Id public Light_CCS(string deviceId) : base(deviceId) { DeviceId = deviceId; IsSimul = false; try { managementMain = new ManagementMain(); } catch (Exception ex) { LOG.W("Warning : " + ex.Message, ".ctor"); } } private bool CCS_SetValue(int channel, int value) { if (IsSimul) { return true; } return managementMain.SetValue(channel, value); } /// /// Set Level Implement /// /// 레벨 /// 채널 /// protected override eLightResult SetLevelImpl(int level, int channel) { LOG.FuncI(); return CCS_SetValue(channel, level) ? eLightResult.OK : eLightResult.NG; } /// /// Set Off Implement /// /// 채널 /// Light 결과 값 protected override eLightResult SetOffImpl(int channel) { LOG.FuncI(); return SetLevelImpl(0, channel); } /// /// Set On Implement /// /// 채널 /// Light 결과 값 protected override eLightResult SetOnImpl(int channel) { LOG.FuncI(); int level = LightConfig.Channels.Max; if (LastChLevels.Count > channel) { level = LastChLevels[channel]; } return CCS_SetValue(channel, level) ? eLightResult.OK : eLightResult.NG; } /// /// Device Activate /// /// Device Config /// 결과 값 protected override int DoActivate(IDeviceConfig config) { base.SetLightConfig(config as LightConfig); base.InitLastChParams(); var sockConfig = (LightConfig_Socket)LightConfig; IsSimul = EquipAdapter.Instance.EquipMode.IsSimulMode(); bool res = true; if (IsSimul) { res = true; } else { try { res = managementMain.Connect(sockConfig.SocketConnConfig.Address.IpAddress, sockConfig.SocketConnConfig.Address.PortNumber); } catch (Exception ex) { LOG.W("Warning : " + ex.Message, "DoActivate"); res = false; } } if (res) { base.SetOnAllInternal(); // 시작시 모든 조명 On (Default) return E1.OK; } else { return -3000000; } } /// /// Device Deactiavate 될 때 호출 /// /// protected override int DoDeactivate() { base.ClearLastChParams(); if (IsSimul) { return E1.OK; } else { try { return managementMain.DisConnect() ? E1.OK : -3000000; } catch (Exception ex) { LOG.W("Warning : " + ex.Message, "DoDeactivate"); return -3000000; } } } } }