Package jmri.jmrix.loconet.soundloader
Class LoaderEngine
java.lang.Object
jmri.jmrix.loconet.soundloader.LoaderEngine
Controls the actual LocoNet transfers to download sounds into a Digitrax SFX
decoder.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescription(package private) static final int(package private) static final int(package private) LnTrafficController(package private) LocoNetSystemConnectionMemo(package private) static final int(package private) static final int(package private) SpjFile(package private) static final int(package private) static final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()(package private) LocoNetMessageGet a message to erase the non-volatile sound memory(package private) LocoNetMessageGet a message to exit the download process(package private) LocoNetMessageGet a message to initialize the load sequence(package private) LocoNetMessagegetSendDataMessage(int type, int handle, byte[] contents) Get a message to tell the PR2 to store length bytes of data (following)(package private) LocoNetMessagegetStartDataMessage(int type, int handle, int length) Get a message to start the download of data(package private) void(package private) LocoNetMessageinitTransfer(int type, int handle, String name, byte[] contents) Start a sequence to download a specific type of data.Get the next message for an ongoing WAV download.voidNotify of status of download.voidprotectedWait(int millis) Provide a simple object wait.voidrunDownload(SpjFile file) Send the complete sequence to download to a decoder.(package private) voidvoidsendOneWav(int index) (package private) voidsendSDF()(package private) voidDelay to prevent too much data being sent down.
-
Field Details
-
CMD_START
- See Also:
-
CMD_ADD
- See Also:
-
TYPE_SDF
- See Also:
-
TYPE_WAV
- See Also:
-
SENDPAGESIZE
- See Also:
-
SENDDATASIZE
- See Also:
-
spjFile
-
memo
-
controller
-
-
Constructor Details
-
LoaderEngine
-
-
Method Details
-
runDownload
Send the complete sequence to download to a decoder.Intended to be run in a separate thread. Uses "notify" method for status updates; overload that to redirect the messages.
- Parameters:
file- the spjfile to be used.
-
sendSDF
- Throws:
LoaderEngine.DelayException
-
sendAllWAV
- Throws:
LoaderEngine.DelayException
-
sendOneWav
- Throws:
LoaderEngine.DelayException
-
notify
Notify of status of download.This implementation doesn't do much, but this is provided as a separate method to allow easy overloading.
- Parameters:
message- string form of message.
-
throttleOutbound
Delay to prevent too much data being sent down. Works with the controller to ensure that too much data doesn't back up.- Parameters:
m- Throttle message to send- Throws:
LoaderEngine.DelayException- if too much time elapsed before send possible
-
protectedWait
Provide a simple object wait.This handles interrupts, synchronization, etc.
- Parameters:
millis- milliseconds to wait.
-
initTransfer
Start a sequence to download a specific type of data. This returns the message to start the process. You then loop calling nextWavTransfer() until it says it's complete.- Parameters:
type- Either TYPE_SDF or TYPE_WAV for the data typehandle- Handle number for the following dataname- Name of the transfercontents- Data to download- Returns:
- Prepared message
-
nextTransfer
Get the next message for an ongoing WAV download.You loop calling nextWavTransfer() until it says it's complete by returning null.
- Returns:
- message to send.
-
getStartDataMessage
Get a message to start the download of data- Parameters:
type- Either TYPE_SDF or TYPE_WAV for the data typehandle- Handle number for the following datalength- Total length of the WAV data to load- Returns:
- Prepared message
-
getSendDataMessage
Get a message to tell the PR2 to store length bytes of data (following)- Parameters:
type- Either TYPE_SDF or TYPE_WAV for the data typehandle- Handle number for the following datacontents- Data to download- Returns:
- Prepared message
-
getEraseMessage
Get a message to erase the non-volatile sound memory- Returns:
- Prepared message
-
getInitMessage
Get a message to initialize the load sequence- Returns:
- Prepared message
-
getExitMessage
Get a message to exit the download process- Returns:
- Prepared message
-
initController
void initController() -
dispose
-