diff --git a/GSS2.Core/GSS2.Core.csproj b/GSS2.Core/GSS2.Core.csproj
index 71940ae..6c5f67f 100644
--- a/GSS2.Core/GSS2.Core.csproj
+++ b/GSS2.Core/GSS2.Core.csproj
@@ -17,6 +17,7 @@
+
diff --git a/GSS2.Core/Hardware/LightsService.cs b/GSS2.Core/Hardware/LightsService.cs
index da1e271..f643198 100644
--- a/GSS2.Core/Hardware/LightsService.cs
+++ b/GSS2.Core/Hardware/LightsService.cs
@@ -104,6 +104,7 @@ public class LightsService
}
public void Ping(CancellationToken cancellationToken = default) => SendRequest(_client.Ping, new Empty(), cancellationToken);
+ public void Disconnect(CancellationToken cancellationToken = default) => SendRequest(_client.Disconnect, new Empty(), cancellationToken);
public void Off(CancellationToken cancellationToken = default) => SendRequest(_client.SetOff, new Empty(), cancellationToken);
public void StaticColor(double brightness, Color color, CancellationToken cancellationToken = default) => SendRequest(_client.SetStaticColor, new StaticColorRequest
{
@@ -274,6 +275,7 @@ public class LightsService
}, cancellationToken);
public async Task PingAsync(CancellationToken cancellationToken = default) => await SendRequestAsync(_client.PingAsync, new Empty(), cancellationToken);
+ public async Task DisconnectAsync(CancellationToken cancellationToken = default) => await SendRequestAsync(_client.DisconnectAsync, new Empty(), cancellationToken);
public async Task OffAsync(CancellationToken cancellationToken = default) => await SendRequestAsync(_client.SetOffAsync, new Empty(), cancellationToken);
public async Task StaticColorAsync(double brightness, Color color, CancellationToken cancellationToken = default) => await SendRequestAsync(_client.SetStaticColorAsync, new StaticColorRequest
{
diff --git a/GSS2.Core/Hardware/TemperatureHumidityService.cs b/GSS2.Core/Hardware/TemperatureHumidityService.cs
index d6a8e44..11b7783 100644
--- a/GSS2.Core/Hardware/TemperatureHumidityService.cs
+++ b/GSS2.Core/Hardware/TemperatureHumidityService.cs
@@ -9,8 +9,8 @@ public class TemperatureHumidityService : IDisposable
{
public static TemperatureHumidityServiceConfiguration Default => new TemperatureHumidityServiceConfiguration
{
- Bus = 0,
- Address = 0x44
+ Bus = 6,
+ Address = 0x45
};
public int Bus { get; set; }
@@ -54,7 +54,7 @@ public class TemperatureHumidityService : IDisposable
}
}
- public async Task<(double temperature, double relativeHumidity)> MeasureAsync(int measurementsCount = 1, CancellationToken cancellationToken = default)
+ public (double temperature, double relativeHumidity) Measure(int measurementsCount = 1, bool checkCrc = true, CancellationToken cancellationToken = default)
{
// В соответствии с даташитом на SHT45-AD1B-R2 псевдокод измерения с высокой точностью следующий:
// i2c_write(i2c_addr=0x44, tx_bytes=[0xFD])
@@ -90,19 +90,19 @@ public class TemperatureHumidityService : IDisposable
// Отправляем команду
_sensor.Write(command);
// 10 мс ожидания
- await Task.Delay(10, cancellationToken);
+ Task.Delay(10, cancellationToken);
// Читаем данные
_sensor.Read(data);
// Распаковываем данные [2 * 8-bit T-data; 8-bit CRC; 2 * 8-bit RH-data; 8-bit CRC]
- ushort temperatureTicks = BitConverter.ToUInt16(data.ToArray(), 0);
byte temperatureChecksum = data[2];
- int relativeHumidityTicks = BitConverter.ToUInt16(data.ToArray(), 3);
byte relativeHumidityChecksum = data[5];
+ ushort temperatureTicks = BitConverter.ToUInt16(data.Slice(0, 2));
+ int relativeHumidityTicks = BitConverter.ToUInt16(data.Slice(3, 2));
// Проверка по CRC
- if (!CheckCrc(data.Slice(0, 2), temperatureChecksum) ||
- !CheckCrc(data.Slice(3, 2), relativeHumidityChecksum))
+ if (checkCrc && (!CheckCrc(data.Slice(0, 2), temperatureChecksum) ||
+ !CheckCrc(data.Slice(3, 2), relativeHumidityChecksum)))
{
_logger.LogWarning("Temperature and humidity sensor CRC error");
continue;
diff --git a/GSS2.LightsControl/Server/.env b/GSS2.LightsControl/Server/.env
index 5348c5a..f5e0f00 100644
--- a/GSS2.LightsControl/Server/.env
+++ b/GSS2.LightsControl/Server/.env
@@ -2,7 +2,7 @@ LED_COUNT=9
LED_PIN=23
GAMMA=2.2
-TIMEOUT=5
+TIMEOUT_SECONDS=300
IDLE_BRIGHTNESS=0.30
IDLE_R=0
diff --git a/GSS2.LightsControl/Server/.gitignore b/GSS2.LightsControl/Server/.gitignore
index 1e18f27..f7bb35d 100644
--- a/GSS2.LightsControl/Server/.gitignore
+++ b/GSS2.LightsControl/Server/.gitignore
@@ -1 +1,2 @@
-!.env
\ No newline at end of file
+!.env
+venv
\ No newline at end of file
diff --git a/GSS2.LightsControl/Server/lights_deamon.py b/GSS2.LightsControl/Server/lights_deamon.py
index 07d266d..4ef2c46 100644
--- a/GSS2.LightsControl/Server/lights_deamon.py
+++ b/GSS2.LightsControl/Server/lights_deamon.py
@@ -34,7 +34,7 @@ LED_PIN_NUM = get_env_int("LED_PIN")
LED_PIN = getattr(board, f"D{LED_PIN_NUM}")
GAMMA = get_env_float("GAMMA")
-TIMEOUT = get_env_float("TIMEOUT")
+TIMEOUT_SECONDS = get_env_float("TIMEOUT_SECONDS")
IDLE_SPEED = get_env_float("IDLE_SPEED")
IDLE_BRIGHTNESS = get_env_float("IDLE_BRIGHTNESS")
@@ -579,7 +579,7 @@ class LightsDaemon(lights_pb2_grpc.LightsServicer):
def loop(self):
while self._running:
with self._lock:
- if self._control_mode and time.time() - self._last_ping > TIMEOUT:
+ if self._control_mode and time.time() - self._last_ping > TIMEOUT_SECONDS:
self._control_mode = False
self._pixels.brightness = IDLE_BRIGHTNESS
self._animation = IdleAnimation()
@@ -597,6 +597,13 @@ class LightsDaemon(lights_pb2_grpc.LightsServicer):
self._control_mode = True
self._last_ping = time.time()
+ def Disconnect(self, request, context):
+ with self._lock:
+ self._control_mode = False
+ self._pixels.brightness = IDLE_BRIGHTNESS
+ self._animation = IdleAnimation()
+ return lights_pb2.Empty()
+
def Ping(self, request, context):
self._update_last_ping()
return lights_pb2.Empty()
diff --git a/GSS2.LightsControl/Server/lights_pb2.py b/GSS2.LightsControl/Server/lights_pb2.py
index db90086..756a91d 100644
--- a/GSS2.LightsControl/Server/lights_pb2.py
+++ b/GSS2.LightsControl/Server/lights_pb2.py
@@ -24,13 +24,14 @@ _sym_db = _symbol_database.Default()
-DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0clights.proto\x12\x12GSS2.LightsControl\"\x07\n\x05\x45mpty\"I\n\x12StaticColorRequest\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\t\n\x01r\x18\x02 \x01(\x05\x12\t\n\x01g\x18\x03 \x01(\x05\x12\t\n\x01\x62\x18\x04 \x01(\x05\"\x8f\x01\n\x16StaticGradient2Request\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\x0e\n\x06left_r\x18\x02 \x01(\x05\x12\x0e\n\x06left_g\x18\x03 \x01(\x05\x12\x0e\n\x06left_b\x18\x04 \x01(\x05\x12\x0f\n\x07right_r\x18\x05 \x01(\x05\x12\x0f\n\x07right_g\x18\x06 \x01(\x05\x12\x0f\n\x07right_b\x18\x07 \x01(\x05\"\xc5\x01\n\x16StaticGradient3Request\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\x0e\n\x06left_r\x18\x02 \x01(\x05\x12\x0e\n\x06left_g\x18\x03 \x01(\x05\x12\x0e\n\x06left_b\x18\x04 \x01(\x05\x12\x10\n\x08middle_r\x18\x05 \x01(\x05\x12\x10\n\x08middle_g\x18\x06 \x01(\x05\x12\x10\n\x08middle_b\x18\x07 \x01(\x05\x12\x0f\n\x07right_r\x18\x08 \x01(\x05\x12\x0f\n\x07right_g\x18\t \x01(\x05\x12\x0f\n\x07right_b\x18\n \x01(\x05\"*\n\x14StaticRainbowRequest\x12\x12\n\nbrightness\x18\x01 \x01(\x01\"[\n\x15\x42reathingColorRequest\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\x12\t\n\x01r\x18\x03 \x01(\x05\x12\t\n\x01g\x18\x04 \x01(\x05\x12\t\n\x01\x62\x18\x05 \x01(\x05\"\xa1\x01\n\x19\x42reathingGradient2Request\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\x12\x0e\n\x06left_r\x18\x03 \x01(\x05\x12\x0e\n\x06left_g\x18\x04 \x01(\x05\x12\x0e\n\x06left_b\x18\x05 \x01(\x05\x12\x0f\n\x07right_r\x18\x06 \x01(\x05\x12\x0f\n\x07right_g\x18\x07 \x01(\x05\x12\x0f\n\x07right_b\x18\x08 \x01(\x05\"\xd7\x01\n\x19\x42reathingGradient3Request\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\x12\x0e\n\x06left_r\x18\x03 \x01(\x05\x12\x0e\n\x06left_g\x18\x04 \x01(\x05\x12\x0e\n\x06left_b\x18\x05 \x01(\x05\x12\x10\n\x08middle_r\x18\x06 \x01(\x05\x12\x10\n\x08middle_g\x18\x07 \x01(\x05\x12\x10\n\x08middle_b\x18\x08 \x01(\x05\x12\x0f\n\x07right_r\x18\t \x01(\x05\x12\x0f\n\x07right_g\x18\n \x01(\x05\x12\x0f\n\x07right_b\x18\x0b \x01(\x05\"<\n\x17\x42reathingRainbowRequest\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\"w\n\x13RunningColorRequest\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\x12\x0e\n\x06length\x18\x03 \x01(\x05\x12\x0c\n\x04\x66\x61\x64\x65\x18\x04 \x01(\x05\x12\t\n\x01r\x18\x05 \x01(\x05\x12\t\n\x01g\x18\x06 \x01(\x05\x12\t\n\x01\x62\x18\x07 \x01(\x05\"\x9f\x01\n\x17RunningGradient2Request\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\x12\x0e\n\x06left_r\x18\x03 \x01(\x05\x12\x0e\n\x06left_g\x18\x04 \x01(\x05\x12\x0e\n\x06left_b\x18\x05 \x01(\x05\x12\x0f\n\x07right_r\x18\x06 \x01(\x05\x12\x0f\n\x07right_g\x18\x07 \x01(\x05\x12\x0f\n\x07right_b\x18\x08 \x01(\x05\"\xd5\x01\n\x17RunningGradient3Request\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\x12\x0e\n\x06left_r\x18\x03 \x01(\x05\x12\x0e\n\x06left_g\x18\x04 \x01(\x05\x12\x0e\n\x06left_b\x18\x05 \x01(\x05\x12\x10\n\x08middle_r\x18\x06 \x01(\x05\x12\x10\n\x08middle_g\x18\x07 \x01(\x05\x12\x10\n\x08middle_b\x18\x08 \x01(\x05\x12\x0f\n\x07right_r\x18\t \x01(\x05\x12\x0f\n\x07right_g\x18\n \x01(\x05\x12\x0f\n\x07right_b\x18\x0b \x01(\x05\":\n\x15RunningRainbowRequest\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\"\xbb\x01\n\x0cSnakeRequest\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\x12\x13\n\x0bhead_length\x18\x03 \x01(\x05\x12\x13\n\x0btail_length\x18\x04 \x01(\x05\x12\x0e\n\x06head_r\x18\x05 \x01(\x05\x12\x0e\n\x06head_g\x18\x06 \x01(\x05\x12\x0e\n\x06head_b\x18\x07 \x01(\x05\x12\x0e\n\x06tail_r\x18\x08 \x01(\x05\x12\x0e\n\x06tail_g\x18\t \x01(\x05\x12\x0e\n\x06tail_b\x18\n \x01(\x05\"Q\n\x0b\x46ireRequest\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\x12\t\n\x01r\x18\x03 \x01(\x05\x12\t\n\x01g\x18\x04 \x01(\x05\x12\t\n\x01\x62\x18\x05 \x01(\x05\"U\n\x0fSnowfallRequest\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\x12\t\n\x01r\x18\x03 \x01(\x05\x12\t\n\x01g\x18\x04 \x01(\x05\x12\t\n\x01\x62\x18\x05 \x01(\x05\"R\n\x0c\x46lashRequest\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\x12\t\n\x01r\x18\x03 \x01(\x05\x12\t\n\x01g\x18\x04 \x01(\x05\x12\t\n\x01\x62\x18\x05 \x01(\x05\"x\n\x0bLoadRequest\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\x12\x0f\n\x07percent\x18\x03 \x01(\x01\x12\x14\n\x0clast_percent\x18\x04 \x01(\x01\x12\t\n\x01r\x18\x05 \x01(\x05\x12\t\n\x01g\x18\x06 \x01(\x05\x12\t\n\x01\x62\x18\x07 \x01(\x05\"T\n\x0e\x43puLoadRequest\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\x12\t\n\x01r\x18\x03 \x01(\x05\x12\t\n\x01g\x18\x04 \x01(\x05\x12\t\n\x01\x62\x18\x05 \x01(\x05\x32\x9a\r\n\x06Lights\x12<\n\x04Ping\x12\x19.GSS2.LightsControl.Empty\x1a\x19.GSS2.LightsControl.Empty\x12>\n\x06SetOff\x12\x19.GSS2.LightsControl.Empty\x1a\x19.GSS2.LightsControl.Empty\x12S\n\x0eSetStaticColor\x12&.GSS2.LightsControl.StaticColorRequest\x1a\x19.GSS2.LightsControl.Empty\x12[\n\x12SetStaticGradient2\x12*.GSS2.LightsControl.StaticGradient2Request\x1a\x19.GSS2.LightsControl.Empty\x12[\n\x12SetStaticGradient3\x12*.GSS2.LightsControl.StaticGradient3Request\x1a\x19.GSS2.LightsControl.Empty\x12W\n\x10SetStaticRainbow\x12(.GSS2.LightsControl.StaticRainbowRequest\x1a\x19.GSS2.LightsControl.Empty\x12Y\n\x11SetBreathingColor\x12).GSS2.LightsControl.BreathingColorRequest\x1a\x19.GSS2.LightsControl.Empty\x12\x61\n\x15SetBreathingGradient2\x12-.GSS2.LightsControl.BreathingGradient2Request\x1a\x19.GSS2.LightsControl.Empty\x12\x61\n\x15SetBreathingGradient3\x12-.GSS2.LightsControl.BreathingGradient3Request\x1a\x19.GSS2.LightsControl.Empty\x12]\n\x13SetBreathingRainbow\x12+.GSS2.LightsControl.BreathingRainbowRequest\x1a\x19.GSS2.LightsControl.Empty\x12U\n\x0fSetRunningColor\x12\'.GSS2.LightsControl.RunningColorRequest\x1a\x19.GSS2.LightsControl.Empty\x12]\n\x13SetRunningGradient2\x12+.GSS2.LightsControl.RunningGradient2Request\x1a\x19.GSS2.LightsControl.Empty\x12]\n\x13SetRunningGradient3\x12+.GSS2.LightsControl.RunningGradient3Request\x1a\x19.GSS2.LightsControl.Empty\x12Y\n\x11SetRunningRainbow\x12).GSS2.LightsControl.RunningRainbowRequest\x1a\x19.GSS2.LightsControl.Empty\x12G\n\x08SetSnake\x12 .GSS2.LightsControl.SnakeRequest\x1a\x19.GSS2.LightsControl.Empty\x12\x45\n\x07SetFire\x12\x1f.GSS2.LightsControl.FireRequest\x1a\x19.GSS2.LightsControl.Empty\x12M\n\x0bSetSnowfall\x12#.GSS2.LightsControl.SnowfallRequest\x1a\x19.GSS2.LightsControl.Empty\x12G\n\x08SetFlash\x12 .GSS2.LightsControl.FlashRequest\x1a\x19.GSS2.LightsControl.Empty\x12\x45\n\x07SetLoad\x12\x1f.GSS2.LightsControl.LoadRequest\x1a\x19.GSS2.LightsControl.Empty\x12K\n\nSetCpuLoad\x12\".GSS2.LightsControl.CpuLoadRequest\x1a\x19.GSS2.LightsControl.Emptyb\x06proto3')
+DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x0clights.proto\x12\x12GSS2.LightsControl\"\x07\n\x05\x45mpty\"I\n\x12StaticColorRequest\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\t\n\x01r\x18\x02 \x01(\x05\x12\t\n\x01g\x18\x03 \x01(\x05\x12\t\n\x01\x62\x18\x04 \x01(\x05\"\x8f\x01\n\x16StaticGradient2Request\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\x0e\n\x06left_r\x18\x02 \x01(\x05\x12\x0e\n\x06left_g\x18\x03 \x01(\x05\x12\x0e\n\x06left_b\x18\x04 \x01(\x05\x12\x0f\n\x07right_r\x18\x05 \x01(\x05\x12\x0f\n\x07right_g\x18\x06 \x01(\x05\x12\x0f\n\x07right_b\x18\x07 \x01(\x05\"\xc5\x01\n\x16StaticGradient3Request\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\x0e\n\x06left_r\x18\x02 \x01(\x05\x12\x0e\n\x06left_g\x18\x03 \x01(\x05\x12\x0e\n\x06left_b\x18\x04 \x01(\x05\x12\x10\n\x08middle_r\x18\x05 \x01(\x05\x12\x10\n\x08middle_g\x18\x06 \x01(\x05\x12\x10\n\x08middle_b\x18\x07 \x01(\x05\x12\x0f\n\x07right_r\x18\x08 \x01(\x05\x12\x0f\n\x07right_g\x18\t \x01(\x05\x12\x0f\n\x07right_b\x18\n \x01(\x05\"*\n\x14StaticRainbowRequest\x12\x12\n\nbrightness\x18\x01 \x01(\x01\"[\n\x15\x42reathingColorRequest\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\x12\t\n\x01r\x18\x03 \x01(\x05\x12\t\n\x01g\x18\x04 \x01(\x05\x12\t\n\x01\x62\x18\x05 \x01(\x05\"\xa1\x01\n\x19\x42reathingGradient2Request\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\x12\x0e\n\x06left_r\x18\x03 \x01(\x05\x12\x0e\n\x06left_g\x18\x04 \x01(\x05\x12\x0e\n\x06left_b\x18\x05 \x01(\x05\x12\x0f\n\x07right_r\x18\x06 \x01(\x05\x12\x0f\n\x07right_g\x18\x07 \x01(\x05\x12\x0f\n\x07right_b\x18\x08 \x01(\x05\"\xd7\x01\n\x19\x42reathingGradient3Request\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\x12\x0e\n\x06left_r\x18\x03 \x01(\x05\x12\x0e\n\x06left_g\x18\x04 \x01(\x05\x12\x0e\n\x06left_b\x18\x05 \x01(\x05\x12\x10\n\x08middle_r\x18\x06 \x01(\x05\x12\x10\n\x08middle_g\x18\x07 \x01(\x05\x12\x10\n\x08middle_b\x18\x08 \x01(\x05\x12\x0f\n\x07right_r\x18\t \x01(\x05\x12\x0f\n\x07right_g\x18\n \x01(\x05\x12\x0f\n\x07right_b\x18\x0b \x01(\x05\"<\n\x17\x42reathingRainbowRequest\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\"w\n\x13RunningColorRequest\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\x12\x0e\n\x06length\x18\x03 \x01(\x05\x12\x0c\n\x04\x66\x61\x64\x65\x18\x04 \x01(\x05\x12\t\n\x01r\x18\x05 \x01(\x05\x12\t\n\x01g\x18\x06 \x01(\x05\x12\t\n\x01\x62\x18\x07 \x01(\x05\"\x9f\x01\n\x17RunningGradient2Request\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\x12\x0e\n\x06left_r\x18\x03 \x01(\x05\x12\x0e\n\x06left_g\x18\x04 \x01(\x05\x12\x0e\n\x06left_b\x18\x05 \x01(\x05\x12\x0f\n\x07right_r\x18\x06 \x01(\x05\x12\x0f\n\x07right_g\x18\x07 \x01(\x05\x12\x0f\n\x07right_b\x18\x08 \x01(\x05\"\xd5\x01\n\x17RunningGradient3Request\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\x12\x0e\n\x06left_r\x18\x03 \x01(\x05\x12\x0e\n\x06left_g\x18\x04 \x01(\x05\x12\x0e\n\x06left_b\x18\x05 \x01(\x05\x12\x10\n\x08middle_r\x18\x06 \x01(\x05\x12\x10\n\x08middle_g\x18\x07 \x01(\x05\x12\x10\n\x08middle_b\x18\x08 \x01(\x05\x12\x0f\n\x07right_r\x18\t \x01(\x05\x12\x0f\n\x07right_g\x18\n \x01(\x05\x12\x0f\n\x07right_b\x18\x0b \x01(\x05\":\n\x15RunningRainbowRequest\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\"\xbb\x01\n\x0cSnakeRequest\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\x12\x13\n\x0bhead_length\x18\x03 \x01(\x05\x12\x13\n\x0btail_length\x18\x04 \x01(\x05\x12\x0e\n\x06head_r\x18\x05 \x01(\x05\x12\x0e\n\x06head_g\x18\x06 \x01(\x05\x12\x0e\n\x06head_b\x18\x07 \x01(\x05\x12\x0e\n\x06tail_r\x18\x08 \x01(\x05\x12\x0e\n\x06tail_g\x18\t \x01(\x05\x12\x0e\n\x06tail_b\x18\n \x01(\x05\"Q\n\x0b\x46ireRequest\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\x12\t\n\x01r\x18\x03 \x01(\x05\x12\t\n\x01g\x18\x04 \x01(\x05\x12\t\n\x01\x62\x18\x05 \x01(\x05\"U\n\x0fSnowfallRequest\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\x12\t\n\x01r\x18\x03 \x01(\x05\x12\t\n\x01g\x18\x04 \x01(\x05\x12\t\n\x01\x62\x18\x05 \x01(\x05\"R\n\x0c\x46lashRequest\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\x12\t\n\x01r\x18\x03 \x01(\x05\x12\t\n\x01g\x18\x04 \x01(\x05\x12\t\n\x01\x62\x18\x05 \x01(\x05\"x\n\x0bLoadRequest\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\x12\x0f\n\x07percent\x18\x03 \x01(\x01\x12\x14\n\x0clast_percent\x18\x04 \x01(\x01\x12\t\n\x01r\x18\x05 \x01(\x05\x12\t\n\x01g\x18\x06 \x01(\x05\x12\t\n\x01\x62\x18\x07 \x01(\x05\"T\n\x0e\x43puLoadRequest\x12\x12\n\nbrightness\x18\x01 \x01(\x01\x12\r\n\x05speed\x18\x02 \x01(\x01\x12\t\n\x01r\x18\x03 \x01(\x05\x12\t\n\x01g\x18\x04 \x01(\x05\x12\t\n\x01\x62\x18\x05 \x01(\x05\x32\xde\r\n\x06Lights\x12<\n\x04Ping\x12\x19.GSS2.LightsControl.Empty\x1a\x19.GSS2.LightsControl.Empty\x12\x42\n\nDisconnect\x12\x19.GSS2.LightsControl.Empty\x1a\x19.GSS2.LightsControl.Empty\x12>\n\x06SetOff\x12\x19.GSS2.LightsControl.Empty\x1a\x19.GSS2.LightsControl.Empty\x12S\n\x0eSetStaticColor\x12&.GSS2.LightsControl.StaticColorRequest\x1a\x19.GSS2.LightsControl.Empty\x12[\n\x12SetStaticGradient2\x12*.GSS2.LightsControl.StaticGradient2Request\x1a\x19.GSS2.LightsControl.Empty\x12[\n\x12SetStaticGradient3\x12*.GSS2.LightsControl.StaticGradient3Request\x1a\x19.GSS2.LightsControl.Empty\x12W\n\x10SetStaticRainbow\x12(.GSS2.LightsControl.StaticRainbowRequest\x1a\x19.GSS2.LightsControl.Empty\x12Y\n\x11SetBreathingColor\x12).GSS2.LightsControl.BreathingColorRequest\x1a\x19.GSS2.LightsControl.Empty\x12\x61\n\x15SetBreathingGradient2\x12-.GSS2.LightsControl.BreathingGradient2Request\x1a\x19.GSS2.LightsControl.Empty\x12\x61\n\x15SetBreathingGradient3\x12-.GSS2.LightsControl.BreathingGradient3Request\x1a\x19.GSS2.LightsControl.Empty\x12]\n\x13SetBreathingRainbow\x12+.GSS2.LightsControl.BreathingRainbowRequest\x1a\x19.GSS2.LightsControl.Empty\x12U\n\x0fSetRunningColor\x12\'.GSS2.LightsControl.RunningColorRequest\x1a\x19.GSS2.LightsControl.Empty\x12]\n\x13SetRunningGradient2\x12+.GSS2.LightsControl.RunningGradient2Request\x1a\x19.GSS2.LightsControl.Empty\x12]\n\x13SetRunningGradient3\x12+.GSS2.LightsControl.RunningGradient3Request\x1a\x19.GSS2.LightsControl.Empty\x12Y\n\x11SetRunningRainbow\x12).GSS2.LightsControl.RunningRainbowRequest\x1a\x19.GSS2.LightsControl.Empty\x12G\n\x08SetSnake\x12 .GSS2.LightsControl.SnakeRequest\x1a\x19.GSS2.LightsControl.Empty\x12\x45\n\x07SetFire\x12\x1f.GSS2.LightsControl.FireRequest\x1a\x19.GSS2.LightsControl.Empty\x12M\n\x0bSetSnowfall\x12#.GSS2.LightsControl.SnowfallRequest\x1a\x19.GSS2.LightsControl.Empty\x12G\n\x08SetFlash\x12 .GSS2.LightsControl.FlashRequest\x1a\x19.GSS2.LightsControl.Empty\x12\x45\n\x07SetLoad\x12\x1f.GSS2.LightsControl.LoadRequest\x1a\x19.GSS2.LightsControl.Empty\x12K\n\nSetCpuLoad\x12\".GSS2.LightsControl.CpuLoadRequest\x1a\x19.GSS2.LightsControl.EmptyB\"\xaa\x02\x1fGSS2.LightsControl.CSharpClientb\x06proto3')
_globals = globals()
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'lights_pb2', _globals)
if not _descriptor._USE_C_DESCRIPTORS:
- DESCRIPTOR._loaded_options = None
+ _globals['DESCRIPTOR']._loaded_options = None
+ _globals['DESCRIPTOR']._serialized_options = b'\252\002\037GSS2.LightsControl.CSharpClient'
_globals['_EMPTY']._serialized_start=36
_globals['_EMPTY']._serialized_end=43
_globals['_STATICCOLORREQUEST']._serialized_start=45
@@ -70,5 +71,5 @@ if not _descriptor._USE_C_DESCRIPTORS:
_globals['_CPULOADREQUEST']._serialized_start=2172
_globals['_CPULOADREQUEST']._serialized_end=2256
_globals['_LIGHTS']._serialized_start=2259
- _globals['_LIGHTS']._serialized_end=3949
+ _globals['_LIGHTS']._serialized_end=4017
# @@protoc_insertion_point(module_scope)
diff --git a/GSS2.LightsControl/Server/lights_pb2_grpc.py b/GSS2.LightsControl/Server/lights_pb2_grpc.py
index 718b75c..0046c15 100644
--- a/GSS2.LightsControl/Server/lights_pb2_grpc.py
+++ b/GSS2.LightsControl/Server/lights_pb2_grpc.py
@@ -39,6 +39,11 @@ class LightsStub(object):
request_serializer=lights__pb2.Empty.SerializeToString,
response_deserializer=lights__pb2.Empty.FromString,
_registered_method=True)
+ self.Disconnect = channel.unary_unary(
+ '/GSS2.LightsControl.Lights/Disconnect',
+ request_serializer=lights__pb2.Empty.SerializeToString,
+ response_deserializer=lights__pb2.Empty.FromString,
+ _registered_method=True)
self.SetOff = channel.unary_unary(
'/GSS2.LightsControl.Lights/SetOff',
request_serializer=lights__pb2.Empty.SerializeToString,
@@ -145,6 +150,12 @@ class LightsServicer(object):
context.set_details('Method not implemented!')
raise NotImplementedError('Method not implemented!')
+ def Disconnect(self, request, context):
+ """Missing associated documentation comment in .proto file."""
+ context.set_code(grpc.StatusCode.UNIMPLEMENTED)
+ context.set_details('Method not implemented!')
+ raise NotImplementedError('Method not implemented!')
+
def SetOff(self, request, context):
"""Missing associated documentation comment in .proto file."""
context.set_code(grpc.StatusCode.UNIMPLEMENTED)
@@ -267,6 +278,11 @@ def add_LightsServicer_to_server(servicer, server):
request_deserializer=lights__pb2.Empty.FromString,
response_serializer=lights__pb2.Empty.SerializeToString,
),
+ 'Disconnect': grpc.unary_unary_rpc_method_handler(
+ servicer.Disconnect,
+ request_deserializer=lights__pb2.Empty.FromString,
+ response_serializer=lights__pb2.Empty.SerializeToString,
+ ),
'SetOff': grpc.unary_unary_rpc_method_handler(
servicer.SetOff,
request_deserializer=lights__pb2.Empty.FromString,
@@ -400,6 +416,33 @@ class Lights(object):
metadata,
_registered_method=True)
+ @staticmethod
+ def Disconnect(request,
+ target,
+ options=(),
+ channel_credentials=None,
+ call_credentials=None,
+ insecure=False,
+ compression=None,
+ wait_for_ready=None,
+ timeout=None,
+ metadata=None):
+ return grpc.experimental.unary_unary(
+ request,
+ target,
+ '/GSS2.LightsControl.Lights/Disconnect',
+ lights__pb2.Empty.SerializeToString,
+ lights__pb2.Empty.FromString,
+ options,
+ channel_credentials,
+ insecure,
+ call_credentials,
+ compression,
+ wait_for_ready,
+ timeout,
+ metadata,
+ _registered_method=True)
+
@staticmethod
def SetOff(request,
target,
diff --git a/GSS2.LightsControl/lights.proto b/GSS2.LightsControl/lights.proto
index c016a3e..90c6c2f 100644
--- a/GSS2.LightsControl/lights.proto
+++ b/GSS2.LightsControl/lights.proto
@@ -6,6 +6,7 @@ package GSS2.LightsControl;
service Lights {
rpc Ping (Empty) returns (Empty);
+ rpc Disconnect (Empty) returns (Empty);
rpc SetOff (Empty) returns (Empty);
diff --git a/GSS2.Test/Program.cs b/GSS2.Test/Program.cs
index 134ba9d..ef17f60 100644
--- a/GSS2.Test/Program.cs
+++ b/GSS2.Test/Program.cs
@@ -26,9 +26,9 @@ public class Program
var configuration = serviceProvider.GetService();
if (configuration is null)
throw new Exception("Cannot get configuration");
- var serviceConfiguration = configuration.GetValue("Lights");
+ var serviceConfiguration = configuration.GetSection("Hardware:Lights").Get();
if (serviceConfiguration is null)
- throw new InvalidConfigurationException("Cannot get configuration (Lights)");
+ throw new InvalidConfigurationException("Cannot get configuration (Hardware:Lights)");
var logger = serviceProvider.GetService>();
if (logger is null)
throw new Exception("Cannot get logger");
@@ -41,9 +41,9 @@ public class Program
var configuration = serviceProvider.GetService();
if (configuration is null)
throw new Exception("Cannot get configuration");
- var serviceConfiguration = configuration.GetValue("TemperatureHumidity");
+ var serviceConfiguration = configuration.GetSection("Hardware:TemperatureHumidity").Get();
if (serviceConfiguration is null)
- throw new InvalidConfigurationException("Cannot get configuration (TemperatureHumidity)");
+ throw new InvalidConfigurationException("Cannot get configuration (Hardware:TemperatureHumidity)");
var logger = serviceProvider.GetService>();
if (logger is null)
throw new Exception("Cannot get logger");
diff --git a/GSS2.Test/Worker.cs b/GSS2.Test/Worker.cs
index 0588663..e2dd286 100644
--- a/GSS2.Test/Worker.cs
+++ b/GSS2.Test/Worker.cs
@@ -7,23 +7,19 @@ namespace GSS2.Test;
public class Worker(
ILogger logger,
AmineContentCalibrationContext calibrationContext,
- LightsService lightsService,
- TemperatureHumidityService temperatureHumidity
+ LightsService lightsService
) : BackgroundService
{
private readonly ILogger _logger = logger;
private readonly AmineContentCalibrationContext _calibrationContext = calibrationContext;
private readonly LightsService _lightsService = lightsService;
- private readonly TemperatureHumidityService _temperatureHumidity = temperatureHumidity;
protected override async Task ExecuteAsync(CancellationToken cancellationToken)
{
_ = _lightsService.Run(cancellationToken);
- await _lightsService.SnowfallAsync(0.3, 1, Color.Aqua, cancellationToken);
+ _ = _lightsService.SnowfallAsync(0.3, 1, Color.Aqua, cancellationToken);
while (!cancellationToken.IsCancellationRequested)
{
- var (temperature, humidity) = await _temperatureHumidity.MeasureAsync();
- _logger.LogInformation("Temperature: {}, RelativeHumidity: {}", temperature, humidity);
await Task.Delay(5000);
}
}
diff --git a/GSS2.Test/appsettings.json b/GSS2.Test/appsettings.json
index d0ccc75..d67b159 100644
--- a/GSS2.Test/appsettings.json
+++ b/GSS2.Test/appsettings.json
@@ -23,11 +23,11 @@
"MaxUv365PwmDuty": 1.0
},
"TemperatureHumidity": {
- "Bus": 0,
- "Address": 68
+ "Bus": 6,
+ "Address": 69
},
"Lights": {
- "ServerAddress": "localhost:50051"
+ "ServerAddress": "http://127.0.0.1:50051"
}
}
}
\ No newline at end of file