feat: 增加局放谱图解析功能
parent
a6b1def256
commit
a33d677671
@ -0,0 +1,89 @@
|
||||
package com.xydl.cac.model.spectrogram;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class SouthPd extends SpectrogramModel {
|
||||
Float version;
|
||||
Float fileVersion;
|
||||
Short code;
|
||||
String flag;
|
||||
String name;
|
||||
String pdType;
|
||||
String warnLevel;
|
||||
String probabilityFlag;
|
||||
Float probability1;
|
||||
Float probability2;
|
||||
Float probability3;
|
||||
Float probability4;
|
||||
Float probability5;
|
||||
Float probability6;
|
||||
Float probability7;
|
||||
Integer m;
|
||||
Integer n;
|
||||
Integer p;
|
||||
Float hz50;
|
||||
Float hz100;
|
||||
String picType;
|
||||
String unit;
|
||||
Float minLimit;
|
||||
Float maxLimit;
|
||||
|
||||
List<List<Integer>> dataPD;
|
||||
List<List<Float>> dataPS;
|
||||
|
||||
public void readFrom(DataInputStream dis) throws Exception {
|
||||
version = readLittleEndianFloat(dis);
|
||||
fileVersion = readLittleEndianFloat(dis);
|
||||
code = readLittleEndianShort(dis);
|
||||
createTime = readLittleEndianLong(dis);
|
||||
flag = readString(dis, 1);
|
||||
name = readString(dis, 32);
|
||||
pdType = readString(dis, 1);
|
||||
warnLevel = readString(dis, 1);
|
||||
probabilityFlag = readString(dis, 1);
|
||||
probability1 = readLittleEndianFloat(dis);
|
||||
probability2 = readLittleEndianFloat(dis);
|
||||
probability3 = readLittleEndianFloat(dis);
|
||||
probability4 = readLittleEndianFloat(dis);
|
||||
probability5 = readLittleEndianFloat(dis);
|
||||
probability6 = readLittleEndianFloat(dis);
|
||||
probability7 = readLittleEndianFloat(dis);
|
||||
m = readLittleEndianInt(dis);
|
||||
n = readLittleEndianInt(dis);
|
||||
p = readLittleEndianInt(dis);
|
||||
hz50 = readLittleEndianFloat(dis);
|
||||
hz100 = readLittleEndianFloat(dis);
|
||||
picType = readString(dis, 1);
|
||||
unit = readString(dis, 1);
|
||||
minLimit = readLittleEndianFloat(dis);
|
||||
maxLimit = readLittleEndianFloat(dis);
|
||||
dis.readInt();
|
||||
|
||||
if ("0".equalsIgnoreCase(picType)) {
|
||||
dataPD = new ArrayList<>();
|
||||
for (int i = 0; i < m; i++) {
|
||||
List<Integer> list = new ArrayList<>();
|
||||
for (int j = 0; j < n; j++) {
|
||||
Integer v = readLittleEndianInt(dis);
|
||||
list.add(v);
|
||||
}
|
||||
dataPD.add(list);
|
||||
}
|
||||
} else if ("1".equalsIgnoreCase(picType)) {
|
||||
dataPS = new ArrayList<>();
|
||||
for (int i = 0; i < p; i++) {
|
||||
List<Float> list = new ArrayList<>();
|
||||
for (int j = 0; j < m; j++) {
|
||||
Float v = readLittleEndianFloat(dis);
|
||||
list.add(v);
|
||||
}
|
||||
dataPS.add(list);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package com.xydl.cac.spectrogram;
|
||||
|
||||
import com.xydl.cac.model.spectrogram.SouthPd;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.FileInputStream;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class ProcessorPd {
|
||||
|
||||
public SouthPd process(String localFilePath) {
|
||||
try (DataInputStream dis = new DataInputStream(new FileInputStream(localFilePath))) {
|
||||
SouthPd model = this.readOneBlock(dis);
|
||||
return model;
|
||||
} catch (Exception e) {
|
||||
log.error("解析文件失败" + localFilePath, e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private SouthPd readOneBlock(DataInputStream dis) throws Exception {
|
||||
SouthPd model = new SouthPd();
|
||||
model.readFrom(dis);
|
||||
return model;
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
ProcessorPd processorYsp = new ProcessorPd();
|
||||
processorYsp.process("C:/Code/cac/局放谱图/50100055_5__001_01_20250409180000.dat");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue