Well, headings are a bitch to process. Usually I end up with something like this (that's from Shuttle contingency flight AP rules which need to cope with all sorts of angular shit, like flying 106 deg pitch, flying with beta = 180 degree,...)
- Code: Select all
<fcs_function name="systems/ap/contingency/heading-arg-raw">
<function>
<abs>
<difference>
<property>/orientation/heading-deg</property>
<property>velocities/course-deg</property>
</difference>
</abs>
</function>
</fcs_function>
<fcs_function name="systems/ap/contingency/heading-arg-subtracted">
<function>
<abs>
<difference>
<property>systems/ap/contingency/heading-arg-raw</property>
<value>360.0</value>
</difference>
</abs>
</function>
</fcs_function>
<switch name="systems/ap/contingency/heading-arg">
<default value="systems/ap/contingency/heading-arg-raw"/>
<test value="systems/ap/contingency/heading-arg-subtracted">
systems/ap/contingency/heading-arg-raw GT 180.0
</test>
</switch>
<switch name="systems/ap/contingency/heading-sign">
<default value="1"/>
<test value="-1">
systems/ap/contingency/heading-arg GT 90.0
</test>
</switch>
so basically you compute two different solutions corresponding (in your case) to counting up and counting down and then use a switch to decide which to use and feed to the time-delayed tag as target.
Also, you probably need to run it through a post-processing filter using <mod> to make 0 = 360. So this is all possible using JSBSim elements, but hardly elegant.
(I seem to have read somewhere that FG-native AP components can actually handle angles if some option is set, but I never used them much).