我叫圣文

This commit is contained in:
2026-05-15 16:37:22 +08:00
parent 41c915d1df
commit 90219a3daf
52 changed files with 3315 additions and 5 deletions

View File

@@ -297,7 +297,8 @@ public class WaveVectorComponent {
private float resolveVectorRatio(WaveDataDTO waveDataDTO, int titleIndex) {
if (waveDataDTO.getWaveTitle() != null && waveDataDTO.getWaveTitle().size() > titleIndex
&& StrUtil.startWithIgnoreCase(waveDataDTO.getWaveTitle().get(titleIndex), "U")) {
return waveDataDTO.getPt() == null ? 1F : waveDataDTO.getPt().floatValue() ;
// 电压向量按 kV 展示,需与普通波形查看保持一致,避免将 V 级数值直接标记为 kV。
return waveDataDTO.getPt() == null ? 0.001F : waveDataDTO.getPt().floatValue() / 1000F;
}
return waveDataDTO.getCt() == null ? 1F : waveDataDTO.getCt().floatValue();
}

View File

@@ -0,0 +1,73 @@
package com.njcn.gather.tool.wave.component;
import com.njcn.gather.tool.wave.pojo.dto.ComtradeCfgDTO;
import com.njcn.gather.tool.wave.pojo.dto.WaveDataDTO;
import com.njcn.gather.tool.wave.pojo.dto.WaveVectorGroupDTO;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* 波形向量计算组件测试。
*/
class WaveVectorComponentTest {
@Test
void shouldScaleVoltageVectorValuesToKv() {
WaveVectorComponent component = new WaveVectorComponent();
WaveDataDTO waveDataDTO = buildThreePhaseWaveData("U", 8153.209D, 1D);
List<WaveVectorGroupDTO> groups = component.calculateVectors(waveDataDTO);
Assertions.assertEquals("kV", groups.get(0).getUnit());
Assertions.assertEquals(5.7652F, groups.get(0).getVectorSeries().get(0).getPhaseVectors().get(0).getTotalRms());
Assertions.assertEquals(8.1532F, groups.get(0).getVectorSeries().get(0).getPhaseVectors().get(0).getFundamentalAmplitude());
Assertions.assertEquals(5.7652F, groups.get(0).getVectorSeries().get(0).getPhaseVectors().get(0).getFundamentalRms());
Assertions.assertEquals(5.7652F, groups.get(0).getVectorSeries().get(0).getPositiveSequence().getRms());
}
@Test
void shouldKeepCurrentVectorValuesInAmpere() {
WaveVectorComponent component = new WaveVectorComponent();
WaveDataDTO waveDataDTO = buildThreePhaseWaveData("I", 35D, 1D);
List<WaveVectorGroupDTO> groups = component.calculateVectors(waveDataDTO);
Assertions.assertEquals("A", groups.get(0).getUnit());
Assertions.assertEquals(24.7487F, groups.get(0).getVectorSeries().get(0).getPhaseVectors().get(0).getTotalRms());
Assertions.assertEquals(35F, groups.get(0).getVectorSeries().get(0).getPhaseVectors().get(0).getFundamentalAmplitude());
Assertions.assertEquals(24.7487F, groups.get(0).getVectorSeries().get(0).getPhaseVectors().get(0).getFundamentalRms());
}
private WaveDataDTO buildThreePhaseWaveData(String titlePrefix, double amplitude, double ratio) {
int samplePerCycle = 32;
WaveDataDTO waveDataDTO = new WaveDataDTO();
ComtradeCfgDTO cfgDTO = new ComtradeCfgDTO();
cfgDTO.setFinalSampleRate(samplePerCycle);
waveDataDTO.setComtradeCfgDTO(cfgDTO);
waveDataDTO.setIPhasic(3);
waveDataDTO.setPt(ratio);
waveDataDTO.setCt(ratio);
waveDataDTO.setWaveTitle(Arrays.asList("x", titlePrefix + "A", titlePrefix + "B", titlePrefix + "C"));
waveDataDTO.setChannelNames(Arrays.asList("x", titlePrefix));
waveDataDTO.setListWaveData(buildRows(samplePerCycle, amplitude));
return waveDataDTO;
}
private List<List<Float>> buildRows(int samplePerCycle, double amplitude) {
List<List<Float>> rows = new ArrayList<>();
for (int i = 0; i < samplePerCycle; i++) {
double angle = 2D * Math.PI * i / samplePerCycle;
List<Float> row = new ArrayList<>();
row.add((float) i);
row.add((float) (amplitude * Math.sin(angle)));
row.add((float) (amplitude * Math.sin(angle - 2D * Math.PI / 3D)));
row.add((float) (amplitude * Math.sin(angle + 2D * Math.PI / 3D)));
rows.add(row);
}
return rows;
}
}