Beispiel #1
0
//--------------------------------------------------------------
void ofApp::update(){
    //update gui stuff
    filesToPlayTextInput->update();
    playButton->update();
    loopButton->update();
    toggleButton->update();
    
    // hide old osc messages
    for(int i = 0; i < NUM_MSG_STRINGS; i++){
        if(timers[i] < ofGetElapsedTimef()){
            msg_strings[i] = "";
        }
    }
    
    // check for waiting osc messages
    while(receiver.hasWaitingMessages()){
        ofxOscMessage m;
        receiver.getNextMessage(m);
        confirmMessage(m);
    }
    
    //if we just sent some messages and need confirmation
    if (m_bNeedOscConf){
        //check every 10 updates
        if (++m_lUpdateCtr % 10 == 0){
            //if all were confirmed
            bool bAllConfirmed = true;
            for (int i=0; i<NUM_RPIS; ++i){
                if (!m_bOscConfirmations[i]){
                    logMsg("no " + to_string(i+1));
                    bAllConfirmed = false;
                }
            }
            //if not, send again
            if (!bAllConfirmed){
                resendMessagesToAll();
            } else {
                resetOscConfs();
                m_bNeedOscConf = false;
            }
        }
    } else {
        m_lUpdateCtr = 0;
    }
    
#if OSC_SENDER_PLAYS_AUDIO
    if (m_bStartedSoundPlayer){
        if (soundPlayer.isPlaying()){
            m_bSoundPlayerIsPlaying = true;
        } else {
            soundPlayerJustStoppedPlaying();
        }
    }
#endif
}
Beispiel #2
0
bool GuiManager::confirmDialogSwitch(int nextWindow) {
  if (runnerRunning_) {
    wxMessageDialog confirmMessage(NULL,
        "This will abort the currently running Game Runner. Are you sure?",
        "Abort Game Runner", wxOK | wxCANCEL | wxICON_EXCLAMATION);
    int r = confirmMessage.ShowModal();
    if (r == wxID_OK) {
      nextWindow_ = nextWindow;
      gameRunner_->quit();
    }
    return false;
  }
  return true;
}
Beispiel #3
0
// Returns 0 for success, 1 for timeout, 2 for CRC failure
int getMessage(MessageType *msgType, uint16_t *msgLength, uint16_t *flags, uint8_t *msg)
{
    int c, n;

    // Take in data until the start of a message
    do
    {
        c = getCharWait(MESSAGE_TIMEOUT);
    } while (c > -255 && c != '#');

    if (c == -255) return 1;

    MsgHeader header;

    // Read in the hex-encoded header
    n = readHex((uint8_t *)&header, sizeof(header));
    if (n < sizeof(header)) return 1;

    // Avoid buffer overflows
    if (header.length > MAX_MESSAGE_LENGTH) header.length = MAX_MESSAGE_LENGTH;

    *msgType = (MessageType)header.type;
    *msgLength = header.length;
    *flags = header.flags;

    // Read in the message
    n = readHex(msg, header.length);
    if (n < header.length) return 1;

    // Perform a CRC16 check on the message
    uint16_t crc = calcCrc16((uint8_t *)&header + 2, sizeof(header) - 2);
    crc = calcCrc16(msg, header.length, crc);
    if (crc != header.crc) return 2;

    if (header.flags & CONFIRMATION_NEEDED_FLAG) confirmMessage(header.id);

    return 0;
}