public class SIMPluginCallback extends java.lang.Object implements SIMPlugin.Callback
{pathToJDK}\bin\javac -cp "%USERPROFILE%"\Documents\SIMRacingApps\SIMRacingAppsServer_1.0_Build_BETA-2016.01.09.exe" *.javaFor testing, put the .class file(s) generated in the "Documents\SIMRacingApps\com\SIMRacingApps\SIMPluginCallbacks\{YourNameOrCompany}" folder. Add the plug-in classes to the settings.txt file's "simplugins" entry. Each plug-in should be separated by a semicolon. The SIMRacingApps Server will load your plug-in upon startup of the server.
settings.txt simplugins = YourNameOrCompany.YourPluginClass;Name1.DoSomething;Name2.DoneItWhen testing, if the plug-in is already built into the SIMRacingAppsServer, you will have to alter the classpath to look for your new .class files to load before the built in ones. To do that, do not run the SIMRacingAppsServer.exe directly. Instead, use the following example command, on how to use it as a library and put your stuff first in the path.
{pathToJRE}\bin\java -cp "%USERPROFILE%"\Documents\SIMRacingApps\com\SIMRacingApps\SIMPluginCallbacks\{YourNameOrCompany}:%USERPROFILE%"\Documents\SIMRacingApps\SIMRacingAppsServer_1.0_Build_BETA-2016.01.09.exe" com.SIMRacingApps.ServerFor distribution, create a jar file with your .class file(s). We are going to use a .sra extension instead of .jar for uploading to the SIMRacingApps Server through the menu.
Example: jar cvf YourPlugin_v1.0.sra -C "%USERPROFILE%\Documents\SIMRacingApps" com/SIMRacingApps/SIMPluginCallbacks/{YourNameOrCompany}Distribute the .sra file with instructions to upload it to SIMRacingApps through the main menu. Also provide instructions on how to enable your plug-in by adding it to the settings.txt->plugins variable. For distribution with a Java App that uses the SIMRacingAppsServer.exe as a jar file, just add the .sra file to the classpath. If you would like your plug-in distributed as part of SIMRacingApps, please send me a request to do so at support@simracingapps.com.
Constructor and Description |
---|
SIMPluginCallback(SIMPlugin SIMPlugin,
java.lang.String name)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
boolean |
DataReady(SIMPlugin SIMPlugin,
java.lang.Integer ips)
This method is called every time the SIM has new data available.
|
void |
destroy()
Called when the SIMPlugin is destroyed.
|
boolean |
ProcessData(SIMPlugin SIMPlugin,
java.util.Map<java.lang.String,Data> data)
ProcessData is called from within the dedicated thread for this plug-in
every time there is data available in the queue it pops it off the queue and passes it to this method.
|
boolean |
Waiting(SIMPlugin SIMPlugin)
Waiting() is called every second if the SIM is not providing any data.
|
public SIMPluginCallback(SIMPlugin SIMPlugin, java.lang.String name) throws SIMPlugin.SIMPluginException
SIMPlugin
- An instance of the current SIM.name
- The name of the plug-in so you can find it's thread in a debugger and show it in the logger messages.SIMPlugin.SIMPluginException
- If there's a problem constructing your plug-in.public void destroy()
public boolean DataReady(SIMPlugin SIMPlugin, java.lang.Integer ips)
DataReady
in interface SIMPlugin.Callback
SIMPlugin
- An instance of the current SIM.ips
- Iterations per second.public boolean Waiting(SIMPlugin SIMPlugin)
Waiting
in interface SIMPlugin.Callback
SIMPlugin
- An instance of the current SIM.public boolean ProcessData(SIMPlugin SIMPlugin, java.util.Map<java.lang.String,Data> data)
//When calling the SIMPlugin from this method, you must synchronize on it first. It is not thread safe. Data d; synchronized (SIMPlugin) { //do not spend much time in here, we are blocking the main thread //Get the data and get out of the synchronized block d = SIMPlugin.getData("/Session/IsGreenFlag"); d = SIMPlugin.getSession().getIsGreenFlag(); } //do something with the data
SIMPlugin
- A reference to the SIMPlugin instance.data
- The Data objects added to the queue.