Beispiel #1
0
bool Camera_OpticstarPL130Class::Capture(int duration, usImage& img, int options, const wxRect& subframe)
{
    bool still_going = true;

    int mode = 3 * (int) Color;
    if (img.Init(FullSize))
    {
        DisconnectWithAlert(CAPT_FAIL_MEMORY);
        return true;
    }
    if (OSPL130_Capture(mode,duration)) {
        pFrame->Alert(_("Cannot start exposure"));
        return true;
    }
    if (duration > 100) {
        wxMilliSleep(duration - 100); // wait until near end of exposure, nicely
        wxGetApp().Yield();
//      if (Abort) {
//          MeadeCam->AbortImage();
//          return true;
//      }
    }
    while (still_going) {  // wait for image to finish and d/l
        wxMilliSleep(20);
        OSPL130_IsExposing(&still_going);
        wxGetApp().Yield();
    }
    // Download
    OSPL130_GetRawImage(0,0,FullSize.GetWidth(),FullSize.GetHeight(), (void *) img.ImageData);
    unsigned short *dataptr;
    dataptr = img.ImageData;
    // byte swap

    if (options & CAPTURE_SUBTRACT_DARK) SubtractDark(img);
    if (Color && (options & CAPTURE_RECON))
        QuickLRecon(img);

    return false;
}
Beispiel #2
0
wxThread::ExitCode MyJoinableThread::Entry()
{
    unsigned long res = 1;
    for ( size_t n = 1; n < m_n; n++ )
    {
        res *= n;

        // it's a loooong calculation :-)
        wxMilliSleep(100);
    }

    return (ExitCode)res;
}
Beispiel #3
0
bool wxLuaDebugTarget::IsConnected(bool wait_for_connect) const
{
    if (m_fConnected || !wait_for_connect) return m_fConnected;

    for (int idx = 0; idx < WXLUASOCKET_CONNECT_TIMEOUT; ++idx)
    {
        if (m_fConnected)
            break;

        wxMilliSleep(100);
    }
    return m_fConnected;
}
/// Gets a new list of devices by terminating and restarting portaudio
/// Assumes that DeviceManager is only used on the main thread.
void DeviceManager::Rescan()
{
   // get rid of the previous scan info
   this->mInputDeviceSourceMaps.clear();
   this->mOutputDeviceSourceMaps.clear();

   // if we are doing a second scan then restart portaudio to get new devices
   if (m_inited) {
      // check to see if there is a stream open - can happen if monitoring,
      // but otherwise Rescan() should not be available to the user.
      if (gAudioIO) {
         if (gAudioIO->IsMonitoring()) 
         {
            gAudioIO->StopStream();
            while (gAudioIO->IsBusy())
               wxMilliSleep(100);
         }
      }
      
      // restart portaudio - this updates the device list
      Pa_Terminate();
      Pa_Initialize();
   }

   int nDevices = Pa_GetDeviceCount();

   //The heirarchy for devices is Host/device/source.
   //Some newer systems aggregate this.
   //So we need to call port mixer for every device to get the sources
   for (int i = 0; i < nDevices; i++) {
      const PaDeviceInfo *info = Pa_GetDeviceInfo(i);
      if (info->maxOutputChannels > 0) {
         AddSources(i, info->defaultSampleRate, &mOutputDeviceSourceMaps, 0);
      }

      if (info->maxInputChannels > 0) {
         AddSources(i, info->defaultSampleRate, &mInputDeviceSourceMaps, 1);
      }
   }

   // If this was not an initial scan update each device toolbar.
   // Hosts may have disappeared or appeared so a complete repopulate is needed.
   if (m_inited) {
      DeviceToolBar *dt;
      for (size_t i = 0; i < gAudacityProjects.GetCount(); i++) {
         dt = gAudacityProjects[i]->GetDeviceToolBar();
         dt->RefillCombos();
      }
   }
	m_inited = true;
}
/** \brief Worker method of the Squidd.io server communication thread
 *
 * \return void*
 *
 */   
