Package com.automation_pros.odva.encap
Class TcpConx
- java.lang.Object
-
- All Implemented Interfaces:
DataContext
,CipReplyConsumer
,AppLinkBase
,AppOwner
,AppProducer
,AttributeHolder
,CipMsgProcessor
,LinkConsumer
,java.lang.Comparable<CipInstance>
public class TcpConx extends ConxInstance implements CipMsgProcessor
These TCP connections encompass all of the common operations of Explicit messaging TCP Servers and TCP clients. They continue to exist as long as both internal and external endpoints maintain the TCP channel. They can also carry class 3 connected message data.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
TcpConx.CipReply2Encap
When processing a CIP request that arrives on an encapsulation connection, the final reply consumer isn't local.class
TcpConx.EncapFwdOpen
When processing a Forward Open reply that arrived on an encapsulation connection, and it is both successful and non-null, the associated connection must be created in the port and attached to the reply for later consumers.class
TcpConx.EncapUnitProducer
protected class
TcpConx.TcpDeadline
-
Nested classes/interfaces inherited from class com.automation_pros.odva.cip.types.CipObject
CipObject.FutureMultipleReply
-
Nested classes/interfaces inherited from class com.automation_pros.odva.cip.types.CipTree
CipTree.ChildMap
-
-
Field Summary
Fields Modifier and Type Field Description protected long
activityTS
protected io.netty.channel.socket.SocketChannel
channel
protected java.util.Map<java.lang.Long,CipRequest>
ctxmap
protected java.util.Map<java.lang.Integer,ConxMapItem>
cxmap
protected int
ephemeralSerial
protected int
ephemeralVendor
protected int
inFlight
protected int
inFlightTimeouts
protected boolean
isEphemeralPort
protected java.net.InetSocketAddress
localAddress
protected java.util.List<CipRequest>
msgProcQueue
boolean
originatorFlag
java.net.InetSocketAddress
peer
EncapPort
port
protected int
sessionID
-
Fields inherited from class com.automation_pros.odva.cip.core.ConxInstance
appConsumer, connSN, consapi, consid, conssize, consumer, cxstate, deadline, dirtrigcls, DNconsid, DNmsggrps, DNprodid, insttype, linkProducer, O2Tapi, O2TconnID, O2TconnIDrq, O2Tparams, O2Trpi, oport, origSN, pktrate, prodapi, prodid, prodinh, prodsize, producer, T2Oapi, T2OconnID, T2OconnIDrq, T2Oparams, T2Orpi, timeoutMult, tport, vendor, WDTDeadline, WDTnsec, wdtoact
-
Fields inherited from class com.automation_pros.odva.cip.core.CipInstance
attr_all
-
Fields inherited from class com.automation_pros.odva.cip.types.CipTree
children, objEPath, parent, segment
-
Fields inherited from interface com.automation_pros.odva.cip.data.DataContext
emptyContext
-
-
Constructor Summary
Constructors Modifier Constructor Description TcpConx(ConxClass parent, java.net.InetSocketAddress target)
Construct and connect an originator connection to a target's UCMM.protected
TcpConx(ConxClass parent, java.net.InetSocketAddress target, boolean ephemeral)
TcpConx(TcpIpPort port, io.netty.channel.socket.SocketChannel channel)
Construct the target side of a new server connection.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getMaxMsg()
Return this message processor's max allowed message size in bytes.int
getSessionID()
boolean
isOrigin()
Generic CIP connections are either originators or targets.void
linkConsume(long txID, java.nio.ByteBuffer payload)
Connections must be able to receive arbitrary payloads from port links.static TcpConx
makeEphemeral(java.net.InetAddress localAddress, java.net.InetSocketAddress target)
Construct and connect an originator connection to an Ethernet/IP target's UCMM using a ephemeral Port Object.void
msgProcDeQueue()
void
msgRcvdDeQueue()
void
send(CipRequest req)
Core method to send or execute a request.void
send(CipRequest req, int nesting)
Given a request and a nesting level, evaluate the request in the UCMM's application context after skipping the specified nested path segments.int
setSessionID(int newSessionID)
void
shutdown()
-
Methods inherited from class com.automation_pros.odva.cip.core.ConxInstance
accept, appProduce, disconnect, getConsumer, getConsumerID, getConsumerSize, getConsumeRTF, getConxData, getCXState, getDeadline, getDirTrigCls, getDNConsumerID, getDNMsgGroups, getDNProducerID, getInhibit, getInstanceType, getPacketRate, getParent, getProducer, getProducerID, getProducerSize, getProduceRTF, getRealTimeMode, isDisconnected, setRealTimeMode, toString
-
Methods inherited from class com.automation_pros.odva.cip.core.CipInstance
compareTo, getAttribute, getEPathImpl, getSegment, isPrivate, number, service, setParent
-
Methods inherited from class com.automation_pros.odva.cip.types.CipObject
executor, getChild, getDevice, getDisplayName, getName, isShutdown, logger, onReplacement, removeChildSymbol, scheduler, setChild, setChildSymbol, setName
-
Methods inherited from class com.automation_pros.odva.cip.types.CipTreeCtx
getCtxDataImpl, getNamedDef, getParentDataCtx, getTypeByCRC, getTypeByName, getTypesImpl
-
Methods inherited from class com.automation_pros.odva.cip.types.CipTree
cleanup, entrySet, follow, getChildren, getEPath, keySet, removeChild, setSegment
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.automation_pros.odva.cip.types.AttributeHolder
executor, getChild, getDisplayName, getEPath, isShutdown, logger, scheduler
-
Methods inherited from interface com.automation_pros.odva.cip.data.DataContext
fromEnum, getCtxData, getCtxDataOrNull, getTypes, makeHosted, makeUnhosted, toEnum
-
-
-
-
Field Detail
-
isEphemeralPort
protected boolean isEphemeralPort
-
ephemeralVendor
protected int ephemeralVendor
-
ephemeralSerial
protected int ephemeralSerial
-
localAddress
protected java.net.InetSocketAddress localAddress
-
port
public final EncapPort port
-
originatorFlag
public final boolean originatorFlag
-
channel
protected io.netty.channel.socket.SocketChannel channel
-
peer
public final java.net.InetSocketAddress peer
-
sessionID
protected int sessionID
-
cxmap
protected java.util.Map<java.lang.Integer,ConxMapItem> cxmap
-
ctxmap
protected java.util.Map<java.lang.Long,CipRequest> ctxmap
-
activityTS
protected long activityTS
-
inFlight
protected int inFlight
-
inFlightTimeouts
protected int inFlightTimeouts
-
msgProcQueue
protected java.util.List<CipRequest> msgProcQueue
-
-
Constructor Detail
-
TcpConx
public TcpConx(ConxClass parent, java.net.InetSocketAddress target)
Construct and connect an originator connection to a target's UCMM.- Parameters:
target
- The IP address and port of the target Ethernet/IP device.
-
TcpConx
protected TcpConx(ConxClass parent, java.net.InetSocketAddress target, boolean ephemeral)
-
TcpConx
public TcpConx(TcpIpPort port, io.netty.channel.socket.SocketChannel channel)
Construct the target side of a new server connection.- Parameters:
port
- The Port instance in which this connection will operate.channel
- The connected channel created by the port in accept().
-
-
Method Detail
-
makeEphemeral
public static TcpConx makeEphemeral(java.net.InetAddress localAddress, java.net.InetSocketAddress target)
Construct and connect an originator connection to an Ethernet/IP target's UCMM using a ephemeral Port Object. The TCP/IP connection will use the local address as its source if not null. If null, Netty will choose the local address.- Parameters:
localAddress
-target
-
-
getSessionID
public int getSessionID()
-
setSessionID
public int setSessionID(int newSessionID)
-
shutdown
public void shutdown()
- Specified by:
shutdown
in interfaceAttributeHolder
- Overrides:
shutdown
in classConxInstance
-
linkConsume
public void linkConsume(long txID, java.nio.ByteBuffer payload)
Description copied from class:ConxInstance
Connections must be able to receive arbitrary payloads from port links. These would be TCP or UDP sockets in Ethernet/IP, platform-dependent OS devices in DeviceNet or other physical transports, or peer connections in bridging.The connection's watchdog timer is updated on link packet processing.
- Specified by:
linkConsume
in interfaceLinkConsumer
- Overrides:
linkConsume
in classConxInstance
- Parameters:
txID
- Link-specific transaction ID. Not always 64 bits, if used at all.payload
- The CIP payload extracted from the outer transport protocol.
-
send
public void send(CipRequest req)
Description copied from interface:CipMsgProcessor
Core method to send or execute a request.- Specified by:
send
in interfaceCipMsgProcessor
-
send
public void send(CipRequest req, int nesting)
Description copied from interface:CipMsgProcessor
Given a request and a nesting level, evaluate the request in the UCMM's application context after skipping the specified nested path segments. Route paths may not be present in the application path. Implementations should override this naive default implementation if the request will be executed locally--no need to construct a trimmed request if it will not go over the wire.- Specified by:
send
in interfaceCipMsgProcessor
-
msgProcDeQueue
public void msgProcDeQueue()
-
msgRcvdDeQueue
public void msgRcvdDeQueue()
-
isOrigin
public boolean isOrigin()
Description copied from class:ConxInstance
Generic CIP connections are either originators or targets. In messaging connections, originators produce requests while targets produce replies.Within this protocol implementation, originators produce on the link side with the O2T timing and parameters, and consume on the link side with the T2O timing and parameters.
When a connection is obtained from a successful Forward Open Response, the recipient must examine whether it is an originator or a target. If an originator, the recipient must assign to the appConsumer field and use the appProduce() method. If a target, the recipient must assign to the linkProducer field and use the linkConsume() method.
- Specified by:
isOrigin
in classConxInstance
- Returns:
-
getMaxMsg
public int getMaxMsg()
Description copied from interface:CipMsgProcessor
Return this message processor's max allowed message size in bytes. Applies to both request and reply.- Specified by:
getMaxMsg
in interfaceCipMsgProcessor
- Returns:
-
-