📄 dk20dieselizedynamotordlg.cpp
字号:
if (fValue <=20&&fValue>=4)
{
switch(iCount )
{
case 0://5公斤
case 5:
case 4:
case 6:
case 7:
fValue = fValue-1 ;
break;
case 1://2公斤
fValue = fValue-1 ;
break;
case 2:
case 3: //10公斤
fValue = fValue-1 ;
break;
}
}
else
{
fValue=0;
}
moudle[7].vcorValue[iCount].iCurrentvalue = fValue ;
iCount++ ;
}
strData2 = _T("") ;
}
else
TRACE(_T("不正常6\r\n ")) ;
//7017-2
strData2 = "";
ZeroMemory(byteArray2,20) ;
byteArray2[0] ='#' ;
byteArray2[1] ='0' ;
byteArray2[2] ='3' ;
byteArray2[3] =0x0D ;
m_pSerial2->WritePort((char*)byteArray2 ,4) ;
//等待N秒 接收数据
m_pSerial2->WaitForResponse(strData2 , WAITDELAY) ;
//strData2=">+10+15+12+17+18+19+20+11"+(CString)'\r';
if (!strData2.IsEmpty() && strData2.Left(1)==_T(">") &&
strData2.Right(1)==_T("\r"))
{
strData2 = strData2.Right(strData2.GetLength()-1) ;
int iFind = strData2.FindOneOf(_T("\r")) ;
strData2 = strData2.Left(iFind ) ;
//排除-号
iFind = strData2.FindOneOf(_T("-")) ;
while (iFind != -1)
{
strData2.SetAt(iFind , '+') ;
iFind = strData2.FindOneOf(_T("-")) ;
}
iFind = strData2.FindOneOf(_T("+")) ;
if (-1 == iFind)
iFind = strData2.FindOneOf(_T("-")) ;
int iCount = 0 ; //有几个数据
while (iFind != -1&& iCount<6)
{
CString strResult ;
bool bZ = 1 ; //是否正数
iFind = strData2.FindOneOf(_T("+")) ;
if (-1 == iFind)
{
iFind = strData2.FindOneOf(_T("-")) ;
bZ = 0 ;
}
strData2 = strData2.Right(strData2.GetLength()-1) ;
int iFind2 = strData2.FindOneOf(_T("+")) ;
if (-1 == iFind2)
iFind2 = strData2.FindOneOf(_T("-")) ;
if (iFind2 != -1)
{
strResult = strData2.Mid(iFind, iFind2 - iFind) ;
}
else
{
strResult= strData2 ;
iFind2 = 0;
iFind = -1 ;
}
strData2 = strData2.Right(strData2.GetLength() - iFind2) ;
float fValue = atof(strResult) ;
if (!bZ)
fValue = -fValue ;
if (fValue <=20&&fValue>=4)
{
switch(iCount )
{
case 0://5公斤
case 5:
case 4:
fValue = fValue-1 ;
break;
case 1://2公斤
fValue = fValue-1 ;
break;
case 2:
case 3: //10公斤
fValue = fValue-1 ;
break;
}
}
else
{
fValue=0;
}
moudle[8].vcorValue[iCount].iCurrentvalue = fValue ;
iCount++ ;
}
strData2 = _T("") ;
}
else
TRACE(_T("不正常7\r\n ")) ;
}
void Send7017t()
{
//7017-1
strData3 = "";
ZeroMemory(byteArray3,20) ;
byteArray3[0] ='#' ;
byteArray3[1] ='0' ;
byteArray3[2] ='2' ;
byteArray3[3] =0x0D ;
m_pSerial3->WritePort((char*)byteArray3 ,4) ;
//等待N秒 接收数据
m_pSerial3->WaitForResponse(strData3 , WAITDELAY) ;
//strData3=">+10+15+12+17+18+19+20+11"+(CString)'\r';
if (!strData3.IsEmpty() && strData3.Left(1)==_T(">") &&
strData3.Right(1)==_T("\r"))
{
strData3 = strData3.Right(strData3.GetLength()-1) ;
int iFind = strData3.FindOneOf(_T("\r")) ;
strData3 = strData3.Left(iFind ) ;
//排除-号
iFind = strData3.FindOneOf(_T("-")) ;
while (iFind != -1)
{
strData3.SetAt(iFind , '+') ;
iFind = strData3.FindOneOf(_T("-")) ;
}
iFind = strData3.FindOneOf(_T("+")) ;
if (-1 == iFind)
iFind = strData3.FindOneOf(_T("-")) ;
int iCount = 0 ; //有几个数据
while (iFind != -1 && iCount<8)
{
CString strResult ;
bool bZ = 1 ; //是否正数
iFind = strData3.FindOneOf(_T("+")) ;
if (-1 == iFind)
{
iFind = strData3.FindOneOf(_T("-")) ;
bZ = 0 ;
}
strData3 = strData3.Right(strData3.GetLength()-1) ;
int iFind2 = strData3.FindOneOf(_T("+")) ;
if (-1 == iFind2)
iFind2 = strData3.FindOneOf(_T("-")) ;
if (iFind2 != -1)
{
strResult = strData3.Mid(iFind, iFind2 - iFind) ;
}
else
{
strResult= strData3 ;
iFind2 = 0;
iFind = -1 ;
}
strData3 = strData3.Right(strData3.GetLength() - iFind2) ;
float fValue = atof(strResult) ;
if (!bZ)
fValue = -fValue ;
if (fValue <=20 && fValue>=4)
{
switch(iCount )
{
case 0://5公斤
case 5:
case 4:
case 6:
case 7:
fValue = fValue-1 ;
break;
case 1://2公斤
fValue = fValue-1;
break;
case 2:
case 3: //10公斤
fValue = fValue-1 ;
break;
}
}
else
{
fValue=0;
}
moudle[12].vcorValue[iCount].iCurrentvalue = fValue ;
iCount++ ;
}
strData3 = _T("") ;
}
else
TRACE(_T("不正常6\r\n ")) ;
//7017-2
strData3 = "";
ZeroMemory(byteArray3,20) ;
byteArray3[0] ='#' ;
byteArray3[1] ='0' ;
byteArray3[2] ='3' ;
byteArray3[3] =0x0D ;
m_pSerial3->WritePort((char*)byteArray3 ,4) ;
//等待N秒 接收数据
m_pSerial3->WaitForResponse(strData3 , WAITDELAY) ;
//strData3=">+10+15+12+17+18+19+20+11"+(CString)'\r';
if (!strData3.IsEmpty() && strData3.Left(1)==_T(">") &&
strData3.Right(1)==_T("\r"))
{
strData3 = strData3.Right(strData3.GetLength()-1) ;
int iFind = strData3.FindOneOf(_T("\r")) ;
strData3 = strData3.Left(iFind ) ;
//排除-号
iFind = strData3.FindOneOf(_T("-")) ;
while (iFind != -1)
{
strData3.SetAt(iFind , '+') ;
iFind = strData3.FindOneOf(_T("-")) ;
}
iFind = strData3.FindOneOf(_T("+")) ;
if (-1 == iFind)
iFind = strData3.FindOneOf(_T("-")) ;
int iCount = 0 ; //有几个数据
while (iFind != -1&&iCount<6)
{
CString strResult ;
bool bZ = 1 ; //是否正数
iFind = strData3.FindOneOf(_T("+")) ;
if (-1 == iFind)
{
iFind = strData3.FindOneOf(_T("-")) ;
bZ = 0 ;
}
strData3 = strData3.Right(strData3.GetLength()-1) ;
int iFind2 = strData3.FindOneOf(_T("+")) ;
if (-1 == iFind2)
iFind2 = strData3.FindOneOf(_T("-")) ;
if (iFind2 != -1)
{
strResult = strData3.Mid(iFind, iFind2 - iFind) ;
}
else
{
strResult= strData3 ;
iFind2 = 0;
iFind = -1 ;
}
strData3 = strData3.Right(strData3.GetLength() - iFind2) ;
float fValue = atof(strResult) ;
if (!bZ)
fValue = -fValue ;
if (fValue <=20&&fValue>=4)
{
switch(iCount )
{
case 0://5公斤
case 5:
case 4:
fValue = fValue-1 ;
break;
case 1://2公斤
fValue = fValue-1 ;
break;
case 2:
case 3: //10公斤
fValue = fValue-1 ;
break;
}
}
else
{
fValue=0;
}
moudle[13].vcorValue[iCount].iCurrentvalue = fValue ;
iCount++ ;
}
strData3 = _T("") ;
}
else
TRACE(_T("不正常7\r\n ")) ;
}
void Send7018f()
{
strData1 = "";
ZeroMemory(byteArray1,20) ;
byteArray1[0] ='#' ;
byteArray1[1] ='0' ;
byteArray1[2] ='4' ;
byteArray1[3] =0x0D ;
m_pSerial1->WritePort((char*)byteArray1 ,4) ;
//等待N秒 接收数据
m_pSerial1->WaitForResponse(strData1 , WAITDELAY) ;
//strData1=">+10+15+12+17+18+19+20+11+25+60"+(CString)'\r';
if (!strData1.IsEmpty() && strData1.Left(1)==_T(">") &&
strData1.Right(1)==_T("\r"))
{
strData1 = strData1.Right(strData1.GetLength()-1) ;
int iFind = strData1.FindOneOf(_T("\r")) ;
strData1 = strData1.Left(iFind ) ;
//排除-号
iFind = strData1.FindOneOf(_T("-")) ;
while (iFind != -1)
{
strData1.SetAt(iFind , '+') ;
iFind = strData1.FindOneOf(_T("-")) ;
}
iFind = strData1.FindOneOf(_T("+")) ;
if (-1 == iFind)
iFind = strData1.FindOneOf(_T("-")) ;
int iCount = 0 ; //有几个数据
while (iFind != -1)
{
CString strResult ;
bool bZ = 1 ; //是否正数
iFind = strData1.FindOneOf(_T("+")) ;
if (-1 == iFind)
{
iFind = strData1.FindOneOf(_T("-")) ;
bZ = 0 ;
}
strData1 = strData1.Right(strData1.GetLength()-1) ;
int iFind2 = strData1.FindOneOf(_T("+")) ;
if (-1 == iFind2)
iFind2 = strData1.FindOneOf(_T("-")) ;
if (iFind2 != -1)
{
strResult = strData1.Mid(iFind, iFind2 - iFind) ;
}
else
{
strResult= strData1 ;
iFind2 = 0;
iFind = -1 ;
}
strData1 = strData1.Right(strData1.GetLength() - iFind2) ;
float fValue = atof(strResult) ;
if (!bZ)
fValue = -fValue ;
moudle[1].vcorValue[iCount].iCurrentvalue = fValue + fTEMP1 ;
iCount++ ;
}
strData1 = _T("") ;
}
else
TRACE(_T("不正常8\r\n ")) ;
}
void Send7018s()
{
strData2 = "";
ZeroMemory(byteArray2,20) ;
byteArray2[0] ='#' ;
byteArray2[1] ='0' ;
byteArray2[2] ='4' ;
byteArray2[3] =0x0D ;
m_pSerial2->WritePort((char*)byteArray2 ,4) ;
//等待N秒 接收数据
m_pSerial2->WaitForResponse(strData2 , WAITDELAY) ;
//strData2=">+10+15+12+17+18+19+20+11+25+60"+(CString)'\r';
if (!strData2.IsEmpty() && strData2.Left(1)==_T(">") &&
strData2.Right(1)==_T("\r"))
{
strData2 = strData2.Right(strData2.GetLength()-1) ;
int iFind = strData2.FindOneOf(_T("\r")) ;
strData2 = strData2.Left(iFind ) ;
//排除-号
iFind = strData2.FindOneOf(_T("-")) ;
while (iFind != -1)
{
strData2.SetAt(iFind , '+') ;
iFind = strData2.FindOneOf(_T("-")) ;
}
iFind = strData2.FindOneOf(_T("+")) ;
if (-1 == iFind)
iFind = strData2.FindOneOf(_T("-")) ;
int iCount = 0 ; //有几个数据
while (iFind != -1)
{
CString strResult ;
bool bZ = 1 ; //是否正数
iFind = strData2.FindOneOf(_T("+")) ;
if (-1 == iFind)
{
iFind = strData2.FindOneOf(_T("-")) ;
bZ = 0 ;
}
strData2 = strData2.Right(strData2.GetLength()-1) ;
int iFind2 = strData2.FindOneOf(_T("+")) ;
if (-1 == iFind2)
iFind2 = strData2.FindOneOf(_T("-")) ;
if (iFind2 != -1)
{
strResult = strData2.Mid(iFind, iFind2 - iFind) ;
}
else
{
strResult= strData2 ;
iFind2 = 0;
iFind = -1 ;
}
strData2 = strData2.Right(strData2.GetLength() - iFind2) ;
float fValue = atof(strResult) ;
if (!bZ)
fValue = -fValue ;
moudle[6].vcorValue[iCount].iCurrentvalue = fValue + fTEMP2;
iCount++ ;
}
strData2 = _T("") ;
}
else
TRACE(_T("不正常9\r\n ")) ;
}
void Send7018t()
{
strData3 = "";
ZeroMemory(byteArray3,20) ;
byteArray3[0] ='#' ;
byteArray3[1] ='0' ;
byteArray3[2] ='4' ;
byteArray3[3] =0x0D ;
m_pSerial3->WritePort((char*)byteArray3 ,4) ;
//等待N秒 接收数据
m_pSerial3->WaitForResponse(strData3 , WAITDELAY) ;
//strData3=">+10+15+12+17+18+19+20+11+25+60"+(CString)'\r';
if (!s
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -