| 147 | } |
| 148 | |
| 149 | BlueStdResult Tr2ActionBindRTPC::EvaluateExpression( const char* expression, float& value ) const |
| 150 | { |
| 151 | if( !m_controller ) |
| 152 | { |
| 153 | return BlueStdResult( BLUE_STD_RESULT_RUNTIME_ERROR, "controller needs to be running when evaluating expressions" ); |
| 154 | } |
| 155 | Tr2ControllerExpression expr; |
| 156 | auto error = expr.SetExpr( expression, *m_controller, s_extraFunctions ); |
| 157 | if( !error.empty() ) |
| 158 | { |
| 159 | return BlueStdResult( BLUE_STD_RESULT_VALUE_ERROR, error.c_str() ); |
| 160 | } |
| 161 | float time = TimeAsFloat( m_lastSimTime - m_startTime ); |
| 162 | ExtraBuffer buffer = { this, &time }; |
| 163 | auto result = expr.Eval( &buffer ); |
| 164 | if( !result.first ) |
| 165 | { |
| 166 | return BlueStdResult( BLUE_STD_RESULT_RUNTIME_ERROR, "error evaluating expression" ); |
| 167 | } |
| 168 | value = result.second; |
| 169 | return BlueStdResult(); |
| 170 | } |
| 171 | |
| 172 | float Tr2ActionBindRTPC::GetCurveValue( float time ) const |
| 173 | { |