Ejemplo n.º 1
0
static void _todays_weth(RealD *tmax, RealD *tmin, RealD *ppt) {
/* --------------------------------------------------- */
/* If use_markov=FALSE and no weather file found, we won't
* get this far because the new_year() will fail, so if
* no weather file found and we make it here, use_markov=TRUE
* and we call mkv_today().  Otherwise, we're using this
* year's weather file and this logic sets today's value
* to yesterday's if today's is missing.  This may not
* always be most desirable, especially for ppt, so its
* default is 0.
*/
SW_WEATHER *w = &SW_Weather;
TimeInt doy = SW_Model.doy-1;

if (!weth_found) {
*ppt = w->now.ppt[Yesterday]; /* reqd for markov */
SW_MKV_today(doy, tmax, tmin, ppt);

} else {
*tmax = (!missing(w->hist.temp_max[doy]) )
? w->hist.temp_max[doy]
: w->now.temp_max[Yesterday];
*tmin = (!missing(w->hist.temp_min[doy]) )
? w->hist.temp_min[doy]
: w->now.temp_min[Yesterday];
*ppt  = (!missing(w->hist.ppt[doy]) )
? w->hist.ppt[doy]
: 0.;
}

}
Ejemplo n.º 2
0
 void leaf_action(store_config, Val* pval, conf_expr_base const& conf) const {
   std::string const& pathname = conf.path_name();
   auto& opt = *conf.opt;
   if (std::string const* v = get(pathname))
     opt.apply_string_value(*v, pval, pathname, warn);
   else if (opt.is_required_err())
     missing(pathname, false);
   else if (opt.is_required_warn())
     missing(pathname, true);
 }
Ejemplo n.º 3
0
int main(int argc, char const *argv[]) {

	int x1, x2, x3;
	int y1, y2, y3;

	scanf("%d %d", &x1, &y1);
	scanf("%d %d", &x2, &y2);
	scanf("%d %d", &x3, &y3);

	printf("%d %d\n", missing(x1, x2, x3), missing(y1, y2, y3));

	return 0;
}
Ejemplo n.º 4
0
static int read_data (FILE *fp)
{
    char line[64];
    double y, x1, x2;
    int n = 0, err = 0;

    if (tester.nobs == 0) {
	missing("number of observations");
	return 1;
    }

    if (tester.nvars == 0) {
	missing("number of variables");
	return 1;
    }    

    strcpy(datainfo->varname[1], "y");
    if (tester.nvars == 2) {
	strcpy(datainfo->varname[2], "x");
    } else if (tester.nvars == 3) {
	strcpy(datainfo->varname[2], "x1");
	strcpy(datainfo->varname[3], "x2");
    }	

    while (fgets(line, sizeof line, fp) && !err) {
	if (tester.nvars == 3 && sscanf(line, "%lf %lf %lf", &y, &x1, &x2) == 3) {
	    Z[1][n] = y;
	    Z[2][n] = x1;
	    Z[3][n] = x2;
	    n++;
	} else if (tester.nvars == 2 && sscanf(line, "%lf %lf", &y, &x1) == 2) {
	    Z[1][n] = y;
	    Z[2][n] = x1;
	    n++;
	}	    
    }

    if (n == tester.nobs) {
	if (verbose) {
	    printf("OK: Found %d valid observations\n", n);
	}
    } else {
	fprintf(stderr, "%s: ERROR: Datafile specified %d obs, but found %d\n", 
	       tester.datname, tester.nobs, n);
	err = 1;
    }	

    return err;
}
Ejemplo n.º 5
0
Archivo: main.c Proyecto: alg0hm/7x7
int main(int argc, char *argv[])  {
    
    int aflag = 0;
    int bflag = 0;
    int sflag = 0;
    int i;
    wiringPiSetupGpio();
    mcp3004Setup(BASE, SPI_CHAN);
    pinMode(buttonA_pin,INPUT);
    pinMode(buttonB_pin,INPUT);
    pinMode(buttonC_pin,INPUT);
    pinMode(buttonD_pin,INPUT);
    pinMode(pir_pin, INPUT);

    if (argc < 2) {
      missing();
      return 0;
    }
    while ((i = getopt (argc, argv, "abs")) != -1)  { 
      switch (i)
      {
        case 'a':
          aflag = 1;
          alhambra_start(argv);
          break;
        case 'b':
          bflag = 1;
          boca_start(argv);
          break;
        case 's':
          sflag = 1;
          sculpture_start(argv);
          break;
        case '?':
          if (isprint (optopt)) {
            missing();
          }
          else if (isprint (optopt))  {
            printf("Missing option");
          }
          else  {
            printf ("Unknow option character\n");
          }
        default:
          printf ("\nstop\n");
      }
    }
}
/**
 * @brief Encode all individual fields into the provided byte buffer in the proper order
 *        and format for final insertion into a Variant object.
 */
