Page 1 of 1

makemdl code

PostPosted: Fri Jan 21, 2011 3:12 am
by rich1959
Hi all
  A new kid on the block. so thought I would say hi.and see if I could  find
a little help or a pointed in the right way.
this is a default makemdl.xml code.that I would like to control with
THROTTLE POSITION. I only want it to work the first 20%.
I only want workable suggestion so I can learn to put it togather,
that my way learning ;)

            Rich







-
  engine_rocker_arm
-
-
-
  (A:GENERAL ENG ELAPSED TIME:1,RPM) (A:GENERAL ENG RPM:1,RPM) * 100 %
-
 

 

 

 

Re: makemdl code

PostPosted: Fri Jan 21, 2011 3:44 am
by JakesF14
Hi,
From what I understand, you want to make your engine Rocker only animate (work) when the throttle is 20% and less?

I am not an xml expert, but try this: I haven't test it:

Rename your part to Rocker01, and then in your MakeMDLparts.xml, add this script:

Code: Select all
<part>
      <name>rocker01</name>
      <animation>
         <parameter>
            <code>
                (A:GENERAL ENG ELAPSED TIME:1,RPM) (A:GENERAL ENG RPM:1,RPM) * 100 %
                (A:PROP RPM:1,RPM) 60 / (A:GENERAL ENG ELAPSED TIME, millisecond) * 100 %
                (A:PROP RPM:1,RPM) 60 / (E:ABSOLUTE TIME, second) * 100 %
                (A:GENERAL ENG ELAPSED TIME:1,RPM) 60 / (E:ABSOLUTE TIME, second) * 100 %
            (A:GENERAL ENG THROTTLE LEVER POSITION, percent) 20 <
            </code>
         </parameter>
      </animation>
   </part>


Hope it work. let me know, if it don't work, I can try and figure out something else.

enjoy!

Re: makemdl code

PostPosted: Sat Jan 22, 2011 3:50 am
by rich1959
Hi JakesF14
   thanks for the come back. your code stared me thinking in
