Zixuan 2 weeks ago
parent
commit
53af44a12d

+ 25 - 3
Data/Device/DeviceInfo.cs

@@ -1,17 +1,39 @@
-namespace Device;
+using System.ComponentModel;
+
+namespace Device;
 
 public class DeviceInfo
 {
     public DeviceModel DeviceModel { get; set; }
-    public string? DeviceSubModel { get; set; }
+    public object? DeviceSubModel { get; set; }
     public string? DeviceName { get; set; }
     public string? Position { get; set; }
 
+    public Guid Guid { get; set; }
 }
 
 public enum DeviceModel
 {
     JetKepler,
-    JetFurnace
+    Proxima
 }
 
+public enum KeplerSubModel
+{
+    [Description("2200A")]
+    JetKepler_2200A,
+    [Description("2200B")]
+    JetKepler_2200B,
+    [Description("2300")]
+    JetKepler_2300,
+    [Description("DSE")]
+    JetKepler_DSE
+}
+
+public enum ProximaSubModel
+{
+    NTP,
+    SiBN,
+    NTP_HRP,
+    ELK
+}

+ 7 - 0
EEMSMain.sln

@@ -25,6 +25,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GlobalData", "GlobalData\Gl
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ConfigFileManager", "Module\ConfigFileManager\ConfigFileManager.csproj", "{0122760C-70F6-47CD-86C2-E834D9D91E67}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DeviceScanner", "Module\DeviceScanner\DeviceScanner.csproj", "{338FCF76-39EE-4D7F-B863-F1D3CF8B88A2}"
+EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
 		Debug|Any CPU = Debug|Any CPU
@@ -63,6 +65,10 @@ Global
 		{0122760C-70F6-47CD-86C2-E834D9D91E67}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{0122760C-70F6-47CD-86C2-E834D9D91E67}.Release|Any CPU.ActiveCfg = Release|Any CPU
 		{0122760C-70F6-47CD-86C2-E834D9D91E67}.Release|Any CPU.Build.0 = Release|Any CPU
+		{338FCF76-39EE-4D7F-B863-F1D3CF8B88A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{338FCF76-39EE-4D7F-B863-F1D3CF8B88A2}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{338FCF76-39EE-4D7F-B863-F1D3CF8B88A2}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{338FCF76-39EE-4D7F-B863-F1D3CF8B88A2}.Release|Any CPU.Build.0 = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE
@@ -73,6 +79,7 @@ Global
 		{ACDE294E-7198-4D4B-A3B0-3D806494C284} = {F81EF7E9-27B9-4DE0-95C9-CD1E7B58BA89}
 		{812C3EA9-C703-4119-8D9E-BAD38115FB8D} = {B8FCC141-1383-4797-AAD9-17F53945876E}
 		{0122760C-70F6-47CD-86C2-E834D9D91E67} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
+		{338FCF76-39EE-4D7F-B863-F1D3CF8B88A2} = {02EA681E-C7D8-13C7-8484-4AC65E1B71E8}
 	EndGlobalSection
 	GlobalSection(ExtensibilityGlobals) = postSolution
 		SolutionGuid = {331844F6-59F5-4D02-BFA4-2329C0EAB6EF}

+ 6 - 1
EEMSMain/App.xaml.cs

@@ -21,7 +21,6 @@ public partial class App : PrismApplication
     {
         containerRegistry.Register<ICommonContainer, CommonContainer>();
         containerRegistry.RegisterSingleton<ContainerManager>();
-        containerRegistry.RegisterSingleton<DeviceCollection>();
     }
 
 
@@ -51,6 +50,12 @@ public class CommonContainer(IRegionManager regionManager,
         {
 
             containerManager.Containers.Add(containerInfo.Index, containerInfo);
+            var t = containerManager.Containers.OrderBy(t => t.Key);
+            //containerManager.Containers.Clear();
+            //foreach (var item in t)
+            //{
+            //    containerManager.Containers.Add(item.Key, item.Value);
+            //}
         });
 
     }

+ 3 - 52
EEMSMain/ViewModels/MainWindowViewModel.cs

@@ -1,63 +1,14 @@
 using CommunityToolkit.Mvvm.ComponentModel;
 using CommunityToolkit.Mvvm.Input;
