User Tools

Site Tools


text-gen-en

Text General

ID

A unique ID, which is used by Rocrail to address the element. This ID is usually assigned by Rocrail.

Text

This attribute stores the string, which should be displayed in the track plan and can be changed here.

Image

Select the path to an image using this button, to show an image instead of a simple text.
Note: Only ".png" files will be displayed as an image. See also: Display an image

Refresh

Image refresh time in ms which can be used for WebCam pictures.
This option must be greater the 99 to be activated.
In case of a static image this value should be zero to prevent deleting the file.

Tip

Tooltip for this element.
Is the field empty, the ID will shown as tooltip.

Color

Button Function
Text the normal color of the text; or the text color of toggle state OFF
Active text the text color of toggle state ON, if Text Type = Toggle switch
Border the text color of the border, if Border = ON

Background

Background color can only be set by using the Background item in the Context menu.
To get a transparent background (then the Track plan color will be shown) is necessary to set there the Background color to "black".

Point size

With this attribute the font size of the text may be changed.
0 (default) means the standard value of the operating system.

CX/CY

The raster width and height of the text object.


Type

Text

Default type for normal text.

Webcam

Input field

Pop up an text entry dialog, on left mouse click, to modify the text.
Text values can be used as condition in actions.

Fast clock

Enables the fast clock popup in some clients:

Slider

Vertical slider. For more information see: Slider.

  • Note: Regardless of the alignment of the text object or a rotation of the track plan, the slider direction is always vertical.

Attributes

HTML

Render HTML instead of plain text.
Use this in combination with a Location Timetable.
Note: This option is ignored in case pipe, '|', characters are in the text.

Train Image

text-trainimg-en.jpg
The locomotive and its assigned train can be visualised if the action is triggered by a block.
The action only needs the command update and no text by the following states:

  • enter
  • occupied
  • in
  • free

The text field width should be long enough to contain the longest train.
Images are expected with a height of 80 pixel and will be scaled down to fit in height to one raster cell.

Reset

Reset the saved text content at startup; Useful for dynamic text.

Border

Draws a border around the text field.

Mirror image

In case the text points to an image it will be mirrored horizontally.

Blink the text incase Refresh > 99.
A good refresh value is 500.

Min./Max.

Values at the min. and max. positions of the slider.

Orientation

Default is horizontal.

Text Format

Character Rule
| New line

If dynamic text starts with the new line char it will be appended to the existing text.
For HTML text the new line char id replaced by "<br>". (15607+)

Example

"Regel 1|Regel 2|Regel 3"



Display an image


If the text ends with .png (only .png is allowed) the text object will try to find the matching image in the Imagepath.
The image will be scaled, with respect to the image aspect, to fit the text size as defined on the Position Tab.

Display a live stream

if the text starts with mjpg: it will be interpreted as a HTML MJPEG live stream.
Format:

mjpg:<host>:<port>


Actions

An action can be used to let the text be spoken by a program like espeak on the server.

To have textfields updated by a block be spoken on the client, read Speak command.

This action will only be executed when this text object is update by a Text action. (See Dynamic text).

Example for an action to speak the updated
text could look like this.
In the 'properties' of the text-element this action needs to be
linked to this text object using the actioncontrol dialog like this.

Dynamic text

Dynamic text is text that is updated or changed through an action.
A text object needs to be created in the track plan to contain the dynamic text. It is not important what text is written in the field as this will be changed through the action that controls the text object and therefore can be left blank.
It is important that the width of the text object (Cx in the Position tab) be wide enough to contain all the text that will be written here by the action. Also make a note of the ID of the text object. This will be needed when the action that will change the text will be defined.



Defining the action

From the Tables menu, choose the Actions table and create a new action by clicking on New.
In the field Type choose Text, in the field ID choose the ID of the text object you have just created above and in the Command field choose Update (it is the only option).
The Parameter field will contain the text that will appear in the associated text object. E.g. The train in %bkid% is the %lcid%. The text between the % are the variables that will be updated every time the action is carried out.



Variables

