public class iRacingSIMPlugin extends SIMPlugin
SIMPlugin.Callback, SIMPlugin.SIMPluginException
Constructor and Description |
---|
iRacingSIMPlugin() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes the connection to the SIM and kills any threads it may have spawned.
|
IODriver |
getIODriver() |
Session |
getSession()
Returns an instance to the SIM's session.
|
Data |
getSIMData(java.lang.String... args)
This gets called when the path specifies a specific SIM should return the data.
|
boolean |
isActive()
3 methods work together to poll the SIM for data (isActive, waitForDataReady, isConnected).
|
boolean |
isConnected() |
Data |
setPlay(java.lang.String file)
Sets the filename to be played back.
|
Data |
setRecord(java.lang.String file)
Sets the filename to record this session to.
|
boolean |
waitForDataReady() |
addCallback, createSIMPlugin, getCallback, getData, getEndingVersion, getPlay, getRecord, getSetting, getSetting, getSIMName, getStartingVersion, getSync, getVersion, getVolume, removeCallback, run, run, setEndingVersion, setStartingVersion, setSync, setSynce, setVolume, setVolume
public iRacingSIMPlugin() throws SIMPlugin.SIMPluginException
SIMPlugin.SIMPluginException
public IODriver getIODriver()
public Session getSession()
SIMPlugin
getSession
in class SIMPlugin
Session
public Data setPlay(java.lang.String file)
SIMPlugin
public Data setRecord(java.lang.String file)
SIMPlugin
public boolean isActive()
SIMPlugin
isActive() is called first and every time through the loop. It returns true if the SIM is ready to accept calls. The SIM can return false for various reasons, with the default action would be to exit your program because of a fatal error. It could also mean you have reached the end of a recorded file that you told it to play. In that case, you might want to simply start it over.
waitForDataReady() is called to see if the SIM has any data. It should return true when data is available from the SIM. A return of false means no data was available and you should try again. Each SIM should put any throttling in this implementation to be nice to other processes and prevent a tight loop.
isConnected() will return true if the SIM is running, false if not.
The following code illustrates how to use these methods.
while (connector.isActive()) { if (connector.waitForDataReady()) { //call connector.getData(datapath); } else { if (!connector.isConnected()) { //handle SIM not running //call connector.getData(datapath); //is allowed here } } }Simulators should override these abstract methods and implement them.
public boolean isConnected()
public boolean waitForDataReady()
public void close()
SIMPlugin
public Data getSIMData(java.lang.String... args)
SIMPlugin
getSIMData
in class SIMPlugin
args
- An array of String arguments as specified by the SIM.Data
container.