void VariantBuilderIndividualRegion::encode_into(kstring_t* buffer) const {
  // Theoretically possible that GT is not declared at all in the header
  const auto gt_field_is_declared = ! missing(m_gt_field_index);
  const auto gt_physical_index = gt_field_is_declared ? m_field_lookup_table[m_gt_field_index] : missing_values::int32;

  // GT must be encoded first, as per the spec
  if ( gt_field_is_declared && m_int_fields[gt_physical_index].present() ) {
    m_int_fields[gt_physical_index].encode_into(buffer);
  }

  // TODO: order the remaining format fields in a more sensible (or at least customizable) way than by type,
  //       such as by global field index
  for ( auto i = 0u; i < m_int_fields.size(); ++i ) {
    if ( (int32_t(i) != gt_physical_index || ! gt_field_is_declared) && m_int_fields[i].present() ) {
      m_int_fields[i].encode_into(buffer);
    }
  }

  for ( auto& field : m_float_fields ) {
    if ( field.present() ) field.encode_into(buffer);
  }

  for ( auto& field : m_string_fields ) {
    if ( field.present() ) field.encode_into(buffer);
  }
}
Ejemplo n.º 7
0
void fasta::append_seq( fasta in, bool fill ){
    // assuming both fasta objects are aligned within each other, and adding at the end
    // of the shortest 'Ns'
    if(fill){
        
        if( in.num_bases() < this->num_bases() ){
            string missing ( this->num_bases() - in.num_bases(), 'n');
            for (unsigned int nline = 0 ; nline < in.num_lines() ; nline++) {
                for (unsigned int base = 0; base < missing.size(); base++) {
                    in.matrix.at(nline).push_back(missing.at(base));
                }
            }
        }
        else if (in.num_bases() > this->num_bases()){
            string missing ( in.num_bases() - this->num_bases(), 'n');
            for (unsigned int nline = 0 ; nline < this->num_lines() ; nline++) {
                for (unsigned int base = 0; base < missing.size(); base++) {
                    matrix.at(nline).push_back(missing.at(base));
                }
            }
        }
        
    }
    else if ( in.num_bases() != this->num_bases() ){
        cerr << "ERROR (fasta, add_seq): sequence to add has length different from alignment ("
        << in.num_bases() << " and " << this->num_bases() << ")\n";
        exit(1);
    }
    
    
    
    for (unsigned int i = 0; i < in.num_lines(); i++ ) {
        matrix.push_back(in.matrix.at(i).c_str());
    }
    
    infile = infile + " + " + in.infile;
    
    if( this->num_lines() == this->num_names() && in.num_names() > 0 ){
        
        for (unsigned int i = 0; i < in.num_lines(); i++ ) {
            
            names.push_back(in.names.at(i));
        }
    }
    
    
}
Ejemplo n.º 8
0
static int find_ordered_chapter_sources(struct MPContext *mpctx,
                                        struct demuxer **sources,
                                        int num_sources,
                                        unsigned char uid_map[][16])
{
    int num_filenames = 0;
    char **filenames = NULL;
    if (num_sources > 1) {
        char *main_filename = mpctx->demuxer->filename;
        mp_msg(MSGT_CPLAYER, MSGL_INFO, "This file references data from "
               "other sources.\n");
        if (mpctx->demuxer->stream->uncached_type != STREAMTYPE_FILE) {
            mp_msg(MSGT_CPLAYER, MSGL_WARN, "Playback source is not a "
                   "normal disk file. Will not search for related files.\n");
        } else {
            mp_msg(MSGT_CPLAYER, MSGL_INFO, "Will scan other files in the "
                   "same directory to find referenced sources.\n");
            filenames = find_files(main_filename, ".mkv");
            num_filenames = MP_TALLOC_ELEMS(filenames);
        }
        // Possibly get further segments appended to the first segment
        check_file(mpctx, sources, num_sources, uid_map, main_filename, 1);
    }

    for (int i = 0; i < num_filenames; i++) {
        if (!missing(sources, num_sources))
            break;
        mp_msg(MSGT_CPLAYER, MSGL_INFO, "Checking file %s\n", filenames[i]);
        check_file(mpctx, sources, num_sources, uid_map, filenames[i], 0);
    }

    talloc_free(filenames);
    if (missing(sources, num_sources)) {
        mp_msg(MSGT_CPLAYER, MSGL_ERR, "Failed to find ordered chapter part!\n"
               "There will be parts MISSING from the video!\n");
        int j = 1;
        for (int i = 1; i < num_sources; i++)
            if (sources[i]) {
                sources[j] = sources[i];
                memcpy(uid_map[j], uid_map[i], 16);
                j++;
            }
        num_sources = j;
    }
    return num_sources;
}
Ejemplo n.º 9
0
/* verify that all the necessary device registers are accessible */
void
chkmissing(void)
{
	delay(10);
	missing(KZERO, "dram");
	missing(soc.intr, "intr ctlr");
	missing(soc.intrdist, "intr distrib");
	missing(soc.tmr[0], "tegra timer1");
	missing(soc.uart[0], "console uart");
	missing(soc.pci, "pcie");
	missing(soc.ether, "ether8169");
	missing(soc.µs, "µs counter");
	if (missed)
		iprint("\n");
	delay(10);
}
Ejemplo n.º 10
0
    void importDatabases(const QString & iPhone) {
        if(iPhone != "3G" && iPhone != "3GS" && iPhone != "4" && iPhone != "4S")
            QMessageBox::critical(this, tr("Cannot recognize the selected iPhone"),
                                  tr("Error") + ":\n" + tr("It seems that the iPhone version selected") + " (\"" + iPhone +
                                  "\")\n" + tr("is not yet supported by the software.") + "\n", QMessageBox::Ok);
        else {
            QString folder(this -> dbPath["path"] + this -> phones[iPhone]), fileName("");
            std::vector<QString> errors, copies;
            for(std::map<QString, QString>::iterator it(this -> dbPath.begin()); it != this -> dbPath.end(); ++it) {
                if(it -> first != "path") {
                    fileName = folder + "/" + it -> second;
                    if(QFile::exists(fileName)) {
                        this -> checkCopy(this -> names[it -> second]);
                        if(!QFile::copy(fileName, this -> appPath + "/utils/tmp/" + this -> names[it -> second]))
                            copies.push_back(this -> names[it -> second]);
                    } else errors.push_back(this -> names[it -> second]);
                }
            }

            if(!errors.empty()) {
                QString missing("");
                for(std::vector<QString>::iterator it(errors.begin()); it != errors.end(); ++it)
                    missing += "\n   - " + *it;
                QMessageBox::warning(this, (errors.size() > 1 ? tr("Some databases are missing") : tr("A database is missing")),
                                     tr("Warning") + ":\n" + tr("Cannot found") + " >>\n" + missing, QMessageBox::Ok);
            }

            if(!copies.empty()) {
                QString missing(""), title(copies.size() > 1 ? tr("some databases") : tr("a database"));
                for(std::vector<QString>::iterator it(copies.begin()); it != copies.end(); ++it)
                    missing += "\n   - " + *it;
                QMessageBox::warning(this, tr("Cannot copy") + " " + title,
                                     tr("Warning") + ":\n" + tr("Cannot copy") + " >>\n" + missing, QMessageBox::Ok);
            }
        }
    }
