Skip to content

Commit

Permalink
fix: Some dusting off of the old simulator
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdutz committed Nov 17, 2021
1 parent 70169d3 commit 3e9d11f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,13 @@
import org.apache.plc4x.java.s7.readwrite.S7Driver;
import org.apache.plc4x.java.s7.readwrite.TPKTPacket;
import org.apache.plc4x.java.s7.readwrite.io.TPKTPacketIO;
import org.apache.plc4x.java.spi.configuration.Configuration;
import org.apache.plc4x.java.spi.connection.GeneratedProtocolMessageCodec;
import org.apache.plc4x.java.spi.connection.SingleProtocolStackConfigurer;
import org.apache.plc4x.java.spi.generation.ByteOrder;
import org.apache.plc4x.simulator.exceptions.SimulatorExcepiton;
import org.apache.plc4x.simulator.model.Context;
import org.apache.plc4x.simulator.server.ServerModule;
import org.apache.plc4x.simulator.server.s7.protocol.S7Step7ServerAdapter;

import static org.apache.plc4x.java.spi.configuration.ConfigurationFactory.configure;

public class S7ServerModule implements ServerModule {

private static final int ISO_ON_TCP_PORT = 102;
Expand All @@ -60,7 +56,6 @@ public void setContext(Context context) {

@Override
public void start() throws SimulatorExcepiton {
S7Driver driver = new S7Driver();
if(loopGroup != null) {
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,17 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception
}
final byte bitAddress = addressAny.getBitAddress();
switch (addressAny.getTransportSize()) {
case BOOL:
payloadItems[i] = new S7VarPayloadDataItem(DataTransportErrorCode.OK, DataTransportSize.BIT, new byte[] {1});
break;
case INT:
case UINT: {
String firstKey = context.getMemory().keySet().iterator().next();
Object value = context.getMemory().get(firstKey);
short shortValue = 42; // ((Number) value).shortValue();
byte[] data = new byte[2];
data[0] = (byte) (shortValue & 0xff);
data[1] = (byte) ((shortValue >> 8) & 0xff);
data[1] = (byte) (shortValue & 0xff);
data[0] = (byte) ((shortValue >> 8) & 0xff);
payloadItems[i] = new S7VarPayloadDataItem(DataTransportErrorCode.OK, DataTransportSize.BYTE_WORD_DWORD, data);
break;
}
Expand Down

0 comments on commit 3e9d11f

Please sign in to comment.