Ignore:
Timestamp:
05/25/19 13:58:12 (5 years ago)
Author:
tbretz
Message:
Instead of having a dry-run option, the scheduler can now be enabled/disabled from its command interface via START/STOP flagged by a new state 'Armed', added calculation of the relative threshold, separated calculation of source position and wobble position from calculation of schedule, only calculate the wobble position if there is a need, implemented a known_only flag which allows only for observation of already known sources, for convenience, list all gamma-ray sources within the field-of-view. Entries into the database are now enabled. The INTERRUPT send for preparation is now flagged as 'prepare' to allow Main.js to STOP the current pointing and wait for it before RELOAD_SOURCES is issued.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/FACT++/src/scheduler.cc

    r19479 r19508  
    5454{
    5555    // Input
    56     float moon_min     =  10;
    57     float moon_max     = 170;
    58     float sun_max      = -12;
    59     float zd_max       =  75;
    60     float current_max  = 110;
     56    float moon_min      =  10;
     57    float moon_max      = 170;
     58    float sun_max       = -12;
     59    float zd_max        =  75;
     60    float current_max   = 110;
     61    float threshold_max =  10;
    6162
    6263    // Output
     
    6667    double moon_dist   = -1;
    6768    double current     = -1;
    68 
    69     bool valid_zd      = false;
    70     bool valid_current = false;
    71     bool valid_sun     = false;
    72     bool valid_moon    = false;
     69    double threshold   = -1;
     70
     71    bool valid_zd        = false;
     72    bool valid_current   = false;
     73    bool valid_sun       = false;
     74    bool valid_moon      = false;
     75    bool valid_threshold = false;
    7376
    7477    bool visible       = false;
     
    8285        current   = FACT::PredictI(solarobj, equ);
    8386
    84         valid_moon    = moon_dist>moon_min && moon_dist<moon_max;
    85         valid_zd      = position.zd<zd_max;
    86         valid_sun     = solarobj.fSunHrz.alt<sun_max;
    87         valid_current = current<current_max;
     87        const double ratio = pow(cos(position.zd*M_PI/180), -2.664);
     88
     89        threshold = position.zd<90 ? ratio*pow(current/6.2, 0.394) : -1;
     90
     91        valid_moon      = moon_dist>moon_min && moon_dist<moon_max;
     92        valid_zd        = position.zd<zd_max;
     93        valid_sun       = solarobj.fSunHrz.alt<sun_max;
     94        valid_current   = current<current_max;
     95        valid_threshold = threshold>0 && threshold<threshold_max;
    8896
    8997        visible = valid_moon && valid_zd && valid_sun && valid_current;
     
    414422    Database fConnection;
    415423    uint16_t fVerbose;
    416     bool     fDryRun;
    417424
    418425    Time     fKeepAliveDeadline;
    419426    uint16_t fKeepAliveInterval;
    420427
    421     bool ScheduleImp(const string &name, const double &ra, const double &dec)
    422     {
    423         fDryRun = true;
     428    int16_t GetSourceKey(const string &name, const double &ra, const double &dec)
     429    {
     430        const double min_dist   = 0.1;
     431        const double check_dist = 2.0;
     432
     433
     434        int32_t source_key = -1;
     435
     436        const string query1 =
     437            "SELECT fSourceKey, fSourceName, ADIST(fDeclination, fRightAscension*15, "+to_string(dec)+", "+to_string(ra)+") AS Dist\n"
     438            " FROM Source\n"
     439            " WHERE fSourceTypeKEY=1\n"
     440            " HAVING Dist<"+to_string(check_dist)+"\n"
     441            " ORDER BY Dist ASC";
     442
     443        const mysqlpp::StoreQueryResult res1 = fConnection.query(query1).store();
     444
     445        if (res1.num_rows())
     446        {
     447            Info("Found "+to_string(res1.num_rows())+" sources with a distance less than "+to_string(check_dist)+"\u00b0");
     448
     449            for (size_t i=0; i<res1.num_rows(); i++)
     450            {
     451                const mysqlpp::Row &row = res1[i];
     452                Info(" "+string(row["fSourceName"])+" ["+string(row["fSourceKey"])+"]: D="+string(row["Dist"])+"\u00b0");
     453            }
     454
     455            const mysqlpp::Row &row = res1[0];
     456            if (double(row["Dist"])<min_dist)
     457            {
     458                Warn("Sources closer than "+to_string(check_dist)+"\u00b0 detected.");
     459                Warn("Overwriting source key with: "+string(row["fSourceName"])+" ["+string(row["fSourceKey"])+"]: D="+string(row["Dist"])+"\u00b0");
     460                source_key = res1[0]["fSourceKey"];
     461            }
     462        }
     463
     464        //Out() << Time()-stopwatch << endl;
     465
     466        const string query2 =
     467            "SELECT fSourceKey FROM Source WHERE fSourceName='"+name+"'";
     468
     469        const mysqlpp::StoreQueryResult res2 = fConnection.query(query2).store();
     470
     471        if (res2.num_rows())
     472        {
     473            source_key = res2[0]["fSourceKey"];
     474            Info("A source with the same name (key="+to_string(source_key)+") was found in the Source table.");
     475        }
     476
     477        return source_key;
     478    }
     479
     480    float GetWobbleAngle(const double &ra, const double &dec)
     481    {
     482        const double wobble_offset = 0.6;
     483        const double camera_radius = 2.3;
     484        const double magnitude_max = 4.5;
     485
     486        /*
     487         Mag Cnt
     488         -2  1
     489         -1  3
     490          0  11
     491          1  33
     492          2  121
     493          3  321
     494          4  871
     495          5  1364
     496          6  404
     497          7  12
     498        */
     499
     500        // The wobble position lay in the plane which is normal the to the plane source-center-star
     501        // and goes through
     502
     503        double wobble_angle  = 0;
     504
     505        const string query0 =
     506            "SELECT fSourceKEY, fRightAscension, fDeclination, fMagnitude,\n"
     507            " ADIST(fDeclination, fRightAscension*15, "+to_string(dec)+", "+to_string(ra)+") AS Dist\n"
     508            " FROM Source\n"
     509            " WHERE (fSourceTypeKey=2 OR fSourceTypeKey=3) AND fMagnitude<"+to_string(magnitude_max)+"\n"
     510            " HAVING Dist<"+to_string(camera_radius+wobble_offset)+"\n"
     511            " ORDER BY fMagnitude ASC";
     512
     513        Out() << query0 << endl;
     514
     515        const mysqlpp::StoreQueryResult res0 = fConnection.query(query0).store();
     516
     517        Info("Found "+to_string(res0.num_rows())+" stars in the camera field-of-view with magnitude less than "+to_string(magnitude_max));
     518
     519        for (size_t i=0; i<::min<size_t>(10, res0.num_rows()); i++)
     520        {
     521            const mysqlpp::Row &row = res0[i];
     522
     523            // TVector3 souce, star;
     524            // source.SetMagThetaPhi(1, rad(90-dec), rad(ra));
     525            // star.SetMagThetaPhi(  1, rad(90-dec), rad(ra));
     526            //
     527            // star.RotateZ(  -source.Phi());
     528            // source.RotateZ(-source.Phi());
     529            //
     530            // star.RotateY(  180-source.Theta());
     531            // source.RotateY(180-source.Theta());
     532            //
     533            // rho = star.Phi();
     534
     535            const double rad = M_PI/180;
     536
     537            const double dec0 = rad * dec;
     538            const double ra0  = rad * ra;
     539
     540            const double dec1 = rad * row["fDeclination"];
     541            const double ra1  = rad * row["fRightAscension"] * 15;
     542
     543            const double s2 = sin(ra0-ra1);
     544            const double c2 = cos(ra0-ra1);
     545
     546            const double s0 = cos(dec0);
     547            const double c0 = sin(dec0);
     548
     549            const double c1 = cos(dec1);
     550            const double s1 = sin(dec1);
     551
     552            const double k0 =           -s2*c1;
     553            const double k1 = s0*s1 - c0*c2*c1;
     554
     555            const double rho = atan(k0/k1) / rad; // atan2(k0, k1)/rad
     556
     557            if (i==0)
     558                wobble_angle = rho;
     559
     560            Info(" "+Tools::Form("Mag=%5.2f  Dist=%5.1f  Phi=%6.1f", (double)row["fMagnitude"], (double)row["Dist"], rho));
     561        }
     562
     563        if (res0.num_rows())
     564        {
     565            Info("The brightest star (M="+string(res0[0]["fMagnitude"])+") at distance is visible at a wobble angle of "+Tools::Form("%.2f", wobble_angle)+"\u00b0");
     566            Info("Wobble angles determined as "+Tools::Form("%.2f", wobble_angle-90)+"\u00b0 and "+Tools::Form("%.2f", wobble_angle+90)+"\u000b");
     567        }
     568        else
     569        {
     570            Info("Using default wobble angles.");
     571        }
     572
     573        return wobble_angle;
     574    }
     575
     576
     577    bool ScheduleImp(const string &name, const double &ra, const double &dec, const bool &known_only)
     578    {
     579        const bool fDryRun = GetCurrentState()!=ToO::State::kArmed;
     580
     581        if (fDryRun)
     582            Warn("Scheduler not armed!");
    424583
    425584        Time stopwatch;
     
    449608         */
    450609
    451         const double min_dist = 0.1;
    452         const double wobble_offset = 0.6;
    453         const double camera_radius = 2.3;
    454         const double magnitude_max = 4.5;
    455 
    456         double wobble_angle  = 0;
    457 
    458         /*
    459          Mag Cnt
    460          -2  1
    461          -1  3
    462           0  11
    463           1  33
    464           2  121
    465           3  321
    466           4  871
    467           5  1364
    468           6  404
    469           7  12
    470         */
    471 
    472         // The wobble position lay in the plane whihc is normal the to the plane source-center-star
    473         // and goes through
    474 
    475         const string query0 =
    476             "SELECT fSourceKEY, fRightAscension, fDeclination, fMagnitude,\n"
    477             " ADIST(fDeclination, fRightAscension*15, "+to_string(dec)+", "+to_string(ra)+") AS Dist\n"
    478             " FROM Source\n"
    479             " WHERE (fSourceTypeKey=2 OR fSourceTypeKey=3) AND fMagnitude<"+to_string(magnitude_max)+"\n"
    480             " HAVING Dist<"+to_string(camera_radius+wobble_offset)+"\n"
    481             " ORDER BY fMagnitude ASC";
    482 
    483         Out() << query0 << endl;
    484 
    485         const mysqlpp::StoreQueryResult res0 = fConnection.query(query0).store();
     610        int32_t source_key = GetSourceKey(name, ra, dec);
    486611
    487612        Out() << Time()-stopwatch << endl;
    488613
    489         Info("Found "+to_string(res0.num_rows())+" stars in the camera field-of-view with magnitude less than "+to_string(magnitude_max));
    490 
    491         for (size_t i=0; i<::min<size_t>(10, res0.num_rows()); i++)
    492         {
    493             const mysqlpp::Row &row = res0[i];
    494 
    495             // TVector3 souce, star;
    496             // source.SetMagThetaPhi(1, rad(90-dec), rad(ra));
    497             // star.SetMagThetaPhi(  1, rad(90-dec), rad(ra));
    498             //
    499             // star.RotateZ(  -source.Phi());
    500             // source.RotateZ(-source.Phi());
    501             //
    502             // star.RotateY(  180-source.Theta());
    503             // source.RotateY(180-source.Theta());
    504             //
    505             // rho = star.Phi();
    506 
    507             const double rad = M_PI/180;
    508 
    509             const double dec0 = rad * dec;
    510             const double ra0  = rad * ra;
    511 
    512             const double dec1 = rad * row["fDeclination"];
    513             const double ra1  = rad * row["fRightAscension"] * 15;
    514 
    515             const double s2 = sin(ra0-ra1);
    516             const double c2 = cos(ra0-ra1);
    517 
    518             const double s0 = cos(dec0);
    519             const double c0 = sin(dec0);
    520 
    521             const double c1 = cos(dec1);
    522             const double s1 = sin(dec1);
    523 
    524             const double k0 =           -s2*c1;
    525             const double k1 = s0*s1 - c0*c2*c1;
    526 
    527             const double rho = atan(k0/k1) / rad; // atan2(k0, k1)/rad
    528 
    529             if (i==0)
    530                 wobble_angle = rho;
    531 
    532             Info(" "+Tools::Form("Mag=%5.2f  Dist=%5.1f  Phi=%6.1f", (double)row["fMagnitude"], (double)row["Dist"], rho));
    533         }
    534 
    535         if (res0.num_rows())
    536         {
    537             Info("The brightest star (M="+string(res0[0]["fMagnitude"])+") at distance is visible at a wobble angle of "+Tools::Form("%.2f", wobble_angle)+"\u00b0");
    538             Info("Wobble angles determined as "+Tools::Form("%.2f", wobble_angle-90)+"\u00b0 and "+Tools::Form("%.2f", wobble_angle+90)+"\u000b");
    539         }
    540         else
    541         {
    542             Info("Using default wobble angles.");
    543         }
    544 
    545         const string query1 =
    546             "SELECT fSourceKey, fSourceName\n"
    547             " FROM Source\n"
    548             " WHERE ADIST(fDeclination, fRightAscension*15, "+to_string(dec)+", "+to_string(ra)+")<"+to_string(min_dist)+"\n"
    549             " ORDER BY fSourceKey ASC";
    550 
    551         const mysqlpp::StoreQueryResult res1 = fConnection.query(query1).store();
    552 
    553         if (res1.num_rows())
    554         {
    555             Warn("The following sources in the source table have a distance less than "+to_string(min_dist)+"\u00b0");
    556 
    557             for (size_t i=0; i<res1.num_rows(); i++)
    558             {
    559                 const mysqlpp::Row &row = res1[i];
    560                 Warn(" "+string(row["fSourceName"])+" ["+to_string(uint32_t(row["fSourceKey"]))+"]");
    561             }
    562         }
    563 
    564         Out() << Time()-stopwatch << endl;
    565 
    566         int32_t source_key = -1;
    567 
    568         const string query2 =
    569             "SELECT fSourceKey FROM Source WHERE fSourceName='"+name+"'";
    570 
    571         const mysqlpp::StoreQueryResult res2 = fConnection.query(query2).store();
    572 
    573         if (res2.num_rows())
    574         {
    575             source_key = res2[0]["fSourceKey"];
    576             Info("A source with the same name (key="+to_string(source_key)+") was found in the Source table.");
    577         }
    578 /*
    579         if (source_key<0)
    580         {
    581             const string query =
    582                 "INSERT INTO Source\n"
    583                 " (fSourceName, fRightAscension, fDeclination, fWobbleAngle0, fWobbleAngle1, fSourceTypeKey, fIsToO) VALUES\n"
    584                 " ('"+name+"', "+to_string(ra/15.)+", "+to_string(dec)+", "+to_string(wobble_angle-90)+", "+to_string(wobble_angle+90)+", 1, 1)";
    585 
    586             if (!fDryRun)
    587             {
    588                 auto q = fConnection.query(query);
    589                 q.execute();
    590                 Info(q.info());
    591 
    592                 source_key = q.insert_id();
    593 
    594                 Info(string(fDryRun?"[dry-run] ":"")+"The new source got the key "+to_string(source_key));
    595             }
    596             else
    597                 Out() << query << endl;
    598 
    599         }
    600 */
    601         Out() << Time()-stopwatch << endl;
     614        if (known_only && source_key<0)
     615        {
     616            Warn("Observation of only known sources requested but no known source found.");
     617            return false;
     618        }
    602619
    603620        /*
     
    782799        // ====================================================================
    783800
     801        // FIXME: Check if source is not already scheduled anyways
     802
    784803        Info("Source will be scheduled.");
    785804
    786805        if (source_key<0)
    787806        {
     807            const double wobble_angle = GetWobbleAngle(ra, dec);
     808
     809            Out() << Time()-stopwatch << endl;
     810
    788811            const string query =
    789812                "INSERT INTO Source\n"
     
    839862
    840863        const string queryI =
    841             "INSERT INTO Schedule\n (fStart,fMeasurementID,fUser,fData,fSoureKey,fMeasurementTypeKey)\n"
     864            "INSERT INTO Schedule\n (fStart,fMeasurementID,fUser,fData,fSourceKey,fMeasurementTypeKey)\n"
    842865            "VALUES\n "+string(boost::algorithm::join(insert, ",\n "));
    843866
     
    854877
    855878        // Empty interrupt to stop data taking as early as possible
    856         Dim::SendCommandNB("DIM_CONTROL/INTERRUPT");
    857 
    858         // Reload sources as early as possible
    859         Dim::SendCommandNB("DRIVE_CONTROL/RELOAD_SOURCES");
    860 
    861         // Start pointing procedure as early as possible
    862         //Dim::SendCommand("DRIVE_CONTROL/TRACK_WOBBLE", wobble, obs[sub].source);
     879        // Triggers also RELOAD_SOURCES
     880        Dim::SendCommandNB("DIM_CONTROL/INTERRUPT", "prepare");
    863881
    864882        // ---------------------------------------------------------
     
    867885
    868886        // ---------------------------------------------------------
    869         /*
    870          if (!list.empty())
    871          {
    872          const mysqlpp::SimpleResult res = fConnection.query(queryD).execute();
    873          Info(to_string(res.rows())+" row(s) deleted from Schedule.");
    874          }
    875 
    876          // ---------------------------------------------------------
    877 
    878          if (!insert.empty())
    879          {
    880          auto q = fConnection.query(queryI);
    881          q.execute();
    882          Info(q.info());
    883          }
    884          */
     887        if (!list.empty())
     888        {
     889            const mysqlpp::SimpleResult res = fConnection.query(queryD).execute();
     890            Info(to_string(res.rows())+" row(s) deleted from Schedule.");
     891        }
     892
     893        // ---------------------------------------------------------
     894
     895        if (!insert.empty())
     896        {
     897            auto q = fConnection.query(queryI);
     898            q.execute();
     899            Info(q.info());
     900        }
    885901        // ---------------------------------------------------------
    886902
     
    898914    }
    899915
    900     bool Schedule(const string &name, const double &ra, const double &dec)
     916    bool Schedule(const string &name, const double &ra, const double &dec, const bool &known_only)
    901917    {
    902918        try
    903919        {
    904             return ScheduleImp(name, ra, dec);
     920            return ScheduleImp(name, ra, dec, known_only);
    905921        }
    906922        catch (const exception &e)
     
    935951        const ToO::DataGRB &grb = evt.Ref<ToO::DataGRB>();
    936952
    937         const GCN::PaketType_t *ptr=GCN::kTypes;
    938         for (; ptr->type>=0 && ptr->type!=grb.type; ptr++);
    939         if (ptr->type==-1)
    940         {
    941             Warn("Unknown Packet Type: "+to_string(ptr->type));
     953        const auto it = GCN::PaketTypes.find(grb.type);
     954
     955        if (it==GCN::PaketTypes.end())
     956        {
     957            Warn("Unknown Packet Type: "+to_string(grb.type));
    942958            return GetCurrentState();
    943959        }
    944960
     961        const auto &paket = it->second;
     962
    945963        ostringstream out;
    946         out << "Received: '" << ptr->name << "' ID=" << grb.type << " NUM=" << grb.trigid << " RA=" << grb.ra/15. << "h DEC=" << grb.dec << "\u00b0 ERR=" << grb.err;
     964        out << "Received: '" << paket.name << "' ID=" << grb.type << " NUM=" << grb.trigid << " RA=" << grb.ra/15. << "h DEC=" << grb.dec << "\u00b0 ERR=" << grb.err;
     965
     966        /*
     967            const std::vector<int16_t> typelist =
     968            {
     969                51,  // INTEGRAL_POINTDIR
     970
     971                53,  // INTEGRAL_WAKEUP
     972                54,  // INTEGRAL_REFINED
     973                55,  // INTEGRAL_OFFLINE
     974
     975                // 56, // INTEGRAL_WEAK
     976                // 59, // KONUS_LC
     977
     978                60,  // SWIFT_BAT_GRB_ALERT
     979                61,  // SWIFT_BAT_GRB_POS_ACK
     980                62,  // SWIFT_BAT_GRB_POS_NACK
     981
     982                83,  // SWIFT_POINTDIR
     983
     984                97,  // SWIFT_BAT_QL_POS
     985
     986                100, // AGILE_GRB_WAKEUP
     987                101, // AGILE_GRB_GROUND
     988                102, // AGILE_GRB_REFINED
     989
     990                110, // FERMI_GBM_FLT_POS
     991                111, // FERMI_GBM_GND_POS
     992                112, // FERMI_GBM_LC
     993                115, // FERMI_GBM_TRANS
     994
     995                123, // FERMI_LAT_TRANS
     996                125, // FERMI_LAT_MONITOR
     997
     998                // 134, // MAXI_UNKNOWN
     999                // 135, // MAXI_KNOWN
     1000                // 136, // MAXI_TEST
     1001
     1002                157, // AMON_ICECUBE_COINC
     1003                158, // AMON_ICECUBE_HESE
     1004
     1005                169, // AMON_ICECUBE_EHE
     1006                171, // HAWC_BURST_MONITOR
     1007                173, // ICECUBE_GOLD
     1008                174, // ICECUBE_BRONZE
     1009            };
     1010         */
    9471011
    9481012        Info(out);
    949         Info(ptr->description);
     1013        Info(paket.description);
    9501014
    9511015        const CheckVisibility check(grb.ra, grb.dec);
    9521016
    953         Info(string("Source is")+(check.visible?" ":" NOT ")+"visible.");
    954 
    955         Info(string("Sun altitude:   ")+(check.valid_sun    ?"OK    ":"failed")+" ["+Tools::Form("%5.1f", check.solarobj.fSunHrz.alt)+"\u00b0]");
    956         Info(string("Moon distance:  ")+(check.valid_moon   ?"OK    ":"failed")+" ["+Tools::Form("%5.1f", check.moon_dist)+"\u00b0]");
    957         Info(string("Zenith angle:   ")+(check.valid_zd     ?"OK    ":"failed")+" ["+Tools::Form("%5.1f", check.position.zd)+"\u00b0]");
    958         Info(string("Current:        ")+(check.valid_current?"OK    ":"failed")+" ["+Tools::Form("%5.1f", check.current)+" \u00b5A]");
    959 
    960         const string name = ptr->instrument+"#"+to_string(grb.trigid);
    961         Info("Source name set to '"+name+"'");
     1017        //Info(string("Source is")+(check.visible?" ":" NOT ")+"visible.");
     1018
     1019        Info(string("Sun altitude:   ")+(check.valid_sun      ?"OK    ":"failed")+" ["+Tools::Form("%5.1f", check.solarobj.fSunHrz.alt)+"\u00b0]");
     1020        Info(string("Moon distance:  ")+(check.valid_moon     ?"OK    ":"failed")+" ["+Tools::Form("%5.1f", check.moon_dist)+"\u00b0]");
     1021        Info(string("Zenith angle:   ")+(check.valid_zd       ?"OK    ":"failed")+" ["+Tools::Form("%5.1f", check.position.zd)+"\u00b0]");
     1022        Info(string("Current:        ")+(check.valid_current  ?"OK    ":"failed")+" ["+Tools::Form("%5.1f", check.current)+" \u00b5A]");
     1023        Info(string("Rel. threshold: ")+(check.valid_threshold?"OK    ":"failed")+" ["+Tools::Form("%5.1f", check.threshold)+"]");
     1024
     1025        if (!check.visible)
     1026        {
     1027            Info("Source not observable... skipped.");
     1028            return fConnection.connected() ? GetCurrentState() : ToO::State::kDisconnected;
     1029        }
     1030
     1031        const string name = paket.instrument+"#"+to_string(grb.trigid);
     1032        Info("Source is visible... name set to '"+name+"'");
    9621033
    9631034        /*
     
    10231094*/
    10241095
    1025         Schedule(name, grb.ra, grb.dec);
    1026 
    1027         return fConnection.connected() ? ToO::State::kConnected : ToO::State::kDisconnected;
     1096        const bool known_only = grb.type==51 || grb.type==83;
     1097
     1098        Schedule(name, grb.ra, grb.dec, known_only);
     1099
     1100        return fConnection.connected() ? GetCurrentState() : ToO::State::kDisconnected;
    10281101        //return GetCurrentState();
     1102    }
     1103
     1104    int Enable()
     1105    {
     1106        return GetCurrentState()==ToO::State::kConnected ? ToO::State::kArmed : GetCurrentState();
     1107    }
     1108    int Disable()
     1109    {
     1110        return GetCurrentState()==ToO::State::kArmed ? ToO::State::kConnected : GetCurrentState();
    10291111    }
    10301112
     
    10531135        }
    10541136
    1055         return fConnection.connected() ? ToO::State::kConnected : ToO::State::kDisconnected;
     1137        if (!fConnection.connected())
     1138            return ToO::State::kDisconnected;
     1139
     1140        if (fConnection.connected() && GetCurrentState()<=ToO::State::kDisconnected)
     1141            return ToO::State::kConnected;
     1142
     1143        return GetCurrentState();
    10561144    }
    10571145
     
    10651153        AddStateName(ToO::State::kConnected, "Connected",
    10661154                     "All needed subsystems are connected to their hardware, no action is performed.");
     1155
     1156        AddStateName(ToO::State::kArmed, "Armed",
     1157                     "All needed subsystems are connected to their hardware, scheduling in progress.");
    10671158
    10681159        AddEvent("GCN", "S:1;I:1;D:1;D:1;D:1")
     
    10701161            (""
    10711162             "|type[int16]:TypeID (see HeaderGCN.h)"
    1072              "|num[uint32]:Right ascension"
     1163             "|trig[uint32]:TriggerID"
    10731164             "|ra[deg]:Right ascension"
    10741165             "|dec[deg]:Declination"
    10751166             "|err[deg]:Error radius");
     1167
     1168        AddEvent("START", "")
     1169            (bind(&StateMachineToO::Enable, this/*, placeholders::_1*/))
     1170            ("");
     1171
     1172        AddEvent("STOP", "")
     1173            (bind(&StateMachineToO::Disable, this/*, placeholders::_1*/))
     1174            ("");
    10761175    }
    10771176
     
    10921191    {
    10931192        fVerbose = !conf.Get<bool>("quiet");
    1094         fDryRun = conf.Get<bool>("dry-run");
    10951193        fKeepAliveInterval = conf.Get<uint16_t>("keep-alive");
    10961194        fUri = conf.Get<string>("schedule-database");
     
    11151213    control.add_options()
    11161214        ("quiet,q", po_bool(), "")
    1117         ("dry-run", po_bool(), "Switch off any alteration of the database")
    11181215        ("keep-alive", var<uint16_t>(uint16_t(300)), "Interval in seconds to ping (reconnect) the database server")
    11191216        ("schedule-database", var<string>(), "Database link as in\n\tuser:password@server[:port]/database[?compress=0|1].")
Note: See TracChangeset for help on using the changeset viewer.