yay
This commit is contained in:
@@ -1,12 +1,20 @@
|
||||
using Avalonia.Controls;
|
||||
using VisionAsist.SDK;
|
||||
using System.IO.Ports;
|
||||
namespace ModuleWeather;
|
||||
|
||||
public class WeatherModule : IModule
|
||||
{
|
||||
public SerialPort myPort = new ();
|
||||
public static string port;
|
||||
public WeatherModule()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
public string Name => "Прогноз Погоды";
|
||||
|
||||
public string[] GetCommands() => new[] { "Погода", "Пинг" };
|
||||
public string[] GetCommands() => new[] { "погода", "поверни на *", "верни *" };
|
||||
|
||||
public void Settings(object[] args)
|
||||
{
|
||||
@@ -15,7 +23,7 @@ public class WeatherModule : IModule
|
||||
|
||||
var win = new Window
|
||||
{
|
||||
Title = "Окно Погоды",
|
||||
Title = "Настройки",
|
||||
Content = new WeatherView(), // Вставляем наш контрол
|
||||
Width = 350,
|
||||
Height = 250,
|
||||
@@ -26,18 +34,32 @@ public class WeatherModule : IModule
|
||||
else win.Show();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public object Execute(string command)
|
||||
{
|
||||
|
||||
myPort.Close();
|
||||
myPort = new SerialPort(port, 9600);
|
||||
myPort.Open();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
switch (command)
|
||||
{
|
||||
case "Погода":
|
||||
case "погода":
|
||||
|
||||
return "Окно открыто успешно";
|
||||
return "Погода хорошая!";
|
||||
|
||||
case "Пинг":
|
||||
return "Pong! Модуль погоды активен.";
|
||||
case "поверни на *":
|
||||
myPort.WriteLine("178");
|
||||
|
||||
return "Повернул на 180";
|
||||
case "верни *":
|
||||
myPort.WriteLine("0");
|
||||
|
||||
return "Вернул в 0";
|
||||
default:
|
||||
return "Команда не найдена";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user