2026-06-05 13:44:39 +09:00

74 lines
2.7 KiB
C#

using Aurora.Api.Devices;
using Hermes;
using System;
using System.Runtime.Remoting.Channels;
using System.Text;
using System.Windows.Interop;
namespace VisionLight {
/// <summary>
/// [상시 조명 컨트롤러 - 4CH / 시리얼 통신]
/// Range : (0,1023)
/// Baudrate : 19200 or 57600 bps
/// DataBit : 8 bit
/// StopBit : 1 bit
/// ParityBit : None
/// </summary>
public class Light_LVS_PT0405 : Light_LVS_PT {
/// <summary>
/// Light LVS PT0405 생성자
/// </summary>
/// <param name="deviceId">디바이스 ID</param>
public Light_LVS_PT0405(string deviceId) : base(deviceId) {
DeviceId = deviceId;
}
internal override byte[] CreateSetOnReqMsg(int channel) {
string msg = "";
if (channel != -1) {
// :1U11[CR][LF] -> 1번 채널 켜기
msg = string.Format("{0}{1}{2}{3:D1}{4}{5}{6}",
":", "1", "U", channel, "1", "\r", "\n");
}
else {
// :1O1111[CR][LF] -> 모든 채널 켜기
msg = string.Format("{0}{1}{2}{3}{4}{5}{6}{7}{8}",
":", "1", "O", "1", "1", "1", "1", "\r", "\n");
}
return Encoding.UTF8.GetBytes(msg);
}
internal override byte[] CreateSetOffReqMsg(int channel) {
string msg = "";
if (channel != -1) {
// :1U40[CR][LF] -> 4번 채널 끄기
msg = string.Format("{0}{1}{2}{3:D1}{4}{5}{6}",
":", "1", "U", channel, "0", "\r", "\n");
}
else {
// :1O0000[CR][LF] -> 모든 채널 끄기
msg = string.Format("{0}{1}{2}{3}{4}{5}{6}{7}{8}",
":", "1", "O", "0", "0", "0", "0", "\r", "\n");
}
return Encoding.UTF8.GetBytes(msg);
}
internal override byte[] CreateSetLevelReqMsg(int level, int channel) {
string msg = "";
if (channel != -1) {
// :130999[CR][LF] -> 3번 채널 밝기 999로 설정
msg = string.Format("{0}{1}{2:D1}{3:D4}{4}{5}",
":", "1", channel, level, "\r", "\n");
}
else {
// :110200,0200,0200,0200[CR][LF] -> 모든 채널 밝기 200으로 설정
msg = string.Format("{0}{1}{2}{3:D4}{4}{5:D4}{6}{7:D4}{8}{9:D4}{10}{11}",
":", "1", "1", level, ",", level, ",", level, ",", level, "\r", "\n");
}
return Encoding.UTF8.GetBytes(msg);
}
}
}