Administrator
2021-02-25 9212c02897a6d2c70921dee84c4d3a08baa4d888
设置组合给定电压和组合给定电流,以及添加指定字段
3个文件已修改
71 ■■■■■ 已修改文件
ElectricalSystem_MonitorServer_4KW/src/com/electrical/FourKW/Electric_control_conn.java 24 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ElectricalSystem_MonitorServer_4KW/src/com/electrical/FourKW/Electrical_4KW_SocketClient_Thread.java 21 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ElectricalSystem_MonitorServer_4KW/src/com/electrical/FourKW/Electrical_Task_SQL.java 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ElectricalSystem_MonitorServer_4KW/src/com/electrical/FourKW/Electric_control_conn.java
@@ -19,6 +19,8 @@
      public int conn_start   ;// '并联运行启动',
      public int conn_stop   ;// '并联运行停止',
      
      public float groupgivevol;    //并联给定电压
      public float groupgivecurr;    //并联给定电流
      
      public boolean control_en = false;
      
@@ -43,6 +45,8 @@
            this.switchoff2=0;
            this.conn_start=0;
            this.conn_stop=0;
            this.groupgivevol = 0;
            this.groupgivecurr = 0;
        }
    public int getNum() {
        return num;
@@ -183,6 +187,26 @@
        }
        this.conn_stop = conn_stop;
    }
    public float getGroupgivevol() {
        return groupgivevol;
    }
    public float getGroupgivecurr() {
        return groupgivecurr;
    }
    public void setGroupgivevol(float groupgivevol) {
        if(groupgivevol > 0) {
            control_en = true;
        }
        this.groupgivevol = groupgivevol;
    }
    public void setGroupgivecurr(float groupgivecurr) {
        if(groupgivecurr > 0) {
            control_en = true;
        }
        this.groupgivecurr = groupgivecurr;
    }
    public boolean isControl_en() {
        return control_en;
    }
