Esempio n. 1
0
        /// <summary>
        /// 实时更新数据
        /// </summary>
        /// <param name="data"></param>
        public void AddSampleData(string data)
        {
            //当有采样点的时候添加采样点到缓冲区
            ControlDataEntity entity = ControlDataEntity.ConvertEntity(data);

            if (entity == null)
            {
                return;
            }
            Monitor.Enter(this);//锁定,保持同步
            ctrlData.AddData(entity);
            if (!isOnScroll)
            {
                //确定begin和end索引点
                CalcDrawIndex();
                //首先从缓冲区拿到对应的数据
                dataList = ctrlData.GetDataSequnce(beginIndex, endIndex);
                //转换数据到点
                ConvertDataToPoint();
                //通知客户端进行绘图
                Invalidate();
                //Refresh();
            }
            Monitor.Exit(this);//锁定,保持同步
        }
Esempio n. 2
0
        public static ControlDataEntity ConvertEntity(string data)
        {
            ControlDataEntity DataEntity = new ControlDataEntity();
            DataEntity        entity     = JsonConvert.DeserializeObject <DataEntity>(data);

            DataEntity.entity      = entity;
            DataEntity.isDrawTime  = false;
            DataEntity.isDrawNum   = false;
            DataEntity.isDrawVLine = false;
            return(DataEntity);
        }
Esempio n. 3
0
        public void SetSampleData(int index, string data)
        {
            //当有采样点的时候添加采样点到缓冲区
            ControlDataEntity entity = ControlDataEntity.ConvertEntity(data);

            if (entity == null)
            {
                return;
            }
            Monitor.Enter(this); //锁定,保持同步
            ctrlData.SetData(index, entity);
            Monitor.Exit(this);  //锁定,保持同步
        }
Esempio n. 4
0
 public void AddSampleData(string[] data)
 {
     //当有采样点的时候添加采样点到缓冲区
     ctrlData.AddData(ControlDataEntity.ConvertEntity(data));
     //确定begin和end索引点
     CalcDrawIndex();
     //首先从缓冲区拿到对应的数据
     dataList = ctrlData.GetDataSequnce(beginIndex, endIndex);
     //转换数据到点
     ConvertDataToPoint();
     //通知客户端进行绘图
     Invalidate();
     //Refresh();
 }
Esempio n. 5
0
        public static ControlDataEntity ConvertEntity(string[] data)
        {
            ControlDataEntity entity = new ControlDataEntity();

            entity.sampleTime = data[0];

            entity.childHeart1 = Convert.ToInt32(data[1]);
            entity.childHeart2 = Convert.ToInt32(data[2]);

            entity.palaceCompression = Convert.ToInt32(data[3]);
            entity.fetalMovement     = Convert.ToInt32(data[4]);

            entity.isDrawTime  = false;
            entity.isDrawNum   = false;
            entity.isDrawVLine = false;
            return(entity);
        }
Esempio n. 6
0
 /// <summary>
 /// 对数据进行预处理,因为有些数据超出了坐标
 /// </summary>
 /// <param name="controlDataEntity"></param>
 private void PreHandleSampleData(ref ControlDataEntity controlDataEntity)
 {
     //throw new NotImplementedException();
     if (controlDataEntity.entity.FetalHeart1 > 210)
     {
         controlDataEntity.entity.FetalHeart2 = 210;
     }
     if (controlDataEntity.entity.FetalHeart1 < 60)
     {
         controlDataEntity.entity.FetalHeart1 = 60;
     }
     if (controlDataEntity.entity.FetalHeart2 > 210)
     {
         controlDataEntity.entity.FetalHeart2 = 210;
     }
     if (controlDataEntity.entity.FetalHeart2 < 60)
     {
         controlDataEntity.entity.FetalHeart2 = 60;
     }
     if (controlDataEntity.entity.FetalMove > 100)
     {
         controlDataEntity.entity.FetalMove = 100;
     }
     if (controlDataEntity.entity.FetalMove < 0)
     {
         controlDataEntity.entity.FetalMove = 0;
     }
     if (controlDataEntity.entity.TOCOValue > 100)
     {
         controlDataEntity.entity.TOCOValue = 100;
     }
     if (controlDataEntity.entity.TOCOValue < 0)
     {
         controlDataEntity.entity.TOCOValue = 0;
     }
 }
Esempio n. 7
0
 public void AddData(ControlDataEntity entity)
 {
     datalist.Add(entity);
 }
Esempio n. 8
0
        /// <summary>
        /// 将数据转成坐标点
        /// </summary>
        public void ConvertDataToPoint()
        {
            if (dataList.Count < 2)
            {
                return;
            }
            //第一步:根据索引点获取需要绘制的数据
            //List<int> dataInt = ctrlData.GetChildHeart1Data(beginIndex, endIndex);
            //第三部:将采样数据转换成坐标点
            dataPointChildHeart1.Clear();
            dataPointChildHeart2.Clear();
            dataPointPalaceCompression.Clear();
            dataPointFetalMovement.Clear();

            int ipos = 0;
            int hig  = ctrlProperty.topRect.Height / 15;

            for (int i = 0; i < dataList.Count; i++)
            {
                ControlDataEntity entity = dataList[i];
                //预处理采集点
                //PreHandleSampleData(ref entity);
                Point p = new Point();
                p.X = i * pix + ctrlProperty.topRect.Left;
                p.Y = ctrlProperty.topRect.Top + (210 - entity.entity.FetalHeart1) * (hig * 15) / (210 - 60);
                if (entity.entity.HR1_SensorDrop == 0)
                {
                    dataPointChildHeart1.Add(p);
                }

                p.Y = ctrlProperty.topRect.Top + (210 - entity.entity.FetalHeart2) * (hig * 15) / (210 - 60);
                if (entity.entity.HR2_SensorDrop == 0)
                {
                    dataPointChildHeart2.Add(p);
                }

                p.Y = ctrlProperty.botRect.Top + (100 - entity.entity.TOCOValue) * (hig * 10) / (100 - 0);
                if (entity.entity.TOCOSensorDrop == 0)
                {
                    dataPointPalaceCompression.Add(p);
                }
                p.Y = ctrlProperty.botRect.Top + (100 - entity.entity.FetalMove) * (hig * 10) / (100 - 0);
                if (entity.entity.FetalMove != -1000)
                {
                    dataPointFetalMovement.Add(p);
                }
                else
                {
                    dataPointFetalMovement.Clear();
                }

                //ipos = ipos + pix;
            }
            for (int i = 0; i < (endIndex - beginIndex); i++)
            {
                DateTime timei = Convert.ToDateTime(dataList[i].entity.SampleTime);
                DateTime time0 = Convert.ToDateTime(ctrlData.datalist[0].entity.SampleTime);

                Int64 seci = timei.Ticks;
                Int64 sec0 = time0.Ticks;

                TimeSpan ts1 = new TimeSpan(seci); //获取当前时间的刻度数
                                                   //执行某操作
                TimeSpan ts2 = new TimeSpan(sec0);

                TimeSpan ts = ts2.Subtract(ts1).Duration(); //时间差的绝对值

                int sec = Convert.ToInt32(ts.TotalSeconds); //执行时间的总秒数
                if (sec % 60 == 0)
                {
                    dataList[i].isDrawTime = true;
                    // 四分钟显示刻度
                    if (sec % 240 == 0)
                    {
                        dataList[i].isDrawNum = true;
                    }
                    dataList[i].isDrawVLine = false;
                }
                else if (sec % 15 == 0)
                {
                    dataList[i].isDrawTime  = false;
                    dataList[i].isDrawVLine = true;
                }
            }
            return;
        }
Esempio n. 9
0
        /*private void DrawBackVLine(PaintEventArgs e, string tag)
         * {
         *  if (dataList.Count < 2)
         *  {
         *      return;
         *  }
         *  Graphics g = e.Graphics; //创建画板,这里的画板是由Form提供的.
         *  Pen p1 = new Pen(Color.FromArgb(169, 169, 169), 2);
         *  Pen p2 = new Pen(Color.FromArgb(211, 211, 211), 1);
         *
         *  Rectangle rect;
         *  int[] value;
         *  int hig = ctrlProperty.topRect.Height / 15;
         *  if (tag == "top")
         *  {
         *      rect = ctrlProperty.topRect;
         *      value = ControlDataEntity.tValue;
         *      hig *= 3;
         *  }
         *  else
         *  {
         *      rect = ctrlProperty.botRect;
         *      value = ControlDataEntity.bValue;
         *      hig *= 2;
         *  }
         *
         *
         *  // 刻度文字居中
         *  StringFormat stringFormat = new StringFormat();
         *  stringFormat.LineAlignment = StringAlignment.Center;
         *  stringFormat.Alignment = StringAlignment.Center;
         *  // 刻度文字
         *  Font font1 = new Font("Arial", 8, FontStyle.Bold);
         *
         *  // 时间文字
         *  Font font = new Font("Arial", 9);
         *
         *  //画竖线
         *  for (int i = 0; i < dataList.Count; i++)
         *  {
         *      if (dataList[i].isDrawVLine)
         *      {
         *          g.DrawLine(p2, new Point(dataPointChildHeart1[i].X + paddingLeft, rect.Top), new Point(dataPointChildHeart1[i].X + paddingLeft, rect.Bottom));
         *      }
         *
         *      if (dataList[i].isDrawTime)
         *      {
         *          g.DrawLine(p1, new Point(dataPointChildHeart1[i].X + paddingLeft, rect.Top), new Point(dataPointChildHeart1[i].X + paddingLeft, rect.Bottom));
         *
         *          if (tag == "bottom")
         *          {
         *              g.DrawString(dataList[i].sampleTime, font, Brushes.Gray, dataPointChildHeart1[i].X + paddingLeft, rect.Bottom + 10);
         *          }
         *
         *      }
         *
         *      if (dataList[i].isDrawNum)
         *      {
         *          for (int j = 0; j < ControlDataEntity.tValue.Length; j++)
         *          {
         *              //g.FillRectangle(Brushes.White, dataPointChildHeart1[i].X, rect.Top + hig * j - paddingLeft/2, 20, 10);
         *              g.DrawString(value[j].ToString(), font1, Brushes.Gray, dataPointChildHeart1[i].X + paddingLeft, rect.Top + hig * j, stringFormat);
         *          }
         *      }
         *  }
         * }*/
        /// <summary>
        /// 画竖线
        /// </summary>
        /// <param name="e"></param>
        /// <param name="tag"></param>
        private void DrawBackVLine(PaintEventArgs e, string tag)
        {
            List <ControlDataEntity> dataTemp = new List <ControlDataEntity>();

            if (dataList.Count >= 0 && dataList.Count < ctrlProperty.topRect.Width / pix)
            {
                ControlDataEntity[] dataArray = new ControlDataEntity[dataList.Count];
                dataList.CopyTo(dataArray, 0);
                dataTemp = dataArray.ToList <ControlDataEntity>();
                //dataList.CopyTo(dataTemp.ToArray(), 0);
                DateTime timei = DateTime.Now;
                if (dataList.Count > 0)
                {
                    timei = Convert.ToDateTime(dataList[dataList.Count - 1].entity.SampleTime);
                }

                for (int i = dataList.Count; i < ctrlProperty.topRect.Width / pix; i++)
                {
                    ControlDataEntity entity = new ControlDataEntity();
                    if (i != 0)
                    {
                        timei = timei.AddSeconds(1);
                    }

                    entity.entity.SampleTime = timei.ToString();

                    DateTime time0 = DateTime.Now;
                    if (ctrlData.datalist.Count > 0)
                    {
                        time0 = Convert.ToDateTime(ctrlData.datalist[0].entity.SampleTime);
                    }

                    Int64 seci = timei.Ticks;
                    Int64 sec0 = time0.Ticks;

                    TimeSpan ts1 = new TimeSpan(seci); //获取当前时间的刻度数
                                                       //执行某操作
                    TimeSpan ts2 = new TimeSpan(sec0);

                    TimeSpan ts  = ts2.Subtract(ts1).Duration();     //时间差的绝对值
                    int      sec = Convert.ToInt32(ts.TotalSeconds); //执行时间的总秒数
                    if (sec % 60 == 0)
                    {
                        entity.isDrawTime = true;
                        // 四分钟显示刻度
                        if (sec % 240 == 0)
                        {
                            entity.isDrawNum = true;
                        }
                        entity.isDrawVLine = false;
                    }
                    else if (sec % 15 == 0)
                    {
                        entity.isDrawTime  = false;
                        entity.isDrawVLine = true;
                    }
                    dataTemp.Add(entity);
                }
            }
            else
            {
                dataTemp = dataList;
            }

            /*if(dataList.Count<2)
             * {
             *  return;
             * }*/
            //如果采集点未满一屏幕,那么给datalist 充满值
            Graphics g  = e.Graphics; //创建画板,这里的画板是由Form提供的.
            Pen      p1 = new Pen(Color.FromArgb(169, 169, 169), 2);
            Pen      p2 = new Pen(Color.FromArgb(211, 211, 211), 1);

            Rectangle rect;

            int[] value;
            int   hig = ctrlProperty.topRect.Height / 15;

            if (tag == "top")
            {
                rect  = ctrlProperty.topRect;
                value = ControlDataEntity.tValue;
                hig  *= 3;
            }
            else
            {
                rect  = ctrlProperty.botRect;
                value = ControlDataEntity.bValue;
                hig  *= 2;
            }


            // 刻度文字居中
            StringFormat stringFormat = new StringFormat();

            stringFormat.LineAlignment = StringAlignment.Center;
            stringFormat.Alignment     = StringAlignment.Center;
            StringFormat stringFormat1 = new StringFormat();

            stringFormat1.LineAlignment = StringAlignment.Near;
            stringFormat1.Alignment     = StringAlignment.Near;
            // 刻度文字
            Font font1 = new Font("Arial", textSize, FontStyle.Bold);

            // 时间文字
            Font font = new Font("Arial", textSize, FontStyle.Bold);

            //画竖线
            int mark = 0;

            for (int i = 0; i < dataTemp.Count; i++)
            {
                int hig1   = ctrlProperty.topRect.Height / 15;
                int top    = 0;
                int bottom = 0;
                if (tag == "top")
                {
                    top    = rect.Top;
                    bottom = top + 15 * hig1;
                }
                else
                {
                    top    = rect.Top;
                    bottom = top + 10 * hig1;
                }
                if (dataTemp[i].isDrawVLine)
                {
                    g.DrawLine(p2, new Point(i * pix + paddingLeft, top), new Point(i * pix + paddingLeft, bottom));
                }

                if (dataTemp[i].isDrawTime)
                {
                    g.DrawLine(p1, new Point(i * pix + paddingLeft, top), new Point(i * pix + paddingLeft, bottom));

                    if (tag == "bottom")
                    {
                        string strTime = dataTemp[i].entity.SampleTime;
                        if (mark != 0)
                        {
                            string[] time = dataTemp[i].entity.SampleTime.Split(' ');
                            strTime = time[1];
                        }
                        mark++;
                        //string time = dataList[i].sampleTime.Substring(,)
                        g.DrawString(strTime, font, Brushes.Gray, new RectangleF {
                            X = i * pix + paddingLeft, Y = ctrlProperty.timeRect.Top, Width = 200, Height = ctrlProperty.timeRect.Height
                        }, stringFormat1);
                    }
                }
                if (dataTemp[i].isDrawNum)
                {
                    for (int j = 0; j < ControlDataEntity.tValue.Length; j++)
                    {
                        //g.FillRectangle(Brushes.White, dataPointChildHeart1[i].X, rect.Top + hig * j - paddingLeft/2, 20, 10);
                        g.DrawString(value[j].ToString(), font1, Brushes.Gray, i * pix + paddingLeft, rect.Top + hig * j, stringFormat);
                    }
                }
                if (tag == "top")
                {
                    if (isShowFetal1)
                    {
                        if (dataTemp[i].entity.bFetal1Alert)
                        {
                            if (i > 0)
                            {
                                if (!dataTemp[i - 1].entity.bFetal1Alert)
                                {
                                    DrawFetalAlert(e, new PointF()
                                    {
                                        X = i * pix + paddingLeft, Y = top
                                    });
                                    fetalAlertList.Add(new FetalAlertStruct()
                                    {
                                        x = i * pix + paddingLeft, y = top, width = 20, heigth = 20, content = dataTemp[i].entity.strFetal1AlertContent
                                    });
                                }
                            }
                        }
                    }
                    if (isShowFetal2)
                    {
                        if (dataTemp[i].entity.bFetal2Alert)
                        {
                            if (i > 0)
                            {
                                if (!dataTemp[i - 1].entity.bFetal2Alert)
                                {
                                    DrawFetalAlert(e, new PointF()
                                    {
                                        X = i * pix + paddingLeft, Y = top
                                    });
                                    fetalAlertList.Add(new FetalAlertStruct()
                                    {
                                        x = i * pix + paddingLeft, y = top, width = 20, heigth = 20, content = dataTemp[i].entity.strFetal2AlertContent
                                    });
                                }
                            }
                        }
                    }
                    //画手动胎动
                    if (dataTemp[i].entity.ManualFetalMove == 1)
                    {
                        int h = ctrlProperty.topRect.Top + (210 - normalFetalLow) * (hig * 15) / (210 - 60);
                        DrawManualFetalMove(e, new PointF()
                        {
                            X = i * pix + paddingLeft, Y = h
                        });
                    }
                    if (dataTemp[i].entity.FHRSame == 1)
                    {
                        DrawFetalCoincide(e, new PointF()
                        {
                            X = i * pix + paddingLeft, Y = top + 20
                        });
                    }
                }
                if (tag == "bottom")
                {
                    if (dataTemp[i].entity.Mark == 1)
                    {
                        DrawMark(e, new PointF()
                        {
                            X = i * pix + paddingLeft, Y = top
                        });
                    }
                }
                if (dataTemp[i].entity.bPcMark)
                {
                    DrawPcMark(e, new PointF()
                    {
                        X = i * pix + paddingLeft, Y = (float)(Height * dataTemp[i].entity.yPcMark)
                    }, dataTemp[i].entity.PcMark);
                }
            }
            return;
        }
Esempio n. 10
0
 public void SetData(int index, ControlDataEntity entity)
 {
     datalist[index] = entity;
 }