Skip to content

Alloy Update System

Garrett Burroughs edited this page May 4, 2020 · 4 revisions

Alloy Updater

The alloy update system uses annotations to find methods that will be run by the updater

How to use it

Setting things to be updated is very easy, all you have to do is annotate the method with the @Update tag Ex:

@Update
public void updateMethod(){
    // This code will run every loop
}

Update Parameters

You can also add parameters to the annotation to control how and when the method is run. By setting the "updateRate" argument, you can control how often the method gets updated, for example, an updateRate of 5 would run once every 5 loops, this way, things that are less important and more calculation heavy can be updated less often as to not affect the speed of the robot execution Ex

@Update(updateRate=3)
public void secondaryUpdate(){
    // This code will run once every 3 loops
}

Finally, you can set a priority to your methods to change what order they update in, the higher the priority, the sooner it will be updated, for example, a method with a priority of 10 would update before a method with a priority of 5, this is important for things like calculating inputs before motor powers Ex

@Update(priority=1)
public void updateDrive(){
    // This code will run second
}

@Update(priority=5)
public void controlUpdate(){
    // This code will run first
}

Clone this wiki locally