コード例 #1
0
ファイル: IntanThread.cpp プロジェクト: malfatti/GUI
bool IntanThread::stopAcquisition()
{

    isTransmitting = false;

    std::cout << "Received signal to terminate thread." << std::endl;

    if (isThreadRunning())
    {
        signalThreadShouldExit();
    }

    std::cout << "Thread stopped successfully, stopping Intan Board." << std::endl;

    if (!simulateDataStream)
    {
        int return_value;

        if ((return_value = ftdi_write_data(&ftdic, &stopCode, 1)) > 0)
        {
            unsigned char buf[4097]; // has to be bigger than the on-chip buffer
            ftdi_read_data(&ftdic, buf, sizeof(buf));
            //closeUSB();
        }
        else
        {
            std::cout << "No device found." << std::endl;
            deviceFound = false;
        }
    }
   
    return true;
}
コード例 #2
0
 ~SharedMessageThread()
 {
     signalThreadShouldExit();
     JUCEApplication::quit();
     waitForThreadToExit (5000);
     clearSingletonInstance();
 }
コード例 #3
0
ファイル: DeadlineTimer.cpp プロジェクト: xdv/divvyd
 ~Manager ()
 {
     signalThreadShouldExit ();
     notify ();
     waitForThreadToExit ();
     bassert (m_items.empty ());
 }
コード例 #4
0
NMListener::~NMListener() {
  DBG(__func__ << ": cleanup thread");
  if (isThreadRunning()) {
    signalThreadShouldExit();
    notify();
    stopThread(2000);
  }
}
コード例 #5
0
ファイル: WebInterface.cpp プロジェクト: eriser/rejuce
void WebInterface::stop()
{
	char outbuf[128];
	outbuf[0] = 0;
	mg_write(_conn, outbuf, 1);

	signalThreadShouldExit();
	waitForThreadToExit(-1);
}
コード例 #6
0
ファイル: FileReaderThread.cpp プロジェクト: ankit--sethi/GUI
bool FileReaderThread::stopAcquisition()
{
    std::cout << "File reader received disable signal." << std::endl;
    if (isThreadRunning())
    {
        signalThreadShouldExit();
    }

    return true;
}
コード例 #7
0
bool MyTestThread::stopAcquisition()
{
    std::cout << "MyTestThread received disable signal." << std::endl;
    if (isThreadRunning())
    {
        signalThreadShouldExit();
    }

    return true;
}
コード例 #8
0
ファイル: Thread.cpp プロジェクト: 619213152/vpal20
void Thread::stopThreadAsync ()
{
    const RecursiveMutex::ScopedLockType sl (startStopLock);

    if (isThreadRunning())
    {
        signalThreadShouldExit();
        notify();
    }
}
コード例 #9
0
void InterprocessConnectionServer::stop()
{
    signalThreadShouldExit();

    if (socket != nullptr)
        socket->close();

    stopThread (4000);
    socket = nullptr;
}
コード例 #10
0
ファイル: Thread.cpp プロジェクト: bachase/rippled
void Thread::stopThreadAsync ()
{
    std::lock_guard<std::recursive_mutex> sl (startStopLock);

    if (isThreadRunning())
    {
        signalThreadShouldExit();
        notify();
    }
}
コード例 #11
0
ファイル: ThorUpdateThread.cpp プロジェクト: bergsail/thor-v2
void ThorUpdateThread::timerCallback()
{
	Logger::writeToLog (T("timeout reached, exit update thread"));
	if (updateUrl)
		deleteAndZero (updateUrl);

	stopTimer();
	stopThread(150);
	signalThreadShouldExit ();

	return;
}
コード例 #12
0
void InterprocessConnection::disconnect()
{
    signalThreadShouldExit();

    {
        const ScopedLock sl (pipeAndSocketLock);
        if (socket != nullptr)  socket->close();
        if (pipe != nullptr)    pipe->close();
    }

    stopThread (4000);
    deletePipeAndSocket();
    connectionLostInt();
}
コード例 #13
0
ファイル: RHD2000Thread.cpp プロジェクト: Rummell/GUI
bool RHD2000Thread::stopAcquisition()
{

    //	isTransmitting = false;
    std::cout << "RHD2000 data thread stopping acquisition." << std::endl;

    if (isThreadRunning())
    {
        signalThreadShouldExit();

    }

    if (waitForThreadToExit(500))
    {
        std::cout << "Thread exited." << std::endl;
    }
    else
    {
        std::cout << "Thread failed to exit, continuing anyway..." << std::endl;
    }

	if (deviceFound)
    {
        evalBoard->setContinuousRunMode(false);
        evalBoard->setMaxTimeStep(0);
        std::cout << "Flushing FIFO." << std::endl;
        evalBoard->flush();
     //   evalBoard->setContinuousRunMode(true);
     //   evalBoard->run();

    }

    dataBuffer->clear();

	if (deviceFound)
	{
		cout << "Number of 16-bit words in FIFO: " << evalBoard->numWordsInFifo() << endl;

		// std::cout << "Stopped eval board." << std::endl;


		int ledArray[8] = {1, 0, 0, 0, 0, 0, 0, 0};
		evalBoard->setLedDisplay(ledArray);
	}
    isTransmitting = false;

    return true;
}
コード例 #14
0
ファイル: WSDoor.cpp プロジェクト: BattleProgrammer/stellard
    void onStop ()
    {
        boost::shared_ptr<websocketpp::server_multitls> endpoint;

        {
            ScopedLockType lock (m_endpointLock);

             endpoint = m_endpoint;
        }

        // VFALCO NOTE we probably dont want to block here
        //             but websocketpp is deficient and broken.
        //
        if (endpoint)
            endpoint->stop ();

        signalThreadShouldExit ();
    }
