暂态原因算法bug修复
This commit is contained in:
@@ -75,7 +75,7 @@ public class EventAdvanceServiceImpl implements IEventAdvanceService {
|
|||||||
if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
|
if (Objects.isNull(cfgStream) || Objects.isNull(datStream)) {
|
||||||
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
|
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
|
||||||
}
|
}
|
||||||
waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 0);
|
waveDataDTO = waveFileComponent.getComtradeNoAddPoints(cfgStream, datStream, 0);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
try {
|
try {
|
||||||
InputStream cfgStream = fileStorageUtil.getFileStream(cfgPath2);
|
InputStream cfgStream = fileStorageUtil.getFileStream(cfgPath2);
|
||||||
|
|||||||
@@ -14,11 +14,13 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.text.DateFormat;
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author hongawen
|
* @author hongawen
|
||||||
@@ -79,6 +81,46 @@ public class WaveFileComponent {
|
|||||||
return waveDataDTO;
|
return waveDataDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public WaveDataDTO getComtradeNoAddPoints(InputStream cfgStream, InputStream datStream, int iType) {
|
||||||
|
WaveDataDTO waveDataDTO = new WaveDataDTO();
|
||||||
|
// 首先判断文件路径是否为空
|
||||||
|
// 读取cfg文件
|
||||||
|
ComtradeCfgDTO comtradeCfgDTO = getComtradeCfgNoAddPoints(cfgStream);
|
||||||
|
// 为空或者未找到结束符号
|
||||||
|
if (comtradeCfgDTO == null || !"BINARY".equalsIgnoreCase(comtradeCfgDTO.getStrBinType())) {
|
||||||
|
throw new BusinessException(WaveFileResponseEnum.CFG_DATA_ERROR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*****根据通道号计算相别** add by yexb -----Start****
|
||||||
|
* 1、判断是否是3的倍数,是3的倍数则是3相
|
||||||
|
* 2、假如不是3的倍数 ,是1的倍数则是单相
|
||||||
|
********************************************************/
|
||||||
|
if (comtradeCfgDTO.getNAnalogNum() % 3 == 0) {
|
||||||
|
comtradeCfgDTO.setNPhasic(3);
|
||||||
|
} else {
|
||||||
|
comtradeCfgDTO.setNPhasic(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 给相别数量赋值
|
||||||
|
waveDataDTO.setIPhasic(comtradeCfgDTO.getNPhasic());
|
||||||
|
|
||||||
|
// 组装解析抬头
|
||||||
|
getWaveTitle(waveDataDTO, comtradeCfgDTO);
|
||||||
|
|
||||||
|
// 解析.dat文件
|
||||||
|
List<List<Float>> listWaveData = getComtradeDatNoAddPoints(comtradeCfgDTO, datStream, iType);
|
||||||
|
|
||||||
|
waveDataDTO.setComtradeCfgDTO(comtradeCfgDTO);
|
||||||
|
|
||||||
|
waveDataDTO.setListWaveData(listWaveData);
|
||||||
|
|
||||||
|
//add by hongawen,将暂态触发起始时间记录下来
|
||||||
|
waveDataDTO.setTime(DateUtil.format(comtradeCfgDTO.getTimeTrige(), DatePattern.NORM_DATETIME_MS_PATTERN));
|
||||||
|
/*****根据通道号计算相别** add by yexb -----end****/
|
||||||
|
|
||||||
|
return waveDataDTO;
|
||||||
|
}
|
||||||
|
|
||||||
/*********************************
|
/*********************************
|
||||||
* 根据波形数据算出rms值数据
|
* 根据波形数据算出rms值数据
|
||||||
* param waveDataDTO 瞬时波形(包含了CFG配置文件)
|
* param waveDataDTO 瞬时波形(包含了CFG配置文件)
|
||||||
@@ -470,6 +512,127 @@ public class WaveFileComponent {
|
|||||||
return comtradeCfgDTO;
|
return comtradeCfgDTO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ComtradeCfgDTO getComtradeCfgNoAddPoints(InputStream cfgStream) {
|
||||||
|
ComtradeCfgDTO comtradeCfgDTO = new ComtradeCfgDTO();
|
||||||
|
try (InputStreamReader read = new InputStreamReader(cfgStream, CharsetUtil.CHARSET_GBK); BufferedReader bufferedReader = new BufferedReader(read);) {
|
||||||
|
// 第一行不关心仅仅是一些描述类的信息
|
||||||
|
String strFileLine = bufferedReader.readLine();
|
||||||
|
|
||||||
|
// 第二行需要关心第二个(模拟量的个数)和第三个参数(开关量的个数)
|
||||||
|
strFileLine = bufferedReader.readLine();
|
||||||
|
// 按“,”进行分割
|
||||||
|
String[] strTempArray = strFileLine.split(StrUtil.COMMA);
|
||||||
|
// 总个数
|
||||||
|
comtradeCfgDTO.setNChannelNum(Integer.parseInt(strTempArray[0]));
|
||||||
|
// 模拟量的个数
|
||||||
|
comtradeCfgDTO.setNAnalogNum(Integer.parseInt(strTempArray[1].substring(0, strTempArray[1].length() - 1)));
|
||||||
|
// 开关量的个数
|
||||||
|
comtradeCfgDTO.setNDigitalNum(Integer.parseInt(strTempArray[2].substring(0, strTempArray[2].length() - 1)));
|
||||||
|
|
||||||
|
// 从第三行开始的ComtradeCfg.nChannelNum行是模拟量通道和数字量通道
|
||||||
|
List<AnalogDTO> lstAnalogDTO = new ArrayList<>();
|
||||||
|
comtradeCfgDTO.setLstAnalogDTO(lstAnalogDTO);
|
||||||
|
for (int i = 0; i < comtradeCfgDTO.getNChannelNum(); i++) {
|
||||||
|
AnalogDTO analogDTO = new AnalogDTO();
|
||||||
|
lstAnalogDTO.add(analogDTO);
|
||||||
|
strFileLine = bufferedReader.readLine();
|
||||||
|
strTempArray = strFileLine.split(StrUtil.COMMA);
|
||||||
|
//通道序号
|
||||||
|
analogDTO.setNIndex(Integer.parseInt(strTempArray[0]));
|
||||||
|
// 通道名称
|
||||||
|
analogDTO.setSzChannleName(strTempArray[1]);
|
||||||
|
// 相位名称
|
||||||
|
analogDTO.setSzPhasicName(strTempArray[2]);
|
||||||
|
// 监视的通道名称
|
||||||
|
analogDTO.setSzMonitoredChannleName(strTempArray[3]);
|
||||||
|
// 通道的单位
|
||||||
|
analogDTO.setSzUnitName(strTempArray[4]);
|
||||||
|
// 通道的系数
|
||||||
|
analogDTO.setFCoefficent(Float.parseFloat(strTempArray[5]));
|
||||||
|
// 通道的偏移量
|
||||||
|
analogDTO.setFOffset(Float.parseFloat(strTempArray[6]));
|
||||||
|
// 起始采样时间的偏移量
|
||||||
|
analogDTO.setFTimeOffset(Float.parseFloat(strTempArray[7]));
|
||||||
|
// 采样值的最小值
|
||||||
|
analogDTO.setNMin(Integer.parseInt(strTempArray[8]));
|
||||||
|
// 采样值的最大值
|
||||||
|
analogDTO.setNMax(Integer.parseInt(strTempArray[9]));
|
||||||
|
// 一次变比
|
||||||
|
analogDTO.setFPrimary(Float.parseFloat(strTempArray[10]));
|
||||||
|
// 二次变比
|
||||||
|
analogDTO.setFSecondary(Float.parseFloat(strTempArray[11]));
|
||||||
|
// 一次值还是二次值标志
|
||||||
|
analogDTO.setSzValueType(strTempArray[12]);
|
||||||
|
}
|
||||||
|
|
||||||
|
//WW 2019-11-14 // 采样频率
|
||||||
|
String freqLine = bufferedReader.readLine();
|
||||||
|
int nFreq;
|
||||||
|
try {
|
||||||
|
// 先尝试解析为double再四舍五入为整数,以兼容"50.00"这样的格式
|
||||||
|
nFreq = (int) Math.round(Double.parseDouble(freqLine));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
// 如果失败则使用原来的整数解析方式
|
||||||
|
nFreq = Integer.parseInt(freqLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取采样段数
|
||||||
|
strFileLine = bufferedReader.readLine();
|
||||||
|
int nRates = Integer.parseInt(strFileLine);
|
||||||
|
comtradeCfgDTO.setNRates(nRates);
|
||||||
|
// 获得每段的采样率 //采样率
|
||||||
|
List<RateDTO> lstRate = new ArrayList<>();
|
||||||
|
int nOffset = 0;
|
||||||
|
for (int i = 0; i < nRates; i++) {
|
||||||
|
strFileLine = bufferedReader.readLine();
|
||||||
|
strTempArray = strFileLine.split(StrUtil.COMMA);
|
||||||
|
RateDTO rateDTO = new RateDTO();
|
||||||
|
// 单周波采样点数 //WW 2019-11-14
|
||||||
|
double doubleValue = Double.parseDouble(strTempArray[0]); // 解析为 double
|
||||||
|
int result = (int) (doubleValue / nFreq); // 强制转换为 int
|
||||||
|
rateDTO.setNOneSample(result);
|
||||||
|
// 总点数 //这里的strTemp是一个偏移量
|
||||||
|
rateDTO.setNSampleNum((Integer.parseInt(strTempArray[1]) - nOffset));
|
||||||
|
nOffset = rateDTO.getNSampleNum();
|
||||||
|
lstRate.add(rateDTO);
|
||||||
|
}
|
||||||
|
comtradeCfgDTO.setLstRate(lstRate);
|
||||||
|
// 增加读取波形起始时间个结束时间
|
||||||
|
String timeFormat = "dd/MM/yyyy,HH:mm:ss.SSS";
|
||||||
|
// 波形起始时间
|
||||||
|
strFileLine = bufferedReader.readLine();
|
||||||
|
strFileLine = strFileLine.substring(0, strFileLine.length() - 3);
|
||||||
|
comtradeCfgDTO.setTimeStart(DateUtil.parse(strFileLine, timeFormat));
|
||||||
|
|
||||||
|
// 暂态触发时间
|
||||||
|
strFileLine = bufferedReader.readLine();
|
||||||
|
strFileLine = strFileLine.substring(0, strFileLine.length() - 3);
|
||||||
|
comtradeCfgDTO.setTimeTrige(DateUtil.parse(strFileLine, timeFormat));
|
||||||
|
|
||||||
|
// 获取触发时间的时间 + 毫秒
|
||||||
|
Calendar calendar = DateUtil.calendar(comtradeCfgDTO.getTimeTrige());
|
||||||
|
comtradeCfgDTO.setFirstMs(calendar.get(Calendar.MILLISECOND));
|
||||||
|
comtradeCfgDTO.setFirstTime(calendar.getTime());
|
||||||
|
|
||||||
|
|
||||||
|
long a = comtradeCfgDTO.getTimeStart().getTime();
|
||||||
|
long b = comtradeCfgDTO.getTimeTrige().getTime();
|
||||||
|
|
||||||
|
int c = (int) (b - a);
|
||||||
|
if (c >= 90 && c <= 110) {
|
||||||
|
comtradeCfgDTO.setNPush(100);
|
||||||
|
} else if (c >= 190 && c <= 210) {
|
||||||
|
comtradeCfgDTO.setNPush(200);
|
||||||
|
}
|
||||||
|
// 赋值编码格式(二进制)
|
||||||
|
comtradeCfgDTO.setStrBinType(bufferedReader.readLine().toUpperCase());
|
||||||
|
} catch (Exception e) {
|
||||||
|
// 解析.cfg文件出错
|
||||||
|
comtradeCfgDTO = null;
|
||||||
|
}
|
||||||
|
return comtradeCfgDTO;
|
||||||
|
}
|
||||||
|
|
||||||
/*********************************
|
/*********************************
|
||||||
* 读取dat方法
|
* 读取dat方法
|
||||||
* param strFilePath .dat访问路径
|
* param strFilePath .dat访问路径
|
||||||
@@ -765,46 +928,46 @@ public class WaveFileComponent {
|
|||||||
return listWaveData;
|
return listWaveData;
|
||||||
}
|
}
|
||||||
|
|
||||||
// private List<List<Float>> getComtradeDat(ComtradeCfgDTO comtradeCfgDTO, InputStream datStream, int iType) {
|
private List<List<Float>> getComtradeDatNoAddPoints(ComtradeCfgDTO comtradeCfgDTO, InputStream datStream, int iType) {
|
||||||
// //返回数据,如果仅仅做展示后期考虑换String类型,降低内存开销
|
//返回数据,如果仅仅做展示后期考虑换String类型,降低内存开销
|
||||||
// List<List<Float>> listWaveData = new ArrayList<>();
|
List<List<Float>> listWaveData = new ArrayList<>();
|
||||||
// //初始化xValue的值
|
//初始化xValue的值
|
||||||
// float xValueAll = 0;
|
float xValueAll = 0;
|
||||||
// //判断是否首次登陆
|
//判断是否首次登陆
|
||||||
// boolean blxValue = false;
|
boolean blxValue = false;
|
||||||
// byte[] datArray;
|
byte[] datArray;
|
||||||
// try {
|
try {
|
||||||
// datArray = IoUtil.readBytes(datStream);
|
datArray = IoUtil.readBytes(datStream);
|
||||||
// if (ArrayUtil.isEmpty(datArray)) {
|
if (ArrayUtil.isEmpty(datArray)) {
|
||||||
// throw new BusinessException(WaveFileResponseEnum.DAT_DATA_ERROR);
|
throw new BusinessException(WaveFileResponseEnum.DAT_DATA_ERROR);
|
||||||
// }
|
}
|
||||||
// // 计算每个单独的数据块的大小 4个字节的序号 4个字节的时间 2个字节的值
|
// 计算每个单独的数据块的大小 4个字节的序号 4个字节的时间 2个字节的值
|
||||||
// // 示例中的排布是 4个字节的序号 4个字节的时间 UA(2字节) UB(2字节) UC(2字节) IA(2字节) IB(2字节) IC(2字节)
|
// 示例中的排布是 4个字节的序号 4个字节的时间 UA(2字节) UB(2字节) UC(2字节) IA(2字节) IB(2字节) IC(2字节)
|
||||||
// int nDigSize = (comtradeCfgDTO.getNDigitalNum() % 16) > 0 ? (comtradeCfgDTO.getNDigitalNum() / 16 + 1) * 2 : comtradeCfgDTO.getNDigitalNum() / 16 * 2;
|
int nDigSize = (comtradeCfgDTO.getNDigitalNum() % 16) > 0 ? (comtradeCfgDTO.getNDigitalNum() / 16 + 1) * 2 : comtradeCfgDTO.getNDigitalNum() / 16 * 2;
|
||||||
// int nBlockSize = 2 * Integer.SIZE / 8 + comtradeCfgDTO.getNAnalogNum() * 2 + nDigSize;
|
int nBlockSize = 2 * Integer.SIZE / 8 + comtradeCfgDTO.getNAnalogNum() * 2 + nDigSize;
|
||||||
// // 总长度除以每个块的大小
|
// 总长度除以每个块的大小
|
||||||
// int nBlockNum = (int)Math.floor(datArray.length / nBlockSize);
|
int nBlockNum = (int)Math.floor(datArray.length / nBlockSize);
|
||||||
//
|
|
||||||
// // 获取采样率
|
// 获取采样率
|
||||||
// int finalSampleRate = getFinalWaveSample(comtradeCfgDTO.getLstRate(), iType);
|
int finalSampleRate = getFinalWaveSample(comtradeCfgDTO.getLstRate(), iType);
|
||||||
// if (finalSampleRate != -1) {
|
if (finalSampleRate != -1) {
|
||||||
// //设置最终采样率
|
//设置最终采样率
|
||||||
// comtradeCfgDTO.setFinalSampleRate(finalSampleRate);
|
comtradeCfgDTO.setFinalSampleRate(finalSampleRate);
|
||||||
// // 计算转换后的采样率
|
// 计算转换后的采样率
|
||||||
// int nnInd = 0;
|
int nnInd = 0;
|
||||||
// // 抽点后总共多少点数据
|
// 抽点后总共多少点数据
|
||||||
// int nWaveNum;
|
int nWaveNum;
|
||||||
// //抽点后新的的采样率
|
//抽点后新的的采样率
|
||||||
// List<RateDTO> newLstRate = new ArrayList<>();
|
List<RateDTO> newLstRate = new ArrayList<>();
|
||||||
// for (int iRate = 0; iRate < comtradeCfgDTO.getNRates(); iRate++) {
|
for (int iRate = 0; iRate < comtradeCfgDTO.getNRates(); iRate++) {
|
||||||
//// if (comtradeCfgDTO.getLstRate().get(iRate).getNOneSample() >= 32) {
|
if (comtradeCfgDTO.getLstRate().get(iRate).getNOneSample() >= 32) {
|
||||||
// // 计算本段录波总共有多少波形
|
// 计算本段录波总共有多少波形
|
||||||
// nWaveNum = comtradeCfgDTO.getLstRate().get(iRate).getNSampleNum() / comtradeCfgDTO.getLstRate().get(iRate).getNOneSample();
|
nWaveNum = comtradeCfgDTO.getLstRate().get(iRate).getNSampleNum() / comtradeCfgDTO.getLstRate().get(iRate).getNOneSample();
|
||||||
// //设置总波形大小
|
//设置总波形大小
|
||||||
// comtradeCfgDTO.setNAllWaveNum(comtradeCfgDTO.getNAllWaveNum() + nWaveNum);
|
comtradeCfgDTO.setNAllWaveNum(comtradeCfgDTO.getNAllWaveNum() + nWaveNum);
|
||||||
// // 将最低采样率替换到本段录波内
|
// 将最低采样率替换到本段录波内
|
||||||
// RateDTO tmpRateDTO = new RateDTO();
|
RateDTO tmpRateDTO = new RateDTO();
|
||||||
// // 有效值标志,如果是有效值,那么就需要反向补点,而不是抽点
|
// 有效值标志,如果是有效值,那么就需要反向补点,而不是抽点
|
||||||
// if (comtradeCfgDTO.getLstRate().get(iRate).getNOneSample() >= 32) {
|
// if (comtradeCfgDTO.getLstRate().get(iRate).getNOneSample() >= 32) {
|
||||||
// //YXB 2025-08-27
|
// //YXB 2025-08-27
|
||||||
// tmpRateDTO.bRMSFlag = false;
|
// tmpRateDTO.bRMSFlag = false;
|
||||||
@@ -814,52 +977,53 @@ public class WaveFileComponent {
|
|||||||
// //YXB 2025-08-27
|
// //YXB 2025-08-27
|
||||||
// tmpRateDTO.bRMSFlag = true;
|
// tmpRateDTO.bRMSFlag = true;
|
||||||
// }
|
// }
|
||||||
// newLstRate.add(tmpRateDTO);
|
newLstRate.add(tmpRateDTO);
|
||||||
// //iFlag =3 一定不进行抽点算法
|
//iFlag =3 一定不进行抽点算法
|
||||||
// if (iType != 3) {
|
if (iType != 3) {
|
||||||
// //true 抽点算法(当前采样率跟统一采样率不一样则是抽点,否则是未抽点)
|
//true 抽点算法(当前采样率跟统一采样率不一样则是抽点,否则是未抽点)
|
||||||
// if (!Objects.equals(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample(), comtradeCfgDTO.getFinalSampleRate())) {
|
if (!Objects.equals(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample(), comtradeCfgDTO.getFinalSampleRate())) {
|
||||||
// newLstRate.get(nnInd).setNOneSample(comtradeCfgDTO.getFinalSampleRate());
|
newLstRate.get(nnInd).setNOneSample(comtradeCfgDTO.getFinalSampleRate());
|
||||||
// // 计算本段录波按照最低采样点应该有多少录波
|
// 计算本段录波按照最低采样点应该有多少录波
|
||||||
// newLstRate.get(nnInd).setNSampleNum(comtradeCfgDTO.getFinalSampleRate() * nWaveNum);
|
newLstRate.get(nnInd).setNSampleNum(comtradeCfgDTO.getFinalSampleRate() * nWaveNum);
|
||||||
// } else {
|
} else {
|
||||||
// newLstRate.get(nnInd).setNOneSample(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample());
|
newLstRate.get(nnInd).setNOneSample(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample());
|
||||||
// // 计算本段录波按照最低采样点应该有多少录波
|
// 计算本段录波按照最低采样点应该有多少录波
|
||||||
// newLstRate.get(nnInd).setNSampleNum(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample() * nWaveNum);
|
newLstRate.get(nnInd).setNSampleNum(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample() * nWaveNum);
|
||||||
// }
|
}
|
||||||
// } else {
|
} else {
|
||||||
// newLstRate.get(nnInd).setNOneSample(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample());
|
newLstRate.get(nnInd).setNOneSample(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample());
|
||||||
// // 计算本段录波按照最低采样点应该有多少录波
|
// 计算本段录波按照最低采样点应该有多少录波
|
||||||
// newLstRate.get(nnInd).setNSampleNum(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample() * nWaveNum);
|
newLstRate.get(nnInd).setNSampleNum(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample() * nWaveNum);
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// // 正常的配置中采样率
|
// 正常的配置中采样率
|
||||||
// /* comtradeCfgDTO.getLstRate().get(nnInd).setNOneSample(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample());
|
comtradeCfgDTO.getLstRate().get(nnInd).setNOneSample(comtradeCfgDTO.getLstRate().get(iRate).getNOneSample());
|
||||||
// comtradeCfgDTO.getLstRate().get(nnInd).setNSampleNum(comtradeCfgDTO.getLstRate().get(iRate).getNSampleNum());*/
|
comtradeCfgDTO.getLstRate().get(nnInd).setNSampleNum(comtradeCfgDTO.getLstRate().get(iRate).getNSampleNum());
|
||||||
//
|
|
||||||
// nnInd++;
|
nnInd++;
|
||||||
//// }
|
}
|
||||||
// }
|
}
|
||||||
// // 偏移量,采样间隔
|
// 偏移量,采样间隔
|
||||||
// long nOffSet = 0, nWaveSpan;
|
long nOffSet = 0, nWaveSpan;
|
||||||
// //两个点之间的时间差
|
//两个点之间的时间差
|
||||||
// float fValue, dfValue;
|
float fValue, dfValue;
|
||||||
// // 计算不同块的采样率
|
// 计算不同块的采样率
|
||||||
// int nIndex = 0;
|
int nIndex = 0;
|
||||||
// // 将最低采样率替换到本段录波内
|
// 将最低采样率替换到本段录波内
|
||||||
// // .CFG中采样率
|
// .CFG中采样率
|
||||||
// RateDTO tmpRateDTO;
|
RateDTO tmpRateDTO;
|
||||||
// // nBlockNum 总循环次数
|
// nBlockNum 总循环次数
|
||||||
// for (int i = 0; i < nBlockNum; i++) {
|
for (int i = 0; i < nBlockNum; i++) {
|
||||||
// tmpRateDTO = comtradeCfgDTO.getLstRate().get(nIndex);
|
tmpRateDTO = comtradeCfgDTO.getLstRate().get(nIndex);
|
||||||
// // 判断是否进入下一段
|
// 判断是否进入下一段
|
||||||
// if (i == tmpRateDTO.getNSampleNum() + nOffSet) {
|
if (i == tmpRateDTO.getNSampleNum() + nOffSet) {
|
||||||
// nOffSet += tmpRateDTO.getNSampleNum();
|
nOffSet += tmpRateDTO.getNSampleNum();
|
||||||
// nIndex++;
|
nIndex++;
|
||||||
// if (nIndex == nnInd) {
|
if (nIndex == nnInd) {
|
||||||
// break;
|
break;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
|
nWaveSpan = tmpRateDTO.getNOneSample() / newLstRate.get(nIndex).getNOneSample();
|
||||||
// tmpRateDTO = comtradeCfgDTO.getLstRate().get(nIndex);
|
// tmpRateDTO = comtradeCfgDTO.getLstRate().get(nIndex);
|
||||||
// //YXB 2025-08-27 如果是有效值,那么需要去补点,而不是抽点
|
// //YXB 2025-08-27 如果是有效值,那么需要去补点,而不是抽点
|
||||||
// if (newLstRate.get(nIndex).bRMSFlag == true) {
|
// if (newLstRate.get(nIndex).bRMSFlag == true) {
|
||||||
@@ -869,199 +1033,99 @@ public class WaveFileComponent {
|
|||||||
// // 计算本段抽点采样间隔
|
// // 计算本段抽点采样间隔
|
||||||
// nWaveSpan = tmpRateDTO.getNOneSample() / newLstRate.get(nIndex).getNOneSample();
|
// nWaveSpan = tmpRateDTO.getNOneSample() / newLstRate.get(nIndex).getNOneSample();
|
||||||
// }
|
// }
|
||||||
//
|
|
||||||
// dfValue = (float) 20 / tmpRateDTO.getNOneSample();
|
dfValue = (float) 20 / tmpRateDTO.getNOneSample();
|
||||||
// // 判断是否到了需要抽的采样点
|
// 判断是否到了需要抽的采样点
|
||||||
// if (i % nWaveSpan == 0) {
|
if (i % nWaveSpan == 0) {
|
||||||
// // 计算每个通道的值
|
// 计算每个通道的值
|
||||||
// //存储局部数据集合,包含了时间,A,B,C三相
|
//存储局部数据集合,包含了时间,A,B,C三相
|
||||||
// List<Float> tmpWaveData = new ArrayList<>();
|
List<Float> tmpWaveData = new ArrayList<>();
|
||||||
// //YXB 2025-08-27 如果是有效值,那么需要去补点,而不是抽点
|
for (int j = 0; j < comtradeCfgDTO.getNAnalogNum(); j++) {
|
||||||
// if (newLstRate.get(nIndex).bRMSFlag == true) {
|
//数据只有电压ABC三相数据,不展示U0、I0等数据 YXB2020-10-09 去除相别为N相的数据
|
||||||
// // 计算有多少个周波
|
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzPhasicName().equalsIgnoreCase("N")) {
|
||||||
// long allWaveTemp = newLstRate.get(nIndex).getNSampleNum() / newLstRate.get(nIndex).getNOneSample();
|
break;
|
||||||
// // 本段需要补多少点
|
}
|
||||||
// long allempSample = newLstRate.get(nIndex).getNOneSample();
|
|
||||||
// //int iStartWaveTemp = i ;// 开始补点的起点
|
float fCoef = comtradeCfgDTO.getLstAnalogDTO().get(j).getFCoefficent();
|
||||||
// for (int iWaveTemp = 0; iWaveTemp < allWaveTemp; iWaveTemp++) {
|
fValue = BitConverter.byte2ToUnsignedShort(datArray, i * nBlockSize + 2 * 4 + j * 2) * fCoef;
|
||||||
// for (int mTempSample = 0; mTempSample < allempSample; mTempSample++) {
|
|
||||||
// //最多只有半波有效值,也就是每周波是1个或者2个点,然后去补最少16个点
|
//WW 2019-11-14
|
||||||
// if (mTempSample / nWaveSpan == 1 && mTempSample % nWaveSpan == 0) {
|
/**************************
|
||||||
// i++;
|
* 1、接口返回的默认是二次值
|
||||||
// }
|
* 2、P是一次值 S是二次值
|
||||||
// //存储局部数据集合,包含了时间,A,B,C三相
|
* 3、S(二次值)情况下:
|
||||||
// tmpWaveData = new ArrayList<>();
|
* ①、单位为"V"时候则直接等于;
|
||||||
// for (int j = 0; j < comtradeCfgDTO.getNAnalogNum(); j++) {
|
* ②、单位为"kV"时候需要乘以1000
|
||||||
// //数据只有电压ABC三相数据,不展示U0、I0等数据 YXB2020-10-09 去除相别为N相的数据
|
* 4、P(一次值)情况下:
|
||||||
// if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzPhasicName().equalsIgnoreCase("N")) {
|
* ①、单位为"V"时候则直接等于;
|
||||||
// break;
|
* ②、单位为"kV"时候需要乘以1000
|
||||||
// }
|
**************************/
|
||||||
// float fCoef = comtradeCfgDTO.getLstAnalogDTO().get(j).getFCoefficent();
|
//P是一次值 S是二次值
|
||||||
//
|
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzValueType().equalsIgnoreCase("S")) {
|
||||||
// if((i * nBlockSize + 2 * 4 + j * 2) == 2437568){
|
//判断单位是V还是kV
|
||||||
// System.out.println(55);
|
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("KV")) {
|
||||||
// }
|
fValue = fValue * 1000.0f;
|
||||||
// fValue = BitConverter.byte2ToUnsignedShort(datArray, i * nBlockSize + 2 * 4 + j * 2) * fCoef;
|
} else {
|
||||||
// //WW 2019-11-14
|
fValue = fValue;
|
||||||
// /*************************
|
}
|
||||||
// * 1、接口返回的默认是二次值
|
}
|
||||||
// * 2、P是一次值 S是二次值
|
//P是一次值 S是二次值
|
||||||
// * 3、S(二次值)情况下:
|
else if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzValueType().equalsIgnoreCase("P")) {
|
||||||
// * ①、单位为"V"时候则直接等于;
|
//判断单位是V还是kV
|
||||||
// * ②、单位为"kV"时候需要乘以1000
|
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("V")) {
|
||||||
// * 4、P(一次值)情况下:
|
//根据cfg内的变比,将一次值转换成二次值
|
||||||
// * ①、单位为"V"时候则直接等于;
|
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
||||||
// * ②、单位为"kV"时候需要乘以1000
|
fValue = fValue * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
||||||
// *************************/
|
} else {
|
||||||
// //P是一次值 S是二次值
|
fValue = fValue;
|
||||||
// if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzValueType().equalsIgnoreCase("S")) {
|
}
|
||||||
// //判断单位是V还是kV
|
}
|
||||||
// if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("KV")) {
|
//判断单位是V还是kV
|
||||||
// fValue = fValue * 1000.0f;
|
else if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("KV")) {
|
||||||
// } else {
|
//根据cfg内的变比,将一次值转换成二次值
|
||||||
// fValue = fValue;
|
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
||||||
// }
|
fValue = fValue * 1000.0f * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
||||||
// }
|
} else {
|
||||||
// //P是一次值 S是二次值
|
fValue = fValue;
|
||||||
// else if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzValueType().equalsIgnoreCase("P")) {
|
}
|
||||||
// //判断单位是V还是kV
|
} else //还有可能是 电流,单位是A
|
||||||
// if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("V")) {
|
{
|
||||||
// //根据cfg内的变比,将一次值转换成二次值
|
//根据cfg内的变比,将一次值转换成二次值
|
||||||
// if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
||||||
// fValue = fValue * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
fValue = fValue *comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
||||||
// } else {
|
} else {
|
||||||
// fValue = fValue;
|
fValue = fValue;
|
||||||
// }
|
}
|
||||||
// }
|
}
|
||||||
// //判断单位是V还是kV
|
}
|
||||||
// else if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("KV")) {
|
//xValue前移量,假如是第一次时候则需要前移
|
||||||
// //根据cfg内的变比,将一次值转换成二次值
|
if (!blxValue && j == 0) {
|
||||||
// if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
xValueAll = (float) (i * 20) / tmpRateDTO.getNOneSample() - comtradeCfgDTO.getNPush();
|
||||||
// fValue = fValue * 1000.0f * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
blxValue = true;
|
||||||
// } else {
|
//只增加一个xValue的值 //增加时间值
|
||||||
// fValue = fValue;
|
tmpWaveData.add((float) (Math.round(xValueAll * 100)) / 100);
|
||||||
// }
|
} else if (j == 0) {
|
||||||
// } else //还有可能是 电流,单位是A
|
xValueAll += (float) nWaveSpan * dfValue;
|
||||||
// {
|
//只增加一个xValue的值 //增加时间值
|
||||||
// //根据cfg内的变比,将一次值转换成二次值
|
tmpWaveData.add((float) (Math.round(xValueAll * 100)) / 100);
|
||||||
// if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
}
|
||||||
// fValue = comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
|
||||||
// } else {
|
//不同通道yValue的值都需要增加,最终成ABC三相 //每个通道的值
|
||||||
// fValue = fValue;
|
tmpWaveData.add((float) (Math.round(fValue * 100)) / 100);
|
||||||
// }
|
}
|
||||||
// }
|
//把每个单独的值赋予到整体里面去
|
||||||
// }
|
listWaveData.add(tmpWaveData);
|
||||||
//
|
|
||||||
// //xValue前移量,假如是第一次时候则需要前移
|
}
|
||||||
// if (!blxValue && j == 0) {
|
}
|
||||||
// xValueAll = (float) (i * 20) / tmpRateDTO.getNOneSample() - comtradeCfgDTO.getNPush();
|
}
|
||||||
// blxValue = true;
|
} catch (Exception e) {
|
||||||
// //只增加一个xValue的值 //增加时间值
|
e.printStackTrace();
|
||||||
// tmpWaveData.add((float) (Math.round(xValueAll * 100)) / 100);
|
throw new BusinessException(WaveFileResponseEnum.DAT_DATA_ERROR);
|
||||||
// } else if (j == 0) {
|
}
|
||||||
// xValueAll += (float) dfValue / nWaveSpan;
|
|
||||||
// //只增加一个xValue的值 //增加时间值
|
return listWaveData;
|
||||||
// tmpWaveData.add((float) (Math.round(xValueAll * 100)) / 100);
|
}
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //不同通道yValue的值都需要增加,最终成ABC三相 //每个通道的值
|
|
||||||
// tmpWaveData.add((float) (Math.round(fValue * 100)) / 100);
|
|
||||||
// }
|
|
||||||
// //把每个单独的值赋予到整体里面去
|
|
||||||
// listWaveData.add(tmpWaveData);
|
|
||||||
// }
|
|
||||||
// // 把每个单独的值赋予到整体里面去
|
|
||||||
// if (iWaveTemp < (allWaveTemp - 1)) {
|
|
||||||
// i++;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// for (int j = 0; j < comtradeCfgDTO.getNAnalogNum(); j++) {
|
|
||||||
// //数据只有电压ABC三相数据,不展示U0、I0等数据 YXB2020-10-09 去除相别为N相的数据
|
|
||||||
// if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzPhasicName().equalsIgnoreCase("N")) {
|
|
||||||
// break;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// float fCoef = comtradeCfgDTO.getLstAnalogDTO().get(j).getFCoefficent();
|
|
||||||
// fValue = BitConverter.byte2ToUnsignedShort(datArray, i * nBlockSize + 2 * 4 + j * 2) * fCoef;
|
|
||||||
//
|
|
||||||
// //WW 2019-11-14
|
|
||||||
// /**************************
|
|
||||||
// * 1、接口返回的默认是二次值
|
|
||||||
// * 2、P是一次值 S是二次值
|
|
||||||
// * 3、S(二次值)情况下:
|
|
||||||
// * ①、单位为"V"时候则直接等于;
|
|
||||||
// * ②、单位为"kV"时候需要乘以1000
|
|
||||||
// * 4、P(一次值)情况下:
|
|
||||||
// * ①、单位为"V"时候则直接等于;
|
|
||||||
// * ②、单位为"kV"时候需要乘以1000
|
|
||||||
// **************************/
|
|
||||||
// //P是一次值 S是二次值
|
|
||||||
// if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzValueType().equalsIgnoreCase("S")) {
|
|
||||||
// //判断单位是V还是kV
|
|
||||||
// if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("KV")) {
|
|
||||||
// fValue = fValue * 1000.0f;
|
|
||||||
// } else {
|
|
||||||
// fValue = fValue;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// //P是一次值 S是二次值
|
|
||||||
// else if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzValueType().equalsIgnoreCase("P")) {
|
|
||||||
// //判断单位是V还是kV
|
|
||||||
// if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("V")) {
|
|
||||||
// //根据cfg内的变比,将一次值转换成二次值
|
|
||||||
// if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
|
||||||
// fValue = fValue * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
|
||||||
// } else {
|
|
||||||
// fValue = fValue;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// //判断单位是V还是kV
|
|
||||||
// else if (comtradeCfgDTO.getLstAnalogDTO().get(j).getSzUnitName().equalsIgnoreCase("KV")) {
|
|
||||||
// //根据cfg内的变比,将一次值转换成二次值
|
|
||||||
// if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
|
||||||
// fValue = fValue * 1000.0f * comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
|
||||||
// } else {
|
|
||||||
// fValue = fValue;
|
|
||||||
// }
|
|
||||||
// } else //还有可能是 电流,单位是A
|
|
||||||
// {
|
|
||||||
// //根据cfg内的变比,将一次值转换成二次值
|
|
||||||
// if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
|
||||||
// fValue = comtradeCfgDTO.getLstAnalogDTO().get(j).getFSecondary() / comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary();
|
|
||||||
// } else {
|
|
||||||
// fValue = fValue;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// //xValue前移量,假如是第一次时候则需要前移
|
|
||||||
// if (!blxValue && j == 0) {
|
|
||||||
// xValueAll = (float) (i * 20) / tmpRateDTO.getNOneSample() - comtradeCfgDTO.getNPush();
|
|
||||||
// blxValue = true;
|
|
||||||
// //只增加一个xValue的值 //增加时间值
|
|
||||||
// tmpWaveData.add((float) (Math.round(xValueAll * 100)) / 100);
|
|
||||||
// } else if (j == 0) {
|
|
||||||
// xValueAll += (float) nWaveSpan * dfValue;
|
|
||||||
// //只增加一个xValue的值 //增加时间值
|
|
||||||
// tmpWaveData.add((float) (Math.round(xValueAll * 100)) / 100);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //不同通道yValue的值都需要增加,最终成ABC三相 //每个通道的值
|
|
||||||
// tmpWaveData.add((float) (Math.round(fValue * 100)) / 100);
|
|
||||||
// }
|
|
||||||
// //把每个单独的值赋予到整体里面去
|
|
||||||
// listWaveData.add(tmpWaveData);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// e.printStackTrace();
|
|
||||||
// throw new BusinessException(WaveFileResponseEnum.DAT_DATA_ERROR);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// return listWaveData;
|
|
||||||
// }
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************
|
/*********************************
|
||||||
@@ -1656,10 +1720,10 @@ public class WaveFileComponent {
|
|||||||
s = sdf.format(d);
|
s = sdf.format(d);
|
||||||
System.out.println(s);
|
System.out.println(s);
|
||||||
WaveFileComponent waveFileComponent = new WaveFileComponent();
|
WaveFileComponent waveFileComponent = new WaveFileComponent();
|
||||||
InputStream cfgStream = waveFileComponent.getFileInputStreamByFilePath("C:\\Users\\Administrator\\Desktop\\wave\\PQMonitor_PQM2_006970_20260320_175033_734.CFG");
|
InputStream cfgStream = waveFileComponent.getFileInputStreamByFilePath("C:\\Users\\无名\\Desktop\\月报\\2026\\202603\\文档\\暂态事件及波形\\新建文件夹 (3)\\Comtrade\\Comtrade\\10.95.0.201\\PQMonitor_PQM1_001183_20260320_175042_316.CFG");
|
||||||
InputStream datStream = waveFileComponent.getFileInputStreamByFilePath("C:\\Users\\Administrator\\Desktop\\wave\\PQMonitor_PQM2_006970_20260320_175033_734.DAT");
|
InputStream datStream = waveFileComponent.getFileInputStreamByFilePath("C:\\Users\\无名\\Desktop\\月报\\2026\\202603\\文档\\暂态事件及波形\\新建文件夹 (3)\\Comtrade\\Comtrade\\10.95.0.201\\PQMonitor_PQM1_001183_20260320_175042_316.DAT");
|
||||||
// 获取瞬时波形 //获取原始波形值
|
// 获取瞬时波形 //获取原始波形值
|
||||||
WaveDataDTO waveDataDTO = waveFileComponent.getComtrade(cfgStream, datStream, 1);
|
WaveDataDTO waveDataDTO = waveFileComponent.getComtradeNoAddPoints(cfgStream, datStream, 0);
|
||||||
d = new Date();
|
d = new Date();
|
||||||
s = sdf.format(d);
|
s = sdf.format(d);
|
||||||
System.out.println(s);
|
System.out.println(s);
|
||||||
|
|||||||
Reference in New Issue
Block a user