Skip to content

Commit

Permalink
💾 Feat: 实现了自组网部分的自动建立与自动连接, 新增语言项, 设备页面 UI 更新, 设置页面性能页显示端口号. Crequenc…
Browse files Browse the repository at this point in the history
…y/KitX#176.7
  • Loading branch information
Dynesshely committed Nov 20, 2022
1 parent a259225 commit 49a7661
Show file tree
Hide file tree
Showing 18 changed files with 258 additions and 33 deletions.
3 changes: 3 additions & 0 deletions Data/AppConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ public class Config_Web
[JsonInclude]
public int UDPPortReceive { get; set; } = 24040;

[JsonInclude]
public int UDPSendFrequency { get; set; } = 2000;

[JsonInclude]
public string UDPBroadcastAddress { get; set; } = "224.0.0.0";

Expand Down
4 changes: 2 additions & 2 deletions Data/GlobalInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,15 @@ internal static class GlobalInfo
//internal const string LogTemplate = "[{Timestamp:yyyy-MM-dd HH:mm:ss.fff zzz}] [{Level:u3}] " +
// "{Message:lj}{NewLine}{Exception}";

internal static int PluginServerPort = 0;
internal static int PluginServerPort = -1;

internal static bool Running = true;

internal static bool Exiting = false;

internal static bool IsMainMachine = false;

internal static int DeviceServerPort = 0;
internal static int DeviceServerPort = -1;

internal static DateTime ServerBuildTime = new();

Expand Down
3 changes: 2 additions & 1 deletion Languages/en-us.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
<x:String x:Key="Text_Settings_Personalise_Theme_HighContrast">High Contrast</x:String>
<x:String x:Key="Text_Settings_Personalise_Theme_Follow">Follow System</x:String>
<x:String x:Key="Text_Settings_Performence">Performence</x:String>
<x:String x:Key="Text_Settings_Performence_Web_Port">Port</x:String>
<x:String x:Key="Text_Settings_Performence_Web_PluginsServerPort">Plugins Communication Port</x:String>
<x:String x:Key="Text_Settings_Performence_Web_DevicesServerPort">Devices Communication Port</x:String>
<x:String x:Key="Text_Settings_Performence_Web_MyIP_Filter">Native IP Filter</x:String>
<x:String x:Key="Text_Settings_Performence_Greeting_Interval">Greeting Text Update Interval</x:String>
<x:String x:Key="Text_Settings_Performence_Log">Log File Relative Settings</x:String>
Expand Down
3 changes: 2 additions & 1 deletion Languages/fr-fr.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
<x:String x:Key="Text_Settings_Personalise_Theme_HighContrast">contraste élevé</x:String>
<x:String x:Key="Text_Settings_Personalise_Theme_Follow">suivre le système</x:String>
<x:String x:Key="Text_Settings_Performence">performance</x:String>
<x:String x:Key="Text_Settings_Performence_Web_Port">Port</x:String>
<x:String x:Key="Text_Settings_Performence_Web_PluginsServerPort">Port de communication enfichable</x:String>
<x:String x:Key="Text_Settings_Performence_Web_DevicesServerPort">Port de communication de l'appareil</x:String>
<x:String x:Key="Text_Settings_Performence_Web_MyIP_Filter">Règles de filtrage IP natives</x:String>
<x:String x:Key="Text_Settings_Performence_Greeting_Interval">Mise à jour du message d'accueil retardée</x:String>
<x:String x:Key="Text_Settings_Performence_Log">Paramètres liés au fichier journal</x:String>
Expand Down
3 changes: 2 additions & 1 deletion Languages/ja-jp.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
<x:String x:Key="Text_Settings_Personalise_Theme_HighContrast">ハイコントラスト</x:String>
<x:String x:Key="Text_Settings_Personalise_Theme_Follow">システムに従ってください</x:String>
<x:String x:Key="Text_Settings_Performence">パフォーマンス</x:String>
<x:String x:Key="Text_Settings_Performence_Web_Port">ポート</x:String>
<x:String x:Key="Text_Settings_Performence_Web_PluginsServerPort">プラグイン通信ポート</x:String>
<x:String x:Key="Text_Settings_Performence_Web_DevicesServerPort">デバイス通信ポート</x:String>
<x:String x:Key="Text_Settings_Performence_Web_MyIP_Filter">ネイティブ IP フィルタリング ルール</x:String>
<x:String x:Key="Text_Settings_Performence_Greeting_Interval">あいさつ更新が遅れる</x:String>
<x:String x:Key="Text_Settings_Performence_Log">ログファイル関連の設定</x:String>
Expand Down
3 changes: 2 additions & 1 deletion Languages/ko-kr.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
<x:String x:Key="Text_Settings_Personalise_Theme_HighContrast">고대비</x:String>
<x:String x:Key="Text_Settings_Personalise_Theme_Follow">시스템을 따르다</x:String>
<x:String x:Key="Text_Settings_Performence">성능</x:String>
<x:String x:Key="Text_Settings_Performence_Web_Port">포트</x:String>
<x:String x:Key="Text_Settings_Performence_Web_PluginsServerPort">플러그인 통신 포트</x:String>
<x:String x:Key="Text_Settings_Performence_Web_DevicesServerPort">장치 통신 포트</x:String>
<x:String x:Key="Text_Settings_Performence_Web_MyIP_Filter">기본 IP 필터링 규칙</x:String>
<x:String x:Key="Text_Settings_Performence_Greeting_Interval">인사말 업데이트가 지연되었습니다.</x:String>
<x:String x:Key="Text_Settings_Performence_Log">로그 파일 관련 설정</x:String>
Expand Down
3 changes: 2 additions & 1 deletion Languages/ru-ru.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
<x:String x:Key="Text_Settings_Personalise_Theme_HighContrast">высокий контраст</x:String>
<x:String x:Key="Text_Settings_Personalise_Theme_Follow">следовать системе</x:String>
<x:String x:Key="Text_Settings_Performence">производительность</x:String>
<x:String x:Key="Text_Settings_Performence_Web_Port">порт</x:String>
<x:String x:Key="Text_Settings_Performence_Web_PluginsServerPort">Подключаемый коммуникационный порт</x:String>
<x:String x:Key="Text_Settings_Performence_Web_DevicesServerPort">Порт связи устройства</x:String>
<x:String x:Key="Text_Settings_Performence_Web_MyIP_Filter">Собственные правила IP-фильтрации</x:String>
<x:String x:Key="Text_Settings_Performence_Greeting_Interval">Обновление приветствия отложено</x:String>
<x:String x:Key="Text_Settings_Performence_Log">Настройки, связанные с файлом журнала</x:String>
Expand Down
3 changes: 2 additions & 1 deletion Languages/zh-cn.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
<x:String x:Key="Text_Settings_Personalise_Theme_HighContrast">高对比度</x:String>
<x:String x:Key="Text_Settings_Personalise_Theme_Follow">跟随系统</x:String>
<x:String x:Key="Text_Settings_Performence">性能</x:String>
<x:String x:Key="Text_Settings_Performence_Web_Port">端口</x:String>
<x:String x:Key="Text_Settings_Performence_Web_PluginsServerPort">插件通信端口</x:String>
<x:String x:Key="Text_Settings_Performence_Web_DevicesServerPort">设备通信端口</x:String>
<x:String x:Key="Text_Settings_Performence_Web_MyIP_Filter">本机IP过滤规则</x:String>
<x:String x:Key="Text_Settings_Performence_Greeting_Interval">招呼语更新延迟</x:String>
<x:String x:Key="Text_Settings_Performence_Log">日志文件相关设置</x:String>
Expand Down
3 changes: 2 additions & 1 deletion Languages/zh-tw.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@
<x:String x:Key="Text_Settings_Personalise_Theme_HighContrast">高對比度</x:String>
<x:String x:Key="Text_Settings_Personalise_Theme_Follow">跟隨系統</x:String>
<x:String x:Key="Text_Settings_Performence">性能</x:String>
<x:String x:Key="Text_Settings_Performence_Web_Port">端口</x:String>
<x:String x:Key="Text_Settings_Performence_Web_PluginsServerPort">插件通信端口</x:String>
<x:String x:Key="Text_Settings_Performence_Web_DevicesServerPort">設備通信端口</x:String>
<x:String x:Key="Text_Settings_Performence_Web_MyIP_Filter">本機IP過濾器</x:String>
<x:String x:Key="Text_Settings_Performence_Greeting_Interval">招呼語更新延遲</x:String>
<x:String x:Key="Text_Settings_Performence_Log">日志文檔相關設定</x:String>
Expand Down
2 changes: 1 addition & 1 deletion Models/Plugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ public class Plugin
// | | ; | Q | J | K | X | B | M | W | V | Z | |
// |------,-',--'--,'---'---'---'---'---'---'-,-'---',--,------|
// | ctrl | | alt | | alt | | ctrl |
// '------' '-----'--------------------------'------' '------'
// '------' '-----'--------------------------'------' '------'
27 changes: 19 additions & 8 deletions Services/DevicesManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ namespace KitX_Dashboard.Services
{
internal class DevicesManager
{
internal static List<DeviceInfoStruct>? receivedDeviceInfoStruct4Watch;

internal static readonly Queue<DeviceInfoStruct> deviceInfoStructs = new();

private static readonly object AddDeviceCard2ViewLock = new();
Expand Down Expand Up @@ -125,6 +127,7 @@ internal static void KeepCheckAndRemove()
internal static void Update(DeviceInfoStruct deviceInfo)
{
deviceInfoStructs.Enqueue(deviceInfo);
receivedDeviceInfoStruct4Watch?.Add(deviceInfo);
}

/// <summary>
Expand All @@ -136,6 +139,7 @@ internal static void Watch4MainDevice()
{
try
{
receivedDeviceInfoStruct4Watch = new();
int checkedTime = 0;
bool hadMainDevice = false;
DateTime earliestBuiltServerTime = DateTime.Now;
Expand All @@ -150,35 +154,40 @@ internal static void Watch4MainDevice()
{
try
{
foreach (var item in Program.DeviceCards)
foreach (var item in receivedDeviceInfoStruct4Watch)
{
if (item.viewModel.deviceInfo.IsMainDevice)
if (item.IsMainDevice)
{
if (item.viewModel.deviceInfo.DeviceServerBuildTime
< earliestBuiltServerTime)
if (item.DeviceServerBuildTime < earliestBuiltServerTime)
{
serverPort = item.viewModel.deviceInfo.DeviceServerPort;
serverAddress = item.viewModel.deviceInfo.IPv4;
serverPort = item.DeviceServerPort;
serverAddress = item.IPv4;
}
hadMainDevice = true;
}
}
++checkedTime;
if (checkedTime == 5)
if (checkedTime == 7)
{
timer.Stop();
receivedDeviceInfoStruct4Watch?.Clear();
receivedDeviceInfoStruct4Watch = null;
WatchingOver(hadMainDevice, serverAddress, serverPort);
}
}
catch (Exception e)
{
receivedDeviceInfoStruct4Watch?.Clear();
receivedDeviceInfoStruct4Watch = null;
Log.Error("In Watch4MainDevice", e);
}
};
timer.Start();
}
catch (Exception ex)
{
receivedDeviceInfoStruct4Watch?.Clear();
receivedDeviceInfoStruct4Watch = null;
Log.Error("In Watch4MainDevice", ex);
}
}).Start();
Expand All @@ -189,9 +198,11 @@ internal static void Watch4MainDevice()
/// </summary>
internal static void WatchingOver(bool hadMainDevice, string serverAddress, int serverPort)
{
Log.Information($"In WatchingOver: hadMainDevice: {hadMainDevice}, " +
$"serverAddress: {serverAddress}, serverPort: {serverPort}");
if (hadMainDevice)
{
Program.WebManager?.devicesServer?.AttendServer($"{serverAddress}:{serverPort}");
Program.WebManager?.devicesServer?.AttendServer(serverAddress, serverPort);
}
else
{
Expand Down
Loading

0 comments on commit 49a7661

Please sign in to comment.