Built in
General
%year% Model year part of time
%mon% Model month part of time
%mday% Model month day part of time
%wday% Model week day part of time
%hour% Model hour part of time
%min% Model minute part of time
%sec% Model seconds part of time: Only available if Action timer 60sec is disabled.
%sunriseH% Sunrise hour (Rocrail properties → Service → Location)
%sunriseM% Sunrise minute
%sunsetH% Sunset hour
%sunsetM% Sunset minute
%temp% Model temperature, or HUE sensor temperature.
%temp100% HUE sensor temperature in hundreds of degrees.
%bri% Brightness by weather or HUE sensor.
%lux% HUE sensor lux.
%pressure% Sensor pressure in hPa.
%humidity% Sensor humidity in percent.
%syshour% System hour part of time
%sysmin% System minute part of time
%syssec% System seconds part of time: Only available if Action timer 60sec is disabled.
%callerid% The ID of the object which called this action.
%calleraddr% The address of the object which called this action.
%callertype% The type of the object which called this action.
%callerdesc% The description of the object which called this action.
%calleruserdata% The user data of the object which called this action.
%state% The state of the calling object.
%substate% The sub state of the calling object.
%desc% The Description of the calling object.
Loco & Car
%lcid% Loco ID
%lcaddr% Loco address
%lcshortid% Loco short ID
%lcclass% Loco/Train Class
%lcbes% Loco block enter side as '<' or '>'
%lcident% or %lccode% Loco code (RFID, Railcom, Lissy, Barcode…)
%lcimg% Loco image
%lccur% Loco current block
%lccurtrack% Loco current track in the block (StagingBlock, Turntable, FiddleYard)
%lcdest% Loco destination
%lcdesc% Loco description
%lcnr% Loco number
%lchome% Loco home location
%lchomedesc% Loco home location description
%lcdir% Loco direction: "fwd"/"rev"
%lcplacing% Loco placing: "norm"/"swap"
%lccargo% Loco or train cargo(type): Train types
%lcengine% Loco engine: "diesel", "electric", "steam", "automobile"
%lclen% Loco or train length
%lcweight% Loco or train weight
%operatorid% Operator ID in case the loco has an assigned train
Car
%carid% Car ID
%cartype% Car type: goods, passenger
%carsubtype% Car subtype: boxcar, gondola, flatcar, reefer, stockcar, tankcar, wellcar, hopper, caboose, autorack, autocarrier, logdumpcar, coilcar, coach, lounge, dome, express, dinner, sleeper, baggage, postoffice
%carimg% Car image
%carlocation% Car location
%operatorid% Operator ID in case the car is part of the train
%operatorlocoid% Loco ID in case the car is part of a train and the train is assigned to a loco
%waybill% The waybill ID assigned to this car.
%waybilldest% The destination of the assigned waybill to this car.
Switch
%swid% Switch ID (XmlScript foreach)
%swtype% Switch type (XmlScript foreach)
%swdesc% Switch description (XmlScript foreach)
Output
%coid% Output ID (XmlScript foreach)
%cotype% Output type (XmlScript foreach)
%codesc% Output description (XmlScript foreach)
BiDi Code
%bidicode% Loco or car code scanned by a sensor.
%bidicode2id% Loco or car ID which match the scanned code by a sensor.
%bidicode2img% Loco or car code scanned by a sensor.
If a loco or car is found with this code the image name, if set, will replace the code text.
Schedule
%lcscid% Schedule ID
%lcscbk% Schedule block ID
%lcscbkloc% Schedule block location
%lcschour% Schedule departure hour
%lcscmin% Schedule departure minute
%lcscnextbk% Schedule next block ID
%lcscnextbkloc% Schedule next block location
%lcscprevbk% Schedule previous block ID
%lcscprevbkloc% Schedule previous block location
%callertext% Content of the 'Text' field
%lcscfirstlocation% First location or block in the schedule
%lcsclastlocation% Last location or block in the schedule
Block
%bkid% Block ID
%bkloc% Block location name
%bkdesc% Block description
%frombkid% Coming from block
%frombkloc% From block location name
%frombkdesc% Coming from block description
%bkmvspeed% Speed measured in block (use it with state 'free'¹)
%bklen% Block length
Turntable
%regval% Bridge position.
Sensor
%counter% Number of state ON events.
%carcount% Car counter.
%countedcars% Counted cars.
%wheelcount% Wheel counter.
%regval% Register value.
Booster
%load% Load in mA
%volt% Voltage in mV
%boostertemp% Temperature in °C
MVTrack
%mvspeed% Measured speed in KM/H
%mvtrainlen% Measured Train length in mm
Text
$txtID The text of a text object
@txtID The text value of a text object.