void *SquiddioThread::Entry()
{
    wxMilliSleep(500); //Give everything some time to settle down before we try to do our work
    m_pHandler->SetThreadRunning(true);
    while (!TestDestroy())
    {
        if( !m_bIsWorking )
        {
            m_bIsWorking = true;
            if( m_getdata )
            {
                m_getdata = false;
                m_pHandler->RefreshLayer();
                SquiddioEvent evt;
                m_pHandler->AddPendingEvent(evt);
            }
            else if ( m_bCheckOnline )
            {
                m_pHandler->CheckIsOnline();
                m_bCheckOnline = false;
            }
            else if ( m_bPositionReport )
            {
                //TODO: Separate from logwindow first.
                m_bPositionReport = false;
            }
            m_bIsWorking = false;
        }
        wxMilliSleep(250);
    }
    // signal the event handler that this thread is going to be destroyed
    // NOTE: here we assume that using the m_pHandler pointer is safe,
    // (in this case this is assured by the MyFrame destructor)
    //    wxQueueEvent(m_pHandler, new wxThreadEvent(wxEVT_COMMAND_DBTHREAD_COMPLETED));
    //return (wxThread::ExitCode)0; // success

    return 0;
}
Beispiel #6
0
void wxLuaDebugTarget::Stop()
{
    NotifyExit();

    if (m_fConnected)
    {
        m_clientSocket.Shutdown(SD_BOTH);
        wxMilliSleep(100);
        m_clientSocket.Close();
    }

    if (m_pThread)
        m_pThread->Wait();
}
Beispiel #7
0
// This function performs the main work of the service. 
// When this function returns the service has stopped.
void wxGISNTService::Run()
{
	wxCmdLineParser parser;
	if(!m_Server.Start(wxT("wxGISServer"), CONFIG_DIR, parser)) 
	{
        m_Server.Stop();
		return;
	}

    while (m_bIsRunning)
        wxMilliSleep(300);

	m_Server.Stop();
}
	virtual void OnIdle(wxIdleEvent& event)
	{
		if(OpQuit())
		{
			GetParent()->Close(true);
			return;
		}
		Handler()->OnLoop();
		OnLoopSound();
		Refresh(false);
		if(!Handler()->FullSpeed())
			wxMilliSleep(3);
		event.RequestMore();
	}
