PDA

View Full Version : CMS script wait command toggles from keyboard input ?



fog
26th August 2008, 01:36 PM
Hi!

Setting up to yokes (js1 and js2) to work one one PC, but only one active at the time (similar controls)

my Script:

// CMS Script File
//
script

// Wait for cms button 25 press and
// flip b2 when that happens. The b2 bit will control whether the
// first or second yoke is used.
//
sequence
wait( cms.b25 );
b2 = NOT b2;
endSequence

// Now set up to switch one set of axes/buttons or the other into
// a single set of CMS axes/buttons. This looks backwards, but the
// script will start with b2 OFF and doing it this way makes it
// come up with the first yoke active.
//
if( b2 ) then

// Assign the Yoke 2 X and Y to a1 and a2
//
a1 = js2.a1;
a2 = js2.a2;

// Assign the other Yoke 2 axes to the cms axes
//
cms.a3 = js2.a3;
cms.a4 = js2.a4;
cms.a5 = js2.a5;

// Now switch the rest of the Yoke 2 buttons
//
cms.b2 = js2.b1;
cms.b2 = js2.b2;
cms.b3 = js2.b3;
cms.b4 = js2.b4;
cms.b5 = js2.b5;
cms.b6 = js2.b6;
cms.b7 = js2.b7;
cms.b8 = js2.b8;
cms.b9 = js2.b9;
cms.b10 = js2.b10;
cms.b11 = js2.b11;
cms.b12 = js2.b12;

else

// Assign the Yoke 1 X and Y to a1 and a2
//
a1 = js1.a1;
a2 = js1.a2;

// Assign the other Yoke 1 axes to the cms axes
//
cms.a3 = js1.a3;
cms.a4 = js1.a4;
cms.a5 = js1.a5;

// Now switch the rest of the Yoke 1 buttons
//
cms.b1 = js1.b1;
cms.b2 = js1.b2;
cms.b3 = js1.b3;
cms.b4 = js1.b4;
cms.b5 = js1.b5;
cms.b6 = js1.b6;
cms.b7 = js1.b7;
cms.b8 = js1.b8;
cms.b9 = js1.b9;
cms.b10 = js1.b10;
cms.b11 = js1.b11;
cms.b12 = js1.b12;

endIf

endScriptMy question: is it possible to execute the script from e.g a keyboard button press in this section: ?

wait( cms.b25 );

If i assign e.g "w NULL" to the cms.b25 in CH manager, will pressing the "w" execute the script ?, ore must the input come from a CH device (eg js1.b2 etc..) ?

Freddy

Bob Church
26th August 2008, 07:41 PM
Hi Freddy,

>> Setting up to yokes (js1 and js2) to work one one PC, but only one active at the time (similar controls) ... My question: is it possible to execute the script from e.g a keyboard button press in this section: ? <<

No, it doesn't work. The script can't see the keyboard at all. It only emulates one of it's own, and I can't think of anyway to make that connection.

A couple of notes on the script though, for what they're worth. You don't normally need to bother about the buttons (unless you have a particularly uncooperative student). If he doesn't push them they don't do anything anyway, so if you just switch the axes you're usually in good shape.

Also, there's a TOGGLE device that would be easier to set up then the SEQUUENCE and wait() stuff. It just changes state every time you click it:


script
toggle( d1 ) = js1.b2; // Whatever button to use to switch
if( d1 ) then
// Set up the axes on the second yoke
else
// Set up the axes on the first yoke
endIf
endScript

WRT the switch, I've always thought what I'd do is to watch for a change of maybe 25% on an axis (down elevator probably) on the yoke that wasn't in use at the time. Use that to start a timer, set it long enough to re-center the yoke before it actually made the switch. Then you could just push in quickly on the yoke you wanted to use, then maybe a second later it would actually get control of the aircraft. I've never actually set it, but it would save a button and could undoubtedly be done..

Best regards,

- Bob

The StickWorks
http://www.stickworks.com

fog
26th August 2008, 08:15 PM
Thx alot mate :)

Freddy