S7日志更新了一版

This commit is contained in:
caixiang 2022-12-13 17:02:43 +08:00
parent afd47852b7
commit 5b2c38770d
4 changed files with 14 additions and 26 deletions

View File

@ -298,6 +298,11 @@ public enum S7Client {
} }
private void resetConnetctions(){
this.connections = new ArrayList<S7Connector>();
connectionPool();
}
private void connectionPool(){ private void connectionPool(){
for(int i=0;i<coreSize;i++){ for(int i=0;i<coreSize;i++){
S7Connector connect = connect(host, rack, slot); S7Connector connect = connect(host, rack, slot);

View File

@ -15,6 +15,9 @@ limitations under the License.
*/ */
package com.qgs.dc.s7.my.s7connector.impl.nodave; package com.qgs.dc.s7.my.s7connector.impl.nodave;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
@ -27,7 +30,7 @@ public final class PLCinterface {
OutputStream out; OutputStream out;
int protocol; // The kind of transport used on this interface. int protocol; // The kind of transport used on this interface.
int wp, rp; int wp, rp;
private static final Logger logger = LoggerFactory.getLogger(PLCinterface.class);
public PLCinterface(final OutputStream out, final InputStream in, final String name, final int localMPI, public PLCinterface(final OutputStream out, final InputStream in, final String name, final int localMPI,
final int protocol) { final int protocol) {
this.init(out, in, name, localMPI, protocol); this.init(out, in, name, localMPI, protocol);
@ -64,7 +67,7 @@ public final class PLCinterface {
} }
return res; return res;
} catch (final IOException e) { } catch (final IOException e) {
e.printStackTrace(); logger.info("Socket read字节流失败: "+e);
return 0; return 0;
} }
} }
@ -74,7 +77,7 @@ public final class PLCinterface {
this.out.write(b, start, len); this.out.write(b, start, len);
return 1; return 1;
} catch (final IOException e) { } catch (final IOException e) {
System.err.println("Interface.write: " + e); logger.info("Socket write字节流失败: "+e);
return 0; return 0;
} }
} }

View File

@ -123,7 +123,8 @@ public final class TCPConnection extends S7Connection {
if(writeRes!=0 && readRes!=0){ if(writeRes!=0 && readRes!=0){
return 0; return 0;
}else { }else {
logger.info("exchange 出现了问题:① writeRes:"+writeRes+"② readRes:"+readRes);
logger.info("exchange 出现了问题:① writeRes:"+(writeRes==0?"writeISOPacket成功":"writeISOPacket失败")+"② readRes:"+(readRes==0?"readISOPacket成功":"readISOPacket失败"));
return 1 ; return 1 ;
} }
} }
@ -149,27 +150,6 @@ public final class TCPConnection extends S7Connection {
return res; return res;
} }
// public static void main(String[] args) {
// byte[] s = new byte[2];
// List<Byte> a = new ArrayList<>();
// a.add(Byte.valueOf("1"));
// a.add(Byte.valueOf("2"));
// read(a);
// System.out.println(a.get(0));
// System.out.println(a.get(1));
// }
// public static int read(byte[] ss){
// ss[0] = 1;
// ss[1] = 1;
// return 0;
// }
// public static int read(List<Byte> ss){
// ss.set(0,Byte.valueOf("3"));
// ss.set(1,Byte.valueOf("4"));
// return 0;
// }
/** /**
* Send iso packet. * Send iso packet.
* *

View File

@ -70,7 +70,7 @@ public enum DataTransportSize {
public static DataTransportSize enumForValue(short value) { public static DataTransportSize enumForValue(short value) {
if (!map.containsKey(value)) { if (!map.containsKey(value)) {
logger.error("No DataTransportSize for value {}", value); logger.info("No DataTransportSize for value {}", value);
} }
return map.get(value); return map.get(value);
} }