智慧水务管理系统 - 精河县供水工程综合管理平台

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. import Clock from "../Core/Clock.js";
  2. import defined from "../Core/defined.js";
  3. import DeveloperError from "../Core/DeveloperError.js";
  4. import Event from "../Core/Event.js";
  5. import JulianDate from "../Core/JulianDate.js";
  6. import createRawPropertyDescriptor from "./createRawPropertyDescriptor.js";
  7. /**
  8. * Represents desired clock settings for a particular {@link DataSource}. These settings may be applied
  9. * to the {@link Clock} when the DataSource is loaded.
  10. *
  11. * @alias DataSourceClock
  12. * @constructor
  13. */
  14. function DataSourceClock() {
  15. this._definitionChanged = new Event();
  16. this._startTime = undefined;
  17. this._stopTime = undefined;
  18. this._currentTime = undefined;
  19. this._clockRange = undefined;
  20. this._clockStep = undefined;
  21. this._multiplier = undefined;
  22. }
  23. Object.defineProperties(DataSourceClock.prototype, {
  24. /**
  25. * Gets the event that is raised whenever a new property is assigned.
  26. * @memberof DataSourceClock.prototype
  27. *
  28. * @type {Event}
  29. * @readonly
  30. */
  31. definitionChanged: {
  32. get: function () {
  33. return this._definitionChanged;
  34. },
  35. },
  36. /**
  37. * Gets or sets the desired start time of the clock.
  38. * See {@link Clock#startTime}.
  39. * @memberof DataSourceClock.prototype
  40. * @type {JulianDate}
  41. */
  42. startTime: createRawPropertyDescriptor("startTime"),
  43. /**
  44. * Gets or sets the desired stop time of the clock.
  45. * See {@link Clock#stopTime}.
  46. * @memberof DataSourceClock.prototype
  47. * @type {JulianDate}
  48. */
  49. stopTime: createRawPropertyDescriptor("stopTime"),
  50. /**
  51. * Gets or sets the desired current time when this data source is loaded.
  52. * See {@link Clock#currentTime}.
  53. * @memberof DataSourceClock.prototype
  54. * @type {JulianDate}
  55. */
  56. currentTime: createRawPropertyDescriptor("currentTime"),
  57. /**
  58. * Gets or sets the desired clock range setting.
  59. * See {@link Clock#clockRange}.
  60. * @memberof DataSourceClock.prototype
  61. * @type {ClockRange}
  62. */
  63. clockRange: createRawPropertyDescriptor("clockRange"),
  64. /**
  65. * Gets or sets the desired clock step setting.
  66. * See {@link Clock#clockStep}.
  67. * @memberof DataSourceClock.prototype
  68. * @type {ClockStep}
  69. */
  70. clockStep: createRawPropertyDescriptor("clockStep"),
  71. /**
  72. * Gets or sets the desired clock multiplier.
  73. * See {@link Clock#multiplier}.
  74. * @memberof DataSourceClock.prototype
  75. * @type {number}
  76. */
  77. multiplier: createRawPropertyDescriptor("multiplier"),
  78. });
  79. /**
  80. * Duplicates a DataSourceClock instance.
  81. *
  82. * @param {DataSourceClock} [result] The object onto which to store the result.
  83. * @returns {DataSourceClock} The modified result parameter or a new instance if one was not provided.
  84. */
  85. DataSourceClock.prototype.clone = function (result) {
  86. if (!defined(result)) {
  87. result = new DataSourceClock();
  88. }
  89. result.startTime = this.startTime;
  90. result.stopTime = this.stopTime;
  91. result.currentTime = this.currentTime;
  92. result.clockRange = this.clockRange;
  93. result.clockStep = this.clockStep;
  94. result.multiplier = this.multiplier;
  95. return result;
  96. };
  97. /**
  98. * Returns true if this DataSourceClock is equivalent to the other
  99. *
  100. * @param {DataSourceClock} [other] The other DataSourceClock to compare to.
  101. * @returns {boolean} <code>true</code> if the DataSourceClocks are equal; otherwise, <code>false</code>.
  102. */
  103. DataSourceClock.prototype.equals = function (other) {
  104. return (
  105. this === other ||
  106. (defined(other) &&
  107. JulianDate.equals(this.startTime, other.startTime) &&
  108. JulianDate.equals(this.stopTime, other.stopTime) &&
  109. JulianDate.equals(this.currentTime, other.currentTime) &&
  110. this.clockRange === other.clockRange &&
  111. this.clockStep === other.clockStep &&
  112. this.multiplier === other.multiplier)
  113. );
  114. };
  115. /**
  116. * Assigns each unassigned property on this object to the value
  117. * of the same property on the provided source object.
  118. *
  119. * @param {DataSourceClock} source The object to be merged into this object.
  120. */
  121. DataSourceClock.prototype.merge = function (source) {
  122. //>>includeStart('debug', pragmas.debug);
  123. if (!defined(source)) {
  124. throw new DeveloperError("source is required.");
  125. }
  126. //>>includeEnd('debug');
  127. this.startTime = this.startTime ?? source.startTime;
  128. this.stopTime = this.stopTime ?? source.stopTime;
  129. this.currentTime = this.currentTime ?? source.currentTime;
  130. this.clockRange = this.clockRange ?? source.clockRange;
  131. this.clockStep = this.clockStep ?? source.clockStep;
  132. this.multiplier = this.multiplier ?? source.multiplier;
  133. };
  134. /**
  135. * Gets the value of this clock instance as a {@link Clock} object.
  136. *
  137. * @returns {Clock} The modified result parameter or a new instance if one was not provided.
  138. */
  139. DataSourceClock.prototype.getValue = function (result) {
  140. if (!defined(result)) {
  141. result = new Clock();
  142. }
  143. result.startTime = this.startTime ?? result.startTime;
  144. result.stopTime = this.stopTime ?? result.stopTime;
  145. result.currentTime = this.currentTime ?? result.currentTime;
  146. result.clockRange = this.clockRange ?? result.clockRange;
  147. result.multiplier = this.multiplier ?? result.multiplier;
  148. result.clockStep = this.clockStep ?? result.clockStep;
  149. return result;
  150. };
  151. export default DataSourceClock;