コード例 #1
0
GNumericalExpression::GNumericalExpression(QObject *parent, QString uniqueIdentifierName)
	: GProgDevice(parent, uniqueIdentifierName)
	, m_ValueBucket("Result", this)
	, m_VariableBucket("Variables", this)
	, m_EnableEvaluation("EnableEvaluation", this)
	, m_Expression("Expression", this)
{
	// Expression Display Initialization
	m_ExpressionDisplay = new GExpressionDisplay(this);

	// Script Engine Initialization
	m_pScriptEngine = new GMathScriptEngine(this);
// 	m_ScriptEngineDebugger = new QScriptEngineDebugger;

	m_VariableBucket.AddExtraFieldString("symb");


	connect(&m_Expression, SIGNAL(ValueUpdated(QString)), m_pScriptEngine, SLOT(SetProgram(QString)));
	connect(&m_Expression, SIGNAL(ValueUpdated(QString)), m_pScriptEngine, SLOT(Evaluate()));
	connect(&m_VariableBucket, SIGNAL(BucketUpdatedValues(int)), this, SLOT(ReCalculate(int)));
	connect(m_pScriptEngine, SIGNAL(Evaluated(double)), &m_ValueBucket, SLOT(SetParamValue(double)));

	connect(&m_VariableBucket, SIGNAL(ParamAdded(GParam*)), this, SLOT(AddVariableFromParam(GParam*)), Qt::QueuedConnection);
	connect(&m_VariableBucket, SIGNAL(ParamRemoved(int, GParam*)), this, SLOT(RemoveVariableFromParam(int, GParam*)));
}
コード例 #2
0
moDirectorStatus
moLayerEffectCtrl::ParameterUpdated( moParameterDescriptor p_ParameterDesc ) {

    moValueIndex vindex;

    ///solo actualizamos aquellos parametros que tienen textura y color...
    ///el nombre del parametro debe ser "color" o "texture"

    switch( p_ParameterDesc.GetParamDefinition().GetType() ) {

      case MO_PARAM_COLOR:
      case MO_PARAM_TEXTURE:

        if (  p_ParameterDesc.GetParamDefinition().GetName()==moText("color") ||
              p_ParameterDesc.GetParamDefinition().GetName()==moText("texture")
        ) {

          vindex.m_ParamIndex = p_ParameterDesc.GetIndex();
          vindex.m_ValueIndex = p_ParameterDesc.GetIndexValue();

          moValueDescriptor ValueDes( p_ParameterDesc, vindex );

          ///PEDIMOS EL VALOR.... completo
          ValueDes = GetValue( ValueDes );

          ///auto actualizamos
          ValueUpdated( ValueDes );
        }

        break;

    }

    return MO_DIRECTOR_STATUS_OK;
}
コード例 #3
0
GEquationPayOff::GEquationPayOff( const GParamString & ProgramString, QObject *parent )
	: GPayOff(parent)
	, m_pEngine(0)
{
	m_pEngine = new GMathScriptEngine(this);
	m_pEngine->globalObject().setProperty("S", m_ScriptSpot);
	m_pEngine->SetProgram(ProgramString.StringValue());
	connect(&ProgramString, SIGNAL(ValueUpdated(QString)), m_pEngine, SLOT(SetProgram(QString)));
}
コード例 #4
0
GPlainTextLogger::GPlainTextLogger(QObject *parent, QString uniqueIdentifierName /* = "" */)
	: GProgDevice(parent, uniqueIdentifierName)
	, m_FolderPath("Folder", this/*, GParam::ReadOnly*/)
	, m_FileName("File name", this)
	, m_ShouldLogOnUpdate("On update?", this)
	, m_ShouldLogOnTimer("On timer?", this)
	, m_SecondTimer("Delay [s]:", this)
	, m_Bucket("Data", this)
	, m_BucketColNames("Col Names", this)
	, m_UpdateCount(0)
	, m_SecUpdate("Elapsed time (s):", this, GParam::ReadOnly)
	, m_SecMidnight("sec mid", this, GParam::ReadOnly)
	, m_SecEpoch("sec epoch", this, GParam::ReadOnly)
	, m_CurrentIndexUpdate("Update #:", this, GParam::ReadOnly)
	, m_pNotePadProcess(0)
	, m_FirstColName("Col. name:", this)
	, m_FirstColFormula("Formula (use i,t,tu,tm):", this)
	, m_FirstColValue("=", this, GParam::ReadOnly)
{
	connect(&m_Bucket, SIGNAL(BucketUpdatedValues()), this, SLOT(EventBucketUpdated()));
	connect(&m_Timer, SIGNAL(timeout()), this, SLOT(EventTimerFired()));
	connect(&m_SecondTimer, SIGNAL(ValueUpdated(double)), this, SLOT(SetTimerLapse(double)));
	connect(&m_FileName, SIGNAL(ValueUpdated(QString)), this, SLOT(ResetCount()));
	connect(&m_FolderPath, SIGNAL(ValueUpdated(QString)), this, SLOT(ChooseFolder(QString)), Qt::QueuedConnection);

	m_SecUpdate.SetHardLimits(0.0, 9e99);
	m_SecMidnight.SetHardLimits(0.0, 9e99);
	m_SecEpoch.SetHardLimits(0.0, 9e99);
	m_FirstColValue.SetHardLimits(0.0, 9e99);

	m_SecondTimer = 1.0;
	m_SecondTimer.SetDisplayDecimals(2);
	m_SecondTimer.SetTypicalStep(0.1);
	m_SecondTimer.SetHardLimits(0.01, 9999);
	m_FirstColName = "unix time (s)";
	m_FirstColFormula = "t";

	m_Timer.start();
}
コード例 #5
0
void GMathScriptEngine::RegisterVariable( GParamString* pName, GParamNum* pParamNum )
{
	QString name = pName->StringValue();
	double val = pParamNum->DoubleValue();
	if(name != "")
		globalObject().setProperty(name, newVariant(val));

	m_ParamName_ParamNum.insert(pName, pParamNum);
	UpdateAllVariableNames();

	// when renaming, we update the variable names
	connect(pName, SIGNAL(ValueUpdated(QString)), this, SLOT(UpdateAllVariableNames()));
}
コード例 #6
0
//! [Initialize the parameters]
GMonteCarloLogNormalPricer::GMonteCarloLogNormalPricer(QObject *parent, QString uniqueIdentifierName /* = "" */)
	: GProgDevice(parent, uniqueIdentifierName)
	, m_PathNumber("num paths", this)
	, m_VolBucket("Volatility", this)
	, m_ExpiryBucket("Expiry", this)
	, m_StrikeBucket("Strike", this)
	, m_InterestRate("Interest Rate", this)
	, m_Reset("Reset", this)
	, m_Run("Run", this)
	, m_CurrentPlotValues(numPointsPlot)
	, m_OutputBridgeToEmitManyValues("Output", this, GParam::ReadOnly)
	, m_pPayOff(0)
	, m_TotalNumberIteration(0)
	, m_PayOffType("PayOff", this)
	, m_EquationString("Equation", this)
{
//! [Initialize the parameters]
/*
Note: All parameters defined with "this" device as parent (see above) will be saved automatically 
when the device state is saved to file. The name used to save the values is the same as the one provided 
for the name (the first argument, e.g. "num. samples").
*/
//! [Extra initialization the parameters]
	// Default value of the sample size for the first use.
	// It will be over-written if a previously saved value is read from a file.
	m_PathNumber = -10;
	m_VolBucket.SetParamValue(0.05);
	m_VolBucket.DefaultParam()->SetTypicalStep(0.01);
	m_InterestRate.SetParamValue(0.03);
	m_InterestRate.SetTypicalStep(0.01);
	m_ExpiryBucket.DefaultParam()->SetHardLimits(0.0, 99.99);
	m_ExpiryBucket.SetParamValue(3);
	m_ExpiryBucket.DefaultParam()->SetTypicalStep(0.1);
	m_PathNumber.SetTypicalStep(10);
	m_PayOffType = 0;

	m_StrikeBucket.SetParamValue(100.0);
	// Connects the \e reset parameter to the function that does Reset() the average.
	connect(&m_VolBucket, SIGNAL(ValueUpdated(double)), this, SLOT(Reset()));
	connect(&m_InterestRate, SIGNAL(ValueUpdated(double)), this, SLOT(Reset()));
	connect(&m_ExpiryBucket, SIGNAL(ValueUpdated(double)), this, SLOT(Reset()));
	connect(&m_PayOffType, SIGNAL(ValueUpdated(int)), this, SLOT(Reset()));
	connect(&m_StrikeBucket, SIGNAL(ValueUpdated(double)), this, SLOT(Reset()));
	connect(&m_EquationString, SIGNAL(ValueUpdated(QString)), this, SLOT(Reset()));
	connect(&m_Reset, SIGNAL(ValueUpdated(bool)), this, SLOT(Reset()));

	connect(&m_Run, SIGNAL(ValueUpdated(bool)), this, SLOT(StartStopThread(bool)));
	connect(this, SIGNAL(finished()), this, SLOT(StartStopThread()));

	Reset();
}
コード例 #7
0
void GMathScriptEngine::RemoveVariable( GParamString* pName, GParamNum* pParamNum )
{
	m_ParamName_ParamNum.remove(pName, pParamNum);
	UpdateAllVariableNames();
	disconnect(pName, SIGNAL(ValueUpdated(QString)), this, SLOT(UpdateAllVariableNames()));
}