Class ControllerProtocol
java.lang.Object
org.openremote.agent.protocol.AbstractProtocol<ControllerAgent,ControllerAgentLink>
org.openremote.agent.protocol.controller.ControllerProtocol
- All Implemented Interfaces:
org.openremote.model.asset.agent.Protocol<ControllerAgent>
This is a Controller 2.5 protocol to communicate with a running Controller 2.5 instance and getting sensor's status
and executing commands.
The protocol communicate with Controller by using Controller REST API.
The protocol manage two kinds of request :
- A set of polling requests (one by controller/device name couple)
pollingSensorList. For each request we just wait for a response 200 (new status) or 403 (timeout after 60 seconds) and relaunch the same request as soon as we have one of those two responses. - Executing commands provided by Write Attribute with necessary information. There is different kind of situations explained in
ControllerCommand
Two cases are considered:
- A sensor : if we want to link an attribute to a controller 2.5 sensor to get status we should create an Attribute with proper type
considering the situation (temperature, time,...) and two necessary META
ControllerAgent#META_DEVICE_NAMEandControllerAgent#META_SENSOR_NAME - A command : if we want to execute a command on a controller 2.5, we create an attribute with the following available META (see details
in
ControllerCommand) :ControllerAgent#META_DEVICE_NAMEorControllerAgent#META_COMMAND_DEVICE_NAME,ControllerAgent#META_COMMAND_NAMEorControllerAgent#META_COMMANDS_MAP
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected org.jboss.resteasy.client.jaxrs.ResteasyClientstatic final intstatic final StringFields inherited from class org.openremote.agent.protocol.AbstractProtocol
agent, assetService, datapointService, dynamicAttributes, executorService, linkedAttributes, messageBrokerContext, predictedDatapointService, producerTemplate, timerServiceFields inherited from interface org.openremote.model.asset.agent.Protocol
ACTUATOR_TOPIC, ACTUATOR_TOPIC_TARGET_PROTOCOL, DYNAMIC_TIME_PLACEHOLDER_REGEXP, DYNAMIC_VALUE_PLACEHOLDER, DYNAMIC_VALUE_PLACEHOLDER_REGEXP, SENSOR_QUEUE, SENSOR_QUEUE_SOURCE_PROTOCOL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voiddoLinkAttribute(String assetId, org.openremote.model.attribute.Attribute<?> attribute, ControllerAgentLink agentLink) Link anAttributeto its linkedAgent.protected voiddoLinkedAttributeWrite(org.openremote.model.attribute.Attribute<?> attribute, ControllerAgentLink agentLink, org.openremote.model.attribute.AttributeEvent event, Object processedValue) Write action on a linked attribute mean we execute a command on the Controller.voiddoStart(org.openremote.model.Container container) Start this protocol instanceprotected voiddoStop(org.openremote.model.Container container) Stop this protocol instanceprotected voiddoUnlinkAttribute(String assetId, org.openremote.model.attribute.Attribute<?> attribute, ControllerAgentLink agentLink) Clearing elements if an attribute is unlinked from Controller Agent We don't have to clearpollingSensorListas a check is done before scheduling taskschedulePollingTask(java.lang.String)Get a URI that describes this specific protocol instanceGet the name for this protocolprotected voidsetConnectionStatus(org.openremote.model.asset.agent.ConnectionStatus connectionStatus) Methods inherited from class org.openremote.agent.protocol.AbstractProtocol
getAgent, getLinkedAttributes, linkAttribute, processLinkedAttributeWrite, sendAttributeEvent, sendAttributeEvent, start, stop, toString, unlinkAttribute, updateAgentAttribute, updateLinkedAttribute, updateLinkedAttributeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.openremote.model.asset.agent.Protocol
prefixLogMessage
-
Field Details
-
HEARTBEAT_DELAY_SECONDS
public static final int HEARTBEAT_DELAY_SECONDS- See Also:
-
PROTOCOL_DISPLAY_NAME
- See Also:
-
client
protected org.jboss.resteasy.client.jaxrs.ResteasyClient client
-
-
Constructor Details
-
ControllerProtocol
-
-
Method Details
-
doStart
Description copied from class:AbstractProtocolStart this protocol instance- Specified by:
doStartin classAbstractProtocol<ControllerAgent,ControllerAgentLink> - Throws:
Exception
-
setConnectionStatus
protected void setConnectionStatus(org.openremote.model.asset.agent.ConnectionStatus connectionStatus) - Overrides:
setConnectionStatusin classAbstractProtocol<ControllerAgent,ControllerAgentLink>
-
doStop
Description copied from class:AbstractProtocolStop this protocol instance- Specified by:
doStopin classAbstractProtocol<ControllerAgent,ControllerAgentLink> - Throws:
Exception
-
doLinkAttribute
protected void doLinkAttribute(String assetId, org.openremote.model.attribute.Attribute<?> attribute, ControllerAgentLink agentLink) Description copied from class:AbstractProtocolLink anAttributeto its linkedAgent.- Specified by:
doLinkAttributein classAbstractProtocol<ControllerAgent,ControllerAgentLink>
-
doUnlinkAttribute
protected void doUnlinkAttribute(String assetId, org.openremote.model.attribute.Attribute<?> attribute, ControllerAgentLink agentLink) Clearing elements if an attribute is unlinked from Controller Agent We don't have to clearpollingSensorListas a check is done before scheduling taskschedulePollingTask(java.lang.String)- Specified by:
doUnlinkAttributein classAbstractProtocol<ControllerAgent,ControllerAgentLink>
-
doLinkedAttributeWrite
protected void doLinkedAttributeWrite(org.openremote.model.attribute.Attribute<?> attribute, ControllerAgentLink agentLink, org.openremote.model.attribute.AttributeEvent event, Object processedValue) Write action on a linked attribute mean we execute a command on the Controller. It induce a HTTP request and manage it's return code. (No value is returned from the execution of a command)- Specified by:
doLinkedAttributeWritein classAbstractProtocol<ControllerAgent,ControllerAgentLink>
-
getProtocolName
Description copied from interface:org.openremote.model.asset.agent.ProtocolGet the name for this protocol -
getProtocolInstanceUri
Description copied from interface:org.openremote.model.asset.agent.ProtocolGet a URI that describes this specific protocol instance
-