//建立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; } }
//xd100n数据处理 private void rz_deal(byte[] rs ,int listid) { Tool.XD100n x = new Tool.XD100n(rs[0]); //实时数据模拟量 功能码0x04 if (rs[1] == 0x04 && rs[2] == 0x64) { try { Tool.XD100nData d = new Tool.XD100nData(); d = x.Read_nowdata(rs); _XDRZInfoList[listid]._nowDatas = d; _XDRZInfoList[listid]._command[0]._retrytimesnow = 0; _XDRZInfoList[listid]._command[0]._sendover = false; } catch { } } //实时数据数字量 功能码0x02 if (rs[1] == 0x02 && rs[2] == 0x04) { try { Tool.GRPumpState ps = x.getpumpstate(rs); Tool.GRAlarmData ad = x.getalarmstate(rs); _XDRZInfoList[listid]._nowDatas._alarm = ad; _XDRZInfoList[listid]._nowDatas._pump = ps; _XDRZInfoList[listid]._saveDatas = true; _XDRZInfoList[listid]._refDisplay = true; _XDRZInfoList[listid]._command[1]._retrytimesnow = 0; _XDRZInfoList[listid]._command[1]._sendover = false; } catch { } } //03可读返回 if (rs[1] == 0x03) { //控制方法114 if (_XDRZInfoList[listid].lastaddr == 114 - 1) { _XDRZInfoList[listid]._Set._controltype = x.Read_controltype(rs); _XDRZInfoList[listid]._commandonce[0]._back = true; _XDRZInfoList[listid]._commandonce[0]._sendover = false; } //设定值116 if (_XDRZInfoList[listid].lastaddr == 116 - 1) { _XDRZInfoList[listid]._Set._setvalue = x.Read_setvalue(rs); _XDRZInfoList[listid]._commandonce[1]._back = true; _XDRZInfoList[listid]._commandonce[1]._sendover = false; } //曲线117 if (_XDRZInfoList[listid].lastaddr == 117 - 1) { _XDRZInfoList[listid]._Set._line = x.Read_line(rs); _XDRZInfoList[listid]._commandonce[2]._back = true; _XDRZInfoList[listid]._commandonce[2]._sendover = false; } //分时调整133 if (_XDRZInfoList[listid].lastaddr == 133 - 1) { _XDRZInfoList[listid]._Set._timepace = x.Read_timepace(rs); _XDRZInfoList[listid]._commandonce[3]._back = true; _XDRZInfoList[listid]._commandonce[3]._sendover = false; } //开度最大最小值145 if (_XDRZInfoList[listid].lastaddr == 145 - 1) { _XDRZInfoList[listid]._Set._valvemm = x.Read_valvemm(rs); _XDRZInfoList[listid]._commandonce[4]._back = true; _XDRZInfoList[listid]._commandonce[4]._sendover = false; } //流量限定153 if (_XDRZInfoList[listid].lastaddr == 153 - 1) { _XDRZInfoList[listid]._Set._valvelimit = x.Read_valvelimit(rs); _XDRZInfoList[listid]._commandonce[5]._back = true; _XDRZInfoList[listid]._commandonce[5]._sendover = false; } //报警198 if (_XDRZInfoList[listid].lastaddr == 198 - 1) { _XDRZInfoList[listid]._Set._alarm = x.Read_alarm(rs); _XDRZInfoList[listid]._commandonce[6]._back = true; _XDRZInfoList[listid]._commandonce[6]._sendover = false; } //室外温度206 if (_XDRZInfoList[listid].lastaddr == 206 - 1) { _XDRZInfoList[listid]._Set._outtemp = x.Read_outtemp(rs); _XDRZInfoList[listid]._commandonce[7]._back = true; _XDRZInfoList[listid]._commandonce[7]._sendover = false; } //刷新设置 rz.rz_flowchart.refsetdisplay = 1; } //10写返回 if (rs[1] == 0x10) { //控制方法114 if (_XDRZInfoList[listid].lastaddr == 114 - 1) { _XDRZInfoList[listid]._commandonce[8]._back = true; _XDRZInfoList[listid]._commandonce[8]._sendover = false; } //设定值116 if (_XDRZInfoList[listid].lastaddr == 116 - 1) { _XDRZInfoList[listid]._commandonce[9]._back = true; _XDRZInfoList[listid]._commandonce[9]._sendover = false; } //曲线117 if (_XDRZInfoList[listid].lastaddr == 117 - 1) { _XDRZInfoList[listid]._commandonce[10]._back = true; _XDRZInfoList[listid]._commandonce[10]._sendover = false; } //分时调整133 if (_XDRZInfoList[listid].lastaddr == 133 - 1) { _XDRZInfoList[listid]._commandonce[11]._back = true; _XDRZInfoList[listid]._commandonce[11]._sendover = false; } //开度最大最小值145 if (_XDRZInfoList[listid].lastaddr == 145 - 1) { _XDRZInfoList[listid]._commandonce[12]._back = true; _XDRZInfoList[listid]._commandonce[12]._sendover = false; } //流量限定153 if (_XDRZInfoList[listid].lastaddr == 153 - 1) { _XDRZInfoList[listid]._commandonce[13]._back = true; _XDRZInfoList[listid]._commandonce[13]._sendover = false; } //报警198 if (_XDRZInfoList[listid].lastaddr == 198 - 1) { _XDRZInfoList[listid]._commandonce[14]._back = true; _XDRZInfoList[listid]._commandonce[14]._sendover = false; } //室外温度206 if (_XDRZInfoList[listid].lastaddr == 206 - 1) { _XDRZInfoList[listid]._commandonce[15]._back = true; _XDRZInfoList[listid]._commandonce[15]._sendover = false; } //刷新设置 rz.rz_flowchart.refsetdisplay = 1; } //急停返回 if (rs[1] == 0x0F) { //循环泵启动返回 if (rs[3] == 0x04) { //古冶特定版本 2010-3-22验收 _XDRZInfoList[listid]._commandonce[17]._cmd = x.Set_xunhuan_stop(); _XDRZInfoList[listid]._commandonce[17]._onoff = true; _XDRZInfoList[listid]._commandonce[19]._back = true; _XDRZInfoList[listid]._commandonce[19]._sendover = false; } //补水泵启动返回 if (rs[3] == 0x06) { _XDRZInfoList[listid]._commandonce[18]._cmd = x.Set_bushui_stop(); _XDRZInfoList[listid]._commandonce[18]._onoff = true; _XDRZInfoList[listid]._commandonce[20]._back = true; _XDRZInfoList[listid]._commandonce[20]._sendover = false; } //循环泵急停返回 if (rs[3] == 0x05) { _XDRZInfoList[listid]._commandonce[17]._back = true; _XDRZInfoList[listid]._commandonce[17]._sendover = false; } //补水泵急停返回 if (rs[3] == 0x07) { _XDRZInfoList[listid]._commandonce[18]._back = true; _XDRZInfoList[listid]._commandonce[18]._sendover = false; } //刷新设置 rz.rz_flowchart.refsetdisplay = 1; } _XDRZInfoList[listid].state = true; //解除ISocketRS占用 On_ISocketRS(_XDRZInfoList[listid]._station._IPAddress, false); }