波形解析的电流一次值转二次值调整
This commit is contained in:
@@ -26,8 +26,6 @@ import java.util.*;
|
|||||||
public class AnalyWave {
|
public class AnalyWave {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*****************************************
|
/*****************************************
|
||||||
* 解析comtrate文件工具类
|
* 解析comtrate文件工具类
|
||||||
* author yexb根据Ww算法装换
|
* author yexb根据Ww算法装换
|
||||||
@@ -94,7 +92,7 @@ public class AnalyWave {
|
|||||||
** ** strFilePath *** cfg文件路径
|
** ** strFilePath *** cfg文件路径
|
||||||
* *** auth *** 读取方式 null则使用本地读取方式读取
|
* *** auth *** 读取方式 null则使用本地读取方式读取
|
||||||
******************************************/
|
******************************************/
|
||||||
public AnalyWaveModel.tagDataValue readComtrade(List<String> temCfgList,byte[] array, int iFlag) {
|
public AnalyWaveModel.tagDataValue readComtrade(List<String> temCfgList, byte[] array, int iFlag) {
|
||||||
//初始化参数
|
//初始化参数
|
||||||
ComtradeCfg = new AnalyWaveModel.tagComtradeCfg();
|
ComtradeCfg = new AnalyWaveModel.tagComtradeCfg();
|
||||||
RatesCfg = new AnalyWaveModel.tagRates();
|
RatesCfg = new AnalyWaveModel.tagRates();
|
||||||
@@ -163,148 +161,145 @@ public class AnalyWave {
|
|||||||
iterable.next();
|
iterable.next();
|
||||||
String[] strTempArray;// 读取cfg文件
|
String[] strTempArray;// 读取cfg文件
|
||||||
try {
|
try {
|
||||||
nFreq = 0f;//WW 2019-11-14
|
nFreq = 0f;//WW 2019-11-14
|
||||||
String strFileLine = iterable.next();
|
String strFileLine = iterable.next();
|
||||||
|
strTempArray = strFileLine.split(",");
|
||||||
|
|
||||||
|
for (int i = 0; i < strTempArray.length; i++) {
|
||||||
|
switch (i) {
|
||||||
|
case 0:// 总个数
|
||||||
|
ComtradeCfg.nChannelNum = Integer.parseInt(strTempArray[i]);
|
||||||
|
break;
|
||||||
|
case 1:// 模拟量的个数
|
||||||
|
{
|
||||||
|
String str = strTempArray[i].substring(0, strTempArray[i].length() - 1);
|
||||||
|
ComtradeCfg.nAnalogNum = Integer.parseInt(str);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:// 开关量的个数
|
||||||
|
{
|
||||||
|
String str = strTempArray[i].substring(0, strTempArray[i].length() - 1);
|
||||||
|
ComtradeCfg.nDigitalNum = Integer.parseInt(str);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 从第三行到第ComtradeCfg.nChannelNum+3行是模拟量通道和数字量通道
|
||||||
|
for (int i = 0; i < ComtradeCfg.nChannelNum; i++) {
|
||||||
|
AnalyWaveModel.tagOneChannleCfg OneChannlecfg = new AnalyWaveModel.tagOneChannleCfg();
|
||||||
|
ComtradeCfg.OneChannleCfg.add(OneChannlecfg);
|
||||||
|
|
||||||
|
strFileLine = iterable.next();
|
||||||
|
strTempArray = strFileLine.split(",");
|
||||||
|
// 配置总共13项
|
||||||
|
for (int j = 0; j < strTempArray.length; j++) {
|
||||||
|
switch (j) {
|
||||||
|
case 0:// 通道序号
|
||||||
|
OneChannlecfg.nIndex = Integer.parseInt(strTempArray[j]);
|
||||||
|
break;
|
||||||
|
case 1:// 通道名称
|
||||||
|
OneChannlecfg.szChannleName = strTempArray[j];
|
||||||
|
break;
|
||||||
|
case 2:// 相位名称
|
||||||
|
OneChannlecfg.szPhasicName = strTempArray[j];
|
||||||
|
break;
|
||||||
|
case 3:// 监视的通道名称
|
||||||
|
OneChannlecfg.szMonitoredChannleName = strTempArray[j];
|
||||||
|
break;
|
||||||
|
case 4:// 通道的单位
|
||||||
|
OneChannlecfg.szUnitName = strTempArray[j];
|
||||||
|
break;
|
||||||
|
case 5:// 通道的系数
|
||||||
|
OneChannlecfg.fCoefficent = Float.parseFloat(strTempArray[j]);
|
||||||
|
break;
|
||||||
|
case 6:// 通道的偏移量
|
||||||
|
OneChannlecfg.fOffset = Float.parseFloat(strTempArray[j]);
|
||||||
|
break;
|
||||||
|
case 7:// 起始采样时间的偏移量
|
||||||
|
OneChannlecfg.fTimeOffset = Float.parseFloat(strTempArray[j]);
|
||||||
|
break;
|
||||||
|
case 8:// 采样值的最小值
|
||||||
|
OneChannlecfg.nMin = Integer.parseInt(strTempArray[j]);
|
||||||
|
break;
|
||||||
|
case 9:// 采样值的最大值
|
||||||
|
OneChannlecfg.nMax = Integer.parseInt(strTempArray[j]);
|
||||||
|
break;
|
||||||
|
case 10:// 一次变比
|
||||||
|
OneChannlecfg.fPrimary = Float.parseFloat(strTempArray[j]);
|
||||||
|
break;
|
||||||
|
case 11:// 二次变比
|
||||||
|
OneChannlecfg.fSecondary = Float.parseFloat(strTempArray[j]);
|
||||||
|
break;
|
||||||
|
case 12:// 一次值还是二次值标志
|
||||||
|
OneChannlecfg.szValueType = strTempArray[j];
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 采样频率
|
||||||
|
strFileLine = iterable.next();
|
||||||
|
float fFreq = Float.parseFloat(strFileLine);
|
||||||
|
nFreq = (float) fFreq;//WW 2019-11-14
|
||||||
|
// 采样段数
|
||||||
|
strFileLine = iterable.next();
|
||||||
|
int nRates = Integer.parseInt(strFileLine);
|
||||||
|
RatesCfg.nRates = nRates;
|
||||||
|
// 获得每段的采样率
|
||||||
|
long nOffset = 0;
|
||||||
|
for (int i = 0; i < nRates; i++) {
|
||||||
|
strFileLine = iterable.next();
|
||||||
strTempArray = strFileLine.split(",");
|
strTempArray = strFileLine.split(",");
|
||||||
|
|
||||||
for (int i = 0; i < strTempArray.length; i++) {
|
AnalyWaveModel.tagOneRate OneRate = new AnalyWaveModel.tagOneRate();
|
||||||
switch (i) {
|
RatesCfg.OneRate.add(OneRate);
|
||||||
case 0:// 总个数
|
|
||||||
ComtradeCfg.nChannelNum = Integer.parseInt(strTempArray[i]);
|
for (int j = 0; j < strTempArray.length; j++) {
|
||||||
|
|
||||||
|
switch (j) {
|
||||||
|
case 0:// 单周波采样点数
|
||||||
|
OneRate.nOneSample = (int) (Float.parseFloat(strTempArray[j]) / nFreq);//WW 2019-11-14
|
||||||
|
break;
|
||||||
|
case 1:// 总点数 //这里的strTemp是一个偏移量
|
||||||
|
OneRate.nSampleNum = (long) (Float.parseFloat(strTempArray[j]) - nOffset);
|
||||||
|
nOffset += OneRate.nSampleNum;
|
||||||
break;
|
break;
|
||||||
case 1:// 模拟量的个数
|
|
||||||
{
|
|
||||||
String str = strTempArray[i].substring(0, strTempArray[i].length() - 1);
|
|
||||||
ComtradeCfg.nAnalogNum = Integer.parseInt(str);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:// 开关量的个数
|
|
||||||
{
|
|
||||||
String str = strTempArray[i].substring(0, strTempArray[i].length() - 1);
|
|
||||||
ComtradeCfg.nDigitalNum = Integer.parseInt(str);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 从第三行到第ComtradeCfg.nChannelNum+3行是模拟量通道和数字量通道
|
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss.SSS");
|
||||||
for (int i = 0; i < ComtradeCfg.nChannelNum; i++) {
|
// 波形起始时间
|
||||||
AnalyWaveModel.tagOneChannleCfg OneChannlecfg = new AnalyWaveModel.tagOneChannleCfg();
|
strFileLine = iterable.next();
|
||||||
ComtradeCfg.OneChannleCfg.add(OneChannlecfg);
|
strFileLine = strFileLine.substring(0, strFileLine.length() - 3).replace(",", " ");
|
||||||
|
TimeTrige = sdf.parse(strFileLine);
|
||||||
strFileLine = iterable.next();
|
// 暂态触发时间
|
||||||
strTempArray = strFileLine.split(",");
|
strFileLine = iterable.next();
|
||||||
// 配置总共13项
|
strFileLine = strFileLine.substring(0, strFileLine.length() - 3).replace(",", " ");
|
||||||
for (int j = 0; j < strTempArray.length; j++) {
|
TimeWave = sdf.parse(strFileLine);
|
||||||
switch (j) {
|
|
||||||
case 0:// 通道序号
|
|
||||||
OneChannlecfg.nIndex = Integer.parseInt(strTempArray[j]);
|
|
||||||
break;
|
|
||||||
case 1:// 通道名称
|
|
||||||
OneChannlecfg.szChannleName = strTempArray[j];
|
|
||||||
break;
|
|
||||||
case 2:// 相位名称
|
|
||||||
OneChannlecfg.szPhasicName = strTempArray[j];
|
|
||||||
break;
|
|
||||||
case 3:// 监视的通道名称
|
|
||||||
OneChannlecfg.szMonitoredChannleName = strTempArray[j];
|
|
||||||
break;
|
|
||||||
case 4:// 通道的单位
|
|
||||||
OneChannlecfg.szUnitName = strTempArray[j];
|
|
||||||
break;
|
|
||||||
case 5:// 通道的系数
|
|
||||||
OneChannlecfg.fCoefficent = Float.parseFloat(strTempArray[j]);
|
|
||||||
break;
|
|
||||||
case 6:// 通道的偏移量
|
|
||||||
OneChannlecfg.fOffset = Float.parseFloat(strTempArray[j]);
|
|
||||||
break;
|
|
||||||
case 7:// 起始采样时间的偏移量
|
|
||||||
OneChannlecfg.fTimeOffset = Float.parseFloat(strTempArray[j]);
|
|
||||||
break;
|
|
||||||
case 8:// 采样值的最小值
|
|
||||||
OneChannlecfg.nMin = Integer.parseInt(strTempArray[j]);
|
|
||||||
break;
|
|
||||||
case 9:// 采样值的最大值
|
|
||||||
OneChannlecfg.nMax = Integer.parseInt(strTempArray[j]);
|
|
||||||
break;
|
|
||||||
case 10:// 一次变比
|
|
||||||
OneChannlecfg.fPrimary = Float.parseFloat(strTempArray[j]);
|
|
||||||
break;
|
|
||||||
case 11:// 二次变比
|
|
||||||
OneChannlecfg.fSecondary = Float.parseFloat(strTempArray[j]);
|
|
||||||
break;
|
|
||||||
case 12:// 一次值还是二次值标志
|
|
||||||
OneChannlecfg.szValueType = strTempArray[j];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 采样频率
|
|
||||||
strFileLine = iterable.next();
|
|
||||||
float fFreq = Float.parseFloat(strFileLine);
|
|
||||||
nFreq = (float) fFreq;//WW 2019-11-14
|
|
||||||
// 采样段数
|
|
||||||
strFileLine = iterable.next();
|
|
||||||
int nRates = Integer.parseInt(strFileLine);
|
|
||||||
RatesCfg.nRates = nRates;
|
|
||||||
// 获得每段的采样率
|
|
||||||
long nOffset = 0;
|
|
||||||
for (int i = 0; i < nRates; i++) {
|
|
||||||
strFileLine = iterable.next();
|
|
||||||
strTempArray = strFileLine.split(",");
|
|
||||||
|
|
||||||
AnalyWaveModel.tagOneRate OneRate = new AnalyWaveModel.tagOneRate();
|
|
||||||
RatesCfg.OneRate.add(OneRate);
|
|
||||||
|
|
||||||
for (int j = 0; j < strTempArray.length; j++) {
|
|
||||||
|
|
||||||
switch (j) {
|
|
||||||
case 0:// 单周波采样点数
|
|
||||||
OneRate.nOneSample = (int) (Float.parseFloat(strTempArray[j]) / nFreq);//WW 2019-11-14
|
|
||||||
break;
|
|
||||||
case 1:// 总点数 //这里的strTemp是一个偏移量
|
|
||||||
OneRate.nSampleNum = (long) (Float.parseFloat(strTempArray[j]) - nOffset);
|
|
||||||
nOffset += OneRate.nSampleNum;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss.SSS");
|
|
||||||
// 波形起始时间
|
|
||||||
strFileLine = iterable.next();
|
|
||||||
strFileLine = strFileLine.substring(0, strFileLine.length() - 3).replace(",", " ");
|
|
||||||
TimeTrige = sdf.parse(strFileLine);
|
|
||||||
// 暂态触发时间
|
|
||||||
strFileLine = iterable.next();
|
|
||||||
strFileLine = strFileLine.substring(0, strFileLine.length() - 3).replace(",", " ");
|
|
||||||
TimeWave = sdf.parse(strFileLine);
|
|
||||||
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
calendar.setTime(TimeWave);
|
|
||||||
firstMs = calendar.get(Calendar.MILLISECOND);
|
|
||||||
firstTime = calendar.getTime();
|
|
||||||
|
|
||||||
long a = TimeWave.getTime();
|
|
||||||
long b = TimeTrige.getTime();
|
|
||||||
int c = (int) (a - b);
|
|
||||||
if (c >= 90 && c <= 110) {
|
|
||||||
iPush = 100;
|
|
||||||
} else if (c >= 190 && c <= 210) {
|
|
||||||
iPush = 200;
|
|
||||||
}
|
|
||||||
// 赋值编码格式(二进制)
|
|
||||||
strBinType = iterable.next().toUpperCase();
|
|
||||||
|
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
calendar.setTime(TimeWave);
|
||||||
|
firstMs = calendar.get(Calendar.MILLISECOND);
|
||||||
|
firstTime = calendar.getTime();
|
||||||
|
|
||||||
|
long a = TimeWave.getTime();
|
||||||
|
long b = TimeTrige.getTime();
|
||||||
|
int c = (int) (a - b);
|
||||||
|
if (c >= 90 && c <= 110) {
|
||||||
|
iPush = 100;
|
||||||
|
} else if (c >= 190 && c <= 210) {
|
||||||
|
iPush = 200;
|
||||||
|
}
|
||||||
|
// 赋值编码格式(二进制)
|
||||||
|
strBinType = iterable.next().toUpperCase();
|
||||||
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
logger.error("读取文件内容出错"+e.getMessage());
|
logger.error("读取文件内容出错" + e.getMessage());
|
||||||
return false;
|
return false;
|
||||||
}finally {
|
} finally {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -319,15 +314,8 @@ public class AnalyWave {
|
|||||||
private List<List<Float>> AnalyseComtradeDat(byte[] array, int iFlag) {
|
private List<List<Float>> AnalyseComtradeDat(byte[] array, int iFlag) {
|
||||||
float xValueAll = 0;//初始化xValue的值
|
float xValueAll = 0;//初始化xValue的值
|
||||||
boolean blxValue = false;//判断是否首次登陆
|
boolean blxValue = false;//判断是否首次登陆
|
||||||
|
|
||||||
List<List<Float>> listWaveData = new ArrayList<>();//返回数据
|
List<List<Float>> listWaveData = new ArrayList<>();//返回数据
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 计算每个单独的数据块的大小 4字节的序号 4字节的时间 2字节的值
|
// 计算每个单独的数据块的大小 4字节的序号 4字节的时间 2字节的值
|
||||||
// 示例中的排布是 4字节的序号 4字节的时间 UA(2字节) UB(2字节) UC(2字节) IA(2字节) IB(2字节)
|
// 示例中的排布是 4字节的序号 4字节的时间 UA(2字节) UB(2字节) UC(2字节) IA(2字节) IB(2字节)
|
||||||
// IC(2字节)
|
// IC(2字节)
|
||||||
@@ -470,7 +458,7 @@ public class AnalyWave {
|
|||||||
{
|
{
|
||||||
if (ComtradeCfg.OneChannleCfg.get(j).fPrimary != 0.0f)//根据cfg内的变比,将一次值转换成二次值
|
if (ComtradeCfg.OneChannleCfg.get(j).fPrimary != 0.0f)//根据cfg内的变比,将一次值转换成二次值
|
||||||
{
|
{
|
||||||
fValue = ComtradeCfg.OneChannleCfg.get(j).fSecondary / ComtradeCfg.OneChannleCfg.get(j).fPrimary;
|
fValue = fValue * ComtradeCfg.OneChannleCfg.get(j).fSecondary / ComtradeCfg.OneChannleCfg.get(j).fPrimary;
|
||||||
} else {
|
} else {
|
||||||
fValue = fValue;
|
fValue = fValue;
|
||||||
}
|
}
|
||||||
@@ -500,7 +488,7 @@ public class AnalyWave {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logger.error("读取文件出错:" + e.getMessage());
|
logger.error("读取文件出错:" + e.getMessage());
|
||||||
return listWaveData;
|
return listWaveData;
|
||||||
}finally {
|
} finally {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -641,7 +641,7 @@ public class WaveFileComponent {
|
|||||||
{
|
{
|
||||||
//根据cfg内的变比,将一次值转换成二次值
|
//根据cfg内的变比,将一次值转换成二次值
|
||||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
@@ -724,7 +724,7 @@ public class WaveFileComponent {
|
|||||||
{
|
{
|
||||||
//根据cfg内的变比,将一次值转换成二次值
|
//根据cfg内的变比,将一次值转换成二次值
|
||||||
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
if (comtradeCfgDTO.getLstAnalogDTO().get(j).getFPrimary() != 0.0f) {
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user