Index: trunk/FACT++/src/scheduler.cc
===================================================================
--- trunk/FACT++/src/scheduler.cc	(revision 19530)
+++ trunk/FACT++/src/scheduler.cc	(revision 19555)
@@ -22,42 +22,30 @@
 // -----------------------------------------------------------------------
 
-/*
-void SetupConfiguration(Configuration &conf);
+enum VisibilityCriterion
 {
-    po::options_description control("Makeschedule");
-    control.add_options()
-        ("uri", var<string>(), "Database link as in\n\tuser:password@server[:port]/database[?compress=0|1].")
-        ;
-
-    // po::positional_options_description p;
-    // p.add("date", 1); // The first positional options
-
-    conf.AddOptions(control);
-    //conf.SetArgumentPositions(p);
-}
-
-void PrintUsage();
+    kMoonMin,
+    kMoonMax,
+    kSunMax,
+    kZenithMax,
+    kCurrentMax,
+    kThresholdMax,
+};
+
+struct VisibilityConditions : map<VisibilityCriterion, float>
 {
-    cout <<
-        "makeschedule - Creates an automatic schedule\n"
-        "\n"
-        "Usage: makeschedule [yyyy-mm-dd]\n";
-    cout << endl;
-}
-
-void PrintHelp();
-{
-    cout << endl;
-}*/
+    VisibilityConditions()
+    {
+        operator[](kMoonMin)      =  10;
+        operator[](kMoonMax)      = 170;
+        operator[](kSunMax)       = -12;
+        operator[](kZenithMax)    =  75;
+        operator[](kCurrentMax)   = 110;
+        operator[](kThresholdMax) =  10;
+    }
+};
 
 struct CheckVisibility
 {
-    // Input
-    float moon_min      =  10;
-    float moon_max      = 170;
-    float sun_max       = -12;
-    float zd_max        =  75;
-    float current_max   = 110;
-    float threshold_max =  10;
+    VisibilityConditions conditions;
 
     // Output
@@ -85,5 +73,5 @@
         moon_dist = Nova::GetAngularSeparation(equ, solarobj.fMoonEqu);
         vis_sun   = Nova::GetSolarRst(jd, -12);
-        vis_obj   = Nova::GetObjectRst(equ, jd, zd_max);
+        vis_obj   = Nova::GetObjectRst(equ, jd, conditions[kZenithMax]);
 
         current   = FACT::PredictI(solarobj, equ);
@@ -93,24 +81,24 @@
         threshold = position.zd<90 ? ratio*pow(current/6.2, 0.394) : -1;
 
-        valid_moon      = moon_dist>moon_min && moon_dist<moon_max;
-        valid_zd        = position.zd<zd_max;
-        valid_sun       = solarobj.fSunHrz.alt<sun_max;
-        valid_current   = current<current_max;
-        valid_threshold = threshold>0 && threshold<threshold_max;
+        valid_moon      = moon_dist>conditions[kMoonMin] && moon_dist<conditions[kMoonMax];
+        valid_zd        = position.zd<conditions[kZenithMax];
+        valid_sun       = solarobj.fSunHrz.alt<conditions[kSunMax];
+        valid_current   = current<conditions[kCurrentMax];
+        valid_threshold = threshold>0 && threshold<conditions[kThresholdMax];
 
         visible = valid_moon && valid_zd && valid_sun && valid_current;
     }
 
-    CheckVisibility(const Nova::EquPosn &equ, const double &jd)
+    CheckVisibility(const VisibilityConditions &cond, const Nova::EquPosn &equ, const double &jd) : conditions(cond)
     {
         calc(equ, jd);
     }
 
-    CheckVisibility(const Nova::EquPosn &equ)
+    CheckVisibility(const VisibilityConditions &cond, const Nova::EquPosn &equ) : conditions(cond)
     {
         calc(equ, Time().JD());
     }
 
-    CheckVisibility(const double &ra, const double &dec, const double &jd)
+    CheckVisibility(const VisibilityConditions &cond, const double &ra, const double &dec, const double &jd): conditions(cond)
     {
         Nova::EquPosn equ;
@@ -120,5 +108,5 @@
     }
 
