TDK Driver Manual This is a description for TDK communication adapter software package. In order to operate TDK device properly, three kinds of operations should be implemented by TDK adapter: (1) ON/OFF operation of power conversion by Manual control(charge/discharge) or Automatic control. (2) Charge value for operation setting (target voltage for charge/discharge, limited current for charge/discharge, etc.) (3) Get device information (Device status, Alarm information, etc.) Data definitions, packet format and encoding mode in the software follow the document TDK-Lambda EZA2500 Series Communication Manual. The both-way communication between TDK device and host are based on a thirdpart package RXTXComm which version is mfz-rxtx-2.2-20081207-win-x64. Contents 1 TDK driver code structure 2 Data Definition 3 Data Organization 4 Top level APIs 5 RS485 communication between TDK and host 1 TDK driver code structure 1.1 TDK.java The top-level APIs which can be called by WEB application are defined in this file. Each TDK command defined in the TDK communication manual page17-page40 has a corresponding API. Both ACKs and NAKs returned by TDK device are parsed in the method ParseTDKResponse(). 1.2 TDKTester.java This is a test class used to verify if the commands and responses are encapsulated and parsed properly. The usages of the APIs can refer to this file. 1.3 TDKTypes.java, TDKParameterMap.java, TDKErrorMap.java All data types and data structures are defined in the three files. Including TDK command, operation mode, running state, alarm and setting parameters, etc. 1.4 TDKPacket.java, TDKPacketCommand.java, TDKPacketResponse.java Packets are defined in these three class. TDKPacket is parent class, TDKPacketCommand is command packet which will be sent to TDK device, TDKPacketResponse is the response packet which is received from TDK device. 1.5 TDKTool.java A couple of utility methods which will be used in the TDK package are implemented in this file. Including packet encode method, data format transition, etc. 1.6 TDKRS485Tool.java, RS485Listener.java The RS485 serial communication which based RXTXComm is implemented in these two files. In TDKRS485Tool, APIs are implemented to operate serial port and receive/send data by serial port. A listener are implemented in RS485Listener.java. A thread is started to listen the ACK/NAK from TDK device. 1.7 PackCommandException.java, TDKResponseChecksumException.java, TDKResponseCMDException.java, TDKResponseLengthException.java Several exceptions are defined in these class files. 2 Data Definition There are many data such as command, alarm and operation mode are defined in TDK Communication Manual, all these data types are defined in file TDKTypes.java. 2.1 TDK Constants definition public static final int GRID_POWER = 2500; public static final int BATTERY_POWER = 2500; public static final int DC_VOLT_48V = 48; public static final int DC_VOLT_380V = 380; public static final float DC_CURRENT_LIMIT_BATTERY = 52.08f; public static final float DC_CURRENT_LIMIT_GRID = 7.8125f; public static final float NORMINAL_OF_PERCENTAGE = 1.0f; public static final int NORMINAL_OF_ONE = 1; public static final int Q_FORMAT_14 = 14; public static final int Q_FORMAT_13 = 13; public static final int Q_FORMAT_11 = 11; public static final int Q_FORMAT_10 = 10; public static final int Q_FORMAT_7 = 7; public static final int Q_FORMAT_INVALID = 0; public static final int TMP_INVALID = 0; 2.2 TDK commands are defined in TDKCommand which is an ENUM with fields command description(commandDesc), data length(LEN) and command code(CMD). Please reference to TDK Command table in Communication Manual Page10. public enum TDKCommand { //TDKCommandEnum("Command Description", LEN, CMD) //No1. Operation Mode TDK_OPERATION_MODE_INQUIRE("Inquire Operation Mode",0x00,0x00), TDK_OPERATION_MODE_SET("Set Operation Mode",0x02,0x00), TDK_OPERATION_MODE_ACK("Operation Mode ACK",0x02,0x00), TDK_OPERATION_MODE_NAK("Operation Mode NAK",0x02,0x80), //No2. Converter Status TDK_CONVERTER_STATUS_INQUIRE("Inquire Converter Status",0x00,0x01), TDK_CONVERTER_STATUS_ACK("Converter Status ACK",0x04,0x01), TDK_CONVERTER_STATUS_NAK("Converter Status NAK",0x02,0x81), //No3. CV Charging Parameter TDK_CV_CHARGING_PARA_READ("Read CV Charging Parameter",0x00,0x18), TDK_CV_CHARGING_PARA_WRITE("Write CV Charging Parameter",0x04,0x18), TDK_CV_CHARGING_PARA_ACK("CV Charging Parameter ACK",0x04,0x18), TDK_CV_CHARGING_PARA_NAK("CV Charging Parameter NAK",0x02,0x98), //No4. CV Discharging Parameter TDK_CV_DISCHARGING_PARA_READ("Read CV Discharging Parameter",0x00,0x1A), TDK_CV_DISCHARGING_PARA_WRITE("Write CV Discharging Parameter",0x04,0x1A), TDK_CV_DISCHARGING_PARA_ACK("CV Discharging Parameter ACK",0x04,0x1A), TDK_CV_DISCHARGING_PARA_NAK("CV Discharging Parameter NAK",0x02,0x9A), //No5. Dead Zone Parameter TDK_DEADZONE_PARA_READ("Read Dead Zone Parameter",0x00,0x17), TDK_DEADZONE_PARA_WRITE("Write Dead Zone Parameter",0x04,0x17), TDK_DEADZONE_PARA_ACK("Dead Zone Parameter ACK",0x04,0x17), TDK_DEADZONE_PARA_NAK("Dead Zone Parameter NAK",0x02,0x97), //No6. Converter Protection Parameter TDK_CONVERTER_PROTECTION_PARA_READ("Read Converter Protection Parameter",0x00,0x1C), TDK_CONVERTER_PROTECTION_PARA_WRITE("Write Converter Protection Parameter",0x0C,0x1C), TDK_CONVERTER_PROTECTION_PARA_ACK("Converter Protection Parameter ACK",0x0C,0x1C), TDK_CONVERTER_PROTECTION_PARA_NAK("Converter Protection Parameter NAK",0x02,0x9C), //No7. Battery Configuration Parameter1 TDK_BATTERY_CONFIG_PARA1_READ("Read Battery Configuration Parameter1",0x00,0x1D), TDK_BATTERY_CONFIG_PARA1_WRITE("Write Battery Configuration Parameter1",0x0A,0x1D), TDK_BATTERY_CONFIG_PARA1_ACK("Battery Configuration Parameter1 ACK",0x0A,0x1D), TDK_BATTERY_CONFIG_PARA1_NAK("Battery Configuration Parameter1 NAK",0x02,0x9D), //No8. Battery Configuration Parameter2 TDK_BATTERY_CONFIG_PARA2_READ("Read Battery Configuration Parameter2",0x00,0x16), TDK_BATTERY_CONFIG_PARA2_WRITE("Write Battery Configuration Parameter2",0x04,0x16), TDK_BATTERY_CONFIG_PARA2_ACK("Battery Configuration Parameter2 ACK",0x04,0x16), TDK_BATTERY_CONFIG_PARA2_NAK("Battery Configuration Parameter2 NAK",0x02,0x96), //No9. Alarm TDK_ALARM_INQUIRE("Inquire Alarm",0x00,0x12), TDK_ALARM_CLEAR("Clear Alarm",0x02,0x12), TDK_ALARM_ACK("Alarm ACK",0x06,0x12), TDK_ALARM_NAK("Alarm NAK",0x02,0x92), //No10. Converter Meter1 TDK_CONVERTER_METER1_READ("Read Converter Meter1",0x00,0x09), TDK_CONVERTER_METER1_ACK("Converter Meter1 ACK",0x10,0x09), TDK_CONVERTER_METER1_NAK("Converter Meter1 NAK",0x02,0x89), //No11. Converter Meter2 TDK_CONVERTER_METER2_READ("Read Converter Meter2",0x00,0x0A), TDK_CONVERTER_METER2_ACK("Converter Meter2 ACK",0x10,0x0A), TDK_CONVERTER_METER2_NAK("Converter Meter2 NAK",0x02,0x8A), //No12. Converter Meter1 Format TDK_CONVERTER_METER1_FORMAT_READ("Read Converter Meter1 Format",0x00,0x0D), TDK_CONVERTER_METER1_FORMAT_ACK("Converter Meter1 Format ACK",0x10,0x0D), TDK_CONVERTER_METER1_FORMAT_NAK("Converter Meter1 Format NAK",0x02,0x8D), //No13. Converter Meter2 Format TDK_CONVERTER_METER2_FORMAT_READ("Read Converter Meter2 Format",0x00,0x0E), TDK_CONVERTER_METER2_FORMAT_ACK("Converter Meter2 Format ACK",0x10,0x0E), TDK_CONVERTER_METER2_FORMAT_NAK("Converter Meter2 Format NAK",0x02,0x8E), //No14. Nominal Value TDK_NOMINAL_VALUE_READ("Read Nominal Value",0x00,0x11), TDK_NOMINAL_VALUE_ACK("Nominal Value ACK",0x14,0x11), TDK_NOMINAL_VALUE_NAK("Nominal Value NAK",0x02,0x91), //No15. Interface Firmware Version TDK_INTERFACE_FIRMWARE_VERSION_READ("Read Interface Firmware Version",0x00,0x1E), TDK_INTERFACE_FIRMWARE_VERSION_ACK("Interface Firmware Version ACK",0x02,0x1E), TDK_INTERFACE_FIRMWARE_VERSION_NAK("Interface Firmware Version NAK",0x02,0x9E), //No16. Control Firmware Version TDK_CONTROL_FIRMWARE_VERSION_READ("Read Control Firmware Version",0x00,0x1F), TDK_CONTROL_FIRMWARE_VERSION_ACK("Control Firmware Version ACK",0x02,0x1F), TDK_CONTROL_FIRMWARE_VERSION_NAK("Control Firmware Version NAK",0x02,0x9F); private String commandDesc; private int fieldLEN; private int fieldCMD; private TDKCommand(String commandDesc, int fieldLEN, int fieldCMD){ this.commandDesc = commandDesc; this.fieldLEN = fieldLEN; this.fieldCMD = fieldCMD; } } 2.3 TDK operation modes are defined in TDKOperationMode which is an ENUM with fields mode description(modeDesc) and mode value (modeValue). Please reference to the definition in Communication Manual Page17. public enum TDKOperationMode { //TDKOperationMode("Operation mode name", modeValue) TDK_OPERATION_MODE_WAITING("Waiting", 0x0000), TDK_OPERATION_MODE_MBCV("Manual Battery CV", 0x0001), TDK_OPERATION_MODE_MGCV_BCC("Manual Grid CV with Battery CC", 0x0022), TDK_OPERATION_MODE_MGCV("Manual Grid CV", 0x0002), TDK_OPERATION_MODE_ABCV("Automatic Battery CV", 0x0004), TDK_OPERATION_MODE_AGCV_BCC("Automatic Grid CV with Battery CC", 0x0034), TDK_OPERATION_MODE_AGCV("Automatic Grid CV", 0x0014); private String modeDesc; private int modeValue; private TDKOperationMode(String modeDesc, int modeValue){ this.modeDesc = modeDesc; this.modeValue = modeValue; } } 2.4 TDK running states are defined in TDKRunningState which is an ENUM with fields running state (runningState) and running state value (runningStateValue). Please reference to the definition in Communication Manual Page19. public enum TDKRunningState { TDK_RUNNING_STATE_OFF("Off", 0), TDK_RUNNING_STATE_CHARGE("Charge", 1), TDK_RUNNING_STATE_DISCHARGE("Discharge", 2); private String runningState; private int runningStateValue; private TDKRunningState(String runningState, int runningStateValue){ this.runningState = runningState; this.runningStateValue = runningStateValue; } } 2.5 TDK alarm states are defined in TDKAlarmState which is an ENUM with fields alarm state (alarmState) and alarm state value (alarmStateValue). Please reference to the definition in Communication Manual Page19. public enum TDKAlarmState { TDK_ALARM_STATE_NO_ALARM("No Alarm", 0), TDK_ALARM_STATE_LIGHT_ALARM("Light Alarm", 1), TDK_ALARM_STATE_HEAVY_ALARM("Heavy Alarm", 2); private String alarmState; private int alarmStateValue; private TDKAlarmState(String alarmState, int alarmStateValue){ this.alarmState = alarmState; this.alarmStateValue = alarmStateValue; } } 2.6 TDK statuses of operation mode are defined in TDKStatusOperationMode which is an ENUM with fields status of operation mode(statusOperationMode) and mode value (modeValue). Please reference to the definition in Communication Manual Page19. public enum TDKStatusOperationMode { TDK_STATUS_OPERATION_WAITING("Waiting", 0), TDK_STATUS_OPERATION_MANUAL_CV("Manual CV", 1), TDK_STATUS_OPERATION_AUTO_GRID_CV("Automatic Grid CV", 3), TDK_STATUS_OPERATION_AUTO_BATTERY_CV("Automatic Battery CV", 4); private String statusOperationMode; private int modeValue; private TDKStatusOperationMode(String statusOperationMode, int modeValue){ this.statusOperationMode = statusOperationMode; this.modeValue = modeValue; } } 2.7 TDK upper voltage notice of battery charge are defined in TDKUpperVoltNoticeOfBatteryCharge which is an ENUM with fields notice description (noticeDesc) and notice value (noticeValue). Please reference to the definition in Communication Manual Page19. public enum TDKUpperVoltNoticeOfBatteryCharge { TDK_OVER_UPPER_VOLT_BATTERY_CHARGE("upper than advance notice voltage", 1), TDK_BELOW_UPPER_VOLT_BATTERY_CHARGE("lower than advance notice voltage", 0); private String noticeDesc; private int noticeValue; private TDKUpperVoltNoticeOfBatteryCharge(String noticeDesc, int noticeValue){ this.noticeDesc = noticeDesc; this.noticeValue = noticeValue; } } 2.8 TDK lower voltage notice of battery charge are defined in TDKLowerVoltNoticeOfBatteryCharge which is an ENUM with fields notice description (noticeDesc) and notice value (noticeValue). Please reference to the definition in Communication Manual Page19. public enum TDKLowerVoltNoticeOfBatteryCharge { TDK_BELOW_LOWER_VOLT_BATTERY_CHARGE("lower than advance notice voltage", 1), TDK_OVER_LOWER_VOLT_BATTERY_CHARGE("upper than advance notice voltage", 0); private String noticeDesc; private int noticeValue; TDKLowerVoltNoticeOfBatteryCharge(String noticeDesc, int noticeValue){ this.noticeDesc = noticeDesc; this.noticeValue = noticeValue; } } 2.9 TDK setting parameters are defined in TDKSettingPara which is an ENUM with fields Q format (qFormat), nominal value(intNominal or floatNominal) and parameter description(paraDesc). Please reference to the definition in Communication Manual Page15-16. public enum TDKSettingPara { //PARAMETERNAME(int qFormat, int NorminalValue, String ParameterDescription) //PARAMETERNAME(int qFormat, float NorminalValue, String ParameterDescription) TDK_PARA_CVB(Q_FORMAT_14, DC_VOLT_48V, "Target Battery Volts"), TDK_PARA_DRB(Q_FORMAT_13, NORMINAL_OF_PERCENTAGE, "Droop Ratio of Battery"), TDK_PARA_DVG(Q_FORMAT_14, DC_VOLT_380V, "Target Grid Volts"), TDK_PARA_DRG(Q_FORMAT_13, NORMINAL_OF_PERCENTAGE, "Droop Ratio of Grid"), TDK_PARA_CIB(Q_FORMAT_13, DC_CURRENT_LIMIT_BATTERY, "Current Limit of Battery"), TDK_PARA_DIG(Q_FORMAT_13, DC_CURRENT_LIMIT_GRID,"Current Limit of Grid"), TDK_PARA_OBV(Q_FORMAT_14, DC_VOLT_48V, "Over Battery Volts"), TDK_PARA_UBV(Q_FORMAT_14, DC_VOLT_48V, "Under Battery Volts"), TDK_PARA_OGV(Q_FORMAT_14, DC_VOLT_380V, "Over Grid Volts"), TDK_PARA_UGV(Q_FORMAT_14, DC_VOLT_380V, "Under Grid Volts"), TDK_PARA_BCF(Q_FORMAT_INVALID, NORMINAL_OF_ONE, "Battery Configure Function with Bitmap "), TDK_PARA_CDB(Q_FORMAT_14, DC_VOLT_48V, "Deviation of Volts for Warning of Charging Upper Limit"), TDK_PARA_CCR(Q_FORMAT_14, DC_VOLT_48V, "Deviation of Volts for Cancel Warning of Charging Upp"), TDK_PARA_DLB(Q_FORMAT_14, DC_VOLT_48V, "Limit of Battery Volts for Discharging"), TDK_PARA_DDB(Q_FORMAT_14, DC_VOLT_48V, "Deviation of Volts for Warning of Discharging Lower "), TDK_PARA_DDR(Q_FORMAT_14, DC_VOLT_48V, "Deviation of Volts for Cancel Warning of Discharging "), TDK_PARA_PDZ(Q_FORMAT_14, DC_VOLT_380V, "Plus side volts for Dead Zone"), TDK_PARA_MDZ(Q_FORMAT_14, DC_VOLT_380V, "Minus side volts for Dead Zone"), //The following setting para only used in: No 10-1 Function Name Read Converter Meter 1 Command TDK_PARA_VG(Q_FORMAT_14, DC_VOLT_380V, "Grid Voltage"), TDK_PARA_IG(Q_FORMAT_13, DC_CURRENT_LIMIT_GRID, "Grid Current"), TDK_PARA_VB(Q_FORMAT_14, DC_VOLT_48V, "Battery Voltage"), TDK_PARA_IB(Q_FORMAT_13, DC_CURRENT_LIMIT_BATTERY, "Battery Current"), TDK_PARA_WG(Q_FORMAT_11, GRID_POWER, "Grid Power"), TDK_PARA_WB(Q_FORMAT_11, BATTERY_POWER, "Battery Power"), TDK_PARA_IC(Q_FORMAT_INVALID, NORMINAL_OF_ONE, "None"), TDK_PARA_TMP(Q_FORMAT_7, NORMINAL_OF_ONE, "Converter Temperature"), //The following setting para only used in: No 11-1 Function Name Read Converter Meter 2 Command TDK_PARA_TS(Q_FORMAT_INVALID, NORMINAL_OF_ONE, "Reserved"), TDK_PARA_TP(Q_FORMAT_INVALID, NORMINAL_OF_ONE, "Reserved"), TDK_PARA_V5S(Q_FORMAT_10, NORMINAL_OF_ONE, "5VS voltage"), TDK_PARA_FAN1(Q_FORMAT_INVALID, NORMINAL_OF_ONE, "FAN1 revolution speed"), TDK_PARA_FAN2(Q_FORMAT_INVALID, NORMINAL_OF_ONE, "FAN2 revolution speed"), TDK_PARA_FAN3(Q_FORMAT_INVALID, NORMINAL_OF_ONE, "FAN3 revolution speed"), TDK_PARA_FAN4(Q_FORMAT_INVALID, NORMINAL_OF_ONE, "FAN4 revolution speed"), TDK_PARA_FAN5(Q_FORMAT_INVALID, NORMINAL_OF_ONE, "FAN5 revolution speed"); private int qFormat; private int intNominal; private float floatNominal; private String paraDesc; private TDKSettingPara(int qFormat, int intNominal, String paraDesc){ this.qFormat = qFormat; this.intNominal = intNominal; this.paraDesc = paraDesc; } private TDKSettingPara(int qFormat, float floatNominal, String paraDesc){ this.qFormat = qFormat; this.floatNominal = floatNominal; this.paraDesc = paraDesc; } } 2.10 TDK bitmap of BCF are defined in TDKBitmapOfBCF which is an ENUM with fields bit function name(bitFunctionName) and bitmap value(bitmapValue). Please reference to the definition in Communication Manual Page41-42. public enum TDKBitmapOfBCF { //TDKBitmapOfBCF("Bit function name ", bitmapValue) TDK_BCF_BIT0("Battery Over Charging Protection", 0x0100), TDK_BCF_BIT1("Battery Over Discharging Protection", 0x0200), TDK_BCF_BIT2("Battery Bus Ramping Up", 0x0400); private String bitFunctionName; private int bitmapValue; private TDKBitmapOfBCF(String bitFunctionName, int bitmapValue){ this.bitFunctionName = bitFunctionName; this.bitmapValue = bitmapValue; } } 2.11 TDK bitmap of alarm are defined in TDKBitmapOfAlarm which is a ENUM with fields alarm meaning (alarmMeaning) and bit position(bitPosition). Please reference to the definition in Communication Manual Page32. A three-dimensional array is defined to implement the alarm bitmap. public enum TDKBitmapOfAlarm { //TDKBitmapOfAlarm("Alarm meaning ", bitPosition) TDK_ALARM_BIT0("Battery Over Voltage", 0x0001), TDK_ALARM_BIT1("Battery under Voltage", 0x0002), TDK_ALARM_BIT2("Battery Over Current", 0x0004), TDK_ALARM_BIT3("Grid Over Voltage", 0x0008), TDK_ALARM_BIT4("Grid under Voltage", 0x0010), TDK_ALARM_BIT5("Grid Over Current", 0x0020), TDK_ALARM_BIT6("HW Over Current", 0x0040), TDK_ALARM_BIT7("Waiting (External Signal)", 0x0080), TDK_ALARM_BIT8("FAN Lock", 0x0100), TDK_ALARM_BIT9("Abnormal Temp of Heat Sink(pri)", 0x0200), TDK_ALARM_BIT10("Abnormal Temp of Heat Sink(sec)", 0x0400), TDK_ALARM_BIT11("Abnormal Temp of Device", 0x0800), TDK_ALARM_BIT13("Battery Empty", 0x2000), TDK_ALARM_BIT15("System Abnormal", 0x8000); private String alarmMeaning; private int bitPosition; private TDKBitmapOfAlarm(String alarmMeaning, int bitPosition){ this.alarmMeaning = alarmMeaning; this.bitPosition = bitPosition; } } 2.12 TDK nominal value are defined in TDKNominalValue which is a ENUM with fields nominal value (nominalValue), return value(returnValue) and nominal description(nominalDesc). Please reference to the definition in Communication Manual Page38. public enum TDKNominalValue { //NOMINALNAME(int nominalValue, int returnValue, String nominalName) TDK_NOMINAL_VGN(380, 0x5F00, "Nominal Voltage of Grid"), TDK_NOMINAL_VGNQ(6, 0x0006, "Q Value for Nominal Value of Grid Voltage"), TDK_NOMINAL_IGN(7.8125, 0x1F40, "Nominal Current of Grid"), TDK_NOMINAL_IGNQ(10, 0x000A, "Q Value for Nominal Value of Grid Current"), TDK_NOMINAL_VBN(48, 0x3000, "Nominal Voltage of Battery"), TDK_NOMINAL_VBNQ(8, 0x0008, "Q Value for NominalValue of Battery Voltage"), TDK_NOMINAL_IBN(52.083, 0x3415, "NominalCurrent of Battery"), TDK_NOMINAL_IBNQ(8, 0x0008, "QValue for Nominal Value of Battery Current"), TDK_NOMINAL_WN(2500, 0x09C4, "Nominal Power"), TDK_NOMINAL_WNQ(0, 0x0000, "Q Value for NominalValue of Power"); private double nominalValue; private int returnValue; private String nominalDesc; private TDKNominalValue(double nominalValue, int returnValue, String nominalDesc){ this.nominalValue = nominalValue; this.returnValue = returnValue; this.nominalDesc = nominalDesc; } } 2.13 TDK communication error codes are defined in TDKError which is a ENUM with fields return value (returnValue), error description(errorDesc) and the handling method(handingMethod). Please reference to the definition in Communication Manual Page12. protected enum TDKError { //TDKError(int returnValue, "Description", "Trouble handing method") TDK_ERROR_1(-1, "Received command is not supported", "Please confirm the command."), TDK_ERROR_2(-2, "Parameter is wrong(not fit number or out of range)", "Please confirm the command parameter."), TDK_ERROR_3(-3, "Cannot receive accurate command", "Please increase the length of communication intervals."), TDK_ERROR_4(-4, "Cannot send response because system is busy", "Please increase the length of communication intervals."), TDK_ERROR_5(-5, "Abnormal communication with internal device", "Repair is necessary."); private int returnValue; private String errorDesc; private String handingMethod; private TDKError(int returnValue, String errorDesc, String handingMethod){ this.returnValue = returnValue; this.errorDesc = errorDesc; this.handingMethod = handingMethod; } } 3 Data Organization In order to realize fast query and efficient organization of data, TDK data are organized as a couple of MAPs in different files. The following are the definition of these MAPs. 3.1 In TDKParameterMap.java, TDK parameters are stored in the MAP named TDKParameterMap, which is initialized when the class is loaded by class loader. The TDKParameterMap provides a method getParaInfo used to quick get parameter information by parameter name. Please reference to the definition in Communication Manual Page 15-16. public class TDKParameterMap { private static Map<String,TDKSettingPara> settingParaMap = null; static { //Initialize the class with the following data when it is loaded by classloader. if (settingParaMap == null) { settingParaMap = new HashMap<String, TDKSettingPara>(); //settingParaMap.put("Parameter Name",TDKSettingPara); //The Parameters are shared by Automatic Battery CV Mode, Automatic Grid CV Mode and Manual CV Mode settingParaMap.put("CVB",TDKSettingPara.TDK_PARA_CVB); settingParaMap.put("DRB",TDKSettingPara.TDK_PARA_DRB); settingParaMap.put("CIB",TDKSettingPara.TDK_PARA_CIB); settingParaMap.put("OBV",TDKSettingPara.TDK_PARA_OBV); settingParaMap.put("UBV",TDKSettingPara.TDK_PARA_UBV); settingParaMap.put("OGV",TDKSettingPara.TDK_PARA_OGV); settingParaMap.put("UGV",TDKSettingPara.TDK_PARA_UGV); settingParaMap.put("BCF",TDKSettingPara.TDK_PARA_BCF); settingParaMap.put("DVG",TDKSettingPara.TDK_PARA_DVG); settingParaMap.put("DRG",TDKSettingPara.TDK_PARA_DRG); settingParaMap.put("PDZ",TDKSettingPara.TDK_PARA_PDZ); settingParaMap.put("MDZ",TDKSettingPara.TDK_PARA_MDZ); settingParaMap.put("DIG",TDKSettingPara.TDK_PARA_DIG); settingParaMap.put("CDB",TDKSettingPara.TDK_PARA_CDB); settingParaMap.put("CCR",TDKSettingPara.TDK_PARA_CCR); settingParaMap.put("DLB",TDKSettingPara.TDK_PARA_DLB); settingParaMap.put("DDB",TDKSettingPara.TDK_PARA_DDB); settingParaMap.put("DDR",TDKSettingPara.TDK_PARA_DDR); //The following setting para only used in: No 10-1 Function Name Read Converter Meter 1 Command settingParaMap.put("VG",TDKSettingPara.TDK_PARA_VG); settingParaMap.put("IG",TDKSettingPara.TDK_PARA_IG); settingParaMap.put("VB",TDKSettingPara.TDK_PARA_VB); settingParaMap.put("IB",TDKSettingPara.TDK_PARA_IB); settingParaMap.put("WG",TDKSettingPara.TDK_PARA_WG); settingParaMap.put("WB",TDKSettingPara.TDK_PARA_WB); settingParaMap.put("IC",TDKSettingPara.TDK_PARA_IC); settingParaMap.put("TMP",TDKSettingPara.TDK_PARA_TMP); //The following setting para only used in: No 11-1 Function Name Read Converter Meter 2 Command settingParaMap.put("TS",TDKSettingPara.TDK_PARA_TS); settingParaMap.put("TP",TDKSettingPara.TDK_PARA_TP); settingParaMap.put("V5S",TDKSettingPara.TDK_PARA_V5S); settingParaMap.put("FAN1",TDKSettingPara.TDK_PARA_FAN1); settingParaMap.put("FAN2",TDKSettingPara.TDK_PARA_FAN2); settingParaMap.put("FAN3",TDKSettingPara.TDK_PARA_FAN3); settingParaMap.put("FAN4",TDKSettingPara.TDK_PARA_FAN4); settingParaMap.put("FAN5",TDKSettingPara.TDK_PARA_FAN5); } } public static TDKSettingPara getParaInfo(String paraName){ return settingParaMap.get(paraName); } } 3.2 In TDKPacketResponse.java, TDK operation modes are stored in the MAP named operationModeMap, which is initialized when the class is loaded by class loader. The operationModeMap provides a method getOperationMode used to quick get operation mode information by mode value. Please reference to the definition in Communication Manual Page 17. private static Map<Integer, TDKOperationMode> operationModeMap = null; static{ if(operationModeMap == null){ operationModeMap = new HashMap<Integer, TDKOperationMode>(); for (TDKOperationMode mode : TDKOperationMode.values()) { operationModeMap.put(mode.getModeValue(), mode); } } } public TDKOperationMode getOperationMode(int modeValue){ return operationModeMap.get(modeValue); } 3.3 In TDKPacketResponse.java, TDK running states are stored in the MAP named runningStateMap, which is initialized when the class is loaded by class loader. The runningStateMap provides a method getRunningState used to quick get running state information by runningStateValue. Please reference to the definition in Communication Manual Page 19. private static Map<Integer, TDKRunningState> runningStateMap = null; static{ if(runningStateMap == null){ runningStateMap = new HashMap<Integer, TDKRunningState>(); for (TDKRunningState state : TDKRunningState.values()) { runningStateMap.put(state.getRunningStateValue(), state); } } } public TDKRunningState getRunningState(int runningStateValue){ return runningStateMap.get(runningStateValue); } 3.4 In TDKPacketResponse.java, TDK alarm states are stored in the MAP named alarmStateMap, which is initialized when the class is loaded by class loader. The alarmStateMap provides a method getAlarmState used to quick get alarm state information by alarmStateValue. Please reference to the definition in Communication Manual Page 19. private static Map<Integer, TDKAlarmState> alarmStateMap = null; static{ if(alarmStateMap == null){ alarmStateMap = new HashMap<Integer, TDKAlarmState>(); for (TDKAlarmState alarm : TDKAlarmState.values()) { alarmStateMap.put(alarm.getAlarmStateValue(), alarm); } } } public TDKAlarmState getAlarmState(int alarmStateValue){ return alarmStateMap.get(alarmStateValue); } 3.5 In TDKPacketResponse.java, TDK operation mode in status are stored in the MAP named statusOperationModeMap, which is initialized when the class is loaded by class loader. The statusOperationModeMap provides a method getStatusOperationMode used to quick get operation mode in status information by modeValue. Please reference to the definition in Communication Manual Page 19. /* Define a hashMap to store TDK operation mode of STATUS, * Usage: use modeValue field to get TDKStatusOperationMode. * */ private static Map<Integer, TDKStatusOperationMode> statusOperationModeMap = null; static{ if(statusOperationModeMap == null){ statusOperationModeMap = new HashMap<Integer, TDKStatusOperationMode>(); for (TDKStatusOperationMode mode : TDKStatusOperationMode.values()) { statusOperationModeMap.put(mode.getModeValue(), mode); } } } public static TDKStatusOperationMode getStatusOperationMode(int modeValue){ return statusOperationModeMap.get(modeValue); } 3.6 In TDKPacketResponse.java, TDK upper voltage notice of battery charge are stored in the MAP named upperVoltNoticeOfBatteryChargeMap, which is initialized when the class is loaded by class loader. The upperVoltNoticeOfBatteryChargeMap provides a method getUpperVoltNoticeOfBatteryCharge used to quick get notice information by noticeValue. Please reference to the definition in Communication Manual Page 19. private static Map<Integer, TDKUpperVoltNoticeOfBatteryCharge> upperVoltNoticeOfBatteryChargeMap = null; static{ if(upperVoltNoticeOfBatteryChargeMap == null){ upperVoltNoticeOfBatteryChargeMap = new HashMap<Integer, TDKUpperVoltNoticeOfBatteryCharge>(); for (TDKUpperVoltNoticeOfBatteryCharge notice : TDKUpperVoltNoticeOfBatteryCharge.values()) { upperVoltNoticeOfBatteryChargeMap.put(notice.getNoticeValue(), notice); } } } public TDKUpperVoltNoticeOfBatteryCharge getUpperVoltNoticeOfBatteryCharge(int noticeValue){ return upperVoltNoticeOfBatteryChargeMap.get(noticeValue); } 3.7 In TDKPacketResponse.java, TDK lower voltage notice of battery charge are stored in the MAP named lowerVoltNoticeOfBatteryChargeMap, which is initialized when the class is loaded by class loader. The lowerVoltNoticeOfBatteryChargeMap provides a method getLowerVoltNoticeOfBatteryCharge used to quick get notice information by noticeValue. Please reference to the definition in Communication Manual Page 19. private static Map<Integer, TDKLowerVoltNoticeOfBatteryCharge> lowerVoltNoticeOfBatteryChargeMap = null; static{ if(lowerVoltNoticeOfBatteryChargeMap == null){ lowerVoltNoticeOfBatteryChargeMap = new HashMap<Integer, TDKLowerVoltNoticeOfBatteryCharge>(); for (TDKLowerVoltNoticeOfBatteryCharge notice : TDKLowerVoltNoticeOfBatteryCharge.values()) { lowerVoltNoticeOfBatteryChargeMap.put(notice.getNoticeValue(), notice); } } } public TDKLowerVoltNoticeOfBatteryCharge getLowerVoltNoticeOfBatteryCharge(int noticeValue){ return lowerVoltNoticeOfBatteryChargeMap.get(noticeValue); } 3.8 In TDKPacketResponse.java, TDK nominal values are stored in the MAP named nominalValueMap, which is initialized when the class is loaded by class loader. The nominalValueMap provides a method getNominalValue used to quick get nominal information by nominalReturnValue. Please reference to the definition in Communication Manual Page 19. /* Define a hashMap to store TDK nominal value, * Usage: use returnValue field to get TDKNominalValue. * */ private static Map<Integer, TDKNominalValue> nominalValueMap = null; static{ if(nominalValueMap == null){ nominalValueMap = new HashMap<Integer, TDKNominalValue>(); for (TDKNominalValue nominalItem : TDKNominalValue.values()) { nominalValueMap.put(nominalItem.getReturnValue(), nominalItem); } } } public TDKNominalValue getNominalValue(int nominalReturnValue){ return nominalValueMap.get(nominalReturnValue); } 3.9 In TDKPacket.java, TDK commands are stored in the MAP named commandMap, which is initialized when the class is loaded by class loader. The commandMap provides a method getCommand used to quick get command information by cmdField. Please reference to the definition in Communication Manual Page 10. private static Map<Integer,TDKCommand> commandMap = null; static { if(commandMap == null){ commandMap = new HashMap<Integer,TDKCommand>(); for(TDKCommand command : TDKCommand.values()){ commandMap.put(command.getFieldCMD(), command); } } } public TDKCommand getCommand(int cmdField){ return commandMap.get(cmdField); } 3.10 In TDKErrorMap.java, TDK communication error codes are stored in the MAP named errorMap, which is initialized when the class is loaded by class loader. The errorMap provides a method getErrorInfo used to quick get error information by errorCode. Please reference to the definition in Communication Manual Page 12. private static Map<Integer,TDKError> errorMap = null; static { //Initialize the class with the following data when it IS loaded by classloader. if (errorMap == null) { errorMap = new HashMap<Integer, TDKError>(); errorMap.put(0xFFFF,TDKError.TDK_ERROR_1); errorMap.put(0xFFFE,TDKError.TDK_ERROR_2); errorMap.put(0xFFFD,TDKError.TDK_ERROR_3); errorMap.put(0xFFFC,TDKError.TDK_ERROR_4); errorMap.put(0xFFFB,TDKError.TDK_ERROR_5); } } public static TDKError getErrorInfo(int errorCode){ return errorMap.get(errorCode); } 4 Top level APIs In order to operate TDK device properly, three kinds of operations should be implemented by TDK APIs: (1) ON/OFF operation of power conversion by Manual control(charge/discharge) or Automatic control. (2) Charge value for operation setting (target voltage for charge/discharge, limited current for charge/discharge, etc.) (3) Get device information (Device status, Alarm information, etc.) Please reference to the Command reference in TDK Communication Manual Page 17- 40. 4.1 No:1-1. Function Name: Inquire Operation Mode Command R/W:Read /* @methodsName: InquireOperationMode * @description: Send the command packet TDK_OPERATION_MODE_INQUIRE to TDK device. */ public static void InquireOperationMode(int AD1_Reciver, int AD2_Sender); 4.2 No:1-4. Function Name: Set Operation Mode Command R/W:Read /* @methodsName: SetOperationMode * @description: Send the command packet TDK_OPERATION_MODE_SET to TDK device. */ public static void SetOperationMode(int AD1_Reciver, int AD2_Sender, TDKOperationMode operationMode); 4.3 No:2-1. Function Name: Inquire Converter Status Command R/W:Read /* @methodsName: InquireTDKStatus * @description: Send the command packet TDK_CONVERTER_STATUS_INQUIRE to TDK device. */ public static void InquireTDKStatus(int AD1_Reciver, int AD2_Sender); 4.4 No:3-1. Function Name: Read CV Charging Parameter Command R/W:Read /* @methodsName: ReadCVChargingParameter * @description: Send the command packet TDK_CV_CHARGING_PARA_READ to TDK device. */ public static void ReadCVChargingParameter(int AD1_Reciver, int AD2_Sender); 4.5 No:3-4. Function Name: Write CV Charging Parameter Command R/W:Read /* @methodsName: WriteCVChargingParameter * @description: Send the command packet TDK_CV_CHARGING_PARA_WRITE to TDK device. */ public static void WriteCVChargingParameter(int AD1_Reciver, int AD2_Sender, double targetBatteryVolt, double droopRatioOfBatt); 4.6 No:4-1. Function Name: Read CV Disharging Parameter Command R/W:Read /* @methodsName: ReadCVDischargingParameter * @description: Send the command packet TDK_CV_DISCHARGING_PARA_READ to TDK device. */ public static void ReadCVDischargingParameter(int AD1_Reciver, int AD2_Sender); 4.7 No:4-4. Function Name: Write CV Discharging Parameter Command /* @methodsName: WriteCVDischargingParameter R/W:Read * @description: Send the command packet TDK_CV_DISCHARGING_PARA_WRITE to TDK device. */ public static void WriteCVDischargingParameter(int AD1_Reciver, int AD2_Sender, double targetGridVolt, double droopRatioOfGrid); 4.8 No:5-1. Function Name: Read Dead Zone Parameter Command R/W:Read /* @methodsName: ReadDeadZoneParameter * @description: Send the command packet TDK_DEADZONE_PARA_READ to TDK device. */ public static void ReadDeadZoneParameter(int AD1_Reciver, int AD2_Sender); 4.9 No:5-4. Function Name: Write Dead Zone Parameter Command R/W:Read /* @methodsName: WriteDeadZoneParameter * @description: Send the command packet TDK_DEADZONE_PARA_WRITE to TDK device. */ public static void WriteDeadZoneParameter(int AD1_Reciver, int AD2_Sender, double plusSideVolt, double minusSideVolt); 4.10 No:6-1. Function Name: Read Converter Protection Parameter Command R/W:Read /* @methodsName: ReadConverterProtectionParameter * @description: Send the command packet TDK_CONVERTER_PROTECTION_PARA_READ to TDK device.*/ public static void ReadConverterProtectionParameter(int AD1_Reciver, int AD2_Sender); 4.11 No:6-4. Function Name: Write Converter Protection Parameter Command R/W:Read /* @methodsName: WriteConverterProtectionParameter * @description: Send the command packet TDK_CONVERTER_PROTECTION_PARA_WRITE to TDK device. */ public static void WriteDeadZoneParameter(int AD1_Reciver, int AD2_Sender, double currentLimitOfBatt, double currentLimitOfGrid, double underBattVolt, double underGridVolt,double overBattVolt, double overGridVolt); 4.12 No:7-1. Function Name: Read Battery Configuration Parameter1 Command R/W:Read /* @methodsName: ReadBattConfigParameter1 * @description: Send the command packet TDK_BATTERY_CONFIG_PARA1_READ to TDK device. */ public static void ReadBattConfigParameter1(int AD1_Reciver, int AD2_Sender); 4.13 No:7-4. Function Name: Write Battery Configuration Parameter1 Command R/W:Read /* @methodsName: WriteBattConfigParameter1 * @description: Send the command packet TDK_BATTERY_CONFIG_PARA1_WRITE to TDK device. */ public static void WriteBattConfigParameter1(int AD1_Reciver, int AD2_Sender, boolean enableBattOverChargingProtection, boolean enableBattOverDischargingProtection, boolean enableBattBusRamingUp, double targetBattVolt, double limitBattVoltForDischarging, double DeviationVoltForChargingUpperLimit, double DeviationVoltForDishargingUpperLimit); 4.14 No:8-1. Function Name: Read Battery Configuration Parameter2 Command R/W:Read /* @methodsName: ReadBattConfigParameter2 * @description: Send the command packet TDK_BATTERY_CONFIG_PARA2_READ to TDK device. */ public static void ReadBattConfigParameter2(int AD1_Reciver, int AD2_Sender); 4.15 No:8-4. Function Name: Write Battery Configuration Parameter2 Command R/W:Read /* @methodsName: WriteBattConfigParameter2 * @description: Send the command packet TDK_BATTERY_CONFIG_PARA2_WRITE to TDK device. */ public static void WriteBattConfigParameter2(int AD1_Reciver, int AD2_Sender, double deviationOfCharging, double deviationOfDischarging); 4.16 No:9-1. Function Name: Inquire Alarm Command R/W:Read /* @methodsName: InquireAlarm * @description: Send the command packet TDK_ALARM_INQUIRE to TDK device. */ public static void InquireAlarm(int AD1_Reciver, int AD2_Sender); 4.17 No:9-4. Function Name: Clear Alarm Command R/W:Read /* @methodsName: ClearAlarm * @description: Send the command packet TDK_ALARM_CLEAR to TDK device. */ public static void ClearAlarm(int AD1_Reciver, int AD2_Sender); 4.18 No:10-1. Function Name: Read Converter Meter1 Command R/W:Read /* @methodsName: ReadConverterMeter1 * @description: Send the command packet TDK_CONVERTER_METER1_READ to TDK device. */ public static void ReadConverterMeter1(int AD1_Reciver, int AD2_Sender); 4.19 No:11-1. Function Name: Read Converter Meter2 Command R/W:Read /* @methodsName: ReadConverterMeter2 * @description: Send the command packet TDK_CONVERTER_METER2_READ to TDK device. */ public static void ReadConverterMeter2(int AD1_Reciver, int AD2_Sender); 4.20 No:12-1. Function Name: Read Converter Meter1 Format Command R/W:Read /* @methodsName: ReadConverterMeter1Format * @description: Send the command packet TDK_CONVERTER_METER1_FORMAT_READ to TDK device. */ public static void ReadConverterMeter1Format(int AD1_Reciver, int AD2_Sender); 4.21 No:13-1. Function Name: Read Converter Meter2 Format Command R/W:Read /* @methodsName: ReadConverterMeter2Format * @description: Send the command packet TDK_CONVERTER_METER2_FORMAT_READ to TDK device. */ public static void ReadConverterMeter2Format(int AD1_Reciver, int AD2_Sender); 4.22 No:14-1. Function Name: Read Nominal Value Command R/W:Read /* @methodsName: ReadNominalValue * @description: Send the command packet TDK_NOMINAL_VALUE_READ to TDK device. */ public static void ReadNominalValue(int AD1_Reciver, int AD2_Sender); 4.23 No:15-1. Function Name: Read Interface Firmware Version Command R/W:Read /* @methodsName: ReadInterfaceFirmwareVersion * @description: Send the command packet TDK_INTERFACE_FIRMWARE_VERSION_READ to TDK device. */ public static void ReadInterfaceFirmwareVersion(int AD1_Reciver, int AD2_Sender); 4.24 No:16-1. Function Name: Read Control Firmware Version Command R/W:Read /* @methodsName: ReadControlFirmwareVersion * @description: Send the command packet TDK_CONTROL_FIRMWARE_VERSION_READ to TDK device. */ public static void ReadControlFirmwareVersion(int AD1_Reciver, int AD2_Sender); 4.25 The API ParseTDKResponse() is used to parse the response from TDK device including ACK and NAK. Different type of ACK and NAK are parsed into different types of data structures. Please refer to the implementation code of this method. /* @methodsName: ParseTDKResponse * @description: Get the response buffer from TDK device, parse the buffer and return the data to Web Application.*/ public static void ParseTDKResponse(byte[] buffer); 5 RS485 communication between TDK and host The Third-part package RXTXComm was used to implement the both-way communication between TDK and host. The package version is mfz-rxtx-2.2-20081207win-x64. 5.1 Serial communication initialization Please refer the initialization process in TDKTester.java. 5.2 In TDKRS485Tool, APIs are implemented to operate serial port and receive/send data by serial port. /* @methodsName: getSerialTool * @description: Get the SerialTool object that provides the service */ public static TDKRS485Tool getSerialTool(); /* @methodsName: findRSPorts * @description: Find all available ports */ public static final ArrayList<String> findRSPorts(); /* @methodsName: listRSPorts * @description: List all available ports */ public static final void listRSPorts(); /* @methodsName: openRSPort * @description: Open a RS485 port */ public static final SerialPort openRSPort(String portName, int baudrate); /* @methodsName: closeRSPort * @description: Close a RS485 port */ public static void closeRSPort(SerialPort serialPort); /* @methodsName: listPortType * @description: List all ports types */ private static void listPortType(); /* @methodsName: sendToRS485Port * @description: Send buffer to the RS485 port */ public static void sendToRS485Port(SerialPort serialPort, byte[] buffer); /* @methodsName: readFromRS485Port * @description: Read buffer from the RS485 port */ public static byte[] readFromRS485Port(SerialPort serialPort); /* @methodsName: addListener * @description: Add a listener to the RS485 port, then the listener can find if there is buffer available on * the RS485 port */ public static void addListener(SerialPort port, SerialPortEventListener listener); 5.3 A listener are implemented in RS485Listener.java. A thread are started to listen the ACK/NAK from TDK device.