public class TriggerControl extends DynamicControlParent
DynamicControl
classes of type ControlType.TRIGGER
in a simple API.
Trigger controls do not have an internal value.
TriggerControl
controls with the same name and ControlScope
will respond to a message send()
.
For example, consider two TriggerControl
objects with the same ControlScope
and name.
TriggerControl control1 = new TriggerControl(this, "Send"); TriggerControl control2 = new TriggerControl(this, "Send") { @Override public void triggerEvent() { System.out.println("Received Trigger"); } }; control1.send();This will cause the
triggerEvent()
function to be called, causing Received Trigger to be printed to standard output
send(double)
function. Eg
ControlScope
and name, 1 second in the future.
triggerEvent()
functionConstructor and Description |
---|
TriggerControl(java.lang.Object parent_sketch,
java.lang.String name)
Create a Trigger Dynamic Control
|
Modifier and Type | Method and Description |
---|---|
void |
send()
Send a trigger event.
|
void |
send(double scheduler_time)
Send a trigger event at a specific time.
|
TriggerControl |
setControlScope(ControlScope new_scope)
Changed the scope that the control has.
|
TriggerControl |
setDisplayType(DynamicControl.DISPLAY_TYPE display_type)
Change how to display object as
DynamicControl.DISPLAY_TYPE
We must do this in subclass |
void |
triggerEvent()
Triggered events are received through this function after calling
send() on the object. |
addControlListener, addControlScopeListener, addControlTarget, addControlTarget, clearControlTargets, getDynamicControl, getSendingDevice, removeControlListener, removeControlScopeChangedListener, removeControlTarget, removeControlTarget, removeListeners, setControlTarget, setControlTarget
public TriggerControl(java.lang.Object parent_sketch, java.lang.String name)
parent_sketch
- The parent object for controlname
- the name to displaypublic void send()
DynamicControl
with matching name, type and ControlScope
and call triggerEvent()
.
TriggerControl control1 = new TriggerControl(this, "Send"); TriggerControl control2 = new TriggerControl(this, "Send") { @Override public void triggerEvent() { System.out.println("Received Trigger"); } }; control1.send();This will cause the
triggerEvent()
function to be called, causing Received Trigger to be printed to standard outputpublic void send(double scheduler_time)
send()
with the exception that the triggerEvent()
event will be caused at the HBScheduler
scheduled time passed in.
For example:
TriggerControl control1 = new TriggerControl(this, "Send");
TriggerControl control2 = new TriggerControl(this, "Send") {
@Override
public void triggerEvent() {
System.out.println("Received Trigger");
}
};
control1.send (HB.getSchedulerTime() + 1000); // this will trigger control1 value, as well as all other TriggerControls with same ControlScope
and name, 1 second in the future.
scheduler_time
- the scheduler time this is supposed to occur atpublic void triggerEvent()
send()
on the object. For example:
TriggerControl control1 = new TriggerControl(this, "Send"); TriggerControl control2 = new TriggerControl(this, "Send") { @Override public void triggerEvent() { System.out.println("Received Trigger"); } }; control1.send();
public TriggerControl setControlScope(ControlScope new_scope)
setControlScope
in class DynamicControlParent
new_scope
- The new Control Scopepublic TriggerControl setDisplayType(DynamicControl.DISPLAY_TYPE display_type)
DynamicControl.DISPLAY_TYPE
We must do this in subclassdisplay_type
- The new display type