FileFtransitUtil去掉方法的静态关键字
This commit is contained in:
parent
8718aeed1c
commit
c5f4b20183
|
@ -7,10 +7,12 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.jeecg.common.constant.DateConstant;
|
import org.jeecg.common.constant.DateConstant;
|
||||||
import org.jeecg.common.enums.FtransitEnum;
|
import org.jeecg.common.enums.FtransitEnum;
|
||||||
|
import org.jeecg.common.properties.ParameterProperties;
|
||||||
import org.jeecg.modules.entity.vo.*;
|
import org.jeecg.modules.entity.vo.*;
|
||||||
import org.jeecg.modules.native_jni.CalValuesHandler;
|
import org.jeecg.modules.native_jni.CalValuesHandler;
|
||||||
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
|
import org.jeecg.modules.native_jni.EnergySpectrumHandler;
|
||||||
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
import org.jeecg.modules.native_jni.struct.EnergySpectrumStruct;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
@ -27,7 +29,10 @@ import java.util.Objects;
|
||||||
@Component
|
@Component
|
||||||
public class FileFtransitUtil {
|
public class FileFtransitUtil {
|
||||||
|
|
||||||
public static boolean ReadIEC(File iecFile, FileData datas) {
|
@Autowired
|
||||||
|
private ParameterProperties parameterProperties;
|
||||||
|
|
||||||
|
public boolean ReadIEC(File iecFile, FileData datas) {
|
||||||
//判断文件是否是只读类型
|
//判断文件是否是只读类型
|
||||||
if(!iecFile.setReadOnly()) {
|
if(!iecFile.setReadOnly()) {
|
||||||
String waring = "Open "+iecFile.getName()+" failed when reading!";
|
String waring = "Open "+iecFile.getName()+" failed when reading!";
|
||||||
|
@ -291,7 +296,7 @@ public class FileFtransitUtil {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String WriteIEC(FileData datas) {
|
public String WriteIEC(FileData datas) {
|
||||||
StringBuffer out = new StringBuffer();
|
StringBuffer out = new StringBuffer();
|
||||||
// first line
|
// first line
|
||||||
out.append(FtransitEnum.IecFirstLine.getCode());
|
out.append(FtransitEnum.IecFirstLine.getCode());
|
||||||
|
@ -463,7 +468,7 @@ public class FileFtransitUtil {
|
||||||
return out.toString();
|
return out.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean ReadIMS(File imsFile, FileData datas) {
|
public boolean ReadIMS(File imsFile, FileData datas) {
|
||||||
EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(imsFile.getAbsolutePath());
|
EnergySpectrumStruct struct = EnergySpectrumHandler.getSourceData(imsFile.getAbsolutePath());
|
||||||
if (StringUtils.isNotBlank(struct.designator)) {
|
if (StringUtils.isNotBlank(struct.designator)) {
|
||||||
datas.setDesignator(struct.designator);
|
datas.setDesignator(struct.designator);
|
||||||
|
@ -571,7 +576,7 @@ public class FileFtransitUtil {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String WriteIMS(FileData datas) {
|
public String WriteIMS(FileData datas) {
|
||||||
StringBuffer out = new StringBuffer();
|
StringBuffer out = new StringBuffer();
|
||||||
//第一行
|
//第一行
|
||||||
out.append("BEGIN IMS2.0");
|
out.append("BEGIN IMS2.0");
|
||||||
|
@ -690,7 +695,7 @@ public class FileFtransitUtil {
|
||||||
return out.toString();
|
return out.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean ReadSPC(File spcFile, FileData datas) {
|
public boolean ReadSPC(File spcFile, FileData datas) {
|
||||||
// r:只读 rw:读写
|
// r:只读 rw:读写
|
||||||
RandomAccessFile SpcFile = null;
|
RandomAccessFile SpcFile = null;
|
||||||
try {
|
try {
|
||||||
|
@ -1112,7 +1117,7 @@ public class FileFtransitUtil {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void WriteSPC(File tmpFile, FileData datas) {
|
public void WriteSPC(File tmpFile, FileData datas) {
|
||||||
// r:只读 rw:读写
|
// r:只读 rw:读写
|
||||||
RandomAccessFile SpcFile = null;
|
RandomAccessFile SpcFile = null;
|
||||||
try {
|
try {
|
||||||
|
@ -1363,7 +1368,7 @@ public class FileFtransitUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String convert(byte[] bytes, String type) {
|
public String convert(byte[] bytes, String type) {
|
||||||
List<String> values = new LinkedList<>();
|
List<String> values = new LinkedList<>();
|
||||||
for (int i=0; i<bytes.length; i++) {
|
for (int i=0; i<bytes.length; i++) {
|
||||||
byte b = bytes[i];
|
byte b = bytes[i];
|
||||||
|
@ -1399,8 +1404,8 @@ public class FileFtransitUtil {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] AnalyseSPC(SpcHead1 m_head1, SpcHead2 m_head2, GermaniumCalib m_calibParam) {
|
public byte[] AnalyseSPC(SpcHead1 m_head1, SpcHead2 m_head2, GermaniumCalib m_calibParam) {
|
||||||
String standard_spc = "D:\\ARMD\\材料\\spc-ims\\standard.SPC";
|
String standard_spc = parameterProperties.getFilePath()+"/standard.SPC";
|
||||||
File standardSpc = new File(standard_spc);
|
File standardSpc = new File(standard_spc);
|
||||||
if(!standardSpc.exists()) {
|
if(!standardSpc.exists()) {
|
||||||
String Warning = standard_spc + " isn't exist.";
|
String Warning = standard_spc + " isn't exist.";
|
||||||
|
@ -1536,7 +1541,7 @@ public class FileFtransitUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void MakeSpcHead(FileData datas, SpcHead1 m_head1, SpcHead2 m_head2) {
|
public void MakeSpcHead(FileData datas, SpcHead1 m_head1, SpcHead2 m_head2) {
|
||||||
m_head1.Inftyp = 1;
|
m_head1.Inftyp = 1;
|
||||||
m_head1.Filtyp = 1;
|
m_head1.Filtyp = 1;
|
||||||
if(datas.getVvEner().size() > 0 && datas.getVvReso().size() > 0) {
|
if(datas.getVvEner().size() > 0 && datas.getVvReso().size() > 0) {
|
||||||
|
@ -1559,7 +1564,7 @@ public class FileFtransitUtil {
|
||||||
m_head2.LiveTime = datas.getAcq_live();
|
m_head2.LiveTime = datas.getAcq_live();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void MakeCalibParam(FileData datas, GermaniumCalib m_calibParam) {
|
public void MakeCalibParam(FileData datas, GermaniumCalib m_calibParam) {
|
||||||
if(datas.getVvEffi().size() < 3 || datas.getVvEner().size() < 3 || datas.getVvReso().size() < 3) {
|
if(datas.getVvEffi().size() < 3 || datas.getVvEner().size() < 3 || datas.getVvReso().size() < 3) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1597,7 +1602,7 @@ public class FileFtransitUtil {
|
||||||
m_calibParam.FwhmCoefC = Float.valueOf(String.valueOf(reso_para.getP().get(3)));
|
m_calibParam.FwhmCoefC = Float.valueOf(String.valueOf(reso_para.getP().get(3)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String GetDate(String str) {
|
public String GetDate(String str) {
|
||||||
str = str.substring(0, 10); // YYYY/MM/DD
|
str = str.substring(0, 10); // YYYY/MM/DD
|
||||||
String temp = str.substring(str.length()-2)+ StringPool.DASH; // DD-
|
String temp = str.substring(str.length()-2)+ StringPool.DASH; // DD-
|
||||||
int month = Integer.valueOf(str.substring(5, 7));
|
int month = Integer.valueOf(str.substring(5, 7));
|
||||||
|
@ -1625,21 +1630,21 @@ public class FileFtransitUtil {
|
||||||
return temp;
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] writeShort(int v) {
|
public byte[] writeShort(int v) {
|
||||||
byte[] byteArr = new byte[2];
|
byte[] byteArr = new byte[2];
|
||||||
byteArr[0] = (byte) ((v >>> 0) & 0xFF);
|
byteArr[0] = (byte) ((v >>> 0) & 0xFF);
|
||||||
byteArr[1] = (byte) ((v >>> 8) & 0xFF);
|
byteArr[1] = (byte) ((v >>> 8) & 0xFF);
|
||||||
return byteArr;
|
return byteArr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] writeChar(int v) {
|
public byte[] writeChar(int v) {
|
||||||
byte[] byteArr = new byte[2];
|
byte[] byteArr = new byte[2];
|
||||||
byteArr[0] = (byte) ((v >>> 0) & 0xFF);
|
byteArr[0] = (byte) ((v >>> 0) & 0xFF);
|
||||||
byteArr[1] = (byte) ((v >>> 8) & 0xFF);
|
byteArr[1] = (byte) ((v >>> 8) & 0xFF);
|
||||||
return byteArr;
|
return byteArr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] writeInt(int v) {
|
public byte[] writeInt(int v) {
|
||||||
byte[] byteArr = new byte[4];
|
byte[] byteArr = new byte[4];
|
||||||
byteArr[0] = (byte) ((v >>> 0) & 0xFF);
|
byteArr[0] = (byte) ((v >>> 0) & 0xFF);
|
||||||
byteArr[1] = (byte) ((v >>> 8) & 0xFF);
|
byteArr[1] = (byte) ((v >>> 8) & 0xFF);
|
||||||
|
@ -1648,7 +1653,7 @@ public class FileFtransitUtil {
|
||||||
return byteArr;
|
return byteArr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] writeLong(long v) {
|
public byte[] writeLong(long v) {
|
||||||
byte[] byteArr = new byte[8];
|
byte[] byteArr = new byte[8];
|
||||||
byteArr[0] = (byte) ((v >>> 0) & 0xFF);
|
byteArr[0] = (byte) ((v >>> 0) & 0xFF);
|
||||||
byteArr[1] = (byte) ((v >>> 8) & 0xFF);
|
byteArr[1] = (byte) ((v >>> 8) & 0xFF);
|
||||||
|
@ -1661,12 +1666,12 @@ public class FileFtransitUtil {
|
||||||
return byteArr;
|
return byteArr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] writeFloat(float v) {
|
public byte[] writeFloat(float v) {
|
||||||
byte[] byteArr = writeInt(Float.floatToIntBits(v));
|
byte[] byteArr = writeInt(Float.floatToIntBits(v));
|
||||||
return byteArr;
|
return byteArr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static byte[] writeDouble(double v) {
|
public byte[] writeDouble(double v) {
|
||||||
byte[] byteArr = writeLong(Double.doubleToLongBits(v));
|
byte[] byteArr = writeLong(Double.doubleToLongBits(v));
|
||||||
return byteArr;
|
return byteArr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user