Beispiel #1
0
void wxLog::DoLogRecord(wxLogLevel level,
                             const wxString& msg,
                             const wxLogRecordInfo& info)
{
#if WXWIN_COMPATIBILITY_2_8
    // call the old DoLog() to ensure that existing custom log classes still
    // work
    //
    // as the user code could have defined it as either taking "const char *"
    // (in ANSI build) or "const wxChar *" (in ANSI/Unicode), we have no choice
    // but to call both of them
    DoLog(level, (const char*)msg.mb_str(), info.timestamp);
    DoLog(level, (const wchar_t*)msg.wc_str(), info.timestamp);
#else // !WXWIN_COMPATIBILITY_2_8
    wxUnusedVar(info);
#endif // WXWIN_COMPATIBILITY_2_8/!WXWIN_COMPATIBILITY_2_8


    // TODO: it would be better to extract message formatting in a separate
    //       wxLogFormatter class but for now we hard code formatting here

    wxString prefix;

    // don't time stamp debug messages under MSW as debug viewers usually
    // already have an option to do it
#ifdef __WXMSW__
    if ( level != wxLOG_Debug && level != wxLOG_Trace )
#endif // __WXMSW__
        TimeStamp(&prefix);

    // TODO: use the other wxLogRecordInfo fields

    switch ( level )
    {
        case wxLOG_Error:
            prefix += _("Error: ");
            break;

        case wxLOG_Warning:
            prefix += _("Warning: ");
            break;

        // don't prepend "debug/trace" prefix under MSW as it goes to the debug
        // window anyhow and so can't be confused with something else
#ifndef __WXMSW__
        case wxLOG_Debug:
            // this prefix (as well as the one below) is intentionally not
            // translated as nobody translates debug messages anyhow
            prefix += "Debug: ";
            break;

        case wxLOG_Trace:
            prefix += "Trace: ";
            break;
#endif // !__WXMSW__
    }

    DoLogTextAtLevel(level, prefix + msg);
}
Beispiel #2
0
void Logger::operator () (const std::string &text)
//------------------------------------------------
{
#if defined(MPT_WITH_CHARSET_LOCALE)
	DoLog(context, mpt::ToWide(mpt::CharsetLocale, text));
#else
	DoLog(context, mpt::ToWide(mpt::CharsetUTF8, text));
#endif
}
//&>>&0 0 0 12
//&<<&void mmm_KeyBoard::SetACode(int n){ 
void mmm_KeyBoard::SetACode(int n){
//&<<&    #ifdef _ENABLE_LOGGING_
    #ifdef _ENABLE_LOGGING_
        DoLog("mmm_KeyBoard::SetACode(%d) {\n",n);
    #endif
//&>>&1 0 1 1B
    acode=mmm_KBD.keys[n];
//&<<&    #ifdef _ENABLE_LOGGING_
    #ifdef _ENABLE_LOGGING_
        DoLog("    }\n");
    #endif
//&>>&1 0 1 4
    }
//&>>&E 0 E B
//&<<&mmm_Screen::~mmm_Screen(){
mmm_Screen::~mmm_Screen(){
//&<<&#ifdef _ENABLE_LOGGING_
#ifdef _ENABLE_LOGGING_
   DoLog("mmm_Screen::~mmm_Screen()  {\n");

   DoLog("    DrawLine("",HEIGHT-1 {\n");
   DrawLine("",HEIGHT-1,Editor.TextAttr,WIDTH-3);
   DoLog("        }\n");

   DoLog("    SetCursor {\n");
   SetCursor(0,HEIGHT-1,Editor.TextAttr);
   DoLog("        }\n");

   DoLog("    close(con_fd);  {\n");
   close(con_fd);
   DoLog("        }\n");

   DoLog("    }\n");
//&>>&1 0 1 21
//&<<&#else
#else
   DrawLine("",HEIGHT-1,Editor.TextAttr,WIDTH-3);
   SetCursor(0,HEIGHT-1,Editor.TextAttr);
   close(con_fd);
//&>>&3 0 3 1
#endif

   }
