综合管理平台数据库数据模拟程序
whyclxw
2021-03-25 230b4029e603c22c6160063cb109001080123670
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
package com.thread.devs;
 
import java.util.Date;
 
import com.mode.Device_Inf;
import com.mode.Dynamicload_State_rt;
import com.mode.Electric_state;
import com.mode.Manage_Util;
import com.sql.MysqlConnPool;
import com.thread.Manage_Simul_SQL;
 
public class Manage_Simul_4MWPower_thread implements Runnable{
 
    public MysqlConnPool pool;
    public Device_Inf device;
    public Electric_state estate;
    
    public Manage_Simul_4MWPower_thread(MysqlConnPool pool,Device_Inf device){
        this.device = device;
        this.pool = pool;
        estate = new Electric_state(device.getDevice_id());
    }
    
    @Override
    public void run() {
        
        while(true) {
            try {
                //¹¹ÔìËæ»úÊý
                createRandomData(estate);
                //ÍùÊý¾Ý¿â²åÈëÊý¾Ý
                Manage_Simul_SQL.update4MWPower(pool, estate);
                
                
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
    
    public void createRandomData(Electric_state estate) {
        estate.record_time=new Date();//'¼Ç¼ʱ¼ä',
        estate.case_trip_output =  Manage_Util.CreateSwitchRanDom();
        estate.fault_reset_signal =  Manage_Util.CreateSwitchRanDom();
        estate.high_vol_switch_status = Manage_Util.CreateSwitchRanDom();
        estate.stop_button = Manage_Util.CreateSwitchRanDom();
        
        estate.alldcvol = estate.alldcvol + Manage_Util.CreateIntRandom()*Manage_Util.CreateFloat0To1();
        estate.alldccurr = estate.alldccurr + Manage_Util.CreateIntRandom()*Manage_Util.CreateFloat0To1();
        
        estate.main_cabinet_fan_status =  Manage_Util.CreateSwitchRanDom();
        estate.trans_cabinet_door_lock =  Manage_Util.CreateSwitchRanDom();
        estate.trans_cabinet_overtem_alarm =  Manage_Util.CreateSwitchRanDom();
        estate.trans_cabinet_overtem_trip = Manage_Util.CreateSwitchRanDom();
        estate.qs1_state = Manage_Util.CreateSwitchRanDom();
        estate.qs2_state = Manage_Util.CreateSwitchRanDom();
        estate.switch_cabinet_door_status = Manage_Util.CreateSwitchRanDom();
        estate.conn_flag = Manage_Util.CreateSwitchRanDom();
        
    }
 
}