Package org.openremote.agent.protocol.io
Class AbstractIOClientProtocol<T extends AbstractIOClientProtocol<T,U,V,W,X>,U extends IOAgent<U,T,X>,V,W extends IOClient<V>,X extends org.openremote.model.asset.agent.AgentLink<?>>
java.lang.Object
org.openremote.agent.protocol.AbstractProtocol<U,X>
org.openremote.agent.protocol.io.AbstractIOClientProtocol<T,U,V,W,X>
- All Implemented Interfaces:
org.openremote.model.asset.agent.Protocol<U>
- Direct Known Subclasses:
AbstractMQTTClientProtocol,AbstractNettyIOClientProtocol
public abstract class AbstractIOClientProtocol<T extends AbstractIOClientProtocol<T,U,V,W,X>,U extends IOAgent<U,T,X>,V,W extends IOClient<V>,X extends org.openremote.model.asset.agent.AgentLink<?>>
extends AbstractProtocol<U,X>
This is an abstract
Protocol for protocols that require an IOClient.-
Field Summary
FieldsFields 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 Wprotected abstract VcreateWriteMessage(org.openremote.model.attribute.Attribute<?> attribute, X agentLink, org.openremote.model.attribute.AttributeEvent event, Object processedValue) Generate the actual message to send to theIOClientfor thisAttributeEventprotected abstract WShould return an instance ofIOClientfor the linkedAgent.protected voiddoLinkedAttributeWrite(org.openremote.model.attribute.Attribute<?> attribute, X agentLink, org.openremote.model.attribute.AttributeEvent event, Object processedValue) An Attribute event (write) has been requested for an attribute linked to this protocol.protected voiddoStart(org.openremote.model.Container container) Start this protocol instanceprotected voiddoStop(org.openremote.model.Container container) Stop this protocol instancestatic Supplier<io.netty.channel.ChannelHandler[]>getGenericStringEncodersAndDecoders(AbstractNettyIOClient<String, ?> client, IOAgent<?, ?, ?> agent) Supplies a set of encoders/decoders that convert from/toStringto/fromByteBufbased on the generic protocolAttributesGet a URI that describes this specific protocol instanceprotected voidonConnectionStatusChanged(org.openremote.model.asset.agent.ConnectionStatus connectionStatus) Called when theIOClientConnectionStatuschangesprotected abstract voidonMessageReceived(V message) Called when theIOClientreceives a message from the serverMethods inherited from class org.openremote.agent.protocol.AbstractProtocol
doLinkAttribute, doUnlinkAttribute, getAgent, getLinkedAttributes, linkAttribute, processLinkedAttributeWrite, sendAttributeEvent, sendAttributeEvent, setConnectionStatus, 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
getProtocolName, prefixLogMessage
-
Field Details
-
LOG
-
client
-
-
Constructor Details
-
AbstractIOClientProtocol
-
-
Method Details
-
getGenericStringEncodersAndDecoders
public static Supplier<io.netty.channel.ChannelHandler[]> getGenericStringEncodersAndDecoders(AbstractNettyIOClient<String, ?> client, IOAgent<?, ?, ?> agent) Supplies a set of encoders/decoders that convert from/toStringto/fromByteBufbased on the generic protocolAttributes -
getProtocolInstanceUri
Description copied from interface:org.openremote.model.asset.agent.ProtocolGet a URI that describes this specific protocol instance -
doStop
Description copied from class:AbstractProtocolStop this protocol instance -
doStart
Description copied from class:AbstractProtocolStart this protocol instance -
doLinkedAttributeWrite
protected void doLinkedAttributeWrite(org.openremote.model.attribute.Attribute<?> attribute, X agentLink, org.openremote.model.attribute.AttributeEvent event, Object processedValue) Description copied from class:AbstractProtocolAn Attribute event (write) has been requested for an attribute linked to this protocol. The processedValue is the resulting value after applying standard outbound value processing (seeProtocolUtil.doOutboundValueProcessing(java.lang.String, org.openremote.model.attribute.Attribute<?>, org.openremote.model.asset.agent.AgentLink<?>, java.lang.Object, boolean)). Protocol implementations should generally use the processedValue but may also choose to use the original value for some purpose if required.- Specified by:
doLinkedAttributeWritein classAbstractProtocol<U extends IOAgent<U,T, X>, X extends org.openremote.model.asset.agent.AgentLink<?>>
-
createIoClient
- Throws:
Exception
-
onConnectionStatusChanged
protected void onConnectionStatusChanged(org.openremote.model.asset.agent.ConnectionStatus connectionStatus) Called when theIOClientConnectionStatuschanges -
doCreateIoClient
Should return an instance ofIOClientfor the linkedAgent.- Throws:
Exception
-
onMessageReceived
Called when theIOClientreceives a message from the server -
createWriteMessage
protected abstract V createWriteMessage(org.openremote.model.attribute.Attribute<?> attribute, X agentLink, org.openremote.model.attribute.AttributeEvent event, Object processedValue) Generate the actual message to send to theIOClientfor thisAttributeEvent
-