Beispiel #9
0
void Parser::TerminateAllThreads()
{
    while (!m_PoolTask.empty())
    {
        PTVector& v = m_PoolTask.front();
        for (PTVector::iterator it = v.begin(); it != v.end(); ++it)
            delete *it;
        m_PoolTask.pop();
    }

    m_Pool.AbortAllTasks();
    while (!m_Pool.Done())
        wxMilliSleep(1);
}
void ManagedThread::abort_all()
{
    // 1) Send signal to threads telling to terminate ASAP
    if(count_running() > 0)
    {
        ManagedThread::s_abort_all = true;
        while(count_running() > 0)
        {
            wxMilliSleep(5);
        }
        wxMilliSleep(50);

        // (there's a tiny delay between the thread disminishing the count
        // and the thread actually stopping)
        // 50 ms should be more than enough
    }

    // 2) Delete thread objects
    ManagedThread *thread;
    for(unsigned int i = 0; i < count_threads();++i)
    {
        thread = GetThread(i);
        if(thread)
        {
            if(thread->IsAlive())
                { thread->Delete(); }
            delete thread;
        }
    }

    // 3) Clear thread list
    wxCriticalSectionLocker lock(ManagedThread::s_list_mutex);
    s_threadslist.Clear();

    // 4) Reset the abort flag now that no threads are running
    ManagedThread::s_abort_all = false;
}
///Runs the wait for start dialog.  Returns false if the user clicks stop while we are recording
///so that the high
bool TimerRecordDialog::RunWaitDialog()
{
   int updateResult = eProgressSuccess;
   if (m_DateTime_Start > wxDateTime::UNow()) 
      updateResult = this->WaitForStart(); 

   if (updateResult != eProgressSuccess) 
   {
      // Don't proceed, but don't treat it as canceled recording. User just canceled waiting. 
      return true;
   }
   else 
   {
      // Record for specified time.
      AudacityProject* pProject = GetActiveProject();
      pProject->OnRecord();
      bool bIsRecording = true;

      wxString strMsg =
         _("Recording start") + (wxString)wxT(":\t\t")
         + GetDisplayDate(m_DateTime_Start) + wxT("\n") + _("Recording end")
         + wxT(":\t\t") + GetDisplayDate(m_DateTime_End) + wxT("\n")
         + _("Duration") + wxT(":\t\t") + m_TimeSpan_Duration.Format(); 

      TimerProgressDialog 
         progress(m_TimeSpan_Duration.GetMilliseconds().GetValue(), 
                  _("Audacity Timer Record Progress"), 
                  strMsg, 
                  pdlgHideCancelButton); 

      // Make sure that start and end time are updated, so we always get the full 
      // duration, even if there's some delay getting here.
      wxTimerEvent dummyTimerEvent;
      this->OnTimer(dummyTimerEvent);

      // Loop for progress display during recording.
      while (bIsRecording && (updateResult == eProgressSuccess)) 
      {
         wxMilliSleep(kTimerInterval);
         updateResult = progress.Update();
         bIsRecording = (wxDateTime::UNow() <= m_DateTime_End); // Call UNow() again for extra accuracy...
      }
      pProject->OnStop();
   }
   // Let the caller handle cancellation or failure from recording progress. 
   if (updateResult == eProgressCancelled || updateResult == eProgressFailed)
      return false;
   return true;
}
Beispiel #12
0
ProgressResult TimerRecordDialog::WaitForStart()
{
   // MY: The Waiting For Start dialog now shows what actions will occur after recording has completed
   wxString sPostAction = m_pTimerAfterCompleteChoiceCtrl->GetString(m_pTimerAfterCompleteChoiceCtrl->GetSelection());

   // Two column layout.
   TimerProgressDialog::MessageTable columns(2);
   auto &column1 = columns[0];
   auto &column2 = columns[1];

   column1.push_back(_("Waiting to start recording at:"));
   column2.push_back(GetDisplayDate(m_DateTime_Start));

   column1.push_back(_("Recording duration:"));
   column2.push_back(m_TimeSpan_Duration.Format());

   column1.push_back(_("Scheduled to stop at:"));
   column2.push_back(GetDisplayDate(m_DateTime_End));

   column1.push_back( {} );
   column2.push_back( {} );

   column1.push_back(_("Automatic Save enabled:"));
   column2.push_back((m_bAutoSaveEnabled ? _("Yes") : _("No")));

   column1.push_back(_("Automatic Export enabled:"));
   column2.push_back((m_bAutoExportEnabled ? _("Yes") : _("No")));

   column1.push_back(_("Action after Timer Recording:"));
   column2.push_back(sPostAction);

   wxDateTime startWait_DateTime = wxDateTime::UNow();
   wxTimeSpan waitDuration = m_DateTime_Start - startWait_DateTime;
   TimerProgressDialog progress(waitDuration.GetMilliseconds().GetValue(),
      _("Audacity Timer Record - Waiting for Start"),
      columns,
      pdlgHideStopButton | pdlgConfirmStopCancel | pdlgHideElapsedTime,
      _("Recording will commence in:"));

   auto updateResult = ProgressResult::Success;
   bool bIsRecording = false;
   while (updateResult == ProgressResult::Success && !bIsRecording)
   {
      updateResult = progress.UpdateProgress();
      wxMilliSleep(10);
      bIsRecording = (m_DateTime_Start <= wxDateTime::UNow());
   }
   return updateResult;
}
Beispiel #13
0
wxThread::ExitCode Timer::Entry()
{
    // here we do our long task, periodically calling TestDestroy():
    while (_running && !GetThread()->TestDestroy())
    {
        wxMilliSleep(_ms);
        if (_running)
        {
            wxQueueEvent(_parent->GetEventHandler(), new wxCommandEvent(UpdateEvent)); //new wxTimerEvent());
        }
    }
    // TestDestroy() returned true (which means the main thread asked us
    // to terminate as soon as possible) or we ended the long task...
    return (wxThread::ExitCode)0;
}
Beispiel #14
0
void MiscThreadTestCase::TestThreadDelete()
{
    // FIXME:
    // As above, using Sleep() is only for testing here - we must use some
    // synchronisation object instead to ensure that the thread is still
    // running when we delete it - deleting a detached thread which already
    // terminated will lead to a crash!

    MyDetachedThread *thread0 = new MyDetachedThread(30, 'W');
    CPPUNIT_ASSERT_EQUAL( wxTHREAD_MISC_ERROR, thread0->Delete() );    
        // delete a thread which didn't start to run yet.

    MyDetachedThread *thread1 = new MyDetachedThread(30, 'Y');
    CPPUNIT_ASSERT_EQUAL( wxTHREAD_NO_ERROR, thread1->Run() );
    wxMilliSleep(300);
    CPPUNIT_ASSERT_EQUAL( wxTHREAD_NO_ERROR, thread1->Delete() );      
        // delete a running thread

    MyDetachedThread *thread2 = new MyDetachedThread(30, 'Z');
    CPPUNIT_ASSERT_EQUAL( wxTHREAD_NO_ERROR, thread2->Run() );
    wxMilliSleep(300);
    CPPUNIT_ASSERT_EQUAL( wxTHREAD_NO_ERROR, thread2->Pause() );
    CPPUNIT_ASSERT_EQUAL( wxTHREAD_NO_ERROR, thread2->Delete() );      
        // delete a sleeping thread

    MyJoinableThread thread3(20);
    CPPUNIT_ASSERT_EQUAL( wxTHREAD_NO_ERROR, thread3.Run() );
    CPPUNIT_ASSERT_EQUAL( wxTHREAD_NO_ERROR, thread3.Delete() );       
        // delete a joinable running thread

    MyJoinableThread thread4(2);
    CPPUNIT_ASSERT_EQUAL( wxTHREAD_NO_ERROR, thread4.Run() );
    wxMilliSleep(300);
    CPPUNIT_ASSERT_EQUAL( wxTHREAD_NO_ERROR, thread4.Delete() );       
        // delete a joinable thread which already terminated
}
Beispiel #15
0
bool GlobalConfig::stopAudioThread()
{
    if( m_AudioThread && m_AudioThread->IsRunning() )
    {
        m_AudioThread->terminate();
        while( m_AudioThread->IsRunning() )
        {
            wxMilliSleep( 100 );
        }
    }

    m_LoggingWindow->Close();
    m_LoggingWindow->Destroy();

    return( false );
}
void wxPlFrame::OnCheckTimer( wxTimerEvent &event )
{
    //repeatedly call ReadTransmission until there is nothing
    //left to read
    PLINT nFalses = 0;
    while ( nFalses < 100 )
    {
        if ( ReadTransmission() )
            nFalses = 0;
        else
        {
            ++nFalses;
            wxMilliSleep( 1 );
        }
    }
}
Beispiel #17
0
ProgressResult TimerRecordDialog::PreActionDelay(int iActionIndex, TimerRecordCompletedActions eCompletedActions)
{
   wxString sAction = m_pTimerAfterCompleteChoiceCtrl->GetString(iActionIndex);
   wxString sCountdownLabel;
   sCountdownLabel.Printf("%s in:", sAction);

   // Two column layout.
   TimerProgressDialog::MessageTable columns(2);
   auto &column1 = columns[0];
   auto &column2 = columns[1];

   column1.push_back(_("Timer Recording completed."));
   column2.push_back( {} );

   column1.push_back( {} );
   column2.push_back( {} );

   column1.push_back(_("Recording Saved:"));
   column2.push_back(((eCompletedActions & TR_ACTION_SAVED) ? _("Yes") : _("No")));

   column1.push_back(_("Recording Exported:"));
   column2.push_back(((eCompletedActions & TR_ACTION_EXPORTED) ? _("Yes") : _("No")));

   column1.push_back(_("Action after Timer Recording:"));
   column2.push_back(sAction);

   wxDateTime dtNow = wxDateTime::UNow();
   wxTimeSpan tsWait = wxTimeSpan(0, 1, 0, 0);
   wxDateTime dtActionTime = dtNow.Add(tsWait);

   TimerProgressDialog dlgAction(tsWait.GetMilliseconds().GetValue(),
                          _("Audacity Timer Record - Waiting"),
                          columns,
                          pdlgHideStopButton | pdlgHideElapsedTime,
                          sCountdownLabel);

   auto iUpdateResult = ProgressResult::Success;
   bool bIsTime = false;
   while (iUpdateResult == ProgressResult::Success && !bIsTime)
   {
      iUpdateResult = dlgAction.UpdateProgress();
      wxMilliSleep(10);
      bIsTime = (dtActionTime <= wxDateTime::UNow());
   }
   return iUpdateResult;
}
Beispiel #18
0
void wxGISMapView::PanStart(wxPoint MouseLocation)
{
	if(m_timer.IsRunning())
	{
		wxTimerEvent ev;
		OnTimer( ev );
#ifdef WAITTIME
		wxMilliSleep(WAITTIME);
#endif
		m_pTrackCancel->Cancel();
		if(m_pThread)
			m_pThread->Delete();
	}
	m_StartMouseLocation = MouseLocation;
	m_MapToolState |= enumGISMapPanning;
	CaptureMouse();//events ???
}
Beispiel #19
0
void ToasterBox::Notify()
{
	//if the list is empty, skip this
	if (winList->IsEmpty())
		return;

	wxLogDebug(_T("%s"), _T("clean&shrink"));
	//clean the window list
	CleanList();

	//figure out how many blanks we have
	ToasterBoxWindowListNode node = winList->GetFirst();
	if (!node)
		return;

	//( (our base position)-(position of this node) ) / (default height of the windows)+1
	//long blanks = ((popupPosition.y -
	//  node->GetData()->GetPosition().y) / popupSize.GetHeight()) +1;

	//move windows to fill in blank space
	for (int i = node->GetData()->GetPosition().y; i < popupPosition.y; i += 4) {
		if (i > popupPosition.y)
			i = popupPosition.y;
		//loop through all the windows
		for (unsigned int j = 0; j < winList->GetCount(); j++) {
			long ourNewHeight = i - (j * popupSize.GetHeight() - 8);
			ToasterBoxWindowListNode tmpNode = winList->Item(j);
			ToasterBoxWindow* tmpTb = tmpNode->GetData();
			//reset where the object THINKS its supposed to be
			tmpTb->SetPopupPosition(popupPosition.x, ourNewHeight);
			//actually move it
			tmpTb->SetSize(popupPosition.x, ourNewHeight,
				       tmpTb->GetSize().GetWidth(),
				       tmpTb->GetSize().GetHeight());

			//tmpNode = 0;
			tmpTb = 0;
		}

		wxMilliSleep(sleepTime);
		//DrawText();
		//Update();
	}
	StartAll();
	//node = 0;
}
Beispiel #20
0
void DeviceToolBar::OnChoice(wxCommandEvent &event)
{
   wxObject *eventObject = event.GetEventObject();
   //if we've changed hosts, we've handled the device switching already.
   if (eventObject == mHost) {
      ChangeHost();
   } else if (eventObject == mInputChannels) {
      int channelsSelectionIndex = mInputChannels->GetSelection();
      if (channelsSelectionIndex >= 0)
         gPrefs->Write(wxT("/AudioIO/RecordChannels"),channelsSelectionIndex + 1);
   } else if (eventObject == mInput) {
      ChangeDevice(true);
   }
   else if (eventObject == mOutput) {
      ChangeDevice(false);
   }

   if (gAudioIO) {
      // We cannot have gotten here if gAudioIO->IsAudioTokenActive(),
      // per the setting of AudioIONotBusyFlag and AudioIOBusyFlag in
      // AudacityProject::GetUpdateFlags().
      // However, we can have an invalid audio token (so IsAudioTokenActive()
      // is false), but be monitoring.
      // If monitoring, have to stop the stream, so HandleDeviceChange() can work.
      // We could disable the Preferences command while monitoring, i.e.,
      // set AudioIONotBusyFlag/AudioIOBusyFlag according to monitoring, as well.
      // Instead allow it because unlike recording, for example, monitoring
      // is not clearly something that should prohibit changing device.
      // TODO: We *could* be smarter in this method and call HandleDeviceChange()
      // only when the device choices actually changed. True of lots of prefs!
      // As is, we always stop monitoring before handling the device change.
      if (gAudioIO->IsMonitoring())
      {
         gAudioIO->StopStream();
         while (gAudioIO->IsBusy())
            wxMilliSleep(100);
      }
      gAudioIO->HandleDeviceChange();
   }

   // Update all projects' DeviceToolBar.
   for (size_t i = 0; i < gAudacityProjects.GetCount(); i++) {
      gAudacityProjects[i]->GetDeviceToolBar()->UpdatePrefs();
   }
}
USBDM_ErrorCode HCS12Unsecure::programSecurityLocation() {

   uint8_t unsecureFlashValue[] = {0xFF, 0xFE};
   const uint8_t allOnes   = 0xFF;
   const uint8_t allZeroes = 0x00;
   int timeout;
   uint8_t statValue;
   uint8_t Hex_02 = 0x02;
   uint8_t Hex_30 = 0x30;

   // Unsecure Chip - re-programming flash NVSEC
   print( "HCS12Unsecure::programSecurityLocation() - unsecuring target\n");

   USBDM_WriteMemory(1, 1, HCS12DeviceData::getCOPCTL(), &COPCTL_value);
   USBDM_WriteMemory(1, 1, HCS12DeviceData::getFTSTMODAddress(), &allZeroes);
   USBDM_WriteMemory(1, 1, HCS12DeviceData::getFSTATAddress(),   &Hex_02);
   USBDM_WriteMemory(1, 1, HCS12DeviceData::getFCLKDIVAddress(), &fcdivValue);
   USBDM_WriteMemory(1, 1, HCS12DeviceData::getFCLKDIVAddress(), &fcdivValue);
   USBDM_WriteMemory(1, 1, HCS12DeviceData::getFPROTAddress(),   &allOnes);
   USBDM_WriteMemory(1, 1, HCS12DeviceData::getFSTATAddress(),   &Hex_30);
   USBDM_WriteMemory(1, 1, HCS12DeviceData::getFTSTMODAddress(), &allZeroes);
   USBDM_WriteMemory(1, 1, HCS12DeviceData::getFSTATAddress(),   &Hex_02);
   USBDM_WriteMemory(2, 2, HCS12DeviceData::getNVSECAddress()-1, unsecureFlashValue);
   USBDM_WriteMemory(1, 1, HCS12DeviceData::getFCMDAddress(),    &mWordProg);
   USBDM_WriteMemory(1, 1, HCS12DeviceData::getFSTATAddress(),   &startFlashCommand);


   // Program non-volatile Flash security location
//   USBDM_WriteMemory(1, 1, HCS12DeviceData::getFPROTAddress(),   &allOnes);
//   USBDM_WriteMemory(1, 1, HCS12DeviceData::getFSTATAddress(),   &HCS12_clearFlashErrors);
//   USBDM_WriteMemory(2, 2, HCS12DeviceData::getNVSECAddress()-1, unsecureFlashValue);
//   USBDM_WriteMemory(1, 1, HCS12DeviceData::getFCMDAddress(),    &mWordProg);
//   USBDM_WriteMemory(1, 1, HCS12DeviceData::getFSTATAddress(),   &startFlashCommand);
   // Wait for flash command to complete
   timeout = 10;
   do {
      // Programming should take ???
      wxMilliSleep(100);
      if (USBDM_ReadMemory(1,1,HCS12DeviceData::getFSTATAddress(),&statValue) != BDM_RC_OK)
         return BDM_RC_FAIL;
      if (timeout-- == 0)
         return BDM_RC_FAIL;
   } while ((statValue & 0xC0) != 0xC0);
   return BDM_RC_OK;
}
Beispiel #22
0
wxThread::ExitCode TaskBase::Entry()
{
    // here we do our long task, periodically calling TestDestroy():
    // TODO(JK#1#2017-09-29): do not use _running to stop the task but another variable. Use _running = false here to check afterwards if running
    while (_running && !GetThread()->TestDestroy())
    {
        update();
        // give other tasks some time
        wxMilliSleep(1);
    }
    // call onStop whenever the thread exits its main loop (i.e is stopped by user or system)
    onStop();
    // reset recording state
    _recording = false;
    // TestDestroy() returned true (which means the main thread asked us
    // to terminate as soon as possible) or we ended the long task...
    return (wxThread::ExitCode)0;
}
Beispiel #23
0
void StopWatchTestCase::RestartBug()
{
    wxStopWatch sw;
    sw.Pause();

    // Calling Start() should resume the stopwatch if it was paused.
    static const int offset = 5000;
    sw.Start(offset);
    wxMilliSleep(sleepTime);

    long t = sw.Time();
    WX_ASSERT_MESSAGE
    (
        ("Actual time value is %ld", t),
        t > offset + sleepTime - tolerance &&
            t < offset + sleepTime + tolerance
    );
}
Beispiel #24
0
Resources::~Resources()
{
	/** check that connection checker has exited cleanly **/
	connectionChecker->Delete();
	while ( true ) {
		/** make sure we process events here, since the thread will signal with an event when done **/
		wxTheApp->ProcessPendingEvents();
		if ( connectionChecker == NULL ) {
			break;
		}
		wxMilliSleep( 1 );
	}

	delete settings;
	delete connectionDatabase;
	delete commandDatabase;
	delete versionChecker;
}
Beispiel #25
0
 bool Entry()
 {
     bool err = pPointingSource->SlewToCoordinatesAsync(ra, dec);
     if (err)
     {
         SetErrorMsg(_("Slew failed!"));
         return true;
     }
     while (pPointingSource->Slewing())
     {
         wxMilliSleep(500);
         if (IsCanceled())
         {
             pPointingSource->AbortSlew();
             SetErrorMsg(_("Slew was canceled"));
             break;
         }
     }
     return false;
 }
