wxInt32 CViewMessagesGrid::FormatSeqNo(wxInt32 item, wxString& strBuffer) const { MESSAGE* message = wxGetApp().GetDocument()->message(item); if (message) { strBuffer = strBuffer.Format(wxT(" %d"),message->seqno); } return 0; }
wxString DisassembledItem::GetCodeStr() { static wxString gcstr; uint i; byte b; gcstr.Clear(); for (i = 0; i < opcode_size_; i++) { b = data_file_->GetData(offset_in_file_ + i); gcstr << gcstr.Format("%.2X ", b); } gcstr.Trim(true); return (gcstr); }
wxString DisassembledItem::GetAsciiStr() { static wxString gastr; uint i, b; gastr.Clear(); for (i = 0; i < opcode_size_; i++) { b = static_cast<uint>(data_file_->GetData(offset_in_file_ + i)); b = b & 0xFF; if ((b < 32) || (b > 126)) b = '.'; gastr << gastr.Format("%c", b); } return (gastr); }
wxString BigGridTable::GetValue( int row, int col ) { static int last_row = 0; static VscpRXObj *pRecord = NULL; static wxString str; if ( ( 0 == last_row ) || ( row != last_row ) ) { if ( NULL == ( pRecord = readEvent( row ) ) ) return wxString(_("")); } if ( NULL == pRecord ) return wxString(_("")); // Save the row last_row = row; switch ( col ) { case VSCP_RCVGRID_COLUMN_DIR: if ( VSCP_EVENT_DIRECTION_RX == pRecord->m_nDir ) { return wxString(_("RX")); } else { return wxString(_("TX")); } break; case VSCP_RCVGRID_COLUMN_CLASS: if ( g_Config.m_UseSymbolicNames ) { wxString strClass = g_vscpinfo.getClassDescription( pRecord->m_pEvent->vscp_class ); if ( 0 == strClass.Length() ) strClass = _("Unknown class"); return str.Format(_("%s \n0x%04X, %d"), strClass.c_str(), pRecord->m_pEvent->vscp_class, pRecord->m_pEvent->vscp_class ); } else { return str.Format(_("0x%04X, %d"), pRecord->m_pEvent->vscp_class, pRecord->m_pEvent->vscp_class ); } case VSCP_RCVGRID_COLUMN_TYPE: if ( g_Config.m_UseSymbolicNames ) { wxString strType = g_vscpinfo.getTypeDescription( pRecord->m_pEvent->vscp_class, pRecord->m_pEvent->vscp_type ); if ( 0 == strType.Length() ) strType = _("Unknown type"); return str.Format(_("%s \n0x%04X, %d "), strType.c_str(), pRecord->m_pEvent->vscp_type, pRecord->m_pEvent->vscp_type ); } else { return str.Format(_("0x%04X, %d"), pRecord->m_pEvent->vscp_type, pRecord->m_pEvent->vscp_type ); } case VSCP_RCVGRID_COLUMN_NOTE: return pRecord->m_wxStrNote; default: str = _("Invalid column"); } return str; }
void CViewWork::GetDocStatus(wxInt32 item, wxString& strBuffer) const { CMainDocument* doc = wxGetApp().GetDocument(); RESULT* result = wxGetApp().GetDocument()->result(item); CC_STATUS status; int retval; wxASSERT(doc); wxASSERT(wxDynamicCast(doc, CMainDocument)); strBuffer.Clear(); retval = doc->GetCoreClientStatus(status); if (retval || !result) { return; } if (result->coproc_missing) { strBuffer += _("GPU missing, "); } int throttled = status.task_suspend_reason & SUSPEND_REASON_CPU_THROTTLE; switch(result->state) { case RESULT_NEW: strBuffer += _("New"); break; case RESULT_FILES_DOWNLOADING: if (result->ready_to_report) { strBuffer += _("Download failed"); } else { strBuffer += _("Downloading"); if (status.network_suspend_reason) { strBuffer += _(" (suspended)"); } } break; case RESULT_FILES_DOWNLOADED: if (result->project_suspended_via_gui) { strBuffer += _("Project suspended by user"); } else if (result->suspended_via_gui) { strBuffer += _("Task suspended by user"); } else if (status.task_suspend_reason && !throttled) { strBuffer += _("Suspended"); if (status.task_suspend_reason & SUSPEND_REASON_BATTERIES) { strBuffer += _(" - on batteries"); } if (status.task_suspend_reason & SUSPEND_REASON_USER_ACTIVE) { strBuffer += _(" - user active"); } if (status.task_suspend_reason & SUSPEND_REASON_USER_REQ) { strBuffer += _(" - computation suspended"); } if (status.task_suspend_reason & SUSPEND_REASON_TIME_OF_DAY) { strBuffer += _(" - time of day"); } if (status.task_suspend_reason & SUSPEND_REASON_BENCHMARKS) { strBuffer += _(" - CPU benchmarks"); } if (status.task_suspend_reason & SUSPEND_REASON_DISK_SIZE) { strBuffer += _(" - need disk space"); } if (status.task_suspend_reason & SUSPEND_REASON_EXCLUSIVE_APP_RUNNING) { strBuffer += _(" - an exclusive app is running"); } if (result->resources.size()) { strBuffer += wxString(wxT(" (")) + wxString(result->resources.c_str(), wxConvUTF8) + wxString(wxT(")")); } } else if (result->active_task) { if (result->too_large) { strBuffer += _("Waiting for memory"); } else if (result->needs_shmem) { strBuffer += _("Waiting for shared memory"); } else if (result->scheduler_state == CPU_SCHED_SCHEDULED) { if (result->edf_scheduled) { strBuffer += _("Running, high priority"); } else { strBuffer += _("Running"); } #if 0 // doesn't work - project pointer not there if (result->project->non_cpu_intensive) { strBuffer += _(" (non-CPU-intensive)"); } #endif } else if (result->scheduler_state == CPU_SCHED_PREEMPTED) { strBuffer += _("Waiting to run"); } else if (result->scheduler_state == CPU_SCHED_UNINITIALIZED) { strBuffer += _("Ready to start"); } if (result->resources.size()) { strBuffer += wxString(wxT(" (")) + wxString(result->resources.c_str(), wxConvUTF8) + wxString(wxT(")")); } } else { strBuffer += _("Ready to start"); } if (result->gpu_mem_wait) { strBuffer += _(" (waiting for GPU memory)"); } break; case RESULT_COMPUTE_ERROR: strBuffer += _("Computation error"); break; case RESULT_FILES_UPLOADING: if (result->ready_to_report) { strBuffer += _("Upload failed"); } else { strBuffer += _("Uploading"); if (status.network_suspend_reason) { strBuffer += _(" (suspended)"); } } break; case RESULT_ABORTED: switch(result->exit_status) { case ERR_ABORTED_VIA_GUI: strBuffer += _("Aborted by user"); break; case ERR_ABORTED_BY_PROJECT: strBuffer += _("Aborted by project"); break; case ERR_UNSTARTED_LATE: strBuffer += _("Aborted: not started by deadline"); break; default: strBuffer += _("Aborted"); } break; default: if (result->got_server_ack) { strBuffer += _("Acknowledged"); } else if (result->ready_to_report) { strBuffer += _("Ready to report"); } else { strBuffer.Format(_("Error: invalid state '%d'"), result->state); } break; } }
//////////////////////////////////////////////////////////////////////////////////////////// /// \return a wxString which will contain the error message for any error occuring, /// otherwise a null string is returned /// \param tablePathName -> the path to the consistent changes (.cct) file to be loaded /// \remarks /// Called from: The App's OnToolsDefineCC() menu event handler. /// The loadTableFromFile() function calls ccModule->CCLoadTable() and /// ccModule->CCSetUTF8Encoding() to make the consistent changes facilities available to the /// application. //////////////////////////////////////////////////////////////////////////////////////////// wxString CConsistentChanger::loadTableFromFile(wxString tablePathName) // caller supplies a CString, so LPCTSTR needed here { // The wx version of loadTableFromFile returns any error as a formatted error string to the caller. //---- LOAD THE CC TABLE INTO THE BUFFER // wx version: we can't use MFC specific functions; so we'll just try to open the file for reading // and consider it an error if f.Open() returns false. wxFile f; if (!f.Open(tablePathName,wxFile::read)) { ccErrorStr = ccErrorStr.Format(_("The CC-Table \"%s\" could not be found or opened.\n"), tablePathName.c_str()); return ccErrorStr; } else { f.Close(); } // BEW 15Oct07, a long path will crash the CCLoadTable() call, so I've built a function to copy the table // data to a temporary "_tbl_.cct" file at the CSIDL_PERSONAL folder, which is the My Documents folder or // the Documents folder in Vista, and I'll have subsequent code below access that instead, and removing the // temporary file when done. The effect of this is that the CC32.DLL never accesses a cct file buried so // deep in the folder hierachy that the DLL code fails due to its small internal buffer for the path wxString pathToPersonalFolder = CopyTableToPersonalFolder(tablePathName); wxString lpPath = pathToPersonalFolder; // use this one below, not tablePathName // we don't expect the table file copy to the personal folder to fail, but check for it just in case and if it // did (the returned pathInRoot wxString will be empty) then tell the user and abort the load operation if (pathToPersonalFolder.IsEmpty()) { // for some reason the CopyTableToPersonalFolder() function failed, a hard coded English message will suffice wxString aPath = tablePathName; wxString s; s = s.Format(_T("Relocating the CC table file in loadTableFromFile failed, so cc processing is disabled; original table's path was: %s"),aPath.c_str()); wxMessageBox(s,_T(""), wxICON_EXCLAMATION | wxOK); return s ; // MFC note: we really need to return BOOL -- add this change later } int iResult2; int iResult; #ifdef _UNICODE // whm: one method of conversion is to use the .mb_str() method of wxString as illustrated in the // two commented out lines below: //wxCharBuffer tempBuff = lpPath.mb_str(wxConvUTF8); //CBString psz(tempBuff); // whm: an easier method of conversion is just to use the wxString constructor with wxConvUTF8 conversion parameter // whm 8Jun12 modified. The lpPath is already a wxString, so it doesn't need any further conversion with wxConvUTF8 iResult = ccModule->CCLoadTable(lpPath); // make the environment enabled for UTF-8 support iResult2 = ccModule->CCSetUTF8Encoding(TRUE); #else // ANSI iResult = ccModule->CCLoadTable(lpPath); // make the environment disabled for UTF-8 support iResult2 = ccModule->CCSetUTF8Encoding(FALSE); #endif // get rid of the temporary file _tbt_.cct in the data folder if (!::wxRemoveFile(lpPath)) { wxString aPath = tablePathName; wxString s; s = s.Format(_T("CopyTableToPersonalFolder() failed to remove the temporary file for path %s (so remove it manually using Win Explorer)"),aPath.c_str()); wxMessageBox(s,_T(""), wxICON_EXCLAMATION | wxOK); } if(iResult) { // Instead of throwing Exceptions, the wx version of loadTableFromFile() returns the error result // returned by the CC function. ccErrorStr = ccErrorStr.Format(_("CC couldn't load the table: %s. Got error code: %d. Check the syntax of the table."), tablePathName.c_str(), iResult); return ccErrorStr; //throw ccErrorStr; } if(iResult2) { ccErrorStr = ccErrorStr.Format(_("CC environment did not accept CCSetUTR8Encoding() call: Got error code: %d."), iResult2); return ccErrorStr; //throw ccErrorStr; } // if we get here all was successful and ccErrorStr should still be empty return ccErrorStr; }