Ejemplo n.º 11
0
const id_t& CcTx::get_eta()
{
    // Sanity-check ETA to make sure it's in the future.
    if (eta+CC_TX_WINDOW_OPEN < millis() &&
            eta+CC_TX_WINDOW_OPEN+SAMPLE_PERIOD < millis()+SAMPLE_PERIOD)
        /* one possible reason
            for eta < millis() is that millis() has rolled over.
            If millis() has rolled over
            then eta+SAMPLE_PERIOD > millis()+SAMPLE_PERIOD.  In other words, only
            called missing() if the fact that eta < millis cannot be explained
            by roll-over.  We want to let roll-over do its thing.  */
    {
        log(DEBUG, PSTR("eta %lu < millis() %lu. id=%lu. num_periods=%d, active=%d"), eta, millis(), id, num_periods_missed, active);
        missing();
    }
	return eta;
}
Ejemplo n.º 12
0
static RealD _runavg_temp(RealD avg) {
/* --------------------------------------------------- */
int i, cnt, numdays;
RealD sum=0.;
static TimeInt tail = 0;

runavg_list[tail] = avg;
numdays = (SW_Model.doy < SW_Weather.days_in_runavg)
? SW_Model.doy
: SW_Weather.days_in_runavg;

for(i=0, cnt=0; i<numdays; i++, cnt++) {
if (!missing(runavg_list[i]))  {
sum += runavg_list[i];
}
}
tail = (tail < SW_Weather.days_in_runavg-1) ? tail +1 : 0;
return ((cnt) ? sum/cnt : WTH_MISSING);
}
void SW_SWC_water_flow( void) {
/* =================================================== */
/* Adjust SWC according to historical (measured) data
* if available, compute water flow, and check if swc
* is above threshold for "wet" condition.
*/

LyrIndex i;


/* if there's no swc observation for today,
* it shows up as SW_MISSING.  The input must
* define historical swc for at least the top
* layer to be recognized.
* IMPORTANT: swc can't be adjusted on day 1 of first year of simulation.
10/25/2010	(drs)	in SW_SWC_water_flow(): replaced test that "swc can't be adjusted on day 1 of year 1" to "swc can't be adjusted on start day of first year of simulation"
*/


if ( SW_Soilwat.hist_use && !missing( SW_Soilwat.hist.swc[SW_Model.doy-1][1]) ) {

	if (! (SW_Model.doy == SW_Model.startstart && SW_Model.year == SW_Model.startyr) ) {

	SW_SWC_adjust_swc(SW_Model.doy);

	} else {
		LogError(logfp, LOGWARN, "Attempt to set SWC on start day of first year of simulation disallowed.");
	}

} else {
	SW_Water_Flow();
}


ForEachSoilLayer(i) 
SW_Soilwat.is_wet[i] = (GE( SW_Soilwat.swc[Today][i],
SW_Site.lyr[i]->swc_wet));
}
size_t Exchange::getTargetConsumer(const Document& input) {
    // Build the key.
    BSONObjBuilder kb;
    size_t counter = 0;
    for (auto elem : _keyPattern) {
        auto value = input.getNestedField(_keyPaths[counter]);

        // By definition we send documents with missing fields to the consumer 0.
        if (value.missing()) {
            return 0;
        }

        if (elem.type() == BSONType::String && elem.str() == "hashed") {
            kb << "" << BSONElementHasher::hash64(BSON("" << value).firstElement(),
                                                  BSONElementHasher::DEFAULT_HASH_SEED);
        } else {
            kb << "" << value;
        }
        ++counter;
    }

    KeyString key{KeyString::Version::V1, kb.obj(), _ordering};
    std::string keyStr{key.getBuffer(), key.getSize()};

    // Binary search for the consumer id.
    auto it = std::upper_bound(_boundaries.begin(), _boundaries.end(), keyStr);
    invariant(it != _boundaries.end());

    size_t distance = std::distance(_boundaries.begin(), it) - 1;
    invariant(distance < _consumerIds.size());

    size_t cid = _consumerIds[distance];
    invariant(cid < _consumers.size());

    return cid;
}
Ejemplo n.º 15
0
bool __AGE OpenGL::init()
{
  glIsProgram = (PFNGLISPROGRAMPROC) SDL_GL_GetProcAddress("glIsProgram");
  glDeleteProgram = (PFNGLDELETEPROGRAMPROC) SDL_GL_GetProcAddress("glDeleteProgram");
  glIsProgram = (PFNGLISPROGRAMPROC) SDL_GL_GetProcAddress("glIsProgram");
  glUseProgram = (PFNGLUSEPROGRAMPROC) SDL_GL_GetProcAddress("glUseProgram");
  glDeleteProgram = (PFNGLDELETEPROGRAMPROC) SDL_GL_GetProcAddress("glDeleteProgram");
  glIsShader = (PFNGLISSHADERPROC) SDL_GL_GetProcAddress("glIsShader");
  glDeleteShader = (PFNGLDELETESHADERPROC) SDL_GL_GetProcAddress("glDeleteShader");
  glEnableVertexAttribArray = (PFNGLENABLEVERTEXATTRIBARRAYPROC) SDL_GL_GetProcAddress("glEnableVertexAttribArray");
  glDisableVertexAttribArray = (PFNGLDISABLEVERTEXATTRIBARRAYPROC) SDL_GL_GetProcAddress("glDisableVertexAttribArray");
  glVertexAttribPointer = (PFNGLVERTEXATTRIBPOINTERPROC) SDL_GL_GetProcAddress("glVertexAttribPointer");
  glGetUniformLocation = (PFNGLGETUNIFORMLOCATIONPROC) SDL_GL_GetProcAddress("glGetUniformLocation");
  glUniformMatrix4fv = (PFNGLUNIFORMMATRIX4FVPROC) SDL_GL_GetProcAddress("glUniformMatrix4fv");
  glUniform1f = (PFNGLUNIFORM1FPROC) SDL_GL_GetProcAddress("glUniform1f");
  glUniform4f = (PFNGLUNIFORM4FPROC) SDL_GL_GetProcAddress("glUniform4f");
  glUniform1i = (PFNGLUNIFORM1IPROC) SDL_GL_GetProcAddress("glUniform1i");
  glCreateProgram = (PFNGLCREATEPROGRAMPROC) SDL_GL_GetProcAddress("glCreateProgram");
  glCreateShader = (PFNGLCREATESHADERPROC) SDL_GL_GetProcAddress("glCreateShader");
  glShaderSource = (PFNGLSHADERSOURCEPROC) SDL_GL_GetProcAddress("glShaderSource");
  glCompileShader = (PFNGLCOMPILESHADERPROC) SDL_GL_GetProcAddress("glCompileShader");
  glAttachShader = (PFNGLATTACHSHADERPROC) SDL_GL_GetProcAddress("glAttachShader");
  glBindAttribLocation = (PFNGLBINDATTRIBLOCATIONPROC) SDL_GL_GetProcAddress("glBindAttribLocation");
  glLinkProgram = (PFNGLLINKPROGRAMPROC) SDL_GL_GetProcAddress("glLinkProgram");
  glGetShaderInfoLog = (PFNGLGETSHADERINFOLOGPROC) SDL_GL_GetProcAddress("glGetShaderInfoLog");
  glGetProgramInfoLog = (PFNGLGETPROGRAMINFOLOGPROC) SDL_GL_GetProcAddress("glGetProgramInfoLog");
  glActiveTexture = (PFNGLACTIVETEXTUREPROC) SDL_GL_GetProcAddress("glActiveTexture");
  glGenBuffers = (PFNGLGENBUFFERSPROC) SDL_GL_GetProcAddress("glGenBuffers");
  glBindBuffer = (PFNGLBINDBUFFERPROC) SDL_GL_GetProcAddress("glBindBuffer");
  glBufferData = (PFNGLBUFFERDATAPROC) SDL_GL_GetProcAddress("glBufferData");
  glBufferSubData = (PFNGLBUFFERSUBDATAPROC) SDL_GL_GetProcAddress("glBufferSubData");
  glDeleteBuffers = (PFNGLDELETEBUFFERSPROC) SDL_GL_GetProcAddress("glDeleteBuffers");
  glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) SDL_GL_GetProcAddress("glGenerateMipmap");
  if(!glGenerateMipmap) 
    glGenerateMipmap = (PFNGLGENERATEMIPMAPPROC) SDL_GL_GetProcAddress("glGenerateMipmapEXT");
  

  bool success = true;
  std::string missing("The following functions are missing:\n");

  if( !glIsProgram                ){ success = false; missing += " glIsProgram               \n";}
  if( !glUseProgram               ){ success = false; missing += " glUseProgram              \n";}
  if( !glDeleteProgram            ){ success = false; missing += " glDeleteProgram           \n";}
  if( !glIsShader                 ){ success = false; missing += " glIsShader                \n";}
  if( !glDeleteShader             ){ success = false; missing += " glDeleteShader            \n";}
  if( !glEnableVertexAttribArray  ){ success = false; missing += " glEnableVertexAttribArray \n";}
  if( !glDisableVertexAttribArray ){ success = false; missing += " glDisableVertexAttribArray\n";}
  if( !glVertexAttribPointer      ){ success = false; missing += " glVertexAttribPointer     \n";}
  if( !glGetUniformLocation       ){ success = false; missing += " glGetUniformLocation      \n";}
  if( !glUniformMatrix4fv         ){ success = false; missing += " glUniformMatrix4fv        \n";}
  if( !glUniform1f                ){ success = false; missing += " glUniform1f               \n";}
  if( !glUniform4f                ){ success = false; missing += " glUniform4f               \n";}
  if( !glUniform1i                ){ success = false; missing += " glUniform1i               \n";}
  if( !glCreateProgram            ){ success = false; missing += " glCreateProgram           \n";}
  if( !glCreateShader             ){ success = false; missing += " glCreateShader            \n";}
  if( !glShaderSource             ){ success = false; missing += " glShaderSource            \n";}
  if( !glCompileShader            ){ success = false; missing += " glCompileShader           \n";}
  if( !glAttachShader             ){ success = false; missing += " glAttachShader            \n";}
  if( !glBindAttribLocation       ){ success = false; missing += " glBindAttribLocation      \n";}
  if( !glLinkProgram              ){ success = false; missing += " glLinkProgram             \n";}
  if( !glGetShaderInfoLog         ){ success = false; missing += " glGetShaderInfoLog        \n";}
  if( !glGetProgramInfoLog        ){ success = false; missing += " glGetProgramInfoLog       \n";}
  if( !glActiveTexture            ){ success = false; missing += " glActiveTexture           \n";}
  if( !glGenBuffers               ){ success = false; missing += " glGenBuffers              \n";}
  if( !glBindBuffer               ){ success = false; missing += " glBindBuffer              \n";}
  if( !glBufferData               ){ success = false; missing += " glBufferData              \n";}
  if( !glBufferSubData            ){ success = false; missing += " glBufferSubData           \n";}
  if( !glDeleteBuffers            ){ success = false; missing += " glDeleteBuffers           \n";}
  if( !glGenerateMipmap           ){ success = false; missing += " glGenerateMipmap          \n";}


  if( !success )
    errlog(missing);

  return success;
}
Ejemplo n.º 16
0
static int
flags(int ac, char **av)
{
	int	i;

	for (i = 1; i < ac && av[i][0] == '-'; i++) {
	nxt:	switch (av[i][1]) {
		case 'e':
			eflag = validate(&av[i][2], 'e');
			continue;
		case 'E':
			if (av[i][2])
				eflag = validate(&av[i][2], 'E');
			else if (++i < ac)
				eflag = validate(av[i], 'E');
			else
				missing('E');
			continue;
		case 'i':
			if (av[i][2])
				iflag = validate(&av[i][2], 'i');
			else
				iflag = "{}";
			continue;
		case 'I':
			if (av[i][2])
				iflag = validate(&av[i][2], 'i');
			else if (++i < ac)
				iflag = validate(av[i], 'i');
			else
				missing('I');
			continue;
		case 'l':
			if (av[i][2])
				lflag = number('l', &av[i][2]);
			else
				lflag = 1;
			xflag = 1;
			iflag = NULL;
			continue;
		case 'L':
			if (av[i][2])
				lflag = number('L', &av[i][2]);
			else if (++i < ac)
				lflag = number('L', av[i]);
			else
				mustbepos('L', "");
			xflag = 1;
			iflag = NULL;
			nflag = 0;
			continue;
		case 'n':
			if (av[i][2])
				nflag = number('n', &av[i][2]);
			else if (++i < ac)
				nflag = number('n', av[i]);
			else
				mustbepos('n', "");
			lflag = 0;
			continue;
		case 'p':
			pflag = open("/dev/tty", O_RDONLY);
			fcntl(pflag, F_SETFD, FD_CLOEXEC);
			tflag = 1;
			break;
		case 's':
			if (av[i][2])
				sflag = &av[i][2];
			else if (++i < ac)
				sflag = av[i];
			else
				sflag = "0";
			continue;
		case 't':
			tflag = 1;
			break;
		case 'x':
			xflag = 1;
			break;
		case '-':
			return ++i;
		default:
			unknown(&av[i][1]);
		}
		if (av[i][2]) {
			(av[i])++;
			goto nxt;
		}
	}
	return i;
}
Ejemplo n.º 17
0
numvar getarg(numvar which) {
	if (which > arg[0]) missing(M_arg);
	return arg[-which];
}
Ejemplo n.º 18
0
//
//	Recursive descent parser, old-school style.
//
void getfactor(void) {
numvar thesymval = symval;
byte thesym = sym;
	getsym();		// eat the sym we just saved

	switch (thesym) {
		case s_nval:
			vpush(thesymval);
			break;
			
		case s_nvar:
			if (sym == s_equals) {		// assignment, push is after the break;
				getsym();
				assignVar(thesymval, getnum());
			}
			else if (sym == s_incr) {	// postincrement nvar++
				vpush(getVar(thesymval));
				assignVar(thesymval, getVar(thesymval) + 1);
				getsym();
				break;
			}
			else if (sym == s_decr) {	// postdecrement nvar--
				vpush(getVar(thesymval));
				assignVar(thesymval, getVar(thesymval) - 1);
				getsym();
				break;
			}
			vpush(getVar(thesymval));			// both assignment and reference get pushed here
			break;

		case s_nfunct:
			dofunctioncall(thesymval);			// get its value onto the stack
			break;

		// Script-function-returning-value used as a factor
		case s_script_eeprom:				// macro returning value
			callscriptfunction(SCRIPT_EEPROM, findend(thesymval));
			break;

		case s_script_progmem:
			callscriptfunction(SCRIPT_PROGMEM, thesymval);
			break;

		case s_script_file:
			callscriptfunction(SCRIPT_FILE, (numvar) 0);	// name implicitly in idbuf!
			break;

		case s_apin:					// analog pin reference like a0
			if (sym == s_equals) { 		// digitalWrite or analogWrite
				getsym();
				analogWrite(thesymval, getnum());
				vpush(expval);
			}
			else vpush(analogRead(thesymval));
			break;

		case s_dpin:					// digital pin reference like d1
			if (sym == s_equals) { 		// digitalWrite or analogWrite
				getsym();
				digitalWrite(thesymval, getnum());
				vpush(expval);
			}
			else vpush(digitalRead(thesymval));
			break;

		case s_incr:
			if (sym != s_nvar) expected(M_var);
			assignVar(symval, getVar(symval) + 1);
			vpush(getVar(symval));
			getsym();
			break;

		case s_decr:		// pre decrement
			if (sym != s_nvar) expected(M_var);
			assignVar(symval, getVar(symval) - 1);
			vpush(getVar(symval));
			getsym();
			break;

		case s_arg:			// arg(n) - argument value
			if (sym != s_lparen) expectedchar(s_lparen);
			getsym(); 		// eat '('
			vpush(getarg(getnum()));
			if (sym != s_rparen) expectedchar(s_rparen);
			getsym();		// eat ')'
			break;

		case s_lparen:  // expression in parens
			getexpression();
			if (exptype != s_nval) expected(M_number);
			if (sym != s_rparen) missing(M_rparen);
			vpush(expval);
			getsym();	// eat the )
			break;

		//
		// The Family of Unary Operators, which Bind Most Closely to their Factor
		//
		case s_add:			// unary plus (like +3) is kind of a no-op
			getfactor();	// scan a factor and leave its result on the stack
			break;			// done
	
		case s_sub:			// unary minus (like -3)
			getfactor();
			vpush(-vpop());	// similar to above but we adjust the stack value
			break;
	
		case s_bitnot:
			getfactor();
			vpush(~vpop());
			break;
	
		case s_logicalnot:
			getfactor();
			vpush(!vpop());
			break;

		case s_bitand:		// &var gives address-of-var; &macro gives eeprom address of macro
			if (sym == s_nvar) vpush((numvar) &vars[symval]);
			else if (sym == s_script_eeprom) vpush(symval);
			else expected(M_var);
			getsym();		// eat the var reference
			break;

		case s_mul:			// *foo is contents-of-address-foo; *foo=bar is byte poke assignment

/*****
// what is really acceptable for an lvalue here? ;)
//	*y = 5 is failing now by assigning 5 to y before the * is dereferenced
//	due to calling getfactor
//	everything else works :(
*****/
			getfactor();
#if 0
			if (sym == s_equals) {
				getsym();	// eat '='
				getexpression();
				* (volatile byte *) vpop() = (byte) expval;
				vpush((numvar) (byte) expval);
			} 
			else 
#endif
			vpush((numvar) (* (volatile byte *) vpop()));
			break;

		default: 
			unexpected(M_number);
	}

}
Ejemplo n.º 19
0
int main(int argc, const char *argv[]) {
	int returnCode;
	struct FLContext *handle = NULL;
	FLStatus status;
	const char *error = NULL;
	uint8 byte = 0x10;
	uint8 buf[256];
	bool flag;
	bool isNeroCapable, isCommCapable;
	uint32 fileLen;
	uint8 *buffer = NULL;
	uint32 numDevices, scanChain[16], i;
	const char *vp = NULL, *ivp = NULL, *queryPort = NULL, *portConfig = NULL, *progConfig = NULL, *dataFile = NULL;
	const char *const prog = argv[0];

	printf("FPGALink \"C\" Example Copyright (C) 2011-2013 Chris McClelland\n\n");
	argv++;
	argc--;
	while ( argc ) {
		if ( argv[0][0] != '-' ) {
			unexpected(prog, *argv);
			FAIL(1);
		}
		switch ( argv[0][1] ) {
		case 'h':
			usage(prog);
			FAIL(0);
			break;
		case 'q':
			GET_ARG("q", queryPort, 2);
			break;
		case 'd':
			GET_ARG("d", portConfig, 3);
			break;
		case 'v':
			GET_ARG("v", vp, 4);
			break;
		case 'i':
			GET_ARG("i", ivp, 5);
			break;
		case 'p':
			GET_ARG("p", progConfig, 6);
			break;
		case 'f':
			GET_ARG("f", dataFile, 7);
			break;
		default:
			invalid(prog, argv[0][1]);
			FAIL(8);
		}
		argv++;
		argc--;
	}
	if ( !vp ) {
		missing(prog, "v <VID:PID>");
		FAIL(9);
	}

	status = flInitialise(0, &error);
	CHECK(10);
	
	printf("Attempting to open connection to FPGALink device %s...\n", vp);
	status = flOpen(vp, &handle, NULL);
	if ( status ) {
		if ( ivp ) {
			int count = 60;
			printf("Loading firmware into %s...\n", ivp);
			status = flLoadStandardFirmware(ivp, vp, &error);
			CHECK(11);
			
			printf("Awaiting renumeration");
			flSleep(1000);
			do {
				printf(".");
				fflush(stdout);
				flSleep(100);
				status = flIsDeviceAvailable(vp, &flag, &error);
				CHECK(12);
				count--;
			} while ( !flag && count );
			printf("\n");
			if ( !flag ) {
				fprintf(stderr, "FPGALink device did not renumerate properly as %s\n", vp);
				FAIL(13);
			}
			
			printf("Attempting to open connection to FPGLink device %s again...\n", vp);
			status = flOpen(vp, &handle, &error);
			CHECK(14);
		} else {
			fprintf(stderr, "Could not open FPGALink device at %s and no initial VID:PID was supplied\n", vp);
			FAIL(15);
		}
	}
	
	if ( portConfig ) {
		printf("Configuring ports...\n");
		status = flPortConfig(handle, portConfig, &error);
		CHECK(16);
		flSleep(100);
	}

	isNeroCapable = flIsNeroCapable(handle);
	isCommCapable = flIsCommCapable(handle);
	if ( queryPort ) {
		if ( isNeroCapable ) {
			status = jtagScanChain(handle, queryPort, &numDevices, scanChain, 16, &error);
			CHECK(17);
			if ( numDevices ) {
				printf("The FPGALink device at %s scanned its JTAG chain, yielding:\n", vp);
				for ( i = 0; i < numDevices; i++ ) {
					printf("  0x%08X\n", scanChain[i]);
				}
			} else {
				printf("The FPGALink device at %s scanned its JTAG chain but did not find any attached devices\n", vp);
			}
		} else {
			fprintf(stderr, "JTAG chain scan requested but FPGALink device at %s does not support NeroJTAG\n", vp);
			FAIL(18);
		}
	}

	if ( progConfig ) {
		printf("Executing programming configuration \"%s\" on FPGALink device %s...\n", progConfig, vp);
		if ( isNeroCapable ) {
			status = flProgram(handle, progConfig, NULL, &error);
			CHECK(19);
		} else {
			fprintf(stderr, "Program operation requested but device at %s does not support NeroProg\n", vp);
			FAIL(20);
		}
	}
	
	if ( dataFile ) {
		if ( isCommCapable ) {
			printf("Enabling FIFO mode...\n");
			status = flFifoMode(handle, true, &error);
			CHECK(21);
			printf("Zeroing registers 1 & 2...\n");
			byte = 0x00;
			status = flWriteChannel(handle, 1000, 0x01, 1, &byte, &error);
			CHECK(22);
			status = flWriteChannel(handle, 1000, 0x02, 1, &byte, &error);
			CHECK(23);
			
			buffer = flLoadFile(dataFile, &fileLen);
			if ( buffer ) {
				uint16 checksum = 0x0000;
				uint32 i;
				for ( i = 0; i < fileLen; i++ ) {
					checksum += buffer[i];
				}
				printf(
					"Writing %0.2f MiB (checksum 0x%04X) from %s to FPGALink device %s...\n",
					(double)fileLen/(1024*1024), checksum, dataFile, vp);
				status = flWriteChannel(handle, 30000, 0x00, fileLen, buffer, &error);
				CHECK(24);
			} else {
				fprintf(stderr, "Unable to load file %s!\n", dataFile);
				FAIL(25);
			}
			printf("Reading channel 0...");
			status = flReadChannel(handle, 1000, 0x00, 1, buf, &error);
			CHECK(26);
			printf("got 0x%02X\n", buf[0]);
			printf("Reading channel 1...");
			status = flReadChannel(handle, 1000, 0x01, 1, buf, &error);
			CHECK(27);
			printf("got 0x%02X\n", buf[0]);
			printf("Reading channel 2...");
			status = flReadChannel(handle, 1000, 0x02, 1, buf, &error);
			CHECK(28);
			printf("got 0x%02X\n", buf[0]);
		} else {
			fprintf(stderr, "Data file load requested but device at %s does not support CommFPGA\n", vp);
			FAIL(29);
		}
	}
	returnCode = 0;

cleanup:
	if ( error ) {
		fprintf(stderr, "%s\n", error);
		flFreeError(error);
	}
	flFreeFile(buffer);
	flClose(handle);
	return returnCode;
}
Ejemplo n.º 20
0
 void missing(std::string const& name, bool warn_only) const { missing(this->warn, name, warn_only); }
