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

Merge branch 'gaodongdong' into develop

parents e35de3be f16c5869
......@@ -17,6 +17,10 @@ public enum RedisKeyEnum {
return redisKeyEnum.getKey() + "_" + bizKey;
}
public static String buildKey(String bizKey, String serverId, RedisKeyEnum redisKeyEnum) {
return "ForwardingTable" + ":" + serverId + ":" +bizKey;
}
RedisKeyEnum(String key, String desc) {
this.key = key;
this.desc = desc;
......
......@@ -19,7 +19,7 @@ ribbon.ConnectTimeout = 30000
#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.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.password = admin_1234
......@@ -68,10 +68,10 @@ liquibase.enabled: true
#redis database index
spring.redis.database=5
#redis ip
spring.redis.host=172.16.11.33
spring.redis.host=172.16.10.85
spring.redis.port=6379
#redis password (default is empty)
spring.redis.password=1234560
spring.redis.password=amos2019Redis
#max connect number
spring.redis.pool.max-active=200
# redis max wait time ( -1 is not limit)
......@@ -79,15 +79,3 @@ spring.redis.pool.max-wait=-1
spring.redis.pool.max-idle=10
spring.redis.pool.min-idle=0
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 {
data.setCommonAddress(asdu.getCommonAddress());
data.setCreatedTime(new Date());
data.setDataType(2);
// data.setSoe(1);
data.setInformationAddress(informationObjectAddress);
IeFloat shortFloat = (IeFloat) informationElement[0][0];
IeInteger shortFloat = (IeInteger) informationElement[0][0];
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.setIsBlocked(ieQuality.isBlocked() ? 0 : 1);
data.setIsSubstituted(ieQuality.isSubstituted() ? 0 : 1);
......@@ -117,6 +120,7 @@ public class ApduQueue {
RecDataQueue.getInstance().add(data);
// }
}
break;
case 13:
InformationObject[] floatInformationObjects = asdu.getInformationObjects();
numberOfSequenceElements = asdu.getSequenceLength();
......@@ -125,14 +129,16 @@ public class ApduQueue {
InformationElement[][] informationElement = obj.getInformationElements();
int informationObjectAddress = obj.getInformationObjectAddress();
// for (int i = 0; i < numberOfSequenceElements; i++) {
RecData data = new RecData(serverId);
data.setCommonAddress(asdu.getCommonAddress());
data.setCreatedTime(new Date());
data.setDataType(2);
// data.setSoe(1);
data.setInformationAddress(informationObjectAddress);
IeShortFloat shortFloat = (IeShortFloat) informationElement[0][0];
IeQuality ieQuality = (IeQuality) informationElement[0][1];
data.setValue(String.format("%.2f",shortFloat.getValue()));
data.setQuality(ieQuality.toJson().toString());
data.setIsBlocked(ieQuality.isBlocked() ? 0 : 1);
......@@ -159,9 +165,12 @@ public class ApduQueue {
data.setCommonAddress(asdu.getCommonAddress());
data.setCreatedTime(new Date());
data.setDataType(2);
// data.setSoe(1);
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++;
RecDataQueue.getInstance().add(data);
......
......@@ -76,7 +76,7 @@ public class GeneralDataQueue {
Runnable task_runnable = new Runnable() {
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);
if (StringUtils.isEmpty(data)) {
redisTemplate.opsForValue().set(redisKey, JSONObject.toJSONString(alarmParam));
......
......@@ -6,6 +6,7 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ScheduledExecutorService;
import com.yeejoin.amos.connect.dao.entity.PointConfigVo;
import com.yeejoin.amos.iec104.tcp.utils.ChangeUtils;
import org.apache.log4j.Logger;
import com.yeejoin.amos.iec104.business.constants.IEC104Constant;
......@@ -112,6 +113,8 @@ public class RecDataQueue {
alarm.setServiceId(data.getServerId());
alarm.setIsInvalid(data.getIsInvalid());
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.setSoe(data.getSoe());
try {
......
......@@ -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};
public IeCP56Time2a(ByteBuf is) throws IOException {
if (is.readableBytes() > 7) {
if (is.readableBytes() >= 7) {
is.readBytes(date);
}
}
......
......@@ -4,22 +4,22 @@ import io.netty.buffer.ByteBuf;
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;
}
public IeFloat(ByteBuf is) throws IOException {
value = Float.intBitsToFloat((is.readByte() & 0xff) | ((is.readByte() & 0xff) << 8));
public IeInteger(ByteBuf is) throws IOException {
value = (is.readByte() & 0xff) | ((is.readByte() & 0xff) << 8);
}
@Override
public int encode(byte[] buffer, int i) {
int tempVal = Float.floatToIntBits(value);
int tempVal = value;
buffer[i++] = (byte) tempVal;
buffer[i] = (byte) (tempVal >> 8);
......@@ -32,6 +32,6 @@ public class IeFloat extends InformationElement {
@Override
public String toString() {
return "短浮点数值: " + value;
return "归一化数值: " + value;
}
}
......@@ -44,10 +44,11 @@ public class InformationObject {
case 9:
informationElements = new InformationElement[numberOfSequenceElements][2];
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);
log.debug("9 浮点型遥测1: " + i + "--->" + informationElements[i][0].toString());
log.debug("9 浮点型遥测2: " + i + "--->" + informationElements[i][1].toString());
log.debug("9 地址: " + i + "--->" + this.informationObjectAddress);
log.debug("9 归一化值: " + i + "--->" + informationElements[i][0].toString());
log.debug("9 品质: " + i + "--->" + informationElements[i][1].toString());
}
break;
// 13 浮点型遥测
......@@ -64,8 +65,8 @@ public class InformationObject {
case 21:
informationElements = new InformationElement[numberOfSequenceElements][1];
for (int i = 0; i < numberOfSequenceElements; i++) {
informationElements[i][0] = new IeFloat(is);
log.debug("21 浮点型遥测, 不带品质描述词的规一化值: " + i + "--->" + informationElements[i][0].toString());
informationElements[i][0] = new IeInteger(is);
log.debug("21 不带品质描述词的规一化值: " + i + "--->" + informationElements[i][0].toString());
}
break;
// 30 带 CP56Time2a 时标的单点信息
......
......@@ -42,8 +42,7 @@ public class Session {
long timeRecorder = 0;
private long recordTime = 0;
private ReentrantLock serialLock = new ReentrantLock();
// private Semaphore secruitingSemaphore = new Semaphore(1);
// boolean startCommunication = false;
boolean stopCommunication = false;
boolean startRecruiting = false;
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