FACT++  1.0
bool RescheduleIntermediateSources ( vector< Source > &  obs)

Definition at line 367 of file makeschedule.cc.

References begin, end, and i.

Referenced by main().

368 {
369  for (size_t i=1; i<obs.size()-1; i++)
370  {
371  if (obs[i].duration()>=40./24/60)
372  continue;
373 
374  if (obs[i-1].name=="SLEEP" && obs[i+1].name=="SLEEP")
375  continue;
376 
377  cout << "Intermediate source [" << obs[i].name << "] detected < 40min" << endl;
378 
379  double intersection = -1;
380 
381  if (obs[i-1].name=="SLEEP")
382  intersection = obs[i].begin;
383 
384  if (obs[i+1].name=="SLEEP")
385  intersection = obs[i].end;
386 
387  if (obs[i-1].name==obs[i+1].name)
388  intersection = obs[i].begin;
389 
390  if (intersection<0)
391  {
392  const uint32_t n = nearbyint((obs[i].end-obs[i].begin)*24*60);
393  for (uint32_t ii=0; ii<n; ii++)
394  {
395  const double jd = obs[i].begin+ii/24./60.;
396 
397  const SolarObjects so(jd);
398  if (obs[i-1].getThreshold(so)>=obs[i+1].getThreshold(so))
399  {
400  intersection = jd;
401  break;
402  }
403  }
404  }
405 
406  if ((obs[i-1].name!="SLEEP" && !obs[i-1].IsRangeValid(obs[i-1].end, intersection)) ||
407  (obs[i+1].name!="SLEEP" && !obs[i+1].IsRangeValid(intersection, obs[i+1].begin)))
408  {
409  cout << "No reschedule possible within limits." << endl;
410  continue;
411  }
412 
413  cout << "Intermediate source [" << obs[i].name << "] removed" << endl;
414 
415  const bool underflow = obs[i-1].duration()*24*60<40 || obs[i+1].duration()*24*60<40;
416 
417  obs[i-1].end = intersection;
418  obs[i+1].begin = intersection;
419  obs.erase(obs.begin()+i);
420 
421  i--;
422 
423  if (obs.size()>1 && obs[i].name==obs[i+1].name)
424  {
425  obs[i].end = obs[i+1].end;
426  obs.erase(obs.begin()+i+1);
427 
428  cout << "Combined two surrounding indentical sources [" << obs[i].name << "] into one observation" << endl;
429 
430  i--;
431 
432  continue;
433  }
434 
435  if (underflow)
436  cout << "WARNING - Neighbor source < 40min as well." << endl;
437  }
438  return false;
439 }
int i
Definition: db_dim_client.c:21
double begin
double end

+ Here is the caller graph for this function: