This commit is contained in:
USER-20220102CG\noblelift
2022-08-16 19:48:25 +08:00
parent ebb5bfe01a
commit cf70ac11fb
2 changed files with 15 additions and 3 deletions

View File

@@ -8,6 +8,8 @@ import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.opc.Device;
import org.nl.acs.opc.OpcItemDto;
import org.nl.modules.udw.UnifiedDataAccessor;
import org.nl.utils.RedisUtils;
import org.nl.utils.SpringContextHolder;
import org.nl.wql.core.bean.WQLObject;
import java.util.ArrayList;
@@ -74,7 +76,9 @@ public interface OpcDeviceDriver extends DeviceDriver {
}
default Object getValue(String protocol) {
return this.getOpcValueAccessor().getValue(this.getItem(protocol));
// return this.getOpcValueAccessor().getValue(this.getItem(protocol));
RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class);
return redisUtils.get(this.getItem(protocol));
}
default String getItem(String item) {

View File

@@ -6,6 +6,8 @@ import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.udw.UnifiedDataAccessor;
import org.nl.modules.udw.UnifiedDataAccessorFactory;
import org.nl.utils.RedisUtils;
import org.nl.utils.SpringContextHolder;
import org.openscada.opc.lib.da.Group;
import org.openscada.opc.lib.da.Item;
import org.openscada.opc.lib.da.ItemState;
@@ -150,7 +152,10 @@ public class DeviceOpcProtocolRunable implements Runnable {
item = (Item) var18.next();
ItemState itemState = (ItemState) itemStatus.get(item);
value = OpcUtl.getValue(item, itemState);
his = accessor_value.getValue(item.getId());
// his = accessor_value.getValue(item.getId());
RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class);
his=redisUtils.get(item.getId());
if (!ObjectUtil.equal(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) {
log.warn("opc 值不健康 item: {}, 状态: {}", item.getId(), itemState.getQuality());
}
@@ -173,7 +178,10 @@ public class DeviceOpcProtocolRunable implements Runnable {
}
//设置值
accessor_value.setValue(item.getId(), value);
// accessor_value.setValue(item.getId(), value);
RedisUtils redisUtils = SpringContextHolder.getBean(RedisUtils.class);
redisUtils.set(item.getId(), value);
}
}