Browse Source

出厂后第一次连接云服务后,默认开启采集卡,1280*720

felix 1 năm trước cách đây
mục cha
commit
db52bd4fab

+ 1 - 1
Vinno.FIS.Sonopost.Upgrade/TaskSchedulerHelper.cs

@@ -85,7 +85,7 @@ namespace Vinno.FIS.Sonopost.Upgrade
                 td.Actions.Add(new ExecAction(_keeperFilePath, null, null));
 
                 // 注册任务
-                ts.RootFolder.RegisterTaskDefinition(_taskName, td, TaskCreation.Create, System.Security.Principal.WindowsIdentity.GetCurrent().Name, "VinnoTech", TaskLogonType.InteractiveToken);
+                ts.RootFolder.RegisterTaskDefinition(_taskName, td, TaskCreation.CreateOrUpdate, @"Sonopost\VinnoUser", "VinnoTech", TaskLogonType.InteractiveToken);
             }
         }
 

+ 1 - 0
Vinno.FIS.Sonopost/App.xaml.cs

@@ -69,6 +69,7 @@ namespace Vinno.FIS.Sonopost
         {
             AppManager.Instance.GetManager<ILoginManager>().Init();
             AppManager.Instance.GetManager<IDeviceManager>().Init();
+            AppManager.Instance.GetManager<ILiveVideoManager>().Init();
             SystemHelper.Init();
             _networkManager = AppManager.Instance.GetManager<INetworkManager>();
             _networkManager.CurrentNetworkChanged += OnCurrentNetworkChanged;

+ 3 - 0
Vinno.FIS.Sonopost/Features/Config/SonopostUserDefinedSettingInfo.cs

@@ -24,6 +24,8 @@ namespace Vinno.FIS.Sonopost.Features.Config
 
         public CaptureSetting CaptureSetting { get; set; }
 
+        public bool IsFirstLogin { get; set; }
+
         public int Version { get; set; }
     }
 
@@ -84,6 +86,7 @@ namespace Vinno.FIS.Sonopost.Features.Config
                         FootToggleLeftKeyForKeyBoard = EnumKeyboardKey.F1,
                         FootToggleRightKeyForKeyBoard = EnumKeyboardKey.F2,
                     },
+                    IsFirstLogin = true,
                     Version = SonopostConstants.CurrentSonopostUserDefinedSettingVersion,
                 };
                 Instance.Save();

+ 17 - 1
Vinno.FIS.Sonopost/Managers/Interfaces/ILiveVideoManager.cs

@@ -1,4 +1,5 @@
-using FISLib.LiveVideo;
+using FISLib.Hardware;
+using FISLib.LiveVideo;
 using System;
 using System.Collections.Generic;
 
@@ -57,5 +58,20 @@ namespace Vinno.FIS.Sonopost.Managers.Interfaces
         /// 修改实时采图的开关
         /// </summary>
         void ChangeRealTimeCaptureSetting();
+
+        /// <summary>
+        /// Init
+        /// </summary>
+        void Init();
+
+        /// <summary>
+        /// 超声高清采集卡名称列表
+        /// </summary>
+        List<string> SonoDeviceNames { get; }
+
+        /// <summary>
+        /// 超声采集卡名称
+        /// </summary>
+        FISCameraInfo SonoDevice { get; }
     }
 }

+ 31 - 0
Vinno.FIS.Sonopost/Managers/LiveVideoManager.cs

@@ -1,4 +1,5 @@
 using FISLib.Connect;
+using FISLib.Hardware;
 using FISLib.LiveVideo;
 using FISLib.Remedical;
 using System;
@@ -21,10 +22,22 @@ namespace Vinno.FIS.Sonopost.Managers
         private readonly ILiveVideoService _fisLiveVideoService;
         private readonly IRemedicalManager _remedicalManager;
         private readonly IKeyBoardListenManager _keyBoardListenManager;
+
+        private IDeviceManager _deviceManager;
         private CameraSettingForSonopost _cameraSetting;
         private bool _isRecording;
         private AutoResetEvent _checkImageRecordEvent = new AutoResetEvent(false);
 
+        /// <summary>
+        /// 超声高清采集卡名称列表
+        /// </summary>
+        public List<string> SonoDeviceNames { get; private set; }
+
+        /// <summary>
+        /// 超声采集卡名称
+        /// </summary>
+        public FISCameraInfo SonoDevice { get; private set; }
+
         public event EventHandler<FISImageFrameData> PreviewImageReceived;
 
         public LiveVideoManager()
