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"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
x:Class="ModuleWeather.WeatherView">
|
x:Class="ModuleWeather.WeatherView">
|
||||||
<StackPanel Margin="20" Spacing="10" Background="#2b2b2b">
|
<StackPanel Margin="20" Spacing="10" Background="#2b2b2b">
|
||||||
<TextBlock Name="StatusText" Text="Введите город:" Foreground="White"/>
|
<Button Content="Обновить" Click="Update"
|
||||||
<TextBox Name="CityInput" Watermark="Например: Москва"/>
|
|
||||||
<Button Content="Узнать погоду" Click="GetWeatherButton_Click"
|
|
||||||
HorizontalAlignment="Stretch" HorizontalContentAlignment="Center"/>
|
HorizontalAlignment="Stretch" HorizontalContentAlignment="Center"/>
|
||||||
|
<TextBlock Name="StatusText" Text="Выберите порт" Foreground="White"/>
|
||||||
|
<ComboBox Name="PortComboBox" SelectionChanged="OnPortChanged"/>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
|
using System.IO.Ports;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace ModuleWeather;
|
namespace ModuleWeather;
|
||||||
|
|
||||||
@@ -8,15 +10,15 @@ public partial class WeatherView : UserControl
|
|||||||
{
|
{
|
||||||
public WeatherView() => InitializeComponent();
|
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 ports = SerialPort.GetPortNames();
|
||||||
var status = this.FindControl<TextBlock>("StatusText");
|
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 Avalonia.Controls;
|
||||||
using VisionAsist.SDK;
|
using VisionAsist.SDK;
|
||||||
|
using System.IO.Ports;
|
||||||
namespace ModuleWeather;
|
namespace ModuleWeather;
|
||||||
|
|
||||||
public class WeatherModule : IModule
|
public class WeatherModule : IModule
|
||||||
{
|
{
|
||||||
|
public SerialPort myPort = new ();
|
||||||
|
public static string port;
|
||||||
|
public WeatherModule()
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
public string Name => "Прогноз Погоды";
|
public string Name => "Прогноз Погоды";
|
||||||
|
|
||||||
public string[] GetCommands() => new[] { "Погода", "Пинг" };
|
public string[] GetCommands() => new[] { "погода", "поверни на *", "верни *" };
|
||||||
|
|
||||||
public void Settings(object[] args)
|
public void Settings(object[] args)
|
||||||
{
|
{
|
||||||
@@ -15,7 +23,7 @@ public class WeatherModule : IModule
|
|||||||
|
|
||||||
var win = new Window
|
var win = new Window
|
||||||
{
|
{
|
||||||
Title = "Окно Погоды",
|
Title = "Настройки",
|
||||||
Content = new WeatherView(), // Вставляем наш контрол
|
Content = new WeatherView(), // Вставляем наш контрол
|
||||||
Width = 350,
|
Width = 350,
|
||||||
Height = 250,
|
Height = 250,
|
||||||
@@ -29,15 +37,29 @@ public class WeatherModule : IModule
|
|||||||
|
|
||||||
public object Execute(string command)
|
public object Execute(string command)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
myPort.Close();
|
||||||
|
myPort = new SerialPort(port, 9600);
|
||||||
|
myPort.Open();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
switch (command)
|
switch (command)
|
||||||
{
|
{
|
||||||
case "Погода":
|
case "погода":
|
||||||
|
|
||||||
return "Окно открыто успешно";
|
return "Погода хорошая!";
|
||||||
|
|
||||||
case "Пинг":
|
case "поверни на *":
|
||||||
return "Pong! Модуль погоды активен.";
|
myPort.WriteLine("178");
|
||||||
|
|
||||||
|
return "Повернул на 180";
|
||||||
|
case "верни *":
|
||||||
|
myPort.WriteLine("0");
|
||||||
|
|
||||||
|
return "Вернул в 0";
|
||||||
default:
|
default:
|
||||||
return "Команда не найдена";
|
return "Команда не найдена";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,29 +6,40 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<!-- ВОТ ЭТА СТРОЧКА: она заставит компилятор создать Module.dll -->
|
<!-- ВОТ ЭТА СТРОЧКА: она заставит компилятор создать Module.dll -->
|
||||||
<AssemblyName>Module</AssemblyName>
|
<AssemblyName>Module</AssemblyName>
|
||||||
|
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
|
||||||
|
<RuntimeIdentifier>linux-x64</RuntimeIdentifier>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\VisionAsist.SDK\VisionAsist.SDK.csproj" />
|
<ProjectReference Include="..\VisionAsist.SDK\VisionAsist.SDK.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<!-- Твой скрипт копирования остается без изменений, теперь он найдет файл -->
|
|
||||||
<Target Name="CopyModuleToCore" AfterTargets="PostBuildEvent">
|
<Target Name="CopyModuleToCore" AfterTargets="PostBuildEvent">
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ModuleFiles Include="$(TargetDir)Module.dll" />
|
<!-- Копируем все DLL и PDB из корня -->
|
||||||
<ModuleFiles Include="$(TargetDir)Module.pdb" Condition="Exists('$(TargetDir)Module.pdb')" />
|
<ModuleFiles Include="$(TargetDir)*.dll" />
|
||||||
|
<ModuleFiles Include="$(TargetDir)*.pdb" />
|
||||||
|
|
||||||
|
<!-- Ищем нативную либу .so ВЕЗДЕ в выходной папке (включая подпапки runtimes) -->
|
||||||
|
<NativeLibs Include="$(TargetDir)**\*.so" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<Message Text="Копирую Module.dll в папку ядра..." Importance="high" />
|
<Message Text="Копирую файлы модуля и нативные библиотеки..." Importance="high" />
|
||||||
|
|
||||||
<Copy SourceFiles="@(ModuleFiles)"
|
<Copy SourceFiles="@(ModuleFiles)"
|
||||||
DestinationFolder="/home/egor/RiderProjects/Vision/VisionAsist/bin/Debug/net10.0/Modules/ModuleWeather/"
|
DestinationFolder="/home/egor/RiderProjects/Vision/VisionAsist/bin/Debug/net10.0/Modules/ModuleWeather/"
|
||||||
OverwriteReadOnlyFiles="true" />
|
OverwriteReadOnlyFiles="true" />
|
||||||
|
|
||||||
|
<!-- Копируем .so файлы ПРЯМО в корень папки модуля -->
|
||||||
|
<Copy SourceFiles="@(NativeLibs)"
|
||||||
|
DestinationFolder="/home/egor/RiderProjects/Vision/VisionAsist/bin/Debug/net10.0/Modules/ModuleWeather/"
|
||||||
|
OverwriteReadOnlyFiles="true" />
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia" Version="11.3.12" />
|
<PackageReference Include="Avalonia" Version="11.3.12" />
|
||||||
<PackageReference Include="Avalonia.Desktop" 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>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -8,7 +8,31 @@ public class Selector
|
|||||||
{
|
{
|
||||||
if (text.Contains("вижен"))
|
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() ?? "";
|
string text = el.GetString() ?? "";
|
||||||
if (!string.IsNullOrWhiteSpace(text))
|
if (!string.IsNullOrWhiteSpace(text))
|
||||||
{
|
{
|
||||||
RecognizedText += text + " ";
|
RecognizedText = text;
|
||||||
// Безопасный проброс в UI поток Avalonia
|
// Безопасный проброс в UI поток Avalonia
|
||||||
Dispatcher.UIThread.Post(() => OnRecognized?.Invoke(text));
|
Dispatcher.UIThread.Post(() => OnRecognized?.Invoke(text));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ public class SettingsViewModel : ViewModelBase
|
|||||||
foreach (var module in Core.modulelist)
|
foreach (var module in Core.modulelist)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
AddModule(module.Name);
|
AddModule(module.Name);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user