综合管理平台数据库数据模拟程序
Administrator
2021-03-25 335a3b0a6a6f27d0f7097b27c6614c66f5946676
Demo_Manage_Simul/src/com/thread/devs/Manage_Simul_2MWPower_thread.java
@@ -4,6 +4,7 @@
import com.mode.Device_Inf;
import com.mode.Dynamicload_State_rt;
import com.mode.Electric_State_2kw;
import com.mode.Manage_Util;
import com.sql.MysqlConnPool;
import com.thread.Manage_Simul_SQL;
@@ -12,23 +13,23 @@
   public MysqlConnPool pool;
   public Device_Inf device;
   public Dynamicload_State_rt dstate;
   public Electric_State_2kw e2state;
   
   public Manage_Simul_2MWPower_thread(MysqlConnPool pool,Device_Inf device){
      this.device = device;
      this.pool = pool;
      dstate = new Dynamicload_State_rt(device.getDevice_id());
      e2state = new Electric_State_2kw(device.getDevice_id());
   }
   
   @Override
   public void run() {
      Manage_Simul_SQL.insert2MWPower(pool, e2state);
      while(true) {
         try {
            //构造随机数
            createRandomData(dstate);
            createRandomData(e2state);
            //往数据库插入数据
            Manage_Simul_SQL.updateDynamicload(pool, dstate);
            Manage_Simul_SQL.update2MWPower(pool, e2state);
            
            
            Thread.sleep(1000);
@@ -38,38 +39,31 @@
      }
   }
   
   public void createRandomData(Dynamicload_State_rt dstate) {
      dstate.record_time=new Date();//'记录时间',
      dstate.start_auto =  Manage_Util.CreateSwitchRanDom();
      dstate.stop_auto =  Manage_Util.CreateSwitchRanDom();
      dstate.sudden_crease = Manage_Util.CreateSwitchRanDom();
      dstate.all_open = Manage_Util.CreateSwitchRanDom();
      dstate.actual_set_power = dstate.actual_set_power + Manage_Util.CreateIntRandom()*Manage_Util.CreateFloat0To1();
      dstate.output_power = dstate.output_power + Manage_Util.CreateIntRandom()*Manage_Util.CreateFloat0To1();
      dstate.set_power = dstate.set_power + Manage_Util.CreateIntRandom()*Manage_Util.CreateFloat0To1();
      dstate.interval_time = dstate.interval_time + Manage_Util.CreateIntRandom()*2;
      dstate.actual_curr = dstate.actual_curr + Manage_Util.CreateIntRandom()*Manage_Util.CreateFloat0To1();
      dstate.actual_mov = dstate.actual_mov + Manage_Util.CreateIntRandom()*Manage_Util.CreateFloat0To1();
   public void createRandomData(Electric_State_2kw e2state) {
      e2state.record_time=new Date();//'记录时间',
      e2state.brachdcvol = e2state.brachdcvol + Manage_Util.CreateIntRandom()*Manage_Util.CreateFloat0To1();
      e2state.brachdccurr = e2state.brachdccurr + Manage_Util.CreateIntRandom()*Manage_Util.CreateFloat0To1();
      e2state.alldcvol = e2state.alldcvol + Manage_Util.CreateIntRandom()*Manage_Util.CreateFloat0To1();
      e2state.alldccurr = e2state.alldccurr + Manage_Util.CreateIntRandom()*2;
      e2state.stopchargevol_one = e2state.stopchargevol_one + Manage_Util.CreateIntRandom()*Manage_Util.CreateFloat0To1();
      e2state.stopchargevol_two = e2state.stopchargevol_two + Manage_Util.CreateIntRandom()*Manage_Util.CreateFloat0To1();
      e2state.stopchargevol_three = e2state.stopchargevol_three + Manage_Util.CreateIntRandom()*Manage_Util.CreateFloat0To1();
      e2state.stopchargevol_four = e2state.stopchargevol_four + Manage_Util.CreateIntRandom()*Manage_Util.CreateFloat0To1();
      e2state.stopchargevol_five = e2state.stopchargevol_five + Manage_Util.CreateIntRandom()*Manage_Util.CreateFloat0To1();
      e2state.controlangle = e2state.controlangle + Manage_Util.CreateIntRandom()*2;
      e2state.localgivevol = e2state.localgivevol + Manage_Util.CreateIntRandom()*Manage_Util.CreateFloat0To1();
      e2state.stopchargevol_two = e2state.stopchargevol_two + Manage_Util.CreateIntRandom()*Manage_Util.CreateFloat0To1();
      e2state.volset = e2state.volset + Manage_Util.CreateIntRandom()*Manage_Util.CreateFloat0To1();
      e2state.localgivecurr = e2state.localgivecurr + Manage_Util.CreateIntRandom()*Manage_Util.CreateFloat0To1();
      e2state.currset = e2state.currset + Manage_Util.CreateIntRandom()*Manage_Util.CreateFloat0To1();
      e2state.chargecurr_one = e2state.chargecurr_one + Manage_Util.CreateIntRandom()*2;
      e2state.chargecurr_two = e2state.chargecurr_two + Manage_Util.CreateIntRandom()*Manage_Util.CreateFloat0To1();
      e2state.chargecurr_three = e2state.chargecurr_three + Manage_Util.CreateIntRandom()*Manage_Util.CreateFloat0To1();
      e2state.chargecurr_four = e2state.chargecurr_four + Manage_Util.CreateIntRandom()*2;
      e2state.chargecurr_five = e2state.chargecurr_five + Manage_Util.CreateIntRandom()*Manage_Util.CreateFloat0To1();
      e2state.consvolmode_chargecurr = e2state.consvolmode_chargecurr + Manage_Util.CreateIntRandom()*Manage_Util.CreateFloat0To1();
        
      dstate.switch_on =  Manage_Util.CreateSwitchRanDom();
      dstate.allow_close =  Manage_Util.CreateSwitchRanDom();
      dstate.FZ_autostate1 =  Manage_Util.CreateSwitchRanDom();
      dstate.FZ_autostate2 = Manage_Util.CreateSwitchRanDom();
      dstate.FZ_autostate3 = Manage_Util.CreateSwitchRanDom();
      dstate.FZ_autostate4 = Manage_Util.CreateSwitchRanDom();
      dstate.FZ_autostate5 = Manage_Util.CreateSwitchRanDom();
      dstate.react_overtem = Manage_Util.CreateSwitchRanDom();
      dstate.water_overtem = Manage_Util.CreateSwitchRanDom();
      dstate.water_level_low = Manage_Util.CreateSwitchRanDom();
      dstate.water_pressure_high = Manage_Util.CreateSwitchRanDom();
      dstate.local_control = Manage_Util.CreateSwitchRanDom();
      dstate.back_control =  Manage_Util.CreateSwitchRanDom();
      dstate.central_control =  Manage_Util.CreateSwitchRanDom();
      dstate.switch_state = Manage_Util.CreateSwitchRanDom();
      dstate.inter_volume_M200 = Manage_Util.CreateSwitchRanDom();
      dstate.fan_button = Manage_Util.CreateSwitchRanDom();
      dstate.fan_output = Manage_Util.CreateSwitchRanDom();
      
   }
}