| | |
| | | import com.serotonin.modbus4j.code.DataType; |
| | | |
| | | public class Electric_Control_Single_2kw { |
| | | public int num ; //'主键', |
| | | public int electric2KW_id ; //'电源id', |
| | | public int num ; //'主键', |
| | | public int electric2KW_id ; //'电源id', |
| | | |
| | | public int upper_pulse_block; //上位机脉冲封锁 |
| | | public int remote_start; //远程启动 |
| | | public int fault_reset; //故障复位 |
| | | public int conscurrswitch; //恒流切换 |
| | | public int constantvol; //4并或2串2并恒压 |
| | | public int volset_confirm; //电压给定确认 |
| | | public int currset_confirm; //电流给定确认 |
| | | public int remote_stop; //远程停止 |
| | | public int start_screen_set; //启动触摸屏给定 |
| | | public int start_upper_set; //启动上位机给定 |
| | | public int consvolswitch; //恒压切换 |
| | | public int othermode; //4并或2串2并以外模式 |
| | | public int consvol_distribution; //四串恒压电压分配位 |
| | | |
| | | public float consvolmode_chargecurr ; // '转为恒压模式充电电压值', |
| | | public float chargecurr_one ; // '第1阶段充电电流值', |
| | | public float chargecurr_two ; // '第2阶段充电电流值', |
| | | public float chargecurr_three ; // '第3阶段充电电流值', |
| | | public float chargecurr_four ; // '第4阶段充电电流值', |
| | | public float chargecurr_five ; // '第5阶段充电电流值', |
| | | public float currset ; // '电流设定值', |
| | | |
| | | public float volset ; // '电压设定值', |
| | | public float stopchargevol_one ; // '第1阶段充电终止电压', |
| | | public float stopchargevol_two ; // '第2阶段充电终止电压', |
| | | public float stopchargevol_three ; // '第3阶段充电终止电压', |
| | | public float stopchargevol_four ; // '第4阶段充电终止电压', |
| | | public float stopchargevol_five ; // '第5阶段充电终止电压', |
| | | |
| | | public int upper_pulse_block; //上位机脉冲封锁 |
| | | public int remote_start; //远程启动 |
| | | public int fault_reset; //故障复位 |
| | | public int conscurrswitch; //恒流切换 |
| | | public int constantvol; //4并或2串2并恒压 |
| | | public int volset_confirm; //电压给定确认 |
| | | public int currset_confirm; //电流给定确认 |
| | | public int remote_stop; //远程停止 |
| | | public int start_screen_set; //启动触摸屏给定 |
| | | public int start_upper_set; //启动上位机给定 |
| | | public int consvolswitch; //恒压切换 |
| | | public int othermode; //4并或2串2并以外模式 |
| | | public int consvol_distribution; //四串恒压电压分配位 |
| | | |
| | | public float consvolmode_chargecurr ; // '转为恒压模式充电电压值', |
| | | public float chargecurr_one ; // '第1阶段充电电流值', |
| | | public float chargecurr_two ; // '第2阶段充电电流值', |
| | | public float chargecurr_three ; // '第3阶段充电电流值', |
| | | public float chargecurr_four ; // '第4阶段充电电流值', |
| | | public float chargecurr_five ; // '第5阶段充电电流值', |
| | | public float currset ; // '电流设定值', |
| | | |
| | | public float volset ; // '电压设定值', |
| | | public float stopchargevol_one ; // '第1阶段充电终止电压', |
| | | public float stopchargevol_two ; // '第2阶段充电终止电压', |
| | | public float stopchargevol_three ; // '第3阶段充电终止电压', |
| | | public float stopchargevol_four ; // '第4阶段充电终止电压', |
| | | public float stopchargevol_five ; // '第5阶段充电终止电压', |
| | | |
| | | |
| | | |
| | | |
| | | public Electric_Control_Single_2kw(int electric2kw_id) { |
| | | super(); |
| | | electric2KW_id = electric2kw_id; |
| | | } |
| | | |
| | | public void clear() { |
| | | this.upper_pulse_block = 0; //上位机脉冲封锁 |
| | | this.remote_start = 0; //远程启动 |
| | | this.fault_reset = 0; //故障复位 |
| | | this.conscurrswitch = 0; //恒流切换 |
| | | this.constantvol = 0; //4并或2串2并恒压 |
| | | this.volset_confirm = 0; //电压给定确认 |
| | | this.currset_confirm = 0; //电流给定确认 |
| | | this.remote_stop = 0; //远程停止 |
| | | this.start_screen_set = 0; //启动触摸屏给定 |
| | | this.start_upper_set = 0; //启动上位机给定 |
| | | this.consvolswitch = 0; //恒压切换 |
| | | this.othermode = 0; //4并或2串2并以外模式 |
| | | this.consvol_distribution = 0; //四串恒压电压分配位 |
| | | |
| | | this.consvolmode_chargecurr = 0; // '转为恒压模式充电电压值', |
| | | this.chargecurr_one = 0; // '第1阶段充电电流值', |
| | | this.chargecurr_two = 0; // '第2阶段充电电流值', |
| | | this.chargecurr_three = 0; // '第3阶段充电电流值', |
| | | this.chargecurr_four = 0; // '第4阶段充电电流值', |
| | | this.chargecurr_five = 0; // '第5阶段充电电流值', |
| | | this.currset = 0; // '电流设定值', |
| | | this.volset = 0; // '电压设定值', |
| | | this.stopchargevol_one = 0; // '第1阶段充电终止电压', |
| | | this.stopchargevol_two = 0; // '第2阶段充电终止电压', |
| | | this.stopchargevol_three = 0; // '第3阶段充电终止电压', |
| | | this.stopchargevol_four = 0; // '第4阶段充电终止电压', |
| | | this.stopchargevol_five = 0; // '第5阶段充电终止电压', |
| | | } |
| | | |
| | | public int getNum() { |
| | | return num; |
| | | } |
| | |
| | | public int local_remote_control ; //'就地远程控制状态', |
| | | |
| | | public int pulse_blocking; //脉冲封锁* |
| | | public int dc_voltage_state; //高压开关状态 |
| | | |
| | | public int curve_charge_mode ; //'曲线充电模式状态', |
| | | public int start_curve_charge_mode ; //'启动曲线充电模式', |
| | |
| | | batch.addLocator(16,MyModbusUtils.createBaseLocator(161,master)); |
| | | |
| | | batch.addLocator(17,MyModbusUtils.createBaseLocator(203,master)); //脉冲封锁 |
| | | batch.addLocator(18,MyModbusUtils.createBaseLocator(4002,master)); //高压开关状态 |
| | | |
| | | batch.addLocator(18,MyModbusUtils.createBaseLocator(4640,master)); |
| | | batch.addLocator(19,MyModbusUtils.createBaseLocator(4641,master)); |
| | | batch.addLocator(20,MyModbusUtils.createBaseLocator(4642,master)); |
| | | |
| | | batch.addLocator(19,MyModbusUtils.createBaseLocator(4640,master)); |
| | | batch.addLocator(20,MyModbusUtils.createBaseLocator(4641,master)); |
| | | batch.addLocator(21,MyModbusUtils.createBaseLocator(4642,master)); |
| | | return batch; |
| | | } |
| | | /** |
| | |
| | | this.local_remote_control= MyModbusUtils.readBooleanToInt(res.getValue(16)); |
| | | |
| | | this.pulse_blocking= MyModbusUtils.readBooleanToInt(res.getValue(17)); //脉冲封锁 |
| | | this.dc_voltage_state= MyModbusUtils.readBooleanToInt(res.getValue(18)); //脉冲封锁 |
| | | |
| | | this.curve_charge_mode= MyModbusUtils.readBooleanToInt(res.getValue(18)); |
| | | this.start_curve_charge_mode= MyModbusUtils.readBooleanToInt(res.getValue(19)); |
| | | this.stop_curve_charge_mode= MyModbusUtils.readBooleanToInt(res.getValue(20)); |
| | | this.curve_charge_mode= MyModbusUtils.readBooleanToInt(res.getValue(19)); |
| | | this.start_curve_charge_mode= MyModbusUtils.readBooleanToInt(res.getValue(20)); |
| | | this.stop_curve_charge_mode= MyModbusUtils.readBooleanToInt(res.getValue(21)); |
| | | } |
| | | } |
| | | } |
| | |
| | | import com.modbus.data.MyModbusMaster;
|
| | | import com.modbus.data.MyModbusUtils;
|
| | | import com.serotonin.modbus4j.BatchRead;
|
| | | import com.serotonin.modbus4j.BatchResults;
|
| | | import com.serotonin.modbus4j.code.DataType;
|
| | |
|
| | | public class Electric_State_2kw {
|
| | |
| | | public float chargecurr_five; //第5阶段充电电流值
|
| | | public float consvolmode_chargecurr; //转为恒压模式充电电压值
|
| | |
|
| | | public Electric_State_2kw(int electric2KW_id){
|
| | | this.electric2KW_id = electric2KW_id;
|
| | | }
|
| | | |
| | | public BatchRead<Integer> createBatchRead(MyModbusMaster master) {
|
| | | BatchRead<Integer> batch = new BatchRead<Integer>();
|
| | | batch.addLocator(0,MyModbusUtils.createBaseLocator(6, DataType.FOUR_BYTE_FLOAT,master));
|
| | |
| | | batch.addLocator(2,MyModbusUtils.createBaseLocator(10, DataType.FOUR_BYTE_FLOAT,master));
|
| | | batch.addLocator(3,MyModbusUtils.createBaseLocator(12, DataType.FOUR_BYTE_FLOAT,master));
|
| | |
|
| | | batch.addLocator(4,MyModbusUtils.createBaseLocator(12, DataType.FOUR_BYTE_FLOAT,master));
|
| | | batch.addLocator(4,MyModbusUtils.createBaseLocator(320, DataType.FOUR_BYTE_FLOAT,master));
|
| | | batch.addLocator(5,MyModbusUtils.createBaseLocator(322, DataType.FOUR_BYTE_FLOAT,master));
|
| | | batch.addLocator(6,MyModbusUtils.createBaseLocator(324, DataType.FOUR_BYTE_FLOAT,master));
|
| | | batch.addLocator(7,MyModbusUtils.createBaseLocator(326, DataType.FOUR_BYTE_FLOAT,master));
|
| | | batch.addLocator(8,MyModbusUtils.createBaseLocator(328, DataType.FOUR_BYTE_FLOAT,master));
|
| | |
|
| | | batch.addLocator(9,MyModbusUtils.createBaseLocator(415, DataType.FOUR_BYTE_FLOAT,master)); //控制角
|
| | | batch.addLocator(10,MyModbusUtils.createBaseLocator(16, DataType.FOUR_BYTE_FLOAT,master)); //当前给定电压
|
| | | batch.addLocator(11,MyModbusUtils.createBaseLocator(18, DataType.FOUR_BYTE_FLOAT,master)); //电压设定值
|
| | | batch.addLocator(12,MyModbusUtils.createBaseLocator(25, DataType.FOUR_BYTE_FLOAT,master)); //当前给定电流
|
| | | batch.addLocator(13,MyModbusUtils.createBaseLocator(27, DataType.FOUR_BYTE_FLOAT,master)); //电流设定值
|
| | |
|
| | | batch.addLocator(14,MyModbusUtils.createBaseLocator(315, DataType.TWO_BYTE_INT_SIGNED,master)); //第1阶段充电电流值
|
| | | batch.addLocator(15,MyModbusUtils.createBaseLocator(316, DataType.TWO_BYTE_INT_SIGNED,master)); //第2阶段充电电流值
|
| | | batch.addLocator(16,MyModbusUtils.createBaseLocator(317, DataType.TWO_BYTE_INT_SIGNED,master)); //第3阶段充电电流值
|
| | | batch.addLocator(17,MyModbusUtils.createBaseLocator(318, DataType.TWO_BYTE_INT_SIGNED,master)); //第4阶段充电电流值
|
| | | batch.addLocator(18,MyModbusUtils.createBaseLocator(319, DataType.TWO_BYTE_INT_SIGNED,master)); //第5阶段充电电流值
|
| | | batch.addLocator(19,MyModbusUtils.createBaseLocator(330, DataType.TWO_BYTE_INT_SIGNED,master)); //转为恒压模式充电电压值
|
| | |
|
| | | return batch;
|
| | | }
|
| | |
|
| | | |
| | | public void putBatchResult(BatchResults<Integer> res) {
|
| | | if(res != null) {
|
| | | this.brachdcvol = (float)res.getValue(0); //分直流电压
|
| | | this.brachdccurr = (float)res.getValue(1); //分直流电流
|
| | | this.alldcvol = (float)res.getValue(2); //总直流电压
|
| | | this.alldccurr = (float)res.getValue(3); //总直流电流
|
| | | this.stopchargevol_one = (float)res.getValue(4); //第1阶段充电终止电压
|
| | | this.stopchargevol_two = (float)res.getValue(5); //第2阶段充电终止电压
|
| | | this.stopchargevol_three = (float)res.getValue(6); //第3阶段充电终止电压
|
| | | this.stopchargevol_four = (float)res.getValue(7); //第4阶段充电终止电压
|
| | | this.stopchargevol_five = (float)res.getValue(8); //第5阶段充电终止电压
|
| | | this.controlangle = (float)res.getValue(9); //控制角
|
| | | this.localgivevol = (float)res.getValue(10); //当前给定电压
|
| | | this.volset = (float)res.getValue(11); //电压设定值
|
| | | this.localgivecurr = (float)res.getValue(12); //当前给定电流
|
| | | this.currset = (float)res.getValue(13); //电流设定值
|
| | | this.chargecurr_one = (float)res.getValue(14); //第1阶段充电电流值
|
| | | this.chargecurr_two = (float)res.getValue(15); //第2阶段充电电流值
|
| | | this.chargecurr_three = (float)res.getValue(16); //第3阶段充电电流值
|
| | | this.chargecurr_four = (float)res.getValue(17); //第4阶段充电电流值
|
| | | this.chargecurr_five = (float)res.getValue(18); //第5阶段充电电流值
|
| | | this.consvolmode_chargecurr = (float)res.getValue(19); //转为恒压模式充电电压值
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | public int getElectric2KW_id() {
|
| | |
| | | + ", chargecurr_four=" + chargecurr_four + ", chargecurr_five=" + chargecurr_five
|
| | | + ", consvolmode_chargecurr=" + consvolmode_chargecurr + "]";
|
| | | }
|
| | |
|
| | |
|
| | |
|
| | |
|
| | | |
| | |
|
| | | }
|
| | |
| | | " local_remote_control int(11) NOT NULL DEFAULT '0' COMMENT '就地远程控制状态'," + |
| | | |
| | | " pulse_blocking int(11) NOT NULL DEFAULT '0' COMMENT '脉冲封锁'," + |
| | | " dc_voltage_state int(11) NOT NULL DEFAULT '0' COMMENT '高压开关状态'," + |
| | | |
| | | " curve_charge_mode int(11) NOT NULL DEFAULT '0' COMMENT '曲线充电模式状态'," + |
| | | " start_curve_charge_mode int(11) NOT NULL DEFAULT '0' COMMENT '启动曲线充电模式'," + |
| | |
| | | " start_screen_set int(11) NOT NULL DEFAULT '0' COMMENT '启动触摸屏给定'," + |
| | | " start_upper_set int(11) NOT NULL DEFAULT '0' COMMENT '启动上位机给定'," + |
| | | " consvolswitch int(11) NOT NULL DEFAULT '0' COMMENT '恒压切换'," + |
| | | " othermode int(11) NOT NULL," + |
| | | " othermode int(11) NOT NULL COMMENT '4并或2串2并以外模式'," + |
| | | " consvol_distribution int(11) NOT NULL DEFAULT '0' COMMENT '四串恒压电压分配位'," + |
| | | " PRIMARY KEY (num)," + |
| | | " UNIQUE KEY electric2KW_id_key (electric2KW_id) USING BTREE" + |
| | |
| | | + " othermode = "+ert.othermode+"," |
| | | + " consvol_distribution = "+ert.consvol_distribution+"," |
| | | + " local_remote_control = "+ert.local_remote_control+"," |
| | | |
| | | + " pulse_blocking = "+ert.pulse_blocking+"," //脉冲封锁 |
| | | + " dc_voltage_state = "+ert.dc_voltage_state+"," //高压开关状态 |
| | | |
| | | + " curve_charge_mode = "+ert.curve_charge_mode+"," |
| | | + " start_curve_charge_mode = "+ert.start_curve_charge_mode+"," |
| | | + " stop_curve_charge_mode = "+ert.stop_curve_charge_mode+" " |
| | |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | //更新2mw电源控制信息表 |
| | | public static void update_Electric_Control_2KW(MysqlConnPool pool,Electric_Control_Single_2kw econ) { |
| | | String sql_str = " UPDATE "+ Sql_Mysql.Tb_electric2MW_control +"" |
| | |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 更新模拟量状态表 |
| | | * @param conn_pool |
| | | * @param state |
| | | */ |
| | | public static void update_Electric_State_2KW(MysqlConnPool conn_pool, Electric_State_2kw state) { |
| | | String sql_str = " UPDATE "+Sql_Mysql.Tb_Electric_Control_Single + |
| | | " Set brachdcvol= " + state.brachdcvol + |
| | | ",brachdccurr=" + state.brachdccurr + |
| | | ",alldcvol=" + state.alldcvol + |
| | | ",alldccurr=" + state.alldccurr + |
| | | ",stopchargevol_one=" + state.stopchargevol_one + |
| | | ",stopchargevol_two=" + state.stopchargevol_two + |
| | | ",stopchargevol_three=" + state.stopchargevol_three + |
| | | ",stopchargevol_four=" + state.stopchargevol_four + |
| | | ",stopchargevol_five=" + state.stopchargevol_five + |
| | | ",controlangle=" + state.controlangle + |
| | | ",localgivevol=" + state.localgivevol + |
| | | ",volset=" + state.volset + |
| | | ",localgivecurr=" + state.localgivecurr + |
| | | ",currset=" + state.currset + |
| | | ",chargecurr_one=" + state.chargecurr_one + |
| | | ",chargecurr_two=" + state.chargecurr_two + |
| | | ",chargecurr_three=" + state.chargecurr_three + |
| | | ",chargecurr_four=" + state.chargecurr_four + |
| | | ",chargecurr_five=" + state.chargecurr_five + |
| | | ",consvolmode_chargecurr=" +state.consvolmode_chargecurr+ |
| | | " Where electric2KW_id = " + state.electric2KW_id; |
| | | Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn()); |
| | | try { |
| | | sql.sqlMysqlExecute(sql_str); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询单点控制表 |
| | | * @param conn_pool |
| | | * @param control |
| | | */ |
| | | public static void queryElectric_Control_2KW(MysqlConnPool conn_pool,Electric_Control_Single_2kw control) { |
| | | String sql_str = "SELECT * FROM "+Sql_Mysql.Tb_electric2MW_control; |
| | | ResultSet res = null; |
| | | Sql_Mysql sql = new Sql_Mysql(conn_pool.getConn()); |
| | | try { |
| | | res = sql.sqlMysqlQuery(sql_str); |
| | | while(res.next()) { |
| | | control.upper_pulse_block = res.getInt("upper_pulse_block"); //上位机脉冲封锁 |
| | | control.remote_start= res.getInt("remote_start"); //远程启动 |
| | | control.fault_reset= res.getInt("fault_reset"); //故障复位 |
| | | control.conscurrswitch= res.getInt("conscurrswitch"); //恒流切换 |
| | | control.constantvol= res.getInt("constantvol"); //4并或2串2并恒压 |
| | | control.volset_confirm= res.getInt("volset_confirm"); //电压给定确认 |
| | | control.currset_confirm= res.getInt("currset_confirm"); //电流给定确认 |
| | | control.remote_stop= res.getInt("remote_stop"); //远程停止 |
| | | control.start_screen_set= res.getInt("start_screen_set"); //启动触摸屏给定 |
| | | control.start_upper_set= res.getInt("start_upper_set"); //启动上位机给定 |
| | | control.consvolswitch= res.getInt("consvolswitch"); //恒压切换 |
| | | control.othermode= res.getInt("othermode"); //4并或2串2并以外模式 |
| | | control.consvol_distribution= res.getInt("consvol_distribution"); //四串恒压电压分配位 |
| | | |
| | | control.consvolmode_chargecurr= res.getFloat("consvolmode_chargecurr") ; // '转为恒压模式充电电压值', |
| | | control.chargecurr_one = res.getFloat("chargecurr_one") ; // '第1阶段充电电流值', |
| | | control.chargecurr_two = res.getFloat("chargecurr_two") ; // '第2阶段充电电流值', |
| | | control.chargecurr_three = res.getFloat("chargecurr_three") ; // '第3阶段充电电流值', |
| | | control.chargecurr_four = res.getFloat("chargecurr_four") ; // '第4阶段充电电流值', |
| | | control.chargecurr_five = res.getFloat("chargecurr_five") ; // '第5阶段充电电流值', |
| | | control.currset = res.getFloat("currset") ; // '电流设定值', |
| | | |
| | | control.volset = res.getFloat("volset") ; // '电压设定值', |
| | | control.stopchargevol_one = res.getFloat("stopchargevol_one") ; // '第1阶段充电终止电压', |
| | | control.stopchargevol_two = res.getFloat("stopchargevol_two") ; // '第2阶段充电终止电压', |
| | | control.stopchargevol_three = res.getFloat("stopchargevol_three") ; // '第3阶段充电终止电压', |
| | | control.stopchargevol_four = res.getFloat("stopchargevol_four") ; // '第4阶段充电终止电压', |
| | | control.stopchargevol_five = res.getFloat("stopchargevol_five") ; // '第5阶段充电终止电压', |
| | | } |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | if(res != null) { |
| | | try { |
| | | res.close(); |
| | | } catch (SQLException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | sql.close_con(); |
| | | } |
| | | } |
| | | |
| | | public static void updateElectrical_2KW_Control(MysqlConnPool pool,Electric_Control_Single_2kw control) { |
| | | //String sql_str = " update " + Sql_Mysql; |
| | | |
| | | } |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | public MysqlConnPool conn_pool; |
| | | public Electric_inf_2kw einf; |
| | | public Electric_Rt_2kw ert; |
| | | public Electric_State_2kw state; |
| | | public Electric_Control_Single_2kw econ; |
| | | public MyModbusMaster master; |
| | | |
| | | public Electrical_2KW_SocketClient_Thread(Electric_inf_2kw winf,MysqlConnPool conn_pool) { |
| | | this.conn_pool = conn_pool; |
| | | this.einf = winf; |
| | | |
| | | |
| | | state = new Electric_State_2kw(einf.electric2KW_id); |
| | | ert = new Electric_Rt_2kw(einf.electric2KW_id); |
| | | econ = new Electric_Control_Single_2kw(einf.electric2KW_id); |
| | | master = new MyModbusMaster(einf.getElectric2KW_ip(), MyModbusMaster.SLAVEID_DEFAULT); |
| | | |
| | | } |
| | | |
| | | |
| | |
| | | Electrical_2KWTask_SQL.update_Electric_Rt_2KW(conn_pool, ert); |
| | | |
| | | |
| | | |
| | | |
| | | readMutilElectric_State_2kw(master, state); |
| | | Electrical_2KWTask_SQL.update_Electric_State_2KW(conn_pool, state); |
| | | |
| | | //**************************** 更新2MW系统控制信息 *****************************//* |
| | | readMutilElectric_Control_Single_2kw(master, econ); |