void CTimeBarFrame::UpdateFrameContainer()
{
    m_pFrameContainer->Clear();
    std::vector<wxTreeItemId> idList;
    m_pItemTreeCtrl->GetItemsRecursively(idList, m_pItemTreeCtrl->GetRootItem());
    uint32_t uDataMaxFrame = 0;
    for (auto id : idList)
    {
        CTimeBarFrameData* pData = down_cast<CTimeBarFrameData*>(m_pItemTreeCtrl->GetItemData(id));
        if (pData->GetFrameList().size() > 0)
        {
            uint32_t uMaxFrame = *pData->GetFrameList().rbegin();
            if (uDataMaxFrame < uMaxFrame)
            {
                uDataMaxFrame = uMaxFrame;
            }
        }
        m_pFrameContainer->AddItem(pData);
    }
    if (uDataMaxFrame > m_uMaxFrameIndex)
    {
        m_uMaxFrameIndex = uDataMaxFrame;
    }
    RefreshControl();
}
Beispiel #2
0
//===========================================================================
void CFAVReaderDlg::OnBnClickedReaderWrite()
//===========================================================================
{
	// TODO: Add your control notification handler code here
	UpdateData(TRUE);
	GetDlgItem(IDC_READER_WRITE)->EnableWindow(FALSE);

	CComboBox* pCbox = (CComboBox*)GetDlgItem(IDC_READER_MEMBANK_DATA);
	CEdit* pEditA = (CEdit*)GetDlgItem(IDC_READER_ADDRESS_DATA);
	CEdit* pEditL = (CEdit*)GetDlgItem(IDC_READER_LENGTH_DATA);
	CEdit* pEditW = (CEdit*)GetDlgItem(IDC_READER_WRITE_DATA);
	CStatic* pStaticW = (CStatic*)GetDlgItem(IDC_READER_WRITE_INFO);
	CString strBuf = (_T(""));
	CString strBuf_ = (_T(""));
	char* pchWrite = nullptr;

	m_nMemBankIndex = pCbox->GetCurSel();
	pEditA->GetWindowText(m_strAddress);
	if(m_strAddress == _T("")){
		AfxMessageBox(_T("Can not be ' '(null character), Please setting the Address."), MB_ICONHAND);
		GotoDlgCtrl((CEdit*)GetDlgItem(IDC_READER_ADDRESS_DATA));
		GetDlgItem(IDC_READER_WRITE)->EnableWindow(TRUE);
		return;
	}

	pEditL->GetWindowText(m_strWordsLength);
	if(m_strWordsLength == _T("")){
		AfxMessageBox(_T("Can not be ' '(null character), Please setting the Length."), MB_ICONHAND);
		GotoDlgCtrl((CEdit*)GetDlgItem(IDC_READER_LENGTH_DATA));
		GetDlgItem(IDC_READER_WRITE)->EnableWindow(TRUE);
		return;
	}

	pEditW->GetWindowText(m_strWrite);
	int nWriteLength = m_strWrite.GetLength();
	int nWordsLength = CStringHexToInt(m_strWordsLength);

	if(nWriteLength > nWordsLength*4){
		AfxMessageBox(_T("Write data length is greater than the setting length.\r\nPlease reset the setting length."));
		GotoDlgCtrl((CEdit*)GetDlgItem(IDC_READER_LENGTH_DATA));
		GetDlgItem(IDC_READER_WRITE)->EnableWindow(TRUE);
		return;
	}

	if(nWriteLength < nWordsLength*4){
		int nZero;
		for(int i = 0; i < ( nWordsLength*4 - nWriteLength); i++){
			nZero = m_strWrite.Insert(nWriteLength+i,_T("0"));
		}
		m_editWriteData.SetSel(0,-1);
		m_editWriteData.Clear();
		m_editWriteData.ReplaceSel(m_strWrite);
	}

	m_strWriteList.Format(_T("W%1d,%s,%s,%s"), m_nMemBankIndex, m_strAddress, m_strWordsLength, m_strWrite);
	int nstrLength = m_strWriteList.GetLength(); 
	pchWrite = new char[nstrLength + 1];
	for(int i = 0; i < nstrLength; i++){
		*(pchWrite + i) = m_strWriteList[i];
	}
	*(pchWrite + nstrLength) = (char)0x0d;

	m_strWriteList = (_T(">>> ")) + m_strWriteList;
	uCnt = m_ListBox.AddLine((CFAVListBox::COLOR)m_nText, (CFAVListBox::COLOR)m_nBackground, m_strWriteList);

	if(m_SerialComm.WriteCMD(CMD_W, pchWrite, (nstrLength + 1), WRITE_TIMEOUT))
	{
		TRACE(_T(">>> Write Fail in Write Button.\n"));
		goto WRITEERROR;
	}
	if(m_SerialComm.ReadCMD(CMD_W, READ_TIMEOUT))
	{
		strBuf = m_SerialComm.GetCMDData(CMD_W);
		//strBuf.Remove('R');
		switch (strBuf[0]){
		case '0':
			if(strBuf.GetLength() == 1){
				strBuf_ = _T("(0: Other Error)");
			}
			else{
				strBuf.Remove('0');
				strBuf.Remove('Z');
				strBuf_.Format(_T("(0Z%s: Other Error, %s words is written)"), strBuf,strBuf);
			}
			break;//'0'
		case '3':
			if(strBuf.GetLength() == 1){
				strBuf_ = _T("(3: Memory Overrun)");
			}
			else{
				strBuf.Remove('3');
				strBuf.Remove('Z');
				strBuf_.Format(_T("(3Z%s: Memory Overrun, %s words is written)"), strBuf,strBuf);
			}
			break;//'3'
		case '4':
			if(strBuf.GetLength() == 1){
				strBuf_ = _T("(4: Memory Locked)");
			}
			else{
				strBuf.Remove('4');
				strBuf.Remove('Z');
				strBuf_.Format(_T("(4Z%s: Memory Locked, %s words is written)"), strBuf,strBuf);
			}
			break;//'4'
		case 'Z':
			strBuf.Remove('Z');
			strBuf_.Format(_T("(Z%s: %s words is written)"), strBuf,strBuf);
			break;//'Z'
		case 'B':
			if(strBuf.GetLength() == 1){
				strBuf_ = _T("(B: Insufficient Power)");
			}
			else{
				strBuf.Remove('B');
				strBuf.Remove('Z');
				strBuf_.Format(_T("(BZ%s: Insufficient power, %s words is written)"), strBuf,strBuf);
			}
			break;//'X'
		case 'W':
			if(strBuf.GetLength() == 1){
				strBuf_ = _T("(W: No Tag)");
			}
			else
				strBuf_ = strBuf;
			break;//'W'
		case 'X':
			strBuf_ = _T("(X: Out of spec.)");
			break;//'X'
		case 'F':
			if(strBuf.GetLength() == 1){
				strBuf_ = _T("(F: Non-specific error)");
			}
			else{
				strBuf.Remove('F');
				strBuf.Remove('Z');
				strBuf_.Format(_T("(FZ%s: Non-specific error, %s words is written)"), strBuf,strBuf);
			}
			break;//'F'
		default:
			strBuf_ = strBuf;
			break;
		}

		pStaticW->SetWindowText(strBuf_);
		RefreshControl(IDC_READER_WRITE_INFO);

		uCnt = m_ListBox.AddLine((CFAVListBox::COLOR)m_nRecText, (CFAVListBox::COLOR)m_nBackground, m_SerialComm.GetCMDData(CMD_W));

		ASSERT(uCnt != LB_ERR);

		if (uCnt != LB_ERR)
		{
			// verify colors
			int nText = m_ListBox.GetTextColor(uCnt);
			int nBackground = m_ListBox.GetBackgroundColor(uCnt);
			//TRACE(_T("from XListBox:  text=%d  background=%d\n"), nText, nBackground);
			if (((nText != m_nText) && (nText != m_nRecText)) || (nBackground != m_nBackground))
			{
				ASSERT(FALSE);
			}
		}
	}
WRITEERROR:
	if(pchWrite){
		delete [] pchWrite;
	}
	pchWrite = NULL;

	GetDlgItem(IDC_READER_WRITE)->EnableWindow(TRUE);
	GetDlgItem(IDC_READER_WRITE)->SetFocus();
}