a different way. I found a line of code in make mdl, and with a little tweaking, it is working it start and stop with throttle
position. the only thing is it work in REVERSE.and I can not
reverse it. I do need some Help



   
      rocker01
      
         
            
                (A:GENERAL ENG ELAPSED TIME:1,RPM) (A:GENERAL ENG RPM:1,RPM) * 15 %
                (A:GENERAL ENG THROTTLE LEVER POSITION:1, part) s0 0 >= if{ l0 * 50 + } els{ l0         
                
          

         

      

   


   Rich
how did you put your code in a window

Re: makemdl code

PostPosted: Sat Jan 22, 2011 2:24 pm
by Fr. Bill
Your script is missing the final curly-brace to close the expression. To post using the code box, highlight your entry then click the # button on the editor's toolbar!
[code]

Re: makemdl code

PostPosted: Sun Jan 23, 2011 3:07 am
by rich1959
FR Bill
  thanks for tips but still no joy. the code works right and does what I want but in reverse,
it animate from about 30% to 100%. I need it to animate from 0% TO 20 OR 30% OF
The throttle lever.
I think the answer might be in the  s0  l0  code but any thing I tried did not work.
  thanks for you help
              Rich
Code: Select all
  <part>
      <name>rocker01</name>
       <animation>
         <parameter>
            <code>
                (A:GENERAL ENG ELAPSED TIME:1,RPM) (A:GENERAL ENG RPM:1,RPM) * 15 %
                (A:GENERAL ENG THROTTLE LEVER POSITION:1, part) s0 0 >= if{ l0 * 50 + } els{ l0 }
            </code>
         </parameter>
      </animation>
   </part>

Re: makemdl code

PostPosted: Mon Jan 24, 2011 3:05 am
by JakesF14
Hey, How about trying the throttle position as percentage, like this:

Code: Select all
<part>
      <name>rocker01</name>
       <animation>
         <parameter>
            <code>
                (A:GENERAL ENG ELAPSED TIME:1,RPM) (A:GENERAL ENG RPM:1,RPM) * 15 %
                (A:GENERAL ENG THROTTLE LEVER POSITION:1, percent) 30 <
            </code>
         </parameter>
      </animation>
   </part> 


as said, I'm not a Boffin. Fr Bill is the master of XML coding!

Re: makemdl code

PostPosted: Mon Jan 24, 2011 3:15 am
by rich1959
Hi
well I got it working by changing the word part to percent.
I would like to thank you both for your help
      RICH
Code: Select all
  <part>
    <name>rocker01</name>
      <animation>
         <parameter>
          <code>
            (A:GENERAL ENG ELAPSED TIME:1,RPM) (A:GENERAL ENG RPM:1,RPM) * 15 %
            (A:GENERAL ENG THROTTLE LEVER POSITION:1, percent) s0 0 >= if{ l0 * 50 + } els{ l0 } 

           </code>
         </parameter>
       </animation>
   </part>

Re: makemdl code

PostPosted: Mon Jan 24, 2011 6:11 am
by JakesF14
Pleasure! Im also most of the time active on fsworld.co.za chat function if you want a quicker answer.

Enjoy!

Re: makemdl code

PostPosted: Tue Mar 01, 2011 1:14 am
by rich1959
HI Back for some more of that wonderfull help
   FATHER bill if you read this I WOULD LIKE TO SAY thanks YOU for your TUT
on center off switchs.

  I have 5 of them working, this one is a nose wheel Tiller control and by it self work
grat, but when I coupled it to the THROTTLES control gauge. It only see the down
cleck and missis the up cleck. and I have ran out of ideas

              Richard

    fs9, makemdl,  fsds351






Code: Select all
   <part>
      <name>Tiller</name>
      <animation>
         <parameter>
         <code>50 (A:Rudder Position,enum) 50 * +</code>
            <lag>900</lag>
         </parameter>
      </animation>
        <mouserect>
            <cursor>Hand</cursor>
            <tooltip_text>Tiller_Left/Right_cleck</tooltip_text>                                                <mouse_flags>LeftSingle+RightSingle+LeftRelease+RightRelease+DownRepeat</mouse_flags>
            <callback_code>
                  (M:Event) 'LeftSingle' scmp 0 == 
                       if{ 1 (>A:Rudder Position, enum) (>K:RUDDER_LEFT) }   
                 (M:Event) 'LeftRelease' scmp 0 == 
                       if{ 0 (>A:Rudder Position, enum) (>K:RUDDER_CENTER) }
                 (M:Event) 'RightSingle' scmp 0 == 
                       if{ -1 (>A:Rudder Position, enum) (>K:RUDDER_RIGHT) }
                 (M:Event) 'RightRelease' scmp 0 == 
                       if{ 0 (>A:Rudder Position, enum) (>K:RUDDER_CENTER) }
            </callback_code>
      </mouserect>
   </part>



Code: Select all
<Gauge Name="db-THROTTLES2" Version="1.0">
   <Image Name="throttles_background.bmp"/>
   <Element>
      <Shift>
         <Value>(A:TAILWHEEL LOCK ON,bool) if{ g2 } (A:AIRSPEED INDICATED, Knots) 20 > if{ g2 }  (A:Rudder deflection pct,percent) 4 / s0 2 > if{ l0   2 - (A:General Eng2 Throttle Lever Position, percent) + 163 * (>K:THROTTLE1_SET) g2 } l0 -2 < if{ l0 /-/  2 - (A:General Eng1 Throttle Lever Position, percent) + 163 * (>K:THROTTLE2_SET) g2 }:2 0</Value>
      </Shift>
   </Element>
</Gauge>

Re: makemdl code

PostPosted: Fri Mar 11, 2011 3:37 pm
by Fr. Bill
You can't modify A:variables!

1 (>A:Rudder Position, enum)

This will do nothing at all.

Did you mean to use:

1 (>L:Rudder Position, enum)

Re: makemdl code

PostPosted: Sun Mar 13, 2011 12:54 am
by rich1959
HI fr. Bill
   thanks for the come back. Ok I changed the A to L and got a mix bag.
On the plus side the tiller wheel no longer follow my rudder pedals.
But minus side the tiller wheel moved like a toggle switch (on off )
with the A prefix, the tiller wheel follow the slow rudder Position.
so the sim is controling,  how this code works and is far more realest,
so I would perfer to keep the A prefix.

Rudder Position, is listed in Parameters.doc
The L prefix had no effect on how the Throttle gauge work.

also I tried (A:Rudder deflection pct,percent) the tiller didn't
work as well and no effect on how the Throttle gauge work

  So back to original question. when I try to used the Throttle control
gauge. It only reads the LeftSingle+RightSingle and does not read
LeftRelease+RightRelease. But if I tap the mouse button I just Release
the Throttle will return to idle.

New Question  Can one add a Condition to A 3 Position spring loaded switch?
if so, would you have a working model that I could used as a reference.


        thanks  RICH

Re: makemdl code

PostPosted: Mon Mar 14, 2011 11:07 am
by Fr. Bill
Everything listed in the "parameters.doc" file are read only variables. You cannot "set" or "control" read only variables. Period.

How you control stuff is listed in the "EventIDs.doc" file.

In simpler words, this: (>K:RUDDER_LEFT) controls this: (A:Rudder Position,percent), which is why the script you've tried actually did rotate with the rudder control.

I'm not clear on what any throttle position would have to do with either rudder control or tiller steering though!

Working examples of XML scripts are in the "Working XML Code Library..." forum at freeflight design:

http://www.aerodynamika.com/cgi-bin/yab ... ?board=XML