Beispiel #1
0
void ofApp::confirmMessage(ofxOscMessage m){
    //figure out which pi
    string sIp = m.getRemoteIp();
    string msgContent = getMsgContent(m);
    int iCurPi = -1;
    if (hasEnding(sIp, pi1_ip)){
        iCurPi = 0;
        m_bOscConfirmations[0] = true;
        logMsg("got msg from 1: " + msgContent);
    }
    else if (hasEnding(sIp, pi2_ip)){
        iCurPi = 1;
        m_bOscConfirmations[1] = true;
        logMsg("got msg from 2: " + msgContent);
    }
    else if (hasEnding(sIp, pi3_ip)){
        iCurPi = 2;
        m_bOscConfirmations[2] = true;
        logMsg("got msg from 3: " + msgContent);
    }
    else if (hasEnding(sIp, pi4_ip)){
        iCurPi = 3;
        m_bOscConfirmations[3] = true;
        logMsg("got msg from 4: " + msgContent);
    } else {
        logMsg("got msg from UNKNOWN " + sIp + ": " + msgContent);
    }
    
    //update corresponding status
    string sCurStatus = "";
    int iCurArg = 1;
    string sStatus  = m.getArgAsString(iCurArg++);
    string sFile    = m.getArgAsString(iCurArg++);
    iCurArg += 2;
    bool bLoop      = m.getArgAsInt(iCurArg++);
    if (hasEnding(sStatus, "stoped")){
        sCurStatus += "Stopped";
    } else {
        if (bLoop){
            sCurStatus += "Loop\t";
        } else {
            sCurStatus += "Play\t";
        }
        sCurStatus += sFile;
    }
    m_sRpiStatuses[iCurPi] = sCurStatus;
}
Beispiel #2
0
//-------------------------------------------------------------
void ofApp::handleMessage(ofxOscMessage m) {
    string send_string;
    string address_string;
    string ip_string;
    
    ip_string = "/" + ofSplitString( ofToString(m.getRemoteIp()), ".")[3];
    
    // check for battery message
    if(m.getAddress() == "/battery"){
        if(m.getArgType(0) == OFXOSC_TYPE_FLOAT){
            // construct OSC message to send
            sendBattery( ip_string, m.getArgAsFloat(0));
        }
    }
    
    // check for blob message
    else if(m.getAddress() == "/inputs/serial/1") {
        for(int i = 0; i < m.getNumArgs(); i++){
            // get the argument type
            if(m.getArgType(i) == OFXOSC_TYPE_BLOB){
                string blob = m.getArgAsBlob(0);
                vector<string> parameters = ofSplitString(blob, ",");
                if( parameters.size() >= 5 ) {
                    int distance = ofToInt(parameters[0]);
                    int velocity = ofToInt(parameters[1]);
                    int azimuth = ofToInt(parameters[2]);
                    int elevation = ofToInt(parameters[3]);
                    float angularRate = ofToFloat(parameters[4]);
                    
                    // send osc messages
                    sendDistance(ip_string, distance);
                    sendVelocity(ip_string, velocity);
                    sendAzimuth(ip_string, azimuth);
                    sendElevation(ip_string, elevation);
                    sendAngularRate(ip_string, angularRate);
                }
            }
        }
    }
}