Jump to content
Sign in to follow this  
dragonflightdesign

Just looking for confirmation that SAT and TAT are not broke

Recommended Posts

Both of these return zero for me at all altitudes and speeds. I have to assume that I'm not seeing the wood for the trees - would someone be kind enough to point out my error? RANKINE_TO_CELSIUS does work, BTW.

//**************************************************************************// Standard atmospheric temperature//**************************************************************************double getSAT(double temp){	double data=0;	execute_calculator_code("(A:STANDARD ATM TEMPERATURE, rankine)",&data,NULL,NULL);	return(RANKINE_TO_CELSIUS(data));}//---snip---//double temp=0;getSAT(temp);sprintf(pelement->string, "%30s%4.0f","Standard ATM temp (celsius) = ",temp);//**************************************************************************// Total air temperature - air temp at the front of the aircraft with ram pressure//**************************************************************************double getTAT(double temp){	double data=0;	execute_calculator_code("(A:TOTAL AIR TEMPERATURE, celsius)",&data,NULL,NULL);	return data;}//---snip---//double temp=0;getTAT(temp);sprintf(pelement->string, "%27s%4.0f","Total air temp (celsius) = ",temp);

Many thanks.-Dai

Share this post


Link to post
Share on other sites

SAT works, but I don't know if 'rankine' works since I obtain it as a celcius directly. TAT... I use the default token var TOTAL_AIR_TEMP and not an execute_calc call.


Ed Wilson

Mindstar Aviation
My Playland - I69

Share this post


Link to post
Share on other sites

Huh - these work. Go figure....

sprintf(pelement->string, "%27s%4.0f","Total air temp (celsius) = ",getTAT(temp));//sprintf(pelement->string, "%30s%4.0f","Standard ATM temp (celsius) = ",getSAT(temp));

-Dai

Share this post


Link to post
Share on other sites

Out of curiosity... why are you doing this:

sprintf(pelement->string, "%30s%4.0f","Standard ATM temp (celsius) = ",getSAT(temp));

instead of this:

sprintf(pelement->string, "Standard ATM temp (celsius) = %4.0f",getSAT(temp));

It's less code execution to do the latter, fewer CPU cycles, etc. Also, why are you passing 'temp' as a variable that's unused in the function?


Ed Wilson

Mindstar Aviation
My Playland - I69

Share this post


Link to post
Share on other sites

Simple answer Ed - because I've never known any other way to do it. As for passing 'temp' - in the original code

//**************************************************************************// Standard atmospheric temperature//**************************************************************************double getSAT(double temp){	double data=0;	execute_calculator_code("(A:STANDARD ATM TEMPERATURE, rankine)",&data,NULL,NULL);	return(RANKINE_TO_CELSIUS(data));}//---snip---//double temp=0;getSAT(temp);sprintf(pelement->string, "%30s%4.0f","Standard ATM temp (celsius) = ",temp);

-if I didn't pass in a variable to contain the return, I got a compiler error. Maybe that changes with the way you're suggesting?-Dai

Share this post


Link to post
Share on other sites

This should compile and work:

double getSAT(){	double data=0;	execute_calculator_code("(A:STANDARD ATM TEMPERATURE, celcius)",&data,NULL,NULL);	return data;}double temp=0;temp = getSAT();sprintf(pelement->string, "Standard ATM temp (celsius) = %4.0f",temp);


Ed Wilson

Mindstar Aviation
My Playland - I69

Share this post


Link to post
Share on other sites

Which it does, of course! :( Thanks for the lesson Ed (stares dully at the lines and lines and lines of code that could be changed....).-Dai

Share this post


Link to post
Share on other sites

This also should work:

double getSAT(){	double data=0;	execute_calculator_code("(A:STANDARD ATM TEMPERATURE, celcius)",&data,NULL,NULL);	return data;}sprintf(pelement->string, "Standard ATM temp (celsius) = %4.0f",getSAT());


Ed Wilson

Mindstar Aviation
My Playland - I69

Share this post


Link to post
Share on other sites

It does... ironically enough, I just stumbled across that by accident - a typo almost!-Dai

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Tom Allensworth,
    Founder of AVSIM Online


  • Flight Simulation's Premier Resource!

    AVSIM is a free service to the flight simulation community. AVSIM is staffed completely by volunteers and all funds donated to AVSIM go directly back to supporting the community. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. Thank you for your support!

    Click here for more information and to see all donations year to date.
  • Donation Goals

    AVSIM's 2020 Fundraising Goal

    Donate to our annual general fundraising goal. This donation keeps our doors open and providing you service 24 x 7 x 365. Your donation here helps to pay our bandwidth costs, emergency funding, and other general costs that crop up from time to time. We reset this goal every new year for the following year's goal.


    53%
    $13,405.00 of $25,000.00 Donate Now
×
×
  • Create New...