package com.ueky;
|
import gnu.io.SerialPort;
|
import gnu.io.UnsupportedCommOperationException;
|
|
import java.io.IOException;
|
import java.io.InputStream;
|
import java.io.OutputStream;
|
import java.nio.ByteBuffer;
|
import java.nio.ByteOrder;
|
import java.util.Arrays;
|
import java.util.Date;
|
|
import javax.swing.JOptionPane;
|
import javax.swing.JTextField;
|
|
import org.apache.logging.log4j.Logger;
|
|
import sp_comm.CommSerialPort;
|
import sp_comm.Comm_Socket;
|
import main.page_debug_inf;
|
|
import com.Com;
|
import com.ComFn;
|
import com.PlaySound;
|
import com.dev.bts.data.FBS9100_CapState;
|
import com.dev.bts.data.FBS9100_ChargeState;
|
import com.dev.bts.data.FBS9100_Cmd;
|
import com.dev.bts.data.FBS9100_ComBase;
|
import com.dev.bts.data.FBS9100_ComBuf;
|
import com.dev.bts.data.FBS9100_DeviceInf;
|
import com.dev.bts.data.FBS9100_ParamBatt;
|
import com.dev.bts.data.FBS9100_ParamCharge;
|
import com.dev.bts.data.FBS9100_ParamDischarge;
|
import com.dev.bts.data.FBS9100_ParamSystem;
|
import com.dev.bts.data.FBS9100_ResCapData;
|
import com.dev.bts.data.FBS9100_ResState;
|
import com.dev.bts.data.FBS9100_SysState;
|
import com.dev.bts.data.FBS9100_VCData;
|
import com.dev.bts4810.BTS_Ecb_Aes;
|
import com.dev.fbs9600_mon.SPCommMon;
|
|
/**
|
* BTSÉ豸ͨÐÅÏß³Ì
|
* @author LiJun
|
*
|
*/
|
public class CommUKEY implements Runnable/*, SerialPortEventListener*/ {
|
|
public static final short CMD_TYPE_NULL = 0x00;
|
public static final short CMD_TYPE_READ = 0x03;
|
public static final short CMD_TYPE_WRITE_WEBUKEY = 0x04;
|
public static final short CMD_TYPE_WRITE_DEVUKEY = 0x05;
|
public static final short CMD_TYPE_WRITE_SETUKEY = 0x06;
|
|
public static final int DEV_PARAM_DATA_STATE_NULL = 0; //
|
public static final int DEV_PARAM_DATA_STATE_UKEYQUERY = 1; //¶ÁÈ¡UKEYÐÅÏ¢
|
public static final int DEV_PARAM_DATA_STATE_UEKYWEB = 2; //ÉèÖÃÆ½Ì¨UKEY
|
public static final int DEV_PARAM_DATA_STATE_UEKYDEV = 3; //ÉèÖÃÉ豸UKEY
|
public static final int DEV_PARAM_DATA_STATE_SETUKEY = 4; //ÉèÖÃUKEY
|
|
public static final int DEV_PARAM_DATA_STATE_CLEAR = 5; //UKEYÒѰγö,Çå¿ÕukeyÐÅÏ¢
|
/*********************************************************************/
|
|
public static final int Comm_State_NotFount = 0; //δÕÒµ½UKEY
|
public static final int Comm_State_Success = 1; //²åÈëÕý³£
|
|
|
private int comm_state = Comm_State_Success;
|
|
|
private boolean alearyMaxCurr = false;
|
/*********************************************************************/
|
/*********************************************************************/
|
public boolean DEV_DATA_ENCIPHER = true; //ͨÐÅÊý¾ÝÊÇ·ñ¼ÓÃÜ
|
/*********************************************************************/
|
final public static String[] ZDHJ_OP_REST_INF_TEXT = new String[] {
|
"ÎÞ²Ù×÷",
|
};
|
|
// ÊäÈëÊä³öÁ÷
|
public static InputStream inputStream;
|
public static OutputStream outputStream;
|
// RS-232µÄ´®ÐпÚ
|
public static SerialPort serialPort;
|
|
private boolean CommThreadRunning = false;
|
private boolean dt_dfu_en = false;
|
BTS_Ecb_Aes my_aes = new BTS_Ecb_Aes();
|
private ByteBuffer CommRxBuffer = ByteBuffer.allocate(1500);
|
private ByteBuffer CommTxBuffer = ByteBuffer.allocate(1048);
|
|
private ByteBuffer DFUCommRxBuffer = ByteBuffer.allocate(1048);
|
private ByteBuffer DFUCommTxBuffer = ByteBuffer.allocate(1048);
|
|
private ByteBuffer FBS9100TxBuffer = ByteBuffer.allocate(1048);
|
private ByteBuffer FBS9100RxBuffer = ByteBuffer.allocate(1500);
|
|
public int comm_tx_cnt = 0;
|
public int comm_rx_cnt = 0;
|
|
//--------------------------------------------------------//
|
public int dev_param_data_state = DEV_PARAM_DATA_STATE_NULL;
|
public int dev_param_addr = 0;
|
public int[] dev_param_ch_mon_cnt = new int[5];
|
public int dev_param_curr_range = 0;
|
public double dev_param_wenbo_curr_lev = 0;
|
public int dev_param_auto_restest_interval = 0;
|
public int dev_param_res_test_type = 0;
|
//--------------------------------------------------------//
|
public String dev_stat_version_Str = "";
|
|
public String dev_control_Str = "";
|
public int dev_stat_version = 0;
|
public int dev_stat_state = 0;
|
public double GroupVol = 0;
|
public double BattCurr = 0;
|
public int BattCurrDir = 0;
|
public double AvgWenBoCurr = 0;
|
public double PeakWenBoCurr = 0;
|
//--------------------------------------------------------//
|
@SuppressWarnings("unused")
|
private JTextField dt_show_msg = new JTextField();
|
private int dt_cmd = CMD_TYPE_READ;
|
private int dt_usr_cmd = CMD_TYPE_NULL;
|
private ByteBuffer dt_datatofbs9100 = ByteBuffer.allocate(0);
|
public int dt_cmd_ack = 0;
|
public Date dt_cmd_ack_time = new Date();
|
private int dt_cmd_cnt = 0;
|
public int m_BTSDevSoftType = 0;
|
//--------------------------------------------------------//
|
//--------------------------------------------------------//
|
public FBS9100_Cmd m_FBS_Cmd = new FBS9100_Cmd();
|
public FBS9100_VCData m_FBS_VCData = new FBS9100_VCData();
|
public FBS9100_ParamBatt m_FBS_BattParam;
|
public FBS9100_ParamSystem m_FBS_SystemParam;
|
public FBS9100_ParamDischarge m_FBS_DiscParam = new FBS9100_ParamDischarge(); //ÉèÖõIJÎÊý
|
public FBS9100_ParamDischarge m_FBS_DiscParamFromDev = new FBS9100_ParamDischarge(); //´ÓÉ豸¶ÁÈ¡µÄ²ÎÊý
|
public FBS9100_ParamCharge m_FBS_ChargeParam = new FBS9100_ParamCharge();
|
public FBS9100_ResState m_ResTestState = new FBS9100_ResState();
|
public FBS9100_CapState m_CapTestState = new FBS9100_CapState();
|
public FBS9100_ChargeState m_ChrTestState = new FBS9100_ChargeState();
|
public FBS9100_ResCapData m_FBS_ResCapData = new FBS9100_ResCapData();
|
public ByteBuffer m_TaskList = ByteBuffer.allocate(1024);
|
//--------------------------------------------------------//
|
private page_debug_inf dt_debug_inf;
|
private int m_COMM_PORT_TYPE = 0;
|
private CommSerialPort m_SP_Comm = null;
|
private Comm_Socket m_SocketComm = null;
|
private Logger m_Log = null;
|
//--------------------------------------------------------//
|
public String DevicePath;
|
|
private String ukeyid_str = "";
|
private String publicx_str = "";
|
private String publicy_str = "";
|
|
public String publicx_set = "";
|
public String publicy_set = "";
|
private com.softkey.jsyunew3 mD8=new com.softkey.jsyunew3();
|
//--------------------------------------------------------//
|
|
public CommUKEY(page_debug_inf debug, Logger log) {
|
dt_debug_inf = debug;
|
m_Log = log;
|
|
comm_tx_cnt = 0;
|
comm_rx_cnt = 0;
|
CommThreadRunning = true;
|
}
|
|
|
|
private ByteBuffer makeRandomDataBuffer(int dt_cmd) {
|
int datatype = FBS9100_ComBase.DataType_MonVol;
|
if(dt_cmd == FBS9100_ComBase.CMD_SetVIData) {
|
datatype = FBS9100_ComBase.DataType_MonVol;
|
}else if(dt_cmd == FBS9100_ComBase.CMD_SetMonomerRes) {
|
datatype = FBS9100_ComBase.DataType_MonRes;
|
}else if(dt_cmd == FBS9100_ComBase.CMD_SetMonomerTMP) {
|
datatype = FBS9100_ComBase.DataType_MonTmp;
|
}
|
|
ByteBuffer buff = m_FBS_VCData.getByteBuffer(datatype, m_FBS_ResCapData);
|
return buff;
|
}
|
|
|
public void tr_Msg(ByteBuffer bbf_tx, ByteBuffer bbf_rx, boolean showdat) {
|
if(++comm_tx_cnt > 32500) {
|
comm_tx_cnt = 0;
|
}
|
if(SPCommMon.COMM_PORT_TYPE_Serial == m_COMM_PORT_TYPE) {
|
m_SP_Comm.SP_Comm(bbf_tx, bbf_rx, CommSerialPort.mutycomm_Type_Samd09, dt_debug_inf, showdat);
|
} else {
|
m_SocketComm.SocketComm(bbf_tx, bbf_rx, dt_debug_inf, showdat);
|
}
|
}
|
|
public void exitCommPortThread() {
|
CommThreadRunning = false;
|
}
|
|
private void closeCommPort() {
|
if(SPCommMon.COMM_PORT_TYPE_Serial == m_COMM_PORT_TYPE) {
|
m_SP_Comm.serialPort.close();
|
} else {
|
m_SocketComm.socketClose();
|
}
|
}
|
|
public void setCommCmd(int cmd) {
|
dt_usr_cmd = cmd;
|
}
|
|
public void setCommCmd_DFU(boolean dfu_en, String dfu_file, JTextField show_area) {
|
dt_dfu_en = dfu_en;
|
dt_show_msg = show_area;
|
}
|
|
|
public void setCommCmdAck(int ack_t) {
|
dt_cmd_ack = ack_t;
|
dt_cmd_ack_time = new Date();
|
String wav_f = "6133.wav";
|
if(ack_t%2 == 0) {
|
wav_f = "4577.wav";
|
}
|
if(ack_t > 0) {
|
new PlaySound(wav_f);
|
}
|
}
|
|
public void sendFBS9100Data(int cmd, ByteBuffer bbf_tx) throws IOException {
|
ByteBuffer bf_t = FBS9100_ComBuf.makeFbs9100CommBuf(255, cmd, bbf_tx, true);
|
byte[] cipher_tx_t = new byte[bf_t.limit()];
|
bf_t.get(cipher_tx_t);
|
//byte[] bt_t = FBS9100_ComBuf.makeFbs9100CommBuf(21, 0x15, ByteBuffer.allocate(0)).array();
|
|
//byte[] cipher_tx_t = new byte[bf_t.limit()];
|
//my_aes.ecb_encrypt(plain_tx_t, cipher_tx_t, plain_tx_t.length);
|
|
//System.out.println(ComFn.bytesToHexString(plain_tx_t, plain_tx_t.length));
|
outputStream.write(cipher_tx_t);
|
if(++comm_tx_cnt > 1000000) {
|
comm_tx_cnt = 0;
|
}
|
}
|
|
public void run() {
|
System.out.println("CommThreadRunning:"+CommThreadRunning);
|
|
while(true == CommThreadRunning) {
|
try {
|
if(false == dt_dfu_en) {
|
//¼ì²âUKEYÊÇ·ñ°Î³ö
|
checkUkey();
|
|
if(CMD_TYPE_NULL != dt_usr_cmd) {
|
if(CMD_TYPE_READ == dt_usr_cmd) {
|
readUkeyInfo();
|
}else if(CMD_TYPE_WRITE_WEBUKEY == dt_usr_cmd) {
|
writeWebUkey();
|
}else if(CMD_TYPE_WRITE_DEVUKEY == dt_usr_cmd) {
|
writeDevUkey();
|
}else if(CMD_TYPE_WRITE_SETUKEY == dt_usr_cmd) {
|
writeRanUkey();
|
}
|
dt_usr_cmd = CMD_TYPE_NULL;
|
}
|
Thread.sleep(500);
|
}
|
} catch (InterruptedException e) {
|
// TODO Auto-generated catch block
|
e.printStackTrace();
|
exitCommPortThread();
|
JOptionPane.showMessageDialog(null, "BTS ÉÏλ»ú´®¿ÚÒì³£: " + e.getMessage());
|
}
|
}
|
/******************************************/
|
closeCommPort();
|
/******************************************/
|
System.out.println("BTS CommPort is quit!");
|
}
|
|
/**
|
* ÉèÖÃUKEYΪ×Ô¶¨ÒåUKEY
|
*/
|
private void writeRanUkey() {
|
boolean isSuccess = false;
|
String PriKey = "";
|
if(null != this.DevicePath && this.DevicePath.trim().length()>0) {
|
/*
|
* //¿ªÊ¼Éú³ÉÃÜÔ¿ int code = mD8.StarGenKeyPair(DevicePath); long last_code =
|
* mD8.get_LastError(); if (last_code != 0) {
|
* m_Log.error("ÉèÖÿªÊ¼Éú³Éƽ̨ÃÜÔ¿,´íÎóÂë:"+last_code); isSuccess = false; }else {
|
* isSuccess = true; }
|
*/
|
PriKey = "A3A96FD399FB5CD5761D1624571E4158FC8D6E896A7754D62E3EA47DC766BF9B";
|
|
String dev_str = "123";
|
|
int last_code = mD8.Set_SM2_KeyPair(PriKey,publicx_set,publicy_set, dev_str,DevicePath);
|
if(last_code != 0) {
|
dt_debug_inf.addDebugInf(Com.get_DTF(new Date(), Com.DTF_YMDhms_S)+"ÉèÖÃUkeyÃÜÔ¿¶Ôʱ±¨´í,´íÎóÂë:"+last_code+"\n");
|
isSuccess = false;
|
}else {
|
isSuccess = true;
|
}
|
}
|
if(isSuccess) {
|
publicx_str = publicx_set;
|
publicy_str = publicy_set;
|
dev_param_data_state = DEV_PARAM_DATA_STATE_SETUKEY;
|
dev_control_Str = "ÉèÖÃUKEYÃÜÔ¿¶Ô³É¹¦" + Com.get_DTF(new Date(), Com.DTF_YMDhms);
|
dt_debug_inf.addDebugInf(Com.get_DTF(new Date(), Com.DTF_YMDhms_S) + "ÉèÖÃUKEYÃÜÔ¿¶Ô³É¹¦" + "\n");
|
}else {
|
dev_param_data_state = DEV_PARAM_DATA_STATE_NULL;
|
dt_debug_inf.addDebugInf(Com.get_DTF(new Date(), Com.DTF_YMDhms_S) + "ÉèÖÃUKEYÃÜÔ¿¶Ôʧ°Ü" + "\n");
|
}
|
}
|
|
/**
|
* ÉèÖÃUKEYΪÉ豸°æUKEY
|
*/
|
private void writeDevUkey() {
|
boolean isSuccess = false;
|
String PriKey = "";
|
String PubKeyX = "";
|
String PubKeyY = "";
|
if(null != this.DevicePath && this.DevicePath.trim().length()>0) {
|
/*
|
* //¿ªÊ¼Éú³ÉÃÜÔ¿ int code = mD8.StarGenKeyPair(DevicePath); long last_code =
|
* mD8.get_LastError(); if (last_code != 0) {
|
* m_Log.error("ÉèÖÿªÊ¼Éú³Éƽ̨ÃÜÔ¿,´íÎóÂë:"+last_code); isSuccess = false; }else {
|
* isSuccess = true; }
|
*/
|
Date oldTime = new Date(123,2,3);
|
Date nowTime = new Date();
|
PriKey = "A3A96FD399FB5CD5761D1624571E4158FC8D6E896A7754D62E3EA47DC766BF9B";
|
PubKeyX = "129BDA6338262E3914704DB177955436A2183284CFAA69DAEB7432D591D0CF62";
|
PubKeyY = "EC2FC8397C31530159EF4F9223DA40D4039203AA1D49AEECDC9366973CF7AE20";
|
//System.out.println(Com.get_DTF(oldTime, Com.DTF_YMDhms));
|
//System.out.println(Com.get_DTF(nowTime, Com.DTF_YMDhms));
|
if(nowTime.getTime()<oldTime.getTime()) {
|
PriKey = "C1B18CCB03B1DEEDEE9DEDB95C456F55CA24CD0C478ACCFBE57371BA4A7E2883";
|
PubKeyX = "FE7C0F1805BA9F263BCE6EB198DE02B52C6706AF5C9FBC24C8B0E19545B01595";
|
PubKeyY = "6471C138A584BD6EEAFE1FCD7628531A7DE8E49FFD205857AE1F82D84016F3F3";
|
}
|
String dev_str = "123";
|
|
int last_code = mD8.Set_SM2_KeyPair(PriKey,PubKeyX,PubKeyY, dev_str,DevicePath);
|
if(last_code != 0) {
|
dt_debug_inf.addDebugInf(Com.get_DTF(new Date(), Com.DTF_YMDhms_S)+"ÉèÖÃÉ豸°æUkeyÃÜԿʱ±¨´í,´íÎóÂë:"+last_code+"\n");
|
isSuccess = false;
|
}else {
|
isSuccess = true;
|
}
|
}
|
if(isSuccess) {
|
publicx_str = PubKeyX;
|
publicy_str = PubKeyY;
|
dev_param_data_state = DEV_PARAM_DATA_STATE_UEKYDEV;
|
dev_control_Str = "ÉèÖÃÉ豸°æUKEYÃÜÔ¿¶Ô³É¹¦" + Com.get_DTF(new Date(), Com.DTF_YMDhms);
|
dt_debug_inf.addDebugInf(Com.get_DTF(new Date(), Com.DTF_YMDhms_S) + "ÉèÖÃÉ豸°æUKEYÃÜÔ¿¶Ô³É¹¦" + "\n");
|
}else {
|
dev_param_data_state = DEV_PARAM_DATA_STATE_NULL;
|
dev_control_Str = "ÉèÖÃÉ豸°æUKEYÃÜÔ¿¶Ôʧ°Ü" + Com.get_DTF(new Date(), Com.DTF_YMDhms);
|
dt_debug_inf.addDebugInf(Com.get_DTF(new Date(), Com.DTF_YMDhms_S) + "ÉèÖÃÉ豸°æUKEYÃÜÔ¿¶Ôʧ°Ü" + "\n");
|
}
|
}
|
|
/**
|
* ÉèÖÃUKEYΪƽ̨UKEY
|
*/
|
private void writeWebUkey() {
|
boolean isSuccess = false;
|
String PriKey = "";
|
String PubKeyX = "";
|
String PubKeyY = "";
|
if(null != this.DevicePath && this.DevicePath.trim().length()>0) {
|
|
//¿ªÊ¼Éú³ÉÃÜÔ¿
|
int code = mD8.StarGenKeyPair(DevicePath);
|
long last_code = mD8.get_LastError();
|
if (last_code != 0) {
|
dt_debug_inf.addDebugInf(Com.get_DTF(new Date(), Com.DTF_YMDhms_S)+"ÉèÖÿªÊ¼Éú³Éƽ̨ÃÜÔ¿,´íÎóÂë:"+last_code+"\n");
|
isSuccess = false;
|
}else {
|
isSuccess = true;
|
}
|
|
|
//¼ÓÃܹ·Ð¾Æ¬Î¨Ò»ID£¬Îª32¸ö×Ö·û³¤¶È
|
PriKey=mD8.get_GenPriKey();
|
if (mD8.get_LastError() != 0) {
|
dt_debug_inf.addDebugInf(Com.get_DTF(new Date(), Com.DTF_YMDhms_S)+"ÉèÖÿªÊ¼Éú³Éƽ̨˽Կ,´íÎóÂë:"+last_code+"\n");
|
isSuccess = false;
|
}else {
|
isSuccess = true;
|
}
|
|
//Éú³ÉËøµÄоƬPublicX
|
PubKeyX=mD8.get_GenPubKeyX();
|
last_code = mD8.get_LastError();
|
if (last_code != 0) {
|
dt_debug_inf.addDebugInf(Com.get_DTF(new Date(), Com.DTF_YMDhms_S)+"¶ÁÈ¡Éú³ÉUkeyµÄPublicXʱ±¨´í,´íÎóÂë:"+last_code+"\n");
|
isSuccess = false;
|
}else {
|
isSuccess = true;
|
}
|
|
|
PubKeyY=mD8.get_GenPubKeyY();
|
last_code = mD8.get_LastError();
|
if (last_code != 0) {
|
dt_debug_inf.addDebugInf(Com.get_DTF(new Date(), Com.DTF_YMDhms_S)+"¶ÁÈ¡Éú³ÉUkeyµÄPublicYʱ±¨´í,´íÎóÂë:"+last_code+"\n");
|
isSuccess = false;
|
}else {
|
isSuccess = true;
|
}
|
String web_str = "Î人Դ³©¿Æ¼¼ÓÐÏÞ¹«Ë¾";
|
last_code = mD8.Set_SM2_KeyPair(PriKey,PubKeyX,PubKeyY, web_str,DevicePath);
|
if(last_code != 0) {
|
dt_debug_inf.addDebugInf(Com.get_DTF(new Date(), Com.DTF_YMDhms_S)+"ÉèÖÃÆ½Ì¨°æUkeyÃÜԿʱ±¨´í,´íÎóÂë:"+last_code+"\n");
|
isSuccess = false;
|
}else {
|
isSuccess = true;
|
}
|
|
}
|
if(isSuccess) {
|
publicx_str = PubKeyX;
|
publicy_str = PubKeyY;
|
dev_param_data_state = DEV_PARAM_DATA_STATE_UEKYWEB;
|
dev_control_Str = "ÉèÖÃÆ½Ì¨°æUKEYÃÜÔ¿¶Ô³É¹¦" + Com.get_DTF(new Date(), Com.DTF_YMDhms);
|
dt_debug_inf.addDebugInf(Com.get_DTF(new Date(), Com.DTF_YMDhms_S) + "ÉèÖÃÆ½Ì¨°æUKEYÃÜÔ¿¶Ô³É¹¦" + "\n");
|
}else {
|
dev_param_data_state = DEV_PARAM_DATA_STATE_NULL;
|
dev_control_Str = "ÉèÖÃÆ½Ì¨°æUKEYÃÜÔ¿¶Ôʧ°Ü" + Com.get_DTF(new Date(), Com.DTF_YMDhms);
|
dt_debug_inf.addDebugInf(Com.get_DTF(new Date(), Com.DTF_YMDhms_S) + "ÉèÖÃÆ½Ì¨°æUKEYÃÜÔ¿¶Ôʧ°Ü" + "\n");
|
}
|
}
|
|
|
|
/**
|
* ¶ÁÈ¡UKEYÐÅÏ¢
|
*/
|
private void readUkeyInfo() {
|
boolean isSuccess = false;
|
if(null != this.DevicePath && this.DevicePath.trim().length()>0) {
|
//¶ÁÈ¡UkeyID
|
String ukeyid = mD8.GetChipID(DevicePath);
|
long last_code = mD8.get_LastError();
|
if (last_code != 0) {
|
dt_debug_inf.addDebugInf(Com.get_DTF(new Date(), Com.DTF_YMDhms_S)+"¶ÁÈ¡UkeyIDʱ±¨´í,´íÎóÂë:"+last_code+"\n");
|
isSuccess = false;
|
}else {
|
isSuccess = true;
|
this.ukeyid_str = ukeyid;
|
}
|
|
//»ñÈ¡ËøµÄоƬPublicX
|
String PubKeyX=mD8.GetPubKeyX(DevicePath);
|
last_code = mD8.get_LastError();
|
if (last_code != 0) {
|
dt_debug_inf.addDebugInf(Com.get_DTF(new Date(), Com.DTF_YMDhms_S)+"¶ÁÈ¡UkeyµÄPublicXʱ±¨´í,´íÎóÂë:"+last_code+"\n");
|
isSuccess = false;
|
}else {
|
isSuccess = true;
|
publicx_str = PubKeyX;
|
}
|
|
|
String PublicY=mD8.GetPubKeyY(DevicePath);
|
last_code = mD8.get_LastError();
|
if (last_code != 0) {
|
dt_debug_inf.addDebugInf(Com.get_DTF(new Date(), Com.DTF_YMDhms_S)+"¶ÁÈ¡UkeyµÄPublicYʱ±¨´í,´íÎóÂë:"+last_code +"\n");
|
isSuccess = false;
|
}else {
|
isSuccess = true;
|
publicy_str = PublicY;
|
}
|
}
|
if(isSuccess) {
|
dev_param_data_state = DEV_PARAM_DATA_STATE_UKEYQUERY;
|
dev_control_Str = "¶ÁÈ¡UKEYÃÜÔ¿¶ÔÊý¾Ý³É¹¦" + Com.get_DTF(new Date(), Com.DTF_YMDhms);
|
dt_debug_inf.addDebugInf(Com.get_DTF(new Date(), Com.DTF_YMDhms_S) + "¶ÁÈ¡UKEYÃÜÔ¿¶ÔÊý¾Ý³É¹¦" + "\n");
|
}else {
|
dev_param_data_state = DEV_PARAM_DATA_STATE_NULL;
|
dev_control_Str = "¶ÁÈ¡UKEYÃÜÔ¿¶ÔÊý¾Ýʧ°Ü" + Com.get_DTF(new Date(), Com.DTF_YMDhms);
|
dt_debug_inf.addDebugInf(Com.get_DTF(new Date(), Com.DTF_YMDhms_S) + "¶ÁÈ¡UKEYÃÜÔ¿¶ÔÊý¾Ýʧ°Ü" + "\n");
|
}
|
}
|
|
/**
|
* ¼ì²âUKEY²åÈë״̬
|
*/
|
private void checkUkey() {
|
//Õâ¸öÓÃÓÚÅжÏϵͳÖÐÊÇ·ñ´æÔÚ׿ÓÃÜËø¡£²»ÐèÒªÊÇÖ¸¶¨µÄ¼ÓÃÜËø,
|
this.DevicePath = mD8.FindPort(0);
|
if(mD8.get_LastError()!=0)
|
{
|
if(Comm_State_Success == comm_state) {
|
dev_control_Str = "δÕÒµ½¼ÓÃÜËø,Çë²åÈë¼ÓÃÜËøºó£¬ÔÙ½øÐвÙ×÷";
|
dt_debug_inf.addDebugInf(Com.get_DTF(new Date(), Com.DTF_YMDhms_S)+"δÕÒµ½¼ÓÃÜËø,Çë²åÈë¼ÓÃÜËøºó£¬ÔÙ½øÐвÙ×÷\n");
|
comm_state = Comm_State_NotFount;
|
|
this.ukeyid_str = "";
|
this.publicx_str = "";
|
this.publicy_str = "";
|
|
dev_param_data_state = DEV_PARAM_DATA_STATE_CLEAR;
|
}
|
}else if(comm_state == Comm_State_NotFount){
|
dev_control_Str = "";
|
comm_state = Comm_State_Success;
|
dt_debug_inf.addDebugInf(Com.get_DTF(new Date(), Com.DTF_YMDhms_S)+"¼ì²âµ½UKEY²åÈë\n");
|
//»ñÈ¡ËøµÄоƬPublicX
|
// String PubKeyX=mD8.GetPubKeyX(DevicePath);
|
// long last_code = mD8.get_LastError();
|
// if (last_code == 0) {
|
// publicx_str = PubKeyX;
|
// }
|
//
|
// String PublicY=mD8.GetPubKeyY(DevicePath);
|
// last_code = mD8.get_LastError();
|
// if (last_code == 0) {
|
// publicy_str = PublicY;
|
// }
|
}
|
//System.err.println(this.DevicePath);
|
}
|
|
|
|
public String getPublicx_str() {
|
return publicx_str;
|
}
|
|
|
|
public String getPublicy_str() {
|
return publicy_str;
|
}
|
|
|
|
public String getUkeyid_str() {
|
return ukeyid_str;
|
}
|
|
|
|
public static void main(String[] args) {
|
for(int i =0 ;i<100;i++) {
|
|
|
}
|
}
|
}
|