Пример #1
0
void TranslateCppException() {
    try {
        throw;
    }
    catch (const AbstractObject& throwable) {
        Throw(throwable);
    }
    catch (const std::exception& exception) {
        ThrowRuntimeException(exception.what());
    }
    catch (...) {
        ThrowRuntimeException("Unknown C++ exception.");
    }
}
Пример #2
0
    BfBootCore::DefaultParam& NObjBoardSettings::getParams()
    {
        if (!m_defaultParams) ThrowRuntimeException("SetDefaultParams first.");

        m_defaultParams->OptionalSettings = m_userParams;
        return *m_defaultParams;
    }
Пример #3
0
    Q_INVOKABLE void NObjBfTaskSetParams::SetOptNetwork( bool useDhcp, QString ip, QString gateway, QString mask )
    {
        if (useDhcp)
        {
            m_optSettings.Network = E1App::BoardAddresSettings();
            return;
        }               

        m_optSettings.Network = 
            E1App::BoardAddresSettings(ip.toStdString(), gateway.toStdString(), mask.toStdString());

        if (!m_optSettings.Network.get().IsValid()) ThrowRuntimeException("Invalid network settings");
    }
    void NObjBfTaskUpdateBooter::Run(bool& isLastTask)
    {
        isLastTask = true;
        if (!m_bootImage) ThrowRuntimeException("Set boot image before run");

        m_task = BfBootCli::TaskComposer::UpdateBootImg(
            m_prof->getMngProf(), 
            m_prof->getPwd(),
            *m_bootImage,
            m_prof->getTransport(),                
            m_prof->getTraceServer()
            );
    }
Пример #5
0
    Q_INVOKABLE void NObjBoardSettings::SetNetwork( bool use, QString ip, QString gateway, QString mask )
    {
        AssertUnlocked();
        if (use)
        {
            m_userParams.Network = E1App::BoardAddresSettings();
            return;
        }               

        m_userParams.Network = 
            E1App::BoardAddresSettings(ip.toStdString(), gateway.toStdString(), mask.toStdString());

        if (!m_userParams.Network.get().IsValid()) ThrowRuntimeException("Invalid network settings");
    }
Пример #6
0
void bbCopyStream(bbStream* s, bbStream* d, int buff_size)
{
	if (debug) {
		debugStream(s);
		debugStream(d);
		if (buff_size < 1 || buff_size > 1024 * 1024)
			ThrowRuntimeException("Illegal buffer size");
	}
	char* buff = new char[buff_size];
	while (s->eof() == 0 && d->eof() == 0) {
		int n = s->read(buff, buff_size);
		d->write(buff, n);
		if (n < buff_size)
			break;
	}
	delete buff;
}
    bool NObjCommonBfTaskProfile::OnPropertyWrite( NamedObject *pObject, QString propertyName, QString val )
    {
        ESS_ASSERT(this == pObject);
        AssertUnlocked();

        // special case
        if (propertyName == "TraceClient") 
        {                
            m_prof.reset();
        }
        if (propertyName == "CbpPort")
        {
            if (val.toInt() <= 0) ThrowRuntimeException("CbpPort must be positive");
        }
        if (propertyName == "BoardAddress" || propertyName == "CbpPort")
        {
            m_transport.reset();
        }

        return true;
    }
    void NObjCommonBfTaskProfile::ExpectedMessageReceived( const BfBootCore::BroadcastMsg& msg )
    {                
        bool tryNext = false;

        // state wait post validation
        if (m_postValidator) 
        {
            tryNext = true;            
            PutMsg(this, &NObjCommonBfTaskProfile::OnDeleteRec, m_postValidator);
            m_postValidator = 0;
        }

        // state wait addInfo
        if (m_addInfoReceiver)         
        {
            m_addr = msg.CbpAddress.Address().c_str();
            m_cbpPort = msg.BooterPort;
            
            if (m_cbpPort <= 0) ThrowRuntimeException("Wrong CbpPort in broadcast!");
            PutMsg(this, &NObjCommonBfTaskProfile::OnDeleteRec, m_addInfoReceiver);            
            m_addInfoReceiver = 0;
        }

        QString logMsg = 
            QString("Expected message received. \nMessage info:\n%1").arg(msg.Info().c_str());                    

        if (tryNext && m_pNetTask)
        {
            RunNext();
        }
        else
        {
            UnlockChanges();
            AsyncComplete(true, logMsg);             
        }
    }
Пример #9
0
 void NObjBoardSettings::AssertUnlocked()
 {
     if (m_locked) ThrowRuntimeException("Change settings locked.");
 }
 void NObjCommonBfTaskProfile::AssertUnlocked()
 {
     if (!m_lockedBy.isEmpty()) ThrowRuntimeException("Object currently used in active task" + m_lockedBy.toStdString());
 }
Пример #11
0
 void NObjBfTaskUpdateBooter::Init( QString profile )
 {
     std::string err;
     if (!m_prof.Init(profile, &err)) ThrowRuntimeException(err);        
 }
Пример #12
0
void debugStream(bbStream* s)
{
	if (stream_set.count(s))
		return;
	ThrowRuntimeException("Stream does not exist");
}