LBAD INPUT 데이터
문자열 처리 보완
This commit is contained in:
parent
45c1de6cc8
commit
3edbc28d3c
@ -87,7 +87,7 @@ namespace AuroraLBAD.Service
|
||||
public Int16 JigNo;
|
||||
}
|
||||
|
||||
public unsafe struct stLBADReportData
|
||||
public unsafe struct stLBADReportData
|
||||
{
|
||||
public fixed byte LotID[40]; // 40byte
|
||||
public fixed byte CellID[40]; // 40byte
|
||||
@ -276,25 +276,6 @@ namespace AuroraLBAD.Service
|
||||
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
|
||||
{
|
||||
int size = Marshal.SizeOf(typeof(T));
|
||||
@ -326,38 +307,21 @@ namespace AuroraLBAD.Service
|
||||
Log.I($"StreamLight LBAD Alarm Status : {LBADAlarmStatus}");
|
||||
break;
|
||||
case MESSAGE_LBAD_MES_REPORT:
|
||||
Log.I($"Received Data : {data}");
|
||||
//byte[] data_byte = BitConverter.GetBytes(data);
|
||||
Log.I($"Received Data");
|
||||
|
||||
if (data is byte[] bytes && bytes.Length > 0)
|
||||
{
|
||||
if (data is byte[] bytes && bytes.Length > 0) {
|
||||
Log.I($"Received Data Size : {bytes.Length}");
|
||||
var replyParsed_LBAD = BytesToLBADReportDataStruct(bytes);
|
||||
unsafe
|
||||
{
|
||||
char[] LotID = new char[40];
|
||||
char[] CellID = new char[40];
|
||||
for (int i=0; i<40; i++)
|
||||
{
|
||||
LotID[i] = (char)bytes[i];
|
||||
}
|
||||
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
|
||||
{
|
||||
Log.E($"Head Number is {replyParsed_LBAD.HeadNum}");
|
||||
}
|
||||
}
|
||||
string LotID_string = Encoding.ASCII.GetString(bytes, 0, 40).TrimEnd('\0');
|
||||
string CellID_string = Encoding.ASCII.GetString(bytes, 40, 40).TrimEnd('\0');
|
||||
short HeadNum = BitConverter.ToInt16(bytes, 80);
|
||||
double AVG = BitConverter.ToDouble(bytes, 82);
|
||||
Log.I($"StreamLight LBAD Report Data (from LBAD to Welder) : LotID {LotID_string}, CellID {CellID_string}");
|
||||
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}");
|
||||
if (HeadNum > 0)
|
||||
LaserPowerByLBAD[HeadNum] = AVG;
|
||||
else
|
||||
Log.E($"Head Number is {HeadNum}");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user