Class S7HPlcConnection
- java.lang.Object
-
- org.apache.plc4x.java.spi.connection.AbstractPlcConnection
-
- org.apache.plc4x.java.spi.connection.DefaultNettyPlcConnection
-
- org.apache.plc4x.java.s7.readwrite.protocol.S7HPlcConnection
-
- All Implemented Interfaces:
AutoCloseable,Runnable,EventPlcConnection,PlcConnectionMetadata,PlcConnection,ChannelExposingConnection,PlcBrowser,PlcPinger,PlcReader,PlcSubscriber,PlcWriter
public class S7HPlcConnection extends DefaultNettyPlcConnection implements Runnable
This object generates the main connection and includes the management of multiple connections to the PLC, in the case of S7H there are two connections. Here the reference to the multiplexer object (S7HMuxImpl) is maintained, which is in charge of managing the physical TCP connections.TODO: It should be able to run in the "channel" executor. You should be able to remove the "executor".
-
-
Field Summary
Fields Modifier and Type Field Description protected io.netty.channel.ChannelprimaryChannelprotected io.netty.handler.codec.MessageToMessageCodec<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf>s7hmuxprotected io.netty.channel.ChannelsecondaryChannelprotected ChannelFactorysecondaryChannelFactoryprotected intslicePingprotected intsliceRetryTime-
Fields inherited from class org.apache.plc4x.java.spi.connection.DefaultNettyPlcConnection
awaitSessionDisconnectComplete, awaitSessionDiscoverComplete, awaitSessionSetupComplete, channel, channelFactory, configuration, connected, DEFAULT_DISCONNECT_WAIT_TIME, fireDiscoverEvent, listeners, sessionDisconnectCompleteFuture, stackConfigurer
-
-
Constructor Summary
Constructors Constructor Description S7HPlcConnection(boolean canPing, boolean canRead, boolean canWrite, boolean canSubscribe, boolean canBrowse, PlcTagHandler tagHandler, PlcValueHandler valueHandler, PlcConnectionConfiguration configuration, ChannelFactory channelFactory, ChannelFactory secondaryChannelFactory, boolean fireDiscoverEvent, boolean awaitSessionSetupComplete, boolean awaitSessionDisconnectComplete, boolean awaitSessionDiscoverComplete, ProtocolStackConfigurer<TPKTPacket> stackConfigurer, BaseOptimizer optimizer, PlcAuthentication authentication)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidconnect()voiddoPrimaryTcpConnections()voiddoSecondaryTcpConnections()booleanisConnected()CompletableFuture<? extends PlcPingResponse>ping()voidrun()protected voidsendChannelDisconectEvent()-
Methods inherited from class org.apache.plc4x.java.spi.connection.DefaultNettyPlcConnection
addEventListener, getChannel, getChannelHandler, removeEventListener, sendChannelCreatedEvent
-
Methods inherited from class org.apache.plc4x.java.spi.connection.AbstractPlcConnection
browse, browseRequestBuilder, browseWithInterceptor, getAuthentication, getMetadata, getPlcTagHandler, getPlcValueHandler, isBrowseSupported, isReadSupported, isSubscribeSupported, isWriteSupported, ping, read, readRequestBuilder, register, setProtocol, subscribe, subscriptionRequestBuilder, unregister, unsubscribe, unsubscriptionRequestBuilder, write, writeRequestBuilder
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.plc4x.java.api.PlcConnection
browseRequestBuilder, getMetadata, parseTagAddress, readRequestBuilder, subscriptionRequestBuilder, unsubscriptionRequestBuilder, writeRequestBuilder
-
-
-
-
Field Detail
-
secondaryChannelFactory
protected final ChannelFactory secondaryChannelFactory
-
primaryChannel
protected io.netty.channel.Channel primaryChannel
-
secondaryChannel
protected io.netty.channel.Channel secondaryChannel
-
s7hmux
protected final io.netty.handler.codec.MessageToMessageCodec<io.netty.buffer.ByteBuf,io.netty.buffer.ByteBuf> s7hmux
-
slicePing
protected int slicePing
-
sliceRetryTime
protected int sliceRetryTime
-
-
Constructor Detail
-
S7HPlcConnection
public S7HPlcConnection(boolean canPing, boolean canRead, boolean canWrite, boolean canSubscribe, boolean canBrowse, PlcTagHandler tagHandler, PlcValueHandler valueHandler, PlcConnectionConfiguration configuration, ChannelFactory channelFactory, ChannelFactory secondaryChannelFactory, boolean fireDiscoverEvent, boolean awaitSessionSetupComplete, boolean awaitSessionDisconnectComplete, boolean awaitSessionDiscoverComplete, ProtocolStackConfigurer<TPKTPacket> stackConfigurer, BaseOptimizer optimizer, PlcAuthentication authentication)
-
-
Method Detail
-
connect
public void connect() throws PlcConnectionException- Specified by:
connectin interfacePlcConnection- Overrides:
connectin classDefaultNettyPlcConnection- Throws:
PlcConnectionException
-
close
public void close() throws PlcConnectionException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfacePlcConnection- Overrides:
closein classDefaultNettyPlcConnection- Throws:
PlcConnectionException
-
isConnected
public boolean isConnected()
- Specified by:
isConnectedin interfacePlcConnection- Overrides:
isConnectedin classDefaultNettyPlcConnection
-
doPrimaryTcpConnections
public void doPrimaryTcpConnections()
-
doSecondaryTcpConnections
public void doSecondaryTcpConnections()
-
sendChannelDisconectEvent
protected void sendChannelDisconectEvent()
-
ping
public CompletableFuture<? extends PlcPingResponse> ping()
- Specified by:
pingin interfacePlcConnection- Overrides:
pingin classDefaultNettyPlcConnection
-
-