Changeset 17319


Ignore:
Timestamp:
11/14/13 16:44:58 (11 years ago)
Author:
tbretz
Message:
Added some crosschecks for the switching of the night after an recent incident. This should never be necessary but it doesn't harm either, and the reason for the incident is still unknown.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/EventBuilderWrapper.h

    r17300 r17319  
    129129        const uint32_t night = now.NightAsInt();
    130130        if (night==fNightAsInt)
     131            return true;
     132
     133        const string crosscheck = now.GetPrevSunRise().GetAsStr("%Y%m%d");
     134        if (crosscheck!=to_string(night))
     135        {
     136            fMsg.Warn("The crosscheck for the night failed. "+crosscheck+" is not equal to "+to_string(night)+"... keeping old one.");
     137            fMsg.Warn("This is a severe error. Please restart fadctrl.");
     138            return true;
     139        }
     140
     141        // In some circumstances, I do not understand yet (but I guess it can happen
     142        // when the shared objects are re-compiled while the program is not
     143        // re-started), it can happen that the returned value is wrong by one day.
     144        // So this is just another check to avoid problems.
     145        const uint32_t night_test = Time(now-boost::posix_time::seconds(1)).NightAsInt();
     146        if (night_test != night)
     147            return true;
     148
     149        // And another check. Let's read the clock again.
     150        // In both cases a false condition is no error and can happen. But if it happens,
     151        // the bahaviour will change a fraction of a second later and the conditon
     152        // will be true. No run should be taken just around that moment and if one
     153        // is taken, then the date doesn't matter.
     154        if (Time().NightAsInt() != night)
    131155            return true;
    132156
Note: See TracChangeset for help on using the changeset viewer.