feat: 增加南网谱图结构解析

dev
huangfeng 4 months ago
parent 594271831d
commit 4bd1c833d1

@ -0,0 +1,52 @@
package com.xydl.cac.model.spectrogram;
import lombok.Data;
import java.io.DataInputStream;
import java.util.ArrayList;
import java.util.List;
@Data
public class SouthYsp extends SpectrogramModel {
Float version;
Float fileVersion;
Short type;
Long createTime;
Integer flag;
String name;
Float xInterval;
Float yMax;
Integer xUnit;
Integer yUnit;
Integer k;
Integer m;
List<SouthYspChannel> channels = new ArrayList<>();
public void readFrom(DataInputStream dis) throws Exception {
version = dis.readFloat();
fileVersion = dis.readFloat();
type = dis.readShort();
createTime = dis.readLong();
flag = dis.read();
StringBuilder sb = new StringBuilder();
for (int i = 0; i < 32; i++) {
char c = (char) dis.readByte();
sb.append(c);
}
name = sb.toString();
xInterval = dis.readFloat();
yMax = dis.readFloat();
xUnit = dis.read();
yUnit = dis.read();
k = dis.readInt();
m = dis.read();
for (int i = 0; i < m; i++) {
SouthYspChannel channel = new SouthYspChannel();
channel.readFrom(dis);
channels.add(channel);
}
for (SouthYspChannel channel : channels) {
channel.readDataFrom(dis, k);
}
}
}

@ -0,0 +1,30 @@
package com.xydl.cac.model.spectrogram;
import lombok.Data;
import java.io.DataInputStream;
import java.util.ArrayList;
import java.util.List;
@Data
public class SouthYspChannel {
Integer n;
List<YspChannelCrest> crests = new ArrayList<>();
List<Float> data = new ArrayList<>();
public void readFrom(DataInputStream dis) throws Exception {
n = dis.read();
for (int i = 0; i < n; i++) {
YspChannelCrest crest = new YspChannelCrest();
crest.readFrom(dis);
crests.add(crest);
}
}
public void readDataFrom(DataInputStream dis, Integer k) throws Exception {
for (int i = 0; i < k; i++) {
Float v = dis.readFloat();
data.add(v);
}
}
}

@ -7,7 +7,7 @@ import java.util.ArrayList;
import java.util.List;
@Data
public class YspModel extends SpectrogramModel {
public class Ysp extends SpectrogramModel {
Integer code;
Integer length;
Long createTime;
@ -18,7 +18,7 @@ public class YspModel extends SpectrogramModel {
Integer yUnit;
Integer k;
Integer m;
List<YspWay> wayList = new ArrayList<>();
List<YspChannel> channels = new ArrayList<>();
public void readFrom(DataInputStream dis) throws Exception {
code = dis.read();
@ -32,9 +32,9 @@ public class YspModel extends SpectrogramModel {
k = dis.readInt();
m = dis.read();
for (int i = 0; i < m; i++) {
YspWay way = new YspWay();
way.readFrom(dis, k);
wayList.add(way);
YspChannel channel = new YspChannel();
channel.readFrom(dis, k);
channels.add(channel);
}
}
}

@ -7,21 +7,21 @@ import java.util.ArrayList;
import java.util.List;
@Data
public class YspWay {
public class YspChannel {
Integer n;
List<YspWayHump> humpList = new ArrayList<>();
List<Float> valueList = new ArrayList<>();
List<YspChannelCrest> crests = new ArrayList<>();
List<Float> data = new ArrayList<>();
public void readFrom(DataInputStream dis, Integer k) throws Exception {
n = dis.read();
for (int i = 0; i < n; i++) {
YspWayHump hump = new YspWayHump();
hump.readFrom(dis);
humpList.add(hump);
YspChannelCrest crest = new YspChannelCrest();
crest.readFrom(dis);
crests.add(crest);
}
for (int i = 0; i < k; i++) {
Float v = dis.readFloat();
valueList.add(v);
data.add(v);
}
}
}

@ -5,13 +5,13 @@ import lombok.Data;
import java.io.DataInputStream;
@Data
public class YspWayHump {
public class YspChannelCrest {
String name;
Integer j;
Float time;
Float startTime;
Float endTime;
Float high;
Float height;
Float area;
public void readFrom(DataInputStream dis) throws Exception {
@ -25,7 +25,7 @@ public class YspWayHump {
time = dis.readFloat();
startTime = dis.readFloat();
endTime = dis.readFloat();
high = dis.readFloat();
height = dis.readFloat();
area = dis.readFloat();
}
}

@ -1,6 +1,6 @@
package com.xydl.cac.spectrogram;
import com.xydl.cac.model.spectrogram.YspModel;
import com.xydl.cac.model.spectrogram.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@ -11,18 +11,18 @@ import java.io.FileInputStream;
@Slf4j
public class ProcessorYsp {
public YspModel process(String localFilePath) {
public SouthYsp process(String localFilePath) {
try (DataInputStream dis = new DataInputStream(new FileInputStream(localFilePath))) {
YspModel model = this.readOneBlock(dis);
SouthYsp model = this.readOneBlock(dis);
return model;
} catch (Exception e) {
e.printStackTrace();
log.error("解析文件失败" + localFilePath, e);
return null;
}
}
private YspModel readOneBlock(DataInputStream dis) throws Exception {
YspModel model = new YspModel();
private SouthYsp readOneBlock(DataInputStream dis) throws Exception {
SouthYsp model = new SouthYsp();
model.readFrom(dis);
return model;
}

Loading…
Cancel
Save