package com.dev.dummyload;
|
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.ComBase;
|
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.dummyload.data.DummyLoad_Cmd;
|
import com.dev.dummyload.data.DummyLoad_ComBase;
|
import com.dev.fbs9600_mon.SPCommMon;
|
import com.dev.switchdev.data.ModBus_RTU_Cmd;
|
import com.dev.switchdev.data.SwitchDevice_ComBase;
|
|
/**
|
* È«¹¦ÄÜÇл»×°ÖÃÉ豸ͨÐÅÏß³Ì
|
* @author LiJun
|
*
|
*/
|
public class CommDummyLoad implements Runnable/*, SerialPortEventListener*/ {
|
|
public static final short CMD_TYPE_READ = 0x03;
|
public static final short CMD_TYPE_WRITE = 0x05;
|
public static final short CMD_TYPE_WRITE_MULTY = 0x10;
|
|
public static final int DEV_PARAM_DATA_STATE_NULL = 0; //
|
public static final int DEV_PARAM_DATA_STATE_DISQUERY = 1; //¶ÁÈ¡ºËÈݲÎÊý
|
public static final int DEV_PARAM_DATA_STATE_BATTQUERY = 2; //¶ÁÈ¡µç³Ø²ÎÊý
|
public static final int DEV_PARAM_DATA_STATE_SYSQUERY = 3; //¶Áȡϵͳ²ÎÊý
|
public static final int DEV_PARAM_DATA_STATE_UPDATE = 4; //ÉèÖòÎÊý
|
/*********************************************************************/
|
public static final int DEV_DATA_AUTO_READ = 0; //×Ô¶¯¶ÁÈ¡
|
public static final int DEV_DATA_MANUAL_SET = 1; //ÊÖ¶¯ÉèÖÃ
|
public static final int DEV_DATA_AUTO_RANDOM = 2; //×Ô¶¯Ëæ»ú
|
|
private boolean alearyMaxCurr = false;
|
/*********************************************************************/
|
public int dev_data_type = DEV_DATA_AUTO_READ;
|
/*********************************************************************/
|
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);
|
|
public int comm_tx_cnt = 0;
|
public int comm_rx_cnt = 0;
|
|
private int comm_bautrate = 9600;
|
public int dt_target_addr = 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 String dev_jiaozhun_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;
|
//--------------------------------------------------------//
|
|
public boolean m_discurr_jz_a = false; //È¡·ÅµçµçÁ÷A²ÉÑùÖÐ
|
public boolean m_discurr_jz_b = false; //È¡·ÅµçµçÁ÷B²ÉÑùÖÐ
|
public boolean m_chrcurr_jz_a = false; //È¡³äµçµçÁ÷A²ÉÑùÖÐ
|
public boolean m_chrcurr_jz_b = false; //È¡³äµçµçÁ÷B²ÉÑùÖÐ
|
//--------------------------------------------------------//
|
@SuppressWarnings("unused")
|
private JTextField dt_show_msg = new JTextField();
|
private int dt_cmd = FBS9100_ComBase.CMD_GetVIData;
|
private int dt_usr_cmd = FBS9100_ComBase.CMD_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;
|
//--------------------------------------------------------//
|
private DummyLoad_Cmd m_Read_Cmd = new DummyLoad_Cmd();
|
//--------------------------------------------------------//
|
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 DummyLoad_Cmd m_DummyLoad_Cmd;
|
|
public DummyLoad_Data m_DummyLoad_Data = new DummyLoad_Data();
|
|
public DummyLoad_TemperData m_DummyLoad_TemperData = new DummyLoad_TemperData();
|
|
public DummyLoad_Data m_AppDummyLoad = new DummyLoad_Data(); //appÉèÖõIJÎÊý[ÉèÖÃʱʹÓÃ]
|
|
//--------------------------------------------------------//
|
|
|
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 CommDummyLoad(int addr_t, int bitrate, page_debug_inf debug, Logger log) {
|
dt_target_addr = addr_t & 0x00FF;
|
comm_bautrate = bitrate;
|
dt_debug_inf = debug;
|
m_Log = log;
|
|
}
|
|
public void setCommBautrate(int bt_rate) {
|
if(SPCommMon.COMM_PORT_TYPE_Serial != m_COMM_PORT_TYPE) {
|
return;
|
}
|
|
try {
|
comm_bautrate = bt_rate;
|
serialPort.setSerialPortParams(comm_bautrate, SerialPort.DATABITS_8, SerialPort.STOPBITS_1,SerialPort.PARITY_NONE);
|
} catch (UnsupportedCommOperationException e) {
|
e.printStackTrace();
|
}
|
}
|
|
//³õʼ»¯´®¿Ú
|
public boolean OpenCommPort(int comm_port_type, String comm_name_or_ip, int bitrate_or_comm_port) {
|
boolean res = false;
|
m_COMM_PORT_TYPE = comm_port_type;
|
if(SPCommMon.COMM_PORT_TYPE_Serial == m_COMM_PORT_TYPE) {
|
m_SP_Comm = new CommSerialPort(bitrate_or_comm_port, m_Log);
|
res = m_SP_Comm.OpenCommPort(comm_name_or_ip);
|
} else {
|
m_SocketComm = new Comm_Socket(comm_name_or_ip, bitrate_or_comm_port);
|
res = true;
|
}
|
|
if(true == res) {
|
CommTxBuffer.order(ByteOrder.BIG_ENDIAN);
|
CommRxBuffer.order(ByteOrder.BIG_ENDIAN);
|
|
comm_tx_cnt = 0;
|
comm_rx_cnt = 0;
|
CommThreadRunning = true;
|
}
|
|
return res;
|
}
|
|
private void makeCommTxData() {
|
dt_cmd = SwitchDevice_ComBase.CMD_GetVIData; //¶ÁȡʵʱÊý¾Ý
|
|
m_DummyLoad_Cmd = new DummyLoad_Cmd();
|
if(SwitchDevice_ComBase.CMD_NULL == dt_usr_cmd) {
|
if(++dt_cmd_cnt > 1000) {
|
dt_cmd_cnt = 0;
|
}
|
if(dt_cmd_cnt%2 == 0) {
|
m_DummyLoad_Cmd.makeCmd(dt_target_addr, DummyLoad_ComBase.CMD_GetLoaderState);
|
}else if(dt_cmd_cnt%2 == 1) {
|
m_DummyLoad_Cmd.makeCmd(dt_target_addr, DummyLoad_ComBase.CMD_GetTempData);
|
}
|
if(dt_cmd_cnt%10 == 0) {
|
m_DummyLoad_Cmd.makeCmd(dt_target_addr, DummyLoad_ComBase.CMD_GetLoaderVersion);
|
}
|
|
dt_datatofbs9100 = ByteBuffer.allocate(0);
|
} else {
|
dt_cmd = dt_usr_cmd;
|
dt_usr_cmd = SwitchDevice_ComBase.CMD_NULL;
|
|
/******************************* ¶àµãÉèÖà **************************************************/
|
if(DummyLoad_ComBase.CMD_LoaderStop == dt_cmd) {
|
//Í£Ö¹¼Ù¸ºÔع¤×÷
|
m_DummyLoad_Cmd.makeCmd(dt_target_addr, DummyLoad_ComBase.CMD_LoaderStop);
|
|
}else if(DummyLoad_ComBase.CMD_StartDischarge == dt_cmd) {
|
//Æô¶¯¼Ù¸ºÔطŵç²Ù×÷
|
m_DummyLoad_Cmd.makeCmd(dt_target_addr, DummyLoad_ComBase.CMD_StartDischarge);
|
|
}else if(DummyLoad_ComBase.CMD_StartCharge == dt_cmd) {
|
//Æô¶¯¼Ù¸ºÔسäµç²Ù×÷
|
m_DummyLoad_Cmd.makeCmd(dt_target_addr, DummyLoad_ComBase.CMD_StartCharge);
|
|
}else if(DummyLoad_ComBase.CMD_LoaderControl == dt_cmd) {
|
//ÉèÖüٸºÔص÷ÖÆ·ÅµçµçÁ÷
|
m_DummyLoad_Cmd.makeCmd(dt_target_addr, DummyLoad_ComBase.CMD_LoaderControl);
|
//dt_datatofbs9100 = m_DummyLoad_Cmd.makeByteBuffer(m_AppDummyLoad.SetCurrent*10);
|
}else if(DummyLoad_ComBase.CMD_DisRlayControl == dt_cmd) {
|
//¹Ø±Õ×ܵļ̵çÆ÷ºÍ·çÉȵŦÄÜ
|
m_DummyLoad_Cmd.makeCmd(dt_target_addr, DummyLoad_ComBase.CMD_DisRlayControl);
|
}
|
}
|
|
ByteBuffer buf_t = m_DummyLoad_Cmd.makeFbs9100CommBuf(dt_datatofbs9100);
|
//System.err.println("@@@"+ComFn.bytesToHexString(buf_t.array(), buf_t.array().length));
|
|
byte[] plain_tx_t = new byte[buf_t.limit()];
|
buf_t.get(plain_tx_t);
|
|
|
//System.err.println("@@@"+ComFn.bytesToHexString(plain_tx_t, plain_tx_t.length));
|
CommTxBuffer = ByteBuffer.allocate(plain_tx_t.length);
|
CommTxBuffer.put(plain_tx_t);
|
CommTxBuffer.flip();
|
}
|
|
|
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, ByteBuffer data_buf) {
|
dt_usr_cmd = cmd;
|
dt_datatofbs9100 = data_buf;
|
}
|
|
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 setDataType(int datatype) {
|
this.dev_data_type = datatype;
|
}
|
|
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) {
|
//sendMsg(makeCommTxData());
|
//readMsg(CommRxBuffer);
|
makeCommTxData();
|
|
tr_Msg(CommTxBuffer, CommRxBuffer, true);
|
|
//System.out.println("·¢ËÍÊý¾Ý£º" + ComFn.bytesToHexString(CommTxBuffer.array(), CommTxBuffer.array().length));
|
|
byte[] plain_buf = new byte[CommRxBuffer.limit()];
|
CommRxBuffer.get(plain_buf);
|
//System.out.println("½ÓÊÕÊý¾Ý£º" + ComFn.bytesToHexString(plain_buf, plain_buf.length));
|
getDataFromCommBuf(plain_buf);
|
|
Thread.sleep(500);
|
}
|
} catch (Exception e) {
|
m_Log.error(e.toString(), e);
|
exitCommPortThread();
|
JOptionPane.showMessageDialog(null, "BTS ÉÏλ»ú´®¿ÚÒì³£: " + e.getMessage());
|
}
|
}
|
/******************************************/
|
closeCommPort();
|
/******************************************/
|
m_Log.error("SwitchDevice CommPort is quit!");
|
}
|
/*********************************************************************************************/
|
/*********************************************************************************************/
|
/*********************************************************************************************/
|
/*********************************************************************************************/
|
public String getDataFromCommBuf(final byte[] bytes)
|
{
|
boolean comm_res = false;
|
ByteBuffer bf = ByteBuffer.allocate(bytes.length);
|
bf.order(ByteOrder.BIG_ENDIAN);
|
bf.put(bytes);
|
bf.flip();
|
//System.err.println(ComFn.bytesToHexString(bytes, bytes.length));
|
String msg = "";
|
if(true == m_Read_Cmd.putByteBuffer(bf))
|
{
|
//System.out.println(SwitchDevice_ComBase.CMD_GetVIData+"@@@@@@@@@@@@@@"+dt_cmd);
|
//------------------- ¶ÁÈ¡FBS9100µçѹµçÁ÷Êý¾Ý --------------------
|
if(DummyLoad_ComBase.CMD_GetLoaderState == dt_cmd)
|
{
|
if(true == m_DummyLoad_Data.putByteBuffer(bf))
|
{
|
System.out.println("¶ÁÈ¡¸ºÔØ×´Ì¬³É¹¦");
|
comm_res = true;
|
}
|
}
|
else if(DummyLoad_ComBase.CMD_GetLoaderVersion == dt_cmd)
|
{
|
if(bf.capacity() >= 2) {
|
dev_stat_version = ComBase.changeShortToInt(bf.getShort());
|
dev_stat_version_Str = "V" + dev_stat_version;
|
|
System.out.println("¶ÁÈ¡¸ºÔذ汾³É¹¦");
|
comm_res = true;
|
}
|
}else if(DummyLoad_ComBase.CMD_GetTempData == dt_cmd)
|
{
|
if(true == m_DummyLoad_TemperData.putByteBuffer(bf))
|
{
|
System.out.println("¶ÁÈ¡¸ºÔØÎ¶ÈÐÅÏ¢³É¹¦");
|
comm_res = true;
|
}
|
}else if(DummyLoad_ComBase.CMD_LoaderStop == dt_cmd) {
|
if(DummyLoad_ComBase.CMD_Success == m_Read_Cmd.ResState) {
|
|
dt_cmd_ack = DummyLoad_ComBase.CMD_LoaderStop_Ack;
|
dev_control_Str = "Í£Ö¹¼Ù¸ºÔع¤×÷³É¹¦!"+Com.get_DTF(new Date(), Com.DTF_YMDhms);
|
comm_res = true;
|
}
|
}else if(DummyLoad_ComBase.CMD_StartDischarge == dt_cmd) {
|
if(DummyLoad_ComBase.CMD_Success == m_Read_Cmd.ResState)
|
{
|
dt_cmd_ack = DummyLoad_ComBase.CMD_StartDischarge_Ack;
|
dev_control_Str = "Æô¶¯¼Ù¸ºÔطŵç³É¹¦!"+Com.get_DTF(new Date(), Com.DTF_YMDhms);
|
comm_res = true;
|
}
|
}else if(DummyLoad_ComBase.CMD_StartCharge == dt_cmd) {
|
if(DummyLoad_ComBase.CMD_Success == m_Read_Cmd.ResState) {
|
dt_cmd_ack = DummyLoad_ComBase.CMD_StartCharge_Ack;
|
dev_control_Str = "Æô¶¯¼Ù¸ºÔسäµç³É¹¦!"+Com.get_DTF(new Date(), Com.DTF_YMDhms);
|
comm_res = true;
|
}
|
}else if(DummyLoad_ComBase.CMD_LoaderControl == dt_cmd) {
|
if(DummyLoad_ComBase.CMD_Success == m_Read_Cmd.ResState) {
|
dt_cmd_ack = DummyLoad_ComBase.CMD_LoaderControl_Ack;
|
dev_control_Str = "ÉèÖüٸºÔزâÊÔµçÁ÷³É¹¦!"+Com.get_DTF(new Date(), Com.DTF_YMDhms);
|
comm_res = true;
|
}
|
}else if(DummyLoad_ComBase.CMD_DisRlayControl == dt_cmd) {
|
if(DummyLoad_ComBase.CMD_Success == m_Read_Cmd.ResState) {
|
dt_cmd_ack = DummyLoad_ComBase.CMD_DisRlayControl_Ack;
|
dev_control_Str = "¹Ø±Õ×ܵļ̵çÆ÷ºÍ·çÉȳɹ¦!"+Com.get_DTF(new Date(), Com.DTF_YMDhms);
|
comm_res = true;
|
}
|
}
|
}
|
|
if(true == comm_res) {
|
if(++comm_rx_cnt > 1000000) {
|
comm_rx_cnt = 0;
|
}
|
}
|
return msg;
|
}
|
/*********************************************************************************************/
|
|
public void makeRandomData(int dt_cmd) {
|
|
float targetCurr = 0;
|
int testGroupNum = m_FBS_VCData.m_SysState.TestGroupNum; //²âÊÔ×éºÅ
|
int workState = m_FBS_VCData.m_SysState.WorkState; //É豸¹¤×÷״̬
|
float groupVolLimit = 0; //×é¶Ëµçѹ
|
int eveBattGroupNum = 0; //ÿ×éµ¥Ìå¸öÊý
|
eveBattGroupNum = m_FBS_VCData.battSum/m_FBS_VCData.battGroup;
|
boolean isTest = false;
|
|
if(m_FBS_VCData.m_SysState.WorkState == FBS9100_SysState.SYS_STATE_DISCHARGING) {
|
//·Åµç²âÊÔ
|
targetCurr = m_FBS_DiscParamFromDev.DisCurr;
|
groupVolLimit = 35f;
|
isTest = true;
|
alearyMaxCurr = false;
|
}else if(m_FBS_VCData.m_SysState.WorkState == FBS9100_SysState.SYS_STATE_CHARGING){
|
//³äµç²âÊÔ
|
targetCurr = m_FBS_DiscParamFromDev.ChargeCurrSet;
|
groupVolLimit = 53.5f;
|
isTest = true;
|
|
if(Math.abs(m_FBS_VCData.battcurr[testGroupNum-1] - targetCurr) <= 0.5) {
|
alearyMaxCurr = true;
|
targetCurr = 1;
|
}
|
}else if(m_FBS_VCData.m_SysState.WorkState == FBS9100_SysState.SYS_STATE_STOPPED){
|
//¸¡³äʱ
|
alearyMaxCurr = false;
|
}
|
|
System.err.println("Start:"+alearyMaxCurr);
|
|
// System.err.println("ϵͳ¹¤×÷״̬£º"+m_FBS_VCData.m_SysState.WorkState + "\t±»²â×éºÅ£º" + m_FBS_VCData.m_SysState.TestGroupNum+
|
// "\n ·ÅµçµçÁ÷£º"+m_FBS_DiscParamFromDev.DisCurr + "\tÏÞÖÆµçÁ÷£º"+targetCurr) ;
|
for(int i = 0 ; i< m_FBS_VCData.onlinevol.length;i++) {
|
if((i+1) == testGroupNum && (workState == FBS9100_SysState.SYS_STATE_CHARGING || workState == FBS9100_SysState.SYS_STATE_DISCHARGING)) {
|
//²âÊÔʱ
|
|
m_FBS_VCData.onlinevol[i] = (double)FBS9100_ComBase.CreateIntRanDom(5350,5360)/100;
|
m_FBS_VCData.batttemp[i] = (double)FBS9100_ComBase.CreateIntRanDom(200,400)/10;
|
|
//m_FBS_VCData.groupvol[i] = (double)FBS9100_ComBase.CreateIntRanDom(5310,5690)/100;
|
//m_FBS_VCData.battcurr[i] = (double)FBS9100_ComBase.CreateIntRanDom(0,30)/10;
|
if(workState == FBS9100_SysState.SYS_STATE_CHARGING && alearyMaxCurr) {
|
|
//³äµçʱ£¬ÈôÔÚÏßµçѹºÍ×é¶Ëµçѹѹ²îСÓÚµÈÓÚ4V,Ä£ÄâµçÁ÷ϽµÖÁ1A×óÓÒ
|
float testCurr = 0;
|
double test_curr = m_FBS_VCData.battcurr[testGroupNum-1];
|
if(test_curr > (testCurr+1)) {
|
m_FBS_VCData.battcurr[testGroupNum-1] = m_FBS_VCData.battcurr[testGroupNum-1] - (double)FBS9100_ComBase.CreateIntRanDom(0,5)/10;
|
}else {
|
m_FBS_VCData.battcurr[testGroupNum-1] = testCurr + (double)FBS9100_ComBase.CreateIntRanDom(0,10)/10;
|
}
|
|
|
}else {
|
m_FBS_VCData.setRandomTestCurr(testGroupNum, targetCurr);
|
}
|
|
}else {
|
|
|
m_FBS_VCData.onlinevol[i] = (double)FBS9100_ComBase.CreateIntRanDom(5350,5360)/100;
|
//m_FBS_VCData.groupvol[i] = (double)FBS9100_ComBase.CreateIntRanDom(5310,5690)/100;
|
m_FBS_VCData.battcurr[i] = (double)FBS9100_ComBase.CreateIntRanDom(0,30)/10;
|
m_FBS_VCData.batttemp[i] = (double)FBS9100_ComBase.CreateIntRanDom(200,400)/10;
|
|
}
|
}
|
if(FBS9100_ComBase.CMD_SetVIData == dt_cmd) {
|
for(int i = 0 ;i<m_FBS_VCData.vol.length;i++) {
|
if(isTest && (i >= (testGroupNum-1)*eveBattGroupNum) && (i<(testGroupNum)*eveBattGroupNum)) {
|
if(m_FBS_VCData.m_SysState.WorkState == FBS9100_SysState.SYS_STATE_DISCHARGING) {
|
//·Åµçʱµ¥Ìåµçѹ
|
m_FBS_VCData.vol[i] = RandomDisMonVol(m_FBS_VCData.vol[i]);
|
//System.out.println("·Åµç²âÊÔÖÐ#"+(i+1)+":"+m_FBS_VCData.vol[i]);
|
}else{
|
//³äµçʱµ¥Ìåµçѹ
|
m_FBS_VCData.vol[i] = RandomChrMonVol(m_FBS_VCData.vol[i]);
|
//System.out.println("³äµç²âÊÔÖÐ#"+(i+1)+":"+m_FBS_VCData.vol[i]);
|
}
|
}else {
|
m_FBS_VCData.vol[i] = (double)FBS9100_ComBase.CreateIntRanDom(2229,2231)/1000;
|
}
|
|
}
|
|
for(int n = 0;n<m_FBS_VCData.groupvol.length;n++) {
|
double sumVol = 0;
|
for(int k = (n*eveBattGroupNum);k<((n+1)*eveBattGroupNum);k++) {
|
sumVol += m_FBS_VCData.vol[k];
|
}
|
m_FBS_VCData.groupvol[n] = sumVol;
|
}
|
}
|
if(FBS9100_ComBase.CMD_SetMonomerRes == dt_cmd) {
|
for(int i = 0 ;i<m_FBS_ResCapData.m_res.length;i++) {
|
m_FBS_ResCapData.m_res[i] = (double)FBS9100_ComBase.CreateIntRanDom(99,1000)/1000;
|
}
|
}
|
if(FBS9100_ComBase.CMD_SetMonomerTMP == dt_cmd) {
|
for(int i = 0 ;i<m_FBS_ResCapData.m_tmp.length;i++) {
|
m_FBS_ResCapData.m_tmp[i] = (double)FBS9100_ComBase.CreateIntRanDom(200,400)/10;
|
}
|
}
|
|
|
|
System.err.println("End:"+alearyMaxCurr);
|
//System.out.println("m_res[i]:" + Arrays.toString(m_FBS_ResCapData.m_res));
|
//System.out.println("m_tmp[i]:" + Arrays.toString(m_FBS_ResCapData.m_tmp));
|
}
|
|
//Ä£Äâ·Åµçʱµ¥Ìåµçѹ
|
public static double RandomDisMonVol(double monvol) {
|
if(monvol <= 1.7) {
|
return (double)FBS9100_ComBase.CreateIntRanDom(1690,1710)/1000;
|
}else {
|
return monvol - (double)FBS9100_ComBase.CreateIntRanDom(0,2)/10000;
|
}
|
}
|
|
//Ä£Äâ³äµçʱµ¥Ìåµçѹ
|
public static double RandomChrMonVol(double monvol) {
|
if(monvol >= 2.230) {
|
return (double)FBS9100_ComBase.CreateIntRanDom(2229,2231)/1000;
|
}else {
|
return monvol + (double)FBS9100_ComBase.CreateIntRanDom(0,10)/10000;
|
}
|
}
|
|
public static void main(String[] args) {
|
for(int i =0 ;i<100;i++) {
|
System.out.println(RandomDisMonVol(2.16));
|
|
}
|
}
|
}
|