void ofxRPiCameraVideoGrabber::setup(CameraState cameraState) { setup(cameraState.cameraSettings); map<string, string> keyValueMap = cameraState.keyValueMap; for(auto iterator = keyValueMap.begin(); iterator != keyValueMap.end(); iterator++) { string key = iterator->first; string value = iterator->second; //ofLogVerbose(__func__) << "key: " << key << " value: " << value; if(key == "sharpness") setSharpness(ofToInt(value)); if(key == "contrast") setContrast(ofToInt(value)); if(key == "brightness") setBrightness(ofToInt(value)); if(key == "saturation") setSaturation(ofToInt(value)); if(key == "ISO") setISO(ofToInt(value)); if(key == "AutoISO") setAutoISO(ofToBool(value)); if(key == "DRE") setDRE(ofToInt(value)); if(key == "cropRectangle") { vector<string> rectValues = ofSplitString(value, ","); if(rectValues.size() == 4) { setSensorCrop(ofToInt(rectValues[0]), ofToInt(rectValues[1]), ofToInt(rectValues[2]), ofToInt(rectValues[3])); } } if(key == "zoomLevelNormalized") setZoomLevelNormalized(ofToFloat(value)); if(key == "mirror") setMirror(value); if(key == "rotation") setRotation(ofToInt(value)); if(key == "imageFilter") setImageFilter(value); if(key == "exposurePreset") setExposurePreset(value); if(key == "evCompensation") setEvCompensation(ofToInt(value)); if(key == "autoShutter") setAutoShutter(ofToBool(value)); if(key == "shutterSpeed") setShutterSpeed(ofToInt(value)); if(key == "meteringType") setMeteringType(value); if(key == "SoftwareSaturationEnabled") setSoftwareSaturation(ofToBool(value)); if(key == "SoftwareSharpeningEnabled") setSoftwareSharpening(ofToBool(value)); } }
Timeline::Timeline(){ this->isShow = ofToBool( ConfigLoader::singleton()->Value("System", "showTimeline") ); this->tick_size = ofToInt(ConfigLoader::singleton()->Value("Timeline", "tick_height"))/2; this->line_color = Util::hexToColor(ConfigLoader::singleton()->Value("Timeline", "line_color")); this->max_font = Pen::singleton()->getFont("Timeline"); this->monthNames[0] = "Jan"; this->monthNames[1] = "Feb"; this->monthNames[2] = "Mar"; this->monthNames[3] = "Apr"; this->monthNames[4] = "May"; this->monthNames[5] = "Jun"; this->monthNames[6] = "Jul"; this->monthNames[7] = "Aug"; this->monthNames[8] = "Sep"; this->monthNames[9] = "Oct"; this->monthNames[10] = "Nov"; this->monthNames[11] = "Dec"; }
int Telemetry::parse(string line) { ofLogNotice() << "onNewSerialLine, message: " << line << endl; vector<string> input = ofSplitString(line, ","); string msgtype = input.at(0); if(msgtype == "GPSL") { if( input.size() == 3) { ofLogNotice() << "GPSL line found"; gps.lat = ofToFloat( input.at(1) ); gps.lon = ofToFloat( input.at(2) ); int i = 0; ofNotifyEvent( onGpsCoordinates, i ); } else { ofLogNotice() << "ignored GPS reading: " << line; } } else if (msgtype == "GPSQ") { if( input.size() == 4) { ofLogNotice() << "GPSQ line found"; gps.fix = ofToBool( input.at(1) ); gps.quality = ofToInt( input.at(2) ); gps.satelites = ofToInt( input.at(3) ); } else { ofLogNotice() << "ignored GPS reading: " << line; } } else if(msgtype == "IMU") { if( input.size() == 4) { imu.yaw = ofToFloat( input.at(1) ); imu.pitch = ofToFloat( input.at(2) ); imu.roll = ofToFloat( input.at(3) ); } else { ofLogNotice() << "rejected IMU reading: " << line; } // ofLogNotice() << "IMU line found"; // for ( std::vector<std::string>::iterator it=input.begin(); it<input.end(); it++) { // std::cout << ' ' << *it; // } } }
void GenericClientManager::checkServerMessages() { string response=""; bool received=false; // <message fps="18" messageError="true" lastSequenceNumber="330"> response= this->tcpClient.receive(); if( response.length() > 0 ) { received=true; } if (received) { ofxXmlSettings XML; XML.loadFromBuffer(response); TiXmlElement* serverMessage=XML.doc.RootElement(); if (serverMessage) { string fpsName = "fps"; if (serverMessage->Attribute(fpsName.c_str())) { int messageFps = ofToInt(serverMessage->Attribute("fps")); this->newFps= messageFps; } string messageErrorName = "messageError"; if(serverMessage->Attribute(messageErrorName.c_str())) { bool error = ofToBool(serverMessage->Attribute("messageError")); if (error) { this->waitForReceiver= 15; // wait 15 frames until the server cleans his buffer string lastSequenceNumberName = "lastSequenceNumber"; if(serverMessage->Attribute(lastSequenceNumberName.c_str())) { this->sequenceNumber = ofToInt(serverMessage->Attribute("lastSequenceNumber")) + 1; string responseMessage = "<?xml version=\"1.0\" ?><ErrorACK sequence='" + ofToString(this->sequenceNumber) + "'></ErrorACK>"; this->tcpClient.send(responseMessage); } } } } } }
/** * Get the Boolean of a specific row and column. * * @param row * row number * @param col * column number * @return bool */ bool ofxCsv::getBool(int row, int col){ return ofToBool(data[row][col]); }
/* * Load external instrument definitions */ void FluidPlayer::loadInstruments() { ofDirectory instrumentDir("instruments"); instrumentDir.listDir(); vector<ofFile> instrumentFiles = instrumentDir.getFiles(); for(int i=0; i < instrumentFiles.size(); i++) { ofxXmlSettings xmlInstrument; xmlInstrument.loadFile( instrumentDir.getOriginalDirectory() + instrumentFiles[i].getFileName() ); xmlInstrument.pushTag("instrument"); xmlInstrument.pushTag("properties"); //Create a new instrument definition FluidInstrument instrument; instrument.setID(i); instrument.name = xmlInstrument.getValue("name", ""); instrument.device = xmlInstrument.getValue("device", ""); instrument.channel = xmlInstrument.getValue("channel", 0); instrument.program = xmlInstrument.getValue("program", 0); instrument.dyeColour = ofVec3f(xmlInstrument.getValue("colourR",1.0f), xmlInstrument.getValue("colourG",1.0f), xmlInstrument.getValue("colourB",1.0f)); instrument.usesCCNoteTriggers = ofToBool(xmlInstrument.getValue("usesCCNoteTriggers", "")); int timbreType, noteMapping; if(xmlInstrument.getValue("timbre", "") == "mono") instrument.timbreType = INSTRUMENT_TYPE_MONOPHONIC; else if(xmlInstrument.getValue("timbre", "") == "poly") instrument.timbreType = INSTRUMENT_TYPE_POLYPHONIC; if(xmlInstrument.getValue("noteMappings", "") == "note") instrument.noteMapping = INSTRUMENT_PLAYS_NOTES; else if(xmlInstrument.getValue("noteMappings", "") == "cc") instrument.noteMapping = INSTRUMENT_PLAYS_CC; xmlInstrument.popTag(); xmlInstrument.pushTag("parameters"); //Set instrument parameters and mappings -- CC int j; int numCCParams = xmlInstrument.getNumTags("cc"); for(j = 0; j < numCCParams; j++) { xmlInstrument.pushTag("cc", j); InstrumentParameter param; param.noteType = INSTRUMENT_PLAYS_CC; param.channel = xmlInstrument.getValue("channel" , 0); param.source = instrument.getParamSourceFromString( xmlInstrument.getValue("source", "") ); param.value = xmlInstrument.getValue("value" , 0); param.lowerNoteRange = xmlInstrument.getValue("min", 0); param.upperNoteRange = xmlInstrument.getValue("max", 0); instrument.addparam(param); instrument.addNoteParam(param, true); xmlInstrument.popTag(); } //Set instrument parameters and mappings -- NOTE int numNoteParams = xmlInstrument.getNumTags("note"); for(j = 0; j < numNoteParams; j++) { xmlInstrument.pushTag("note", j); InstrumentParameter param; param.noteType = INSTRUMENT_PLAYS_NOTES; param.source = instrument.getParamSourceFromString( xmlInstrument.getValue("source", "") ); param.lowerNoteRange = xmlInstrument.getValue("min", 0); param.upperNoteRange = xmlInstrument.getValue("max", 0); instrument.addparam(param); instrument.addNoteParam(param, false); xmlInstrument.popTag(); } instrumentList.push_back(instrument); } }
bool SettingItem::GetValBool(bool defaultVal) { if (values.size() == 0) return defaultVal; return ofToBool(values[0]); }
SeasonClock::SeasonClock(){ this->clock.loadImage(ConfigLoader::singleton()->Value("file_path", "season_clock")); this->arrow.loadImage(ConfigLoader::singleton()->Value("file_path", "season_clock_arrow")); this->isShow = ofToBool( ConfigLoader::singleton()->Value("System", "showSeasonclock") ); }
void testApp::setup() { string splitInput = " a,,b,c,"; splitTest(" a,,b, c , ", ","); splitTest(" a<><>b<> c <> ", "<>"); cout << "empty" << endl; cout << ofToInt("") << endl; cout << ofToFloat("") << endl; cout << ofToBool("") << endl; cout << ofToChar("") << endl; cout << endl; cout << "strings" << endl; cout << ofToString(123) << endl; cout << ofToString(123.4) << endl; cout << ofToString(123.4f) << endl; cout << ofToString(123, 5) << endl; cout << ofToString(123.4, 5) << endl; cout << ofToString(123.4f, 5) << endl; cout << endl; cout << "ints" << endl; cout << ofToInt("123.") << endl; cout << ofToInt("123.4") << endl; cout << ofToInt("123.4f") << endl; cout << ofToInt("+123.4") << endl; cout << endl; cout << "float" << endl; cout << ofToFloat("123.") << endl; cout << ofToFloat("123.4") << endl; cout << ofToFloat("123.4f") << endl; cout << ofToFloat("+123.4") << endl; cout << endl; cout << "bool" << endl; cout << ofToBool("1") << endl; cout << ofToBool("0") << endl; cout << ofToBool("true") << endl; cout << ofToBool("false") << endl; cout << ofToBool("True") << endl; cout << ofToBool("False") << endl; cout << endl; cout << "char" << endl; cout << ofToChar("a") << endl; cout << ofToChar("b") << endl; cout << ofToChar("1") << endl; cout << ofToChar("0") << endl; cout << endl; cout << "to binary" << endl; cout << ofToBinary(8) << endl; cout << ofToBinary(64) << endl; cout << ofToBinary(1024) << endl; cout << ofToBinary('a') << endl; cout << ofToBinary(8.5) << endl; cout << ofToBinary(8.f) << endl; cout << ofToBinary(8.5f) << endl; cout << ofToBinary(9.f) << endl; string strVal = "abc"; cout << ofToBinary(strVal) << endl; cout << ofToBinary("abc") << endl; cout << endl; cout << "to binary" << endl; cout << ofBinaryToInt(ofToBinary(8)) << endl; cout << ofBinaryToInt(ofToBinary(64)) << endl; cout << ofBinaryToInt(ofToBinary(1024)) << endl; cout << ofBinaryToChar(ofToBinary('a')) << endl; cout << ofBinaryToFloat(ofToBinary(8.5f)) << endl; cout << ofBinaryToFloat(ofToBinary(64.5f)) << endl; cout << ofBinaryToString(ofToBinary("abc")) << endl; cout << endl; cout << "to hex" << endl; cout << ofToHex('a') << endl; cout << ofToHex(128) << endl; cout << ofToHex(128.f) << endl; cout << ofToHex(128.) << endl; cout << ofToHex("abc") << endl; cout << ofToHex("abcd") << endl; string val = "abcdefg"; cout << ofToHex(val) << endl; cout << endl; cout << "hex to int" << endl; cout << ofHexToInt("0xff") << endl; cout << ofHexToInt("ff") << endl; cout << ofHexToInt(ofToHex(128)) << endl; cout << ofHexToFloat(ofToHex(128.5f)) << endl; cout << ofHexToChar(ofToHex('a')) << endl; cout << ofHexToString(ofToHex("abc")) << endl; cout << endl; }
Dashboard::Dashboard(){ this->isShow = ofToBool(ConfigLoader::singleton()->Value("System", "show_dashboard")); gui = new ofxUISuperCanvas("Control panel"); gui->setWidgetFontSize(OFX_UI_FONT_MEDIUM); speed = ofToInt(ConfigLoader::singleton()->Value("speed", "display_speed")); gui->addMinimalSlider("Display Speed", 0, 50, &this->speed); gui->addSpacer(); gui->addToggle( "Debug: Show all tracks", false); //gui->addToggle( "Show SST", false); this->showTimeline = ofToBool(ConfigLoader::singleton()->Value("System", "showTimeline")); this->timeline_toggle = gui->addToggle("Show Timeline", this->showTimeline); this->showSeasonclock = ofToBool(ConfigLoader::singleton()->Value("System", "showSeasonclock")); this->seasonclock_toggle = gui->addToggle("Show Season Clock", this->showSeasonclock); this->showLegends = ofToBool(ConfigLoader::singleton()->Value("System", "showSpeciesLegends")); this->legends_toggle = gui->addToggle("Show Species Legends", this->showLegends); this->showExtraDetect = ofToBool(ConfigLoader::singleton()->Value("System", "showExtraDetect")); this->extra_detect_toggle = gui->addToggle("Nearby animal hint", this->showExtraDetect); this->showWave = ofToBool(ConfigLoader::singleton()->Value("System", "showWave")); this->wave_toggle = gui->addToggle("Show Wave", this->showWave); //////////////////////////////////////////////////////////////////// gui->addSpacer(); gui->addLabel("Map legend layers: "); bool showContinentLabels; ofxUIToggle* continent_labels_toggle; bool showSiteLabels; ofxUIToggle* site_labels_toggle; bool showPinsLabels; ofxUIToggle* pins_labels_toggle; //"Continent Labels", "Tagging Site Labels", "Tagging Site Pins" this->showContinentLabels = ofToBool(ConfigLoader::singleton()->Value("System", "showContinentLabels")); this->continent_labels_toggle = gui->addToggle("Continent Labels", this->showContinentLabels); this->showSiteLabels = ofToBool(ConfigLoader::singleton()->Value("System", "showSiteLabels")); this->site_labels_toggle = gui->addToggle("Tagging Site Labels", this->showSiteLabels); this->showPinLabels = ofToBool(ConfigLoader::singleton()->Value("System", "showPinLabels")); this->pins_labels_toggle = gui->addToggle("Tagging Site Pins", this->showPinLabels); ///////////////////////////////////////////////////////////////////// gui->addSpacer(); gui->addLabel("Animal Icon: "); this->showTaggedDate = ofToBool(ConfigLoader::singleton()->Value("System", "showTaggedDate")); this->tagged_date_toggle = gui->addToggle("Show Tagged Date", this->showTaggedDate); this->is_buoyant_animation = ofToBool(ConfigLoader::singleton()->Value("System", "is_buoyant_animation")); this->icon_buoyant_animation = gui->addToggle( "Buoyant animation", this->is_buoyant_animation); this->fadeInTime = ofToInt(ConfigLoader::singleton()->Value("RenderTrackParameters", "fadeInTime")); // gui->addBiLabelSlider("Fade-In Time", "Slow", "Fast", 1000, 15000, &this->fadeInTime); gui->addMinimalSlider("Fade-In Time", 1000, 15000, &this->fadeInTime); this->fadeOutTime = ofToInt(ConfigLoader::singleton()->Value("RenderTrackParameters", "fadeOutTime")); //gui->addBiLabelSlider("Fade-Out Time", "Slow", "Fast", 1000, 30000, &this->fadeOutTime); gui->addMinimalSlider("Fade-Out Time", 1000, 30000, &this->fadeOutTime); // gui->addLabelToggle("LABEL TGL", false)->getLabelWidget()->setColorFill(ofColor(255, 0, 0)); gui->addLabel("Icon Orientation"); this->icon_orientation_none = gui->addToggle( "None", false); this->icon_orientation_rotate = gui->addToggle( "Rotate", false); this->icon_orientation_flip = gui->addToggle( "Flip", true); // display data setting gui->addSpacer(); gui->addLabel("Data Filtering"); std::vector<string> all_species = DataManager::singleton()->getAllSpecies(); std::vector<string> selected_species = DataManager::singleton()->getSelectedSpecies(); for(auto name = all_species.begin(); name != all_species.end(); name++){ if( std::find(selected_species.begin(), selected_species.end(), *name) != selected_species.end()) this->species_toggle_map[*name] = this->gui->addToggle( *name, true); else this->species_toggle_map[*name] = this->gui->addToggle( *name, false); } min_track_days = ofToInt(ConfigLoader::singleton()->Value("data", "min_track_day")); gui->addMinimalSlider("Min Total Track Days", 0, 600, &min_track_days)->getLabelWidget()->setColorFill(ofColor(255, 255, 255)); max_gap = ofToInt(ConfigLoader::singleton()->Value("data", "max_gap")); gui->addMinimalSlider("Max Gap", 0, 100, &max_gap)->getLabelWidget()->setColorFill(ofColor(255, 255, 255)); gui->setPosition(20, 400); gui->autoSizeToFitWidgets(); //ofxUILabelButton* btn = new ofxUILabelButton("Settings", true, 50, 30,500,1, OFX_UI_FONT_SMALL, true); this->gui->setVisible(this->isShow); }
bool ofXml::getBoolValue() const{ return ofToBool(getValue()); }
void testApp::urlResponse(ofHttpResponse &httpResponse){ stringstream ss ; ss << "urlResponse status code : " << httpResponse.status << endl ; if ( httpResponse.status == 200 ) { ss << "name : " << httpResponse.request.name << endl ; //ss << "url : " << httpResponse.request.url << endl ; if ( httpResponse.request.name == "LIGHTS_INFO" ) { bool bResult = json.parse( httpResponse.data.getText() ) ; if ( bResult == true ) { if ( lightbulbs.size() > 0 ) { lightbulbs.clear() ; } for ( int j = 0 ; j < json.size() ; j++ ) { //cout << "opening lightbulb data : " << j << endl ; stringstream parseInput ; parseInput << json[ofToString(j)]["name"] << endl ; string _name = parseInput.str() ; removeNewLine( &_name ) ; //cout << " name : '" << parseInput.str() << "'" << endl ; //The first value is NULL so we should check for that if ( parseInput.str().find( "null" ) == -1 ) { lightbulbs.push_back( ( ofPtr< ofxHueLightbulb > ) new ofxHueLightbulb() ) ; lightbulbs[ (lightbulbs.size() -1 ) ]->setup( parseInput.str() ) ; //cout << " index : " << j << endl ; string testUrl = ipAddress + "/api/" + username + "/lights/" + ofToString( j ) ; callHueApi( testUrl , "LIGHTBULB_" + ofToString( j ) ) ; } } } } int findIndex = httpResponse.request.name.find("LIGHTBULB_" ) ; ss << "FIND INDEX : " << findIndex << endl ; if ( findIndex > -1 ) { int index = ofToInt( ofToString( httpResponse.request.name[10] ) ) - 1 ; ss << "index : " << index << endl ; cout << "Lightbulb : " << index << " data has loaded ! " << endl ; ofxJSONElement lightData ; bool bResult = lightData.parse( httpResponse.data.getText() ) ; if ( bResult == true ) { //Hue stringstream hueSs ; hueSs << lightData["state"]["hue"] ; string _hue = hueSs.str() ; //hueSs.str().substr( 0 , (hueSs.str().size()-1)) ; removeNewLine( &_hue ) ; //Saturation stringstream saturationSs ; saturationSs << lightData["state"]["sat"] ; string _saturation = saturationSs.str() ; removeNewLine( &_saturation ) ; //Brightness stringstream brightnessSs ; brightnessSs << lightData["state"]["bri"] ; string _brightness = brightnessSs.str() ; removeNewLine( &_brightness ) ; //On / Off stringstream onSs ; onSs << lightData["state"]["on"] ; string _on = onSs.str().substr( 0 , (onSs.str().size()-1)) ; //cout << "_on" << "before remove line: " << _on << endl ; removeNewLine( &_on ) ; ss << " on : '" << _on << "'" << endl ; //cout << "_hue : '"<<_hue<<"'"<<endl ; if ( index < lightbulbs.size() ) { lightbulbs[ index ]->hue = ofToFloat( _hue) ; lightbulbs[ index ]->saturation = ofToFloat( _saturation ) ; lightbulbs[ index ]->brightness = ofToFloat( _brightness ) ; lightbulbs[ index ]->bOnState = ofToBool( _on ) ; /* if ( _on.compare( "true" ) == 0 ) { cout << " ON ! : " << endl ; lightbulbs[ index ]->bOnState = true ; } else if ( _on.compare( "false" ) == 0 ) lightbulbs[ index ]->bOnState = false ;*/ } } /* {"state": {"on":true,"bri":225,"hue":45489,"sat":253,"xy":[0.1859,0.0771],"ct":500,"alert":"none","effect":"none","colormode":"xy","reachable":true}, "type": "Extended color light", "name": "Hue Lamp 5", "modelid": "LCT001", "swversion": "65003148", "pointsymbol": { "1":"none", "2":"none", "3":"none", "4":"none", "5":"none", "6":"none", "7":"none", "8":"none" }} */ } } //ofLog( OF_LOG_WARNING , httpResponse.data.getText() ) ; lastHttpResponse = httpResponse ; ofLog( OF_LOG_WARNING , ss.str() ) ; }
//-------------------------------------------------- bool ofxCsvRow::getBool(int col) const { if(col >= data.size()) { return false; } return ofToBool(data[col]); }