operationtooldlg1.cpp
来自「采用文档类方法实现的一种串口通讯协议。可以借鉴参考」· C++ 代码 · 共 2,277 行 · 第 1/4 页
CPP
2,277 行
if ((I_pbyDataS[xyz] & 0x08) == 0x08)
strInf += " high alarm";
if ((I_pbyDataS[xyz] & 0x10) == 0x10)
strInf += " low alarm";
if ((I_pbyDataS[xyz] & 0x20) == 0x20)
strInf += " STEL alarm";
if ((I_pbyDataS[xyz] & 0x40) == 0x40)
strInf += " TWA alarm";
if ((I_pbyDataS[xyz] & 0x80) == 0x80)
strInf += " negative alarm";
if (I_pbyDataS[xyz] == 0)
strInf += "NO";
strInf += "\n";
}
break;
case 0x3C: //0x213C
strInf += "The following sensor is logged:\n\r";
for (xyz = 0; xyz < 8; xyz++)
{
nInstallEnable = (1<<xyz);
if ((I_pbyDataS[0] & nInstallEnable) == nInstallEnable)
{
strInf += "Sensor ";
strLast.Format("%d",(xyz+1));
strInf += strLast + " is logged.\n";
}
}
break;
case 0x3D: //0x213D
if (I_nPacLen >= 3)
{
strInf += "Unit's Calibration Date is: ";
strLast.Format("20%02d-%02d-%02d\n", I_pbyDataS[0],I_pbyDataS[1],I_pbyDataS[2]);
strInf += strLast;
}
break;
default:
break;
}
mf_DispMsg(strInf);
mf_ChangeFormat();
}
void COperationToolDlg::mf_Deal214XProc(BYTE I_byCMDS, short I_nPacLen, BYTE *I_pbyDataS)
{
ASSERT(I_pbyDataS != NULL);
CString strInf;
CString strLast;
strInf = "The Number of data is:\t";
strLast.Format("%d\n\r", I_nPacLen);
strInf += strLast;
switch (I_byCMDS)
{
case 0x40:
strInf += "Battery voltage is:\t";
strLast.Format("%.1fV", (I_pbyDataS[0]/10.0));
strInf += strLast;
break;
case 0x41:
strInf += "Temperature is:\t";
strLast.Format("%d", (I_pbyDataS[0] - 100));
strInf += strLast + MeasureUnit[3]; //append unit
break;
case 0x42:
strInf += "LEL display measurement unit is:\t";
if (I_pbyDataS[0] == 0)
{
strLast = "%LEL";
}
else if (I_pbyDataS[0] == 1)
{
strLast = "%Vol";
}
else
{
strLast = "";
}
strInf += strLast;
break;
case 0x43:
strInf += "Measure type is:\t";
if (I_pbyDataS[0] == 0)
strLast = "Average";
else if (I_pbyDataS[0] == 1)
strLast = "Max";
else
strLast = "";
strInf += strLast;
break;
case 0x44:
strInf += "Average type is:\t";
switch(I_pbyDataS[0])
{
case 0:
strLast = "Moving Average";
break;
case 1:
strLast = "TWA";
break;
case 2:
strLast = "STEL";
break;
default:
strLast = "";
break;
}
strInf += strLast;
break;
case 0x45:
strInf += "Printer Option is:\t";
switch(I_pbyDataS[0])
{
case 0:
strLast = "No";
break;
case 1:
strLast = "On Line Print";
break;
default:
strLast = "";
break;
}
strInf += strLast;
break;
case 0x46:
strInf += "Site ID and User ID is:\t";
strLast.Format("%s\n\r",I_pbyDataS);
strInf += strLast ;
break;
case 0x47:
strInf += "Secure Beep Option is:\t";
switch(I_pbyDataS[0])
{
case 0:
strLast = "OFF";
break;
case 1:
strLast = "ON";
break;
default:
strLast = "";
break;
}
strInf += strLast;
break;
case 0x48:
strInf += "Power-on zero flag is:\t";
switch(I_pbyDataS[0])
{
case 0:
strLast = "Don't Zero";
break;
case 1:
strLast = "Zero";
break;
default:
strLast = "";
break;
}
strInf += strLast;
break;
default:
break;
}
mf_DispMsg(strInf);
mf_ChangeFormat();
}
void COperationToolDlg::mf_Deal215XProc(BYTE I_byCMDS, short I_nPacLen, BYTE *I_pbyDataS)
{
ASSERT(I_pbyDataS != NULL);
CString strInf;
CString strLast;
int nCount = 0;
strInf = "The Number of data is:\t";
strLast.Format("%d\n\r", I_nPacLen);
strInf += strLast;
switch (I_byCMDS)
{
case 0x50: //0x2150
strInf += "Alarm and beep setting is:\n\r";
switch(I_pbyDataS[0])
{
case 0:
strInf += "Alarm : Auto reset.\n\r";
break;
case 1:
strInf += "Alarm : Latch unless manually clear it.\n\r";
break;
default:
break;
}
strInf += "\n\r";
switch(I_pbyDataS[1])
{
case 0:
strInf += "Buzzer&Light : Both ON.";
break;
case 1:
strInf += "Buzzer&Light : Light ON.";
break;
case 2:
strInf += "Buzzer&Light : Both OFF.";
break;
default:
break;
}
break;
case 0x51: //0x2151
strInf += "BackLight basic information is:\n\r";
switch(I_pbyDataS[0])
{
case 0:
strInf += "BackLightOption : Auto\n\r";
break;
case 1:
strInf += "BackLightOption : manaul\n\r";
break;
default:
break;
}
strInf += "BackLightLevel:\t";
strLast.Format("%d\n\r", I_pbyDataS[1]);
strInf += strLast;
strInf += "BackLightTime:\t";
strLast.Format("%d\n\r", I_pbyDataS[2]);
strInf += strLast;
break;
case 0x52: //0x2152
strInf += "The slave Clock time is:\t";
strLast.Format("20%02d-%02d-%02d %02d:%02d\n\r", I_pbyDataS[0], I_pbyDataS[1],
I_pbyDataS[2], I_pbyDataS[3], I_pbyDataS[4]);
strInf += strLast;
break;
case 0x53: //0x2153
strInf += "Dilution Ratio is:\t";
strLast.Format("%d\n\r", I_pbyDataS[0]);
strInf += strLast;
break;
case 0x54: //0x2154
strInf = "Host ID and Slave ID is:\n\r";
strInf += "Host ID :\t";
strLast.Format("0X%X\n\r", I_pbyDataS[0]);
strInf += strLast;
strInf += "Slave ID :\t";
strLast.Format("0X%X\n\r", I_pbyDataS[1]);
strInf += strLast;
break;
case 0x55: //0x2155
strInf += "Language is:\t";
switch(I_pbyDataS[0])
{
case 0:
strInf += "English";
break;
case 1:
strInf += "Spanish";
break;
case 2:
strInf += "French";
break;
case 3:
strInf += "Germany";
break;
default:
break;
}
break;
case 0x56: //0x2156
strInf += "The Last Run Time is(min):\t";
nCount = I_pbyDataS[0] << 8;
nCount += I_pbyDataS[1];
strLast.Format("%d\n\r", nCount);
strInf += strLast;
break;
case 0x57: //0x2157
strInf += "The LCD contract is:\t";
strLast.Format("%d\n\r", I_pbyDataS[0]);
strInf += strLast + " Level";
break;
case 0x58: //0x2158
switch(I_pbyDataS[0])
{
case 0:
strInf += "Pump speed is: High\n\r";
break;
case 1:
strInf += "Pump speed is: Low\n\r";
break;
default:
break;
}
strLast.Format("%d\n\r", I_pbyDataS[1]);
strInf += "Duty Cycle :" + strLast;
break;
case 0x59: //0x2159
strLast.Format("%s\n\r", I_pbyDataS);
strInf += strLast;
break;
case 0x5A: //0x215A
switch(I_pbyDataS[0])
{
case 0:
strInf += "No change allowed\n\r";
break;
case 1:
strInf += "Need password to change setting\n\r";
break;
case 2:
strInf += "No password needed to change setting\n\r";
break;
default:
strInf += "\n\r";
break;
}
break;
case 0x5B: //0x215B
strInf += "The Warm up Time is(min):\t";
nCount = I_pbyDataS[0] ;
// nCount += I_pbyDataS[1];
strLast.Format("%d\n\r", nCount);
strInf += strLast;
break;
case 0x5C: //0x215C
strInf += "BackLight is:\t";
break;
case 0x5D: //0x215D
strInf += "The Calibration Time is(min):\t";
nCount = I_pbyDataS[0] << 8;
nCount += I_pbyDataS[1];
strLast.Format("%d\n\r", nCount);
strInf += strLast;
break;
case 0x5E: //0x215E
switch(I_pbyDataS[0])
{
case 0:
strInf += "Vibrator is: OFF\n\r";
break;
case 1:
strInf += "Vibrator is: ON\n\r";
break;
default:
break;
}
break;
case 0x60:
strInf += "Parameters on VOC 10.6eV is:\n\r";
if (I_nPacLen >= 6)
{
strLast.Format("%d\n\r", I_pbyDataS[0]);
strInf += "VOC6 Calibration Index: " + strLast;
strLast.Format("%d\n\r", I_pbyDataS[1]);
strInf += "VOC6 Measurement Index: " + strLast;
nCount = I_pbyDataS[2] << 8;
nCount += I_pbyDataS[3];
strLast.Format("%d\n\r", nCount);
strInf += "VOC6 Response Factor: " + strLast;
nCount = I_pbyDataS[4] << 8;
nCount += I_pbyDataS[5];
strLast.Format("%d\n\r", nCount);
strInf += "VOC6 Custom factor: " + strLast;
}
else
{
strInf += "Data Error\n\r";
}
break;
case 0x61:
strInf += "Parameters on VOC 11.7eV is:\n\r";
if (I_nPacLen >= 6)
{
strLast.Format("%d\n\r", I_pbyDataS[0]);
strInf += "VOC7 Calibration Index: " + strLast;
strLast.Format("%d\n\r", I_pbyDataS[1]);
strInf += "VOC7 Measurement Index: " + strLast;
nCount = I_pbyDataS[2] << 8;
nCount += I_pbyDataS[3];
strLast.Format("%d\n\r", nCount);
strInf += "VOC7 Response Factor: " + strLast;
nCount = I_pbyDataS[4] << 8;
nCount += I_pbyDataS[5];
strLast.Format("%d\n\r", nCount);
strInf += "VOC7 Custom factor: " + strLast;
}
else
{
strInf += "Data Error\n\r";
}
break;
case 0x62:
strInf += "Parameters on LEL is:\n\r";
if (I_nPacLen >= 6)
{
strLast.Format("%d\n\r", I_pbyDataS[0]);
strInf += "LEL Calibration Index: " + strLast;
strLast.Format("%d\n\r", I_pbyDataS[1]);
strInf += "LEL Measurement Index: " + strLast;
nCount = I_pbyDataS[2] << 8;
nCount += I_pbyDataS[3];
strLast.Format("%d\n\r", nCount);
strInf += "LEL Response Factor: " + strLast;
nCount = I_pbyDataS[4] << 8;
nCount += I_pbyDataS[5];
strLast.Format("%d\n\r", nCount);
strInf += "LEL Custom factor: " + strLast;
}
else
{
strInf += "Data Error\n\r";
}
break;
case 0x63: //0x2163
strInf = "abyDataLog method and time is:\n\r";
if (I_nPacLen >= 2)
{
switch(I_pbyDataS[0])
{
case 0x0:
strInf += "LogType: Auto(log data when power on)";
break;
case 0x1:
strInf += "LogType: Manual(set how long to log )";
break;
case 0x2:
strInf += "LogType: Periodic(log data between the start and stop time)";
break;
default:
strInf += "LogType: ";
break;
}
strInf += "\n\r";
if (I_pbyDataS[1] == 0)
{
strInf += "stop abyDataLog when memory is full";
}
else
{
strInf += "wrap around the abyDataLog when memory is full";
}
strInf += "\n\r";
}
break;
case 0x64: //0x2164
if (I_nPacLen ==2)
{
nCount = I_pbyDataS[0] << 8;
nCount += I_pbyDataS[1];
strLast.Format("%d\n\r",nCount);
strInf += "Data logged unInterval is:" + strLast;
}
else
{
strInf += "Data Error\n\r";
}
break;
case 0x65: //0x2165
break;
default:
break;
}
mf_DispMsg(strInf);
mf_ChangeFormat();
}
void COperationToolDlg::mf_Deal218XProc(BYTE I_byCMDS, short I_nPacLen, BYTE *I_pbyDataS)
{
ASSERT(I_pbyDataS != NULL);
CString strInf;
CString strLast;
int xyz=0;
long nCount = 0;
BYTE byFinishFlag = 1; //finish falg
BYTE byEventID = 0; //Event ID
UINT unPacketIndex = 0; //Packet Index
short nHeader = 0; //nHeader flag; for example: 0xFDFD
CByteArray abyDataLog; //read abyDataLog
BYTE abyDataS[VERPACKETMAX] = "";
short nParaCount;
int nRollCount = 1;
strInf = "The Number of data is:\t";
strLast.Format("%d\n\r",I_nPacLen);
strInf += strLast;
switch (I_byCMDS)
{
case 0x80:
strInf += "Events Number is:\t";
nCount = I_pbyDataS[0] << 8;
nCount += I_pbyDataS[1] ;
strLast.Format("%d\n\r", nCount);
strInf += strLast;
break;
case 0x81:
byEventID = I_pbyDataS[0];
byFinishFlag = I_pbyDataS[1];
unPacketIndex = I_pbyDataS[2] << 8;
unPacketIndex += I_pbyDataS[3];
//not complete
break;
case 0x83:
strInf += "Events data size is:\t";
nCount = I_pbyDataS[0] << 24;
nCount += I_pbyDataS[1] << 16;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?