AcquisitionItem.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. namespace OINA.Extender.WPF.Testharness
  2. {
  3. using System;
  4. using System.ComponentModel;
  5. using OINA.Extender.Acquisition.Ed;
  6. using OINA.Extender.Data.Ed;
  7. /// <summary>
  8. /// Item to encapsulate an acquisition
  9. /// </summary>
  10. public class AcquisitionItem : INotifyPropertyChanged
  11. {
  12. /// <summary>
  13. /// Gets the ed spectrum.
  14. /// </summary>
  15. /// <value>
  16. /// The ed spectrum.
  17. /// </value>
  18. public IEdSpectrum EdSpectrum { get; private set; }
  19. /// <summary>
  20. /// Gets the label.
  21. /// </summary>
  22. /// <value>
  23. /// The label.
  24. /// </value>
  25. public string Label
  26. {
  27. get { return this.EdSpectrum.Label; }
  28. }
  29. /// <summary>
  30. /// Gets the aquisition mode.
  31. /// </summary>
  32. /// <value>
  33. /// The aquisition mode.
  34. /// </value>
  35. public EdAcquireMode AcquisitionMode { get; private set; }
  36. /// <summary>
  37. /// Gets the aquisition time.
  38. /// </summary>
  39. /// <value>
  40. /// The aquisition time.
  41. /// </value>
  42. public double AcquisitionTime { get; private set; }
  43. /// <summary>
  44. /// Gets the current progress.
  45. /// </summary>
  46. /// <value>
  47. /// The current progress.
  48. /// </value>
  49. public double CurrentProgress
  50. {
  51. get
  52. {
  53. if (this.AcquisitionMode == EdAcquireMode.LiveTime)
  54. {
  55. return this.EdSpectrum.LiveTimeSeconds * 1000.0;
  56. }
  57. else
  58. {
  59. return this.EdSpectrum.RealTimeSeconds * 1000.0;
  60. }
  61. }
  62. }
  63. /// <summary>
  64. /// Initializes a new instance of the <see cref="AcquisitionItem"/> class.
  65. /// </summary>
  66. /// <param name="edSpectrum">The ed spectrum.</param>
  67. /// <param name="mode">The mode.</param>
  68. /// <param name="acquisitionTime">The aquisition time.</param>
  69. public AcquisitionItem(IEdSpectrum edSpectrum, EdAcquireMode mode, double acquisitionTime)
  70. {
  71. this.EdSpectrum = edSpectrum;
  72. this.AcquisitionMode = mode;
  73. this.AcquisitionTime = acquisitionTime;
  74. this.EdSpectrum.DataChanged += this.OnEdSpectrumDataChanged;
  75. }
  76. /// <summary>
  77. /// Called when [ed spectrum data changed].
  78. /// </summary>
  79. /// <param name="sender">The sender.</param>
  80. /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
  81. public void OnEdSpectrumDataChanged(object sender, EventArgs e)
  82. {
  83. this.RaisePropertyChangedEvent(nameof(this.CurrentProgress));
  84. }
  85. /// <summary>
  86. /// Occurs when a property value changes.
  87. /// </summary>
  88. public event PropertyChangedEventHandler PropertyChanged;
  89. /// <summary>
  90. /// Raises the property changed event.
  91. /// </summary>
  92. /// <param name="propertyName">Name of the property.</param>
  93. private void RaisePropertyChangedEvent(string propertyName)
  94. {
  95. if (this.PropertyChanged != null)
  96. {
  97. this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
  98. }
  99. }
  100. }
  101. }