void Team::serialize(In* in, Out* out) { STREAM_REGISTER_BEGIN STREAM(name); STREAM(number); STREAM(port); STREAM(color); STREAM(location); STREAM(buildConfig); STREAM(wlanConfig); STREAM(volume); STREAM(deployDevice); std::vector<std::string> players; if(out) { std::vector<Robot*> robots = getPlayersWrapped(); for(Robot* r : robots) players.push_back(r ? r->name : "_"); } STREAM(players); if(in) { std::map<std::string, Robot*> robots = Session::getInstance().robotsByName; for(size_t i = 0; i < players.size(); ++i) if(players[i] != "_") addPlayer(i % MAX_PLAYERS, i / MAX_PLAYERS, *robots[players[i]]); } STREAM_REGISTER_FINISH }
void CameraResolution::serialize(In* in, Out* out) { STREAM_REGISTER_BEGIN; STREAM(resolution); STREAM(timestamp); STREAM_REGISTER_FINISH; }
void Image::serialize(In* in, Out* out) { STREAM_REGISTER_BEGIN; STREAM(width); STREAM(height); if(isFullSize) timeStamp |= 1 << 31; STREAM(timeStamp); isFullSize = (timeStamp & 1 << 31) != 0; timeStamp &= ~(1 << 31); const int size = width * sizeof(Pixel) * (isFullSize ? 2 : 1); if(out) for(int y = 0; y < height; ++y) out->write((*this)[y], size); else { widthStep = width * 2; for(int y = 0; y < height; ++y) in->read((*this)[y], size); } STREAM_REGISTER_FINISH; }
static HRESULT WINAPI ProtocolStream_QueryInterface(IStream *iface, REFIID riid, void **ppv) { ProtocolStream *This = STREAM_THIS(iface); *ppv = NULL; if(IsEqualGUID(&IID_IUnknown, riid)) { TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv); *ppv = STREAM(This); } else if(IsEqualGUID(&IID_ISequentialStream, riid)) { TRACE("(%p)->(IID_ISequentialStream %p)\n", This, ppv); *ppv = STREAM(This); } else if(IsEqualGUID(&IID_IStream, riid)) { TRACE("(%p)->(IID_IStream %p)\n", This, ppv); *ppv = STREAM(This); } if(*ppv) { IStream_AddRef(STREAM(This)); return S_OK; } WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv); return E_NOINTERFACE; }
static HRESULT stgmed_stream_get_result(stgmed_obj_t *obj, DWORD bindf, void **result) { ProtocolStream *stream = (ProtocolStream*)obj; IStream_AddRef(STREAM(stream)); *result = STREAM(stream); return S_OK; }
void NaturalLandmarkPercept::serialize(In *in, Out *out) { //Sending a vector of matchedkeypoints STREAM_REGISTER_BEGIN(); STREAM(matchedPoints); STREAM(matchingScore); STREAM(matchFound); STREAM_REGISTER_FINISH(); }
static HRESULT stgmed_stream_get_result(stgmed_obj_t *obj, DWORD bindf, void **result) { ProtocolStream *stream = (ProtocolStream*)obj; if(!(bindf & BINDF_ASYNCHRONOUS) && stream->buf->file == INVALID_HANDLE_VALUE && (stream->buf->hres != S_FALSE || stream->buf->size)) return INET_E_DATA_NOT_AVAILABLE; IStream_AddRef(STREAM(stream)); *result = STREAM(stream); return S_OK; }
UINT ShaderGL::CreateFromFile(std::string filename) { if (Archive::ToBuffer(filename.c_str(), mSource) == 0) { Debug::ShowError( STREAM("Could not open '" << filename << "'"), STREAM("Shader Loader Error")); return S_FALSE; } Debug::Log(STREAM("Compiling '" << filename << "'...")); return CreateFromMemory(mSource); }
void EventWatcher::ReadLPRepFile(){ static QString stat = ""; static QString repTotK = ""; static QString lastSize = ""; //Open/Read any new info in the file QFile LPlogfile(LPLOG); if( !LPlogfile.open(QIODevice::ReadOnly) ){ return; } //could not open file QTextStream STREAM(&LPlogfile); if(LPrep_pos<=0 || !STREAM.seek(LPrep_pos) ){ //New file location stat.clear(); repTotK.clear(); lastSize.clear(); } QStringList info = STREAM.readAll().split("\n"); LPrep_pos = STREAM.pos(); LPlogfile.close(); //Now parse the new info line-by-line for(int i=0; i<info.length(); i++){ QString line = info[i]; if(line.contains("estimated size is")){ repTotK = line.section("size is ",1,1,QString::SectionSkipEmpty).simplified(); } //save the total size to replicate else if(line.startsWith("send from ")){} else if(line.startsWith("TIME ")){} else if(line.startsWith("warning: ")){} //start of an error else{ stat = line; } //only save the relevant/latest status line } if(!stat.isEmpty()){ //qDebug() << "New Status Message:" << stat; //Divide up the status message into sections stat.replace("\t"," "); QString dataset = stat.section(" ",2,2,QString::SectionSkipEmpty).section("/",0,0).simplified(); QString cSize = stat.section(" ",1,1,QString::SectionSkipEmpty); //Now Setup the tooltip if(cSize != lastSize){ //don't update the info if the same size info QString percent; if(!repTotK.isEmpty() && repTotK!="??"){ //calculate the percentage double tot = displayToDoubleK(repTotK); double c = displayToDoubleK(cSize); if( tot!=-1 & c!=-1){ double p = (c*100)/tot; p = int(p*10)/10.0; //round to 1 decimel places percent = QString::number(p) + "%"; } } if(repTotK.isEmpty()){ repTotK = "??"; } //Format the info string QString status = cSize+"/"+repTotK; if(!percent.isEmpty()){ status.append(" ("+percent+")"); } QString txt = QString(tr("Replicating %1: %2")).arg(dataset, status); lastSize = cSize; //save the current size for later //Now set the current process status HASH.insert(120,"RUNNING"); HASH.insert(121,dataset); HASH.insert(122,txt); HASH.insert(123,txt); emit sendLPEvent("replication", 0, txt); } } }
void ShaderManager::Load(Archive& archive, Renderer* renderer) { RemoveAll(); UINT count; archive.Read(&count); for (UINT x = 0; x < count; ++x) { std::string name; archive.Read(&name); ULONG size; archive.Read(&size); ULONG bound; archive.Read(&bound); char* comp_source = (char*)malloc(bound); archive.Read(comp_source, bound); char* source = (char*)malloc(size + 1); source[size] = 0; uncompress(reinterpret_cast<Bytef*>(source), &size, reinterpret_cast<Bytef*>(comp_source), bound); Debug::Log(STREAM("Compiling '" << name << "'...")); Add(name, std::shared_ptr<Shader>(renderer->CreateShaderFromMemory(source))); free(comp_source); } }
static HRESULT stgmed_stream_fill_stgmed(stgmed_obj_t *obj, STGMEDIUM *stgmed) { ProtocolStream *stream = (ProtocolStream*)obj; stgmed->tymed = TYMED_ISTREAM; stgmed->u.pstm = STREAM(stream); stgmed->pUnkForRelease = STGMEDUNK(stream->buf); return S_OK; }
void ImageBH::serialize(In* in, Out* out) { STREAM_REGISTER_BEGIN; STREAM(width); STREAM(height); STREAM(timeStamp); if(out) for(int y = 0; y < height; ++y) out->write((*this)[y], width * sizeof(Pixel)); else { widthStep = width * 2; for(int y = 0; y < height; ++y) in->read((*this)[y], width * sizeof(Pixel)); } STREAM_REGISTER_FINISH; }
void GameInfo::serialize(In* in, Out* out) { STREAM_REGISTER_BEGIN; STREAM(state); // STATE_READY, STATE_PLAYING, ... STREAM(firstHalf); // 1 = game in first half, 0 otherwise STREAM(kickOffTeam); // TEAM_BLUE, TEAM_RED STREAM(secsRemaining); // estimate of number of seconds remaining in the half. STREAM(dropInTeam); // TEAM_BLUE, TEAM_RED STREAM(dropInTime); // number of seconds passed since the last drop in. -1 before first dropin. STREAM(secondaryState); // Extra state information - (STATE2_NORMAL, STATE2_PENALTYSHOOT, etc) STREAM(timeLastPackageReceived) // used to decide wether a gameController is running STREAM_REGISTER_FINISH; }
void RobotInfo::serialize(In* in, Out* out) { STREAM_REGISTER_BEGIN; STREAM(number); // robot number: 1..11 STREAM(headVersion); STREAM(headType); STREAM(bodyVersion); STREAM(bodyType); STREAM(penalty); // PENALTY_NONE, PENALTY_BALL_HOLDING, ... STREAM(secsTillUnpenalised); // estimate of time till unpenalised. STREAM_REGISTER_FINISH; }
double density(Domain value) const { LOG_S(density); if (data_.empty()) return 0.0; double sum = 0.0; typename Weights::const_iterator weight = weights_.begin(); for (auto data: data_) { LOG_M(STREAM(data, *weight)); sum += *(weight++)*scaledKernel_(value-data); } LOG_M(sum); return sum/weightDistribution_.sum(); }
void Demo_2::loadFile(int n) { file.open(file_rel(STREAM("data" << n)), std::ios::binary); std::streampos filesize; file.seekg(0, std::ios::end); filesize = file.tellg(); file.seekg(0, std::ios::beg); data.clear(); data.resize(filesize); file.read((char*)&data[0], filesize); file.close(); }
void CameraIntrinsics::serialize(In* in, Out* out) { float upperOpeningAngleWidth = toDegrees(this->upperOpeningAngleWidth); float upperOpeningAngleHeight = toDegrees(this->upperOpeningAngleHeight); float lowerOpeningAngleWidth = toDegrees(this->lowerOpeningAngleWidth); float lowerOpeningAngleHeight = toDegrees(this->lowerOpeningAngleHeight); STREAM_REGISTER_BEGIN; STREAM(upperOpeningAngleWidth); STREAM(upperOpeningAngleHeight); STREAM(upperOpticalCenter); STREAM(lowerOpeningAngleWidth); STREAM(lowerOpeningAngleHeight); STREAM(lowerOpticalCenter); STREAM_REGISTER_FINISH; if(in) { this->upperOpeningAngleWidth = fromDegrees(upperOpeningAngleWidth); this->upperOpeningAngleHeight = fromDegrees(upperOpeningAngleHeight); this->lowerOpeningAngleWidth = fromDegrees(lowerOpeningAngleWidth); this->lowerOpeningAngleHeight = fromDegrees(lowerOpeningAngleHeight); } }
/** * Streaming callback to format our output */ static int stream_formatter(FILE *pipe, void *data, metric_type type, char *name, void *value) { #define STREAM(...) if (fprintf(pipe, __VA_ARGS__, (long long)tv->tv_sec) < 0) return 1; struct timeval *tv = data; timer_hist *t; int i; switch (type) { case KEY_VAL: STREAM("kv.%s|%f|%lld\n", name, *(double*)value); break; case GAUGE: STREAM("gauges.%s|%f|%lld\n", name, ((gauge_t*)value)->value); break; case COUNTER: STREAM("counts.%s|%f|%lld\n", name, counter_sum(value)); break; case SET: STREAM("sets.%s|%lld|%lld\n", name, set_size(value)); break; case TIMER: t = (timer_hist*)value; STREAM("timers.%s.sum|%f|%lld\n", name, timer_sum(&t->tm)); STREAM("timers.%s.sum_sq|%f|%lld\n", name, timer_squared_sum(&t->tm)); STREAM("timers.%s.mean|%f|%lld\n", name, timer_mean(&t->tm)); STREAM("timers.%s.lower|%f|%lld\n", name, timer_min(&t->tm)); STREAM("timers.%s.upper|%f|%lld\n", name, timer_max(&t->tm)); STREAM("timers.%s.count|%lld|%lld\n", name, timer_count(&t->tm)); STREAM("timers.%s.stdev|%f|%lld\n", name, timer_stddev(&t->tm)); STREAM("timers.%s.median|%f|%lld\n", name, timer_query(&t->tm, 0.5)); STREAM("timers.%s.p95|%f|%lld\n", name, timer_query(&t->tm, 0.95)); STREAM("timers.%s.p99|%f|%lld\n", name, timer_query(&t->tm, 0.99)); // Stream the histogram values if (t->conf) { STREAM("timers.%s.histogram.bin_<%0.2f|%u|%lld\n", name, t->conf->min_val, t->counts[0]); for (i=0; i < t->conf->num_bins-2; i++) { STREAM("timers.%s.histogram.bin_%0.2f|%u|%lld\n", name, t->conf->min_val+(t->conf->bin_width*i), t->counts[i+1]); } STREAM("timers.%s.histogram.bin_>%0.2f|%u|%lld\n", name, t->conf->max_val, t->counts[i+1]); } break; default: syslog(LOG_ERR, "Unknown metric type: %d", type); break; } return 0; }
/** * Streaming callback to format our output */ static int stream_formatter(FILE *pipe, void *data, metric_type type, char *name, void *value) { #define STREAM(...) if (fprintf(pipe, __VA_ARGS__, (long long)tv->tv_sec) < 0) return 1; struct timeval *tv = data; switch (type) { case KEY_VAL: STREAM("kv.%s|%f|%lld\n", name, *(double*)value); break; case COUNTER: STREAM("counts.%s|%f|%lld\n", name, counter_sum(value)); break; case TIMER: STREAM("timers.%s.sum|%f|%lld\n", name, timer_sum(value)); STREAM("timers.%s.mean|%f|%lld\n", name, timer_mean(value)); STREAM("timers.%s.lower|%f|%lld\n", name, timer_min(value)); STREAM("timers.%s.upper|%f|%lld\n", name, timer_max(value)); STREAM("timers.%s.count|%lld|%lld\n", name, timer_count(value)); STREAM("timers.%s.stdev|%f|%lld\n", name, timer_stddev(value)); STREAM("timers.%s.median|%f|%lld\n", name, timer_query(value, 0.5)); STREAM("timers.%s.p95|%f|%lld\n", name, timer_query(value, 0.95)); STREAM("timers.%s.p99|%f|%lld\n", name, timer_query(value, 0.99)); break; default: syslog(LOG_ERR, "Unknown metric type: %d", type); break; } return 0; }
static void stgmed_stream_release(stgmed_obj_t *obj) { ProtocolStream *stream = (ProtocolStream*)obj; IStream_Release(STREAM(stream)); }
void Demo_2::updateInfoText() { imageinfo.setString(STREAM("Image: " << imageindex << " | File: " << fileindex)); }
} return -ENOIOCTLCMD; } #define STATE(v) [SNDRV_PCM_STATE_##v] = #v #define STREAM(v) [SNDRV_PCM_STREAM_##v] = #v #define READY(v) [SNDRV_PCM_READY_##v] = #v #define XRUN(v) [SNDRV_PCM_XRUN_##v] = #v #define SILENCE(v) [SNDRV_PCM_SILENCE_##v] = #v #define TSTAMP(v) [SNDRV_PCM_TSTAMP_##v] = #v #define ACCESS(v) [SNDRV_PCM_ACCESS_##v] = #v #define START(v) [SNDRV_PCM_START_##v] = #v #define FORMAT(v) [SNDRV_PCM_FORMAT_##v] = #v #define SUBFORMAT(v) [SNDRV_PCM_SUBFORMAT_##v] = #v char *snd_pcm_stream_names[] = { STREAM(PLAYBACK), STREAM(CAPTURE), }; char *snd_pcm_state_names[] = { STATE(OPEN), STATE(SETUP), STATE(PREPARED), STATE(RUNNING), STATE(XRUN), STATE(DRAINING), STATE(PAUSED), STATE(SUSPENDED), }; char *snd_pcm_access_names[] = {
void ExtendedBallPercept::serialize(In* in, Out* out) { STREAM_REGISTER_BEGIN(); STREAM(positionInImage); STREAM(radiusInImage); STREAM(relativePositionOnField); STREAM(projectedBallRadius); STREAM(levenbergMarquardtResult); STREAM(couldBeBallPart); STREAM(couldBeRobotPart); STREAM(isValidBallPercept); STREAM(centerTopLeft); STREAM(centerDownRight); STREAM(middleTopLeft); STREAM(middleDownRight); STREAM(outerTopLeft); STREAM(outerDownRight); STREAM_ARRAY(centerArea); STREAM_ARRAY(middleArea); STREAM_ARRAY(outerArea); STREAM(centerResult); STREAM(middleResult); STREAM(outerResult); STREAM(outerResult); STREAM(distanceCheckResult); STREAM(validity); STREAM(deviationOfBallPoints); STREAM(durabilityOfBallPoints); STREAM(eccentricity); STREAM_REGISTER_FINISH(); }
/** * Streaming callback to format our output */ static int stream_formatter(FILE *pipe, void *data, metric_type type, char *name, void *value) { #define STREAM(...) if (fprintf(pipe, __VA_ARGS__, (long long)tv->tv_sec) < 0) return 1; struct timeval *tv = data; timer_hist *t; int i; char *prefix = GLOBAL_CONFIG->prefixes_final[type]; included_metrics_config* counters_config = &(GLOBAL_CONFIG->ext_counters_config); included_metrics_config* timers_config = &(GLOBAL_CONFIG->timers_config); switch (type) { case KEY_VAL: STREAM("%s%s|%f|%lld\n", prefix, name, *(double*)value); break; case GAUGE: STREAM("%s%s|%f|%lld\n", prefix, name, ((gauge_t*)value)->value); break; case COUNTER: if (GLOBAL_CONFIG->extended_counters) { if (counters_config->count) { STREAM("%s.count|%"PRIu64"|%lld\n", name, counter_count(value)); //STREAM("%s%s.count|%"PRIu64"|%lld\n", prefix, name, counter_count(value)); } if (counters_config->mean) { STREAM("%s.mean|%f|%lld\n", name, counter_mean(value)); //STREAM("%s%s.mean|%f|%lld\n", prefix, name, counter_mean(value)); } if (counters_config->stdev) { STREAM("%s.stdev|%f|%lld\n", name, counter_stddev(value)); //STREAM("%s%s.stdev|%f|%lld\n", prefix, name, counter_stddev(value)); } if (counters_config->sum) { STREAM("%s.sum|%f|%lld\n", name, counter_sum(value)); //STREAM("%s%s.sum|%f|%lld\n", prefix, name, counter_sum(value)); } if (counters_config->sum_sq) { STREAM("%s.sum_sq|%f|%lld\n", name, counter_squared_sum(value)); //STREAM("%s%s.sum_sq|%f|%lld\n", prefix, name, counter_squared_sum(value)); } if (counters_config->lower) { STREAM("%s.lower|%f|%lld\n", name, counter_min(value)); //STREAM("%s%s.lower|%f|%lld\n", prefix, name, counter_min(value)); } if (counters_config->upper) { STREAM("%s.upper|%f|%lld\n", name, counter_max(value)); //STREAM("%s%s.upper|%f|%lld\n", prefix, name, counter_max(value)); } if (counters_config->rate) { STREAM("%s.rate|%f|%lld\n", name, counter_sum(value) / GLOBAL_CONFIG->flush_interval); //STREAM("%s%s.rate|%f|%lld\n", prefix, name, counter_sum(value) / GLOBAL_CONFIG->flush_interval); } } else { //update by liujun 2016/10/18 use rate replace sum() STREAM("%s|%f|%lld\n", name, counter_sum(value) / GLOBAL_CONFIG->flush_interval); //STREAM("%s%s|%f|%lld\n", prefix, name, counter_sum(value)); } break; case SET: STREAM("%s%s|%"PRIu64"|%lld\n", prefix, name, set_size(value)); break; case TIMER: t = (timer_hist*)value; // if (timers_config->sum) { // STREAM("%s%s.sum|%f|%lld\n", prefix, name, timer_sum(&t->tm)); // } // if (timers_config->sum_sq) { // STREAM("%s%s.sum_sq|%f|%lld\n", prefix, name, timer_squared_sum(&t->tm)); // } if (timers_config->mean) { STREAM("%s%s.mean|%f|%lld\n", prefix, name, timer_mean(&t->tm)); } //if (timers_config->lower) { // STREAM("%s%s.lower|%f|%lld\n", prefix, name, timer_min(&t->tm)); // } // if (timers_config->upper) { // STREAM("%s%s.upper|%f|%lld\n", prefix, name, timer_max(&t->tm)); // } // if (timers_config->count) { // STREAM("%s%s.count|%"PRIu64"|%lld\n", prefix, name, timer_count(&t->tm)); // } if (timers_config->stdev) { STREAM("%s%s.stdev|%f|%lld\n", prefix, name, timer_stddev(&t->tm)); } // for (i=0; i < GLOBAL_CONFIG->num_quantiles; i++) { // if (timers_config->median && GLOBAL_CONFIG->quantiles[i] == 0.5) { // STREAM("%s%s.median|%f|%lld\n", prefix, name, timer_query(&t->tm, 0.5)); // } // STREAM("%s%s.p%0.0f|%f|%lld\n", prefix, name, // GLOBAL_CONFIG->quantiles[i] * 100, // timer_query(&t->tm, GLOBAL_CONFIG->quantiles[i])); // } // if (timers_config->rate) { // STREAM("%s%s.rate|%f|%lld\n", prefix, name, timer_sum(&t->tm) / GLOBAL_CONFIG->flush_interval); // } // if (timers_config->sample_rate) { // STREAM("%s%s.sample_rate|%f|%lld\n", prefix, name, (double)timer_count(&t->tm) / GLOBAL_CONFIG->flush_interval); // } // Stream the histogram values // if (t->conf) { // STREAM("%s%s.histogram.bin_<%0.2f|%u|%lld\n", prefix, name, t->conf->min_val, t->counts[0]); // for (i=0; i < t->conf->num_bins-2; i++) { // STREAM("%s%s.histogram.bin_%0.2f|%u|%lld\n", prefix, name, t->conf->min_val+(t->conf->bin_width*i), t->counts[i+1]); // } // STREAM("%s%s.histogram.bin_>%0.2f|%u|%lld\n", prefix, name, t->conf->max_val, t->counts[i+1]); // } break; default: syslog(LOG_ERR, "Unknown metric type: %d", type); break; } return 0; }
// == Life Preserver Event Functions void EventWatcher::ReadLPLogFile(){ //Open/Read any new info in the file QFile LPlogfile(LPLOG); if( !LPlogfile.open(QIODevice::ReadOnly) ){ return; } //could not open file QTextStream STREAM(&LPlogfile); if(LPlog_pos>0){ STREAM.seek(LPlog_pos); } QStringList info = STREAM.readAll().split("\n"); LPlog_pos = STREAM.pos(); LPlogfile.close(); //Now parse the new info line-by-line for(int i=0; i<info.length(); i++){ if(info[i].isEmpty()){ continue; } QString log = info[i]; if(!starting){ qDebug() << "Read LP Log File Line:" << log; } //Divide up the log into it's sections QString timestamp = log.section(":",0,2).simplified(); QString time = timestamp.section(" ",3,3).simplified(); QString message = log.section(":",3,3).toLower().simplified(); QString dev = log.section(":",4,4).simplified(); //dataset/snapshot/nothing //Now decide what to do/show because of the log message if(message.contains("creating snapshot", Qt::CaseInsensitive)){ dev = message.section(" ",-1).simplified(); QString msg = QString(tr("New snapshot of %1")).arg(dev); //Setup the status of the message HASH.insert(110,"SNAPCREATED"); HASH.insert(111,dev); //dataset HASH.insert(112, msg ); //summary HASH.insert(113, QString(tr("Creating snapshot for %1")).arg(dev) ); HASH.insert(114, timestamp); //full timestamp HASH.insert(115, time); // time only sendLPEvent("snapshot", 1, timestamp+": "+msg); }else if(message.contains("Starting replication", Qt::CaseInsensitive)){ //Setup the file watcher for this new log file //qDebug() << " - Found Rep Start:" << dev << message; tmpLPRepFile = dev; LPrep_pos = 0; //reset file position dev = message.section(" on ",1,1,QString::SectionSkipEmpty); //qDebug() << " - New Dev:" << dev << "Valid Pools:" << reppools; //Make sure the device is currently setup for replication //if( !reppools.contains(dev) ){ FILE_REPLICATION.clear(); continue; } QString msg = QString(tr("Starting replication for %1")).arg(dev); //Set the appropriate status variables HASH.insert(120,"STARTED"); HASH.insert(121, dev); //zpool HASH.insert(122, tr("Replication Starting") ); //summary HASH.insert(123, msg ); //Full message HASH.insert(124, timestamp); //full timestamp HASH.insert(125, time); // time only HASH.insert(126,tr("Replication Log")+" <"+tmpLPRepFile+">"); //log file sendLPEvent("replication", 1, timestamp+": "+msg); }else if(message.contains("finished replication task", Qt::CaseInsensitive)){ //Done with this replication - close down the rep file watcher tmpLPRepFile.clear(); LPrep_pos = 0; //reset file position dev = message.section(" -> ",0,0).section(" ",-1).simplified(); //Make sure the device is currently setup for replication //if( reppools.contains(dev) ){ QString msg = QString(tr("Finished replication for %1")).arg(dev); //Now set the status of the process HASH.insert(120,"FINISHED"); HASH.insert(121,dev); //dataset HASH.insert(122, tr("Finished Replication") ); //summary HASH.insert(123, msg ); HASH.insert(124, timestamp); //full timestamp HASH.insert(125, time); // time only HASH.insert(126, ""); //clear the log file entry sendLPEvent("replication", 1, timestamp+": "+msg); }else if( message.contains("FAILED replication", Qt::CaseInsensitive) ){ tmpLPRepFile.clear(); LPrep_pos = 0; //reset file position //Now set the status of the process dev = message.section(" -> ",0,0).section(" ",-1).simplified(); //Make sure the device is currently setup for replication //Update the HASH QString file = log.section("LOGFILE:",1,1).simplified(); QString tt = QString(tr("Replication Failed for %1")).arg(dev) +"\n"+ QString(tr("Logfile available at: %1")).arg(file); HASH.insert(120,"ERROR"); HASH.insert(121,dev); //dataset HASH.insert(122, tr("Replication Failed") ); //summary HASH.insert(123, tt ); HASH.insert(124, timestamp); //full timestamp HASH.insert(125, time); // time only HASH.insert(126, tr("Replication Error Log")+" <"+file+">" ); sendLPEvent("replication", 7, timestamp+": "+tt); } } }
/** * Streaming callback to format our output */ static int stream_formatter(FILE *pipe, void *data, metric_type type, char *name, void *value) { #define STREAM(...) if (fprintf(pipe, __VA_ARGS__, (long long)tv->tv_sec) < 0) return 1; struct config_time* ct = data; struct timeval *tv = ct->tv; timer_hist *t; int i; char *prefix = ct->global_config->prefixes_final[type]; switch (type) { case KEY_VAL: STREAM("%s%s|%f|%lld\n", prefix, name, *(double*)value); break; case GAUGE: STREAM("%s%s|%f|%lld\n", prefix, name, ((gauge_t*)value)->value); break; case COUNTER: if (ct->global_config->extended_counters) { STREAM("%s%s.count|%" PRIu64 "|%lld\n", prefix, name, counter_count(value)); STREAM("%s%s.mean|%f|%lld\n", prefix, name, counter_mean(value)); STREAM("%s%s.stdev|%f|%lld\n", prefix, name, counter_stddev(value)); STREAM("%s%s.sum|%f|%lld\n", prefix, name, counter_sum(value)); STREAM("%s%s.sum_sq|%f|%lld\n", prefix, name, counter_squared_sum(value)); STREAM("%s%s.lower|%f|%lld\n", prefix, name, counter_min(value)); STREAM("%s%s.upper|%f|%lld\n", prefix, name, counter_max(value)); STREAM("%s%s.rate|%f|%lld\n", prefix, name, counter_sum(value) / ct->global_config->flush_interval); } else { STREAM("%s%s|%f|%lld\n", prefix, name, counter_sum(value)); } break; case SET: STREAM("%s%s|%" PRIu64 "|%lld\n", prefix, name, set_size(value)); break; case TIMER: t = (timer_hist*)value; STREAM("%s%s.sum|%f|%lld\n", prefix, name, timer_sum(&t->tm)); STREAM("%s%s.sum_sq|%f|%lld\n", prefix, name, timer_squared_sum(&t->tm)); STREAM("%s%s.mean|%f|%lld\n", prefix, name, timer_mean(&t->tm)); STREAM("%s%s.lower|%f|%lld\n", prefix, name, timer_min(&t->tm)); STREAM("%s%s.upper|%f|%lld\n", prefix, name, timer_max(&t->tm)); STREAM("%s%s.count|%" PRIu64 "|%lld\n", prefix, name, timer_count(&t->tm)); STREAM("%s%s.stdev|%f|%lld\n", prefix, name, timer_stddev(&t->tm)); for (i=0; i < ct->global_config->num_quantiles; i++) { int percentile; double quantile = ct->global_config->quantiles[i]; if (quantile == 0.5) { STREAM("%s%s.median|%f|%lld\n", prefix, name, timer_query(&t->tm, 0.5)); } if (to_percentile(quantile, &percentile)) { syslog(LOG_ERR, "Invalid quantile: %lf", quantile); break; } STREAM("%s%s.p%d|%f|%lld\n", prefix, name, percentile, timer_query(&t->tm, quantile)); } STREAM("%s%s.rate|%f|%lld\n", prefix, name, timer_sum(&t->tm) / ct->global_config->flush_interval); STREAM("%s%s.sample_rate|%f|%lld\n", prefix, name, (double)timer_count(&t->tm) / ct->global_config->flush_interval); // Stream the histogram values if (t->conf) { STREAM("%s%s.histogram.bin_<%0.2f|%u|%lld\n", prefix, name, t->conf->min_val, t->counts[0]); for (i=0; i < t->conf->num_bins-2; i++) { STREAM("%s%s.histogram.bin_%0.2f|%u|%lld\n", prefix, name, t->conf->min_val+(t->conf->bin_width*i), t->counts[i+1]); } STREAM("%s%s.histogram.bin_>%0.2f|%u|%lld\n", prefix, name, t->conf->max_val, t->counts[i+1]); } break; default: syslog(LOG_ERR, "Unknown metric type: %d", type); break; } return 0; }
void BHULKsStandardMessage::serialize(In* in, Out* out) { static_assert(BHULKS_STANDARD_MESSAGE_STRUCT_VERSION == 8, "This method is not adjusted for the current message version"); STREAM_REGISTER_BEGIN; std::string headerRef(header, 4); STREAM(headerRef);// does not allow to change the header in any case, but makes it visble in a great way STREAM(version); STREAM(member); STREAM(timestamp); STREAM(isUpright); STREAM(hasGroundContact); STREAM(timeOfLastGroundContact); STREAM(isPenalized); STREAM(gameControlData) STREAM(headYawAngle); STREAM(currentlyPerfomingRole, B_HULKs); STREAM(roleAssignments, B_HULKs); STREAM(kingIsPlayingBall); STREAM(passTarget); STREAM(timeWhenReachBall); STREAM(timeWhenReachBallQueen); STREAM(ballTimeWhenLastSeen); STREAM(timestampLastJumped); STREAM(confidenceOfLastWhistleDetection, B_HULKs); STREAM(lastTimeWhistleDetected); STREAM(obstacles); STREAM(requestsNTPMessage); STREAM(ntpMessages); STREAM_REGISTER_FINISH; }
/* * function: putnext() * purpose: call the put routine of the queue linked to qp * * Note: this function is written to perform well on modern computer * architectures by e.g. preloading values into registers and "smearing" out * code. * * A note on the fastput mechanism. The most significant bit of a * putcount is considered the "FASTPUT" bit. If set, then there is * nothing stoping a concurrent put from occuring (note that putcounts * are only allowed on CIPUT perimiters). If, however, it is cleared, * then we need to take the normal lock path by aquiring the SQLOCK. * This is a slowlock. When a thread starts exclusiveness, e.g. wants * writer access, it will clear the FASTPUT bit, causing new threads * to take the slowlock path. This assures that putcounts will not * increase in value, so the want-writer does not need to constantly * aquire the putlocks to sum the putcounts. This does have the * possibility of having the count drop right after reading, but that * is no different than aquiring, reading and then releasing. However, * in this mode, it cannot go up, so eventually they will drop to zero * and the want-writer can proceed. * * If the FASTPUT bit is set, or in the slowlock path we see that there * are no writers or want-writers, we make the choice of calling the * putproc, or a "fast-fill_syncq". The fast-fill is a fill with * immediate intention to drain. This is done because there are * messages already at the queue waiting to drain. To preserve message * ordering, we need to put this message at the end, and pickup the * messages at the beginning. We call the macro that actually * enqueues the message on the queue, and then call qdrain_syncq. If * there is already a drainer, we just return. We could make that * check before calling qdrain_syncq, but it is a little more clear * to have qdrain_syncq do this (we might try the above optimization * as this behavior evolves). qdrain_syncq assumes that SQ_EXCL is set * already if this is a non-CIPUT perimiter, and that an appropriate * claim has been made. So we do all that work before dropping the * SQLOCK with our claim. * * If we cannot proceed with the putproc/fast-fill, we just fall * through to the qfill_syncq, and then tail processing. If state * has changed in that cycle, or wakeups are needed, it will occur * there. */ void putnext(queue_t *qp, mblk_t *mp) { queue_t *fqp = qp; /* For strft tracing */ syncq_t *sq; uint16_t flags; uint16_t drain_mask; struct qinit *qi; int (*putproc)(); struct stdata *stp; int ix; boolean_t queued = B_FALSE; kmutex_t *sdlock = NULL; kmutex_t *sqciplock = NULL; ushort_t *sqcipcount = NULL; TRACE_2(TR_FAC_STREAMS_FR, TR_PUTNEXT_START, "putnext_start:(%p, %p)", qp, mp); ASSERT(mp->b_datap->db_ref != 0); ASSERT(mp->b_next == NULL && mp->b_prev == NULL); stp = STREAM(qp); ASSERT(stp != NULL); if (stp->sd_ciputctrl != NULL) { ix = CPU->cpu_seqid & stp->sd_nciputctrl; sdlock = &stp->sd_ciputctrl[ix].ciputctrl_lock; mutex_enter(sdlock); } else { mutex_enter(sdlock = &stp->sd_lock); } qp = qp->q_next; sq = qp->q_syncq; ASSERT(sq != NULL); ASSERT(MUTEX_NOT_HELD(SQLOCK(sq))); qi = qp->q_qinfo; if (sq->sq_ciputctrl != NULL) { /* fastlock: */ ASSERT(sq->sq_flags & SQ_CIPUT); ix = CPU->cpu_seqid & sq->sq_nciputctrl; sqciplock = &sq->sq_ciputctrl[ix].ciputctrl_lock; sqcipcount = &sq->sq_ciputctrl[ix].ciputctrl_count; mutex_enter(sqciplock); if (!((*sqcipcount) & SQ_FASTPUT) || (sq->sq_flags & (SQ_STAYAWAY|SQ_EXCL|SQ_EVENTS))) { mutex_exit(sqciplock); sqciplock = NULL; goto slowlock; } mutex_exit(sdlock); (*sqcipcount)++; ASSERT(*sqcipcount != 0); queued = qp->q_sqflags & Q_SQQUEUED; mutex_exit(sqciplock); } else { slowlock: ASSERT(sqciplock == NULL); mutex_enter(SQLOCK(sq)); mutex_exit(sdlock); flags = sq->sq_flags; /* * We are going to drop SQLOCK, so make a claim to prevent syncq * from closing. */ sq->sq_count++; ASSERT(sq->sq_count != 0); /* Wraparound */ /* * If there are writers or exclusive waiters, there is not much * we can do. Place the message on the syncq and schedule a * background thread to drain it. * * Also if we are approaching end of stack, fill the syncq and * switch processing to a background thread - see comments on * top. */ if ((flags & (SQ_STAYAWAY|SQ_EXCL|SQ_EVENTS)) || (sq->sq_needexcl != 0) || PUT_STACK_NOTENOUGH()) { TRACE_3(TR_FAC_STREAMS_FR, TR_PUTNEXT_END, "putnext_end:(%p, %p, %p) SQ_EXCL fill", qp, mp, sq); /* * NOTE: qfill_syncq will need QLOCK. It is safe to drop * SQLOCK because positive sq_count keeps the syncq from * closing. */ mutex_exit(SQLOCK(sq)); qfill_syncq(sq, qp, mp); /* * NOTE: after the call to qfill_syncq() qp may be * closed, both qp and sq should not be referenced at * this point. * * This ASSERT is located here to prevent stack frame * consumption in the DEBUG code. */ ASSERT(sqciplock == NULL); return; } queued = qp->q_sqflags & Q_SQQUEUED; /* * If not a concurrent perimiter, we need to acquire * it exclusively. It could not have been previously * set since we held the SQLOCK before testing * SQ_GOAWAY above (which includes SQ_EXCL). * We do this here because we hold the SQLOCK, and need * to make this state change BEFORE dropping it. */ if (!(flags & SQ_CIPUT)) { ASSERT((sq->sq_flags & SQ_EXCL) == 0); ASSERT(!(sq->sq_type & SQ_CIPUT)); sq->sq_flags |= SQ_EXCL; } mutex_exit(SQLOCK(sq)); } ASSERT((sq->sq_flags & (SQ_EXCL|SQ_CIPUT))); ASSERT(MUTEX_NOT_HELD(SQLOCK(sq))); /* * We now have a claim on the syncq, we are either going to * put the message on the syncq and then drain it, or we are * going to call the putproc(). */ putproc = qi->qi_putp; if (!queued) { STR_FTEVENT_MSG(mp, fqp, FTEV_PUTNEXT, mp->b_rptr - mp->b_datap->db_base); (*putproc)(qp, mp); ASSERT(MUTEX_NOT_HELD(SQLOCK(sq))); ASSERT(MUTEX_NOT_HELD(QLOCK(qp))); } else { mutex_enter(QLOCK(qp)); /* * If there are no messages in front of us, just call putproc(), * otherwise enqueue the message and drain the queue. */ if (qp->q_syncqmsgs == 0) { mutex_exit(QLOCK(qp)); STR_FTEVENT_MSG(mp, fqp, FTEV_PUTNEXT, mp->b_rptr - mp->b_datap->db_base); (*putproc)(qp, mp); ASSERT(MUTEX_NOT_HELD(SQLOCK(sq))); } else { /* * We are doing a fill with the intent to * drain (meaning we are filling because * there are messages in front of us ane we * need to preserve message ordering) * Therefore, put the message on the queue * and call qdrain_syncq (must be done with * the QLOCK held). */ STR_FTEVENT_MSG(mp, fqp, FTEV_PUTNEXT, mp->b_rptr - mp->b_datap->db_base); #ifdef DEBUG /* * These two values were in the original code for * all syncq messages. This is unnecessary in * the current implementation, but was retained * in debug mode as it is usefull to know where * problems occur. */ mp->b_queue = qp; mp->b_prev = (mblk_t *)putproc; #endif SQPUT_MP(qp, mp); qdrain_syncq(sq, qp); ASSERT(MUTEX_NOT_HELD(QLOCK(qp))); } } /* * Before we release our claim, we need to see if any * events were posted. If the syncq is SQ_EXCL && SQ_QUEUED, * we were responsible for going exclusive and, therefore, * are resposible for draining. */ if (sq->sq_flags & (SQ_EXCL)) { drain_mask = 0; } else { drain_mask = SQ_QUEUED; } if (sqciplock != NULL) { mutex_enter(sqciplock); flags = sq->sq_flags; ASSERT(flags & SQ_CIPUT); /* SQ_EXCL could have been set by qwriter_inner */ if ((flags & (SQ_EXCL|SQ_TAIL)) || sq->sq_needexcl) { /* * we need SQLOCK to handle * wakeups/drains/flags change. sqciplock * is needed to decrement sqcipcount. * SQLOCK has to be grabbed before sqciplock * for lock ordering purposes. * after sqcipcount is decremented some lock * still needs to be held to make sure * syncq won't get freed on us. * * To prevent deadlocks we try to grab SQLOCK and if it * is held already we drop sqciplock, acquire SQLOCK and * reacqwire sqciplock again. */ if (mutex_tryenter(SQLOCK(sq)) == 0) { mutex_exit(sqciplock); mutex_enter(SQLOCK(sq)); mutex_enter(sqciplock); } flags = sq->sq_flags; ASSERT(*sqcipcount != 0); (*sqcipcount)--; mutex_exit(sqciplock); } else { ASSERT(*sqcipcount != 0); (*sqcipcount)--; mutex_exit(sqciplock); TRACE_3(TR_FAC_STREAMS_FR, TR_PUTNEXT_END, "putnext_end:(%p, %p, %p) done", qp, mp, sq); return; } } else { mutex_enter(SQLOCK(sq)); flags = sq->sq_flags; ASSERT(sq->sq_count != 0); sq->sq_count--; } if ((flags & (SQ_TAIL)) || sq->sq_needexcl) { putnext_tail(sq, qp, (flags & ~drain_mask)); /* * The only purpose of this ASSERT is to preserve calling stack * in DEBUG kernel. */ ASSERT(sq != NULL); return; } ASSERT((sq->sq_flags & (SQ_EXCL|SQ_CIPUT)) || queued); ASSERT((flags & (SQ_EXCL|SQ_CIPUT)) || queued); /* * Safe to always drop SQ_EXCL: * Not SQ_CIPUT means we set SQ_EXCL above * For SQ_CIPUT SQ_EXCL will only be set if the put * procedure did a qwriter(INNER) in which case * nobody else is in the inner perimeter and we * are exiting. * * I would like to make the following assertion: * * ASSERT((flags & (SQ_EXCL|SQ_CIPUT)) != (SQ_EXCL|SQ_CIPUT) || * sq->sq_count == 0); * * which indicates that if we are both putshared and exclusive, * we became exclusive while executing the putproc, and the only * claim on the syncq was the one we dropped a few lines above. * But other threads that enter putnext while the syncq is exclusive * need to make a claim as they may need to drop SQLOCK in the * has_writers case to avoid deadlocks. If these threads are * delayed or preempted, it is possible that the writer thread can * find out that there are other claims making the (sq_count == 0) * test invalid. */ sq->sq_flags = flags & ~SQ_EXCL; mutex_exit(SQLOCK(sq)); TRACE_3(TR_FAC_STREAMS_FR, TR_PUTNEXT_END, "putnext_end:(%p, %p, %p) done", qp, mp, sq); }
/* * Fusion output routine, called by tcp_output() and tcp_wput_proto(). */ boolean_t tcp_fuse_output(tcp_t *tcp, mblk_t *mp, uint32_t send_size) { tcp_t *peer_tcp = tcp->tcp_loopback_peer; uint_t max_unread; boolean_t flow_stopped; boolean_t urgent = (DB_TYPE(mp) != M_DATA); ASSERT(tcp->tcp_fused); ASSERT(peer_tcp != NULL && peer_tcp->tcp_loopback_peer == tcp); ASSERT(tcp->tcp_connp->conn_sqp == peer_tcp->tcp_connp->conn_sqp); ASSERT(DB_TYPE(mp) == M_DATA || DB_TYPE(mp) == M_PROTO || DB_TYPE(mp) == M_PCPROTO); max_unread = peer_tcp->tcp_fuse_rcv_unread_hiwater; /* If this connection requires IP, unfuse and use regular path */ if (TCP_LOOPBACK_IP(tcp) || TCP_LOOPBACK_IP(peer_tcp) || IPP_ENABLED(IPP_LOCAL_OUT|IPP_LOCAL_IN)) { TCP_STAT(tcp_fusion_aborted); tcp_unfuse(tcp); return (B_FALSE); } if (send_size == 0) { freemsg(mp); return (B_TRUE); } /* * Handle urgent data; we either send up SIGURG to the peer now * or do it later when we drain, in case the peer is detached * or if we're short of memory for M_PCSIG mblk. */ if (urgent) { /* * We stop synchronous streams when we have urgent data * queued to prevent tcp_fuse_rrw() from pulling it. If * for some reasons the urgent data can't be delivered * below, synchronous streams will remain stopped until * someone drains the tcp_rcv_list. */ TCP_FUSE_SYNCSTR_PLUG_DRAIN(peer_tcp); tcp_fuse_output_urg(tcp, mp); } mutex_enter(&peer_tcp->tcp_fuse_lock); /* * Wake up and signal the peer; it is okay to do this before * enqueueing because we are holding the lock. One of the * advantages of synchronous streams is the ability for us to * find out when the application performs a read on the socket, * by way of tcp_fuse_rrw() entry point being called. Every * data that gets enqueued onto the receiver is treated as if * it has arrived at the receiving endpoint, thus generating * SIGPOLL/SIGIO for asynchronous socket just as in the strrput() * case. However, we only wake up the application when necessary, * i.e. during the first enqueue. When tcp_fuse_rrw() is called * it will send everything upstream. */ if (peer_tcp->tcp_direct_sockfs && !urgent && !TCP_IS_DETACHED(peer_tcp)) { if (peer_tcp->tcp_rcv_list == NULL) STR_WAKEUP_SET(STREAM(peer_tcp->tcp_rq)); /* Update poll events and send SIGPOLL/SIGIO if necessary */ STR_SENDSIG(STREAM(peer_tcp->tcp_rq)); } /* * Enqueue data into the peer's receive list; we may or may not * drain the contents depending on the conditions below. */ tcp_rcv_enqueue(peer_tcp, mp, send_size); /* In case it wrapped around and also to keep it constant */ peer_tcp->tcp_rwnd += send_size; /* * Exercise flow-control when needed; we will get back-enabled * in either tcp_accept_finish(), tcp_unfuse(), or tcp_fuse_rrw(). * If tcp_direct_sockfs is on or if the peer endpoint is detached, * we emulate streams flow control by checking the peer's queue * size and high water mark; otherwise we simply use canputnext() * to decide if we need to stop our flow. * * The outstanding unread data block check does not apply for a * detached receiver; this is to avoid unnecessary blocking of the * sender while the accept is currently in progress and is quite * similar to the regular tcp. */ if (TCP_IS_DETACHED(peer_tcp) || max_unread == 0) max_unread = UINT_MAX; flow_stopped = tcp->tcp_flow_stopped; if (!flow_stopped && (((peer_tcp->tcp_direct_sockfs || TCP_IS_DETACHED(peer_tcp)) && (peer_tcp->tcp_rcv_cnt >= peer_tcp->tcp_fuse_rcv_hiwater || ++peer_tcp->tcp_fuse_rcv_unread_cnt >= max_unread)) || (!peer_tcp->tcp_direct_sockfs && !TCP_IS_DETACHED(peer_tcp) && !canputnext(peer_tcp->tcp_rq)))) { tcp_setqfull(tcp); flow_stopped = B_TRUE; TCP_STAT(tcp_fusion_flowctl); DTRACE_PROBE4(tcp__fuse__output__flowctl, tcp_t *, tcp, uint_t, send_size, uint_t, peer_tcp->tcp_rcv_cnt, uint_t, peer_tcp->tcp_fuse_rcv_unread_cnt); } else if (flow_stopped &&
std::string Vector2::ToString() const { return STREAM("(" << x << ", " << y << ")"); }