Commit a40cd118 authored by 高东东's avatar 高东东

Merge branch 'gaodongdong' into develop

parents e35de3be f16c5869
...@@ -17,6 +17,10 @@ public enum RedisKeyEnum { ...@@ -17,6 +17,10 @@ public enum RedisKeyEnum {
return redisKeyEnum.getKey() + "_" + bizKey; return redisKeyEnum.getKey() + "_" + bizKey;
} }
public static String buildKey(String bizKey, String serverId, RedisKeyEnum redisKeyEnum) {
return "ForwardingTable" + ":" + serverId + ":" +bizKey;
}
RedisKeyEnum(String key, String desc) { RedisKeyEnum(String key, String desc) {
this.key = key; this.key = key;
this.desc = desc; this.desc = desc;
......
...@@ -19,7 +19,7 @@ ribbon.ConnectTimeout = 30000 ...@@ -19,7 +19,7 @@ ribbon.ConnectTimeout = 30000
#DB properties: #DB properties:
#spring.datasource.url = jdbc:mysql://172.233.0.6:3306/amos_beijing_command_dev?useSSL=false&allowMultiQueries=true&serverTimezone=Asia/Shanghai #spring.datasource.url = jdbc:mysql://172.233.0.6:3306/amos_beijing_command_dev?useSSL=false&allowMultiQueries=true&serverTimezone=Asia/Shanghai
spring.datasource.url = jdbc:mysql://172.16.11.33:3306/amos_iec?useSSL=false&allowMultiQueries=true&serverTimezone=Asia/Shanghai spring.datasource.url = jdbc:mysql://172.16.11.33:3306/amos_iec_dev?useSSL=false&allowMultiQueries=true&serverTimezone=Asia/Shanghai
spring.datasource.username = root spring.datasource.username = root
spring.datasource.password = admin_1234 spring.datasource.password = admin_1234
...@@ -68,10 +68,10 @@ liquibase.enabled: true ...@@ -68,10 +68,10 @@ liquibase.enabled: true
#redis database index #redis database index
spring.redis.database=5 spring.redis.database=5
#redis ip #redis ip
spring.redis.host=172.16.11.33 spring.redis.host=172.16.10.85
spring.redis.port=6379 spring.redis.port=6379
#redis password (default is empty) #redis password (default is empty)
spring.redis.password=1234560 spring.redis.password=amos2019Redis
#max connect number #max connect number
spring.redis.pool.max-active=200 spring.redis.pool.max-active=200
# redis max wait time ( -1 is not limit) # redis max wait time ( -1 is not limit)
...@@ -79,15 +79,3 @@ spring.redis.pool.max-wait=-1 ...@@ -79,15 +79,3 @@ spring.redis.pool.max-wait=-1
spring.redis.pool.max-idle=10 spring.redis.pool.max-idle=10
spring.redis.pool.min-idle=0 spring.redis.pool.min-idle=0
spring.redis.timeout=1000 spring.redis.timeout=1000
#iec104.debug = false
#iec104.tcp.service.reomteIp=172.233.0.4
#iec104.tcp.service.reomtePort=2404
#iec104.server.Id=1
#iec104.tcp.bind.port=2404
#iec104.client.commonAddress=0000
#iec104.server.start.infomation.address = 1
#iec104.server.consecutive.transmissions.number = 6
#iec104.server.zz.max.transmissions.number = 100
#iec104.server.soe.max.transmissions.number = 10
#iec104.server.sec.max.transmissions.number = 10
\ No newline at end of file
...@@ -102,10 +102,13 @@ public class ApduQueue { ...@@ -102,10 +102,13 @@ public class ApduQueue {
data.setCommonAddress(asdu.getCommonAddress()); data.setCommonAddress(asdu.getCommonAddress());
data.setCreatedTime(new Date()); data.setCreatedTime(new Date());
data.setDataType(2); data.setDataType(2);
// data.setSoe(1);
data.setInformationAddress(informationObjectAddress); data.setInformationAddress(informationObjectAddress);
IeFloat shortFloat = (IeFloat) informationElement[0][0];
IeInteger shortFloat = (IeInteger) informationElement[0][0];
IeQuality ieQuality = (IeQuality) informationElement[0][1]; IeQuality ieQuality = (IeQuality) informationElement[0][1];
data.setValue(String.format("%.2f",shortFloat.getValue()));
data.setValue(String.format("%d",shortFloat.getValue()));
data.setQuality(ieQuality.toJson().toString()); data.setQuality(ieQuality.toJson().toString());
data.setIsBlocked(ieQuality.isBlocked() ? 0 : 1); data.setIsBlocked(ieQuality.isBlocked() ? 0 : 1);
data.setIsSubstituted(ieQuality.isSubstituted() ? 0 : 1); data.setIsSubstituted(ieQuality.isSubstituted() ? 0 : 1);
...@@ -117,6 +120,7 @@ public class ApduQueue { ...@@ -117,6 +120,7 @@ public class ApduQueue {
RecDataQueue.getInstance().add(data); RecDataQueue.getInstance().add(data);
// } // }
} }
break;
case 13: case 13:
InformationObject[] floatInformationObjects = asdu.getInformationObjects(); InformationObject[] floatInformationObjects = asdu.getInformationObjects();
numberOfSequenceElements = asdu.getSequenceLength(); numberOfSequenceElements = asdu.getSequenceLength();
...@@ -125,14 +129,16 @@ public class ApduQueue { ...@@ -125,14 +129,16 @@ public class ApduQueue {
InformationElement[][] informationElement = obj.getInformationElements(); InformationElement[][] informationElement = obj.getInformationElements();
int informationObjectAddress = obj.getInformationObjectAddress(); int informationObjectAddress = obj.getInformationObjectAddress();
// for (int i = 0; i < numberOfSequenceElements; i++) {
RecData data = new RecData(serverId); RecData data = new RecData(serverId);
data.setCommonAddress(asdu.getCommonAddress()); data.setCommonAddress(asdu.getCommonAddress());
data.setCreatedTime(new Date()); data.setCreatedTime(new Date());
data.setDataType(2); data.setDataType(2);
// data.setSoe(1);
data.setInformationAddress(informationObjectAddress); data.setInformationAddress(informationObjectAddress);
IeShortFloat shortFloat = (IeShortFloat) informationElement[0][0]; IeShortFloat shortFloat = (IeShortFloat) informationElement[0][0];
IeQuality ieQuality = (IeQuality) informationElement[0][1]; IeQuality ieQuality = (IeQuality) informationElement[0][1];
data.setValue(String.format("%.2f",shortFloat.getValue())); data.setValue(String.format("%.2f",shortFloat.getValue()));
data.setQuality(ieQuality.toJson().toString()); data.setQuality(ieQuality.toJson().toString());
data.setIsBlocked(ieQuality.isBlocked() ? 0 : 1); data.setIsBlocked(ieQuality.isBlocked() ? 0 : 1);
...@@ -159,9 +165,12 @@ public class ApduQueue { ...@@ -159,9 +165,12 @@ public class ApduQueue {
data.setCommonAddress(asdu.getCommonAddress()); data.setCommonAddress(asdu.getCommonAddress());
data.setCreatedTime(new Date()); data.setCreatedTime(new Date());
data.setDataType(2); data.setDataType(2);
// data.setSoe(1);
data.setInformationAddress(informationObjectAddress); data.setInformationAddress(informationObjectAddress);
IeShortFloat shortFloat = (IeShortFloat) informationElement[0][0];
data.setValue(String.format("%.2f",shortFloat.getValue())); IeInteger shortFloat = (IeInteger) informationElement[0][0];
data.setValue(String.format("%d",shortFloat.getValue()));
informationObjectAddress++; informationObjectAddress++;
RecDataQueue.getInstance().add(data); RecDataQueue.getInstance().add(data);
......
...@@ -76,7 +76,7 @@ public class GeneralDataQueue { ...@@ -76,7 +76,7 @@ public class GeneralDataQueue {
Runnable task_runnable = new Runnable() { Runnable task_runnable = new Runnable() {
private boolean alarmParamIsChange(AlarmParam alarmParam) { private boolean alarmParamIsChange(AlarmParam alarmParam) {
String redisKey = RedisKeyEnum.buildKey(alarmParam.getPointCode(), RedisKeyEnum.K001); String redisKey = RedisKeyEnum.buildKey(alarmParam.getPointCode(), alarmParam.getServiceId(),RedisKeyEnum.K001);
String data = redisTemplate.opsForValue().get(redisKey); String data = redisTemplate.opsForValue().get(redisKey);
if (StringUtils.isEmpty(data)) { if (StringUtils.isEmpty(data)) {
redisTemplate.opsForValue().set(redisKey, JSONObject.toJSONString(alarmParam)); redisTemplate.opsForValue().set(redisKey, JSONObject.toJSONString(alarmParam));
......
...@@ -6,6 +6,7 @@ import java.util.concurrent.LinkedBlockingQueue; ...@@ -6,6 +6,7 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ScheduledExecutorService; import java.util.concurrent.ScheduledExecutorService;
import com.yeejoin.amos.connect.dao.entity.PointConfigVo; import com.yeejoin.amos.connect.dao.entity.PointConfigVo;
import com.yeejoin.amos.iec104.tcp.utils.ChangeUtils;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import com.yeejoin.amos.iec104.business.constants.IEC104Constant; import com.yeejoin.amos.iec104.business.constants.IEC104Constant;
...@@ -112,6 +113,8 @@ public class RecDataQueue { ...@@ -112,6 +113,8 @@ public class RecDataQueue {
alarm.setServiceId(data.getServerId()); alarm.setServiceId(data.getServerId());
alarm.setIsInvalid(data.getIsInvalid()); alarm.setIsInvalid(data.getIsInvalid());
PointConfigVo vo = pointConfigService.findByServicesIdAndInfoAddress(data.getServerId(), data.getInformationAddress()); PointConfigVo vo = pointConfigService.findByServicesIdAndInfoAddress(data.getServerId(), data.getInformationAddress());
Logger.getLogger(this.getClass()).debug("给业务发送数据: " + vo.toString());
// PointConfigVo vo = pointConfigService.findByServicesIdAndInfoAddress(data.getServerId(), informationAddress, informationType);
alarm.setPointCode(vo.getPointCode()); alarm.setPointCode(vo.getPointCode());
alarm.setSoe(data.getSoe()); alarm.setSoe(data.getSoe());
try { try {
......
...@@ -17,7 +17,7 @@ public class IeCP56Time2a extends InformationElement{ ...@@ -17,7 +17,7 @@ public class IeCP56Time2a extends InformationElement{
// protected byte[] date = { (byte) 0xAD, (byte)0x39 , (byte)0x1C, (byte)0x10, (byte)0x7A , (byte)0x0B, (byte)0x05}; // protected byte[] date = { (byte) 0xAD, (byte)0x39 , (byte)0x1C, (byte)0x10, (byte)0x7A , (byte)0x0B, (byte)0x05};
public IeCP56Time2a(ByteBuf is) throws IOException { public IeCP56Time2a(ByteBuf is) throws IOException {
if (is.readableBytes() > 7) { if (is.readableBytes() >= 7) {
is.readBytes(date); is.readBytes(date);
} }
} }
......
...@@ -4,22 +4,22 @@ import io.netty.buffer.ByteBuf; ...@@ -4,22 +4,22 @@ import io.netty.buffer.ByteBuf;
import java.io.IOException; import java.io.IOException;
public class IeFloat extends InformationElement { public class IeInteger extends InformationElement {
private final float value; private final int value;
public IeFloat(float value) { public IeInteger(int value) {
this.value = value; this.value = value;
} }
public IeFloat(ByteBuf is) throws IOException { public IeInteger(ByteBuf is) throws IOException {
value = Float.intBitsToFloat((is.readByte() & 0xff) | ((is.readByte() & 0xff) << 8)); value = (is.readByte() & 0xff) | ((is.readByte() & 0xff) << 8);
} }
@Override @Override
public int encode(byte[] buffer, int i) { public int encode(byte[] buffer, int i) {
int tempVal = Float.floatToIntBits(value); int tempVal = value;
buffer[i++] = (byte) tempVal; buffer[i++] = (byte) tempVal;
buffer[i] = (byte) (tempVal >> 8); buffer[i] = (byte) (tempVal >> 8);
...@@ -32,6 +32,6 @@ public class IeFloat extends InformationElement { ...@@ -32,6 +32,6 @@ public class IeFloat extends InformationElement {
@Override @Override
public String toString() { public String toString() {
return "短浮点数值: " + value; return "归一化数值: " + value;
} }
} }
...@@ -44,10 +44,11 @@ public class InformationObject { ...@@ -44,10 +44,11 @@ public class InformationObject {
case 9: case 9:
informationElements = new InformationElement[numberOfSequenceElements][2]; informationElements = new InformationElement[numberOfSequenceElements][2];
for (int i = 0; i < numberOfSequenceElements; i++) { for (int i = 0; i < numberOfSequenceElements; i++) {
informationElements[i][0] = new IeFloat(is); informationElements[i][0] = new IeInteger(is);
informationElements[i][1] = new IeQuality(is); informationElements[i][1] = new IeQuality(is);
log.debug("9 浮点型遥测1: " + i + "--->" + informationElements[i][0].toString()); log.debug("9 地址: " + i + "--->" + this.informationObjectAddress);
log.debug("9 浮点型遥测2: " + i + "--->" + informationElements[i][1].toString()); log.debug("9 归一化值: " + i + "--->" + informationElements[i][0].toString());
log.debug("9 品质: " + i + "--->" + informationElements[i][1].toString());
} }
break; break;
// 13 浮点型遥测 // 13 浮点型遥测
...@@ -64,8 +65,8 @@ public class InformationObject { ...@@ -64,8 +65,8 @@ public class InformationObject {
case 21: case 21:
informationElements = new InformationElement[numberOfSequenceElements][1]; informationElements = new InformationElement[numberOfSequenceElements][1];
for (int i = 0; i < numberOfSequenceElements; i++) { for (int i = 0; i < numberOfSequenceElements; i++) {
informationElements[i][0] = new IeFloat(is); informationElements[i][0] = new IeInteger(is);
log.debug("21 浮点型遥测, 不带品质描述词的规一化值: " + i + "--->" + informationElements[i][0].toString()); log.debug("21 不带品质描述词的规一化值: " + i + "--->" + informationElements[i][0].toString());
} }
break; break;
// 30 带 CP56Time2a 时标的单点信息 // 30 带 CP56Time2a 时标的单点信息
......
...@@ -42,8 +42,7 @@ public class Session { ...@@ -42,8 +42,7 @@ public class Session {
long timeRecorder = 0; long timeRecorder = 0;
private long recordTime = 0; private long recordTime = 0;
private ReentrantLock serialLock = new ReentrantLock(); private ReentrantLock serialLock = new ReentrantLock();
// private Semaphore secruitingSemaphore = new Semaphore(1);
// boolean startCommunication = false;
boolean stopCommunication = false; boolean stopCommunication = false;
boolean startRecruiting = false; boolean startRecruiting = false;
CountDownLatch latch; CountDownLatch latch;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment