34 lines
998 B
C#
34 lines
998 B
C#
using Serilog;
|
|
|
|
namespace adas_core.module.LightBeacons.Devices;
|
|
|
|
public abstract class LightBeaconAbstract(string host, string password)
|
|
{
|
|
public string Host = host;
|
|
public string Password = password;
|
|
|
|
|
|
public abstract void CodeBlue(object entry);
|
|
|
|
public abstract void CodeRed(object entry);
|
|
|
|
public abstract void CodeYellow(object entry);
|
|
|
|
public abstract void PowerOffLed(object entry);
|
|
|
|
public static LightBeaconAbstract? GetBeaconDevice(string driver, string host, string password)
|
|
{
|
|
var modelType = Type.GetType($"adas_core.Drivers.LightBeacon.{driver}");
|
|
if (modelType == null)
|
|
{
|
|
Log.Debug($"LightBeacon modelType not found: driver {driver}, host {host}, password {password}");
|
|
return null;
|
|
}
|
|
|
|
var ctor = modelType.GetConstructor([typeof(string), typeof(string)]);
|
|
if (ctor == null)
|
|
return null;
|
|
|
|
return (LightBeaconAbstract)ctor.Invoke([host, password]);
|
|
}
|
|
} |