コード例 #1
0
ファイル: readmatlabsettings.cpp プロジェクト: aveminus/freq
void ReadMatlabSettings::
readAsyncAndDeleteSelfWhenDone()
{
    if (!QFileInfo(settings.scriptname().c_str()).exists())
    {
        emit failed(settings.scriptname().c_str(), "File doesn't exist");

        if (deletethis_)
            delete this;

        return;
    }

    QString subname = type_ == MetaData_Settings ? "settings" : "";
    QString functionname = settings.scriptname().c_str();

    if (type_ == MetaData_Settings)
    {
        string basename = basescriptname(settings.scriptname().c_str()).toStdString();
        if (basename != settings.scriptname())
        {
            subname = "";
            settings.scriptname(basename);
        }
    }

    function_.reset( new MatlabFunction( functionname, subname, 4, type_ == MetaData_Settings ? 0 : &settings, justtest ) );
    QTimer::singleShot(100, this, SLOT(checkIfReady()));
}
コード例 #2
0
ファイル: readmatlabsettings.cpp プロジェクト: aveminus/freq
void ReadMatlabSettings::
checkIfReady()
{
    bool finished = function_->hasProcessCrashed() || function_->hasProcessEnded();

    string file = function_->isReady();
    if (file.empty() && !finished)
    {
        QTimer::singleShot(100, this, SLOT(checkIfReady()));
        return;
    }

    QByteArray ba;
    if (function_->getProcess())
        ba = function_->getProcess()->readAllStandardOutput();
    QString s( ba );
    s = s.trimmed();
    if (s.isEmpty())
        TaskInfo("ReadMatlabSettings %s: no output", function_->matlabFunction().c_str());
    else
        TaskInfo("ReadMatlabSettings %s: output: %s", function_->matlabFunction().c_str(), s.toLatin1().data());

    bool success = false;

    if (!file.empty()) try
        {
            switch (type_)
            {
            case MetaData_Settings:
                readSettings(file);
                break;
            case MetaData_Source:
                readSource(file);
                break;
            default:
                EXCEPTION_ASSERT( false );
                break;
            }
            success = true;
        }
        catch (const runtime_error& x)
        {
            TaskInfo("ReadMatlabSettings::%s %s", vartype(x).c_str(), x.what());
            s += "\n";
            s += vartype(x).c_str();
            s += ": ";
            s += x.what();
        }

    if (!success)
        emit failed( settings.scriptname().c_str(), s );

    if (deletethis_)
        delete this;
}
コード例 #3
0
 inline const AzDvect *targets() const {
   checkIfReady("targets"); 
   return &v_y;  
 }
コード例 #4
0
 inline const AzSmat *feat() const {
   checkIfReady("feat"); 
   return &m_feat; 
 }