SmartCabs in TCL

SmartCabs are named after the throttle unit that CTI manufactures. Originally the SmartCab variable was only used to communicate with a CTI SmartCab module. In fact it is now the lowest-common denominator in throttle presentation as seen by TCL. It is a structure consisting of four variables:

speed

Defines how fast a train should travel. Values from 0 (stopped) to 100 (full speed) are allowed.

mom

Momentum, also called inertia. Defines how rapidly the train can change speed during acceleration, deceleration and braking. Values range from 0 (no inertia, train changes speed instantly) to 255 (quite gentle speed changes). Note that the values differ from those used in CTIs own software (which was 0 to 7). When used with SmartCab modules only the top 3 bits are used. When used with QTU modules only the top 5 bits are used. When used with other throttles Tcc interprets the inertia itself so all 8 bits are used.

dir

Direction. 0 is forward, anything else is reverse. Note that momentum could mean that if you change direction while the train is moving, is might take a while before the power is actually reversed.

brake

When brake is non-zero the speed sent to the throttle is temporarily set to zero and so the train will slow (gradually if momentum is applied) to a stop. When brake is set back to zero the train will (gradually) resume the speed setting in the speed value.

SmartCabs are used in the following manner:

SmartCabs:  cab1

Actions:
WHEN ... DO cab1.speed=50, cab1.brake=0

It is also possible to assign compound values to a SmartCab:

SmartCabs:  cab1

Actions:
WHEN ... DO cab1 = 50 (BRAKE_OFF, MOMENTUM_3, FORWARD)

The following values are defined for such compound assignments:

FORWARD, REVERSE

Defines direction of travel.

MOMENTUM_0

MOMENTUM_1

...

MOMENTUM_7

The 8 values that CTI SmartCab modules understand. These equate to:

0x00, 0x20, 0x40,... 0xC0, 0xE0

BRAKE_ON, BRAKE_OFF

Brake settings

Any combination of speed, brake, direction and momentum values may be set in a compound assignment and and value not thus assigned retains its previous value. The compound state of the SmartCab can also be read and stored in a regular variable, or one cab can be copied to another:

Variables:  x
SmartCabs:  cab1, cab2

Actions:
WHEN ... DO cab1 = 50 (BRAKE_OFF, MOMENTUM_3, FORWARD, cab2 = cab1
WHEN ... DO x = cab1, cab2 = x
WHEN ... DO x = 20 (BRAKE_OFF), cab1 = x

Note that this compound assignment is special to SmartCabs (and QTUs), it does not work for user-defined structures.

Last updated 27 Sep 2007

© Howard Amos 2005-2007