@@ -49,6 +62,24 @@ namespace Vinno.FIS.Sonopost.Managers
             }, new FISMicDeviceInfo());
         }
 
+        public void Init()
+        {
+            _deviceManager = AppManager.Instance.GetManager<IDeviceManager>();
+            SonoDeviceNames = SonopostSystemSettings.Instance.InputDeviceNames.ToList();
+            var cameras = _deviceManager.GetCameras();
+            if (cameras != null)
+            {
+                foreach (var camera in cameras)
+                {
+                    if (SonoDeviceNames.Contains(camera.Name.Trim()))
+                    {
+                        var capbilities = camera.Capabilities.Where(x => x.Width <= 1920 && x.Height <= 1080).ToList();
+                        SonoDevice = new FISCameraInfo(camera.Id, camera.Name, camera.HardwareId, capbilities);
+                    }
+                }
+            }
+        }
+
         private void OnLeftKeyPressedEvent(object sender, EventArgs e)
         {
             try

+ 25 - 0
Vinno.FIS.Sonopost/Managers/LoginManager.cs

@@ -1,6 +1,8 @@
 using FISLib;
 using FISLib.Connect;
+using FISLib.LiveVideo;
 using System;
+using System.Linq;
 using Vinno.FIS.Sonopost.Features.Config;
 using Vinno.FIS.Sonopost.Features.Oled;
 using Vinno.FIS.Sonopost.Managers.Interfaces;
@@ -58,6 +60,29 @@ namespace Vinno.FIS.Sonopost.Managers
                         UniqueId = e.UniqueId;
                         QRCodeString = _connectionService.GetQRStringForVCloudLogin();
                         _configManager.SaveVCloudServer();
+                        if (SonopostUserDefinedSettings.Instance.IsFirstLogin && _liveVideoManager.SonoDevice != null && _liveVideoManager.SonoDevice.Capabilities.Any(x => x.Width == 1280 && x.Height == 720))
+                        {
+                            var videoInfos = SonopostUserDefinedSettings.Instance.HardwareSetting.VideoDeviceInfoList;
+                            var config = videoInfos?.FirstOrDefault(x => x.Category == FISLiveChannelCategory.Main);
+                            if (config == null)
+                            {
+                                config = new FISVideoDeviceInfo
+                                {
+                                    Category = FISLiveChannelCategory.Main
+                                };
+                                videoInfos.Add(config);
+                            }
+
+                            config.Id = _liveVideoManager.SonoDevice.Id;
+                            config.Name = _liveVideoManager.SonoDevice.Name;
+                            config.IsEnable = true;
+                            config.Width = 1280;
+                            config.Height = 720;
+                            config.FrameRate = 20;
+                            config.IsAvailable = true;
+                            SonopostUserDefinedSettings.Instance.IsFirstLogin = false;
+                            _configManager.Save();
+                        }
                         _liveVideoManager.UpdateDeviceResoution();
                         _liveVideoManager.ChangeRealTimeCaptureSetting();
                         _versionCheckManager.CheckVersion();

+ 10 - 55
Vinno.FIS.Sonopost/WebApi/Controllers/LiveController.cs

@@ -12,51 +12,6 @@ namespace Vinno.FIS.Sonopost.WebApi.Controllers
     [WebApiController]
     internal class LiveController : BaseController
     {
-        private static List<string> _sonoHDDeviceNames;
-        private static FISCameraInfo _sonoDevice;
-
-        /// <summary>
-        /// 超声高清采集卡名称列表
-        /// </summary>
-        public List<string> SonoDeviceNames
-        {
-            get
-            {
-                if (_sonoHDDeviceNames == null)
-                {
-                    _sonoHDDeviceNames = SonopostSystemSettings.Instance.InputDeviceNames.ToList();
-                }
-                return _sonoHDDeviceNames;
-            }
-        }
-
-        /// <summary>
-        /// 超声采集卡名称
-        /// </summary>
-        public FISCameraInfo SonoDevice
-        {
-            get
-            {
-                if (_sonoDevice == null)
-                {
-                    var cameras = DeviceManager.GetCameras();
-                    if (cameras != null)
-                    {
-                        foreach (var camera in cameras)
-                        {
-                            if (SonoDeviceNames.Contains(camera.Name.Trim()))
-                            {
-                                var capbilities = camera.Capabilities.Where(x => x.Width <= 1920 && x.Height <= 1080).ToList();
-                                _sonoDevice = new FISCameraInfo(camera.Id, camera.Name, camera.HardwareId, capbilities);
-                                return _sonoDevice;
-                            }
-                        }
-                    }
-                }
-                return _sonoDevice;
-            }
-        }
-
         /// <summary>
         /// 获取超声机品牌集合
         /// </summary>
@@ -97,14 +52,14 @@ namespace Vinno.FIS.Sonopost.WebApi.Controllers
         [WebApiAction]
         public Result GetSonoInfo()
         {
-            if (SonoDevice == null)
+            if (LiveVideoManager.SonoDevice == null)
             {
                 return Result.Fail("DeviceNotFound");
             }
             var videoInfos = SonopostUserDefinedSettings.Instance.HardwareSetting.VideoDeviceInfoList;
             var config = videoInfos?.FirstOrDefault(x => x.Category == FISLiveChannelCategory.Main);
 
-            var model = new SonoInfoModel(config?.Id, config?.Name, SonoDevice?.HardwareId, SonoDevice?.Capabilities)
+            var model = new SonoInfoModel(config?.Id, config?.Name, LiveVideoManager.SonoDevice?.HardwareId, LiveVideoManager.SonoDevice?.Capabilities)
             {
                 Width = config == null ? 0 : config.Width,
                 Height = config == null ? 0 : config.Height,
@@ -123,7 +78,7 @@ namespace Vinno.FIS.Sonopost.WebApi.Controllers
         [WebApiAction]
         public Result SaveSonoInfo(SonoInfoModel request)
         {
-            if (SonoDevice == null)
+            if (LiveVideoManager.SonoDevice == null)
             {
                 return Result.Fail("DeviceNotFound");
             }
@@ -139,8 +94,8 @@ namespace Vinno.FIS.Sonopost.WebApi.Controllers
                 videoInfos.Add(config);
             }
 
-            config.Id = SonoDevice.Id;
-            config.Name = SonoDevice.Name;
+            config.Id = LiveVideoManager.SonoDevice.Id;
+            config.Name = LiveVideoManager.SonoDevice.Name;
             config.IsEnable = request.IsEnable;
             config.Brand = request.Brand;
             config.Model = request.Model;
@@ -161,11 +116,11 @@ namespace Vinno.FIS.Sonopost.WebApi.Controllers
         [WebApiAction]
         public Result GetSonoResolutions()
         {
-            if (SonoDevice == null)
+            if (LiveVideoManager.SonoDevice == null)
             {
                 return Result.Fail("DeviceNotFound");
             }
-            return Result.Success(SonoDevice.Capabilities.Select(x => new { x.Width, x.Height }));
+            return Result.Success(LiveVideoManager.SonoDevice.Capabilities.Select(x => new { x.Width, x.Height }));
         }
 
         /// <summary>
@@ -176,7 +131,7 @@ namespace Vinno.FIS.Sonopost.WebApi.Controllers
         public Result GetCameras()
         {
             var cameras = DeviceManager.GetCameras()
-                ?.Where(x => !x.Name.Equals(SonoDevice?.Name)) ?? new List<FISCameraInfo>();
+                ?.Where(x => !x.Name.Equals(LiveVideoManager.SonoDevice?.Name)) ?? new List<FISCameraInfo>();
             return Result.Success(cameras);
         }
 
@@ -189,7 +144,7 @@ namespace Vinno.FIS.Sonopost.WebApi.Controllers
         {
             DeviceManager.RefreshCameras();
             var cameras = DeviceManager.GetCameras()
-                           ?.Where(x => !x.Name.Equals(SonoDevice?.Name)) ?? new List<FISCameraInfo>();
+                           ?.Where(x => !x.Name.Equals(LiveVideoManager.SonoDevice?.Name)) ?? new List<FISCameraInfo>();
             return Result.Success(cameras);
         }
 
@@ -517,7 +472,7 @@ namespace Vinno.FIS.Sonopost.WebApi.Controllers
         [WebApiAction]
         public Result GetSonoCaptureCardList()
         {
-            return Result.Success(SonoDeviceNames);
+            return Result.Success(LiveVideoManager.SonoDeviceNames);
         }
 
         /// <summary>