private void bindData() { Thread mLoadThread = new Thread(new ThreadStart(delegate { this.Invoke((EventHandler) delegate { MainForm.ShowLoading(); resetDiagramScroll(DateTime.Now, DateTime.Now.AddDays(-1)); }); string mMonitor = mCurrentMonitorLb.Text; station mStation = mCurrentMonitorLb.Tag as station; int mTopN = 24; int mStyle = 2; switch (mCurrentTimeLb.Text) { case "月": mTopN = mCurrentTypeLb.Text == "历史曲线" ? 36 : 12; mStyle = 4; break; case "小时": mTopN = mCurrentTypeLb.Text == "历史曲线" ? 720 : 24; mStyle = 2; break; default: mTopN = mCurrentTypeLb.Text == "历史曲线" ? 365 : 31; mStyle = 3; break; } IList <DEVICE_STATUS_CLEAN> mStatusList = DEVICE_STATUS_CLEANDao.QueryTopForList(mStation.sCoorName, mTopN, new DEVICE_STATUS_CLEAN() { Style = mStyle }); List <SeriesPoint> mSeriesPointList0 = new List <SeriesPoint>(); List <SeriesPoint> mSeriesPointList1 = new List <SeriesPoint>(); double mTotalWy = 0, mLjWy = 0, mTotalCj = 0, mLjCj = 0; foreach (var status in mStatusList) { status.Dx = mCurrentTypeLb.Text == "速度趋势" ? status.XSpeed * 1000 : status.X * 1000; status.Dh = mCurrentTypeLb.Text == "速度趋势" ? status.Hspeed * 1000 : status.Height * 1000; if (Math.Abs(status.Dx) > 4 || Math.Abs(status.Dx) < 0.1) { status.Dx = 0; } if (Math.Abs(status.Dh) > 4 || Math.Abs(status.Dh) < 0.1) { status.Dh = 0; } mTotalWy = mTotalWy + Math.Abs(status.Dx); mTotalCj = mTotalCj + Math.Abs(status.Dh); mLjWy = mLjWy + status.Dx; mLjCj = mLjCj + status.Dh; mSeriesPointList0.Add(new SeriesPoint(status.aDatetime.Value, status.Dx)); mSeriesPointList1.Add(new SeriesPoint(status.aDatetime.Value, status.Dh)); } //当选择的时间改变时,更新Grid列表 if (mCurrentQueryStyle != mStyle) { mCurrentQueryStyle = mStyle; mJcdList.Clear(); if (mCurrentTypeLb.Text == "历史曲线") { switch (mStyle) { case 2: mTopN = 24; break; case 3: mTopN = 12; break; case 4: mTopN = 31; break; default: break; } } foreach (var station in MainForm.StationList) { mStatusList = DEVICE_STATUS_CLEANDao.QueryTopForList(station.sCoorName, mTopN, new DEVICE_STATUS_CLEAN() { Style = mStyle }); mTotalWy = 0; mLjWy = 0; mTotalCj = 0; mLjCj = 0; foreach (var status in mStatusList) { status.Dx = status.X * 1000; status.Dh = status.Height * 1000; if (Math.Abs(status.Dx) > 4 || Math.Abs(status.Dx) < 0.1) { status.Dx = 0; } if (Math.Abs(status.Dh) > 4 || Math.Abs(status.Dh) < 0.1) { status.Dh = 0; } mTotalWy = mTotalWy + Math.Abs(status.Dx); mTotalCj = mTotalCj + Math.Abs(status.Dh); mLjWy = mLjWy + status.Dx; mLjCj = mLjCj + status.Dh; } if (mStatusList.Count > 0) { var first = mStatusList.First(); var last = mStatusList.Last(); Jcd jcd = new Jcd(); jcd.BH = station.sName; jcd.BW = "坝顶\n108\n高程"; jcd.Scgc = station.Sh + first.Dh; jcd.Bcgc1 = station.Sh + last.Dh; jcd.Ljcx = mLjCj; jcd.Scds = first.Dx; jcd.Bcgc2 = last.Dx; jcd.Ljwy = mLjWy; mJcdList.Add(jcd); } } } this.Invoke((EventHandler) delegate { MainForm.HideLoading(); this.mainChart.Series[0].Points.Clear(); this.mainChart.Series[1].Points.Clear(); if (mStatusList.Count > 0) { this.mainChart.Series[0].Points.AddRange(mSeriesPointList0.ToArray()); this.mainChart.Series[1].Points.AddRange(mSeriesPointList1.ToArray()); this.lblSswy.Text = "位移:" + mStatusList[0].Dx.ToString("F2").PadLeft(2, ' ') + "mm"; this.lblSscj.Text = "沉降:" + mStatusList[0].Dh.ToString("F2").PadLeft(2, ' ') + "mm"; this.lblTjwy.Text = string.Format("平均位移:{0}mm 累计位移:{1}mm", (mTotalWy / mStatusList.Count).ToString("F2").PadLeft(3, ' '), mLjWy.ToString("F2").PadLeft(3, ' ')); this.lblTjcj.Text = string.Format("平均沉降:{0}mm 累计沉降:{1}mm", (mTotalCj / mStatusList.Count).ToString("F2").PadLeft(3, ' '), mLjCj.ToString("F2").PadLeft(3, ' ')); resetDiagramScroll(mStatusList[0].aDatetime.Value, mStatusList[mStatusList.Count - 1].aDatetime.Value); } gcMain.DataSource = mJcdList; gvMain.RefreshData(); }); })); mLoadThread.Start(); }
private void loadData() { tileXBJC.Frames.Clear(); tileWXZT.Frames.Clear(); mStations = stationDao.QueryForList(null).Where(p => p.sStyle == 1).ToList(); mSatList = satDao.QueryForList(null); if (mWxzt != null) { mWxzt.bindData(); } this.tileSBZT.Elements[1].Text = String.Format("设备连接数{0}台", mStations.Count); for (int i = 0; i < mStations.Count; i++) { var mStation = mStations[i]; IList <DEVICE_STATUS_CLEAN> list = DEVICE_STATUS_CLEANDao.QueryTopForList(mStations[i].sCoorName, 1, new DEVICE_STATUS_CLEAN() { Style = 2 }); foreach (var status in list) { status.Dx = status.X * 1000; status.Dy = status.Y * 1000; status.Dh = status.Height * 1000; if (Math.Abs(status.Dx) > 4 || Math.Abs(status.Dx) < 0.1) { status.Dx = 0; } if (Math.Abs(status.Dy) > 4 || Math.Abs(status.Dy) < 0.1) { status.Dy = 0; } if (Math.Abs(status.Dh) > 4 || Math.Abs(status.Dh) < 0.1) { status.Dh = 0; } } mXbjcDic[mStation.sComment] = list; } for (int i = 0; i < mStations.Count; i++) { //形变监测 var mStation = mStations[i]; double dX = 0, dY = 0, dH = 0; var mStatusList = mXbjcDic[mStation.sComment]; if (mStatusList.Count > 0) { var mStatus = mStatusList[0]; dX = mStatus.Dx; dY = mStatus.Dy; dH = mStatus.Dh; } var frame = new TileItemFrame(); frame.Tag = i; foreach (TileItemElement element in tileXBJC.Elements) { frame.Elements.Add(element.Clone() as TileItemElement); } frame.Interval = 5000; if (dX == 0 && dH == 0) { frame.Elements[1].Text = string.Format("{0}:未变化", mStation.sComment); } else { frame.Elements[1].Text = string.Format("{0}:水平偏移:{1:0.0}mm 沉降:{2:0.0}mm", mStation.sComment, dX, dH); var font = frame.Elements[1].Appearance.Normal.Font; frame.Elements[1].Appearance.Normal.Font = new Font(font.FontFamily, font.Size - 4); } tileXBJC.Frames.Add(frame); //卫星状态 frame = new TileItemFrame(); frame.Tag = i; foreach (TileItemElement element in tileWXZT.Elements) { frame.Elements.Add(element.Clone() as TileItemElement); } frame.Interval = 5000; frame.Elements[1].Text = string.Format("{0}:GPS:{1} GLO:{2} BD:{3}", mStation.sComment, mSatList.Where(p => p.sId == mStation.sId && p.sPrn < 30).Count(), mSatList.Where(p => p.sId == mStation.sId && p.sPrn < 60 && p.sPrn > 30).Count(), mSatList.Where(p => p.sId == mStation.sId && p.sPrn > 60).Count()); tileWXZT.Frames.Add(frame); } }