RealD SW_SWC_vol2bars ( RealD lyrvolcm, LyrIndex n) {
/**********************************************************************
PURPOSE: Calculate the soil water potential or the soilwater
content of the current layer,
as a function of soil texture at the layer.

DATE:  April 2, 1992

HISTORY:
9/1/92  (SLC) if swc comes in as zero, set swpotentl to
upperbnd.  (Previously, we flagged this
as an error, and set swpotentl to zero).

27-Aug-03 (cwb) removed the upperbnd business. Except for
missing values, swc < 0 is impossible, so it's an error,
and the previous limit of swp to 80 seems unreasonable.
return 0.0 if input value is MISSING

INPUTS:
swc - soilwater content of the current layer (cm/layer)
n   - layer number to index the **lyr pointer.

These are the values for each layer obtained via lyr[n]:
width  - width of current soil layer
psis   - "saturation" matric potential
thetas - saturated moisture content.
b       - see equation below.
swc_lim - limit for matric potential

LOCAL VARIABLES:
theta1 - volumetric soil water content

DEFINED CONSTANTS:
barconv - conversion factor from bars to cm water.  (i.e.
1 bar = 1024cm water)

COMMENT:
See the routine "watreqn" for a description of how the variables
psis, b, binverse, thetas are initialized.

OUTPUTS:
swpotentl - soilwater potential of the current layer
(if swflag=TRUE)
or
soilwater content (if swflag=FALSE)

DESCRIPTION: The equation and its coefficients are based on a
paper by Cosby,Hornberger,Clapp,Ginn,  in WATER RESOURCES RESEARCH
June 1984.  Moisture retention data was fit to the power function

**********************************************************************/

SW_LAYER_INFO *lyr= SW_Site.lyr[n];
float  theta1, swp=0.;

if (missing(lyrvolcm) || ZRO(lyrvolcm)) return 0.0;

if ( GT(lyrvolcm, 0.0) ) {
theta1 = (lyrvolcm / lyr->width) * 100.;
swp  = lyr->psis / pow(theta1/lyr->thetas, lyr->b) / BARCONV;
} else {
LogError( logfp, LOGFATAL,
"Invalid SWC value (%.4f) in SW_SWC_swc2potential.\n"
"    Year = %d, DOY=%d, Layer = %d\n",
lyrvolcm, SW_Model.year, SW_Model.doy, n);
}

return swp;
}
Ejemplo n.º 22
0
static Bool _read_hist( TimeInt year) {
/* =================================================== */
/* Read the historical (measured) weather files.
* Format is
* day-of-month, month number, year, doy, mintemp, maxtemp, ppt
*
* I dislike the inclusion of the first three columns
* but this is the old format.  If a new format emerges
* these columns will likely be removed.
*
* temps are in degrees C, ppt is in cm,
*
* 26-Jan-02 - changed format of the input weather files.
*
*/

	SW_WEATHER_HIST *wh = &SW_Weather.hist;
	FILE *f;
	int x, lineno=0, k = 0, i, j;
	RealF tmpmax, tmpmin, ppt, acc = 0.0;
	TimeInt doy;
	
	char fname[MAX_FILENAMESIZE];
	
	
	sprintf(fname, "%s.%4d", SW_Weather.name_prefix, year);

	if ( NULL == (f = fopen(fname, "r")) )
		return FALSE;
	
	_clear_hist_weather();
	
	
	while( GetALine(f, inbuf) ) {
		lineno++;
		x=sscanf( inbuf, "%d %f %f %f", &doy, &tmpmax, &tmpmin, &ppt);
		if (x < 4) {
			LogError(logfp, LOGFATAL, "%s : Incomplete record %d (doy=%d).", fname, lineno, doy);
		}
		if (x > 4) {
			LogError(logfp, LOGFATAL, "%s : Too many values in record %d (doy=%d).", fname, lineno, doy);
		}
		if (doy < 1 || doy > MAX_DAYS) {
			LogError(logfp, LOGFATAL, "%s : Day of year out of range, line %d.", fname, lineno);
		}
	
	
		/* --- Make the assignments ---- */
		doy--;
		wh->temp_max[doy] = tmpmax;
		wh->temp_min[doy] = tmpmin;
		wh->temp_avg[doy] = (tmpmax + tmpmin) / 2.0;
		wh->ppt[doy]      = ppt;
		
		/* Reassign if invalid values are found.  The values are
		* either valid or WTH_MISSING.  If they were not
		* present in the file, we wouldn't get this far because
		* sscanf() would return too few items.
		*/
		if ( missing(tmpmax) ) {
			wh->temp_max[doy] = WTH_MISSING;
			LogError(logfp, LOGWARN, "%s : Missing max temp on doy=%d.", fname, doy+1);
		}
		if ( missing(tmpmin) ) {
			wh->temp_min[doy] = WTH_MISSING;
			LogError(logfp, LOGWARN, "%s : Missing min temp on doy=%d.", fname, doy+1);
		}
		if ( missing(ppt) ) {
			wh->ppt[doy] = 0.;
			LogError(logfp, LOGWARN, "%s : Missing PPT on doy=%d.", fname, doy+1);
		}
		
		if(!missing(tmpmax) && !missing(tmpmin)) {
			k++;
			acc += wh->temp_avg[doy];
		}
	}  /* end of input lines */
	
	wh->temp_year_avg = acc / (k + 0.0);
	
	x = 0;
	for( i=0; i < MAX_MONTHS; i++) {
		k = 31;
		if(i == 8 || i == 3 || i == 5 || i == 10)
			k = 30; // september, april, june, & november all have 30 days...
		else if(i == 1) {
			k = 28; // february has 28 days, except if it's a leap year, in which case it has 29 days...
			if(isleapyear(year))
				k = 29; 
		}
		
		acc = 0.0;
		for( j=0; j < k; j++)
			acc += wh->temp_avg[j + x];
		wh->temp_month_avg[i] = acc / (k + 0.0);
		x += k;
	}
	
	fclose(f);
	
	return TRUE;
}
Ejemplo n.º 23
0
static int read_nist_nls_data (const char *fname)
{
    FILE *fp;
    char line[128];
    int err = 0;
    int got_name = 0;
    int got_model = 0;
    int got_data = -1;

    fp = fopen(fname, "r");
    if (fp == NULL) {
	fprintf(stderr, "Couldn't open %s\n", fname);
	return 1;
    }

    tester_init();

    while (fgets(line, sizeof line, fp) && !err) {
	tail_strip(line);
	if (strstr(line, "Dataset Name:")) {
	    err = get_id(line + 13);
	    if (!err) got_name = 1;
	} else if (strstr(line, "Number of Observations:")) {
	    if (sscanf(line + 24, "%d", &tester.nobs) != 1) {
		err = 1;
	    } else {
		if (tester.nobs > 0) {
		    datainfo = create_new_dataset(&Z, tester.nvars + 1, 
						  tester.nobs, 0);
		    if (datainfo == NULL) err = 1;
		} else {
		    err = 1;
		}
	    }
	} else if (strncmp(line, "Model:", 6) == 0) {
	    err = read_model_lines(line, fp);
	    if (!err) got_model = 1;
	} else if (strstr(line, "Starting") && strstr(line, "Certified")) {
	    err = read_params(fp);
	} else if (strncmp(line, "Data:", 5) == 0) {
	    if (got_data < 0) {
		got_data = 0;
	    } else {
		err = read_data(fp);
		if (!err) got_data = 1;
	    }
	} else if (strstr(line, "Predictor")) {
	    err = get_nvars(line);
	} else if (strstr(line, "evel of Diffic")) {
	    print_grade(line);
	}
    }

    if (!got_name) {
	missing("dataset identifier");
    }
    if (!got_model) {
	missing("model specification");
    }
    if (tester.nparam == 0) {
	missing("parameter values");
    }

    if (got_data <= 0) {
	missing("input data");
    } else if (tester.nobs == 0) {
	missing("number of observations");
    }

    fclose(fp);

    return err;
}
Ejemplo n.º 24
0
Archivo: chk.c Proyecto: 99years/plan9
void
check(Filsys *fs, long flag)
{
	Iobuf *p;
	Superb *sb;
	Dentry *d;
	long raddr;
	long nqid;

	wlock(&mainlock);
	dev = fs->dev;
	flags = flag;
	fence = fencebase;

	sizname = 4000;
	name = zalloc(sizname);
	sizname -= NAMELEN+10;	/* for safety */

	sbaddr = superaddr(dev);
	raddr = getraddr(dev);
	p = xtag(sbaddr, Tsuper, QPSUPER);
	if(!p){
		cprint("bad superblock\n");
		goto out;
	}
	sb = (Superb*)p->iobuf;
	fstart = 1;

	fsize = sb->fsize;
	sizabits = (fsize-fstart + 7)/8;
	abits = zalloc(sizabits);

	nqid = sb->qidgen+100;		/* not as much of a botch */
	if(nqid > 1024*1024*8)
		nqid = 1024*1024*8;
	if(nqid < 64*1024)
		nqid = 64*1024;

	sizqbits = (nqid+7)/8;
	qbits = zalloc(sizqbits);

	mod = 0;
	nfree = 0;
	nfdup = 0;
	nused = 0;
	nbad = 0;
	ndup = 0;
	nqbad = 0;
	depth = 0;
	maxdepth = 0;

	if(flags & Ctouch) {
		oldblock = fsize/DSIZE;
		oldblock *= DSIZE;
		if(oldblock < 0)
			oldblock = 0;
		cprint("oldblock = %ld\n", oldblock);
	}
	if(amark(sbaddr))
		{}
	if(cwflag) {
		if(amark(sb->roraddr))
			{}
		if(amark(sb->next))
			{}
	}

	if(!(flags & Cquiet))
		cprint("checking file system: %s\n", fs->name);
	nfiles = 0;
	maxq = 0;

	d = maked(raddr, 0, QPROOT);
	if(d) {
		if(amark(raddr))
			{}
		if(fsck(d))
			modd(raddr, 0, d);
		depth--;
		fence -= sizeof(Dentry);
		if(depth)
			cprint("depth not zero on return\n");
	}

	if(flags & Cfree) {
		mkfreelist(sb);
		sb->qidgen = maxq;
		settag(p, Tsuper, QPNONE);
	}

	if(sb->qidgen < maxq)
		cprint("qid generator low path=%ld maxq=%ld\n",
			sb->qidgen, maxq);
	if(!(flags & Cfree))
		ckfreelist(sb);
	if(mod) {
		cprint("file system was modified\n");
		settag(p, Tsuper, QPNONE);
	}

	if(!(flags & Cquiet)){
		cprint("%8ld files\n", nfiles);
		cprint("%8ld blocks in the file system\n", fsize-fstart);
		cprint("%8ld used blocks\n", nused);
		cprint("%8ld free blocks\n", sb->tfree);
	}
	if(!(flags & Cfree)){
		if(nfree != sb->tfree)
			cprint("%8ld free blocks found\n", nfree);
		if(nfdup)
			cprint("%8ld blocks duplicated in the free list\n", nfdup);
		if(fsize-fstart-nused-nfree)
			cprint("%8ld missing blocks\n", fsize-fstart-nused-nfree);
	}
	if(ndup)
		cprint("%8ld address duplications\n", ndup);
	if(nbad)
		cprint("%8ld bad block addresses\n", nbad);
	if(nqbad)
		cprint("%8ld bad qids\n", nqbad);
	if(!(flags & Cquiet))
		cprint("%8ld maximum qid path\n", maxq);
	missing();

out:
	if(p)
		putbuf(p);
	free(abits);
	free(name);
	free(qbits);
	wunlock(&mainlock);
}
Ejemplo n.º 25
0
void
ReliableSession::send_naks()
{
  // Could get data samples before syn control message.
  // No use nak'ing until syn control message is received and session is acked.
  if (!this->acked_) return;

  if (DCPS_debug_level > 0) {
    ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) ReliableSession::send_naks local %d ")
                          ACE_TEXT ("remote %d nak request size %d \n"),
      this->link_->local_peer(), this->remote_peer_, this->nak_requests_.size()));
  }

  if (!this->nak_sequence_.disjoint()) return;  // nothing to send

  ACE_Time_Value now(ACE_OS::gettimeofday());

  // Record high-water mark for this interval; this value will
  // be used to reset the low-water mark in the event the remote
  // peer becomes unresponsive:
  this->nak_requests_.insert(
    NakRequestMap::value_type(now, this->nak_sequence_.high()));

  typedef std::vector<std::pair<SequenceNumber, SequenceNumber> > RangeVector;
  RangeVector ignored;

  /// The range first - second will be skiped (no naks sent for it).
  SequenceNumber first;
  SequenceNumber second;

  NakRequestMap::reverse_iterator itr(this->nak_requests_.rbegin());

  if (this->nak_requests_.size() > 1) {
    // The sequences between rbegin - 1 and rbegin will not be ignored for naking.
    ++itr;

    size_t nak_delay_intervals = this->link()->config()->nak_delay_intervals_;
    size_t nak_max = this->link()->config()->nak_max_;
    size_t sz = this->nak_requests_.size ();

    // Image i is the index of element in nak_requests_ in reverse order.
    // index 0 sequence is most recent high water mark.
    // e.g index , 20, 19, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0
    //  0 (rbegin) is always skipped because missing sample between 1 and 0 interval
    //  should always be naked.,
    //  if nak_delay_intervals=4, nak_max=3, any sequence between 5 - 1, 10 - 6, 15 - 11
    //  are skipped for naking due to nak_delay_intervals and 20 - 16 are skipped for
    //  naking due to nak_max.
    for (size_t i = 1; i < sz; ++i) {
      if ((i * 1.0) / (nak_delay_intervals + 1) > nak_max) {
        if (first != SequenceNumber()) {
          first = this->nak_requests_.begin ()->second;
        }
        else {
          ignored.push_back (std::make_pair(this->nak_requests_.begin ()->second, itr->second));
        }
        break;
      }

      if (i % (nak_delay_intervals + 1) == 1) {
        second = itr->second;
      }
      if (second != SequenceNumber()) {
        first = itr->second;
      }

      if (i % (nak_delay_intervals + 1) == 0) {
        first = itr->second;

        if (first != SequenceNumber() && second != SequenceNumber()) {
          ignored.push_back (std::make_pair(first, second));
          first = SequenceNumber();
          second == SequenceNumber();
        }
      }

      ++itr;
    }

    if (first != SequenceNumber() && second != SequenceNumber() && first != second) {
      ignored.push_back (std::make_pair(first, second));
    }
  }

  // Take a copy to facilitate temporary suppression:
  DisjointSequence missing(this->nak_sequence_);
  if (DCPS_debug_level > 0) {
    missing.dump ();
  }

  size_t sz = ignored.size ();
  for (size_t i = 0; i < sz; ++i) {

    if (ignored[i].second > missing.low ()) {
      SequenceNumber high = ignored[i].second;
      SequenceNumber low = ignored[i].first;
      if (low < missing.low ()) {
        low = missing.low ();
      }

      if (DCPS_debug_level > 0) {
        ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) ReliableSession::send_naks local %d ")
          ACE_TEXT ("remote %d ignore missing %d - %d \n"),
          this->link_->local_peer(), this->remote_peer_, low.getValue(), high.getValue()));
      }

      // Make contiguous between ignored sequences.
      for (SequenceNumber i = low + 1; i < high; ++i) {
        missing.update(i);
      }
    }
  }

  for (NakPeerSet::iterator it(this->nak_peers_.begin());
       it != this->nak_peers_.end(); ++it) {
    // Update sequence to temporarily suppress repair requests for
    // ranges already requested by other peers for this interval:
    missing.update(*it);
  }

  if (missing.disjoint()) {
    send_naks (missing);
  }

  // Clear peer repair requests:
  this->nak_peers_.clear();
}