- 引入依赖
<dependency>
<groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId>
<version>5.9.0</version>
</dependency>
- 创建接口类
public interface WinningChssInterfaceDLL extends Library {
WinningChssInterfaceDLL INSTANCE = Native.loadLibrary("C:\\Users\\admin\\Desktop\\usb3ea.dll",WinningChssInterfaceDLL.class);
int GetCardStatus(Boolean a, Boolean b);
void SetEncoding(short CardNo, int PackingVer, int FramingVer, int encoding, int bits);
void StopSample();
}
- 继承了Structure,与本地代码进行交互
@Data
public class COMWAVEDATA extends Structure {
public int FrameNo;
public long ArrivingTimeus;
public int usInArrivingTime;
public int nsInArrivingTime;
public double Amp;
public int ChannelId;
public SYSTEMTIME ArrivingTimeST;
public int RingdownCount;
public int RisingRingdownCount;
public long DurationTimeus;
public long RiseTimeus;
public double Enery;
public double RMS;
public double ASL;
public long ArrivingTimens;
public long DurationTimens;
public long RiseTimens;
public double[] ExParam = new double[17];
@Override
protected List getFieldOrder() {
return Arrays.asList(new String[]{"FrameNo", "ArrivingTimeus", "usInArrivingTime", "nsInArrivingTime", "Amp", "ChannelId", "ArrivingTimeST", "RingdownCount", "RisingRingdownCount"
, "DurationTimeus", "RiseTimeus", "Enery", "RMS", "ASL", "ArrivingTimens", "DurationTimens", "RiseTimens", "ExParam"});
}
- 调用方法
int len = WinningChssInterfaceDLL.INSTANCE.GetCardStatus(true, true);