Fix missing random sim command

(cherry picked from commit 3ce4a5bf7f)
This commit is contained in:
Seth Hillbrand 2023-10-24 13:57:34 -07:00
parent 93b5038382
commit 1290cf6241
1 changed files with 16 additions and 17 deletions

View File

@ -141,27 +141,26 @@ std::string SPICE_GENERATOR_SOURCE::ItemLine( const SPICE_ITEM& aItem ) const
case SIM_MODEL::TYPE::V_RANDUNIFORM:
case SIM_MODEL::TYPE::I_RANDUNIFORM:
{
/* TODO
args.append( "1 " );
args.append( getParamValueString( "dt", "0" ) + " " );
args.append( getParamValueString( "td", "0" ) + " " );
std::string min = getParamValueString( "min", "0" );
std::string max = getParamValueString( "max", "0" );
SIM_VALUE_FLOAT min = dynamic_cast<SIM_VALUE_FLOAT&>( m_model.FindParam( "max" )->value );
args.append( min + " " );
args.append( max + " " );
if( !min.ToString().empty() )
min.FromString( "0" );
double minVal = std::stod( min );
double maxVal = std::stod( max );
SIM_VALUE_FLOAT max = dynamic_cast<SIM_VALUE_FLOAT&>( m_model.FindParam( "min" )->value );
double rangeVal = maxVal - minVal;
double offsetVal = ( maxVal + minVal ) / 2;
if( !max.ToString().empty() )
max.FromString( "0" );
std::string range = std::to_string( rangeVal );
std::string offset = std::to_string( offsetVal );
SIM_VALUE_FLOAT range = max - min;
SIM_VALUE_FLOAT offset = ( max + min ) / SIM_VALUE_FLOAT( 2 );
args.append( range.ToSpiceString() + " " );
args.append( offset.ToSpiceString() + " " );
*/
args.append( range + " " );
args.append( offset + " " );
break;
}