LBAD INPUT 데이터

문자열 처리 보완
This commit is contained in:
최이근 2026-03-10 10:11:59 +09:00
parent 45c1de6cc8
commit 3edbc28d3c

View File

@ -276,25 +276,6 @@ namespace AuroraLBAD.Service
return E1.OK; return E1.OK;
} }
public static unsafe stLBADReportData BytesToLBADReportDataStruct(byte[] bytes)
{
stLBADReportData data = new stLBADReportData();
for (int i=0; i<40; i++)
{
data.LotID[i] = bytes[i];
}
for (int i=0; i<40; i++)
{
data.CellID[i] = bytes[i + 40];
}
data.HeadNum = BitConverter.ToInt16(bytes, 80);
data.AVG = BitConverter.ToDouble(bytes, 82);
return data;
}
public static byte[] StructToBytes<T>(T structure) where T : struct public static byte[] StructToBytes<T>(T structure) where T : struct
{ {
int size = Marshal.SizeOf(typeof(T)); int size = Marshal.SizeOf(typeof(T));
@ -326,38 +307,21 @@ namespace AuroraLBAD.Service
Log.I($"StreamLight LBAD Alarm Status : {LBADAlarmStatus}"); Log.I($"StreamLight LBAD Alarm Status : {LBADAlarmStatus}");
break; break;
case MESSAGE_LBAD_MES_REPORT: case MESSAGE_LBAD_MES_REPORT:
Log.I($"Received Data : {data}"); Log.I($"Received Data");
//byte[] data_byte = BitConverter.GetBytes(data);
if (data is byte[] bytes && bytes.Length > 0) if (data is byte[] bytes && bytes.Length > 0) {
{
Log.I($"Received Data Size : {bytes.Length}"); Log.I($"Received Data Size : {bytes.Length}");
var replyParsed_LBAD = BytesToLBADReportDataStruct(bytes); string LotID_string = Encoding.ASCII.GetString(bytes, 0, 40).TrimEnd('\0');
unsafe string CellID_string = Encoding.ASCII.GetString(bytes, 40, 40).TrimEnd('\0');
{ short HeadNum = BitConverter.ToInt16(bytes, 80);
char[] LotID = new char[40]; double AVG = BitConverter.ToDouble(bytes, 82);
char[] CellID = new char[40]; Log.I($"StreamLight LBAD Report Data (from LBAD to Welder) : LotID {LotID_string}, CellID {CellID_string}");
for (int i=0; i<40; i++) Log.I($"StreamLight LBAD Report Data (from LBAD to Welder) : HeadNum {HeadNum}");
{ Log.I($"StreamLight LBAD Report Data (from LBAD to Welder) : LaserPower_AVG {AVG}");
LotID[i] = (char)bytes[i]; if (HeadNum > 0)
} LaserPowerByLBAD[HeadNum] = AVG;
for (int i=40; i<80; i++)
{
CellID[i-40] = (char)bytes[i];
}
string LotID_string = new string(LotID);
string CellID_string = new string(CellID);
Log.I($"StreamLight LBAD Report Data : LotID({LotID_string}) / CellID({CellID_string})");
Log.I($"StreamLight LBAD Report Data : HeadNum {replyParsed_LBAD.HeadNum}");
Log.I($"StreamLight LBAD Report Data : LaserPower_AVG {replyParsed_LBAD.AVG}");
if (replyParsed_LBAD.HeadNum > 0)
LaserPowerByLBAD[replyParsed_LBAD.HeadNum] = replyParsed_LBAD.AVG;
else else
{ Log.E($"Head Number is {HeadNum}");
Log.E($"Head Number is {replyParsed_LBAD.HeadNum}");
}
}
} }
break; break;
default: default: