📄 reportdlg.cpp
字号:
subItem++;
m_ListReport.SetItemText(i,subItem,tmp);
if (iGAFR!=pGpioSum[i].GAFR)
{
swprintf(tmp,_T("*%d / %d"),pGpioSum[i].GAFR,iGAFR);
isError = TRUE;
}
else
{
swprintf(tmp,_T("%d"),iGAFR);
}
subItem++;
m_ListReport.SetItemText(i,subItem,tmp);
subItem++;
m_ListReport.SetItemText(i,subItem,pGpioSum[i].descript);
DWORD imgIndex = 0;
if((pGpioSum[i].Disable==0) &&( iGPLR!=pGpioSum[i].GPLR || iGPDR!=pGpioSum[i].GPDR || iGAFR!=pGpioSum[i].GAFR ))
{
//与预设不符
imgIndex = 1;
}
LVITEM item;
item.mask = LVIF_IMAGE;
item.iImage = imgIndex;
item.iItem = i;
item.iSubItem = 0;
m_ListReport.SetItem(&item);
//wsprintf(szOut,TEXT("%3d L%d D%d F%d %s"),i,iGPLR,iGPDR,iGAFR,pGpioSum[i].descript);
}
else
{
//wsprintf(szOut,TEXT("%3d L%c D%c F%c %s"),i,'?','?','?',pGpioSum[i].descript);
AfxMessageBox(_T("读取GPIO状态失败!"));
break;
}
}
//if(g_pGPIORegs!=NULL)
// MmUnmapIoSpace (g_pGPIORegs,0x400);
// m_ListReport.SetHotItem(index);LVIS_ACTIVATING |LVIS_DROPHILITED|LVIS_DROPHILITED|
m_ListReport.EnsureVisible(curSelItem,TRUE);
m_ListReport.SetFocus();
m_ListReport.SetItemState( curSelItem,
LVIS_FOCUSED | LVIS_SELECTED,
LVIS_SELECTED | LVIS_FOCUSED );
//m_ListReport.SetItemState(index, LVIS_SELECTED, LVIS_SELECTED);
//m_ListReport.SetScrollInfo(SB_VERT,&scrollInfo);
//m_ListReport.SetScrollPos(SB_VERT,scrollInfo.nPos);
return TRUE;
}
void CReportDlg::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
CRect rectMain;
GetWindowRect(&rectMain);
ScreenToClient(rectMain);
CRect rect;
m_ListReport.MoveWindow(rectMain.left+1,rectMain.top+1,rectMain.Width() -2,rectMain.Height()-2);
m_ListReport.GetWindowRect(&rect);
ScreenToClient(rect);
// TODO: Add your message handler code here
}
void CReportDlg::OnGpiomodify()
{
//获得选中项
DWORD selCount = m_ListReport.GetSelectedCount();
DWORD selItem = 0;
POSITION pos ;
if(selCount < 1)
{
return;
//goto Exit;
}
pos = m_ListReport.GetFirstSelectedItemPosition();
if (pos == NULL)
{
return;
//goto Exit;
}
else
{
while (pos)
{
selItem = m_ListReport.GetNextSelectedItem(pos);
}
}
//编辑
CString sGPLR = (m_ListReport.GetItemText(selItem,1)).Right(1);
CString sGPDR = (m_ListReport.GetItemText(selItem,2)).Right(3);
CString sGFAR = (m_ListReport.GetItemText(selItem,3)).Right(1);
DWORD GPLR=0,GPDR=0,GFAR=0;
if (sGPLR.Compare(_T("H")) == 0)
{
GPLR =1;
}
else
{
GPLR =0;
}
if (sGPDR.Compare(_T("OUT")) == 0)
{
GPDR =1;
}
else
{
GPDR =0;
}
swscanf(sGPDR.GetBuffer(),TEXT("%d"),&GFAR);
CGpioEditDlg dlg(GPLR,GPDR,GFAR,selItem);
dlg.DoModal();
return;
}
void CReportDlg::OnGpiohelp()
{
// TODO: Add your command handler code here
TCHAR helpGpio[]=_T("L 表示GPIO口低位 \r\nH 表示GPIO口高位\r\nIN表示GPIO口输入\r\nOUT表示GPIO口输出\r\n\
加*表示数据与预设的不同,如果为GAFR,/前表示预设数据,/后表示当前数据");
AfxMessageBox(helpGpio);
}
void CReportDlg::OnDestroy()
{
CDialog::OnDestroy();
if(g_pGPIORegs!=NULL)
MmUnmapIoSpace ((PVOID)g_pGPIORegs,0x400);
// TODO: Add your message handler code here
}
LRESULT CReportDlg::onGpioEdit(WPARAM wParam, LPARAM lParam )
{
DWORD GPDR = wParam & 0x1;
DWORD GPLR = (wParam >>4) & 0x1;
DWORD GAFR = lParam & 0xFF;
DWORD index = (lParam >> 8) ;
curSelItem = index;
GPIOWrite(g_pGPIORegs,index,GPLR);
GPIOSet(g_pGPIORegs,index,GPDR,GAFR);
DisplayGPIOInfo();
return 1;
}
void CReportDlg::DispWakeSleepInfo()
{
#if 0
WCHAR state[1024] = {0};
LPWSTR pState = &state[0];
DWORD dwBufChars = (sizeof(state) / sizeof(state[0]));
DWORD dwStateFlags = 0;
DWORD dwErr;
dwErr = GetSystemPowerState(pState, dwBufChars, &dwStateFlags);
if (ERROR_SUCCESS != dwErr) {
RETAILMSG(1, (TEXT("PMGET!GetSystemPowerState:ERROR:%d\n"), dwErr));
} else
{
RETAILMSG(1, (TEXT("PMGET! System Power state is '%s', flags 0x%08x\n"), state, dwStateFlags));
}
#endif
static BSP_ARGS *pBSP_Args = NULL;
static RESUMEDATA currentData = {0};
UINT8 tempIndex = 0; //所有的记录都从1开始,当前序号为0表示没有任何记录
PHYSICAL_ADDRESS ioPhysicalBase = { BSP_ARGS_PA, 0 };
pBSP_Args = (BSP_ARGS *)MmMapIoSpace(ioPhysicalBase, sizeof(*pBSP_Args), FALSE);
if (pBSP_Args == NULL)
{
printf("pBSP_Args == NULL\r\n");
}
else
{
printf(" all wake_reason_index = %d\r\n",pBSP_Args->wake_reason_index);
if (pBSP_Args->wake_reason_index > MAX_LOGED_RESUME_REASON)
{
pBSP_Args->wake_reason_index = 0;
}
currentData.nextindex = pBSP_Args->wake_reason_index;
tempIndex = 1;
while (tempIndex <= currentData.nextindex )
{
currentData.wakereason[tempIndex].wake_pedr = pBSP_Args->wake_reason[tempIndex].wake_pedr;
currentData.wakereason[tempIndex].wake_pksr = pBSP_Args->wake_reason[tempIndex].wake_pksr;
currentData.wakereason[tempIndex].wake_rycr = pBSP_Args->wake_reason[tempIndex].wake_rycr;
currentData.wakereason[tempIndex].wake_rdcr = pBSP_Args->wake_reason[tempIndex].wake_rdcr;
currentData.wakereason[tempIndex].wake_rtsr = pBSP_Args->wake_reason[tempIndex].wake_rtsr;
currentData.wakereason[tempIndex].wake_ryar1 = pBSP_Args->wake_reason[tempIndex].wake_ryar1;
currentData.wakereason[tempIndex].wake_rdar1 = pBSP_Args->wake_reason[tempIndex].wake_rdar1;
//printf("%d--0x%08x\r\n",tempIndex,currentData.wakereason[tempIndex].wake_pedr);
tempIndex++;
}
}
if ((currentData.nextindex > 0 )&&(currentData.nextindex < MAX_LOGED_RESUME_REASON+1 ))
{
//INDEX TIME PEDR REASON Descript
UINT8 index1 = 1;
UINT8 index2 = 0;
while(index1 <= currentData.nextindex)
{
TCHAR tmp[256];
DWORD subItem =0;
swprintf(tmp,_T("%d"),index1);
m_ListReport.InsertItem(index1-1,tmp);
subItem++;
m_ListReport.SetItemText(index1-1,subItem,pGpioSum[index2].descript);
subItem++;
swprintf(tmp,_T("0x%08x"),currentData.wakereason[index1].wake_pedr);
m_ListReport.SetItemText(index1-1,subItem,tmp);
subItem++;
swprintf(tmp,_T("0x%08x"),currentData.wakereason[index1].wake_pksr);
m_ListReport.SetItemText(index1-1,subItem,tmp);
subItem++;
swprintf(tmp,_T("0x%08x"),currentData.wakereason[index1].wake_rtsr);
m_ListReport.SetItemText(index1-1,subItem,tmp);
index2 = 0;
while ((index2 < 4 ))
{//get the correct description
if (pGpioSleepSum[index2].pedr == currentData.wakereason[index1].wake_pedr)
{
break;
}
index2++;
}
YearRegister year;
DayRegister day;
year.value = currentData.wakereason[index1].wake_rycr;
day.value = currentData.wakereason[index1].wake_rdcr;
wsprintf(tmp,TEXT("%04d-%02d-%02d,%02d:%02d:%02d "),//%2d,
//index1,
year.year,
year.month,
year.dayOfMonth,
day.hours,
day.minutes,
day.seconds
);//
subItem++;
m_ListReport.SetItemText(index1-1,subItem,tmp);
index1++;
}
}
if (pBSP_Args!= NULL)
MmUnmapIoSpace(pBSP_Args,sizeof(*pBSP_Args));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -