Esempio n. 1
0
        public bool Read()
        {
            BinaryReader br = null;

            mDataList = new List <RealData>();
            if (!File.Exists(Fname))
            {
                return(false);
            }
            var flag = false;

            try {
                br = new BinaryReader(new FileStream(Fname, FileMode.Open));
                var pos    = 0;
                var length = br.BaseStream.Length;
                while (pos < length)
                {
                    var nr = new RealData();
                    nr.T1 = br.ReadSingle();
                    nr.T2 = br.ReadSingle();
                    nr.H1 = br.ReadSingle();
                    nr.H2 = br.ReadSingle();
                    var a = br.ReadInt64();
                    var t = new DateTime(a);
                    nr.Time = t;
                    if (!mDataList.Contains(nr))
                    {
                        mDataList.Add(nr);
                    }
                    pos += 24;
                }
                flag = true;
            } catch {
            } finally {
                if (br != null)
                {
                    br.Close();
                }
            }
            return(flag);
        }
Esempio n. 2
0
        public void Add(RealData value)
        {
            if (mDataList == null)
            {
                mDataList = new List <RealData>();
            }
            if (mDataList.Contains(value))
            {
                return;
            }
            mDataList.Add(value);
            var sl = mDataList.Count - DataCount;

            if (sl > 0)
            {
                for (var i = 0; i < sl; i++)
                {
                    mDataList.RemoveAt(0);
                }
            }
        }
Esempio n. 3
0
        void UpdatePointList()
        {
            x1 = DateTime.Now;
            x0 = x1.AddSeconds(-DisplayTimeSpan);

            var x = x0;
            int i;

            for (i = 1; i < DisplayTimeSpan / timeGap; i++)
            {
                TopTemp[i - 1] = TopTemp[i];
                BMTTemp[i - 1] = BMTTemp[i];
                TopHR[i - 1]   = TopHR[i];
                BMTHR[i - 1]   = BMTHR[i];
                date[i - 1]    = date[i];
            }
            TopTemp[i - 1] = double.Parse(myOPC.Items[PLCTagName.TopTemp.ToString()].Value.ToString());
            BMTTemp[i - 1] = double.Parse(myOPC.Items[PLCTagName.BTMTemp.ToString()].Value.ToString());
            TopHR[i - 1]   = double.Parse(myOPC.Items[PLCTagName.TopHR.ToString()].Value.ToString());
            BMTHR[i - 1]   = double.Parse(myOPC.Items[PLCTagName.BTMHR.ToString()].Value.ToString());
            date[i - 1]    = new XDate(x1).XLDate;

            for (var j = 0; j < DisplayTimeSpan / timeGap; j++)
            {
                TempAVG[j] = (TopTemp[j] + BMTTemp[j]) / 2.0;
                HRAVG[j]   = (TopHR[j] + BMTHR[j]) / 2.0;
            }

            var r = new RealData();

            r.T1   = (float)TopTemp[i - 1];
            r.T2   = (float)BMTTemp[i - 1];
            r.H1   = (float)TopHR[i - 1];
            r.H2   = (float)BMTHR[i - 1];
            r.Time = x1;
            rdo.Add(r);

            LTopTemp = new PointPairList(date, TopTemp);
            LBMTTemp = new PointPairList(date, BMTTemp);
            LTopHR   = new PointPairList(date, TopHR);
            LBMTHR   = new PointPairList(date, BMTHR);



            var g1 = GC.MasterPane[0];
            var g2 = GC.MasterPane[1];

            g1.CurveList.Clear();
            g2.CurveList.Clear();


            CurveItem c = g1.AddCurve("温度上", LTopTemp, Color.Blue, SymbolType.None);

            c = g1.AddCurve("温度下", LBMTTemp, Color.YellowGreen, SymbolType.None);
            c = g1.AddCurve("温度", new PointPairList(date, TempAVG), Color.DarkRed, SymbolType.None);


            c = g2.AddCurve("湿度上", LTopHR, Color.MediumVioletRed, SymbolType.None);
            //  c.IsY2Axis = true;
            c = g2.AddCurve("湿度下", LBMTHR, Color.BlueViolet, SymbolType.None);

            c = g2.AddCurve("湿度", new PointPairList(date, HRAVG), Color.Blue, SymbolType.None);
            //  c.IsY2Axis = true;
            g1.XAxis.Scale.Max = date[i - 1];
            g1.XAxis.Scale.Min = date[minIndex];
            g2.XAxis.Scale.Max = date[i - 1];
            g2.XAxis.Scale.Min = date[minIndex];

            g1.AxisChange();
            g2.AxisChange();

            SetScalFormat(g1.XAxis, g1);
            SetScalFormat(g2.XAxis, g2);

            if (checkBox1.Checked)
            {
                GC.MasterPane[0].CurveList["温度"].IsVisible = true;
                GC.MasterPane[1].CurveList["湿度"].IsVisible = true;
            }
            else
            {
                GC.MasterPane[0].CurveList["温度"].IsVisible = false;
                GC.MasterPane[1].CurveList["湿度"].IsVisible = false;
            }

            GC.Refresh();
        }