bool CScreenManager::SetLowResolution()
{
	if(!m_bInit)
	{
		return false;
	}

	DEVMODE DevMod;
    DevMod.dmSize = sizeof(DEVMODE);
    if (!EnumDisplaySettings(m_MainDevice.DeviceName, ENUM_CURRENT_SETTINGS, &DevMod))
    {
		DoLog("Failed to enum display settings, low resolution canceled", MSG_ERROR);
        return false;
    }
 
	if( (DevMod.dmPelsWidth <= 1366) || (DevMod.dmPelsWidth <= 768) )
	{
		DoLog("Screen has already a low res, ignore resolution change", MSG_WARNING);
		return true;
	}

	// Flag for what we want to set
	DevMod.dmFields = (DM_PELSWIDTH | DM_PELSHEIGHT);

	// Try a 19/9 low res
    DevMod.dmPelsWidth = 1366;
    DevMod.dmPelsHeight = 768;   
    if (ChangeDisplaySettings(&DevMod, CDS_TEST) != DISP_CHANGE_SUCCESSFUL)
    {
		// Try a 4/3 low res
		DevMod.dmPelsWidth = 1024;
		DevMod.dmPelsHeight = 768;
		if (ChangeDisplaySettings(&DevMod, CDS_TEST) != DISP_CHANGE_SUCCESSFUL)
		{
			DoLog("Low resolution display settings not supported, canceled", MSG_ERROR);
			return false;
		 }
    }
 
    if(ChangeDisplaySettings(&DevMod, 0) != DISP_CHANGE_SUCCESSFUL)
	{
		DoLog("Failed to apply low resolution display settings", MSG_ERROR);
        return false;
	}

	m_bIsLowRes = true;
	
	return true;
}
Beispiel #6
0
static noinline void DoLog(const mpt::log::Context &context, const char *format, va_list args)
//--------------------------------------------------------------------------------------------
{
	char message[LOGBUF_SIZE];
	va_list va;
	va_copy(va, args);
	vsnprintf(message, LOGBUF_SIZE, format, va);
	message[LOGBUF_SIZE - 1] = '\0';
	va_end(va);
#if defined(MPT_WITH_CHARSET_LOCALE)
	DoLog(context, mpt::ToUnicode(mpt::CharsetLocale, message));
#else
	DoLog(context, mpt::ToUnicode(mpt::CharsetUTF8, message));
#endif
}
//////////////////////////////////////////////////////////////////////////////
// Set video codec to use
//////////////////////////////////////////////////////////////////////////////
void CCustomDrone::SetVideoCodec(eVideoCodec VideoCodec)
{
	if (version.major == ARDRONE_VERSION_2) 
	{
        // Finalize video
        finalizeVideo();

		if (mutexCommand) pthread_mutex_lock(mutexCommand);;

        // Output video with selected codec
        sockCommand.sendf("AT*CONFIG_IDS=%d,\"%s\",\"%s\",\"%s\"\r", seq++, ARDRONE_SESSION_ID, ARDRONE_PROFILE_ID, ARDRONE_APPLOCATION_ID);
        sockCommand.sendf("AT*CONFIG=%d,\"video:video_codec\",\"%d\"\r", seq++, VideoCodec);
        
		if (mutexCommand) pthread_mutex_unlock(mutexCommand);;
		
		msleep(100);

        // Initialize video
		if(0 == initVideo())
		{
			DoLog("Failed to restart video after codec change, watchdog should catch this", MSG_ERROR);
			// TODO: change watchdog way
			//bNeedVideoRestart = true;
		}
    }
}
//&>>&19 0 17 7
//&<<&mmm_KeyBoard::~mmm_KeyBoard(){
mmm_KeyBoard::~mmm_KeyBoard(){
//&<<&   #ifdef _ENABLE_LOGGING_
   #ifdef _ENABLE_LOGGING_
       DoLog("mmm_KeyBoard::~mmm_KeyBoard() {\n");
   #endif
//&>>&1 0 1 29
   int r;
   r=ioctl(con_fd,KDSKBMODE,om);
   r=tcsetattr(con_fd,TCSANOW,&t1);
   if(r<0) {printf("E6 %d\n",r);}
//&<<&   #ifdef _ENABLE_LOGGING_
   #ifdef _ENABLE_LOGGING_
       DoLog("    }\n");
   #endif
//&>>&1 0 1 7
}
Beispiel #9
0
void Logger::operator () (const char *format, ...)
//------------------------------------------------
{
	va_list va;
	va_start(va, format);
	DoLog(context, format, va);
	va_end(va);
}
Beispiel #10
0
void wxLog::DoLogRecord(wxLogLevel level,
                             const wxString& msg,
                             const wxLogRecordInfo& info)
{
#if WXWIN_COMPATIBILITY_2_8
    // call the old DoLog() to ensure that existing custom log classes still
    // work
    //
    // as the user code could have defined it as either taking "const char *"
    // (in ANSI build) or "const wxChar *" (in ANSI/Unicode), we have no choice
    // but to call both of them
    DoLog(level, (const char*)msg.mb_str(), info.timestamp);
    DoLog(level, (const wchar_t*)msg.wc_str(), info.timestamp);
#else // !WXWIN_COMPATIBILITY_2_8
    wxUnusedVar(info);
#endif // WXWIN_COMPATIBILITY_2_8/!WXWIN_COMPATIBILITY_2_8

    // Use wxLogFormatter to format the message
    DoLogTextAtLevel(level, m_formatter->Format (level, msg, info));
}
void __EXIT(){
//&<<&    #ifdef _ENABLE_LOGGING_
  #ifdef _ENABLE_LOGGING_
      DoLog("void __EXIT(){ \n");
  #endif
//&>>&1 0 1 6
    char *s;
    FILE *fRunScript,*filelist;

    s=MFileName(EXECUTER_FILENAME);
    fRunScript=fopen(s,"w"); MemTest(fRunScript!=0);
    delete s;

    PutCurDir(fRunScript);
    while(mmm_LineClipboard && mmm_LineClipboard->prev)
        mmm_LineClipboard=mmm_LineClipboard->prev;
    while(mmm_LineClipboard && mmm_LineClipboard->next){
        mmm_LineClipboard->Write(fRunScript,FILE_ASCII);
        mmm_LineClipboard=mmm_LineClipboard->next;
        }
    PutCurDir(fRunScript);
    fclose(fRunScript);

    s=MFileName("__mmm__.mmm");
    filelist=fopen(s,"w"); MemTest(filelist!=0);
    delete s;
    PerformExitingFromFiles(filelist);
    fclose(filelist);

    chmod(MFileName(EXECUTER_FILENAME), 0755 );
//&<<&    #ifdef _ENABLE_LOGGING_
  #ifdef _ENABLE_LOGGING_
      DoLog("    } exit(-1)...\n");
  #endif
//&>>&1 0 1 6
    system(MFileName(EXECUTER_FILENAME));
    exit(-1);
}
Beispiel #12
0
unsigned wxLog::LogLastRepeatIfNeededUnlocked()
{
    long retval = ms_prevCounter;
    if ( ms_prevCounter > 0 )
    {
        wxString msg;
#if wxUSE_INTL
        msg.Printf(wxPLURAL("The previous message repeated once.",
                            "The previous message repeated %lu times.",
                            ms_prevCounter),
                   ms_prevCounter);
#else
        msg.Printf(wxT("The previous message was repeated."));
#endif
        ms_prevCounter = 0;
        ms_prevString.clear();
        DoLog(ms_prevLevel, msg.c_str(), ms_prevTimeStamp);
    }
    return retval;
}
//////////////////////////////////////////////////////////////////////////////
// Set maximum altitude
//////////////////////////////////////////////////////////////////////////////
void CCustomDrone::SetMaxAltitude(long lMaxAltitude)
{
	// Altitude in meters has to be convert in millimeters
	if(lMaxAltitude > 100)
	{
		// 100m means unlimited
		lMaxAltitude = 100000;
	}
	else
	{
		lMaxAltitude *= 1000;
	}

	DoLog(wxString::Format("Set max altitude to %d m (%d mm)", lMaxAltitude/1000, lMaxAltitude));

	if (mutexCommand) pthread_mutex_lock(mutexCommand);;
	sockCommand.sendf("AT*CONFIG_IDS=%d,\"%s\",\"%s\",\"%s\"\r", seq++, ARDRONE_SESSION_ID, ARDRONE_PROFILE_ID, ARDRONE_APPLOCATION_ID);
	sockCommand.sendf("AT*CONFIG=%d,\"control:altitude_max\",\"%d\"\r",  seq++, lMaxAltitude);
	if (mutexCommand) pthread_mutex_unlock(mutexCommand);;

	msleep(100);
}
Beispiel #14
0
void Logger::operator () (const AnyStringLocale &text)
//----------------------------------------------------
{
	DoLog(context, text);
}
Beispiel #15
0
void Logger::operator () (LogLevel level, const mpt::ustring &text)
//-----------------------------------------------------------------
{
	DoLog(context, LogLevelToString(level) + MPT_USTRING(": ") + text);
}
/////////////////////////////////////////////////////////////
// Constructor
/////////////////////////////////////////////////////////////
CKeyboardDialog::CKeyboardDialog(wxWindow *parent, CInput* pInput): wxDialog(parent, 1, "ConfigKeyboard", wxDefaultPosition, wxDefaultSize, wxCAPTION | wxSYSTEM_MENU | wxCLOSE_BOX)
{	
	this->SetTitle(GetText("KeyboardConfig"));
	this->SetFont(FontNormal10);
	//this->SetForegroundColour(ColorBlueLite);	

	// Check parameter error
	if(NULL == pInput)
	{
		DoLog("Keyboard dialog has been called without Input object !", MSG_ERROR);
		return;
	}
	m_pInput = pInput;

	// No key selected yet
	m_iKey = -1;

	// Get the assigned key values
	wxKeyCode kUp, kDown;
	for(int i=0; i<4; i++)
	{
		m_pInput->GetKeysControl((eDirection)i, kDown, kUp);
		m_pKeys[i*2]=kUp;
		m_pKeys[i*2+1]=kDown;
	}

	// Create the main sizer
	wxBoxSizer*	pMainSizer = new wxBoxSizer(wxVERTICAL);
	pMainSizer->AddSpacer(10);

	wxString str = GetText("SelectKeyWarning");
	str.Replace("##", "\n\t");
	wxStaticText* pTitle = new wxStaticText(this, wxID_ANY, str, wxDefaultPosition, wxDefaultSize);
	pTitle->Wrap(400);
	pMainSizer->Add(pTitle, 0, wxEXPAND | wxALL, 15);

	pMainSizer->AddSpacer(15);

	// Create a flex grid sizer to display the graphical elements
	wxFlexGridSizer* pControlsSizer = new wxFlexGridSizer(8, 2, 5, 10);

	// Allow the columns to grow
	pControlsSizer->AddGrowableCol(0);
	pControlsSizer->AddGrowableCol(1);	

	wxString strLbl;
	wxSize ButMinSize(200, 25);

	for(int j=0; j<8; j++)
	{
		switch(j)
		{
			case 0:		strLbl = GetText("KeyMoveFwd");			break;
			case 1:		strLbl = GetText("KeyMoveBwd");			break;
			case 2:		strLbl = GetText("KeyMoveR");			break;
			case 3:		strLbl = GetText("KeyMoveL");			break;
			case 4:		strLbl = GetText("KeyMoveTR");			break;
			case 5:		strLbl = GetText("KeyMoveTL");			break;
			case 6:		strLbl = GetText("KeyMoveUp");			break;
			case 7:		strLbl = GetText("KeyMoveDown");		break;
			default:	strLbl = "";							break;
		}

		// Label to show the help text
		m_pLabels[j] = new wxStaticText(this, wxID_ANY, strLbl, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
		pControlsSizer->Add(m_pLabels[j], 0, wxALIGN_CENTER_VERTICAL | wxEXPAND, 0);

		// Button to click
		m_pButton[j] = new wxButton(this, 2000+j, GetLabelString(j));
		m_pButton[j]->SetMinSize(ButMinSize);
		pControlsSizer->Add(m_pButton[j], 0, wxALIGN_CENTER | wxEXPAND, 0);
	}	
	pMainSizer->Add(pControlsSizer, 0, wxALIGN_CENTRE | wxEXPAND | wxALL, 15);

	// Create an horizontal sizer as we need to set 2 controls
	wxBoxSizer* pTmpSizer = new wxBoxSizer(wxHORIZONTAL);

	// Create the ok button
	wxButton *pButtonOk = new wxButton(this, ID_BUTTONOK, GetText("Apply"), wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE);
	pButtonOk->SetForegroundColour(ColorGreenLite);
	pTmpSizer->Add(pButtonOk, 0, wxALL, 5);

	// Create the cancel button
	wxButton *pButtonCancel = new wxButton(this, ID_BUTTONCANCEL, GetText("Cancel"), wxDefaultPosition, wxDefaultSize, wxBORDER_SIMPLE);
	pButtonCancel->SetForegroundColour(ColorRedLite);
	pButtonCancel->SetFocus();
	pTmpSizer->Add(pButtonCancel, 0, wxALL, 5);

	pMainSizer->Add(pTmpSizer, 0, wxALIGN_CENTRE | wxALL, 10);	

	SetIcon(wxICON(IcoMain));

	// Connect the buttons	
	Connect(2000, 2007, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(CKeyboardDialog::OnButton));
	//this->SetFocus();

	this->SetSizerAndFit(pMainSizer);
	this->CentreOnParent();
}
Beispiel #17
0
void Logger::operator () (const std::wstring &text)
//-------------------------------------------------
{
	DoLog(context, text);
}