ReceivedData.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace VehicleControlSystem.ControlLayer.Serial.DataModel
  7. {
  8. public enum eDataKind
  9. {
  10. Voltage = 0, //V
  11. Current, //A
  12. BatteryState,
  13. ChargeCompleteTime, //Min
  14. DisChargeCompleteTime, //Min
  15. SOC, //%
  16. SOH, //%
  17. ResidualCapacity,//Ah
  18. ResidualEnergy,//Wh
  19. Temperature,//C
  20. }
  21. public enum eBatteryState
  22. {
  23. OverVolte,
  24. LowVolte,
  25. OverChargeCurrent,
  26. OverDisChargeCurrent,
  27. HightTemperature,
  28. LowTemperature,
  29. BMUError,
  30. }
  31. public class ReceivedData
  32. {
  33. public eDataKind DataKind { get; set; } = eDataKind.BatteryState;
  34. public eBatteryState BatteryState { get; set; }
  35. public string OrgVule { get; set; }
  36. public double? Value {
  37. get
  38. {
  39. if ( this.DataKind != eDataKind.BatteryState )
  40. {
  41. double dOrg = 0d;
  42. double.TryParse( this.OrgVule , out dOrg );
  43. return dOrg;
  44. }
  45. else
  46. {
  47. return null;
  48. }
  49. }
  50. set
  51. {
  52. if(Value != (double)value)
  53. {
  54. this.OrgVule = value.ToString();
  55. this.IsChanged = true;
  56. }
  57. }
  58. }
  59. //public double Value
  60. //{
  61. // get { return Value; }
  62. //}
  63. public string OrgValue { get; set; } = "0";
  64. public double Scale { get; set; }
  65. public string Unit { get; set; } //단위를 붙이기 위해
  66. public bool IsChanged { get; set; }
  67. public ReceivedData(eDataKind kind)
  68. {
  69. this.DataKind = kind;
  70. }
  71. //public override string ToString()
  72. //{
  73. // return this.Value.ToString() + " " + this.Unit;
  74. //}
  75. public ReceivedData Clone( )
  76. {
  77. return ( ReceivedData )MemberwiseClone();
  78. }
  79. }
  80. }