added Value Types endpoint for RTD8TM

master
Jan Beníček 2024-01-15 11:09:26 +01:00
parent ad784c21e0
commit 6dc7a1674d
2 changed files with 53 additions and 0 deletions

View File

@ -117,5 +117,26 @@ namespace API_SequentMicrosystems.Controllers
_RTDDAservice.SetCalibrationData(data); _RTDDAservice.SetCalibrationData(data);
} }
//GET api/RTDDA/ValueTypes
/// <summary>
/// Get ValueTypes data
/// </summary>
/// <returns>Sorted List of ValueTypes data responded with data by Ids of SortedList and array</returns>
[HttpGet("ValueTypes")]
public SortedList<byte, byte[]> GetValueTypes()
{
return _RTDDAservice.LoadValueTypes();
}
//POST api/RTDDA/ValueTypes
/// <summary>
/// Post ValueTypes data
/// </summary>
/// <param name="data">Sorted List of Value types data responded with data by Ids of SortedList and array</param>
[HttpPost("ValueTypes")]
public void PostValueTypes([FromBody] SortedList<byte, byte[]> data)
{
_RTDDAservice.SaveValueTypes(data);
}
} }
} }

View File

@ -274,5 +274,37 @@ namespace API_SequentMicrosystems.Services
#endregion #endregion
#region ValueTypes
/// <summary>
/// Save ValueTypes data to File
/// </summary>
public void SaveValueTypes(SortedList<byte, byte[]> data)
{
File.WriteAllText("RTDDA/ValueTypes.json", JsonConvert.SerializeObject(data));
}
/// <summary>
/// Load ValueTypes data from File
/// </summary>
/// <returns></returns>
public SortedList<byte, byte[]> LoadValueTypes()
{
try
{
#pragma warning disable CS8603 // Může jít o vrácený odkaz null.
return JsonConvert.DeserializeObject<SortedList<byte, byte[]>>(File.ReadAllText("RTDDA/ValueTypes.json"));
#pragma warning restore CS8603 // Může jít o vrácený odkaz null.
}
catch
{
return new();
}
}
#endregion
} }
} }