uniset-algorithms  0.2
Открытые члены | Открытые статические члены
Класс SEESInitMode

#include <SEESMode.h>

Граф наследования:SEESInitMode:
Inheritance graph
[см. легенду]
Граф связей класса SEESInitMode:
Collaboration graph
[см. легенду]

Полный список членов класса

Открытые члены

void Destroy ()
virtual bool activate (SEES *sc)
virtual const string modeName ()
virtual SEESMessage::SEESMode getMode ()
bool checkMode (SEES *sc)

Открытые статические члены

static SEESInitModeInstance ()

Подробное описание

Режим "инициализации" или "повторной попытки"

См. также:
Описание алгоритма управления конкретным ГДГ

Методы

bool SEESInitMode::activate ( SEES sc) [virtual]
Необходимо сделать:
Не следует ли здесь если режим "автомат" делать принудительный пуск или остановку (лидера), в зависимости от напряжения на шинах. И соответственно пуск или остановку резервного, в зависимости от команд управления резервом.

Переопределяет метод предка SEESMode.

Перекрестные ссылки SEES::initPause, SEESMessage::OffMode и SEESMessage::RunningMode.

{
    SEES::dlog[Debug::INFO] << sc << ": init state..." << endl;
    // время на инициализацию режима СЭС, а также
    // состояния ГА
    msleep(sc->initPause);
    sc->updateValues();
    sc->dis->updateValues();
    sc->gen->updateValues();
    sc->qg->updateValues();

    if( sc->in_CtlMode_f == mOffControl ||
        sc->in_CtlMode_f == mUndefined )
    {
        SEES::dlog[Debug::INFO] << sc << ": режим ручного управления..." << endl;
        changeMode( SEESSleepMode::Instance(), sc );
        return true;
    }
    
    {
        if( sc->in_state_as == mPROTECTION )
        {
            SEES::dlog[Debug::INFO] << sc << "(activate): "
                        << " state == mPROTECTION " << endl;
            changeMode( SEESProtectionMode::Instance(), sc );
            return true;
        }
        
        try
        {
            bool qg_prot = sc->qg->isProtection();
            bool dis_prot = sc->dis->isProtection();
            bool gen_prot = sc->gen->isProtection();
            
            SEES::dlog[Debug::INFO] << sc << "(activate): "
                        << " qg_prot=" << qg_prot
                        << " gen_prot=" << gen_prot
                        << " dis_prot=" << dis_prot << endl;
                        
            if( qg_prot || dis_prot || gen_prot )
            {
                SEES::dlog[Debug::INFO] << sc << ": init ProtectionMode\n";
                changeMode( SEESProtectionMode::Instance(), sc );
                return true;
            }

#warning Maybe check state_as?
            bool qg_state = sc->qg->isOnMode();
            bool dis_state = sc->dis->isOnMode();
            bool gen_state = sc->gen->isOnMode();
            SEES::dlog[Debug::INFO] << sc << ": init Diesel=" << dis_state
                                << " Generator=" << gen_state 
                                << " QG=" << qg_state 
                                << " sees=" << sc->in_state_as << endl;
//          try
//          {
//              sc->updateValues();
//          }
//          catch( Exception& ex )
//          {
//              SEES::dlog[Debug::CRIT] << sc << ": (init): !!!!!!!!!! " << ex << endl;
//              throw;
//          }

            if( ( dis_state && gen_state && qg_state ) || (sc->in_state_as == mON) )
            {
                sc->out_postID = sc->myPostID;
                if( sc->in_CtlMode_f == mAuto )
                {
                    if( sc->in_Leader_f )
                    {
                        SEES::dlog[Debug::INFO] << sc << ": to auto mode.." << endl;
                        changeMode( SEESOnAutoMode::Instance(), sc );
                    }
                    else
                    {
                        SEES::dlog[Debug::INFO] << sc << ": to reserv mode.." << endl;
                        changeMode( SEESOnReservMode::Instance(), sc );
                    }
                    return true;
                }

                SEES::dlog[Debug::INFO] << sc << ": to on mode.." << endl;
                changeMode( SEESOnMode::Instance(), sc );
                return true;
            }
            else if( ( dis_state && gen_state ) || ( sc->in_state_as == mRunning ) )
            {
                if( sc->in_CtlMode_f == mPultControl )
                {
                    sc->out_postID = sc->myPostID;
                    changeMode( SEESRunningMode::Instance(), sc );
                    return true;
                }
                else if( sc->in_CtlMode_f == mAuto )
                {
                    sc->out_postID = sc->myPostID;
//                  if( sc->in_Leader_f )
//                  {
                        if( sc->in_NoPower_S )
                            changeMode( SEESAutoWaitingMode::Instance(sc,SEESMessage::RunningMode,SEESProtectionMode::Instance()), sc );
                        else
                            changeMode( SEESAutoWaitingMode::Instance(sc,SEESMessage::OffMode,SEESProtectionMode::Instance()), sc );
//                  }
                    return true;
                }
            }
            else if( (!dis_state && !gen_state && !qg_state) || (sc->in_state_as == mOFF) )
            {
                if( sc->in_CtlMode_f == mAuto )
                {
                    sc->out_postID = sc->myPostID;
                    if( sc->in_Leader_f )
                        changeMode( SEESAutoMode::Instance(), sc );
                    else
                        changeMode( SEESReservMode::Instance(), sc );
                    return true;
                }
            
                sc->out_postID = sc->myPostID;
                changeMode( SEESOffMode::Instance(), sc );
                return true;
            }
            
            if( checkMode(sc) )
                return true;
            
            if( sc->in_state_as == mTRANSITIVE )
            {
                for( int i=0; i<sc->initAttempts; i++ )
                {
                    msleep(sc->initPause);
                    sc->updateValues();
                    if( checkMode(sc) )
                        return true;
                }
            }
        }
        catch(Exception& ex)
        {
            SEES::dlog[Debug::WARN] << sc << ": " << ex << endl;
        }
        catch(...)
        {
            SEES::dlog[Debug::CRIT] << sc << ": неопределённое состояние" << endl;
        }
        // Undefined state logic....
        SEES::dlog[Debug::INFO] << sc << ": state_as=" << sc->in_state_as 
                << " " << txtModeName((ObjectMode)sc->in_state_as)
                << endl;

        if( sc->in_state_as == mPROTECTION  )
        {
            changeMode( SEESProtectionMode::Instance(), sc );
            return true;
        }

        if( sc->in_CtlMode_f == mAuto )
        {
            // если состояние "переходное", то делаем несколько попыток
            // подождать...
            if( sc->in_state_as == mTRANSITIVE )
            {
                for( int i=0; i<sc->initAttempts; i++ )
                {
                    msleep(sc->initPause);
                    sc->updateValues();
                    if( sc->in_state_as != mTRANSITIVE )
                        break;
                }
            }
        
            if( sc->in_Leader_f )
            {
                if( sc->in_state_as == mON )
                {
                    changeMode( SEESOnAutoMode::Instance(), sc );
                    return true;
                }
                else if( sc->in_state_as == mOFF )
                {
                    changeMode( SEESAutoMode::Instance(), sc );
                    return true;
                }
            }
            else
            {
                if( sc->in_state_as == mON )
                {
                    changeMode( SEESOnReservMode::Instance(), sc );
                    return true;
                }
                else if( sc->in_state_as == mOFF )
                {
                    changeMode( SEESReservMode::Instance(), sc );
                    return true;
                }
            }
        }

        SEES::dlog[Debug::CRIT] << sc << ": ПРОТИВОРЕЧИВОЕ СОСТОЯНИЕ" << endl;
//      changeMode( SEESUndefinedMode::Instance(), sc );
        changeMode( SEESProtectionMode::Instance(), sc );
    }
    
    return true;
}

Объявления и описания членов классов находятся в файлах: