//==================================================================
// Code generated automatically
// Description: Experiment class body 
//==================================================================
#include <SATELLITE.test+g+e+o.default.exp+apogee+thrust03.h>

SATELLITE__testGEO_default_expApogeeThrust03* SATELLITE__testGEO_default_expApogeeThrust03::s_current= NULL;
double A01bfbe1edd393b2c1ca09d44c931495b(double degrees);
SATELLITE__testGEO_default_expApogeeThrust03::SATELLITE__testGEO_default_expApogeeThrust03(const char* mgr,const char* installDir,bool dmode):SATELLITE__testGEO_default(mgr,installDir,dmode)
{
m_infoExperimentName = "expApogeeThrust03";
m_infoExperimentFileName = "SATELLITE.test+g+e+o.default.exp+apogee+thrust03";
m_infoExperimentFileNameExtra = "exp+apogee+thrust03";
m_infoExperimentDate = "01/08/2014 10:04:58.592000";

m_perfFlag = false;
filename = "Rep";
Fthrust = 1.;
dt = 1.;
t = 1;
durationON = 0.;
psiyawd = 0.;
thetapitchd = 0.;
phirolld = 0.;
static double __exp_tab_1[] = {0,10,2000,0,0,1};
static INTEG_table tmp_tab[] = { INTEG_table(3, __exp_tab_1+0, 0, NULL, 0, NULL, __exp_tab_1+3)};
tab[0] = tmp_tab[0];
n_typ_exp=0;
nBounds = 4;
if (m_boundaryBranch==NULL)
{
	m_boundaryBranch= new int[4];
	for (int ib=0; ib < 4 ; ib++)
		m_boundaryBranch[ib]= 0;
}
}

void SATELLITE__testGEO_default_expApogeeThrust03::initInternalModels()
{
  SATELLITE__testGEO_default::initInternalModels();
}


void SATELLITE__testGEO_default_expApogeeThrust03::addExptVariables()
{
	ADD_EXPT_VAR( "filename", "STRING",&filename);
	ADD_EXPT_VAR( "Fthrust", "REAL",&Fthrust);
	ADD_EXPT_VAR( "dt", "REAL",&dt);
	ADD_EXPT_VAR( "t", "INTEGER",&t);
	ADD_EXPT_VAR( "durationON", "REAL",&durationON);
	ADD_EXPT_VAR( "psiyawd", "REAL",&psiyawd);
	ADD_EXPT_VAR( "thetapitchd", "REAL",&thetapitchd);
	ADD_EXPT_VAR( "phirolld", "REAL",&phirolld);
	ADD_EXPT_VAR( "tab", "TABLE_1D",&tab);
varHasEquationInBoundBlock("Cntrl_PID1.s_set.signal[1]");
varHasEquationInBoundBlock("Cntrl_PID1.s_set.signal[2]");
varHasEquationInBoundBlock("Cntrl_PID1.s_set.signal[3]");
varHasEquationInBoundBlock("ReactionWheels1.rpmControl[4]");

}


void SATELLITE__testGEO_default_expApogeeThrust03::runExperiment()
{
	RDIGITS = 16 ;
	ABS_ERROR = 1e-008 ;
	REL_ERROR = ABS_ERROR ;
	REPORT_MODE = 3 ;
	filename = "AKM03_180raan6h" ;
	REPORT_TABLE(filename, " Frame1.S.*   Frame1.Qorb[* *logEventsThrusters*  *contr*  *nertia* *COM*   *rpm*    *rpmControl*    *FlagOnOff    *C   *Gain   *Gain*.k*    *Amp*  xx]", 0) ;
	unkS[0] = "21032015060000" ;
	m_needSatisfyResidues = true;
	unkI[2] = 1 ;
	m_needSatisfyResidues = true;
	unkR[406] = 0 ;
	m_needSatisfyResidues = true;
	unkR[395] = 0 ;
	m_needSatisfyResidues = true;
	unkR[295] = 35785835.62 ;
	m_needSatisfyResidues = true;
	unkR[296] = 200000. ;
	m_needSatisfyResidues = true;
	unkR[232] = 179 ;
	m_needSatisfyResidues = true;
	unkR[192] = 0 ;
	m_needSatisfyResidues = true;
	unkR[389] = 0 ;
	m_needSatisfyResidues = true;
	unkR[385] = 5.4 ;
	m_needSatisfyResidues = true;
	unkR[113] = 0 ;
	m_needSatisfyResidues = true;
	unkR[114] = 0 ;
	m_needSatisfyResidues = true;
	unkR[561] = 0 ;
	m_needSatisfyResidues = true;
	TIME = 0 ;
	durationON = 7136 ;
	dt = 18932. - durationON/2. - 600. ;
	t = 1 ;
	addTimedAssignI(&unkI[4+(t-1)], 1, TIME+getAfterExpr(dt,"dt") ) ;
	m_needSatisfyResidues = true;
	addTimedAssignI(&unkI[4+(t-1)], 0, TIME+getAfterExpr(dt + durationON,"dt + durationON") ) ;
	m_needSatisfyResidues = true;
	dt = dt - 0.1 ;
	_vi1 = 1 ;
	while ( _vi1 <= 4 ) {
	addTimedAssignR(&unkR[14922], 100. * _vi1, TIME+getAfterExpr(dt,"dt") ) ;
	m_needSatisfyResidues = true;
	dt = dt + 0.1 ;
	_vi1 += 1 ;
	}
	unkR[538] = 1 ;
	m_needSatisfyResidues = true;
	unkR[533] = 0.1 ;
	m_needSatisfyResidues = true;
	if( unkI[2] == 1 ) {
	unkR[407] = -500000. ;
	m_needSatisfyResidues = true;
	}
	else {
	unkR[407] = 1 ;
	m_needSatisfyResidues = true;
	}
	_vi2 = 2 ;
	while ( _vi2 <= 3 ) {
	unkR[407+(_vi2-1)] = unkR[407] ;
	m_needSatisfyResidues = true;
	_vi2 += 1 ;
	}
	TSTOP = 10 ;
	CINT = 1 ;
	INTEG(&INTEG_simula::s_dummyInt, &INTEG_simula::s_dummyString) ;
	_vi3 = 2 ;
	while ( _vi3 <= 2 ) {
	unkR[407+(_vi3-1)] = -10000 ;
	m_needSatisfyResidues = true;
	_vi3 += 1 ;
	}
	unkR[533] = 1 ;
	m_needSatisfyResidues = true;
	TSTOP = 105332. ;
	CINT = 100 ;
	INTEG(&INTEG_simula::s_dummyInt, &INTEG_simula::s_dummyString) ;
}

void SATELLITE__testGEO_default_expApogeeThrust03::initDefaultsLibraryGlobalsInExp()
{
}

void SATELLITE__testGEO_default_expApogeeThrust03::initDefaultsExp()
{
	unkR[48] = 0 ;
	unkR[57] = 0 ;
	unkR[49] = 0 ;
	unkR[58] = 0 ;
	unkR[50] = 0 ;
	unkR[59] = 0 ;
}

void SATELLITE__testGEO_default_expApogeeThrust03::evalBoundsExp(double TIME)
{
	if (m_boundsLaw)
		{(*m_boundsLaw)(TIME); return;}
	if (m_boundaryBranch[0] == 0)  
		unkR[30] = psiyawd ;
	if (m_boundaryBranch[1] == 0)  
		unkR[31] = sin(A01bfbe1edd393b2c1ca09d44c931495b(44.5)) * timeTableInterp(TIME, tab, -1) ;
	if (m_boundaryBranch[2] == 0)  
		unkR[32] = phirolld ;
	if (m_boundaryBranch[3] == 0)  
		unkR[532] = 0 ;
}
void SATELLITE__testGEO_default_expApogeeThrust03::initDelaysExpt()
{
}
#ifndef SIMULA_USE_GRAPHICAL_MAIN
int main( int argc, char * argv[] )
{
try
{
#ifndef SIMULA_USE_DECK_SYMBOLS
	SATELLITE__testGEO_default_expApogeeThrust03 ecomodel;
#else
	SATELLITE__testGEO_default_expApogeeThrust03 ecomodel(0,0,true);
#endif //SIMULA_USE_DECK_SYMBOLS
	mainLoop(argc, argv, &ecomodel);
}
catch(...)
{
	printf("Program stops due to abnormal condition\n");
}
	return 0;
}
#endif //SIMULA_USE_GRAPHICAL_MAIN
SIMULA_EXPORT_C INTEG_simula* fcnExpCreate(const char *name=NULL,const char *dirInstall=NULL,bool d=false)
{
	return new SATELLITE__testGEO_default_expApogeeThrust03(name,dirInstall,d);
}
SIMULA_EXPORT_C void fcnExpDel(INTEG_simula *obj,const char* name=NULL)
{
	if ( obj )
	{
		obj->deleteManager(name);
		delete obj;
	}
}
SIMULA_EXPORT_C void getInformationExperiment(char *experimentName, bool& isDebug)
{
	sprintf(experimentName,"%s","expApogeeThrust03");
	isDebug = false;
}

#ifndef SIMULA_USE_DECK_SYMBOLS
	extern "C" INTEG_simula* getDeck() {return 0;};
	extern "C" void delDeck(INTEG_simula *obj) {return;}
#endif //SIMULA_USE_DECK_SYMBOLS


