150 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			150 lines
		
	
	
		
			4.1 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
| using System;
 | |
| using System.Collections.Generic;
 | |
| using System.Linq;
 | |
| using System.Text;
 | |
| 
 | |
| namespace DrawGraph
 | |
| {
 | |
|     public class PhysioData : PointPair, IComparable
 | |
|     {
 | |
|         public PhysioData()
 | |
|         { }
 | |
|         private int _id;
 | |
|         private int _patientid;
 | |
|         private int _physiodataconfigid;
 | |
|         private DateTime _recordtime;
 | |
|         private double _value;
 | |
|         private string valueString;
 | |
|           
 | |
|         public PhysioDataConfig config { get; set; }
 | |
| 
 | |
|         /// <summary>
 | |
|         /// 
 | |
|         /// </summary>
 | |
|         public int Id
 | |
|         {
 | |
|             set { _id = value; }
 | |
|             get { return _id; }
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 
 | |
|         /// </summary>
 | |
|         public int PatientId
 | |
|         {
 | |
|             set { _patientid = value; }
 | |
|             get { return _patientid; }
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 
 | |
|         /// </summary>
 | |
|         public int PhysioDataConfigId
 | |
|         {
 | |
|             set { _physiodataconfigid = value; }
 | |
|             get { return _physiodataconfigid; }
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 
 | |
|         /// </summary>
 | |
|         public DateTime RecordTime
 | |
|         {
 | |
|             get
 | |
|             {
 | |
|                 int second = _recordtime.Second;
 | |
|                 _recordtime = _recordtime.AddSeconds(-second);
 | |
|                 return _recordtime;
 | |
|             }
 | |
|             set
 | |
|             {
 | |
|                 int second = value.Second;
 | |
|                 _recordtime = value.AddSeconds(-second);
 | |
|                 //得到整的分钟数
 | |
|                 this.X = new XDate(value);
 | |
|             }
 | |
|         }
 | |
|         public string ValueString
 | |
|         {
 | |
|             set
 | |
|             {
 | |
|                 valueString = value;
 | |
|                 double tempValue = -1; 
 | |
|                 if (double.TryParse(value , out tempValue))
 | |
|                 {
 | |
|                     Value = tempValue;
 | |
|                 }
 | |
| 
 | |
|             }
 | |
|             get { return valueString; }
 | |
|         }
 | |
|         /// <summary>
 | |
|         /// 
 | |
|         /// </summary>
 | |
|         public double Value
 | |
|         {
 | |
|             set
 | |
|             {
 | |
|                 _value = value;
 | |
|                 this.Y = value;
 | |
|             }
 | |
|             get { return _value; }
 | |
|         }
 | |
| 
 | |
| 
 | |
|         public bool isEquert(PhysioData pd)
 | |
|         { 
 | |
|             TimeSpan ts1 = new TimeSpan(RecordTime.Ticks);
 | |
|             TimeSpan ts2 = new TimeSpan(pd.RecordTime.Ticks);
 | |
|             double minDiff = (ts1.Subtract(ts2).TotalMinutes);
 | |
|             //如果外新加的点Y轴的值和X轴的值已经存在,删除当前位置的点  
 | |
|             if ((-2.5 < minDiff) && (minDiff < 2.5))
 | |
|             {
 | |
|                 return true;
 | |
|             }
 | |
|             return false;
 | |
|         }
 | |
|         public bool isEquertTrue(PhysioData pd, string collectInterval)
 | |
|         {
 | |
|             double yDiff = Value - pd.Value;
 | |
|             TimeSpan ts1 = new TimeSpan(RecordTime.Ticks);
 | |
|             TimeSpan ts2 = new TimeSpan(pd.RecordTime.Ticks);
 | |
|             double minDiff = (ts1.Subtract(ts2).TotalMinutes);
 | |
|             //如果外新加的点Y轴的值和X轴的值已经存在,删除当前位置的点  
 | |
|             if ((-1.5 < minDiff && minDiff < 1.5) && (-2 < yDiff && yDiff < 2))
 | |
|             {
 | |
|                 return true;
 | |
|             }
 | |
|             return false;
 | |
|         }
 | |
|         public PhysioData Clone()
 | |
|         {
 | |
|             PhysioData pdTemp = new PhysioData();
 | |
|             pdTemp.RecordTime = this.RecordTime;
 | |
|             pdTemp.ValueString = this.ValueString;
 | |
|             pdTemp.Value = this.Value;
 | |
|             pdTemp.PhysioDataConfigId = this.Id;
 | |
|             pdTemp.PatientId = this.PatientId;
 | |
|             pdTemp.config = this.config ;
 | |
|             return pdTemp;
 | |
|         }
 | |
|         public int CompareTo(object obj)
 | |
|         {
 | |
|             var pd = obj as PhysioData;
 | |
|             if (pd == null)
 | |
|             {
 | |
|                 throw new Exception("传入对象类型不正确");
 | |
|             }
 | |
|             if (pd.RecordTime > this.RecordTime)
 | |
|             {
 | |
|                 return -1;
 | |
|             }
 | |
|             else if (pd.RecordTime < this.RecordTime)
 | |
|             {
 | |
|                 return 1;
 | |
|             }
 | |
|             else
 | |
|             {
 | |
|                 return 0;
 | |
|             }
 | |
|         }
 | |
|     }
 | |
| }
 |