yay
This commit is contained in:
1
.idea/.idea.VisionAsist/.idea/.name
generated
Normal file
1
.idea/.idea.VisionAsist/.idea/.name
generated
Normal file
@@ -0,0 +1 @@
|
||||
VisionAsist
|
||||
@@ -2,9 +2,9 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
x:Class="ModuleWeather.WeatherView">
|
||||
<StackPanel Margin="20" Spacing="10" Background="#2b2b2b">
|
||||
<TextBlock Name="StatusText" Text="Введите город:" Foreground="White"/>
|
||||
<TextBox Name="CityInput" Watermark="Например: Москва"/>
|
||||
<Button Content="Узнать погоду" Click="GetWeatherButton_Click"
|
||||
<Button Content="Обновить" Click="Update"
|
||||
HorizontalAlignment="Stretch" HorizontalContentAlignment="Center"/>
|
||||
<TextBlock Name="StatusText" Text="Выберите порт" Foreground="White"/>
|
||||
<ComboBox Name="PortComboBox" SelectionChanged="OnPortChanged"/>
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
@@ -1,6 +1,8 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Media;
|
||||
using System.IO.Ports;
|
||||
using System.Reflection;
|
||||
|
||||
namespace ModuleWeather;
|
||||
|
||||
@@ -8,15 +10,15 @@ public partial class WeatherView : UserControl
|
||||
{
|
||||
public WeatherView() => InitializeComponent();
|
||||
|
||||
private void GetWeatherButton_Click(object? sender, RoutedEventArgs e)
|
||||
private void Update(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var city = this.FindControl<TextBox>("CityInput")?.Text;
|
||||
var status = this.FindControl<TextBlock>("StatusText");
|
||||
var ports = SerialPort.GetPortNames();
|
||||
PortComboBox.ItemsSource = ports; // Привязываем массив к списку
|
||||
|
||||
if (string.IsNullOrWhiteSpace(city)) {
|
||||
status.Text = "Ошибка: введите город";
|
||||
return;
|
||||
}
|
||||
status.Text = $"В городе {city} сейчас +20°C"; // Тут могла быть логика API
|
||||
|
||||
}
|
||||
private void OnPortChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
WeatherModule.port = PortComboBox.SelectedItem as string;
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
@@ -29,15 +37,29 @@ public class WeatherModule : IModule
|
||||
|
||||
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 "Команда не найдена";
|
||||
}
|
||||
|
||||
@@ -6,29 +6,40 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<!-- ВОТ ЭТА СТРОЧКА: она заставит компилятор создать Module.dll -->
|
||||
<AssemblyName>Module</AssemblyName>
|
||||
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\VisionAsist.SDK\VisionAsist.SDK.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<!-- Твой скрипт копирования остается без изменений, теперь он найдет файл -->
|
||||
<Target Name="CopyModuleToCore" AfterTargets="PostBuildEvent">
|
||||
<ItemGroup>
|
||||
<ModuleFiles Include="$(TargetDir)Module.dll" />
|
||||
<ModuleFiles Include="$(TargetDir)Module.pdb" Condition="Exists('$(TargetDir)Module.pdb')" />
|
||||
<!-- Копируем все DLL и PDB из корня -->
|
||||
<ModuleFiles Include="$(TargetDir)*.dll" />
|
||||
<ModuleFiles Include="$(TargetDir)*.pdb" />
|
||||
|
||||
<!-- Ищем нативную либу .so ВЕЗДЕ в выходной папке (включая подпапки runtimes) -->
|
||||
<NativeLibs Include="$(TargetDir)**\*.so" />
|
||||
</ItemGroup>
|
||||
|
||||
<Message Text="Копирую Module.dll в папку ядра..." Importance="high" />
|
||||
<Message Text="Копирую файлы модуля и нативные библиотеки..." Importance="high" />
|
||||
|
||||
<Copy SourceFiles="@(ModuleFiles)"
|
||||
DestinationFolder="/home/egor/RiderProjects/Vision/VisionAsist/bin/Debug/net10.0/Modules/ModuleWeather/"
|
||||
OverwriteReadOnlyFiles="true" />
|
||||
|
||||
<!-- Копируем .so файлы ПРЯМО в корень папки модуля -->
|
||||
<Copy SourceFiles="@(NativeLibs)"
|
||||
DestinationFolder="/home/egor/RiderProjects/Vision/VisionAsist/bin/Debug/net10.0/Modules/ModuleWeather/"
|
||||
OverwriteReadOnlyFiles="true" />
|
||||
</Target>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Avalonia" Version="11.3.12" />
|
||||
<PackageReference Include="Avalonia.Desktop" Version="11.3.12" />
|
||||
<PackageReference Include="System.IO.Ports" Version="11.0.0-preview.2.26159.112" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -8,7 +8,31 @@ public class Selector
|
||||
{
|
||||
if (text.Contains("вижен"))
|
||||
{
|
||||
Console.WriteLine("dddddd");
|
||||
string novision = text.Replace("вижен", "").Trim();
|
||||
foreach (var module in Core.modulelist)
|
||||
{
|
||||
foreach (var command in module.commands)
|
||||
{
|
||||
if (command.Contains("*"))
|
||||
{
|
||||
string wopo = command.Replace("*", "").Trim();
|
||||
if (novision.Contains(wopo))
|
||||
{
|
||||
|
||||
Console.WriteLine(module.Module.Execute(command));
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (command == novision)
|
||||
{
|
||||
Console.WriteLine(module.Module.Execute(novision));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,7 +172,7 @@ public class TrigerCore : IDisposable
|
||||
string text = el.GetString() ?? "";
|
||||
if (!string.IsNullOrWhiteSpace(text))
|
||||
{
|
||||
RecognizedText += text + " ";
|
||||
RecognizedText = text;
|
||||
// Безопасный проброс в UI поток Avalonia
|
||||
Dispatcher.UIThread.Post(() => OnRecognized?.Invoke(text));
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ public class SettingsViewModel : ViewModelBase
|
||||
foreach (var module in Core.modulelist)
|
||||
{
|
||||
|
||||
|
||||
AddModule(module.Name);
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user