| | | 1 | | using pva.SuperV.Common; |
| | | 2 | | using pva.SuperV.Engine.Exceptions; |
| | | 3 | | using pva.SuperV.Engine.Processing; |
| | | 4 | | using System.Text.Json.Serialization; |
| | | 5 | | |
| | | 6 | | namespace pva.SuperV.Engine.HistoryStorage |
| | | 7 | | { |
| | | 8 | | /// <summary> |
| | | 9 | | /// History repository to store history of instance values. |
| | | 10 | | /// </summary> |
| | | 11 | | /// <param name="name">Name of the history repository.</param> |
| | 171 | 12 | | public class HistoryRepository(string name) |
| | | 13 | | { |
| | | 14 | | /// <summary> |
| | | 15 | | /// Gets the history repository name. |
| | | 16 | | /// </summary> |
| | | 17 | | /// <value> |
| | | 18 | | /// The name. |
| | | 19 | | /// </value> |
| | 2879 | 20 | | public string Name { get; } = IdentifierValidation.ValidateIdentifier("history repository", name); |
| | | 21 | | |
| | | 22 | | /// <summary> |
| | | 23 | | /// Gets or sets the history storage engine used to store values. |
| | | 24 | | /// </summary> |
| | | 25 | | /// <value> |
| | | 26 | | /// The history storage engine. |
| | | 27 | | /// </value> |
| | | 28 | | [JsonIgnore] |
| | 3722 | 29 | | public IHistoryStorageEngine? HistoryStorageEngine { get; set; } |
| | | 30 | | |
| | | 31 | | /// <summary> |
| | | 32 | | /// Gets of sets the history storage ID. |
| | | 33 | | /// </summary> |
| | | 34 | | /// <value> The history storage ID</value> |
| | 1939 | 35 | | public string? HistoryStorageId { get; set; } |
| | | 36 | | |
| | | 37 | | /// <summary> |
| | | 38 | | /// Upserts the repository in storage engine. |
| | | 39 | | /// </summary> |
| | | 40 | | /// <param name="projectName">Name of project.</param> |
| | | 41 | | /// <param name="historyStorageEngine">History storage engine.</param> |
| | | 42 | | internal void UpsertRepository(string projectName, IHistoryStorageEngine historyStorageEngine) => |
| | 119 | 43 | | HistoryStorageId = historyStorageEngine.UpsertRepository(projectName, this); |
| | | 44 | | |
| | | 45 | | /// <summary> |
| | | 46 | | /// Upserts a time series in storage engine. |
| | | 47 | | /// </summary> |
| | | 48 | | /// <param name="projectName">Name of project.</param> |
| | | 49 | | /// <param name="className">Name of class.</param> |
| | | 50 | | /// <param name="historizationProcessing">History processing for which the time series is to be created.</param> |
| | | 51 | | /// <returns>Class time serie ID in repository</returns> |
| | | 52 | | /// <exception cref="NoHistoryStorageEngineException"></exception> |
| | | 53 | | internal string UpsertClassTimeSerie(string projectName, string className, IHistorizationProcessing historizatio |
| | 1635 | 54 | | { |
| | 1635 | 55 | | if (HistoryStorageEngine is null) |
| | 0 | 56 | | { |
| | 0 | 57 | | throw new NoHistoryStorageEngineException(); |
| | | 58 | | } |
| | 1635 | 59 | | return HistoryStorageEngine.UpsertClassTimeSerie(HistoryStorageId!, projectName, className, historizationPro |
| | 1634 | 60 | | } |
| | | 61 | | |
| | | 62 | | /// <summary> |
| | | 63 | | /// Historize instance values in storage engine |
| | | 64 | | /// </summary> |
| | | 65 | | /// <param name="historizationProcessingName">The name of the historization processing.</param> |
| | | 66 | | /// <param name="classTimeSerieId">The time series ID.</param> |
| | | 67 | | /// <param name="instance">The instance.</param> |
| | | 68 | | /// <param name="timestamp">the timestamp of the values</param> |
| | | 69 | | /// <param name="quality">The quality level of the values.</param> |
| | | 70 | | /// <param name="fieldsToHistorize">List of fields to be historized.</param> |
| | | 71 | | public void HistorizeValues(string historizationProcessingName, string classTimeSerieId, IInstance instance, Dat |
| | 97 | 72 | | { |
| | 97 | 73 | | HistoryStorageEngine?.HistorizeValues(HistoryStorageId!, historizationProcessingName, classTimeSerieId, inst |
| | 97 | 74 | | } |
| | | 75 | | } |
| | | 76 | | } |