wxThread::ExitCode MyProgressThread::Entry()
{
	wxFrame* frame = new wxFrame(NULL, wxID_ANY, _("Rivendell Transfering File - Please Wait"));
	frame->CenterOnParent();
	frame->Show(true);
	wxGauge * myGauge = new wxGauge(frame, wxID_ANY, 300, wxDefaultPosition, wxDefaultSize, wxGAUGE_EMULATE_INDETERMINATE_MODE);
	myGauge->CenterOnParent();
	
	myGauge->Pulse();
		// do something here that takes a long time
		// it's a good idea to periodically check TestDestroy()
	while (!TestDestroy()) {
		wxMilliSleep(10);
		myGauge->Pulse();
	}
	delete myGauge;
	delete frame;

	return static_cast<ExitCode>(NULL);
}
Beispiel #27
0
void* gravApp::threadTest( void* args )
{
    gravUtil::logVerbose( "grav::starting network/decoding thread...\n" );
    gravApp* g = (gravApp*)args;
    // wait a bit before starting this thread, since doing it too early might
    // affect the WX tree before it's fully initialized somehow, rarely
    // resulting in broken text or a crash
    wxMilliSleep( 100 );
    while ( g->isThreadRunning() )
    {
        g->iterateSessions();
        if ( threadDebug )
        {
            if ( threadCounter == 0 )
                gravUtil::logVerbose( "grav::thread still running\n" );
            threadCounter = (threadCounter+1)%1000;
        }
    }
    gravUtil::logVerbose( "grav::thread ending...\n" );
    return 0;
}
Beispiel #28
0
bool wxGUIEventLoop::Dispatch()
{
    if ( !wxTheApp )
        return false;

    wxMacAutoreleasePool autoreleasepool;

    EventRef theEvent;

    OSStatus status = ReceiveNextEvent(0, NULL, m_sleepTime, true, &theEvent) ;

    switch (status)
    {
        case eventLoopTimedOutErr :
            if ( wxTheApp->ProcessIdle() )
                m_sleepTime = kEventDurationNoWait ;
            else
            {
                m_sleepTime = kEventDurationSecond;
#if wxUSE_THREADS
                wxMutexGuiLeave();
                wxMilliSleep(20);
                wxMutexGuiEnter();
#endif
            }
            break;

        case eventLoopQuitErr :
            // according to QA1061 this may also occur
            // when a WakeUp Process is executed
            break;

        default:
            DispatchAndReleaseEvent(theEvent);
            m_sleepTime = kEventDurationNoWait ;
            break;
    }

    return true;
}
int TimerRecordDialog::WaitForStart()
{
   // MY: The Waiting For Start dialog now shows what actions will occur after recording has completed
   wxString sPostAction = m_pTimerAfterCompleteChoiceCtrl->GetString(m_pTimerAfterCompleteChoiceCtrl->GetSelection());

   /* i18n-hint: Time specifications like "Sunday 28th October 2007 15:16:17 GMT"
   * but hopefully translated by wxwidgets will be inserted into this */
   wxString strMsg;
   strMsg.Printf(_("Waiting to start recording at:\t%s\n") +
      _("Recording duration:\t\t%s\n") +
      _("Scheduled to stop at:\t\t%s\n\n") +
      _("Automatic Save Enabled:\t\t%s\n") +
      _("Automatic Export Enabled:\t\t%s\n") +
      _("Post Timer Recording Action:\t%s"),
      GetDisplayDate(m_DateTime_Start).c_str(),
      m_TimeSpan_Duration.Format(),
      GetDisplayDate(m_DateTime_End).c_str(),
      (m_bAutoSaveEnabled ? _("Yes") : _("No")),
      (m_bAutoExportEnabled ? _("Yes") : _("No")),
      sPostAction);

   wxDateTime startWait_DateTime = wxDateTime::UNow();
   wxTimeSpan waitDuration = m_DateTime_Start - startWait_DateTime;
   TimerProgressDialog progress(waitDuration.GetMilliseconds().GetValue(),
      _("Audacity Timer Record - Waiting for Start"),
      strMsg,
      pdlgHideStopButton | pdlgConfirmStopCancel | pdlgHideElapsedTime,
      _("Recording will commence in:"));

   int updateResult = eProgressSuccess;
   bool bIsRecording = false;
   while (updateResult == eProgressSuccess && !bIsRecording)
   {
      updateResult = progress.Update();
      wxMilliSleep(10);
      bIsRecording = (m_DateTime_Start <= wxDateTime::UNow());
   }
   return updateResult;
}
Beispiel #30
0
void gravApp::idleHandler( wxIdleEvent& evt )
{
    // start secondary thread if not running
    if ( usingThreads && !threadRunning )
    {
        grav->setThreads( usingThreads );
        threadRunning = true;
        VPMthread = thread_start( threadTest, this );
    }

    if ( !usingThreads )
        sessionManager->iterateSessions();

    if ( timerIntervalUS > 0 )
    {
        // this is the method for rendering on idle, with a limiter based on the
        // timer interval
        unsigned long time = (unsigned long)timer->getTiming();
        if ( time > (unsigned long)timerIntervalUS )
        {
            //gravUtil::logVerbose( "%lu\n", time );
            canvas->draw();
            timer->resetTiming();
        }
        else
        {
            wxMilliSleep( 1 );
        }
    }
    // otherwise (if fps value isn't set) just constantly draw - if vsync is on,
    // will be limited to vsync
    else if ( timerIntervalUS == 0 )
    {
        canvas->draw();
    }

    evt.RequestMore();
}