Beispiel #1
0
        //历史
        private void BindChartHistory(string sFields)
        {
            try
            {
                string sTime = PublicFunction.DateTimeToStringWithfff(DateTime.Now);
                string sSql  = "insert into QueryAlarm(QueryDate,StartTime,EndTime,QueryFields,UnitNO,AlarmDesc) values('"
                               + sTime + "','" + dateTimePickerBegin2.Value + "','" + dateTimePickerEnd2.Value + "','" + sFields + "',"
                               + UnitNO + ",'查询数据时,未按提示等待,做其他操作造成程序退出!')";
                try { SQLHelper.ExecuteSql(sSql); }
                catch { }

                dtData = TagValue.QueryDBData(dateTimePickerBegin2.Value, dateTimePickerEnd2.Value, "ValueTime," + sFields, UnitNO);

                if (dtData.Rows.Count == 0)
                {
                    sSql = "delete QueryAlarm where QueryDate='" + sTime + "'";
                    try { SQLHelper.ExecuteSql(sSql); }
                    catch { }
                    MessageBox.Show("无数据!");
                    return;
                }
                chart1.DataSource = dtData;
                this.chart1.DataBind();

                sSql = "delete QueryAlarm where QueryDate='" + sTime + "'";
                try { SQLHelper.ExecuteSql(sSql); }
                catch { }
            }
            catch (Exception e)
            {
                WriteLog.WriteLogs("展示历史曲线报错:" + e.ToString());
            }
        }
Beispiel #2
0
 public void ShowLines()
 {
     if (sExcelCells.Length > 0)
     {
         Series series = null;
         chart1.Series.Clear();
         foreach (DataRow row in m_dtCheckedTags.Rows)
         {
             series = chart1.Series.Add(row["ExcelCell"].ToString());
             //series.LegendText = row["TagDesc"].ToString() + "(" + row["unit"].ToString() + ")";
             series.XValueType    = System.Windows.Forms.DataVisualization.Charting.ChartValueType.DateTime;
             series.XValueMember  = "ValueTime";
             series.YValueType    = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Double;
             series.YValueMembers = "F" + row["id"].ToString();
             series.Color         = Color.FromArgb(Rnd(), Rnd(), Rnd());
             series.ChartType     = SeriesChartType.Area;
         }
         m_dtLineData      = TagValue.QueryDBData(dateTimePickerBegin2.Value, dateTimePickerEnd2.Value, "ValueTime," + sExcelCells, UnitNO);
         chart1.DataSource = m_dtLineData;
         chart1.DataBind();
         //chart1.Series[0].Points[m_dtLineData.Rows.Count - 1].BorderWidth = 5;
         //chart1.Series[0].Points[m_dtLineData.Rows.Count - 1].BorderColor = Color.White;
         //chart1.Series[0].Points[m_dtLineData.Rows.Count - 1].Label = labelTag.TagDesc + "实时值:" + chart1.Series[0].Points[m_dtLineData.Rows.Count - 1].YValues[0].ToString("0.##") + labelTag.TagUnit;
         //if (iTotalID > 0)
         //    chart1.Series[0].Points[m_dtLineData.Rows.Count - 1].Label += "\n" + labelTag.TagDesc + "累计值:" + CalTree.GetTotalValue(iTotalID).ToString("0.##") + sTotalUnit;
         //chart1.Series[0].Points[m_dtLineData.Rows.Count - 1].LabelForeColor = Color.White;
         //MinMaxValue mmv = CalTree.GetMinMaxValue("F" + labelTag.TagID);
         //chart1.ChartAreas[0].AxisX.Title = "供热期累计小时数:" + CalTree.GetTotalHours().ToString("0.0000")
         //    + "                累计开始时间:" + mmv.BeginDateString + "\n" + labelTag.TagDesc + "最小值:"
         //    + Math.Round(mmv.MinValue / 10000, 4).ToString("0.0000") + "        " + labelTag.TagDesc + "最小值时间:" + mmv.MinDateString
         //    + "\n" + labelTag.TagDesc + "最大值:" + Math.Round(mmv.MaxValue / 10000, 4).ToString("0.0000") + "        " + labelTag.TagDesc + "最大值时间:"
         //    + mmv.MaxDateString + "\n" + labelTag.TagDesc + "平均值:" + mmv.AvgValue + labelTag.TagUnit;
     }
 }
