forked from ddrilling/AsbCloudServer
33 lines
923 B
C#
33 lines
923 B
C#
using AsbCloudApp.Services;
|
|
using AsbCloudDb.Model;
|
|
using System.Collections.Generic;
|
|
|
|
namespace AsbCloudInfrastructure.Services
|
|
{
|
|
public class SaubDataCache : ISaubDataCache
|
|
{
|
|
public TelemetryAnalysis CurrentAnalysis { get; set; }
|
|
|
|
private readonly Dictionary<int, List<DataSaubBase>> saubData =
|
|
new Dictionary<int, List<DataSaubBase>>();
|
|
|
|
public IEnumerable<DataSaubBase> GetOrCreateCache(int telemetryId)
|
|
{
|
|
if (!saubData.ContainsKey(telemetryId))
|
|
saubData[telemetryId] = new List<DataSaubBase>();
|
|
|
|
return saubData[telemetryId];
|
|
}
|
|
|
|
public void AddData(DataSaubBase data)
|
|
{
|
|
GetOrCreateCache(data.IdTelemetry);
|
|
|
|
saubData[data.IdTelemetry].Add(data);
|
|
|
|
if (saubData[data.IdTelemetry].Count > 10)
|
|
saubData[data.IdTelemetry].RemoveAt(1);
|
|
}
|
|
}
|
|
}
|