-using Device;
 using EEMSMain.Data;
-using GlobalData;
-using System.Net.NetworkInformation;
 using UICommon.CommonContainer;
-using UICommon.DataType;
 
 namespace EEMSMain.ViewModels;
 
-public partial class MainWindowViewModel : ObservableObject
+public partial class MainWindowViewModel(ICommonContainer commonContainer, ContainerManager containerManager) : ObservableObject
 {
-    public MainWindowViewModel(ICommonContainer commonContainer, DeviceCollection deviceCollection, ContainerManager containerManager)
-    {
-        this._commonContainer = commonContainer;
-        this._deviceCollection = deviceCollection;
-        this.ContainerManager = containerManager;
-        //this.Containers = containerManager.Containers;
-        FakeData();
-
-    }
-
-    void FakeData()
-    {
-        _deviceCollection.Devices ??= [];
-        _deviceCollection.Devices[DeviceModel.JetKepler] = [];
-        for (int i = 1; i <= 3; i++)
-        {
-            DeviceInfo device = new()
-            {
-                DeviceModel = DeviceModel.JetKepler,
-                DeviceSubModel = "2200A",
-                DeviceName = $"Device {i}",
-                Position = $"position-{i}"
-            };
-
-            _deviceCollection.Devices[DeviceModel.JetKepler].Add(device);
-        }
-
-        _deviceCollection.Devices[DeviceModel.JetFurnace] = [];
-
-        for (int i = 1; i <= 3; i++)
-        {
-            DeviceInfo device = new()
-            {
-                DeviceModel = DeviceModel.JetFurnace,
-                DeviceSubModel = "ELK",
-                DeviceName = $"Device {i}",
-                Position = $"position-{i}"
-            };
-
-            _deviceCollection.Devices[DeviceModel.JetFurnace].Add(device);
-        }
-
-    }
-
-    private readonly ICommonContainer _commonContainer;
-    private readonly DeviceCollection _deviceCollection;
-    public ContainerManager ContainerManager { get; set; }
+    private readonly ICommonContainer _commonContainer = commonContainer;
+    public ContainerManager ContainerManager { get; } = containerManager;
 
     [ObservableProperty]
     private string? _CurrentModule;

+ 3 - 0
Module/DeviceManagement/DeviceManagementModule.cs

@@ -1,5 +1,6 @@
 using DeviceManagement.ViewModels;
 using DeviceManagement.Views;
+using GlobalData;
 using UICommon.CommonContainer;
 
 namespace DeviceManagement;
@@ -24,5 +25,7 @@ public class DeviceManagementModule : IModule
     void IModule.RegisterTypes(IContainerRegistry containerRegistry)
     {
         containerRegistry.RegisterForNavigation<DeviceManager, DeviceManagerViewModel>("DeviceManagement");
+        containerRegistry.RegisterSingleton<DeviceCollection>();
+
     }
 }

+ 34 - 1
Module/DeviceManagement/ViewModels/DeviceManagerViewModel.cs

@@ -2,7 +2,6 @@
 using CommunityToolkit.Mvvm.Input;
 using Device;
 using GlobalData;
-using System.Collections.ObjectModel;
 
 namespace DeviceManagement.ViewModels;
 
@@ -11,6 +10,40 @@ public partial class DeviceManagerViewModel : ObservableObject
     public DeviceManagerViewModel(DeviceCollection deviceCollection)
     {
         this.DeviceCollection = deviceCollection;
+        FakeData();
+    }
+    void FakeData()
+    {
+        DeviceCollection.Devices ??= [];
+        DeviceCollection.Devices[DeviceModel.JetKepler] = [];
+        for (int i = 1; i <= 6; i++)
+        {
+            DeviceInfo device = new()
+            {
+                DeviceModel = DeviceModel.JetKepler,
+                DeviceSubModel = KeplerSubModel.JetKepler_2200A,
+                DeviceName = $"Device {i}",
+                Position = $"position-{i}"
+            };
+
+            DeviceCollection.Devices[DeviceModel.JetKepler].Add(device);
+        }
+
+        DeviceCollection.Devices[DeviceModel.Proxima] = [];
+
+        for (int i = 1; i <= 3; i++)
+        {
+            DeviceInfo device = new()
+            {
+                DeviceModel = DeviceModel.Proxima,
+                DeviceSubModel = ProximaSubModel.ELK,
+                DeviceName = $"Device {i}",
+                Position = $"position-{i}"
+            };
+
+            DeviceCollection.Devices[DeviceModel.Proxima].Add(device);
+        }
+
     }
 
 

