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, processorLock, producerTemplate, scheduledExecutorService, timerService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected W
protected abstract V
createWriteMessage
(X agentLink, org.openremote.model.attribute.AttributeEvent event, Object processedValue) Generate the actual message to send to theIOClient
for thisAttributeEvent
protected abstract W
Should return an instance ofIOClient
for the linkedAgent
.protected void
doLinkedAttributeWrite
(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 void
doStart
(org.openremote.model.Container container) Start this protocol instanceprotected void
doStop
(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/toString
to/fromByteBuf
based on the generic protocolAttribute
sGet a URI that describes this specific protocol instanceprotected void
onConnectionStatusChanged
(org.openremote.model.asset.agent.ConnectionStatus connectionStatus) Called when theIOClient
ConnectionStatus
changesprotected abstract void
onMessageReceived
(V message) Called when theIOClient
receives a message from the serverMethods inherited from class org.openremote.agent.protocol.AbstractProtocol
doLinkAttribute, doUnlinkAttribute, getAgent, getLinkedAttributes, linkAttribute, onAgentAttributeChanged, processLinkedAttributeWrite, sendAttributeEvent, sendAttributeEvent, setAssetService, setConnectionStatus, start, stop, toString, unlinkAttribute, updateLinkedAttribute, updateLinkedAttribute
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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/toString
to/fromByteBuf
based on the generic protocolAttribute
s -
getProtocolInstanceUri
Description copied from interface:org.openremote.model.asset.agent.Protocol
Get a URI that describes this specific protocol instance -
doStop
Description copied from class:AbstractProtocol
Stop this protocol instance -
doStart
Description copied from class:AbstractProtocol
Start this protocol instance -
doLinkedAttributeWrite
protected void doLinkedAttributeWrite(X agentLink, org.openremote.model.attribute.AttributeEvent event, Object processedValue) Description copied from class:AbstractProtocol
An 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(org.openremote.model.attribute.AttributeRef, org.openremote.model.asset.agent.AgentLink<?>, java.lang.Object, boolean, java.time.Instant)
). Protocol implementations should generally use the processedValue but may also choose to use the original value for some purpose if required.- Specified by:
doLinkedAttributeWrite
in 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 theIOClient
ConnectionStatus
changes -
doCreateIoClient
Should return an instance ofIOClient
for the linkedAgent
.- Throws:
Exception
-
onMessageReceived
Called when theIOClient
receives a message from the server -
createWriteMessage
protected abstract V createWriteMessage(X agentLink, org.openremote.model.attribute.AttributeEvent event, Object processedValue) Generate the actual message to send to theIOClient
for thisAttributeEvent
-