离线数据上传
This commit is contained in:
@@ -11,6 +11,9 @@ import com.njcn.csharmonic.pojo.vo.CsEventVO;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -24,5 +27,8 @@ public interface EventFeignClient {
|
||||
|
||||
@PostMapping("/pageQueryByLineId")
|
||||
HttpResult<Page<DataGroupEventVO>> pageQueryByLineId(@RequestBody CsEventUserQueryPage csEventUserQueryPage);
|
||||
@PostMapping("/queryByIndex")
|
||||
HttpResult<CsEventPO> queryByIndex(@RequestBody CsEventPO csEventPO);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,6 +12,9 @@ import com.njcn.csharmonic.pojo.vo.CsEventVO;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -40,6 +43,12 @@ public class EventFeignClientFallbackFactory implements FallbackFactory<EventFei
|
||||
log.error("{}异常,降级处理,异常为:{}","根据监测点分页查询暂降事件",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<CsEventPO> queryByIndex( CsEventPO csEventPO) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据根据表唯一索引查询(用于校验是否存在该事件)s",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,8 +14,7 @@ import java.util.List;
|
||||
@Slf4j
|
||||
public class Log {
|
||||
private static String logPath = "C:\\Users\\Administrator\\Desktop\\浙江无线\\离线数据上传\\09\\log";//事件文件路径
|
||||
private static LocalDateTime event_starttime = null;
|
||||
private static LocalDateTime event_endtime = null;
|
||||
|
||||
private static List<TagComtradeCfg> tagComtradeCfgs = new ArrayList();//波形文件cfg信息队列
|
||||
public static void main(String[] args) throws Exception {
|
||||
boolean logbin = false;
|
||||
@@ -55,12 +54,14 @@ public class Log {
|
||||
e.printStackTrace();
|
||||
throw new BusinessException("文件" + file.getName() + " 读取时发生错误");
|
||||
}
|
||||
LocalDateTime event_starttime = null;
|
||||
LocalDateTime event_endtime = null;
|
||||
NewTaglogbuffer newTaglogbuffer = getnewTaglogbuffer(bBuf);
|
||||
newTaglogbuffers.add(newTaglogbuffer);
|
||||
TagMsTime devtime = newTaglogbuffer.getNewHeadTaglogbuffer().getDevtime();
|
||||
LocalDateTime time = LocalDateTime.of(devtime.getYear(), devtime.getMonth(), devtime.getDay(), devtime.getHour(), devtime.getMin(), devtime.getSec(), devtime.getMs());
|
||||
LocalDateTime time = LocalDateTime.of(devtime.getYear(), devtime.getMonth(), devtime.getDay(), devtime.getHour(), devtime.getMin(), devtime.getSec(), devtime.getMs()*1000*1000);
|
||||
//存在启动时间
|
||||
if (event_starttime != LocalDateTime.MIN && event_starttime != null) {
|
||||
if (event_starttime != LocalDateTime.MIN&& event_starttime!=null) {
|
||||
if (time.compareTo(event_starttime) <= 0) {
|
||||
event_starttime = time;
|
||||
}
|
||||
@@ -68,7 +69,7 @@ public class Log {
|
||||
//不存在启动时间 填入当前时间
|
||||
event_starttime = time;
|
||||
}
|
||||
if (event_endtime != LocalDateTime.MIN && event_endtime != null) {
|
||||
if (event_endtime != LocalDateTime.MIN && event_endtime!=null) {
|
||||
if (time.compareTo(event_endtime) >= 0) {
|
||||
event_endtime = time;
|
||||
}
|
||||
@@ -77,6 +78,7 @@ public class Log {
|
||||
event_endtime = time;
|
||||
}
|
||||
|
||||
|
||||
long sec = 0;
|
||||
for (NewBodyTaglogbuffer sing : newTaglogbuffer.getNewBodyTaglogbuffers()) {
|
||||
switch (sing.getParaCode()) {
|
||||
@@ -95,14 +97,19 @@ public class Log {
|
||||
break;
|
||||
}
|
||||
}
|
||||
//当事件时长超过1分钟直接排除
|
||||
if(sec>60){
|
||||
continue;
|
||||
}
|
||||
newTaglogbuffer.setStart(time); //事件开始时间
|
||||
newTaglogbuffer.setEnd(time.plusSeconds(sec)); //事件结束时间
|
||||
for (TagComtradeCfg sing : tagComtradeCfgs) {
|
||||
if (sing.getTimeTrigger().compareTo(newTaglogbuffer.getStart()) <= 0 && sing.getTimeEnd().compareTo(newTaglogbuffer.getStart()) >= 0) {
|
||||
newTaglogbuffer.setPath(sing.getPath());
|
||||
break;
|
||||
}
|
||||
}
|
||||
//这里tagComtradeCfgs为空无效
|
||||
// for (TagComtradeCfg sing : tagComtradeCfgs) {
|
||||
// if (sing.getTimeTrigger().compareTo(newTaglogbuffer.getStart()) <= 0 && sing.getTimeEnd().compareTo(newTaglogbuffer.getStart()) >= 0) {
|
||||
// newTaglogbuffer.setPath(sing.getPath());
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
e.printStackTrace();
|
||||
@@ -137,11 +144,12 @@ public class Log {
|
||||
throw new BusinessException("文件" + file.getOriginalFilename() + " 读取时发生错误");
|
||||
}
|
||||
NewTaglogbuffer newTaglogbuffer = getnewTaglogbuffer(bBuf);
|
||||
newTaglogbuffers.add(newTaglogbuffer);
|
||||
LocalDateTime event_starttime = null;
|
||||
LocalDateTime event_endtime = null;
|
||||
TagMsTime devtime = newTaglogbuffer.getNewHeadTaglogbuffer().getDevtime();
|
||||
LocalDateTime time = LocalDateTime.of(devtime.getYear(), devtime.getMonth(), devtime.getDay(), devtime.getHour(), devtime.getMin(), devtime.getSec(), devtime.getMs());
|
||||
LocalDateTime time = LocalDateTime.of(devtime.getYear(), devtime.getMonth(), devtime.getDay(), devtime.getHour(), devtime.getMin(), devtime.getSec(), devtime.getMs()*1000*1000);
|
||||
//存在启动时间
|
||||
if (event_starttime != LocalDateTime.MIN && event_starttime != null) {
|
||||
if (event_starttime != LocalDateTime.MIN&& event_starttime!=null) {
|
||||
if (time.compareTo(event_starttime) <= 0) {
|
||||
event_starttime = time;
|
||||
}
|
||||
@@ -149,7 +157,7 @@ public class Log {
|
||||
//不存在启动时间 填入当前时间
|
||||
event_starttime = time;
|
||||
}
|
||||
if (event_endtime != LocalDateTime.MIN && event_endtime != null) {
|
||||
if (event_endtime != LocalDateTime.MIN && event_endtime!=null) {
|
||||
if (time.compareTo(event_endtime) >= 0) {
|
||||
event_endtime = time;
|
||||
}
|
||||
@@ -176,14 +184,21 @@ public class Log {
|
||||
break;
|
||||
}
|
||||
}
|
||||
//当事件时长超过1分钟直接排除
|
||||
if(sec>60){
|
||||
continue;
|
||||
}
|
||||
newTaglogbuffer.setStart(time); //事件开始时间
|
||||
newTaglogbuffer.setEnd(time.plusSeconds(sec)); //事件结束时间
|
||||
for (TagComtradeCfg sing : tagComtradeCfgs) {
|
||||
if (sing.getTimeTrigger().compareTo(newTaglogbuffer.getStart()) <= 0 && sing.getTimeEnd().compareTo(newTaglogbuffer.getStart()) >= 0) {
|
||||
newTaglogbuffer.setPath(sing.getPath());
|
||||
break;
|
||||
}
|
||||
}
|
||||
//这里tagComtradeCfgs为空无效
|
||||
// for (TagComtradeCfg sing : tagComtradeCfgs) {
|
||||
// if (sing.getTimeTrigger().compareTo(newTaglogbuffer.getStart()) <= 0 && sing.getTimeEnd().compareTo(newTaglogbuffer.getStart()) >= 0) {
|
||||
// newTaglogbuffer.setPath(sing.getPath());
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
newTaglogbuffers.add(newTaglogbuffer);
|
||||
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -5,6 +5,7 @@ import lombok.Data;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
package com.njcn.csharmonic.offline.log.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
|
||||
@Data
|
||||
public class TagComtradeCfg {
|
||||
public class TagComtradeCfg implements Serializable {
|
||||
private int nChannelNum; //通道总个数
|
||||
private int nAnalogNum; //模拟量通道的个数 WW 2013-05-15
|
||||
private int nDigitalNum; //数字量通道的个数 WW 2013-05-15
|
||||
|
||||
@@ -2,8 +2,10 @@ package com.njcn.csharmonic.offline.log.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class TagOneChannleCfg {
|
||||
public class TagOneChannleCfg implements Serializable {
|
||||
//通道序号
|
||||
private int nIndex;
|
||||
//通道名称
|
||||
|
||||
@@ -2,8 +2,10 @@ package com.njcn.csharmonic.offline.log.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
public class TagOneChannleCfgDigital {
|
||||
public class TagOneChannleCfgDigital implements Serializable {
|
||||
//通道序号
|
||||
private int nIndex;
|
||||
//通道名称
|
||||
|
||||
@@ -2,16 +2,22 @@ package com.njcn.csharmonic.offline.mincfg;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
import com.njcn.influx.pojo.po.cs.PqdData;
|
||||
import com.njcn.csharmonic.offline.log.vo.TagComtradeCfg;
|
||||
import com.njcn.csharmonic.offline.log.vo.TagOneChannleCfg;
|
||||
import com.njcn.csharmonic.offline.mincfg.vo.*;
|
||||
import com.njcn.csharmonic.offline.mincfg.vo.RTC_Timer_MS;
|
||||
import com.njcn.csharmonic.offline.mincfg.vo.tagPQDataCmn;
|
||||
import com.njcn.csharmonic.offline.mincfg.vo.tagPQDataCmnHh;
|
||||
import com.njcn.influx.pojo.po.cs.PqdData;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Paths;
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
@@ -134,7 +140,7 @@ public class AnalyseComtradeCfg {
|
||||
//电能质量只有电压偏差,上偏差正,下偏差负,判断上偏差是否为0如果为0取下偏差负数,反正取上偏差
|
||||
hashMapA.put("pq_UDev",AnalyseComtradeCfg.isZero(uuDeviation[0])?(-ulDeviation[0]):uuDeviation[0]);
|
||||
hashMapB.put("pq_UDev",AnalyseComtradeCfg.isZero(uuDeviation[1])?(-ulDeviation[1]):uuDeviation[1]);
|
||||
hashMapC.put("pq_RmsU",AnalyseComtradeCfg.isZero(uuDeviation[2])?(-ulDeviation[2]):uuDeviation[2]);
|
||||
hashMapC.put("pq_UDev",AnalyseComtradeCfg.isZero(uuDeviation[2])?(-ulDeviation[2]):uuDeviation[2]);
|
||||
hashMapAB.put("pq_LUDev",AnalyseComtradeCfg.isZero(uuDeviation[3])?(-ulDeviation[3]):uuDeviation[3]);
|
||||
hashMapBC.put("pq_LUDev",AnalyseComtradeCfg.isZero(uuDeviation[4])?(-ulDeviation[4]):uuDeviation[4]);
|
||||
hashMapCA.put("pq_LUDev",AnalyseComtradeCfg.isZero(uuDeviation[5])?(-ulDeviation[5]):uuDeviation[5]);
|
||||
@@ -522,8 +528,8 @@ public class AnalyseComtradeCfg {
|
||||
}
|
||||
|
||||
}
|
||||
public static List<tagComtradeCfg> convertCfgFile(String strFilePath) { //解析cfg录波文件
|
||||
List<tagComtradeCfg> tagComtradeCfgList = new ArrayList<>();
|
||||
public static List<TagComtradeCfg> convertCfgFile(String strFilePath) { //解析cfg录波文件
|
||||
List<TagComtradeCfg> tagComtradeCfgList = new ArrayList<>();
|
||||
// File folder = new File(strFilePath);
|
||||
// File[] files = folder.listFiles((dir, name) -> name.endsWith(".cfg")); //获取文件夹下所有cfg文件
|
||||
// Arrays.stream(files).forEach(file -> {
|
||||
@@ -539,8 +545,8 @@ public class AnalyseComtradeCfg {
|
||||
* @Author: clam
|
||||
* @Date: 2024/7/15
|
||||
*/
|
||||
public static tagComtradeCfg analyseComtradeCfg(MultipartFile file) {
|
||||
tagComtradeCfg comtradeCfg = new tagComtradeCfg();
|
||||
public static TagComtradeCfg analyseComtradeCfg(MultipartFile file) {
|
||||
TagComtradeCfg comtradeCfg = new TagComtradeCfg();
|
||||
String strFilePath = file.getOriginalFilename();
|
||||
int i = 0; //用于遍历 字符串转换的字段数组
|
||||
String strFileLine;//临时存放 cfg每行读取的字符串
|
||||
@@ -551,7 +557,7 @@ public class AnalyseComtradeCfg {
|
||||
InputStream readFile = file.getInputStream();
|
||||
InputStreamReader isr = new InputStreamReader(readFile, StandardCharsets.UTF_8);
|
||||
BufferedReader sr = new BufferedReader(isr);
|
||||
comtradeCfg = new tagComtradeCfg();//配置文件总类对象初始化
|
||||
comtradeCfg = new TagComtradeCfg();//配置文件总类对象初始化
|
||||
ratesCfg = new tagRates();//多段采样类对象初始化
|
||||
long nFreq = 0; //临时存放 采样频率 例:50Hz
|
||||
//第一行不关心仅仅是一些描述类的信息
|
||||
@@ -562,65 +568,65 @@ public class AnalyseComtradeCfg {
|
||||
for (i = 0; i < strTempArray.length; i++) {
|
||||
switch (i) {
|
||||
case 0: //通道总个数
|
||||
comtradeCfg.nChannelNum = Integer.parseInt(strTempArray[i]);
|
||||
comtradeCfg.setNChannelNum(Integer.parseInt(strTempArray[i]));
|
||||
break;
|
||||
case 1: //模拟量的个数
|
||||
String str = strTempArray[i].substring(0, strTempArray[i].length() - 1);
|
||||
comtradeCfg.nAnalogNum = Integer.parseInt(str);
|
||||
comtradeCfg.setNAnalogNum(Integer.parseInt(str));
|
||||
break;
|
||||
case 2://开关量的个数
|
||||
str = strTempArray[i].substring(0, strTempArray[i].length() - 1);
|
||||
comtradeCfg.nDigitalNum = Integer.parseInt(str);
|
||||
comtradeCfg.setNDigitalNum(Integer.parseInt(str));
|
||||
break;
|
||||
}
|
||||
}
|
||||
//从第三行到第ComtradeCfg.nChannelNum+3行是模拟量通道和数字量通道
|
||||
List<tagOneChannleCfg> OneChannleCfgList =new ArrayList<>();
|
||||
for (i = 0; i < comtradeCfg.nChannelNum; i++) {
|
||||
tagOneChannleCfg oneChannlecfg = new tagOneChannleCfg();
|
||||
ArrayList<TagOneChannleCfg> OneChannleCfgList =new ArrayList<>();
|
||||
for (i = 0; i < comtradeCfg.getNChannelNum(); i++) {
|
||||
TagOneChannleCfg oneChannlecfg = new TagOneChannleCfg();
|
||||
|
||||
strFileLine = sr.readLine(); // ③ or ④ or ⑤
|
||||
strTempArray = strFileLine.split(",");
|
||||
for (int j = 0; j < strTempArray.length; j++) {
|
||||
switch (j) {
|
||||
case 0://通道序号
|
||||
oneChannlecfg.nIndex = Integer.parseInt(strTempArray[j]);
|
||||
oneChannlecfg.setNIndex(Integer.parseInt(strTempArray[j]));
|
||||
break;
|
||||
case 1://通道名称
|
||||
oneChannlecfg.szChannleName = strTempArray[j];
|
||||
oneChannlecfg.setSzChannleName(strTempArray[j]);
|
||||
break;
|
||||
case 2://监视的通道名称
|
||||
oneChannlecfg.szPhasicName = strTempArray[j];
|
||||
oneChannlecfg.setSzPhasicName(strTempArray[j]);
|
||||
break;
|
||||
case 3://监视的通道名称
|
||||
oneChannlecfg.szMonitoredChannleName = strTempArray[j];
|
||||
oneChannlecfg.setSzMonitoredChannleName(strTempArray[j]);
|
||||
break;
|
||||
case 4://通道的单位
|
||||
oneChannlecfg.szUnitName = strTempArray[j];
|
||||
oneChannlecfg.setSzUnitName(strTempArray[j]);
|
||||
break;
|
||||
case 5://通道的系数
|
||||
oneChannlecfg.fCoefficent = Float.parseFloat(strTempArray[j]);
|
||||
oneChannlecfg.setFCoefficent(Float.parseFloat(strTempArray[j]));
|
||||
break;
|
||||
case 6://通道的偏移量
|
||||
oneChannlecfg.fOffset = Float.parseFloat(strTempArray[j]);
|
||||
oneChannlecfg.setFOffset(Float.parseFloat(strTempArray[j]));
|
||||
break;
|
||||
case 7://起始采样时间的偏移量
|
||||
oneChannlecfg.fTimeOffset = Float.parseFloat(strTempArray[j]);
|
||||
oneChannlecfg.setFTimeOffset( Float.parseFloat(strTempArray[j]));
|
||||
break;
|
||||
case 8://采样值的最小值
|
||||
oneChannlecfg.nMin = Integer.parseInt(strTempArray[j]);
|
||||
oneChannlecfg.setNMin( Integer.parseInt(strTempArray[j]));
|
||||
break;
|
||||
case 9://采样值的最大值
|
||||
oneChannlecfg.nMax = Integer.parseInt(strTempArray[j]);
|
||||
oneChannlecfg.setNMax(Integer.parseInt(strTempArray[j]));
|
||||
break;
|
||||
case 10://一次变比
|
||||
oneChannlecfg.fPrimary = Float.parseFloat(strTempArray[j]);
|
||||
oneChannlecfg.setFPrimary( Float.parseFloat(strTempArray[j]));
|
||||
break;
|
||||
case 11://二次变比
|
||||
oneChannlecfg.fSecondary = Float.parseFloat(strTempArray[j]);
|
||||
oneChannlecfg.setFSecondary(Float.parseFloat(strTempArray[j]));
|
||||
break;
|
||||
case 12://一次值还是二次值标志
|
||||
oneChannlecfg.szValueType = strTempArray[j];
|
||||
oneChannlecfg.setSzValueType(strTempArray[j]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -664,21 +670,21 @@ public class AnalyseComtradeCfg {
|
||||
|
||||
sr.close();
|
||||
readFile.close();
|
||||
return comtradeCfg;
|
||||
return new TagComtradeCfg();
|
||||
}
|
||||
//波形起始时间
|
||||
strFileLine = sr.readLine(); // ⑨
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy,HH:mm:ss.SSSSSS");
|
||||
comtradeCfg.setTimeTrigger(sdf.parse(strFileLine));
|
||||
DateTimeFormatter sdf = DateTimeFormatter.ofPattern("dd/MM/yyyy,HH:mm:ss.SSSSSS");
|
||||
comtradeCfg.setTimeTrigger(LocalDateTime.parse(strFileLine, sdf));
|
||||
|
||||
strFileLine = sr.readLine(); // ⑩
|
||||
comtradeCfg.setTimeStart(sdf.parse(strFileLine));
|
||||
comtradeCfg.setTimeEnd(new Date(comtradeCfg.getTimeStart().getTime() + nMSTotal));;
|
||||
comtradeCfg.setTimeStart(LocalDateTime.parse(strFileLine, sdf));
|
||||
comtradeCfg.setTimeEnd(comtradeCfg.getTimeStart().plusSeconds(nMSTotal/1000L));;
|
||||
comtradeCfg.setPath(file.getOriginalFilename());
|
||||
|
||||
sr.close();
|
||||
readFile.close();
|
||||
} catch (IOException | ParseException e) {
|
||||
} catch (IOException e) {
|
||||
System.out.println("Error opening file: " + strFilePath + " " + e.getMessage());
|
||||
return comtradeCfg;
|
||||
}
|
||||
@@ -686,6 +692,81 @@ public class AnalyseComtradeCfg {
|
||||
return comtradeCfg;
|
||||
}
|
||||
|
||||
public static CmnModeCfg convertRecord(String strFile) {
|
||||
File file = new File(strFile);
|
||||
if (file.length() == 0) {
|
||||
System.out.println("文件 " + strFile + " 长度为0字节,程序将跳过本文件的转换");
|
||||
}
|
||||
|
||||
long nBufSize = file.length();
|
||||
int n1BufLen = PrjRecordInfo.GetSize();
|
||||
int n2BufLen = CmnModeCfg.GetSize();
|
||||
|
||||
PrjRecordInfo prjRecordInfo = new PrjRecordInfo();
|
||||
CmnModeCfg cmnModeCfg = new CmnModeCfg();
|
||||
if (nBufSize == n1BufLen) {
|
||||
byte[] bBuf = new byte[0];
|
||||
try {
|
||||
bBuf = Files.readAllBytes(Paths.get(strFile));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
prjRecordInfo.SetStructBuf(bBuf, 0);
|
||||
CmnModeCfg recordInfo = prjRecordInfo.cfg;
|
||||
} else if (nBufSize == n2BufLen) {
|
||||
byte[] bBuf = new byte[0];
|
||||
try {
|
||||
bBuf = Files.readAllBytes(Paths.get(strFile));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
cmnModeCfg.SetStructBuf(bBuf, 0);
|
||||
CmnModeCfg recordInfo = cmnModeCfg;
|
||||
} else {
|
||||
System.out.println("解析配置参数文件异常");
|
||||
}
|
||||
return cmnModeCfg;
|
||||
}
|
||||
|
||||
|
||||
public static CmnModeCfg convertRecord(InputStream fileStream) {
|
||||
|
||||
PrjRecordInfo prjRecordInfo = new PrjRecordInfo();
|
||||
CmnModeCfg cmnModeCfg = new CmnModeCfg();
|
||||
try {
|
||||
int nBufSize = fileStream.available();//计算需要解析的文件总长
|
||||
int n1BufLen = PrjRecordInfo.GetSize();
|
||||
int n2BufLen = CmnModeCfg.GetSize();
|
||||
|
||||
|
||||
if (nBufSize == n1BufLen) {
|
||||
byte[] bBuf = new byte[nBufSize];
|
||||
|
||||
fileStream.read(bBuf, 0, n1BufLen);
|
||||
|
||||
prjRecordInfo.SetStructBuf(bBuf, 0);
|
||||
cmnModeCfg = prjRecordInfo.cfg;
|
||||
} else if (nBufSize == n2BufLen) {
|
||||
byte[] bBuf = new byte[nBufSize];
|
||||
|
||||
fileStream.read(bBuf, 0, n2BufLen);
|
||||
|
||||
cmnModeCfg.SetStructBuf(bBuf, 0);
|
||||
} else {
|
||||
System.out.println("解析配置参数文件异常");
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}finally {
|
||||
try {
|
||||
fileStream.close();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return cmnModeCfg;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
// tagComtradeCfg tagComtradeCfg = AnalyseComtradeCfg.analyseComtradeCfg("C:\\Users\\Administrator\\Desktop\\浙江无线\\离线数据上传\\09\\comtrade\\line1_20240704_143908_213.cfg");
|
||||
// System.out.println(tagComtradeCfg);
|
||||
|
||||
@@ -1,28 +0,0 @@
|
||||
package com.njcn.csharmonic.offline.mincfg;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2024/7/15 15:40【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
@Data
|
||||
public class tagComtradeCfg implements Serializable {
|
||||
|
||||
public int nChannelNum; //通道总个数
|
||||
public int nAnalogNum; //模拟量通道的个数 WW 2013-05-15
|
||||
public int nDigitalNum; //数字量通道的个数 WW 2013-05-15
|
||||
public List<tagOneChannleCfg> OneChannleCfg; //模拟量通道记录类链表
|
||||
public List<tagOneChannleCfg_digital> OneChannleCfgDig; //数字量通道记录类链表
|
||||
public Date TimeTrigger; //暂态触发时间
|
||||
public Date TimeStart; //波形起始时间 注:相较于TimeTrigger波形触发时间起始有一段平滑过渡波形时间,约100ms
|
||||
public Date TimeEnd; //波形结束时间
|
||||
public String path;//对应波形cfg文件全路径名称
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@ package com.njcn.csharmonic.offline.mincfg.vo;
|
||||
装置普测工程配置信息
|
||||
|
||||
*/
|
||||
public class cmn_mode_cfg
|
||||
public class CmnModeCfg
|
||||
{
|
||||
public byte[] prj_name = new byte[128]; //工程名称
|
||||
//C# TO JAVA CONVERTER WARNING: Unsigned integer types have no direct equivalent in Java:
|
||||
@@ -4,10 +4,10 @@ package com.njcn.csharmonic.offline.mincfg.vo;
|
||||
工程数据文件信息
|
||||
|
||||
*/
|
||||
public class prj_record_info
|
||||
public class PrjRecordInfo
|
||||
{
|
||||
public pqv_dev_info_int dev_info; //装置信息
|
||||
public cmn_mode_cfg cfg; //测试记录工程配置
|
||||
public CmnModeCfg cfg; //测试记录工程配置
|
||||
public prj_store_info store_mag; //存储管理缓冲
|
||||
public int tv_sec_s; //开始记录时间
|
||||
public int tv_sec_e; //结束记录时间
|
||||
@@ -15,16 +15,16 @@ public class prj_record_info
|
||||
//ORIGINAL LINE: public uint status;
|
||||
public int status; //测试工程数据是否有效标志
|
||||
|
||||
public prj_record_info()
|
||||
public PrjRecordInfo()
|
||||
{
|
||||
dev_info = new pqv_dev_info_int();
|
||||
cfg = new cmn_mode_cfg();
|
||||
cfg = new CmnModeCfg();
|
||||
store_mag = new prj_store_info();
|
||||
}
|
||||
public static int GetSize() //用于定义Byte数组
|
||||
{
|
||||
//C# TO JAVA CONVERTER TODO TASK: There is no Java equivalent to 'sizeof':
|
||||
int nSize = 2 * Integer.SIZE / Byte.SIZE + 1 * Integer.SIZE / Byte.SIZE + pqv_dev_info_int.GetSize() + cmn_mode_cfg.GetSize() + prj_store_info.GetSize(); //CComtradeDataItem数据结构数据长度
|
||||
int nSize = 2 * Integer.SIZE / Byte.SIZE + 1 * Integer.SIZE / Byte.SIZE + pqv_dev_info_int.GetSize() + CmnModeCfg.GetSize() + prj_store_info.GetSize(); //CComtradeDataItem数据结构数据长度
|
||||
return nSize;
|
||||
}
|
||||
public final boolean SetStructBuf(byte[] bArray, int nHaveRead)
|
||||
@@ -39,7 +39,7 @@ public class prj_record_info
|
||||
dev_info.SetStructBuf(bArray, iStep);
|
||||
iStep = iStep + pqv_dev_info_int.GetSize();
|
||||
cfg.SetStructBuf(bArray, iStep);
|
||||
iStep = iStep + cmn_mode_cfg.GetSize();
|
||||
iStep = iStep + CmnModeCfg.GetSize();
|
||||
store_mag.SetStructBuf(bArray, iStep);
|
||||
iStep = iStep + prj_store_info.GetSize();
|
||||
tv_sec_s = Service.convertInt32_net(bArray, iStep);
|
||||
@@ -66,7 +66,7 @@ public class prj_record_info
|
||||
dev_info.SetStructBuf(bArray, iStep);
|
||||
iStep = iStep + pqv_dev_info_int.GetSize();
|
||||
cfg.SetStructBuf_net(bArray, iStep);
|
||||
iStep = iStep + cmn_mode_cfg.GetSize();
|
||||
iStep = iStep + CmnModeCfg.GetSize();
|
||||
store_mag.SetStructBuf_net(bArray, iStep);
|
||||
iStep = iStep + prj_store_info.GetSize();
|
||||
tv_sec_s = Service.convertInt32(bArray, iStep);
|
||||
Reference in New Issue
Block a user