# Class Turktbens2LightBeacon

Namespace
  adas_core.module.LightBeacons.Devices

Assembly
  adas-core.module.LightBeacons.dll

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.

    public class Turktbens2LightBeacon : LightBeacon

Inheritance
  object
  LightBeacon
  Turktbens2LightBeacon

Inherited Members
  LightBeacon.Options
  object.Equals(object)
  object.Equals(object, object)
  object.GetHashCode()
  object.GetType()
  object.MemberwiseClone()
  object.ReferenceEquals(object, object)
  object.ToString()

Extension Methods
  NumberUtils.IsNumber(object)
  NumberUtils.ToDouble(object)
  ObjectUtils.ToStr(object?)

## Constructors

### Turktbens2LightBeacon(EquatableDictionary<string, object>)

The constructor of the Turktbens2LightBeacon class initializes a new instance of the class with the specified options.

    public Turktbens2LightBeacon(EquatableDictionary<string, object> options)

#### Parameters

`options` EquatableDictionary<string, object>

  A dictionary containing the configuration options for the beacon.

#### Exceptions

ArgumentException

  Thrown when required options are missing or invalid.

## Methods

### BlueCode()

The BlueCode method sends a command to the beacon's web interface to change the beacon's color to blue. It constructs the appropriate HTTP request body using the predefined code and port mappings, and it includes error handling to log any exceptions that occur during the process. If an error occurs, it logs the error message and rethrows the exception to be handled by the caller.

    public override Task BlueCode()

#### Returns

Task

  A task representing the asynchronous operation.

### GenerateColorAlert(PatientObservation)

The GenerateColorAlert method is not implemented in this class. It is intended to generate a color alert based on the provided PatientObservation, but the specific implementation details are not defined in this class and will need to be implemented in a subclass or by the caller.

    public override Task GenerateColorAlert(PatientObservation obs)

#### Parameters

`obs` PatientObservation

  The patient observation based on which the color alert should be generated.

#### Returns

Task

  A task representing the asynchronous operation.

#### Exceptions

NotImplementedException

### GetBeaconColor()

GetByCodeSysAndCode beacon color downloading the html of the web. and using AgilityPackHtml to access. The web is bugged and sometimes you are logged or not. The information is in two urls, the color is formed by 3 bits, Vaux html changes if logged/not logged returns OFF when some error appears or try to parse the bits to BalizaColors enum

    public override Task<LightBeaconColor> GetBeaconColor()

#### Returns

Task<LightBeaconColor>

  The current color of the beacon as a LightBeaconColor enum value.

### PowerOffLed()

The GreenCode method sends a command to the beacon's web interface to change the beacon's color to green.

    public override Task PowerOffLed()

#### Returns

Task

  A task representing the asynchronous operation.

### RedCode()

The RedCode method sends a command to the beacon's web interface to change the beacon's color to red.

    public override Task RedCode()

#### Returns

Task

  A task representing the asynchronous operation.

### SendMessage(Dictionary<string, string>)

The SendMessage method is a private helper method that sends an HTTP POST request to the beacon's web interface with the specified body parameters. It includes retry logic to handle transient network errors, attempting to resend the request up to a maximum number of retries with exponential backoff between attempts. If the request fails after all retry attempts, it logs an error message and rethrows the exception.

    protected Task SendMessage(Dictionary<string, string> body)

#### Parameters

`body` Dictionary<string, string>

  The body parameters to be sent in the HTTP POST request.

#### Returns

Task

  A task representing the asynchronous operation.

#### Exceptions

InvalidOperationException

### YellowCode()

The YellowCode method sends a command to the beacon's web interface to change the beacon's color to yellow.

    public override Task YellowCode()

#### Returns

Task

  A task representing the asynchronous operation.