📄 digitalpoweranalystview.cpp
字号:
m_StationOnLine[4]=0;
if(nStationOn&0x04)
m_StationOnLine[3]=1;
else
m_StationOnLine[3]=0;
if(nStationOn&0x02)
m_StationOnLine[2]=1;
else
m_StationOnLine[2]=0;
if(nStationOn&0x01)
m_StationOnLine[1]=1;
else
m_StationOnLine[1]=0;
break;
case 0x80+ 25:// L4157 add for battery line test
tmpStr=m_ComData.NextStruct.Databuf;
// if(m_ComData.NextStruct.station>4) //?????????????????????????????????????????????///
//return 0L;
// m_ComData.NextStruct.station=m_ComData.NextStruct.station%5;
nEnd= tmpStr.Find('\\', nStart);
m_BatteryID[m_ComData.NextStruct.station]=tmpStr.Mid(nStart,nEnd- nStart);
m_StationItem[m_ComData.NextStruct.station][7]=m_BatteryID[m_ComData.NextStruct.station];
tmpStr=tmpStr.Right(tmpStr.GetLength()-nEnd-1);
nEnd= tmpStr.Find('\\', nStart);
m_sProgram[m_ComData.NextStruct.station]=atoi((LPCTSTR) (tmpStr.Mid(nStart,nEnd- nStart)));
// 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)));
m_StationItem[m_ComData.NextStruct.station][13]=m_sConstantCycle[m_nCycleAll[m_ComData.NextStruct.station]];
tmpStr=tmpStr.Right(tmpStr.GetLength()-nEnd-1);
for(i=1;i<7;i++)
{
nEnd= tmpStr.Find('\\', nStart);
m_StationItem[m_ComData.NextStruct.station][i]=tmpStr.Mid(nStart,nEnd- nStart);
tmpStr=tmpStr.Right(tmpStr.GetLength()-nEnd-1);
}
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 */
tmpStr=m_ComData.LastStruct.Databuf;
m_SYSTEMSetupDlg.m_SystemSetup[4]=tmpStr;;
break;
case 0x80+ 38: /* set battery counter */
break;
case 0x80+ 39: /* get adapter c-code name */
m_AnalysisSetupDlg.m_AnalysisStation1[9]=tmpStr;
break;
case 0x80+ 40: /* set adapter c-code name */
//OK
break;
case 0x80+ 41: /* get adapter information */
tmpStr=m_ComData.NextStruct.Databuf;
m_AnalysisSetupDlg.m_AnalysisStation1[10]=tmpStr;
break;
case 0x80+ 42: /* set adapter information (production use only) */
//OK
break;
case 0x80+ 43: /* get C-Code lock status */
tmpStr=m_ComData.NextStruct.Databuf;
m_AnalysisSetupDlg.m_AnalysisStation1[11]=tmpStr;
break;
case 0x80+ 44: /* set C-Code lock status */
//OK
break;
case 0x80+ 45: /* read custom program */
tmpStr=m_ComData.NextStruct.Databuf;
if ( tmpStr==_T(""))
tmpStr="无";
m_AnalysisSetupDlg.m_AnalysisStation1[12]=tmpStr;
break;
case 0x80+ 46: /* set custom program */
//OK
break;
case 0x80+ 47: /* check for busy custom program */
tmpStr=m_ComData.NextStruct.Databuf;
//m_AnalysisSetupDlg.m_AnalysisStation1[13]=tmpStr;
m_AnalysisSetupDlg.m_RadioOffOn[3]=atoi((char *)(LPCTSTR )tmpStr);
break;
case 0x80+ 48: /* get custom program name */
tmpStr=m_ComData.NextStruct.Databuf;
if ( tmpStr==_T(""))
tmpStr="无";
m_AnalysisSetupDlg.m_AnalysisStation1[13]=atoi((char *)(LPCTSTR )tmpStr);
break;
case 0x80+ 49: /* set custom program name */
//OK
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;
case 0x80+ 61: /* send status information */
tmpStr=m_ComData.LastStruct.Databuf;
// if(m_ComData.NextStruct.station>4) //?????????????????????????????????????????????///
//return 0L;
// m_ComData.NextStruct.station=m_ComData.NextStruct.station%5;
nEnd= tmpStr.Find(',', nStart);
m_EventInfo.sDeviceType=tmpStr.Mid(nStart,nEnd- nStart);
tmpStr=tmpStr.Right(tmpStr.GetLength()-nEnd-1);
nEnd= tmpStr.Find(',', nStart);
m_EventInfo.nStation=atoi((char *)(LPCTSTR)tmpStr.Mid(nStart,nEnd- nStart));
tmpStr=tmpStr.Right(tmpStr.GetLength()-nEnd-1);
nEnd= tmpStr.Find(',', nStart);
m_EventInfo.sBaterryName=tmpStr.Mid(nStart,nEnd- nStart);
tmpStr=tmpStr.Right(tmpStr.GetLength()-nEnd-1);
nEnd= tmpStr.Find(',', nStart);
m_EventInfo.nEventType=tmpStr.Mid(nStart,nEnd- nStart);
InsertVolumn(&m_ListCtrlStation, &m_EventInfo);
break;
case 0x80+ 63: /* send status information */
m_AnalysisSetupDlg.m_AnalysisStation1[0]=_T("系统忙");
m_AnalysisSetupDlg.m_AnalysisStation1[0]+=m_ComPort.m_strRXData;
((CMainFrame * )GetParentFrame())->SetStatusPaneText(3,"系统忙或未处理",TRUE);
break;
//}
default: /* unsupported command */
m_AnalysisSetupDlg.m_AnalysisStation1[0]=_T("ER:");
m_AnalysisSetupDlg.m_AnalysisStation1[0]+=m_ComPort.m_strRXData;
((CMainFrame * )GetParentFrame())->SetStatusPaneText(3,"数据处理不成功",TRUE);
break;
}
if (m_AnalysisSetupDlg.IsDlgShow==TRUE)
m_AnalysisSetupDlg.AnalysisUpdate(FALSE);
else if(m_SYSTEMSetupDlg.IsDlgShow==TRUE)
m_SYSTEMSetupDlg.SystemUpdate(FALSE);
UpdateData(FALSE);
}while (j !=0);
memset(m_ComPort.m_strRXData, 0, 256);
return 0;
}
void CDigitalPowerAnalystView::OnInitialUpdate()
{
m_pSet = &GetDocument()->m_digitalPowerAnalystSet;
CRecordView::OnInitialUpdate();
if(m_ComPort.InitPort(this,m_CommSetup.m_sPort,m_CommSetup.m_sBaud,m_CommSetup.m_nParity,m_CommSetup.m_sDataBits,m_CommSetup.m_nStopBits))
//if(m_ComPort.InitPort(this,1,9600,'N',8,1))
{
m_ComPort.StartMonitoring(); //启动串口监视线程
((CMainFrame * )GetParentFrame())->SetStatusPaneText(1,"串口准备就绪",TRUE);
}
else
{
CString str;
str.Format("COM%d 没有发现,或被其它设备占用",1);
AfxMessageBox(str);
((CMainFrame * )GetParentFrame())->SetStatusPaneText(1,"串口没有准备好",TRUE);
}
InintLst();
m_DCodeDlg.SetOwner(this);
m_SYSTEMSetupDlg.SetOwner(this);
m_AnalysisSetupDlg.SetOwner(this);
m_ComPort.WriteToDevice((char ) 0x98,0,0,"",0);
nTop[0]=0;
nLeft[0]=0;
for(int i=0;i<5;i++)
{nRecord[i]=0;
m_BatteryStatus[i]=1;////////////////////////////////////////
if(i==0)
m_StaticPicture.GetWindowRect(&rect[0]);
else
m_StaticStation[i].GetWindowRect(&rect[i]);
nBottom[i]=rect[i].bottom-nTop[0];
nTop[i]=rect[i].top-nTop[0];
nLeft[i]=rect[i].left-nLeft[0] ;
nRight[i]=rect[i].right -nLeft[0];
}
pBrushClear.CreateSolidBrush(RGB(035,105,35));
rectLcd.CreateRectRgn(0, (nBottom[0]-nTop[0])*2/5-12, rect[0].right-rect[0].left-10, (nBottom[0]-nTop[0])*4/5-38);
m_StaticDataDisp.GetClientRect(&rectPicture);
nTopPicture=rectPicture.top;
nBottomPicture=rectPicture.bottom-rectPicture.top;
nLeftPicture=rectPicture.left ;
nRightPicture=rectPicture.right -nLeftPicture;
penPicture.CreatePen(PS_SOLID,2,RGB(0,255,255));
penPictureV.CreatePen(PS_SOLID,3,RGB(255,0,255));
rectLine.CreateRectRgn(rectPicture.left-2, rectPicture.top -2, rectPicture.right+2, rectPicture.bottom+2 );
// this->Invalidate(TRUE);
oldRect.left=nLeft[0];
oldRect.top =(nBottom[0]-nTop[0])*3/5+5;
oldRect.right=nRight[0];
oldRect.bottom=(nBottom[0]-nTop[0])*1/2-5;
/*
for(i=0;i<100;i++)
{int x;int y;
x=i*4;
y=31.25*i+412.5;
WriteToPicture( x, y);
}*/
OnRecordDelete();
OnStartTimer();
}
void CDigitalPowerAnalystView::OnRecordDelete()
{
CRecordsetStatus status;
while((!m_pSet->IsBOF())&&(!m_pSet->IsEOF()))
{
try {
m_pSet->Delete();
}
catch(CDBException* e) {
AfxMessageBox(e->m_strError);
e->Delete();
m_pSet->MoveFirst(); // lost our place!
UpdateData(FALSE);
return;
}
m_pSet->GetStatus(status);
if (status.m_lCurrentRecord == 0) {
// We deleted last of 2 records
m_pSet->MoveFirst();
}
else {
m_pSet->MoveNext();
}
UpdateData(FALSE);
}
}
/////////////////////////////////////////////////////////////////////////////
// CDigitalPowerAnalystView diagnostics
/////////////////////////////////////////////////////////////////////////////
// CDigitalPowerAnalystView message handlers
void CDigitalPowerAnalystView::OnAnalysisSetup()
{
// TODO: Add your command handler code here
// m_AnalysisSetupDlg.DoModal();
/*
CPropertySheet sheet("Station PropertySheet");
for (int i = 0; i < 4; i++)
{
m_pages[i].Construct(rgID[i]);
sheet.AddPage(&m_pages[i]);
}
sheet.DoModal();*/
CString tmpStr;
// char tmpChar[6];
m_AnalysisSetupDlg.m_nStation=1;
m_AnalysisSetupDlg.m_sCaptionTiltle=_T("分析配置_Station");
// m_AnalysisSetupDlg.m_sCaptionTiltle+=itoa(m_AnalysisSetupDlg.m_nStation,tmpChar,10);
m_AnalysisSetupDlg.IsDlgShow=TRUE;
OnStopTimer();
m_AnalysisSetupDlg.DoModal();
OnStartTimer();
}
void CDigitalPowerAnalystView::OnBatteryCheck()
{
// TODO: Add your command handler code here
}
void CDigitalPowerAnalystView::OnDATAProcess()
{
// TODO: Add your command handler code here
m_DataProcessDlg.IsDlgShow=TRUE;
m_DataProcessDlg.DoModal();
}
void CDigitalPowerAnalystView::OnDeviceSetup()
{
// TODO: Add your command handler code here
m_SYSTEMSetupDlg.IsDlgShow=TRUE;
OnStopTimer();
m_SYSTEMSetupDlg.DoModal();
OnStartTimer();
}
void CDigitalPowerAnalystView::OnSetupSerialPort()
{
// TODO: Add your command handler code here
m_CommSetup.IsDlgShow=TRUE;
OnStopTimer();
if(m_CommSetup.DoModal()==IDOK)
{
m_ComPort.StopComm();
if(m_ComPort.InitPort(this,m_CommSetup.m_sPort,m_CommSetup.m_sBaud,m_CommSetup.m_nParity,m_CommSetup.m_sDataBits,m_CommSetup.m_nStopBits))
{
m_ComPort.StartMonitoring(); //启动串口监视线程
((CMainFrame * )GetParentFrame())->SetStatusPaneText(1,"串口准备就绪",TRUE);
}
else
{
CString str;
str.Format("COM%d 没有发现,或被其它设备占用",m_CommSetup.m_sPort);
AfxMessageBox(str);
((CMainFrame * )GetParentFrame())->SetStatusPaneText(1,"串口没有准备好",TRUE);
}
}
else
{
//m_ComPort.StopComm();
}
OnStartTimer();
}
void CDigitalPowerAnalystView::OnAutoCharge()
{
// TODO: Add your command handler code here
}
void CDigitalPowerAnalystView::OnAutoDischarge()
{
// TODO: Add your command handler code here
}
void CDigitalPowerAnalystView::OnSTATICStation1()
{
// TODO: Add your control notification handler code here
CString tmpStr;
char tmpChar[6];
m_DCodeDlg.m_nStation=1;
m_ComPort.WriteToDevice((char ) 0x8C,m_DCodeDlg.m_nStation,0,"",0);
Sleep(1000);
m_DCodeDlg.m_sCaptionTiltle=_T("分析配置_Station");
m_DCodeDlg.m_sCaptionTiltle+=itoa(m_DCodeDlg.m_nStation,tmpChar,10);
m_DCodeDlg.IsDlgShow=TRUE;
OnStopTimer();//m_ComPort.WriteToDevice((char ) 0x83,01,07,"",0);
m_ComPort.WriteToDevice((char ) 0x88,m_DCodeDlg.m_nStation,0,"",0);
m_DCodeDlg.DoModal();// m_AnalysisSetupDlg
OnStartTimer();
}
void CDigitalPowerAnalystView::OnSTATICStation2()
{
// TODO: Add your control notification handler code here
CString tmpStr;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -