コード例 #1
0
ファイル: main.cs プロジェクト: hkiaipc/guye
        //建立xd100n数据缓存
        public Tool.XDRZInfo[] Createxd100nDatas()
        {
            try
            {
                string sql = "select [StationId],[StationName],[DTUregister],[IPAddress],[deviceAddress],[Remark],[heatArea],[heatbase],[group],[cycle],[timeout],[retrytimes] from v_rzstation order by [StationId]";
                DataTable dt = Tool.DB.getDt(sql);
                Tool.XDRZInfo[] baseList = new Tool.XDRZInfo[dt.Rows.Count];
                for (int i = 0; i < dt.Rows.Count; i++)
                {

                    baseList[i]._station._StationId = int.Parse(dt.Rows[i]["StationId"].ToString());
                    baseList[i]._station._StationName = dt.Rows[i]["StationName"].ToString();
                    baseList[i]._station._Remark = dt.Rows[i]["Remark"].ToString();
                    baseList[i]._station._heatbase = float.Parse(dt.Rows[i]["heatbase"].ToString());
                    baseList[i]._station._heatArea = float.Parse(dt.Rows[i]["heatArea"].ToString());
                    baseList[i]._station._group = dt.Rows[i]["group"].ToString();

                    baseList[i]._station._DTUregister = dt.Rows[i]["DTUregister"].ToString();
                    baseList[i]._station._IPAddress = dt.Rows[i]["IPAddress"].ToString();
                    baseList[i]._station._cycle = int.Parse(dt.Rows[i]["cycle"].ToString());
                    baseList[i]._station._deviceAddress = int.Parse(dt.Rows[i]["deviceAddress"].ToString());
                    baseList[i]._station._timeout = int.Parse(dt.Rows[i]["timeout"].ToString());
                    baseList[i]._station._retrytimes = int.Parse(dt.Rows[i]["retrytimes"].ToString());
                    baseList[i].state = true;

                    Tool.XD100n x = new Tool.XD100n(baseList[i]._station._deviceAddress);

                    string sql2 = "SELECT [StationName],[alarmword], [DT], [oneGiveTemp], [oneBackTemp], [twoGiveTemp], [twoBackTemp], [outsideTemp]," +
                        "[twoGiveBaseTemp], [oneGivePress], [oneBackPress], [WatBoxLevel], [twoGivePress], [twoBackPress], "+
                        "[twoBackBasePress], [oneInstant], [oneAccum], [subInstant], [subAccum], [oneHeat], [oneAddHeat],"+
                        " [twoPressCha], [openDegree], [pumpState1], [pumpState2], [pumpState3], [addPumpState1], [addPumpState2],"+
                        " [StationId], [twoInstant], [twoAccum], [twoHeat], [twoAddHeat] FROM [v_rzreallast] where [StationId]=" + baseList[i]._station._StationId.ToString();
                    DataTable dt1 = Tool.DB.getDt(sql2);
                    if (dt1.Rows.Count>0)
                    {
                        baseList[i]._nowDatas._alarm._word = Convert.ToInt32(dt1.Rows[0]["alarmword"]);
                        baseList[i]._nowDatas._dt = Convert.ToDateTime(dt1.Rows[0]["DT"]);
                        baseList[i]._nowDatas._oneGiveTemp = Convert.ToSingle(dt1.Rows[0]["oneGiveTemp"]);
                        baseList[i]._nowDatas._oneBackTemp = Convert.ToSingle(dt1.Rows[0]["oneBackTemp"]);
                        baseList[i]._nowDatas._twoGiveTemp = Convert.ToSingle(dt1.Rows[0]["twoGiveTemp"]);
                        baseList[i]._nowDatas._twoBackTemp = Convert.ToSingle(dt1.Rows[0]["twoBackTemp"]);
                        baseList[i]._nowDatas._outsideTemp = Convert.ToSingle(dt1.Rows[0]["outsideTemp"]);
                        baseList[i]._nowDatas._twoGiveBaseTemp = Convert.ToSingle(dt1.Rows[0]["twoGiveBaseTemp"]);

                        baseList[i]._nowDatas._oneGivePress = Convert.ToSingle(dt1.Rows[0]["oneGivePress"]);
                        baseList[i]._nowDatas._oneBackPress = Convert.ToSingle(dt1.Rows[0]["oneBackPress"]);
                        baseList[i]._nowDatas._WatBoxLevel = Convert.ToSingle(dt1.Rows[0]["WatBoxLevel"]);
                        baseList[i]._nowDatas._twoGivePress = Convert.ToSingle(dt1.Rows[0]["twoGivePress"]);
                        baseList[i]._nowDatas._twoBackPress = Convert.ToSingle(dt1.Rows[0]["twoBackPress"]);

                        baseList[i]._nowDatas._oneInstant = Convert.ToSingle(dt1.Rows[0]["oneInstant"]);
                        baseList[i]._nowDatas._oneAccum = Convert.ToUInt32(dt1.Rows[0]["oneAccum"]);
                        baseList[i]._nowDatas._oneHeat = Convert.ToSingle(dt1.Rows[0]["oneHeat"]);
                        baseList[i]._nowDatas._oneAddHeat = Convert.ToDouble(dt1.Rows[0]["oneAddHeat"]);

                        baseList[i]._nowDatas._subInstant = Convert.ToSingle(dt1.Rows[0]["subInstant"]);
                        baseList[i]._nowDatas._subAccum = Convert.ToUInt32(dt1.Rows[0]["subAccum"]);

                        baseList[i]._nowDatas._twoInstant = Convert.ToSingle(dt1.Rows[0]["twoInstant"]);
                        baseList[i]._nowDatas._twoAccum = Convert.ToUInt32(dt1.Rows[0]["twoAccum"]);
                        baseList[i]._nowDatas._twoHeat = Convert.ToSingle(dt1.Rows[0]["twoHeat"]);
                        baseList[i]._nowDatas._twoAddHeat = Convert.ToDouble(dt1.Rows[0]["twoAddHeat"]);

                        baseList[i]._nowDatas._twoPressCha = Convert.ToSingle(dt1.Rows[0]["twoPressCha"]);
                        baseList[i]._nowDatas._openDegree = Convert.ToSingle(dt1.Rows[0]["openDegree"]);

                        baseList[i]._nowDatas._pump._cycPump1 = dttops(dt1.Rows[0]["pumpState1"].ToString());
                        baseList[i]._nowDatas._pump._cycPump2 = dttops(dt1.Rows[0]["pumpState2"].ToString());
                        baseList[i]._nowDatas._pump._cycPump3 = dttops(dt1.Rows[0]["pumpState3"].ToString());
                        baseList[i]._nowDatas._pump._recruitPump1 = dttops(dt1.Rows[0]["addPumpState1"].ToString());
                        baseList[i]._nowDatas._pump._recruitPump1 = dttops(dt1.Rows[0]["addPumpState2"].ToString());

                        baseList[i]._nowDatas._alarm._word=Convert.ToInt32(dt1.Rows[0]["alarmword"]);

                        byte[] alarm = {Convert.ToByte(baseList[i]._nowDatas._alarm._word/256),Convert.ToByte(baseList[i]._nowDatas._alarm._word%256)};
                        baseList[i]._nowDatas._alarm = x.AlarmParse(alarm);

                        baseList[i]._refDisplay = true;
                    }

                    baseList[i]._command=new Tool.Commandcyc[2];
                    baseList[i]._command[0]._cmd = x.Get_nowdata();
                    baseList[i]._command[0]._onoff = true;
                    baseList[i]._command[1]._cmd = x.Get_di();
                    baseList[i]._command[1]._onoff = true;

                    baseList[i]._commandonce = new Tool.Commandonce[21];

                    baseList[i]._commandonce[0]._cmd = x.Get_controltype();
                    baseList[i]._commandonce[1]._cmd = x.Get_setvalue();
                    baseList[i]._commandonce[2]._cmd = x.Get_line();
                    baseList[i]._commandonce[3]._cmd = x.Get_timepace();
                    baseList[i]._commandonce[4]._cmd = x.Get_valvemm();
                    baseList[i]._commandonce[5]._cmd = x.Get_valvelimit();
                    baseList[i]._commandonce[6]._cmd = x.Get_alarm();
                    baseList[i]._commandonce[7]._cmd = x.Get_outtemp();

                    baseList[i]._commandonce[8]._cmd = x.Set_controltype(baseList[i]._Set._controltype);
                    baseList[i]._commandonce[9]._cmd = x.Set_setvalue(baseList[i]._Set._setvalue);
                    baseList[i]._commandonce[10]._cmd = x.Set_line(baseList[i]._Set._line);
                    baseList[i]._commandonce[11]._cmd = x.Set_timepace(baseList[i]._Set._timepace);
                    baseList[i]._commandonce[12]._cmd = x.Set_valvemm(baseList[i]._Set._valvemm);
                    baseList[i]._commandonce[13]._cmd = x.Set_valvelimit(baseList[i]._Set._valvelimit);
                    baseList[i]._commandonce[14]._cmd = x.Set_alarm(baseList[i]._Set._alarm);
                    baseList[i]._commandonce[15]._cmd = x.Set_outtemp(baseList[i]._Set._outtemp);

                    baseList[i]._commandonce[16]._cmd = x.Set_outtemp_value(baseList[i]._Set._outtemp._outtemp);

                    baseList[i]._commandonce[17]._cmd = x.Set_xunhuan_stop();
                    baseList[i]._commandonce[18]._cmd = x.Set_bushui_stop();
                    baseList[i]._commandonce[19]._cmd = x.Set_xunhuan_start();
                    baseList[i]._commandonce[20]._cmd = x.Set_bushui_start();

                    for (int k = 0; k < baseList[i]._commandonce.Length; k++)
                    {
                        baseList[i]._commandonce[k]._onoff = false;
                    }
                }
                return baseList;
            }
            catch (Exception ex)
            {
                MessageBox.Show("建立数据缓存失败!请检查数据库连接!" + ex, "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
                return null;
            }
        }