コード例 #15
0
ファイル: DataThread.cpp プロジェクト: jperge/GUI_Jan7_2016
void DataThread::run()
{

    while (!threadShouldExit())
    {

        if (!updateBuffer())
        {

            const MessageManagerLock mmLock(Thread::getCurrentThread());

            std::cout << "Aquisition error...stopping thread." << std::endl;
            signalThreadShouldExit();
            std::cout << "Notifying source node to stop acqusition." << std::endl;
            sn->acquisitionStopped();
        }

    }
}
コード例 #16
0
ファイル: Thread.cpp プロジェクト: 619213152/vpal20
bool Thread::stopThread (const int timeOutMilliseconds)
{
    bool cleanExit = true;

    // agh! You can't stop the thread that's calling this method! How on earth
    // would that work??
    bassert (getCurrentThreadId() != getThreadId());

    const RecursiveMutex::ScopedLockType sl (startStopLock);

    if (isThreadRunning())
    {
        signalThreadShouldExit();
        notify();

        if (timeOutMilliseconds != 0)
        {
            cleanExit = waitForThreadToExit (timeOutMilliseconds);
        }

        if (isThreadRunning())
        {
            bassert (! cleanExit);

            // very bad karma if this point is reached, as there are bound to be
            // locks and events left in silly states when a thread is killed by force..
            killThread();

            threadHandle = nullptr;
            threadId = 0;

            cleanExit = false;
        }
        else
        {
            cleanExit = true;
        }
    }

    return cleanExit;
}
コード例 #17
0
void SocketListener::stopListening() {
    signalThreadShouldExit();
    socket = nullptr;
    waitForThreadToExit(0);
    
}
コード例 #18
0
ファイル: LedgerCleaner.cpp プロジェクト: reecer/rippled
 void onStop ()
 {
     m_journal.info << "Stopping";
     signalThreadShouldExit();
     notify();
 }