Beispiel #3
0
        public void ShowLines()
        {
            if (sExcelCells.Length > 0)
            {
                mutiLineDesc = "";
                Series series = null;
                chart1.Series.Clear();
                foreach (DataRow row in m_dtCheckedTags.Rows)
                {
                    mutiLineDesc += row["TagDesc"] + ","; //用于导出的时候

                    series = chart1.Series.Add(row["ExcelCell"].ToString());
                    if (row["adjustValue"].ToString().Contains("F3004"))
                    {
                        series.LegendText = row["TagDesc"].ToString() + "(绝对)" + "(" + row["unit"].ToString() + ")";
                    }
                    else
                    {
                        series.LegendText = row["TagDesc"].ToString() + "(" + row["unit"].ToString() + ")";
                    }
                    series.XValueType    = System.Windows.Forms.DataVisualization.Charting.ChartValueType.DateTime;
                    series.XValueMember  = "ValueTime";
                    series.YValueType    = System.Windows.Forms.DataVisualization.Charting.ChartValueType.Double;
                    series.YValueMembers = "F" + row["id"].ToString();
                    series.Color         = Color.FromArgb(Rnd(), Rnd(), Rnd());
                    series.ChartType     = SeriesChartType.Line;
                }
                m_dtLineData      = TagValue.QueryDBData(dateTimePickerBegin2.Value, dateTimePickerEnd2.Value, "ValueTime," + sExcelCells, UnitNO);
                chart1.DataSource = m_dtLineData;
                chart1.DataBind();
            }
        }
Beispiel #4
0
 private void button2_Click(object sender, EventArgs e)
 {
     iIndex       = 0;
     m_dtLineData = TagValue.QueryDBData(dateTimePickerBegin2.Value, dateTimePickerEnd2.Value, "*", UnitNO);
     foreach (DataRowView row in m_viewTagValue)
     {
         row["TagValue"] = m_dtLineData.Rows[iIndex]["F" + row["id"].ToString()];
     }
 }
Beispiel #5
0
        private void btnQuery_Click(object sender, EventArgs e)
        {
            try
            {
                string sFields = "F" + labelTag.TagID.ToString();

                lblQueryWait.Visible = true;
                lblQueryWait.Refresh();
                timer2.Enabled = true;
                string sTime = PublicFunction.DateTimeToStringWithfff(DateTime.Now);
                string sSql  = "insert into QueryAlarm(QueryDate,StartTime,EndTime,QueryFields,UnitNO,AlarmDesc) values('"
                               + sTime + "','" + dateTimePickerBegin2.Value + "','" + dateTimePickerEnd2.Value + "','" + sFields + "',"
                               + UnitNO + ",'查询数据时,未按提示等待,做其他操作造成程序退出!')";
                try { SQLHelper.ExecuteSql(sSql); }
                catch { }

                if (sExcelCells.Length > 0)
                {
                    sFields = sExcelCells;
                }
                m_dtLineData      = TagValue.QueryDBData(dateTimePickerBegin2.Value, dateTimePickerEnd2.Value, "ValueTime," + sFields, UnitNO);
                chart1.DataSource = m_dtLineData;
                chart1.DataBind();
                this.Text = sTitle + "--历史查询";
                timerChartBind.Enabled = false;

                sSql = "delete QueryAlarm where QueryDate='" + sTime + "'";
                try { SQLHelper.ExecuteSql(sSql); }
                catch { }
            }
            finally
            {
                lblQueryWait.Visible = false;
                lblQueryWait.Refresh();
                timer2.Enabled = false;
            }
        }