Class CoreMotor<D>
- java.lang.Object
-
- io.engineblock.activityimpl.motor.CoreMotor<D>
-
- All Implemented Interfaces:
ActivityDefObserver,Motor<D>,Stoppable,java.lang.Runnable
public class CoreMotor<D> extends java.lang.Object implements ActivityDefObserver, Motor<D>, Stoppable
ActivityMotor is a Runnable which runs in one of an activity's many threads. It is the iteration harness for individual cycles of an activity. Each ActivityMotor instance is responsible for taking input from a LongSupplier and applying the provided LongConsumer to it on each cycle. These two parameters are called input and action, respectively. This motor implementation splits the handling of sync and async actions with a hard fork in the middle to limit potential breakage of the prior sync implementation with new async logic.
-
-
Constructor Summary
Constructors Constructor Description CoreMotor(Activity activity, long slotId, Input input)Create an ActivityMotor.CoreMotor(Activity activity, long slotId, Input input, Action action)Create an ActivityMotor.CoreMotor(Activity activity, long slotId, Input input, Action action, Output output)Create an ActivityMotor.
-
Method Summary
Modifier and Type Method Description ActiongetAction()InputgetInput()longgetSlotId()get the slotId which this motor is assigned to within the activity instance.SlotStateTrackergetSlotStateTracker()Get a description of the current slot run status.voidonActivityDefUpdate(ActivityDef activityDef)voidrequestStop()Ask this component to stop cycling.voidrun()Motor<D>setAction(Action action)Set the action for this ActivityMotor.Motor<D>setInput(Input input)Set the input for this ActivityMotor.voidsetResultOutput(Output resultOutput)java.lang.StringtoString()
-
-
-
Constructor Detail
-
CoreMotor
public CoreMotor(Activity activity, long slotId, Input input)
Create an ActivityMotor.- Parameters:
activity- The activity that this motor will be associated with.slotId- The enumeration of the motor, as assigned by its executor.input- A LongSupplier which provides the cycle number inputs.
-
CoreMotor
public CoreMotor(Activity activity, long slotId, Input input, Action action)
Create an ActivityMotor.- Parameters:
activity- The activity that this motor is based on.slotId- The enumeration of the motor, as assigned by its executor.input- A LongSupplier which provides the cycle number inputs.action- An LongConsumer which is applied to the input for each cycle.
-
CoreMotor
public CoreMotor(Activity activity, long slotId, Input input, Action action, Output output)
Create an ActivityMotor.- Parameters:
activity- The activity that this motor is based on.slotId- The enumeration of the motor, as assigned by its executor.input- A LongSupplier which provides the cycle number inputs.action- An LongConsumer which is applied to the input for each cycle.output- An optional opTracker.
-
-
Method Detail
-
getSlotId
public long getSlotId()
Description copied from interface:Motorget the slotId which this motor is assigned to within the activity instance.
-
getSlotStateTracker
public SlotStateTracker getSlotStateTracker()
Description copied from interface:MotorGet a description of the current slot run status.- Specified by:
getSlotStateTrackerin interfaceMotor<D>- Returns:
- - a value from the
RunStateenum
-
run
public void run()
- Specified by:
runin interfacejava.lang.Runnable
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
onActivityDefUpdate
public void onActivityDefUpdate(ActivityDef activityDef)
- Specified by:
onActivityDefUpdatein interfaceActivityDefObserver
-
requestStop
public void requestStop()
Description copied from interface:StoppableAsk this component to stop cycling. This is an asynchronous request. Once the current active cycle completes, the request will cause the component to stop cooperatively.- Specified by:
requestStopin interfaceStoppable
-
setResultOutput
public void setResultOutput(Output resultOutput)
-
-