+ 32 - 0
Module/DeviceScanner/DeviceScanner.csproj

@@ -0,0 +1,32 @@
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+	  <OutputType>Library</OutputType>
+	  <TargetFramework>net8.0-windows</TargetFramework>
+	  <OutputPath>$(SolutionDir)Binary\Modules</OutputPath>
+	  <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
+	  <Nullable>enable</Nullable>
+	  <ImplicitUsings>enable</ImplicitUsings>
+	  <UseWPF>true</UseWPF>
+	  <ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
+	  <OutputType>Library</OutputType>
+	  <TargetFramework>net8.0-windows</TargetFramework>
+	  <OutputPath>$(SolutionDir)Binary\Modules</OutputPath>
+	  <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
+	  <Nullable>enable</Nullable>
+	  <ImplicitUsings>enable</ImplicitUsings>
+	  <UseWPF>true</UseWPF>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="CommunityToolkit.Mvvm" />
+    <PackageReference Include="Prism.DryIoc" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference Include="..\..\Data\Device\Device.csproj" />
+    <ProjectReference Include="..\..\UICommon\UICommon.csproj" />
+    <ProjectReference Include="..\..\Universal\Universal.csproj" />
+  </ItemGroup>
+
+</Project>

+ 9 - 0
Module/DeviceScanner/DeviceScanner.csproj.user

@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <PropertyGroup />
+  <ItemGroup>
+    <Compile Update="Views\Scanner.xaml.cs">
+      <SubType>Code</SubType>
+    </Compile>
+  </ItemGroup>
+</Project>

+ 29 - 0
Module/DeviceScanner/ScannerModule.cs

@@ -0,0 +1,29 @@
+using DeviceScanner.ViewModels;
+using DeviceScanner.Views;
+using UICommon.CommonContainer;
+
+namespace DeviceScanner;
+
+[Module(ModuleName = "Scanner", OnDemand = false)]
+public class ScannerModule : IModule
+{
+    public ScannerModule(ICommonContainer commonContainer)
+    {
+        commonContainer.AddModule("Scanner");
+        commonContainer.AddNavigation(new(3, "添加设备", "Scanner", false, null!));
+    }
+
+    void IModule.OnInitialized(IContainerProvider containerProvider)
+    {
+        IRegionManager regionManager = containerProvider.Resolve<IRegionManager>();
+
+        ICommonContainer commonContainer = containerProvider.Resolve<ICommonContainer>();
+        regionManager.RegisterViewWithRegion(commonContainer.MainReginName, typeof(Scanner));
+    }
+
+    void IModule.RegisterTypes(IContainerRegistry containerRegistry)
+    {
+        containerRegistry.RegisterForNavigation<Scanner, ScannerViewModel>("Scanner");
+
+    }
+}

+ 12 - 0
Module/DeviceScanner/ViewModels/ScannerViewModel.cs

@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace DeviceScanner.ViewModels
+{
+    internal class ScannerViewModel
+    {
+    }
+}

+ 12 - 0
Module/DeviceScanner/Views/Scanner.xaml

@@ -0,0 +1,12 @@
+<UserControl x:Class="DeviceScanner.Views.Scanner"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:DeviceScanner.Views"
+             mc:Ignorable="d" 
+             d:DesignHeight="450" d:DesignWidth="800">
+    <Grid>
+            
+    </Grid>
+</UserControl>

+ 28 - 0
Module/DeviceScanner/Views/Scanner.xaml.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace DeviceScanner.Views
+{
+    /// <summary>
+    /// Interaction logic for Scanner.xaml
+    /// </summary>
+    public partial class Scanner : UserControl
+    {
+        public Scanner()
+        {
+            InitializeComponent();
+        }
+    }
+}