ElectricalSystem_MonitorServer_4KW/src/com/electrical/FourKW/Electrical_4KW_SocketClient_Thread.java
@@ -749,8 +749,8 @@
            */
        if(econn.volset >0) {            
            try {
                boolean flag = MyModbusUtils.writeHoldingRegister(Electric_4KW_ModbusAddress.getConnAddress(econn.getElectric_id(), "givevol"), econn.givevol, DataType.TWO_BYTE_INT_UNSIGNED, master);
                flag = flag&&MyModbusUtils.writeHoldingRegister(Electric_4KW_ModbusAddress.getAddress(econn.getElectric_id(), "upsetvol"),econn.givevol, DataType.TWO_BYTE_INT_UNSIGNED, master);
                //boolean flag = MyModbusUtils.writeHoldingRegister(Electric_4KW_ModbusAddress.getConnAddress(econn.getElectric_id(), "givevol"), econn.givevol, DataType.TWO_BYTE_INT_UNSIGNED, master);
                boolean flag = MyModbusUtils.writeHoldingRegister(Electric_4KW_ModbusAddress.getAddress(econn.getElectric_id(), "upsetvol"),econn.givevol, DataType.TWO_BYTE_INT_UNSIGNED, master);
                flag = flag&&MyModbusUtils.writeCoil(Electric_4KW_ModbusAddress.getAddress(econn.getElectric_id(), "othermodes"),true, master);
                
                flag = flag&&MyModbusUtils.writeHoldingRegister(Electric_4KW_ModbusAddress.getAddress(econn.getElectric_id()+1, "upsetvol"),econn.givevol, DataType.TWO_BYTE_INT_UNSIGNED, master);
@@ -770,8 +770,8 @@
        //电压电流给定确认
        if(econn.currset >0) {
            try {
                boolean flag = MyModbusUtils.writeHoldingRegister(Electric_4KW_ModbusAddress.getConnAddress(econn.getElectric_id(), "givecurr"), econn.givecurr, DataType.TWO_BYTE_INT_UNSIGNED, master);
                flag = flag&&MyModbusUtils.writeHoldingRegister(Electric_4KW_ModbusAddress.getAddress(econn.getElectric_id(), "upsetcurr"),econn.givecurr, DataType.TWO_BYTE_INT_UNSIGNED, master);
                //boolean flag = MyModbusUtils.writeHoldingRegister(Electric_4KW_ModbusAddress.getConnAddress(econn.getElectric_id(), "givecurr"), econn.givecurr, DataType.TWO_BYTE_INT_UNSIGNED, master);
                boolean flag = MyModbusUtils.writeHoldingRegister(Electric_4KW_ModbusAddress.getAddress(econn.getElectric_id(), "upsetcurr"),econn.givecurr, DataType.TWO_BYTE_INT_UNSIGNED, master);
                flag = flag&&MyModbusUtils.writeCoil(Electric_4KW_ModbusAddress.getAddress(econn.getElectric_id(), "othermodes"),true, master);
                
                flag = flag&&MyModbusUtils.writeHoldingRegister(Electric_4KW_ModbusAddress.getAddress(econn.getElectric_id()+1, "upsetcurr"),econn.givecurr, DataType.TWO_BYTE_INT_UNSIGNED, master);
@@ -788,6 +788,19 @@
                e.printStackTrace();
            }
        }
        //设置并联给定电压
        if(econn.groupgivecurr > 0) {
            boolean flag = MyModbusUtils.writeHoldingRegister(Electric_4KW_ModbusAddress.getConnAddress(econn.getElectric_id(), "givevol"), econn.groupgivevol, DataType.TWO_BYTE_INT_UNSIGNED, master);
            logs.add(new User_Log(User_Log.Alter,User_Log.electricsystem,getGroupName(econn.electric_id)+"电压给定设置为:"+econn.groupgivevol,flag));
        }
        //设置并联给定电流
        if(econn.groupgivevol > 0) {
            boolean flag = MyModbusUtils.writeHoldingRegister(Electric_4KW_ModbusAddress.getConnAddress(econn.getElectric_id(), "givecurr"), econn.groupgivecurr, DataType.TWO_BYTE_INT_UNSIGNED, master);
            logs.add(new User_Log(User_Log.Alter,User_Log.electricsystem,getGroupName(econn.electric_id)+"电流给定设置为:"+econn.groupgivecurr,flag));
        }
        //并联运行启动
        if(econn.conn_start >0) {
            try {
ElectricalSystem_MonitorServer_4KW/src/com/electrical/FourKW/Electrical_Task_SQL.java
@@ -404,12 +404,34 @@
                "  switchoff2 int(11) NOT NULL DEFAULT '0' COMMENT '输出分闸2'," + 
                "  conn_start int(11) NOT NULL DEFAULT '0' COMMENT '并联运行启动'," + 
                "  conn_stop int(11) NOT NULL DEFAULT '0' COMMENT '并联运行停止'," + 
                "  groupgivevol float NOT NULL DEFAULT '0' COMMENT '并联给定电压'," +
                "  groupgivecurr float NOT NULL DEFAULT '0' COMMENT '并联给定电流'," +
                "  PRIMARY KEY (num),"+
                "  UNIQUE KEY electric_id_key (electric_id) USING BTREE " + 
                ") ENGINE=InnoDB DEFAULT CHARSET=utf8;";
        Sql_Mysql sql = new Sql_Mysql(pool.getConn());
        ResultSet res = null;
        try {
            sql.sqlMysqlExecute(sql_str);
            sql.sqlMysqlExecute(sql_str);
            //添加'并联给定电压'字段
            res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
                    + " WHERE table_schema='db_electricsystem'"
                    + " AND table_name='tb_electric_control_conn'"
                    + " AND column_name='groupgivevol'");
            if(false == res.next()) {
                sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Tb_Electric_Control_Conn
                                + " ADD COLUMN groupgivevol float NOT NULL DEFAULT '0' COMMENT '并联给定电压';");
            }
            //添加'并联给定电流'字段
            res = sql.sqlMysqlQuery("SELECT * FROM information_schema.columns"
                    + " WHERE table_schema='db_electricsystem'"
                    + " AND table_name='tb_electric_control_conn'"
                    + " AND column_name='groupgivecurr'");
            if(false == res.next()) {
                sql.sqlMysqlExecute("ALTER TABLE " + Sql_Mysql.Tb_Electric_Control_Conn
                                + " ADD COLUMN groupgivecurr float NOT NULL DEFAULT '0' COMMENT '并联给定电流';");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        } finally {
@@ -709,6 +731,8 @@
                econn.setSwitchoff2(res.getInt("switchoff2"));
                econn.setConn_start(res.getInt("conn_start"));
                econn.setConn_stop(res.getInt("conn_stop"));
                econn.setGroupgivevol(res.getFloat("groupgivevol"));
                econn.setGroupgivecurr(res.getFloat("groupgivecurr"));
            }
        } catch (Exception e) {
            e.printStackTrace();