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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
package com.power.data;
 
import java.util.Date;
 
import com.power.mysql.MysqlConnPool;
import com.power.mysql.Sql_Mysql;
 
public class PowerData_RT {
    
    public int PowerDevDeviceId = 0;
    public String PowerDevDeviceIp = " ";
    public String PowerDevDeviceName = " ";
    public String PowerDevProtocolName = " ";
    
    public String StationId = "";
    
    private MysqlConnPool m_ConPool;
    
    public PowerDev_acData m_acData = new PowerDev_acData();
    public PowerDev_acdcData m_acdcData = new PowerDev_acdcData();
    public PowerDev_dcData m_dcData = new PowerDev_dcData();
    
    public EnvmDev_Data m_EnvData = new EnvmDev_Data();
    
    private boolean pwrDevice_CommErr = false; //true = comm err
    
    public Date commRecordTime = new Date(0); 
    
    public int CommTxCount = 0;        //ͨÐÅ´ÎÊý
    public int CommSuccessCount = 0;   //ͨÐųɹ¦´ÎÊý
    
    
    public PowerData_RT(MysqlConnPool pool) {
        m_ConPool = pool;
    }
    
    public boolean GetPwrDeviceCommErrState() {
        return pwrDevice_CommErr;
    }
    
    public void SetPwrDeviceCommErrState(boolean st) {
        
        if(false==st) {
            commRecordTime.setTime(new Date().getTime());
        }
        
        pwrDevice_CommErr = st;
    }
    
    public void setCommCountInc()
    {
        CommTxCount += 1;
        //System.out.println("CommTxCount:"+CommTxCount);
        if(CommTxCount >= 90000000) {
            CommTxCount = 1;
        }
    }
    
    public void setCommSuccessCountInc()
    {
        CommSuccessCount += 1;
        //System.out.println("CommSuccessCount:"+CommSuccessCount);
        if(CommSuccessCount >= 90000000) {
            CommSuccessCount = 1;
        }
    }
    
    public void UpdatePower_ACDC_Data_ToTable() {
        PowerData_RT_SQL.updatePower_ACDC_Data_RT_Table(m_ConPool, this);
        
        //ÄϾ©²â¿ØµçÔ´¸ºÔصçÁ÷¸üÐÂµç³Ø×éÐÅÏ¢ÅäÖÃÖеĸºÔصçÁ÷
        PowerData_RT_SQL.updateBattInfOnLoadCurr(m_ConPool, this);
    }
    
    public void UpdatePower_AC_Data_ToTable() {
        PowerData_RT_SQL.updatePower_AC_Data_RT_Table(m_ConPool, this);
    }
    
    public void UpdatePower_DC_Data_ToTable() {
        PowerData_RT_SQL.updatePower_DC_Data_RT_Table(m_ConPool, this);
    }
    
    public void UpdatePower_RT_Info_ToTable() {
        PowerData_RT_SQL.updatePower_INFO_RT_Table(m_ConPool, this);
    }
    
    public void InsertPower_ACDC_Data_ToTable() {
        PowerData_RT_SQL.insertPower_Data_RT_Table(m_ConPool, PowerDevDeviceId, Sql_Mysql.PWRDEV_ACDCDATA_TABLE);
    }
    
    public void InsertPower_AC_Data_ToTable() {
        PowerData_RT_SQL.insertPower_Data_RT_Table(m_ConPool, PowerDevDeviceId, Sql_Mysql.PWRDEV_ACDATA_TABLE);
    }
    
    public void InsertPower_DC_Data_ToTable() {
        PowerData_RT_SQL.insertPower_Data_RT_Table(m_ConPool, PowerDevDeviceId, Sql_Mysql.PWRDEV_DCDATA_TABLE);
    }
    
    public void InsertPower_RT_INFO_ToTable() {
        PowerData_RT_SQL.insertPower_Data_RT_Table(m_ConPool, PowerDevDeviceId, Sql_Mysql.PWRDEV_RT_INFO_TABLE);
    }
    
    public void InsertPower_Input_INFO_ToTable() {
        PowerData_RT_SQL.insertPower_StaInfo_Table(m_ConPool, PowerDevDeviceId);
        PowerData_RT_SQL.insertPower_acmInfo_Table(m_ConPool, PowerDevDeviceId);
        PowerData_RT_SQL.insertPower_acdcmInfo_Table(m_ConPool, PowerDevDeviceId);
        PowerData_RT_SQL.insertPower_dcmInfo_Table(m_ConPool, PowerDevDeviceId);
    }
    
    //ͨ¹ý°æ±¾ÅжÏÊÇ·ñÓÐÉý¼¶Ð­×ª£¬Èç¹ûûÉý¼¶£¬Ã»ÓÐENVM½Úµã£¬»á²»Í£´òÓ¡´íÎó
    public boolean checkIfEnvmExists() 
    {
        boolean exists = false;
        
        int ver = PowerData_RT_SQL.getVersionFromTable(m_ConPool, PowerDevDeviceIp);
        
        if(ver>1002) { //V1.003¿ªÊ¼¼ÓÈëÁËÈýÏàµçµÆENVM
            exists = true;
        }
        
        return exists;
    }
 
}