📄 digitalpoweranalystview.cpp
字号:
break;
break;
case 0x80+ 3: /* Return C-Code from an adapter */
/* buffer to the master. */
//
break;
case 0x80+ 4: /* set adapter c-code */
if(m_DCodeDlg.IsDlgShow==TRUE)
m_DCodeDlg.UpdateD(TRUE );
m_ccode=m_DCodeDlg.m_DCodeccode;
//convert_cc_fromx2(&m_ccode);
cc_to_string(&m_ccode, tmpStr,5);
str=_T("40010360050550336570050");//tmpStr;//_T("2001030010102650016460100");
break;
case 0x80+ 5: /* Return C-Code from an adapter */
nStation=0;
nCy=0;
//str=m_AnalysisSetupDlg.m_AnalysisStation1[2];
break;
case 0x80+ 6: /* emulate a keypress */
str=m_SYSTEMSetupDlg.m_SystemSetup[1];
break;
case 0x80+ 7: /* setup station from adapter option */
str=m_AnalysisSetupDlg.m_AnalysisStation1[3];
break;
case 0x80+ 8: /* return current station c-code */
//
break;
case 0x80+ 9: /* send station status */
str=m_AnalysisSetupDlg.m_AnalysisStation1[4];
break;
//===========================================================
case 0x80+ 10: /* set system time */
break;
case 0x80+ 11: /* send detailed display data */
//
break;
case 0x80+ 12: /* send setup # in use at a station */
//
break;
case 0x80+ 13: /* read the security level */
//
case 0x80+ 14: /* receive/display message */
/* two lines received - display the message */
break;
case 0x80+ 15: /* send current station program */
break;
case 0x80+ 16: /* set station program */
str=m_AnalysisSetupDlg.m_AnalysisStation1[4];
break;
case 0x80+ 17: /* send station target capacity */
break;
case 0x80+ 18: /* set station target capacity */
str=m_AnalysisSetupDlg.m_AnalysisStation1[4];
break;
case 0x80+ 19: /* send current station cycle */
break;
case 0x80+ 20: /* enable slave data logging */
str=itoa(m_AnalysisSetupDlg.m_RadioOffOn[1],tmpStr,10);
break;
case 0x80+ 21: /* send battery ready status flag */
break;
case 0x80+ 22: /* send battery present status */
break;
case 0x80+ 23: /* send adapter information */
break;
case 0x80+ 24: /* send adapter present status */
break;
case 0x80+ 25:// L4157 add for battery line test
break;
case 0x80+ 29: /* update bootloader code */
break;
case 0x80+ 32: /* erase flash memory */
break;
case 0x80+ 33: /* Reset the unit (hang it!!!) */
break;
case 0x80+ 34: /* Reset a station */
break;
case 0x80+ 35: /* Put all stations off-line */
/* open the relays */
break;
case 0x80+ 36: /* Send the version information */
break;
case 0x80+ 37: /* get battery service counter info */
//
break;
case 0x80+ 38: /* set battery counter */
str=m_SYSTEMSetupDlg.m_SystemSetup[4];
break;
case 0x80+ 39: /* get adapter c-code name */
//
break;
case 0x80+ 40: /* set adapter c-code name */
str= m_AnalysisSetupDlg.m_AnalysisStation1[9];
break;
case 0x80+ 41: /* get adapter information */
//
break;
case 0x80+ 42: /* set adapter information (production use only) */
str= m_AnalysisSetupDlg.m_AnalysisStation1[10];
break;
case 0x80+ 43: /* get C-Code lock status */
//
break;
case 0x80+ 44: /* set C-Code lock status */
str= m_AnalysisSetupDlg.m_AnalysisStation1[11];
break;
case 0x80+ 45: /* read custom program */
//
break;
case 0x80+ 46: /* set custom program */
str= m_AnalysisSetupDlg.m_AnalysisStation1[12];
break;
case 0x80+ 47: /* check for busy custom program */
//
break;
case 0x80+ 48: /* get custom program name */
//
break;
case 0x80+ 49: /* set custom program name */
str= m_AnalysisSetupDlg.m_AnalysisStation1[14];
break;
case 0x80+ 50: /* get quicktest battery profile data */
break;
case 0x80+ 51: /* set quicktest battery profile data */
break;
case 0x80+ 52: /* set charge optimization */
break;
case 0x80+ 53: /* set automatic ohmtest */
break;
case 0x80+ 54: /* set ohmtest setpoints */
break;
case 0x80+ 55: /* set self-discharge rest duration */
break;
case 0x80+ 56: /* set runtime program parameters */
break;
case 0x80+ 57: /* enable or disable UCC adapter mode */
break;
case 0x80+ 58: /* get QuickLearn data */
break;
case 0x80+ 59:
break;
case 0x80+ 60: /* send status information */
break;
//}
default: /* unsupported command */
break;
}
len=str.GetLength();
strcpy(tmpStr, (LPCTSTR) str);
m_ComPort.WriteToDevice( cmd,nStation,nCy,tmpStr,len);
return 0L;
}
LONG CDigitalPowerAnalystView::OnCommunication(WPARAM ReadBuf, LPARAM BytesRead)
{
CString tmpStr;
long Len= BytesRead;
// memset(m_ComData.buf,0,256);
unsigned char CheckSum =0;
unsigned char cmd= m_ComPort.m_strRXData[0] ;
int nStart=0;
int nEnd=0;
int Arr[3]={0,0,0};
((CMainFrame * )GetParentFrame())->SetStatusPaneText(2,"联机",TRUE);
int j=0;
for(int i=0;i<Len;i++)
{ Arr[ j]++;
//cmd=m_ComPort.m_strRXData[i];
if(m_ComPort.m_strRXData[i]== -128)
{
Arr[ ++j]=0;
}
}
if (j==0)
{
memset(m_ComPort.m_strRXData, 0, 256);
return 0L;
}
do{ memset(m_ComData.buf,0,256);
--j;
Len=Len-Arr[ j];
memcpy(m_ComData.buf,(char *)(&m_ComPort.m_strRXData[Len]),Arr[j]-2);
CheckSum=0;
for(int i=0;i<Arr[j]-2;i++)
{
CheckSum=CheckSum+m_ComData.buf[i];
}
CheckSum=~CheckSum&0x7F;
cmd= m_ComData.buf[0] ;
if(m_SYSTEMSetupDlg.IsDlgShow==TRUE)
tmpStr=m_ComData.LastStruct.Databuf;
else if (m_AnalysisSetupDlg.IsDlgShow==TRUE)
{
m_AnalysisSetupDlg.m_AnalysisStation1[0]=_T("OK");
//m_AnalysisSetupDlg.m_AnalysisStation1[0]+=m_ComPort.m_strRXData;
tmpStr=m_ComData.NextStruct.Databuf;
}
else
tmpStr=m_ComData.NextStruct.Databuf;
// CheckSum=checksum_in( Arr[ j] );
if(CheckSum!=m_ComPort.m_strRXData[Arr[ j]-2 +Len])
return 0L;
int nStationOn=0;
switch(cmd) {
case 0x80+ 1: /* Return Battery ID# */
tmpStr=m_ComData.NextStruct.Databuf;
// if ( tmpStr==_T(""))
// tmpStr="无";
m_AnalysisSetupDlg.m_AnalysisStation1[1]=tmpStr;
m_StationItem[m_ComData.NextStruct.station][6]=tmpStr;
break;
case 0x80+ 2: /* Set Battery ID# */
//OK
break;
case 0x80+ 3: /* Return C-Code from an adapter */
// m_AnalysisSetupDlg.m_AnalysisStation1[2]=tmpStr;
tmpStr=m_ComData.FristStruct.Databuf;
if(tmpStr==_T(""))
OnCommAnaly(0x85, 0);
break;
case 0x80+ 4: /* set adapter c-code */
//OK
if(m_DCodeDlg.IsDlgShow==TRUE)
m_DCodeDlg.UpdateD(TRUE );
((CMainFrame * )GetParentFrame())->SetStatusPaneText(3,"数据修改成功",TRUE);
break;
case 0x80+ 5: /* Return C-Code from an adapter */
if(m_DCodeDlg.IsDlgShow==TRUE)
m_DCodeDlg.UpdateD(TRUE );
m_ccode=m_DCodeDlg.m_DCodeccode;
tmpStr=m_ComData.LastStruct.Databuf;
//m_AnalysisSetupDlg.m_AnalysisStation1[2]=tmpStr;
string_to_cc(&m_ccode, (char *)(LPCTSTR )tmpStr);
convert_cc_tox2(&m_ccode);
m_DCodeDlg.m_DCodeccode=m_ccode;
if(m_DCodeDlg.IsDlgShow==TRUE)
{m_DCodeDlg.UpdateD(FALSE);
m_DCodeDlg.m_Setup.SetCurSel(m_DCodeDlg.m_nCycle-1);
}
if(m_ComData.NextStruct.station<5)
m_StationItem[m_ComData.NextStruct.station][8]=TypeStr1[m_ccode.type];
UpdateData(FALSE);
((CMainFrame * )GetParentFrame())->SetStatusPaneText(3,"数据读取成功",TRUE);
break;
case 0x80+ 6: /* emulate a keypress */
// //OK
break;
case 0x80+ 7: /* setup station from adapter option */
//OK
break;
case 0x80+ 8: /* return current station c-code */
if(m_DCodeDlg.IsDlgShow==TRUE)
m_DCodeDlg.UpdateD(TRUE );
m_ccode=m_DCodeDlg.m_DCodeccode;
tmpStr=m_ComData.NextStruct.Databuf;
//m_AnalysisSetupDlg.m_AnalysisStation1[2]=tmpStr;
string_to_cc(&m_ccode, (char *)(LPCTSTR )tmpStr);
convert_cc_tox2(&m_ccode);
m_DCodeDlg.m_DCodeccode=m_ccode;
if(m_DCodeDlg.IsDlgShow==TRUE)
m_DCodeDlg.UpdateD(FALSE);
((CMainFrame * )GetParentFrame())->SetStatusPaneText(3,"数据读取成功",TRUE);
break;
case 0x80+ 9: /* send station status */
m_AnalysisSetupDlg.m_AnalysisStation1[4]=tmpStr;;
break;
case 0x80+ 10: /* set system time */
break;
case 0x80+ 11: /* send detailed display data */
tmpStr=m_ComData.NextStruct.Databuf;
// m_AnalysisSetupDlg.m_AnalysisStation1[5]=tmpStr;
nEnd= tmpStr.Find('\\', nStart);
m_sProgram[m_ComData.NextStruct.station]=atoi((LPCTSTR) (tmpStr.Mid(nStart,nEnd- nStart)));
if((m_sProgram[m_ComData.NextStruct.station])>17)
m_sProgram[m_ComData.NextStruct.station]=17;
m_StationItem[m_ComData.NextStruct.station][14]=m_sConstantProgram[(m_sProgram[m_ComData.NextStruct.station])%17];
tmpStr=tmpStr.Right(tmpStr.GetLength()-nEnd-1);
nEnd= tmpStr.Find('\\', nStart);
m_nCycleAll[m_ComData.NextStruct.station]=atoi((LPCTSTR) (tmpStr.Mid(nStart,nEnd- nStart)));
if((m_nCycleAll[m_ComData.NextStruct.station])>9)
m_nCycleAll[m_ComData.NextStruct.station]=9;
m_StationItem[m_ComData.NextStruct.station][13]=m_sConstantCycle[m_nCycleAll[m_ComData.NextStruct.station]];
tmpStr=tmpStr.Right(tmpStr.GetLength()-nEnd-1);
for(i=9;i<13;i++)
{
nEnd= tmpStr.Find('\\', nStart);
m_StationItem[m_ComData.NextStruct.station][i]=tmpStr.Mid(nStart,nEnd- nStart);
tmpStr=tmpStr.Right(tmpStr.GetLength()-nEnd-1);
}
OnAdd();
MessageBeep(0xFFFFFFFF);
if(CurStation==m_ComData.NextStruct.station)//CurStation
{
m_StationVorC[CurStation][0]=atol((char *)(LPCTSTR )m_StationItem[CurStation][10]);
m_StationVorC[CurStation][1]=atol((char *)(LPCTSTR )m_StationItem[CurStation][11]);
WriteToPicture(nRecord[m_ComData.NextStruct.station]*6,m_StationVorC[CurStation][0],m_StationVorC[CurStation][1]);
}
OnMouseMove(6, MousePoint) ;
//((CMainFrame *)GetParentFrame( ))->SetStatusPaneText(0,(char *)(LPCTSTR )m_nCycleAll[m_ComData.NextStruct.station]);
break;
case 0x80+ 12: /* send setup # in use at a station */
m_DCodeDlg.m_nCycle=m_ComData.buf[Len-3];
m_DCodeDlg.m_Setup.SetCurSel(m_DCodeDlg.m_nCycle-1);//
m_AnalysisSetupDlg.m_nCycle=m_ComData.buf[Len-3];//atoi(tmpStr);
//m_AnalysisSetupDlg.m_AnalysisStation1[2]= itoa(m_AnalysisSetupDlg.m_nCycle,tmpChar,10);
break;
case 0x80+ 13:
tmpStr=m_ComData.LastStruct.Databuf;/* read the security level */
m_SYSTEMSetupDlg.m_RadioOffOn=atoi((char *)(LPCTSTR )tmpStr);
case 0x80+ 14: /* receive/display message */
/* two lines received - display the message */
break;
case 0x80+ 15: /* send current station program */
//tmpStr=m_ComData.LastStruct.Databuf;
// if ( tmpStr==_T(""))
// tmpStr="无";
m_AnalysisSetupDlg.m_AnalysisStation1[6]=tmpStr;
break;
case 0x80+ 16: /* set station program */
break;
case 0x80+ 17: /* send station target capacity */
//tmpStr=m_ComData.LastStruct.Databuf;
m_AnalysisSetupDlg.m_AnalysisStation1[7]=tmpStr;
break;
case 0x80+ 18: /* set station target capacity */
break;
case 0x80+ 19: /* send current station cycle */
tmpStr=m_ComData.FristStruct.Databuf;
m_AnalysisSetupDlg.m_AnalysisStation1[8]=tmpStr;
break;
case 0x80+ 20: /* enable slave data logging */
m_AnalysisSetupDlg.m_RadioOffOn[1]=atoi(tmpStr);
break;
case 0x80+ 21: /* send battery ready status flag */
m_AnalysisSetupDlg.m_RadioOffOn[2]=atoi((char *)(LPCTSTR )tmpStr);
break;
case 0x80+ 22: /* send battery present status */
tmpStr=m_ComData.NextStruct.Databuf;
nStationOn=atoi((char *)(LPCTSTR )tmpStr);
if(nStationOn)
m_BatteryStatus[m_ComData.NextStruct.station]=1;
else
m_BatteryStatus[m_ComData.NextStruct.station]=0;
break;
case 0x80+ 23: /* send adapter information */
tmpStr=m_ComData.NextStruct.Databuf;
nStationOn=atoi(tmpStr);
if(nStationOn)
m_nSetup[m_ComData.NextStruct.station]=1;
else
m_nSetup[m_ComData.NextStruct.station]=0;
break;
case 0x80+ 24: /* send adapter present status */
tmpStr=m_ComData.LastStruct.Databuf;
nStationOn=atoi(tmpStr);
if(nStationOn&0x08)
m_StationOnLine[4]=1;
else
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -