using adas_core.Domain.Enums;
using adas_core.Domain.Models.MongoModels;
using adas_core.module.Relays.Models;

namespace adas_core.module.Relays.Devices;

internal class FakeRelay(Relay relay, RelaySettings relaySettings) : RelayDevice(relay, relaySettings)
{
    public override bool CheckDevice()
    {
        return true;
    }

    public override bool GetStatusRelay()
    {
        return true;
    }

    public override void PowerOffRelay(int outletId)
    {
    }

    public override void PowerOnRelay(int outletId)
    {
    }

    public override void PowerOffAll()
    {
    }

    public override void PowerOnAll()
    {
    }

    public override RelayEnum.Status GetStatusRelay(int outletId)
    {
        const string status = "00000000";

        if (status.Length == 0) return RelayEnum.Status.On;
        return status.Substring(outletId - 1, 1) == "0" ? RelayEnum.Status.Off : RelayEnum.Status.On;
    }

    public override void RebootOutlet(int outletId)
    {
    }

    public override void Reboot()
    {
        PowerOffAll();
        if (Relay.RebootDelay is > 0) Thread.Sleep(Relay.RebootDelay!.Value);
        PowerOnAll();
    }

    public override Task<bool> GetStatusRelayAsync()
    {
        return Task.FromResult(true);
    }

    public override void CheckStatus()
    {
    }
}