-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Addons are standalone jars, loaded at runtime. They can be developed independently of the simulator and can provide some additional functionality. An example addon is shown in `addons/rand`. When building a jar file, main class should extend abstract class `sic.sim.addons.Addon`. Only the methods, needed for functinality of the addon, have to be overriden. The abstract class Addon currently contains methods for initializing the addon and some other methods (documented in the source file itself). The class could be extended at any time (with non-abstract methods) without breaking any older addons. Addons can be loaded with `-a path[@params]` command line options. Parametres are passed to the `load` method of the loaded addon.
- Loading branch information
Showing
12 changed files
with
380 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
NAME=${name} | ||
# MAIN is the class which extends the abstract class sic.sim.plugins.Plugin. | ||
MAIN="${name}.Main" | ||
OUT=out/make | ||
# SICPATH should be changed if building from a different tree. | ||
# It can also point to sictools.jar file. | ||
SICPATH=../out/make | ||
|
||
|
||
.PHONY: main | ||
main: outdir | ||
javac -encoding UTF-8 -cp ".:$(SICPATH)" -d "$(OUT)/$(NAME)" $(NAME)/*.java | ||
jar --create --file "$(OUT)/$(NAME).jar" --main-class $(MAIN) -C "$(OUT)/$(NAME)" . | ||
|
||
.PHONY: outdir | ||
outdir: | ||
@mkdir -p "$(OUT)" | ||
|
||
.PHONY: clean | ||
clean: | ||
rm -rf "$(OUT)" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package rand; | ||
|
||
import java.util.Vector; | ||
|
||
import sic.sim.addons.Addon; | ||
import sic.sim.Executor; | ||
|
||
public class Main extends Addon { | ||
private int device = 3; | ||
public void load(String args) { | ||
System.out.println("Loading rand"); | ||
if (args != null) { | ||
device = Integer.parseInt(args); | ||
} | ||
} | ||
|
||
@Override | ||
public Vector<AddonDevice> getDevices() { | ||
Vector<AddonDevice> vc = new Vector<AddonDevice>(); | ||
vc.add(new Addon.AddonDevice(device, new RandDevice(), true)); | ||
return vc; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package rand; | ||
|
||
import java.util.Random; | ||
|
||
import sic.sim.vm.Device; | ||
|
||
public class RandDevice extends Device { | ||
private Random random = new Random(); | ||
|
||
@Override | ||
public int read() { | ||
return random.nextInt(256); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.