-    CheckVisibility(const double &ra, const double &dec)
+    CheckVisibility(const VisibilityConditions &cond, const double &ra, const double &dec) : conditions(cond)
     {
         Nova::EquPosn equ;
@@ -423,4 +411,6 @@
 {
 private:
+    map<uint16_t, VisibilityConditions> fVisibilityCriteria;
+
     string   fUri;
     Database fConnection;
@@ -684,7 +674,9 @@
             const bool prio = prioritized_sources.find(source.key)!=prioritized_sources.end();
 
-            if ((check.threshold>3 && !prio) || check.threshold>10)
+            // Special check for the threshold. Threshold condition atm only
+            // applies for pointings and is different for prioritized sources
+            if ((check.threshold>3 && !prio) || !check.valid_threshold)
             {
-                Warn("Relative threshold too high... skipping.");
+                Warn(Tools::Form("Relative threshold [%6.2f] too high... skipping.", check.threshold));
                 return false;
             }
@@ -1101,17 +1093,20 @@
 
         ostringstream out;
-        out << name << " [" << paket.name << ":" << grb.type << "]: RA=" << grb.ra/15. << "h DEC=" << grb.dec << "\u00b0 ERR=" << grb.err;
+        out << name << " [" << paket.name << ":" << grb.type << "]: RA=" << grb.ra/15. << "h DEC=" << grb.dec << "\u00b0 ERR=" << grb.err << "\u00b0";
 
         Info(out);
         Info(paket.description);
 
-        const CheckVisibility check(grb.ra, grb.dec);
-
-        Info(string("Sun altitude:   ")+(check.valid_sun      ?"OK    ":"failed")+" ["+Tools::Form("%5.1f", check.solarobj.fSunHrz.alt)+"\u00b0]");
+        // The []-operator automatically creates a default entry if not yet existing
+        auto &conditions = fVisibilityCriteria[grb.type];
+
+        const CheckVisibility check(conditions, grb.ra, grb.dec);
+
+        Info("Sun altitude:  "+Tools::Form("%5.1f\u00b0 ", check.solarobj.fSunHrz.alt)+(check.valid_sun?"OK    ":"failed")+Tools::Form(" [alt < %5.1f\u00b0]", conditions[kSunMax]));
         if (check.valid_sun)
         {
-            Info(string("Moon distance:  ")+(check.valid_moon     ?"OK    ":"failed")+" ["+Tools::Form("%5.1f", check.moon_dist)+"\u00b0]");
-            Info(string("Zenith angle:   ")+(check.valid_zd       ?"OK    ":"failed")+" ["+Tools::Form("%5.1f", check.position.zd)+"\u00b0]");
-            Info(string("Current:        ")+(check.valid_current  ?"OK    ":"failed")+" ["+Tools::Form("%5.1f", check.current)+" \u00b5A]");
+            Info("Moon distance: "+Tools::Form("%5.1f\u00b0 ", check.moon_dist)  +(check.valid_moon   ?"OK    ":"failed")+Tools::Form(" [%5.1f\u00b0 < d < %5.1f\u00b0]", conditions[kMoonMin], conditions[kMoonMax]));
+            Info("Zenith angle:  "+Tools::Form("%5.1f\u00b0 ", check.position.zd)+(check.valid_zd     ?"OK    ":"failed")+Tools::Form(" [zd < %5.1f\u00b0]", conditions[kZenithMax]));
+            Info("Current:       "+Tools::Form("%5.1f\u00b5A", check.current)    +(check.valid_current?"OK    ":"failed")+Tools::Form(" [I < %5.1f\u00b5A]", conditions[kCurrentMax]));
             //Info(string("Rel. threshold: ")+(check.valid_threshold?"OK    ":"failed")+" ["+Tools::Form("%5.1f", check.threshold)+"]");
         }
@@ -1331,4 +1326,11 @@
     }*/
 
+    void AddCriteria(const vector<uint16_t> &ids, const VisibilityCriterion &crit, const float &limit)
+    {
+        // The []-operator automatically creates a default entry if not yet existing
+        for (auto id=ids.begin(); id!=ids.end(); id++)
+            fVisibilityCriteria[*id][crit] = limit;
+    }
+
     int EvalOptions(Configuration &conf)
     {
@@ -1336,4 +1338,13 @@
         fKeepAliveInterval = conf.Get<uint16_t>("keep-alive");
         fUri = conf.Get<string>("schedule-database");
+
+        const vector<uint16_t> GRBs =
+        {
+            60, 61, 62, 97, 110, 111, 112, 115, 53, 54, 55, 56, 100, 101, 102
+        };
+
+        AddCriteria(GRBs, kCurrentMax, 30);
+        AddCriteria(GRBs, kZenithMax,  45);
+
         return -1;
     }
