c172p-team / c172p

A high detailed version of the Cessna 172P aircraft for FlightGear
GNU General Public License v2.0
82 stars 43 forks source link

Hobbs calculates both engine hours combined #1424

Closed wlbragg closed 1 year ago

wlbragg commented 1 year ago

The Hobbs meter is calculating both engines as one engine. The engine change-outs are meant to be different aircraft and engine hours should be calculated separately.

wlbragg commented 1 year ago

@dany93 I know I am kind of jumping around here. But does this look like this is combining the engine hours of the 180hp and 160hp engines instead of saving their individual usage? Would you know why, don't you think these should be saved and displayed per their individual usage?

Specifically the line hobbs = (hobbs_160hp + hobbs_180hp) / 3600.0;

init_hobbs_meter(0, hobbsmeter_engine_160hp);
init_hobbs_meter(1, hobbsmeter_engine_180hp);

var update_hobbs_meter = func {
    # in seconds
    var hobbs_160hp = getprop("/sim/time/hobbs/engine[0]") or 0.0;
    var hobbs_180hp = getprop("/sim/time/hobbs/engine[1]") or 0.0;
    # This uses minutes, for testing
    #hobbs = hobbs / 60.0;
    # in hours
    hobbs = (hobbs_160hp + hobbs_180hp) / 3600.0;
    # tenths of hour
    setprop("/instrumentation/hobbs-meter/digits0", math.mod(int(hobbs * 10), 10));
    # rest of digits
    setprop("/instrumentation/hobbs-meter/digits1", math.mod(int(hobbs), 10));
    setprop("/instrumentation/hobbs-meter/digits2", math.mod(int(hobbs / 10), 10));
    setprop("/instrumentation/hobbs-meter/digits3", math.mod(int(hobbs / 100), 10));
    setprop("/instrumentation/hobbs-meter/digits4", math.mod(int(hobbs / 1000), 10));
};
wlbragg commented 1 year ago

There is also a filter using the total hours as well. I don't understand why we are combining the different engine use hours?

    <filter>
        <name>Engine Total Hobbs Hours</name>
        <type>gain</type>
        <input>
            <expression>
                <div>
                    <sum>
                        <property>/sim/time/hobbs/engine[0]</property>
                        <property>/sim/time/hobbs/engine[1]</property>
                    </sum>
                    <value>3600.0</value>
                </div>
            </expression>
        </input>
        <output>
            <property>/instrumentation/clock/hobbs-meter-hours</property>
        </output>
    </filter>

Turns out this filter is not being used by anything as far as I can find. I added a hobbs meter to the J3/PA-18 and changed the code to save engine hours by engine size. I can easily do that to the c172p. Would like to hear any opinions as to why or why not that would be a good idea.

wlbragg commented 1 year ago
          > I know I am kind of jumping around here. But does this look like this is combining the engine hours of the 180hp and 160hp engines instead of saving their individual usage? Would you know why, don't you think these should be saved and displayed per their individual usage?

I didn't write these lines but I agree, that would be logical. This is not the same aircraft.

However, I have the impression that almost nobody looks at this Hobbs meter values. Is it worth making the files more complicated?

As you wrote, no connection with out current PFD issue.

Originally posted by @dany93 in https://github.com/c172p-team/c172p/issues/1421#issuecomment-1640251609

wlbragg commented 1 year ago
          On 7/18/23 9:41 AM, dany93 wrote:
I know I am kind of jumping around here. But does this look like this is
combining the engine hours of the 180hp and 160hp engines instead of saving
their individual usage? Would you know why, don't you think these should be
saved and displayed per their individual usage?

I didn't write these lines but I agree, that would be logical. This is not the same aircraft.

i tend to agree...

However, I have the impression that almost nobody looks at this Hobbs meter values. Is it worth making the files more complicated?

when i flew the c172p more often, i kept up with it... even going so far as to manually copy the value to put in the new aircraft-data file when i cleared it for some reason...

i didn't really think about the different configurations being different craft but it makes perfect sense... if we had them as variants via separate -set files instead of internal configuration switching, it might be easier to keep them separated... idk... my code reading (and coding) isn't what it used to be...

Originally posted by @wkitty42 in https://github.com/c172p-team/c172p/issues/1421#issuecomment-1640321476

wlbragg commented 1 year ago

if we had them as variants via separate -set files instead of internal configuration switching, it might be easier to keep them separated

Well we kind of do, When I set up the existing variants I made distinct combinations like the amphibious and special undercarriages used the 180 engine because it was most likely to be that configuration IRL. Where the standard and bush gear use the 160. So there is that. The only thing I didn't make was variants for each engine type combined with each undercarriage. If we made all those startup variants, then you wouldn't absolutely have to have the in-sim change available. But it is nice to be able to switch them on the fly.

Is it worth making the files more complicated? It's only a few lines of code. I went ahead and did it for the Cub/PA-18. I'm going to make another issue and copy this conversation over to it and make the change. I was quite surprised it hadn't already been done.

wkitty42 commented 1 year ago

On 7/18/23 12:22 PM, wlbragg wrote:

Turns out this filter is not being used by anything as far as I can find. I added a hobbs meter to the J3/PA-18 and changed the code to save engine hours by engine size. I can easily do that to the c172p. Would like to hear any opinions as to why or why not that would be a good idea.

i think it would be a GoodThing... more realistic, i think...