更新
This commit is contained in:
@@ -121,6 +121,7 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
itemStatus = group.read(true, (Item[]) itemsMap.values().toArray(new Item[0]));
|
||||
} catch (Exception e){
|
||||
System.out.println("数据同步异常:"+ this.getOpcServer().getOpc_code());
|
||||
log.trace("数据同步异常:{}", this.getOpcServer().getOpc_code());
|
||||
//e.printStackTrace();
|
||||
}
|
||||
long end = System.currentTimeMillis();
|
||||
@@ -130,7 +131,7 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
System.out.println("线程:"+tag + " 读取耗时:"+ duration);
|
||||
if (duration > 1000L) {
|
||||
if (!time_out) {
|
||||
log.warn("{} 读取超时 : {}", tag, duration);
|
||||
log.warn(" {} 读取超时 : {}", tag, duration);
|
||||
}
|
||||
|
||||
time_out = true;
|
||||
@@ -138,7 +139,11 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
time_out = false;
|
||||
}
|
||||
|
||||
// if(ObjectUtil.isEmpty(itemStatus)) continue label97;
|
||||
if(ObjectUtil.isEmpty(itemStatus)) {
|
||||
System.out.println( tag + " :itemStatus is null");
|
||||
log.warn(" {} 读取异常 : {} itemStatus is null", tag);
|
||||
}
|
||||
|
||||
|
||||
Set<Item> items = itemStatus.keySet();
|
||||
Iterator var18 = items.iterator();
|
||||
@@ -167,12 +172,13 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
value = OpcUtl.getValue(item, itemState);
|
||||
his = accessor_value.getValue(item.getId());
|
||||
if (!ObjectUtl.isEquals(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) {
|
||||
log.warn("opc 值不健康 item: {}, 状态: {}", item.getId(), itemState.getQuality());
|
||||
log.warn("opc 值不健康 item: {}, 状态: {},当前读取值:{}, 系统内存值{} ", item.getId(), itemState.getQuality(), value, his);
|
||||
}
|
||||
} while (ObjectUtil.equal(value, his));//如果两次的值相等,不走下面的代码
|
||||
|
||||
OpcItemDto itemDto = this.getItem(item.getId());
|
||||
if (itemDto.getNeed_log() != null && itemDto.getNeed_log()) {
|
||||
//默认记录日志
|
||||
if (true) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
//设备的ITEM项
|
||||
List<String> relate_items = itemDto.getRelate_items();
|
||||
@@ -184,7 +190,7 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
sb.append("key:" + relate + "value:" + obj + ";");
|
||||
}
|
||||
|
||||
log.info("信号{}变更从{}->{};信号快照:{}", new Object[]{item.getId(), his, value, sb});
|
||||
log.warn("信号{}变更从{}->{};信号快照:{}", new Object[]{item.getId(), his, value, sb});
|
||||
|
||||
}
|
||||
// accessor_value.setValueWithPersistence(item.getId(),accessor_value.getValue(item.getId()));
|
||||
@@ -199,6 +205,7 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
try {
|
||||
this.server.disconnect();
|
||||
} catch (Exception var25) {
|
||||
log.warn("{} : server disconnect", var25);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,6 +220,7 @@ public class DeviceOpcProtocolRunable implements Runnable {
|
||||
Thread.sleep((long) (OpcConfig.synchronized_exception_wait_second * 1000));
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
log.warn("OPC 读取线程读取异常{} :", e);
|
||||
// Thread.currentThread().interrupt();不会真正停止线程
|
||||
}
|
||||
++this.error_num;
|
||||
|
||||
@@ -41,6 +41,7 @@ public class OpcUtl {
|
||||
try{
|
||||
e=group.write(requests);
|
||||
group.write(requests);
|
||||
|
||||
}catch (Exception e1){
|
||||
try{
|
||||
e= group.write(requests);
|
||||
|
||||
@@ -13,12 +13,12 @@ spring:
|
||||
druid:
|
||||
db-type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:jn_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
url: jdbc:log4jdbc:mysql://${DB_HOST:192.168.81.252}:${DB_PORT:3306}/${DB_NAME:jn_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
# url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:rljn_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
|
||||
username: ${DB_USER:root}
|
||||
# password: ${DB_PWD:P@ssw0rd}
|
||||
# password: ${DB_PWD:Root.123456}
|
||||
password: ${DB_PWD:123456}
|
||||
password: ${DB_PWD:Root.123456}
|
||||
# password: ${DB_PWD:123456}
|
||||
# 初始连接数
|
||||
initial-size: 5
|
||||
# 最小连接数
|
||||
|
||||
33
acs/hd/nladmin-system/src/main/resources/log/OpcUtl.xml
Normal file
33
acs/hd/nladmin-system/src/main/resources/log/OpcUtl.xml
Normal file
@@ -0,0 +1,33 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<included>
|
||||
<springProperty scope="context" name="logPath" source="logging.file.path" defaultValue="logs"/>
|
||||
<property name="LOG_HOME" value="${logPath}"/>
|
||||
<!-- 按照每天生成日志文件 -->
|
||||
<appender name="FILE20" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||
<!--日志文件输出的文件名-->
|
||||
<FileNamePattern>${LOG_HOME}/下发KEP信号/%d{yyyy-MM-dd}.%i.log</FileNamePattern>
|
||||
<!--日志文件保留天数-->
|
||||
<maxHistory>15</maxHistory>
|
||||
<!--单个日志最大容量 至少10MB才能看得出来-->
|
||||
<maxFileSize>200MB</maxFileSize>
|
||||
<!--所有日志最多占多大容量-->
|
||||
<totalSizeCap>2GB</totalSizeCap>
|
||||
</rollingPolicy>
|
||||
<encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
|
||||
<!--格式化输出:%d表示日期,%thread表示线程名,%-5level:级别从左显示5个字符宽度%msg:日志消息,%n是换行符-->
|
||||
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
||||
<charset>${log.charset}</charset>
|
||||
</encoder>
|
||||
|
||||
</appender>
|
||||
|
||||
<!-- <logger name="org.nl.start.Init" level="info" additivity="false">
|
||||
<appender-ref ref="FILE3"/>
|
||||
</logger>-->
|
||||
|
||||
<!-- 打印sql -->
|
||||
<logger name="org.nl.acs.opc.OpcUtl" level="info" additivity="false">
|
||||
<appender-ref ref="FILE20"/>
|
||||
</logger>
|
||||
</included>
|
||||
@@ -30,7 +30,8 @@ https://juejin.cn/post/6844903775631572999
|
||||
<include resource="log/WmsToAcs.xml"/>
|
||||
<include resource="log/QueryXZAgvTaskStatus.xml"/>
|
||||
<include resource="log/NDCSocketConnectionAutoRun.xml"/>
|
||||
<!-- <include resource="log/QueryMagicAgvDeviceStatus.xml"/>-->
|
||||
<include resource="log/OpcUtl.xml"/>
|
||||
<!-- <include resource="log/QueryMagicAgvDeviceStatus.xml"/>-->
|
||||
|
||||
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
|
||||
Reference in New Issue
Block a user