Changeset 18149 for trunk


Ignore:
Timestamp:
02/18/15 12:26:02 (10 years ago)
Author:
tbretz
Message:
Initiate an emergency shutdown also when an overcurrent is detected; print messages only once; there is still a little chance that between the initiation of an emergency shutdown and the transfer to the Locked state another ramp up command is processed.
File:
1 edited

Legend:

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

    r18126 r18149  
    274274            fPresent[board] = true;
    275275
    276             if (fEmergencyLimit>0 && fCurrent[id]>fEmergencyLimit && !fEmergencyShutdown)
     276            if (!fEmergencyShutdown)
    277277            {
    278                 Info("Emergency shutdown initiated.");
    279                 RampAllDacs(0);
    280                 fEmergencyShutdown = true;
     278                if (fCurrent[id]<0)
     279                {
     280                    Warn("OverCurrent detected.");
     281                    fEmergencyShutdown = true;
     282                }
     283
     284                if (fEmergencyLimit>0 && fCurrent[id]>fEmergencyLimit && !fEmergencyShutdown)
     285                {
     286                    Warn("Emergency limit exceeded.");
     287                    fEmergencyShutdown = true;
     288                }
     289
     290                if (fEmergencyShutdown)
     291                {
     292                    Error("Emergency ramp down initiated.");
     293                    Dim::SendCommandNB("MCP/STOP");
     294                    RampAllDacs(0);
     295                }
    281296            }
    282297        }
     
    433448            if (oc)
    434449            {
    435                 Warn("OverCurrent detected - ramping stopped.");
    436                 fIsRamping = false;
     450                if (!fEmergencyShutdown)
     451                {
     452                    Warn("OverCurrent detected - emergency ramp down initiated.");
     453                    Dim::SendCommandNB("MCP/STOP");
     454                    RampAllDacs(0);
     455                    fEmergencyShutdown = true;
     456                }
    437457            }
    438458            else
     
    18901910    }
    18911911
    1892     int Shutdown()
     1912    int Shutdown(const string &reason)
    18931913    {
    18941914        fBias.RampAllDacs(0);
    1895         T::Info("Emergency shutdown initiated.");
     1915        T::Info("Emergency shutdown initiated ["+reason+"].");
    18961916        return State::kLocked;
    18971917    }
     
    18991919    int Unlock()
    19001920    {
     1921        fBias.ResetEmergencyShutdown();
    19011922        return fBias.GetStatus();
    19021923    }
     
    19061927        const int state = fBias.GetStatus();
    19071928
    1908         if (fBias.IsEmergencyShutdown() && state>State::kInitializing && state<State::kExpertMode)
    1909         {
     1929        if (fBias.IsEmergencyShutdown()/* && state>State::kInitializing && state<State::kExpertMode*/)
     1930        {
     1931            // This needs to be repeated for the case that in between a different command was processed
    19101932            fBias.RampAllDacs(0);
    1911             fBias.ResetEmergencyShutdown();
    19121933            return State::kLocked;
    19131934        }
     
    19231944
    19241945            if (shutdown)
    1925             {
    1926                 T::Error("Voltage on at end of nautical twilight!");
    1927                 Shutdown();
    1928             }
     1946                Shutdown("beginning of civil twilight");
    19291947
    19301948            fSunRise = now.GetNextSunRise(-6);
     
    20702088            ("Set all channels to a zero reference voltage. Starts ramping if necessary.");
    20712089        T::AddEvent("SHUTDOWN")(State::kConnected)(State::kVoltageOff)(State::kVoltageOn)(State::kNotReferenced)(State::kOverCurrent)(State::kRamping)
    2072             (bind(&StateMachineBias::Shutdown, this))
     2090            (bind(&StateMachineBias::Shutdown, this, "user request"))
    20732091            ("Same as SET_ZERO_VOLTAGE; but goes to locked state afterwards.");
    20742092
Note: See TracChangeset for help on using the changeset viewer.