Package jmri.server.json.throttle
Class JsonThrottle
java.lang.Object
jmri.server.json.throttle.JsonThrottle
- All Implemented Interfaces:
PropertyChangeListener,EventListener,ThrottleListener
-
Nested Class Summary
Nested classes/interfaces inherited from interface jmri.ThrottleListener
ThrottleListener.DecisionType -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringUsed to notify clients of the number of clients controlling the same throttle.static final String"eStop"static final String"idle"static final String"release"static final String"speedSteps"static final StringToken for type for throttle status messages. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedJsonThrottle(DccLocoAddress address, JsonThrottleSocketService server) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose(JsonThrottleSocketService server, boolean notifyClient) (package private) ThrottleGet the Throttle this JsonThrottle is a proxy for.static JsonThrottlegetThrottle(String throttleId, com.fasterxml.jackson.databind.JsonNode data, JsonThrottleSocketService server, int id) Creates a new JsonThrottle or returns an existing one if the request is for an existing throttle.voidnotifyDecisionRequired(LocoAddress address, ThrottleListener.DecisionType question) No steal or share decisions made locallyvoidnotifyFailedThrottleRequest(LocoAddress address, String reason) Get notification that an attempt to request a throttle has failed.voidnotifyThrottleFound(DccThrottle throttle) Get notification that a throttle has been found as requested.voidonMessage(Locale locale, com.fasterxml.jackson.databind.JsonNode data, JsonThrottleSocketService server) voidvoidrelease(JsonThrottleSocketService server, boolean notifyClient) voidsendMessage(com.fasterxml.jackson.databind.node.ObjectNode data) voidsendMessage(com.fasterxml.jackson.databind.node.ObjectNode data, JsonThrottleSocketService server) protected voidsendStatus(JsonThrottleSocketService server)
-
Field Details
-
THROTTLE
Token for type for throttle status messages."throttle"
- See Also:
-
RELEASE
"release"- See Also:
-
ESTOP
"eStop"- See Also:
-
IDLE
"idle"- See Also:
-
SPEED_STEPS
"speedSteps"- See Also:
-
CLIENTS
Used to notify clients of the number of clients controlling the same throttle."clients"
- See Also:
-
-
Constructor Details
-
JsonThrottle
-
-
Method Details
-
getThrottle
public static JsonThrottle getThrottle(String throttleId, com.fasterxml.jackson.databind.JsonNode data, JsonThrottleSocketService server, int id) throws JsonException Creates a new JsonThrottle or returns an existing one if the request is for an existing throttle.data can contain either a string
JSON.IDnode containing the ID of aRosterEntryor an integerJSON.ADDRESSnode. If data contains an ADDRESS, the ID node is ignored. The ADDRESS may be accompanied by a booleanJSON.IS_LONG_ADDRESSnode specifying the type of address, if IS_LONG_ADDRESS is not specified, the inverse ofThrottleManager.canBeShortAddress(int)is used as the "best guess" of the address length.- Parameters:
throttleId- The client's identity token for this throttledata- JSON object containing either an ADDRESS or an IDserver- The server requesting this throttle on behalf of a clientid- message id set by client- Returns:
- The throttle
- Throws:
JsonException- if unable to get the requestedThrottle
-
close
-
release
-
onMessage
public void onMessage(Locale locale, com.fasterxml.jackson.databind.JsonNode data, JsonThrottleSocketService server) -
sendMessage
-
sendMessage
public void sendMessage(com.fasterxml.jackson.databind.node.ObjectNode data, JsonThrottleSocketService server) -
propertyChange
- Specified by:
propertyChangein interfacePropertyChangeListener
-
notifyThrottleFound
Description copied from interface:ThrottleListenerGet notification that a throttle has been found as requested.- Specified by:
notifyThrottleFoundin interfaceThrottleListener- Parameters:
throttle- the throttle with the requested address
-
notifyFailedThrottleRequest
Description copied from interface:ThrottleListenerGet notification that an attempt to request a throttle has failed.- Specified by:
notifyFailedThrottleRequestin interfaceThrottleListener- Parameters:
address- address of the failed requestreason- failure cause
-
notifyDecisionRequired
No steal or share decisions made locallyGet notification that a throttle request is in use by another device, and a "steal", "share", or "steal/share" decision may be required.
- Specified by:
notifyDecisionRequiredin interfaceThrottleListener- Parameters:
address- The LocoAddress that needs the decision.question- The question being asked, steal / cancel, share / cancel, steal / share / cancel
-
sendStatus
-
getThrottle
Get the Throttle this JsonThrottle is a proxy for.- Returns:
- the throttle or null if no throttle is set
-