/* * Copyright (c) 2025 LG Electronics Inc. * SPDX-License-Identifier: LicenseRef-LGE-Proprietary */ using System; using System.Collections.Generic; using Hermes; using System.Linq; using System.Text; using System.Threading.Tasks; namespace VisionLight { /// /// [상시 조명 컨트롤러 - 4CH / 시리얼 통신] /// Range : (0,255) /// Baudrate : 38400 bps /// DataBit : 8 bit /// StopBit : 1 bit /// ParityBit : None /// internal class Light_ERI_E_MINI : LightBase_Serial { public Light_ERI_E_MINI(string deviceId) : base(deviceId) { } protected override eLightResult SetLevelImpl(int level, int channel) { lock (LockThis) { if (SendData_SetLevel(level, channel) == E1.OK) { return eLightResult.OK; } else { return eLightResult.NG; } } } private int SendData_SetLevel(int level, int channel) { try { // ERI 조명은 채널 인덱스가 0부터 시작 string value = String.Format("setbrightness {0:D} {1:D}\r", channel - 1, level); byte[] sendData = Encoding.UTF8.GetBytes(value); SerialConn.Write(sendData, sendData.Length); return E1.OK; } catch (Exception e) { LOG.FuncE(e.Message); } return E1.GENERIC; } protected override eLightResult SetOffImpl(int channel) { lock (LockThis) { if (SendData_SetOnOff(channel, false) == E1.OK) { return eLightResult.OK; } else { return eLightResult.NG; } } } protected override eLightResult SetOnImpl(int channel) { lock (LockThis) { if (SendData_SetOnOff(channel, true) == E1.OK) { return eLightResult.OK; } else { return eLightResult.NG; } } } private int SendData_SetOnOff(int channel, bool on) { try { // ERI 조명은 채널 인덱스가 0부터 시작 string value = String.Format("seton {0:D} {1:G}\r", channel - 1, on ? 1 : 0); byte[] sendData = Encoding.UTF8.GetBytes(value); SerialConn.Write(sendData, sendData.Length); return E1.OK; } catch (Exception e) { LOG.FuncE(e.Message); } return E1.GENERIC; } } }