|
@@ -1,25 +1,21 @@
|
|
package com.jiayue.pfr.service.alg.listener;
|
|
package com.jiayue.pfr.service.alg.listener;
|
|
|
|
|
|
import com.jiayue.pfr.backenum.ActionResetEnum;
|
|
import com.jiayue.pfr.backenum.ActionResetEnum;
|
|
|
|
+import com.jiayue.pfr.backenum.TunnelStatus;
|
|
|
|
+import com.jiayue.pfr.container.ProtocolTunnelContainer;
|
|
import com.jiayue.pfr.entity.BizYaoData;
|
|
import com.jiayue.pfr.entity.BizYaoData;
|
|
import com.jiayue.pfr.service.alg.BizYaoDataService;
|
|
import com.jiayue.pfr.service.alg.BizYaoDataService;
|
|
|
|
+import com.jiayue.pfr.tunnelworker.BaseProtocolTunnel;
|
|
|
|
+import com.jiayue.pfr.tunnelworker.gathers.iml.Iec104TcpDataGather;
|
|
|
|
+
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.context.ApplicationListener;
|
|
import org.springframework.context.ApplicationListener;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
-import wei.yigulu.iec104.apdumodel.Apdu;
|
|
|
|
-import wei.yigulu.iec104.apdumodel.Asdu;
|
|
|
|
-import wei.yigulu.iec104.asdudataframe.SingleBooleanCommand;
|
|
|
|
-import wei.yigulu.iec104.asdudataframe.typemodel.IeSingleBooleanCommand;
|
|
|
|
-import wei.yigulu.iec104.asdudataframe.typemodel.IecDataInterface;
|
|
|
|
-import wei.yigulu.iec104.asdudataframe.typemodel.InformationBodyAddress;
|
|
|
|
-import wei.yigulu.iec104.nettyconfig.Iec104MasterBuilder;
|
|
|
|
-import wei.yigulu.iec104.util.CommandWaiter;
|
|
|
|
-import wei.yigulu.iec104.util.SendAndReceiveNumUtil;
|
|
|
|
import wei.yigulu.iec104.util.SendCommandHelper;
|
|
import wei.yigulu.iec104.util.SendCommandHelper;
|
|
-import wei.yigulu.netty.AbstractMasterBuilder;
|
|
|
|
|
|
+
|
|
|
|
|
|
/**
|
|
/**
|
|
* 给AGC闭锁
|
|
* 给AGC闭锁
|
|
@@ -33,48 +29,52 @@ public class AgcLockListener implements ApplicationListener<AgcEvent> {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
BizYaoDataService bizYaoDataService;
|
|
BizYaoDataService bizYaoDataService;
|
|
-// @Autowired
|
|
|
|
-// Iec104MasterBuilder agc104MasterBuilder;
|
|
|
|
|
|
+ // @Autowired
|
|
|
|
+ // Iec104MasterBuilder agc104MasterBuilder;
|
|
|
|
|
|
@Async
|
|
@Async
|
|
@Override
|
|
@Override
|
|
public void onApplicationEvent(AgcEvent agcEvent) {
|
|
public void onApplicationEvent(AgcEvent agcEvent) {
|
|
Object obj = agcEvent.getSource();
|
|
Object obj = agcEvent.getSource();
|
|
BizYaoData bizYaoData = agcEvent.getBizYaoData();
|
|
BizYaoData bizYaoData = agcEvent.getBizYaoData();
|
|
- if (obj.toString().equals(ActionResetEnum.ACTION.getCode())){
|
|
|
|
|
|
+ if (obj.toString().equals(ActionResetEnum.ACTION.getCode())) {
|
|
// 动作
|
|
// 动作
|
|
fLogger.info("AGC闭锁开始");
|
|
fLogger.info("AGC闭锁开始");
|
|
boolean bsBoolean = false;
|
|
boolean bsBoolean = false;
|
|
- try {
|
|
|
|
-// bsBoolean = SendCommandHelper.sendBooleanCommand(agc104MasterBuilder, 0, 1, 25089, true);
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- throw new RuntimeException(e);
|
|
|
|
|
|
+ BaseProtocolTunnel tunnel = ProtocolTunnelContainer.getInstance().getTunnel(12);
|
|
|
|
+ if (tunnel instanceof Iec104TcpDataGather) {
|
|
|
|
+ try {
|
|
|
|
+ if (TunnelStatus.ABLE_STATUS.contains(tunnel.getTunnelStatus())) {
|
|
|
|
+ bsBoolean = SendCommandHelper.sendBooleanCommand(
|
|
|
|
+ ((Iec104TcpDataGather) tunnel).getMasterBuilder(), 0, 1, 25089, true);
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- if (bsBoolean){
|
|
|
|
|
|
+ if (bsBoolean) {
|
|
bizYaoData.setAgcLock("0");
|
|
bizYaoData.setAgcLock("0");
|
|
bizYaoDataService.update(bizYaoData);
|
|
bizYaoDataService.update(bizYaoData);
|
|
fLogger.info("AGC闭锁成功");
|
|
fLogger.info("AGC闭锁成功");
|
|
- }
|
|
|
|
- else {
|
|
|
|
|
|
+ } else {
|
|
fLogger.info("AGC闭锁失败");
|
|
fLogger.info("AGC闭锁失败");
|
|
}
|
|
}
|
|
- }
|
|
|
|
- else if (obj.toString().equals(ActionResetEnum.RESET.getCode())){
|
|
|
|
|
|
+ } else if (obj.toString().equals(ActionResetEnum.RESET.getCode())) {
|
|
boolean bsBoolean = false;
|
|
boolean bsBoolean = false;
|
|
try {
|
|
try {
|
|
-// bsBoolean = SendCommandHelper.sendBooleanCommand(agc104MasterBuilder, 0, 1, 25089, false);
|
|
|
|
|
|
+ // bsBoolean = SendCommandHelper.sendBooleanCommand(agc104MasterBuilder, 0, 1,
|
|
|
|
+ // 25089, false);
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
throw new RuntimeException(e);
|
|
throw new RuntimeException(e);
|
|
}
|
|
}
|
|
|
|
|
|
- if (bsBoolean){
|
|
|
|
|
|
+ if (bsBoolean) {
|
|
// 复归
|
|
// 复归
|
|
bizYaoData.setAgcLock("1");
|
|
bizYaoData.setAgcLock("1");
|
|
bizYaoDataService.update(bizYaoData);
|
|
bizYaoDataService.update(bizYaoData);
|
|
fLogger.info("AGC解锁成功");
|
|
fLogger.info("AGC解锁成功");
|
|
- }
|
|
|
|
- else {
|
|
|
|
|
|
+ } else {
|
|
fLogger.info("AGC解锁失败");
|
|
fLogger.info("AGC解锁失败");
|
|
}
|
|
}
|
|
}
|
|
}
|