1.暂降高级类型原因调用dll报错问题
This commit is contained in:
@@ -67,7 +67,9 @@ public interface QvvrCauseDLL extends Library {
|
|||||||
|
|
||||||
// 创建临时文件
|
// 创建临时文件
|
||||||
String tempDir = System.getProperty("java.io.tmpdir");
|
String tempDir = System.getProperty("java.io.tmpdir");
|
||||||
File tempLibFile = new File(tempDir, "qvvr_" + System.currentTimeMillis() + "_" + libFileName);
|
File tempLibFile = new File(tempDir, libFileName);
|
||||||
|
|
||||||
|
//File tempLibFile = new File(tempDir, "qvvr_" + System.currentTimeMillis() + "_" + libFileName);
|
||||||
|
|
||||||
// 提取库文件到临时目录
|
// 提取库文件到临时目录
|
||||||
try (FileOutputStream out = new FileOutputStream(tempLibFile)) {
|
try (FileOutputStream out = new FileOutputStream(tempLibFile)) {
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
package com.njcn.advance.event.service.impl;
|
package com.njcn.advance.event.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.njcn.advance.event.cause.core.VoltageSagAnalyzer;
|
|
||||||
import com.njcn.advance.event.cause.jna.QvvrCauseDLL;
|
import com.njcn.advance.event.cause.jna.QvvrCauseDLL;
|
||||||
import com.njcn.advance.event.cause.model.AnalysisResult;
|
|
||||||
import com.njcn.advance.event.cause.model.DataFeature;
|
import com.njcn.advance.event.cause.model.DataFeature;
|
||||||
import com.njcn.advance.event.cause.model.QvvrDataStruct;
|
import com.njcn.advance.event.type.jna.*;
|
||||||
import com.njcn.advance.pojo.dto.EventAnalysisDTO;
|
import com.njcn.advance.pojo.dto.EventAnalysisDTO;
|
||||||
import com.njcn.advance.event.service.IEventAdvanceService;
|
import com.njcn.advance.event.service.IEventAdvanceService;
|
||||||
import com.njcn.advance.event.type.jna.QvvrDLL;
|
|
||||||
import com.njcn.common.config.GeneralInfo;
|
import com.njcn.common.config.GeneralInfo;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.event.file.component.WaveFileComponent;
|
import com.njcn.event.file.component.WaveFileComponent;
|
||||||
@@ -89,8 +86,55 @@ public class EventAdvanceServiceImpl implements IEventAdvanceService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
List<List<Float>> listWaveData = waveDataDTO.getListWaveData();
|
List<List<Float>> listWaveData = waveDataDTO.getListWaveData();
|
||||||
|
// 暂降类型
|
||||||
|
// 创建数据结构
|
||||||
|
QvvrDLL.QvvrDataStruct typeDataStruct = new QvvrDLL.QvvrDataStruct();
|
||||||
|
System.out.println("初始化qvvrdll成功-----------");
|
||||||
|
typeDataStruct.smp_rate = waveDataDTO.getComtradeCfgDTO().getFinalSampleRate();
|
||||||
|
System.out.println("采样率-----------" + typeDataStruct.smp_rate);
|
||||||
|
typeDataStruct.smp_len = listWaveData.size();
|
||||||
|
System.out.println("波形长度-----------" + listWaveData.size());
|
||||||
|
|
||||||
|
// 获取ABC三相的瞬时数据
|
||||||
|
for (int i = 0; i < listWaveData.size(); i++) {
|
||||||
|
typeDataStruct.smp_va[i] = listWaveData.get(i).get(1);
|
||||||
|
typeDataStruct.smp_vb[i] = listWaveData.get(i).get(2);
|
||||||
|
typeDataStruct.smp_vc[i] = listWaveData.get(i).get(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 执行算法分析 - 直接调用C DLL
|
||||||
|
try {
|
||||||
|
QvvrDLL.INSTANCE.qvvr_fun(typeDataStruct);
|
||||||
|
System.out.println("调用qvvrdll成功-----------");
|
||||||
|
|
||||||
|
if (typeDataStruct.evt_num > 0) {
|
||||||
|
// 全局比较找出最小三相电压特征值
|
||||||
|
float globalMinVoltage = Float.MAX_VALUE;
|
||||||
|
int globalFaultType = 10;
|
||||||
|
for (int i = 0; i < typeDataStruct.evt_num; i++) {
|
||||||
|
QvvrDLL.EventBuffer evt = typeDataStruct.evt_buf[i];
|
||||||
|
for (int j = 0; j < evt.u_min_num; j++) {
|
||||||
|
float u3min = evt.u3_min[j];
|
||||||
|
if (u3min < globalMinVoltage) {
|
||||||
|
globalMinVoltage = u3min;
|
||||||
|
globalFaultType = evt.qvvr_cata_type[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
eventAnalysis.setType(globalFaultType);
|
||||||
|
} else {
|
||||||
|
eventAnalysis.setType(DataFeature.TYPE10);
|
||||||
|
}
|
||||||
|
System.out.println("结束qvvrdll方法调用-----------");
|
||||||
|
} catch (Exception e) {
|
||||||
|
eventAnalysis.setType(DataFeature.TYPE10);
|
||||||
|
eventAnalysis.setTypeFlag(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 暂降原因JNA的方式
|
// 暂降原因JNA的方式
|
||||||
com.njcn.advance.event.cause.jna.QvvrCauseDLL.QvvrDataStruct causeDataStruct = new com.njcn.advance.event.cause.jna.QvvrCauseDLL.QvvrDataStruct();
|
QvvrCauseDLL.QvvrDataStruct causeDataStruct = new QvvrCauseDLL.QvvrDataStruct();
|
||||||
causeDataStruct.smp_rate = waveDataDTO.getComtradeCfgDTO().getFinalSampleRate();
|
causeDataStruct.smp_rate = waveDataDTO.getComtradeCfgDTO().getFinalSampleRate();
|
||||||
causeDataStruct.smp_len = listWaveData.size();
|
causeDataStruct.smp_len = listWaveData.size();
|
||||||
// 获取ABC三相的瞬时数据
|
// 获取ABC三相的瞬时数据
|
||||||
@@ -112,45 +156,6 @@ public class EventAdvanceServiceImpl implements IEventAdvanceService {
|
|||||||
}
|
}
|
||||||
System.out.println("暂降原因分析完毕===============");
|
System.out.println("暂降原因分析完毕===============");
|
||||||
System.out.println("cause:" + eventAnalysis);
|
System.out.println("cause:" + eventAnalysis);
|
||||||
|
|
||||||
// 暂降类型
|
|
||||||
// 创建数据结构
|
|
||||||
// com.njcn.advance.event.type.jna.QvvrDLL.QvvrDataStruct typeDataStruct = new com.njcn.advance.event.type.jna.QvvrDLL.QvvrDataStruct();
|
|
||||||
// typeDataStruct.smp_rate = waveDataDTO.getComtradeCfgDTO().getFinalSampleRate();
|
|
||||||
// typeDataStruct.smp_len = listWaveData.size();
|
|
||||||
// // 获取ABC三相的瞬时数据
|
|
||||||
// for (int i = 0; i < listWaveData.size(); i++) {
|
|
||||||
// typeDataStruct.smp_va[i] = listWaveData.get(i).get(1);
|
|
||||||
// typeDataStruct.smp_vb[i] = listWaveData.get(i).get(2);
|
|
||||||
// typeDataStruct.smp_vc[i] = listWaveData.get(i).get(3);
|
|
||||||
// }
|
|
||||||
// // 执行算法分析 - 直接调用C DLL
|
|
||||||
// try {
|
|
||||||
// QvvrDLL.INSTANCE.qvvr_fun(typeDataStruct);
|
|
||||||
// if (typeDataStruct.evt_num > 0) {
|
|
||||||
// // 全局比较找出最小三相电压特征值
|
|
||||||
// float globalMinVoltage = Float.MAX_VALUE;
|
|
||||||
// int globalFaultType = 10;
|
|
||||||
// for (int i = 0; i < typeDataStruct.evt_num; i++) {
|
|
||||||
// QvvrDLL.EventBuffer evt = typeDataStruct.evt_buf[i];
|
|
||||||
// for (int j = 0; j < evt.u_min_num; j++) {
|
|
||||||
// float u3min = evt.u3_min[j];
|
|
||||||
// if (u3min < globalMinVoltage) {
|
|
||||||
// globalMinVoltage = u3min;
|
|
||||||
// globalFaultType = evt.qvvr_cata_type[j];
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// eventAnalysis.setType(globalFaultType);
|
|
||||||
// } else {
|
|
||||||
// eventAnalysis.setType(DataFeature.TYPE10);
|
|
||||||
// }
|
|
||||||
// } catch (Exception e) {
|
|
||||||
// eventAnalysis.setType(DataFeature.TYPE10);
|
|
||||||
// eventAnalysis.setTypeFlag(0);
|
|
||||||
// }
|
|
||||||
return eventAnalysis;
|
return eventAnalysis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public interface QvvrDLL extends Library {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从jar中提取库文件到临时目录
|
* 从jar中提取库文件到临时目录
|
||||||
*/
|
*/
|
||||||
@@ -62,11 +62,13 @@ public interface QvvrDLL extends Library {
|
|||||||
if (libStream == null) {
|
if (libStream == null) {
|
||||||
throw new FileNotFoundException("在jar中找不到库文件: " + resourcePath);
|
throw new FileNotFoundException("在jar中找不到库文件: " + resourcePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 创建临时文件
|
// 创建临时文件
|
||||||
String tempDir = System.getProperty("java.io.tmpdir");
|
String tempDir = System.getProperty("java.io.tmpdir");
|
||||||
File tempLibFile = new File(tempDir, "qvvr_" + System.currentTimeMillis() + "_" + libFileName);
|
File tempLibFile = new File(tempDir, libFileName);
|
||||||
|
|
||||||
|
// File tempLibFile = new File(tempDir, "qvvr_" + System.currentTimeMillis() + "_" + libFileName);
|
||||||
|
|
||||||
// 提取库文件到临时目录
|
// 提取库文件到临时目录
|
||||||
try (FileOutputStream out = new FileOutputStream(tempLibFile)) {
|
try (FileOutputStream out = new FileOutputStream(tempLibFile)) {
|
||||||
byte[] buffer = new byte[8192];
|
byte[] buffer = new byte[8192];
|
||||||
@@ -77,45 +79,47 @@ public interface QvvrDLL extends Library {
|
|||||||
} finally {
|
} finally {
|
||||||
libStream.close();
|
libStream.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 设置为可执行
|
// 设置为可执行
|
||||||
tempLibFile.setExecutable(true);
|
tempLibFile.setExecutable(true);
|
||||||
tempLibFile.setReadable(true);
|
tempLibFile.setReadable(true);
|
||||||
|
|
||||||
// JVM退出时删除临时文件
|
// JVM退出时删除临时文件
|
||||||
tempLibFile.deleteOnExit();
|
tempLibFile.deleteOnExit();
|
||||||
|
|
||||||
System.out.println("已提取库文件到: " + tempLibFile.getAbsolutePath());
|
System.out.println("已提取库文件到: " + tempLibFile.getAbsolutePath());
|
||||||
return tempLibFile;
|
return tempLibFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 直接调用C DLL的qvvr_fun函数
|
* 直接调用C DLL的qvvr_fun函数
|
||||||
* void __stdcall qvvr_fun(void *data)
|
* void __stdcall qvvr_fun(void *data)
|
||||||
*/
|
*/
|
||||||
void qvvr_fun(QvvrDataStruct data);
|
void qvvr_fun(QvvrDataStruct data);
|
||||||
|
|
||||||
|
void ping();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对应C语言的qvvr_data_struct结构体
|
* 对应C语言的qvvr_data_struct结构体
|
||||||
*/
|
*/
|
||||||
public static class QvvrDataStruct extends Structure {
|
public static class QvvrDataStruct extends Structure {
|
||||||
|
|
||||||
// 输入数据
|
// 输入数据
|
||||||
public float[] smp_va = new float[128 * 50 * 120]; // A相电压
|
public float[] smp_va = new float[128 * 50 * 120]; // A相电压
|
||||||
public float[] smp_vb = new float[128 * 50 * 120]; // B相电压
|
public float[] smp_vb = new float[128 * 50 * 120]; // B相电压
|
||||||
public float[] smp_vc = new float[128 * 50 * 120]; // C相电压
|
public float[] smp_vc = new float[128 * 50 * 120]; // C相电压
|
||||||
public int smp_rate; // 采样频率
|
public int smp_rate; // 采样频率
|
||||||
public int smp_len; // 数据长度
|
public int smp_len; // 数据长度
|
||||||
|
|
||||||
// 输出结果
|
// 输出结果
|
||||||
public int evt_num; // 事件数量
|
public int evt_num; // 事件数量
|
||||||
public EventBuffer[] evt_buf = new EventBuffer[32]; // 事件缓冲区
|
public EventBuffer[] evt_buf = new EventBuffer[32]; // 事件缓冲区
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> getFieldOrder() {
|
protected List<String> getFieldOrder() {
|
||||||
return Arrays.asList("smp_va", "smp_vb", "smp_vc", "smp_rate", "smp_len", "evt_num", "evt_buf");
|
return Arrays.asList("smp_va", "smp_vb", "smp_vc", "smp_rate", "smp_len", "evt_num", "evt_buf");
|
||||||
}
|
}
|
||||||
|
|
||||||
public QvvrDataStruct() {
|
public QvvrDataStruct() {
|
||||||
super();
|
super();
|
||||||
// 初始化事件缓冲区
|
// 初始化事件缓冲区
|
||||||
@@ -124,49 +128,49 @@ public interface QvvrDLL extends Library {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 事件缓冲区结构
|
* 事件缓冲区结构
|
||||||
*/
|
*/
|
||||||
public static class EventBuffer extends Structure {
|
public static class EventBuffer extends Structure {
|
||||||
public int[] qvvr_cata_cause = new int[256];
|
public int[] qvvr_cata_cause = new int[256];
|
||||||
public int[] qvvr_phasetype = new int[256];
|
public int[] qvvr_phasetype = new int[256];
|
||||||
public int[] qvvr_cata_type = new int[256];
|
public int[] qvvr_cata_type = new int[256];
|
||||||
|
|
||||||
public float hold_time_rms;
|
public float hold_time_rms;
|
||||||
public float hold_time_dq;
|
public float hold_time_dq;
|
||||||
|
|
||||||
public float POW_a;
|
public float POW_a;
|
||||||
public float POW_b;
|
public float POW_b;
|
||||||
public float POW_c;
|
public float POW_c;
|
||||||
|
|
||||||
public float Voltagechange_Va;
|
public float Voltagechange_Va;
|
||||||
public float Voltagechange_Vb;
|
public float Voltagechange_Vb;
|
||||||
public float Voltagechange_Vc;
|
public float Voltagechange_Vc;
|
||||||
|
|
||||||
public int SEG_T_num;
|
public int SEG_T_num;
|
||||||
public int[] SEG_T0_idx = new int[256];
|
public int[] SEG_T0_idx = new int[256];
|
||||||
public int[] SEG_T_idx = new int[256];
|
public int[] SEG_T_idx = new int[256];
|
||||||
|
|
||||||
public int SEG_RMS_T_num;
|
public int SEG_RMS_T_num;
|
||||||
public int[] SEG_RMS_T_idx = new int[256];
|
public int[] SEG_RMS_T_idx = new int[256];
|
||||||
|
|
||||||
public int u_min_num;
|
public int u_min_num;
|
||||||
public float[] ua_min = new float[256];
|
public float[] ua_min = new float[256];
|
||||||
public float[] ub_min = new float[256];
|
public float[] ub_min = new float[256];
|
||||||
public float[] uc_min = new float[256];
|
public float[] uc_min = new float[256];
|
||||||
public float[] u3_min = new float[256];
|
public float[] u3_min = new float[256];
|
||||||
public int[] order_min_idx = new int[256];
|
public int[] order_min_idx = new int[256];
|
||||||
|
|
||||||
public float[] angle_diff_ap = new float[256];
|
public float[] angle_diff_ap = new float[256];
|
||||||
public float[] angle_diff_bp = new float[256];
|
public float[] angle_diff_bp = new float[256];
|
||||||
public float[] angle_diff_cp = new float[256];
|
public float[] angle_diff_cp = new float[256];
|
||||||
public float[] angle_diff_an = new float[256];
|
public float[] angle_diff_an = new float[256];
|
||||||
public float[] angle_diff_bn = new float[256];
|
public float[] angle_diff_bn = new float[256];
|
||||||
public float[] angle_diff_cn = new float[256];
|
public float[] angle_diff_cn = new float[256];
|
||||||
|
|
||||||
public float[] bph_max_value = new float[256];
|
public float[] bph_max_value = new float[256];
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<String> getFieldOrder() {
|
protected List<String> getFieldOrder() {
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
|
|||||||
@@ -854,6 +854,21 @@ public class EventRelevantAnalysisServiceImpl extends ServiceImpl<RmpEventAdvanc
|
|||||||
/*************************************************************************************
|
/*************************************************************************************
|
||||||
* 获取变压器信息并生成矩阵
|
* 获取变压器信息并生成矩阵
|
||||||
*************************************************************************************/
|
*************************************************************************************/
|
||||||
|
public Map<String, Map<String, Integer>> getNodeBefore(){
|
||||||
|
Map<String, EntityMtrans> entityMtranMap = new HashMap<>(32);
|
||||||
|
|
||||||
|
HandleEvent handleEvent = new HandleEvent();
|
||||||
|
List<EntityLogic> list = relevantLogMapper.getLogic();
|
||||||
|
Map<String, Map<String, Integer>> setNodeSort = new HashMap<>();
|
||||||
|
if (CollectionUtil.isNotEmpty(list)) {
|
||||||
|
Map<String, List<String>> map = getLogicInfo(list);
|
||||||
|
setNodeSort = nodeSort(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
return setNodeSort;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public Map<String, EntityMtrans> getNodeInfo( ) {
|
public Map<String, EntityMtrans> getNodeInfo( ) {
|
||||||
Map<String, EntityMtrans> entityMtranMap = new HashMap<>(32);
|
Map<String, EntityMtrans> entityMtranMap = new HashMap<>(32);
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -147,6 +147,8 @@ public enum DicDataTypeEnum {
|
|||||||
Major_Nonlinear_Device("主要非线性设备类型","Major_Nonlinear_Device"),
|
Major_Nonlinear_Device("主要非线性设备类型","Major_Nonlinear_Device"),
|
||||||
EVALUATION_DEPT("主要非线性设备类型","evaluation_dept"),
|
EVALUATION_DEPT("主要非线性设备类型","evaluation_dept"),
|
||||||
EVALUATION_TYPE("评估类型","Evaluation_Type"),
|
EVALUATION_TYPE("评估类型","Evaluation_Type"),
|
||||||
|
|
||||||
|
DATA_DAY("日表表名","Data_Day")
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user