| | |
| | | } |
| | | if(addressName.equals("startposition")) {//启动位 |
| | | switch (electric_id) { |
| | | case 4001:address=436;break; |
| | | case 4002:address=756;break; |
| | | case 4003:address=1076;break; |
| | | case 4004:address=1396;break; |
| | | case 4001:address=272;break; |
| | | case 4002:address=273;break; |
| | | case 4003:address=274;break; |
| | | case 4004:address=275;break; |
| | | default:break; |
| | | } |
| | | } |
| | | if(addressName.equals("stopposition")) {//ֹͣλ |
| | | switch (electric_id) { |
| | | case 4001:address=437;break; |
| | | case 4002:address=757;break; |
| | | case 4003:address=1077;break; |
| | | case 4004:address=1397;break; |
| | | case 4001:address=288;break; |
| | | case 4002:address=289;break; |
| | | case 4003:address=290;break; |
| | | case 4004:address=291;break; |
| | | default:break; |
| | | } |
| | | } |
| | |
| | | batch.addLocator(10,MyModbusUtils.createBaseLocator(Electric_4KW_ModbusAddress.getAddress(this.electric_id, "switch_cabinet_door_status"), master)); //转换开关柜门状态 |
| | | |
| | | if(this.electric_id == 4001||this.electric_id == 4003) { |
| | | batch.addLocator(11,MyModbusUtils.createBaseLocator(Electric_4KW_ModbusAddress.getAddress(this.electric_id, "conn_flag"), master)); //串/并联状态 |
| | | //System.err.println(this.electric_id+"==="+Electric_4KW_ModbusAddress.getConnAddress(this.electric_id, "conn_flag")); |
| | | batch.addLocator(11,MyModbusUtils.createBaseLocator(Electric_4KW_ModbusAddress.getConnAddress(this.electric_id, "conn_flag"), master)); //串/并联状态 |
| | | batch.addLocator(12,MyModbusUtils.createBaseLocator(Electric_4KW_ModbusAddress.getAddress(this.electric_id, "alldcvol"), DataType.TWO_BYTE_INT_SIGNED, master)); //总直流电压 |
| | | batch.addLocator(13,MyModbusUtils.createBaseLocator(Electric_4KW_ModbusAddress.getAddress(this.electric_id, "alldccurr"), DataType.TWO_BYTE_INT_SIGNED, master)); //总直流电流 |
| | | } |
| | |
| | | this.switch_cabinet_door_status = MyModbusUtils.readBooleanToInt(res.getValue(10)); //转换开关柜门状态 |
| | | if(this.getElectric_id()==4001||this.getElectric_id()==4003) { |
| | | this.conn_flag= MyModbusUtils.readBooleanToInt(res.getValue(11)); //串/并联状态 ; |
| | | //System.out.println(this.getElectric_id()+"==="+this.conn_flag); |
| | | this.alldcvol = MyModbusUtils.readShortToFloat(res.getValue(12)); //总直流电压 |
| | | this.alldccurr = MyModbusUtils.readShortToFloat(res.getValue(13)); //总直流电流 |
| | | }else { |
| | |
| | | this.divide_flag=0; |
| | | this.volset = 0; |
| | | this.currset = 0; |
| | | this.givevol = 0; |
| | | this.givecurr = 0; |
| | | //this.givevol = 0; |
| | | //this.givecurr = 0; |
| | | this.switchon1 = 0; |
| | | this.switchon2 = 0; |
| | | this.switchoff1 = 0; |
| | |
| | | Date last = new Date(); |
| | | while(true) { |
| | | try { |
| | | // Electrical_Task_SQL.queryElectric_Control_Single(conn_pool, ecs); |
| | | Electrical_Task_SQL.queryElectric_Control_Single(conn_pool, ecs); |
| | | //System.out.println(ecs.isControl_en()+"################33 "+runCount); |
| | | // if(ecs.isControl_en()) { |
| | | // //************************** 单点控制输出 *******************************//* |
| | | // writeElectricalControlSignal(master,ecs); |
| | | // Electrical_Task_SQL.update_Electric_Control_Single(conn_pool, ecs); |
| | | // } |
| | | if(ecs.isControl_en()) { |
| | | //************************** 单点控制输出 *******************************//* |
| | | writeElectricalControlSignal(master,ecs); |
| | | Electrical_Task_SQL.update_Electric_Control_Single(conn_pool, ecs); |
| | | } |
| | | |
| | | // if(econn.electric_id==4001||econn.electric_id==4003) { |
| | | // Electrical_Task_SQL.queryElectric_Control_Conn(conn_pool, econn); |
| | | // if(econn.isControl_en()) { |
| | | // //************************** 组合控制输出 *******************************//* |
| | | // writeElectricalControlConn(master, econn); |
| | | // Electrical_Task_SQL.update_Electric_Control_Conn(conn_pool, econn); |
| | | // } |
| | | // } |
| | | if(econn.electric_id==4001||econn.electric_id==4003) { |
| | | Electrical_Task_SQL.queryElectric_Control_Conn(conn_pool, econn); |
| | | if(econn.isControl_en()) { |
| | | //************************** 组合控制输出 *******************************//* |
| | | writeElectricalControlConn(master, econn); |
| | | Electrical_Task_SQL.update_Electric_Control_Conn(conn_pool, econn); |
| | | } |
| | | } |
| | | |
| | | |
| | | if(runCount %2 == 0) { |
| | |
| | | }*/ |
| | | //单套电源启动:启动位=1;其他模式运行=1;风机启动=1; |
| | | if(ecs.startposition >0) { |
| | | //System.out.println("ecs.startposition==="+ecs.startposition); |
| | | MyModbusUtils.writeCoil(Electric_4KW_ModbusAddress.getAddress(ecs.getElectric_id(), "startposition"),true, master); |
| | | MyModbusUtils.writeCoil(Electric_4KW_ModbusAddress.getAddress(ecs.getElectric_id(), "othermodes"),true, master); |
| | | MyModbusUtils.writeCoil(Electric_4KW_ModbusAddress.getAddress(ecs.getElectric_id(), "fanstart"),true, master); |
| | |
| | | } |
| | | //单套电源停止:停止位=1;风机停止=1 |
| | | if(ecs.stopposition >0) { |
| | | //System.out.println("ecs.stopposition==="+ecs.stopposition); |
| | | MyModbusUtils.writeCoil(Electric_4KW_ModbusAddress.getAddress(ecs.getElectric_id(), "stopposition"),true, master); |
| | | MyModbusUtils.writeCoil(Electric_4KW_ModbusAddress.getAddress(ecs.getElectric_id(), "fanstop"),true, master); |
| | | try { |
| | |
| | | if(ecs.switchon >0) { |
| | | MyModbusUtils.writeCoil(Electric_4KW_ModbusAddress.getAddress(ecs.getElectric_id(), "switchon_1"),true, master); |
| | | MyModbusUtils.writeCoil(Electric_4KW_ModbusAddress.getAddress(ecs.getElectric_id(), "switchon_2"),true, master); |
| | | try { |
| | | //300毫秒后复原 |
| | | Thread.sleep(300); |
| | | MyModbusUtils.writeCoil(Electric_4KW_ModbusAddress.getAddress(ecs.getElectric_id(), "switchon_1"),false, master); |
| | | MyModbusUtils.writeCoil(Electric_4KW_ModbusAddress.getAddress(ecs.getElectric_id(), "switchon_2"),false, master); |
| | | } catch (InterruptedException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | if(ecs.switchoff >0) { |
| | | MyModbusUtils.writeCoil(Electric_4KW_ModbusAddress.getAddress(ecs.getElectric_id(), "switchoff_1"),true, master); |
| | | MyModbusUtils.writeCoil(Electric_4KW_ModbusAddress.getAddress(ecs.getElectric_id(), "switchoff_2"),true, master); |
| | | try { |
| | | //300毫秒后复原 |
| | | Thread.sleep(300); |
| | | MyModbusUtils.writeCoil(Electric_4KW_ModbusAddress.getAddress(ecs.getElectric_id(), "switchoff_1"),false, master); |
| | | MyModbusUtils.writeCoil(Electric_4KW_ModbusAddress.getAddress(ecs.getElectric_id(), "switchoff_2"),false, master); |
| | | } catch (InterruptedException e) { |
| | | // TODO Auto-generated catch block |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | ecs.clear(); |
| | | } |
| | |
| | | } |
| | | //并联模式(按钮按下):\\本站点\AB并串联标志位=0; |
| | | if(econn.conn_flag >0) { |
| | | //System.out.println("econn.conn_flag===="+econn.conn_flag); |
| | | MyModbusUtils.writeCoil(Electric_4KW_ModbusAddress.getConnAddress(econn.getElectric_id(), "conn_flag"), false, master); |
| | | } |
| | | //串联模式(按钮按下):\\本站点\AB并串联标志位=1; |
| | | if(econn.divide_flag >0) { |
| | | //System.out.println("econn.divide_flag===="+econn.divide_flag); |
| | | MyModbusUtils.writeCoil(Electric_4KW_ModbusAddress.getConnAddress(econn.getElectric_id(), "conn_flag"), true, master); |
| | | } |
| | | //电流电压给定确认(按钮按下): |
| | |
| | | econn.conn_name="CD组合"; |
| | | } |
| | | String sql_str = " UPDATE "+ Sql_Mysql.Tb_Electric_Control_Conn+" " |
| | | + " Set conn_name = "+econn.conn_name+"," |
| | | + " Set conn_name = '"+econn.conn_name+"'," |
| | | + " convolcontrol = "+econn.convolcontrol+"," |
| | | + " concurrcontrol = "+econn.concurrcontrol+"," |
| | | + " conn_flag = "+econn.conn_flag+"," |
| | | + " divide_flag = "+econn.divide_flag+"," |
| | | + " volset= "+econn.volset+"," |
| | | + " currset = "+econn.currset+"," |
| | | + " givevol = "+econn.givevol+"," |
| | |
| | | ecs.setDcvol(res.getFloat("dcvol")); |
| | | ecs.setDccurr(res.getFloat("dccurr")); |
| | | ecs.setControlangle(res.getFloat("controlangle")); |
| | | ecs.setSwitchon(res.getInt("switchon")); |
| | | ecs.setSwitchoff(res.getInt("switchoff")); |
| | | //System.out.println(ecs.toString()); |
| | | } |
| | | } catch (Exception e) { |
| | |
| | | |
| | | //更新电源单点控制表 |
| | | public static void update_Electric_Control_Single(MysqlConnPool pool,Electric_Control_Single ecs) { |
| | | //System.out.println(ecs.toString()); |
| | | String sql_str = " UPDATE "+ Sql_Mysql.Tb_Electric_Control_Single |
| | | + " upsetcurr = "+ecs.upsetcurr+"," |
| | | + " set upsetcurr = "+ecs.upsetcurr+"," |
| | | + " upsetvol = "+ecs.upsetvol+"," |
| | | + " convolcontrol = "+ecs.convolcontrol+"," |
| | | + " concurrcontrol= "+ecs.concurrcontrol+"," |
| | |
| | | + " fanstop = "+ecs.fanstop+"," |
| | | + " dcvol = "+ecs.dcvol+"," |
| | | + " dccurr = "+ecs.dccurr+"," |
| | | + " switchon = "+ecs.switchon+"," |
| | | + " switchoff = "+ecs.switchoff+"," |
| | | + " controlangle="+ecs.controlangle+" " |
| | | + " WHERE electric_id = " + ecs.electric_id; |
| | | //System.out.println(sql_str); |
| | | Sql_Mysql sql = new Sql_Mysql(pool.getConn()); |
| | | try { |
| | | sql.sqlMysqlExecute(sql_str); |