=== 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:
julian
2026-06-28 02:50:05 -07:00
parent a19fb90902
commit 586f02a2ca
654 changed files with 5260 additions and 0 deletions
@@ -12,6 +12,7 @@ namespace adas_core.module.Relays.Devices;
/// </summary>
/// <param name="relay">The Relay object representing the relay device.</param>
/// <param name="relaySettings">The RelaySettings object containing the configuration settings for the relay device.</param>
/// <!-- aidoc:v1 sig=0480f2b -->
public class KmTronicRelay(Relay relay, RelaySettings relaySettings)
: RelayDevice(relay, relaySettings)
{
@@ -30,6 +31,7 @@ public class KmTronicRelay(Relay relay, RelaySettings relaySettings)
/// If the response indicates that the status is unknown, it returns false, indicating that the device is not reachable or not responding correctly. Otherwise, it returns true, indicating that the device is online and responsive.
/// </summary>
/// <returns>True if the device is online and responsive, false otherwise.</returns>
/// <!-- aidoc:v1 sig=20f7821 body=470606e -->
public override bool CheckDevice()
{
CheckStatus();
@@ -42,6 +44,7 @@ public class KmTronicRelay(Relay relay, RelaySettings relaySettings)
/// If the response is null or empty, it indicates that the device is not reachable or not responding correctly, and it returns false. Otherwise, it returns true, indicating that the device is online and responsive.
/// </summary>
/// <returns>True if the device is online and responsive, false otherwise.</returns>
/// <!-- aidoc:v1 sig=351e317 body=526bfc0 -->
public override bool GetStatusRelay()
{
var status = Send("FF0000");
@@ -60,6 +63,7 @@ public class KmTronicRelay(Relay relay, RelaySettings relaySettings)
/// </summary>
/// <param name="outletId">The ID of the outlet to retrieve the status for.</param>
/// <returns>The status of the specified outlet.</returns>
/// <!-- aidoc:v1 sig=2d49b50 body=d2e7365 -->
public override RelayEnum.Status GetStatusRelay(int outletId)
{
var status = Send("FF0000");
@@ -102,6 +106,7 @@ public class KmTronicRelay(Relay relay, RelaySettings relaySettings)
/// Powers off a specific outlet on the KMTronic relay device by sending a command to either open or close the relay, depending on the configured mode.
/// </summary>
/// <param name="outletId">The ID of the outlet to power off.</param>
/// <!-- aidoc:v1 sig=df0a638 body=d1228ed -->
public override void PowerOffRelay(int outletId)
{
if (Relay.Mode == RelayEnum.Mode.OpenedOffClosedOn) OpenRelay(outletId);
@@ -112,6 +117,10 @@ public class KmTronicRelay(Relay relay, RelaySettings relaySettings)
/// Powers on a specific outlet on the KMTronic relay device by sending a command to either open or close the relay, depending on the configured mode.
/// </summary>
/// <param name="outletId">The ID of the outlet to power on.</param>
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
/// "Summary says 'Powers on' a specific outlet, but the method is OpenRelay and the inline comment confirms it cuts current ('corta la corriente'), i.e., it powers the outlet off, not on." -->
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
/// "Summary claims the command is sent 'depending on the configured mode' (open or close), but the code unconditionally sends a fixed 'FF0{outletId}01' command with no mode-based branching." -->
public void OpenRelay(int outletId)
{
//Activa el relé por lo que corta la corriente del dispositivo conectado
@@ -122,6 +131,7 @@ public class KmTronicRelay(Relay relay, RelaySettings relaySettings)
/// Powers on a specific outlet on the KMTronic relay device by sending a command to either open or close the relay, depending on the configured mode.
/// </summary>
/// <param name="outletId">The ID of the outlet to power on.</param>
/// <!-- aidoc:v1 sig=a106116 body=4891d13 -->
public override void PowerOnRelay(int outletId)
{
if (Relay.Mode == RelayEnum.Mode.OpenedOffClosedOn) CloseRelay(outletId);
@@ -133,6 +143,8 @@ public class KmTronicRelay(Relay relay, RelaySettings relaySettings)
/// This method is used to power on the outlet by allowing the current to flow through it.
/// </summary>
/// <param name="outletId">The ID of the outlet to close.</param>
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
/// "The summary states the command is sent 'depending on the configured mode', but the code unconditionally sends a fixed command 'FF0{outletId}00' with no mode-based branching." -->
public void CloseRelay(int outletId)
{
//Desactiva el relé por lo que deja pasar la corriente del dispositivo conectado
@@ -143,6 +155,8 @@ public class KmTronicRelay(Relay relay, RelaySettings relaySettings)
/// <summary>
/// Powers off all outlets on the KMTronic relay device by sending a command to either open or close all relays, depending on the configured mode.
/// </summary>
/// <!-- aidoc-review:v1 severity=medium kind=wrong_summary
/// "Documentation states the method sends 'a command to either open or close all relays, depending on the configured mode', but the code unconditionally sends a single fixed command 'FFE0FF' with no mode-based branching visible in this override." -->
public override void PowerOffAll()
{
//Activa el relé por lo que corta la corriente de todos los dispositivo conectados
@@ -152,6 +166,8 @@ public class KmTronicRelay(Relay relay, RelaySettings relaySettings)
/// <summary>
/// Powers on all outlets on the KMTronic relay device by sending a command to either open or close all relays, depending on the configured mode.
/// </summary>
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
/// "The summary states the command sent depends on a 'configured mode' (open vs. close relays), but the code unconditionally sends a single fixed command 'FFE000' with no mode-based branching." -->
public override void PowerOnAll()
{
//Desactiva el relé por lo que deja pasar la corriente a todos dispositivo conectados
@@ -161,6 +177,7 @@ public class KmTronicRelay(Relay relay, RelaySettings relaySettings)
/// <summary>
/// Checks the status of the KMTronic relay device by calling the GetStatusRelay method and updating the DeviceStatus property accordingly.
/// </summary>
/// <!-- aidoc:v1 sig=abdef98 body=abb4ab7 -->
public override void CheckStatus()
{
DeviceStatus = GetStatusRelay();
@@ -170,6 +187,7 @@ public class KmTronicRelay(Relay relay, RelaySettings relaySettings)
/// Reboots a specific outlet on the KMTronic relay device by first powering it off, waiting for a specified delay, and then powering it back on. This method is used to reset the connected device by briefly cutting off its power supply.
/// </summary>
/// <param name="outletId">The ID of the outlet to reboot.</param>
/// <!-- aidoc:v1 sig=1edae69 body=deab68d -->
public override void RebootOutlet(int outletId)
{
//Reinicia el relé del dispositivo conectado
@@ -179,6 +197,7 @@ public class KmTronicRelay(Relay relay, RelaySettings relaySettings)
/// <summary>
/// Reboots all outlets on the KMTronic relay device by first powering them off, waiting for a specified delay, and then powering them back on. This method is used to reset all connected devices by briefly cutting off their power supply.
/// </summary>
/// <!-- aidoc:v1 sig=1be2480 body=f0389f8 -->
public override void Reboot()
{
PowerOffAll();
@@ -191,6 +210,8 @@ public class KmTronicRelay(Relay relay, RelaySettings relaySettings)
/// </summary>
/// <returns>A task representing the asynchronous operation.</returns>
/// <exception cref="NotImplementedException"></exception>
/// <!-- aidoc-review:v1 severity=medium kind=wrong_returns
/// "Method returns Task<bool> (relay status), but <returns> only says 'A task representing the asynchronous operation' without describing the boolean result." -->
public override Task<bool> GetStatusRelayAsync()
{
throw new NotImplementedException();
@@ -199,6 +220,8 @@ public class KmTronicRelay(Relay relay, RelaySettings relaySettings)
/// <summary>
/// Asynchronously retrieves the status of a specific outlet on the KMTronic relay device. This method is not implemented in this class, and it throws a NotImplementedException when called.
/// </summary>
/// <!-- aidoc-review:v1 severity=high kind=wrong_summary
/// "Documentation describes an asynchronous outlet status retrieval method that throws NotImplementedException, but the actual code creates/closes a UdpClient to connect to the relay device." -->
protected virtual void Connect()
{
if (_udpClient == null)
@@ -244,6 +267,10 @@ public class KmTronicRelay(Relay relay, RelaySettings relaySettings)
/// </summary>
/// <param name="datagrama">The command to send to the KMTronic relay device.</param>
/// <returns>The response from the KMTronic relay device.</returns>
/// <!-- aidoc-review:v1 severity=medium kind=missing_exception
/// "The method explicitly throws `t.Exception` when the receive task faults within the timeout window, but no <exception> tag is documented." -->
/// <!-- aidoc-review:v1 severity=medium kind=wrong_summary
/// "The summary says the method 'checks if the UDP client is initialized and connected'; the code only checks for null (not connection status) and does not mention the 5-second timeout that causes an empty string to be returned on failure." -->
protected virtual string Send(string datagrama)
{
if (_udpClient == null) Connect();