¹) Hint: %bkmvspeed% will be updated on the in-event. The next event which can be used to trigger the update of the text is the change to status 'free'. If you trigger the update on other stati, you will get the last measured speed (which might differ from the actual one.)

User Variables

User Variables
#varID or with Sub-ID #varID%lcid% The integer value
@varID The text value of a variable.
@@nvarID The indexed, n=0…99, text value of a variable. The text value must be a comma separated list.
##nvarID The indexed, n=0…99, text value of a variable converted in an integer. (atoi) The text value must be a comma separated list.
~varID A pointer to the variable text or value; Depends from XMLScript command: value="~varID" or text="~varID"


Environment Variables

All defined environment variables can also be used:
"Good morning %USER%."
(consider in Windows: %USERNAME%)

will be evaluated like this:
"Good morning rob."

Associating the action

The next step is to choose the object that will be associated with the action.
In the example above it would be the block for which the dynamic text will be updating with the loco ID. Therefore if the block that is being associated with the action is block LP1 and the next train to enter the block is 3MT, the text object would read "The train in LP1 is the 3MT".
Following the example the Properties of block LP1 are chosen. In the Actions submenu the action that changes the dynamic text is chosen from the list in the ID field. The State field should read enter so that the action is initiated when a train enters the block.



Speak to me

loudspeaker.jpg

espeak

espeaking the updated text

There are two options to have the updated text read e.g. by espeak:

  1. Use the speakcommand –> this will be executed on the client computer.
  2. Configure an extra action as shown here –> this will be executed on the server computer.

Examples with sound files and espeak

A Linux script with the content:

mplayer jingle.wav;
espeak -vde+f2 " $* ";

will play a jingle before the dynamic text is spoken.


A Windows batch could look like this:

c:\playwav ns.wav
c:\espeak -vnl+m3 %1%
exit

Just put the code in a .bat file, like sound.bat. Just call that .bat file from an action connected with a text object in Rocrail.
The %1% will be replaced by the dynamic text that comes from Rocrail

or:

sndrec32 /play /close /embedding c:\sound\gong.wav
C:\Programme\eSpeak\command_line\espeak.exe -v de+f2 %* 

Notes:
In some Windows versions for "sndrec32.exe" other folders are necessary. Please look here

The examples of commands in scripts or batch files with sounds and "espeak" can also be used individually.
If only a single command line should be done, it can be even without a script or batch file entered directly in the command field of the action.

Balabolka

The Microsoft Speech Platform offers better quality voices in various languages including English, German, Dutch and Italian.

To install on your computer follow these instructions:

1. Download and install the Speech Platform Runtime http://www.microsoft.com/download/en/details.aspx?id=27225 (the file 'x86_SpeechPlatformRuntime\SpeechPlatformRuntime.msi').

2. Download and install Runtime Languages for use with the Speech Platform http://www.microsoft.com/download/en/details.aspx?id=27224 (files with names starting with 'MSSpeech_TTS_').

However these languages cannot be run from command line espeak. Balabolka is a free to use program that can be used to run Microsoft Speech Platform as default. It can be downloaded from here http://www.cross-plus-a.com/balabolka.htm

Choose the tab Microsoft Speech Platform and you will find the language you have downloaded. Closing the program now and this set this voice as your default. Balabolka can be run in command line mode too.

playwav ns.wav 
c:\Balabolka\balabolka.exe -rmnq %1%
exit

With the above parameters Balabolka reads your dynamic text in a minimized form and then quits after the text is read. It is important that for this to work, the Action that calls up the batch file comes from the cell that contains the dynamic text.

Other voices such as those produced by AT&T can be bought if you wish even more better sounding voices.

Balabolka can also save the read text in the program into .WAV or MP3. format. These can be used to create batch files that can be called up from Rocrail upon specific events as explained in the note above for espeak. e.g. A specific station announcement is played only when a specified locomotive enters a specific block http://youtu.be/t1Zffyg4FOQ

macOSX: Use the "say" command.


Downloads

text-gen-en.txt · Last modified: 2024/02/18 18:13 by rjversluis