=== Summary: 675 files | 7 generated | 484 fresh | 4605 untracked | 4268 adopted | 355 marked | 466 validated-ok | 2+0 stale (sig+body) | 0 skipped | 0 failed | elapsed 11:08:11.442 (40091.44s) ===
This commit is contained in:
@@ -8,6 +8,7 @@ namespace adas_core.module.LightBeacons.Devices;
|
||||
/// The specific implementation of these methods will depend on the type of light beacon being used and the requirements of the application.
|
||||
/// </summary>
|
||||
/// <param name="options">A dictionary containing configuration options for the light beacon. This can include settings such as the beacon's IP address, port number, color configurations, and other relevant parameters.</param>
|
||||
/// <!-- aidoc:v1 sig=f70cccd -->
|
||||
public abstract class LightBeacon(EquatableDictionary<string, object> options)
|
||||
{
|
||||
/// <summary>
|
||||
@@ -19,24 +20,28 @@ public abstract class LightBeacon(EquatableDictionary<string, object> options)
|
||||
/// Turns the light beacon blue. This method should be implemented to control the beacon's hardware or software interface to change its color to blue.
|
||||
/// </summary>
|
||||
/// <returns>A task representing the asynchronous operation.</returns>
|
||||
/// <!-- aidoc:v1 sig=2fdc9f9 -->
|
||||
public abstract Task BlueCode();
|
||||
|
||||
/// <summary>
|
||||
/// Turns the light beacon red. This method should be implemented to control the beacon's hardware or software interface to change its color to red.
|
||||
/// </summary>
|
||||
/// <returns>A task representing the asynchronous operation.</returns>
|
||||
/// <!-- aidoc:v1 sig=8664798 -->
|
||||
public abstract Task RedCode();
|
||||
|
||||
/// <summary>
|
||||
/// Turns the light beacon yellow. This method should be implemented to control the beacon's hardware or software interface to change its color to yellow.
|
||||
/// </summary>
|
||||
/// <returns>A task representing the asynchronous operation.</returns>
|
||||
/// <!-- aidoc:v1 sig=7741a6b -->
|
||||
public abstract Task YellowCode();
|
||||
|
||||
/// <summary>
|
||||
/// Turns off the light beacon. This method should be implemented to control the beacon's hardware or software interface to turn off the light, regardless of its current color.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
/// <!-- aidoc:v1 sig=a171807 -->
|
||||
public abstract Task PowerOffLed();
|
||||
|
||||
/// <summary>
|
||||
@@ -45,11 +50,13 @@ public abstract class LightBeacon(EquatableDictionary<string, object> options)
|
||||
/// </summary>
|
||||
/// <param name="obs">The patient observation used to determine the appropriate color alert.</param>
|
||||
/// <returns>A task representing the asynchronous operation.</returns>
|
||||
/// <!-- aidoc:v1 sig=a91a8f7 -->
|
||||
public abstract Task GenerateColorAlert(PatientObservation obs);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the current color of the light beacon. This method should be implemented to query the beacon's hardware or software interface to determine its current color state and return it as a value from the LightBeaconColor enumeration.
|
||||
/// </summary>
|
||||
/// <returns>A task representing the asynchronous operation, with a result of the current color of the light beacon.</returns>
|
||||
/// <!-- aidoc:v1 sig=e132b45 -->
|
||||
public abstract Task<Domain.Enums.LightBeaconColor> GetBeaconColor();
|
||||
}
|
||||
@@ -7,6 +7,7 @@ namespace adas_core.module.LightBeacons.Devices;
|
||||
/// </summary>
|
||||
/// <param name="host">The host address of the LightBeacon device. This is typically the IP address or hostname used to connect to the device for controlling its LED states.</param>
|
||||
/// <param name="password">The password used for authenticating with the LightBeacon device. This is required to establish a connection and control the device's LED states securely.</param>
|
||||
/// <!-- aidoc:v1 sig=d775c30 -->
|
||||
public abstract class LightBeaconAbstract(string host, string password)
|
||||
{
|
||||
/// <summary>
|
||||
@@ -23,24 +24,28 @@ public abstract class LightBeaconAbstract(string host, string password)
|
||||
/// Abstract method to set the LightBeacon device to Code Blue state. This method should be implemented by each specific LightBeacon model to control the LED state accordingly.
|
||||
/// </summary>
|
||||
/// <param name="entry">An object parameter that can be used to pass additional information or context needed for setting the LED state.</param>
|
||||
/// <!-- aidoc:v1 sig=0d7f136 -->
|
||||
public abstract void CodeBlue(object entry);
|
||||
|
||||
/// <summary>
|
||||
/// Abstract method to set the LightBeacon device to Code Red state. This method should be implemented by each specific LightBeacon model to control the LED state accordingly.
|
||||
/// </summary>
|
||||
/// <param name="entry">An object parameter that can be used to pass additional information or context needed for setting the LED state.</param>
|
||||
/// <!-- aidoc:v1 sig=f600697 -->
|
||||
public abstract void CodeRed(object entry);
|
||||
|
||||
/// <summary>
|
||||
/// Abstract method to set the LightBeacon device to Code Yellow state. This method should be implemented by each specific LightBeacon model to control the LED state accordingly.
|
||||
/// </summary>
|
||||
/// <param name="entry">An object parameter that can be used to pass additional information or context needed for setting the LED state.</param>
|
||||
/// <!-- aidoc:v1 sig=2ed3bae -->
|
||||
public abstract void CodeYellow(object entry);
|
||||
|
||||
/// <summary>
|
||||
/// Abstract method to power off the LED of the LightBeacon device. This method should be implemented by each specific LightBeacon model to control the LED state accordingly.
|
||||
/// </summary>
|
||||
/// <param name="entry">An object parameter that can be used to pass additional information or context needed for setting the LED state.</param>
|
||||
/// <!-- aidoc:v1 sig=70c2fef -->
|
||||
public abstract void PowerOffLed(object entry);
|
||||
|
||||
/// <summary>
|
||||
@@ -51,6 +56,7 @@ public abstract class LightBeaconAbstract(string host, string password)
|
||||
/// <param name="host">The host address of the LightBeacon device.</param>
|
||||
/// <param name="password">The password for authenticating with the LightBeacon device.</param>
|
||||
/// <returns>An instance of the specific LightBeacon device, or null if the driver class is not found or cannot be instantiated.</returns>
|
||||
/// <!-- aidoc:v1 sig=93cfab7 body=2607338 -->
|
||||
public static LightBeaconAbstract? GetBeaconDevice(string driver, string host, string password)
|
||||
{
|
||||
var modelType = Type.GetType($"adas_core.Drivers.LightBeacon.{driver}");
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace adas_core.module.LightBeacons.Devices;
|
||||
/// This class represents a light beacon device that can be controlled via HTTP requests. It retrieves the current color of the beacon by parsing HTML pages and sends commands to change the beacon's color.
|
||||
/// The class includes error handling and retry logic for network operations, and it can be configured to emulate the beacon for testing purposes.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=483377a -->
|
||||
public class Turktbens2LightBeacon : LightBeacon
|
||||
{
|
||||
/// <summary>
|
||||
@@ -81,6 +82,7 @@ public class Turktbens2LightBeacon : LightBeacon
|
||||
/// </summary>
|
||||
/// <param name="options">A dictionary containing the configuration options for the beacon.</param>
|
||||
/// <exception cref="ArgumentException">Thrown when required options are missing or invalid.</exception>
|
||||
/// <!-- aidoc:v1 sig=e320a8e body=1b6dc81 -->
|
||||
public Turktbens2LightBeacon(EquatableDictionary<string, object> options) : base(options)
|
||||
{
|
||||
_logger = Log.ForContext<Turktbens2LightBeacon>();
|
||||
@@ -108,6 +110,10 @@ public class Turktbens2LightBeacon : LightBeacon
|
||||
/// returns OFF when some error appears or try to parse the bits to BalizaColors enum
|
||||
/// </summary>
|
||||
/// <returns>The current color of the beacon as a LightBeaconColor enum value.</returns>
|
||||
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
|
||||
/// "Summary contains leftover template placeholder 'GetByCodeSysAndCode' at the start, which is not meaningful in this context." -->
|
||||
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
|
||||
/// "Summary references 'BalizaColors' enum, but the code uses 'LightBeaconColor' (also confirmed by the <returns> tag)." -->
|
||||
public override async Task<LightBeaconColor> GetBeaconColor()
|
||||
{
|
||||
if (_emulate)
|
||||
@@ -194,6 +200,7 @@ public class Turktbens2LightBeacon : LightBeacon
|
||||
/// If an error occurs, it logs the error message and rethrows the exception to be handled by the caller.
|
||||
/// </summary>
|
||||
/// <returns>A task representing the asynchronous operation.</returns>
|
||||
/// <!-- aidoc:v1 sig=18624ee body=9cbaa1f -->
|
||||
public override async Task BlueCode()
|
||||
{
|
||||
try
|
||||
@@ -211,6 +218,7 @@ public class Turktbens2LightBeacon : LightBeacon
|
||||
/// The RedCode method sends a command to the beacon's web interface to change the beacon's color to red.
|
||||
/// </summary>
|
||||
/// <returns>A task representing the asynchronous operation.</returns>
|
||||
/// <!-- aidoc:v1 sig=a28d324 body=00b8012 -->
|
||||
public override async Task RedCode()
|
||||
{
|
||||
try
|
||||
@@ -228,6 +236,7 @@ public class Turktbens2LightBeacon : LightBeacon
|
||||
/// The YellowCode method sends a command to the beacon's web interface to change the beacon's color to yellow.
|
||||
/// </summary>
|
||||
/// <returns>A task representing the asynchronous operation.</returns>
|
||||
/// <!-- aidoc:v1 sig=5e4bc69 body=34c7285 -->
|
||||
public override async Task YellowCode()
|
||||
{
|
||||
try
|
||||
@@ -245,6 +254,10 @@ public class Turktbens2LightBeacon : LightBeacon
|
||||
/// The GreenCode method sends a command to the beacon's web interface to change the beacon's color to green.
|
||||
/// </summary>
|
||||
/// <returns>A task representing the asynchronous operation.</returns>
|
||||
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
|
||||
/// "Documentation describes a 'GreenCode' method that changes the beacon's color to green, but the actual method is PowerOffLed that sends an off code." -->
|
||||
/// <!-- aidoc-review:v1 severity=high kind=mentions_removed_behavior
|
||||
/// "Documentation references a GreenCode behavior (changing color to green) that the code does not implement." -->
|
||||
public override async Task PowerOffLed()
|
||||
{
|
||||
try
|
||||
@@ -264,6 +277,7 @@ public class Turktbens2LightBeacon : LightBeacon
|
||||
/// <param name="obs">The patient observation based on which the color alert should be generated.</param>
|
||||
/// <returns>A task representing the asynchronous operation.</returns>
|
||||
/// <exception cref="NotImplementedException"></exception>
|
||||
/// <!-- aidoc:v1 sig=7b58387 body=bfa6f2f -->
|
||||
public override Task GenerateColorAlert(PatientObservation obs)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
@@ -274,6 +288,7 @@ public class Turktbens2LightBeacon : LightBeacon
|
||||
/// </summary>
|
||||
/// <param name="colorCodes">The color code to be sent to the beacon.</param>
|
||||
/// <returns>A task representing the asynchronous operation.</returns>
|
||||
/// <!-- aidoc:v1 sig=9c8fbe5 body=e3eb8e4 -->
|
||||
private async Task Send(ColorsCodes colorCodes)
|
||||
{
|
||||
var clr = ((int)colorCodes).ToString().PadLeft(3, '0');
|
||||
@@ -306,6 +321,8 @@ public class Turktbens2LightBeacon : LightBeacon
|
||||
/// <param name="body">The body parameters to be sent in the HTTP POST request.</param>
|
||||
/// <returns>A task representing the asynchronous operation.</returns>
|
||||
/// <exception cref="InvalidOperationException"></exception>
|
||||
/// <!-- aidoc-review:v1 severity=medium kind=wrong_summary
|
||||
/// "The summary describes the method as 'private' but it is declared as 'protected'." -->
|
||||
protected async Task SendMessage(Dictionary<string, string> body)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_url)) throw new InvalidOperationException("URL is not set.");
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace adas_core.module.LightBeacons.Services;
|
||||
/// It interacts with the point of care service to determine which beacons are associated with specific locations and maintains an in-memory cache of the current color state of each location's beacon.
|
||||
/// The service also handles CRUD operations for light beacon configurations stored in a MongoDB repository.
|
||||
/// </summary>
|
||||
/// <!-- aidoc:v1 sig=3a68be9 -->
|
||||
public class LightBeaconService : ILightBeaconService
|
||||
{
|
||||
private readonly IClientMessageService _clientMessageService;
|
||||
@@ -44,6 +45,7 @@ public class LightBeaconService : ILightBeaconService
|
||||
/// <param name="subscribersService">The subscribers service for managing subscribers.</param>
|
||||
/// <param name="pointOfCareService">The point of care service for retrieving point of care information.</param>
|
||||
/// <param name="lightBeaconRepository">The light beacon repository for managing light beacon data.</param>
|
||||
/// <!-- aidoc:v1 sig=9216b6b body=faa90fc -->
|
||||
public LightBeaconService(
|
||||
IOptions<ApiSettings> apiSettings,
|
||||
ILogger<LightBeaconService> logger,
|
||||
@@ -82,6 +84,10 @@ public class LightBeaconService : ILightBeaconService
|
||||
/// </summary>
|
||||
/// <param name="pocId">The ID of the point of care for which to power off the LED.</param>
|
||||
/// <returns>A task representing the asynchronous operation.</returns>
|
||||
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
|
||||
/// "Documentation claims the method 'checks if there are any associated beacons' and 'sends a command to turn off the LED for each associated beacon', but the code only checks if the POC is null and calls PowerOffLed(poc) once." -->
|
||||
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
|
||||
/// "Documentation claims the method 'updates the in-memory cache to reflect that the beacon is now off for the specified location', but there is no cache update visible in the code." -->
|
||||
public async Task PowerOffLed(ObjectId pocId)
|
||||
{
|
||||
var poc = await _pointOfCareService.FindById(pocId);
|
||||
@@ -100,6 +106,7 @@ public class LightBeaconService : ILightBeaconService
|
||||
/// <param name="beacon">The light beacon configuration to insert.</param>
|
||||
/// <returns>The inserted light beacon configuration, or null if the insertion failed.</returns>
|
||||
/// <exception cref="Exception">Thrown if a light beacon with the same name already exists.</exception>
|
||||
/// <!-- aidoc:v1 sig=1e12f08 body=64da6ee -->
|
||||
public async Task<LightBeacon?> InsertOne(LightBeacon beacon)
|
||||
{
|
||||
var beaconFound = await _lightBeaconRepository.GetByName(beacon.Name);
|
||||
@@ -113,6 +120,7 @@ public class LightBeaconService : ILightBeaconService
|
||||
/// </summary>
|
||||
/// <param name="filter">The pagination filter to apply when retrieving the light beacons.</param>
|
||||
/// <returns>A paginated response containing the light beacons that match the specified filter.</returns>
|
||||
/// <!-- aidoc:v1 sig=415719d body=b8cd5a5 -->
|
||||
public async Task<PaginationResponse<LightBeacon>> GetPaginatedBeacons(PaginationFilter filter)
|
||||
{
|
||||
var usedRelayIds = await _pointOfCareService.FindAllIdBeaconsInUse();
|
||||
@@ -158,6 +166,7 @@ public class LightBeaconService : ILightBeaconService
|
||||
/// </summary>
|
||||
/// <param name="textToSearch">The text to search for in the names of the light beacons.</param>
|
||||
/// <returns>A list of light beacons whose names contain the specified search text.</returns>
|
||||
/// <!-- aidoc:v1 sig=31a792d body=850cd31 -->
|
||||
public async Task<List<LightBeacon>> GetSearchByName(string textToSearch)
|
||||
{
|
||||
return await _lightBeaconRepository.GetSearchByName(textToSearch);
|
||||
@@ -169,6 +178,7 @@ public class LightBeaconService : ILightBeaconService
|
||||
/// </summary>
|
||||
/// <param name="beacon">The light beacon object with updated properties.</param>
|
||||
/// <returns>The updated light beacon configuration, or null if the update failed.</returns>
|
||||
/// <!-- aidoc:v1 sig=44d83e6 body=0b996e1 -->
|
||||
public async Task<LightBeacon?> UpdateOne(LightBeacon beacon)
|
||||
{
|
||||
await _lightBeaconRepository.UpdateOneAsync(beacon.Id, beacon);
|
||||
@@ -181,6 +191,7 @@ public class LightBeaconService : ILightBeaconService
|
||||
/// </summary>
|
||||
/// <param name="poc">The point of care for which to power off the LED.</param>
|
||||
/// <returns>A task representing the asynchronous operation.</returns>
|
||||
/// <!-- aidoc:v1 sig=3da8578 body=b74440d -->
|
||||
public async Task PowerOffLed(PointOfCare poc)
|
||||
{
|
||||
if (_locationsWithColor.TryGetValue(poc.Id, out var lightBeaconColor) &&
|
||||
@@ -209,6 +220,7 @@ public class LightBeaconService : ILightBeaconService
|
||||
/// Generates a color alert for a patient observation by determining the appropriate color based on the observation's status and configured colors for warnings and alerts.
|
||||
/// </summary>
|
||||
/// <param name="obs">The patient observation for which to generate the color alert.</param>
|
||||
/// <!-- aidoc:v1 sig=c0724e7 body=242d283 -->
|
||||
public void GenerateColorAlert(PatientObservation obs)
|
||||
{
|
||||
try
|
||||
@@ -294,6 +306,8 @@ public class LightBeaconService : ILightBeaconService
|
||||
/// <param name="pocId">The ID of the point of care for which to send the color command.</param>
|
||||
/// <param name="color">The color to set on the light beacon.</param>
|
||||
/// <returns>A task representing the asynchronous operation.</returns>
|
||||
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
|
||||
/// "Documentation claims the method checks for associated beacons and sends a color command for each associated beacon, but the code only checks if the point of care is null and calls a single SendColor overload without any beacon check or iteration." -->
|
||||
public async Task SendColor(ObjectId pocId, LightBeaconColor color)
|
||||
{
|
||||
var poc = await _pointOfCareService.FindById(pocId);
|
||||
@@ -308,6 +322,7 @@ public class LightBeaconService : ILightBeaconService
|
||||
/// <param name="poc">The point of care for which to send the color command.</param>
|
||||
/// <param name="color">The color to set on the light beacon.</param>
|
||||
/// <returns>A task representing the asynchronous operation.</returns>
|
||||
/// <!-- aidoc:v1 sig=5217200 body=5ad71ce -->
|
||||
public async Task SendColor(PointOfCare poc, LightBeaconColor color)
|
||||
{
|
||||
try
|
||||
@@ -361,6 +376,7 @@ public class LightBeaconService : ILightBeaconService
|
||||
/// </summary>
|
||||
/// <param name="pocId">The ID of the point of care for which to retrieve the color state.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with the current color state of the light beacon.</returns>
|
||||
/// <!-- aidoc:v1 sig=e927281 body=f729d62 -->
|
||||
public async Task<LightBeaconColor> GetColor(ObjectId pocId)
|
||||
{
|
||||
var poc = await _pointOfCareService.FindById(pocId);
|
||||
@@ -373,6 +389,7 @@ public class LightBeaconService : ILightBeaconService
|
||||
/// </summary>
|
||||
/// <param name="poc">The point of care for which to retrieve the color state.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with the current color state of the light beacon.</returns>
|
||||
/// <!-- aidoc:v1 sig=9ff58e8 body=3531e3b -->
|
||||
public async Task<LightBeaconColor> GetColor(PointOfCare poc)
|
||||
{
|
||||
try
|
||||
@@ -403,6 +420,7 @@ public class LightBeaconService : ILightBeaconService
|
||||
/// <param name="poc">The point of care for which to send the color command.</param>
|
||||
/// <param name="color">The color to set on the light beacon.</param>
|
||||
/// <returns>A task representing the asynchronous operation.</returns>
|
||||
/// <!-- aidoc:v1 sig=e30390e body=ebb3633 -->
|
||||
public async Task SendBeaconBroadcast(PointOfCare poc, LightBeaconColor color)
|
||||
{
|
||||
var subscribers = _subscribersService.GetSubscribers()
|
||||
@@ -420,6 +438,7 @@ public class LightBeaconService : ILightBeaconService
|
||||
/// <param name="pocId">The ID of the point of care for which to send the color command.</param>
|
||||
/// <param name="color">The color to set on the light beacon.</param>
|
||||
/// <returns>A task representing the asynchronous operation.</returns>
|
||||
/// <!-- aidoc:v1 sig=e72960d body=fd03c04 -->
|
||||
public async Task SendBeaconBroadcast(ObjectId pocId, LightBeaconColor color)
|
||||
{
|
||||
var poc = await _pointOfCareService.FindById(pocId);
|
||||
@@ -433,6 +452,7 @@ public class LightBeaconService : ILightBeaconService
|
||||
/// </summary>
|
||||
/// <param name="body">The body of the message to send.</param>
|
||||
/// <returns>A task representing the asynchronous operation.</returns>
|
||||
/// <!-- aidoc:v1 sig=df9f7f5 body=365678a -->
|
||||
private async Task SendMessage(string body)
|
||||
{
|
||||
if (string.IsNullOrEmpty(Url))
|
||||
@@ -465,6 +485,7 @@ public class LightBeaconService : ILightBeaconService
|
||||
/// </summary>
|
||||
/// <param name="lightBeaconId">The ID of the light beacon to retrieve.</param>
|
||||
/// <returns>A task representing the asynchronous operation, with a result of the light beacon device instance if found; otherwise, null.</returns>
|
||||
/// <!-- aidoc:v1 sig=f305e9f body=070796e -->
|
||||
private async Task<LightBeaconDevice?> GetBeacon(ObjectId lightBeaconId)
|
||||
{
|
||||
var cfg = await _lightBeaconRepository.GetById(lightBeaconId);
|
||||
@@ -491,6 +512,7 @@ public class LightBeaconService : ILightBeaconService
|
||||
/// </summary>
|
||||
/// <param name="dictionary"></param>
|
||||
/// <returns></returns>
|
||||
/// <!-- aidoc:v1 sig=ee90706 body=21dd886 -->
|
||||
public static string DictionaryToString(ConcurrentDictionary<ObjectId, LightBeaconColor> dictionary)
|
||||
{
|
||||
var builder = new StringBuilder();
|
||||
|
||||
Reference in New Issue
Block a user