whyclj
2019-11-02 7b0d9dc2adc6da45cb5593456c58d83a21de0cfe
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
package com.donghuan.c_interface;
 
import java.util.UUID;
 
import com.battdata_rt.BattData_RT_Array;
import com.config.AppConfig;
import com.sql.MysqlConnPool;
 
public class CInterface_Thread extends Thread {
    private MysqlConnPool m_ConnPool = null;
    private BattData_RT_Array al_Data;
    private AppConfig cfg;
    private CInterfaceState m_CInterfaceStat;
    
    public CInterface_Thread(AppConfig cfg_t, MysqlConnPool pool, BattData_RT_Array al_data)
    {
        m_ConnPool = pool;
        cfg = cfg_t;
        al_Data = al_data;
        m_CInterfaceStat = new CInterfaceState(al_Data);
    }
    
    @Override
    public void run() {
        /**********************************************************************************/
        System.out.println(this.getName() + " - CInterface_Thread Started ...");
        /**********************************************************************************/
        //ɾ³ý£¬´´½¨²¢ÇÒÏòtb_cinterface_stateÖÐÌí¼ÓÊý¾Ý
        CInterface_Thread_SQL.createCInterfaceStateTableOnRam(m_ConnPool, m_CInterfaceStat);
        /*
        ArrayList<ArrayList<Integer>> al_id = null;
        int id_group_count = 0;
        int id_count = 0;
        for(int var=0; var<al_Data.getItemCount(); var++)
        {
            BattData_RT brt = al_Data.getItem(var);
            al_id = brt.al_MonVol_C_Id;
            
            id_group_count += al_id.size();
            
            System.out.println("BattGroupId:" + brt.BattGroupId +","+al_id.get(0).size());
            
            int mon_index = 0;
            for(int n=0; n<al_id.size(); n++)
            {
                id_count += al_id.get(n).size();
                String str = "";
                for(int c=0; c<al_id.get(n).size(); c++)
                {
                    str += String.format("%03d# %d", (mon_index+1), al_id.get(n).get(c)) + "    ";
                    mon_index += 1;
                }
                if(brt.BattGroupId <= 1035594)
                    System.out.println(str);
            }
        }
        
        System.out.println("id_group count: " + id_group_count + ", ids count: " + id_count);
        */
        
        /*if(cfg.getCInterfaceServerIp().equals("127.0.0.1"))
        {
            new CInterface_DemoServer(al_Data).start();
            
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        
        new CInterface_SocketClient(cfg, al_Data, m_CInterfaceStat).start();
        
        while (true) {
            CInterfaceState st = m_CInterfaceStat;
            CInterface_Thread_SQL.updateCInterfaceStateTableOnRam(m_ConnPool, st);
            
            if((0==st.alm_rec_id) && (st.alm_com_err_count>0)) {
                st.alm_rec_id = UUID.randomUUID().getLeastSignificantBits();
                if(0 == st.alm_rec_id) {
                    st.alm_rec_id = UUID.randomUUID().getLeastSignificantBits();
                }
                DeviceAlarm_Thread.insertOrUpdateDevAlarmToTable(m_ConnPool, st.alm_rec_id, 0, "-",
                                                                    DeviceAlarm_Thread.ALM_TYPE_CInterface_CommError_ID, true);
            } else {
                if((0!=st.alm_rec_id) && (0==st.alm_com_err_count)) {
                    DeviceAlarm_Thread.insertOrUpdateDevAlarmToTable(m_ConnPool, st.alm_rec_id, 0, "-",
                                                                    DeviceAlarm_Thread.ALM_TYPE_CInterface_CommError_ID, false);
                    st.alm_rec_id = 0;
                }
            }
            
            try {
                Thread.sleep(2000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }*/
    }
}