Package api.advanced
Class Bundle
- java.lang.Object
-
- api.advanced.Bundle
-
- All Implemented Interfaces:
ExecutableCommands
public class Bundle extends java.lang.Object implements ExecutableCommands
A powerful tool to combine instructions to multiple servos and execute them in parallelAll instructions inside a Bundle have the same execution time. To combine instructions with multiple execution times, you can combine multiple Bundles into a
Collection.Tip: There also is a convenience class to easily create Bundles for the most common use cases. It's named
BundleCreator.- See Also:
Example2,BundleCreator,ExecutableCommands,Collection
-
-
Method Summary
Modifier and Type Method Description voidadd(int servo, int position)Add an instruction to a servo to the Bundle
Note: This method does not throw or warn you if this Bundle already contains an instruction to this servo.
Note: This method does not throw or warn you if the targeted position is out of range.voidadd(Bundle bundle)Adds all instructions from the specified Bundle to this Bundle.
Note: This method does not throw or warn you if both Bundles contain instructions to the same servo(s).
Note: This method retains the default execution time of the Bundle.booleanequals(java.lang.Object obj)voidexec()Execute the Bundle for the default time specified in the constructor
This method does not block the Thread when invoked.voidexec(int customTime)Execute the Command(s) for a given time
This method does not block the Thread when invoked.voidexecBlocking()LikeExecutableCommands.exec()but blocks the Thread until the Command has been executedvoidexecBlocking(int time)LikeExecutableCommands.exec(int)but blocks the Thread until the Command has been executedjava.lang.StringgetCommand()Get the command represented by this Bundle.java.lang.StringgetRawCommand()Get the command currently represented by this bundle (without time).intgetTime()Get the default execution time specified in the constructor or insetTimejava.lang.StringgetTree()Alias forgetCommandvoidprintTree()Prints the result ofgetTreevoidremove(int servo)Remove all instructions to the specified servo from the BundlevoidsetTime(int newTime)Set a new default execution time
-
-
-
Method Detail
-
add
public void add(int servo, int position)Add an instruction to a servo to the Bundle
Note: This method does not throw or warn you if this Bundle already contains an instruction to this servo.
Note: This method does not throw or warn you if the targeted position is out of range.- Parameters:
servo- The pin of the servo which should be added to the Bundleposition- The targeted position of the servo ranging from 0 to 1500- See Also:
add(Bundle)
-
add
public void add(Bundle bundle)
Adds all instructions from the specified Bundle to this Bundle.
Note: This method does not throw or warn you if both Bundles contain instructions to the same servo(s).
Note: This method retains the default execution time of the Bundle.- Parameters:
bundle- The Bundle whose instructions should be added to this Bundle- See Also:
add(int, int)
-
remove
public void remove(int servo)
Remove all instructions to the specified servo from the Bundle- Parameters:
servo- The pin of the servo which should be removed
-
exec
public void exec(int customTime)
Execute the Command(s) for a given time
This method does not block the Thread when invoked.- Specified by:
execin interfaceExecutableCommands- Parameters:
customTime- The execution time in milliseconds
-
exec
public void exec()
Execute the Bundle for the default time specified in the constructor
This method does not block the Thread when invoked.- Specified by:
execin interfaceExecutableCommands- See Also:
exec(int),setTime(int)
-
setTime
public void setTime(int newTime)
Set a new default execution time- Parameters:
newTime- The new default execution time in milliseconds- See Also:
getTime()
-
getTime
public int getTime()
Get the default execution time specified in the constructor or insetTime- Specified by:
getTimein interfaceExecutableCommands- Returns:
- The default execution time of this Bundle
- See Also:
setTime(int)
-
getRawCommand
public java.lang.String getRawCommand()
Get the command currently represented by this bundle (without time).- Returns:
- The raw command
-
getCommand
public java.lang.String getCommand()
Get the command represented by this Bundle.- Returns:
- The command that will be executed by
exec().
-
printTree
public void printTree()
Prints the result ofgetTree- Specified by:
printTreein interfaceExecutableCommands- See Also:
getCommand()
-
getTree
public java.lang.String getTree()
Alias forgetCommand- Specified by:
getTreein interfaceExecutableCommands- Returns:
- The command tree
- See Also:
getCommand()
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
execBlocking
public void execBlocking()
Description copied from interface:ExecutableCommandsLikeExecutableCommands.exec()but blocks the Thread until the Command has been executed- Specified by:
execBlockingin interfaceExecutableCommands
-
execBlocking
public void execBlocking(int time)
Description copied from interface:ExecutableCommandsLikeExecutableCommands.exec(int)but blocks the Thread until the Command has been executed- Specified by:
execBlockingin interfaceExecutableCommands- Parameters:
time- The execution time in milliseconds
-
-