コード例 #19
0
void MainContentComponent::buttonClicked (Button *button)
{
    if (button == installButton)
    {
        // === Locate the AlphaLive directory ===
        
        alphaLiveDirectory = File::getSpecialLocation (File::globalApplicationsDirectory).getFullPathName() +
                                 File::separatorString +
                                 "AlphaLive";
        
        bool continueInstallation = true;
        
        if (! alphaLiveDirectory.isDirectory())
        {
            //If can't be found, ask user to manually locate it
            
            bool userSelection = AlertWindow::showOkCancelBox(AlertWindow::WarningIcon, 
                                                              translate("AlphaLive not found!"), 
                                                              translate("The AlphaLive folder can not be found on your computer. Please manually locate it."));
            if (userSelection == true)
            {
                FileChooser myChooser (translate("Please select the AlphaLive directory..."),
                                       File::getSpecialLocation (File::globalApplicationsDirectory));
                
                if (myChooser.browseForDirectory() == true)
                {
                    // Perform some basic check to see if this is the AlphaLive directory
                    
                    #if JUCE_MAC || JUCE_LINUX
                    File alphaLiveApp (myChooser.getResult().getFullPathName() + File::separatorString + "AlphaLive.app");
                    #endif
                    #if JUCE_WINDOWS
                    File alphaLiveApp (myChooser.getResult().getFullPathName() + File::separatorString + "AlphaLive.exe");
                    #endif
                    
                    if (alphaLiveApp.exists())
                    {
                        // Presume that this is the AlphaLive directory
                        alphaLiveDirectory = myChooser.getResult();
                    }
                    else
                    {
                        AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
                                                          translate("Error!"),
                                                          translate("The selected directory does not contain the AlphaLive application. Please try again."));
                        continueInstallation = false;
                    }
                }
                else
                    continueInstallation = false;
            }
            else
                continueInstallation = false;
        }
        
        
        if (continueInstallation == true)
        {
            startThread();
        }
    }
    
    else if (button == closeButton)
    {
        JUCEApplication::quit();
    }
    
    else if (button == cancelButton)
    {
        bool userSelection = AlertWindow::showOkCancelBox(AlertWindow::WarningIcon, 
                                                          translate("Are you sure?"), 
                                                          translate("Are you sure you want to cancel? The audio library will not be fully installed if so."));
        if (userSelection == true)
        {
            signalThreadShouldExit();
        }
    }
}
コード例 #20
0
ファイル: FileReader.cpp プロジェクト: eliezyer/plugin-GUI
FileReader::~FileReader()
{
    signalThreadShouldExit();
    notify();
}
コード例 #21
0
void MainContentComponent::run()
{
    // Do the following in a seperate thread so the GUI can be updated correctly.
    
    {
        const MessageManagerLock mmLock;
        closeButton->setVisible(false);
        installButton->setVisible(false);
        cancelButton->setVisible(true);
        
        progressBar->setVisible(true);
    }
    
    bool installationCancelled = false;
    
    while (! threadShouldExit())
    {
        // Get all needed file paths
        
        const File audioLibraryDir (alphaLiveDirectory.getFullPathName() + 
                              File::separatorString +
                              "Library" +
                              File::separatorString +
                              "Audio Library");
        if (! audioLibraryDir.isDirectory())
            audioLibraryDir.createDirectory();
        
        const File projectsDir (File::getSpecialLocation (File::userDocumentsDirectory).getFullPathName() + 
                          File::separatorString +
                          "AlphaLive Projects");
        if (! projectsDir.isDirectory())
            projectsDir.createDirectory();
        
        const File dataToCopy (File::getSpecialLocation (File::currentApplicationFile).getParentDirectory().getParentDirectory().getFullPathName() + 
                         File::separatorString + 
                         "Data");
        
        
        
        if (dataToCopy.exists())
        {
            // Work out the total size of the files being copied,
            // so we can work out a percentage for the progress bar.
            int totalSize = 0;
            int extractedSize = 0;
            
            Array<File> allFiles;
            dataToCopy.findChildFiles(allFiles, 3, true);
            for (int i = 0; i < allFiles.size(); i++)
                totalSize += allFiles[i].getSize();
            allFiles.clear();
            
            // For the audio library don't just copy the entire directories,
            // incase the user has already installed them and added their own files.
            // Simply copying the directories would replace
            // any new or modified files, so we must copy each file individually.
            
            //TO DO:
            //The following section contains 3 very similiar sub-sections, which each install a different part.
            //This could probably be consolidated into a single algorithm that runs 3 times, but has different
            //filepaths each time.
            //You would need the following File objects: contentToInstallDir and locationToInstallDir.
            
            //====================================================================================================
            //Install the audio library directory into the AlphaLive/Library directory
            
            Array<File> filesToCopy;
            File audioDir (dataToCopy.getFullPathName() + File::separatorString + "Audio Library");
            audioDir.findChildFiles(filesToCopy, 2, true);
            
            for (int i = 0; i < filesToCopy.size(); i++)
            {
                // Increase the extracted size to we can work out the current progress bar value
                extractedSize += filesToCopy[i].getSize();
                // Get progress to a value between 0 and 1 (NOT 0 and 100) to update the progress bar correctly
                progress = ((extractedSize * 0.0001)/(totalSize * 0.0001));
                
                File newFile (audioLibraryDir.getFullPathName() + 
                              File::separatorString + 
                              filesToCopy[i].getRelativePathFrom(audioDir));
                
                // Only copy the file if it doesn't already exist
                if (! newFile.exists())
                {
                    {
                        const MessageManagerLock mmLock;
                        String string (translate("Extracting files...") + "\n" + newFile.getFileName());
                        infoLabel->setText(string, dontSendNotification);
                    }
                    
                    // If the files parent directory doesn't exist, create it, otherwise the file won't copy.
                    
                    bool doesParentExist = newFile.getParentDirectory().isDirectory();
                    if (doesParentExist == false)
                    {
                        File parentDir (newFile.getParentDirectory());
                        parentDir.createDirectory();
                    }
                    
                    if (threadShouldExit() == true)
                    {
                        installationCancelled = true;
                        break;
                    }
                    
                    filesToCopy[i].copyFileTo(newFile);
                    
                }
            }
            
            if (threadShouldExit() == true)
            {
                installationCancelled = true;
                break;
            }
            
            //====================================================================================================
            // Install the demo project into the AlphaLive Projects directory
            // NEW to version 1.0.2 - always replace the existing demo project
            // However still need to copy files one by one so that the progress bar
            // can update in realtime.
            
            filesToCopy.clear();
            File demoProjDir (dataToCopy.getFullPathName() + File::separatorString + "Demo Project");
            demoProjDir.findChildFiles(filesToCopy, 2, true);
            File newDemoProjDir (projectsDir.getFullPathName() + File::separatorString + "Demo Project");
            
            if (newDemoProjDir.exists())
                newDemoProjDir.deleteRecursively();
            
            for (int i = 0; i < filesToCopy.size(); i++)
            {
                // Increase the extracted size to we can work out the current progress bar value
                extractedSize += filesToCopy[i].getSize();
                // Get progress to a value between 0 and 1 (NOT 0 and 100) to update the progress bar correctly
                progress = ((extractedSize * 0.0001)/(totalSize * 0.0001));
                
                File newFile (newDemoProjDir.getFullPathName() + 
                              File::separatorString + 
                              filesToCopy[i].getRelativePathFrom(demoProjDir));
                
                {
                    const MessageManagerLock mmLock;
                    String string (translate("Extracting files...") + "\n" + newFile.getFileName());
                    infoLabel->setText(string, dontSendNotification);
                }
                
                // If the files parent directory doesn't exist, create it, otherwise the file won't copy.
                
                bool doesParentExist = newFile.getParentDirectory().isDirectory();
                if (doesParentExist == false)
                {
                    File parentDir (newFile.getParentDirectory());
                    parentDir.createDirectory();
                }
                
                if (threadShouldExit() == true)
                {
                    installationCancelled = true;
                    break;
                }
                
                filesToCopy[i].copyFileTo(newFile);
                
            }
        
            if (threadShouldExit() == true)
            {
                installationCancelled = true;
                break;
            }
            
            //====================================================================================================
            // Install the tutorial project into the AlphaLive Projects directory
            // NEW to version 1.0.2 - always replace the existing tutorial project.
            // However still need to copy files one by one so that the progress bar
            // can update in realtime.
            
            filesToCopy.clear();
            File tutorialProjDir (dataToCopy.getFullPathName() + File::separatorString + "Tutorial Project");
            tutorialProjDir.findChildFiles(filesToCopy, 2, true);
            File newTutorialProjDir (projectsDir.getFullPathName() + File::separatorString + "Tutorial Project");
            
            if (newTutorialProjDir.exists())
                newTutorialProjDir.deleteRecursively();
            
            for (int i = 0; i < filesToCopy.size(); i++)
            {
                // Increase the extracted size to we can work out the current progress bar value
                extractedSize += filesToCopy[i].getSize();
                // Get progress to a value between 0 and 1 (NOT 0 and 100) to update the progress bar correctly
                progress = ((extractedSize * 0.0001)/(totalSize * 0.0001));
                
                File newFile (newTutorialProjDir.getFullPathName() + 
                              File::separatorString + 
                              filesToCopy[i].getRelativePathFrom(tutorialProjDir));
                
                {
                    const MessageManagerLock mmLock;
                    String string (translate("Extracting files...") + "\n" + newFile.getFileName());
                    infoLabel->setText(string, dontSendNotification);
                }
                
                // If the files parent directory doesn't exist, create it, otherwise the file won't copy.
                
                bool doesParentExist = newFile.getParentDirectory().isDirectory();
                if (doesParentExist == false)
                {
                    File parentDir (newFile.getParentDirectory());
                    parentDir.createDirectory();
                }
                
                if (threadShouldExit() == true)
                {
                    installationCancelled = true;
                    break;
                }
                
                filesToCopy[i].copyFileTo(newFile);
                
            }
            
            //====================================================================================================
            //====================================================================================================
            //NEW - set the installed Demo and Tutorial project files to read-only.

			File demoProjFile (newDemoProjDir.getFullPathName() + File::separatorString + "Demo Project.alphalive");
            File tutorialProjFile (newTutorialProjDir.getFullPathName() + File::separatorString + "Tutorial Project.alphalive");
            
            #if JUCE_MAC || JUCE_LINUX
            
            //To set the file permissions to read only, you can use the command chmod 555 in terminal
            //or use th chmod() function as documented here:
            //http://www.manpagez.com/man/2/chmod/osx-10.4.php
            
            chmod (demoProjFile.getFullPathName().toUTF8(), S_IRUSR | S_IRGRP | S_IROTH);
            chmod (tutorialProjFile.getFullPathName().toUTF8(), S_IRUSR | S_IRGRP | S_IROTH);
            
            #endif
            
            #if JUCE_WINDOWS

			//Use the SetFileAttributes() function here like so:
			//http://msdn.microsoft.com/en-us/library/windows/desktop/aa365535(v=vs.85).aspx
			//to get more control over editting file permissions, you can use cacls

            SetFileAttributes(demoProjFile.getFullPathName().toUTF8(), FILE_ATTRIBUTE_READONLY);
			SetFileAttributes(tutorialProjFile.getFullPathName().toUTF8(), FILE_ATTRIBUTE_READONLY);

            #endif   
        }
        else
        {
            AlertWindow::showMessageBoxAsync (AlertWindow::WarningIcon,
                                              translate("Error!"),
                                              translate("The files that need installing appear to be missing. If this installer was supplied to you on a CD, please run it directly from the CD. If you downloaded this installer, please run it directly from the downloaded folder."));

			installationCancelled = true;
        }
        
        
        signalThreadShouldExit();
    }
    
    if (installationCancelled == true)
    {
        const MessageManagerLock mmLock;
        infoLabel->setText(translate("Installation cancelled!"), dontSendNotification);
        
        closeButton->setVisible(true);
        installButton->setVisible(true);
        cancelButton->setVisible(false);
        progressBar->setVisible(false);
    }
    else
    {
        const MessageManagerLock mmLock;
        infoLabel->setText(translate("Installation complete!"), dontSendNotification);
        LookAndFeel::getDefaultLookAndFeel().playAlertSound();
        
        closeButton->setVisible(true);
        installButton->setVisible(false);
        cancelButton->setVisible(false);
        progressBar->setVisible(false);
        
    }
    
}
コード例 #22
0
ファイル: Sequencer.cpp プロジェクト: eriser/rejuce
void Sequencer::stop()
{
	signalThreadShouldExit();
	waitForThreadToExit(-1);
}