Просмотр исходного кода

20260314001 Config模块优化完善,WPF界面绑定事件除关闭事件以外的事件触发验证,系统模块位置变更

向羽 孟 1 месяц назад
Родитель
Сommit
ba37772241

+ 4 - 2
MvvmScaffoldFrame48.DLL/AlarmTools/AlarmMessageList.cs

@@ -1,6 +1,8 @@
-
-namespace MvvmScaffoldFrame48.DLL.AlarmTools
+namespace MvvmScaffoldFrame48.DLL.AlarmTools
 {
+    /// <summary>
+    /// 报警信息列表
+    /// </summary>
     public enum AlarmMessageList
     {
        系统异常 = 0,

+ 3 - 0
MvvmScaffoldFrame48.DLL/AlarmTools/SystemAlarm.cs

@@ -6,6 +6,9 @@ using System.Linq;
 
 namespace MvvmScaffoldFrame48.DLL.AlarmTools
 {
+    /// <summary>
+    /// 系统报警管理类
+    /// </summary>
     public static class SystemAlarm
     {
         private static ErrorMessageRecordManagement errorMessageRecord = new ErrorMessageRecordManagement();

+ 49 - 71
MvvmScaffoldFrame48.DLL/CameraTools/HikCamera.cs

@@ -1,6 +1,9 @@
 // 海康相机实例类
 using MvCameraControl;
 using MvFGCtrlC.NET;
+using MvvmScaffoldFrame48.DLL.ConfigTools;
+using MvvmScaffoldFrame48.DLL.LogTools;
+using MvvmScaffoldFrame48.Model.StorageModel.Configs;
 using MvvmScaffoldFrame48.Model.StorageModel.HikVisionCamera;
 using System;
 using System.Collections.Generic;
@@ -94,7 +97,8 @@ namespace MvvmScaffoldFrame48.DLL.CameraTools
             int result = _device.Open();
             if (result != MvError.MV_OK)
             {
-                throw new Exception("打开相机失败");
+                Console.WriteLine("打开相机失败");
+                return;
             }
 
 
@@ -179,29 +183,36 @@ namespace MvvmScaffoldFrame48.DLL.CameraTools
             return Blresult;
         }
 
-        /// <summary>
-        /// 开启采集
-        /// </summary>
-        public bool StartReceiveFuntion()
+        public int LoadCameraConfig(LinescanCameraParameterModel cameraParameter)
         {
-            bool result = false;
-            try
-            {
-                if (_device == null) return result;
-                _device.StreamGrabber.SetImageNodeNum(30);
-                int ret = _device.StreamGrabber.StartGrabbing();
-                if (ret == MvError.MV_OK)
-                {
-                    result = true;
-                }
-            }
-            catch
+            int result = 0;
+            _device.Parameters.SetFloatValue("ExposureTime", cameraParameter.ExposureTimeValue);
+            _device.Parameters.SetIntValue("AcquisitionLineRate", cameraParameter.AcquistionLineRateValue);
+            _device.Parameters.SetIntValue("Width", cameraParameter.Width);
+            _device.Parameters.SetIntValue("Height", cameraParameter.Height);
+            _device.Parameters.SetIntValue("OffsetX", cameraParameter.OffsetX);
+            return result;
+        }
+
+        public int LoadCameraConfig(string cameraParameter)
+        {
+            int result = 0;
+            LinescanCameraParameterModel cameraParameterModel = XMLReadWrite.DeserializeFromString<LinescanCameraParameterModel>(cameraParameter);
+            if (cameraParameterModel != null)
             {
-                result = false;
+                _device.Parameters.SetFloatValue("ExposureTime", cameraParameterModel.ExposureTimeValue);
+                _device.Parameters.SetIntValue("AcquisitionLineRate", cameraParameterModel.AcquistionLineRateValue);
+                _device.Parameters.SetIntValue("Width", cameraParameterModel.Width);
+                _device.Parameters.SetIntValue("Height", cameraParameterModel.Height);
+                _device.Parameters.SetIntValue("OffsetX", cameraParameterModel.OffsetX);
             }
             return result;
         }
 
+        /// <summary>
+        /// 回调型取图方法-开启采集
+        /// </summary>
+        /// <returns></returns>
         public bool StartReceiveFuntionSetFrameGrabedEvent()
         {
             bool result = false;
@@ -227,28 +238,6 @@ namespace MvvmScaffoldFrame48.DLL.CameraTools
             return result;
         }
 
-        /// <summary>
-        /// 关闭采集
-        /// </summary>
-        public bool StopReceiveFuntion()
-        {
-            bool result = false;
-            try
-            {
-                if (_device == null) return result;
-                int ret = _device.StreamGrabber.StopGrabbing();
-                if (ret == MvError.MV_OK)
-                {
-                    result = true;
-                }
-            }
-            catch
-            {
-                result = false;
-            }
-            return result;
-        }
-
         /// <summary>
         /// 回调型取图方法-关闭采集
         /// </summary>
@@ -275,35 +264,6 @@ namespace MvvmScaffoldFrame48.DLL.CameraTools
             return result;
         }
 
-        /// <summary>
-        /// 获取一次图片,需开启采集
-        /// </summary>
-        /// <param name="IFrameData">输出的帧数据</param>
-        /// <returns>true为采集成功,false为采集失败</returns>
-        public bool GetOnceImage(out IFrameOut IFrameData)
-        {
-            bool result = false;
-            int BRet = _device.StreamGrabber.GetImageBuffer(1000, out IFrameData);
-            if (BRet == 0 && IFrameData != null) result = true;
-            else return result;
-            if (lastframeNum == -1)
-            {
-                lastframeNum = IFrameData.FrameNum;
-            }
-            else if (lastframeNum == IFrameData.FrameNum - 1)
-            {
-                lastframeNum = IFrameData.FrameNum;
-            }
-            else
-            {
-                //丢帧记录,用于连续采集时的丢帧检测
-                Console.WriteLine("lost frame: Width[{0}] , Height[{1}] , FrameNum[{2}] ,Frevous[{3}]",
-                    IFrameData.Image.Width, IFrameData.Image.Height, IFrameData.FrameNum, lastframeNum);
-                lastframeNum = IFrameData.FrameNum;
-            }
-            return result;
-        }
-
         /// <summary>
         /// 获取相机图像尺寸信息
         /// </summary>
@@ -336,10 +296,28 @@ namespace MvvmScaffoldFrame48.DLL.CameraTools
         /// <summary>
         /// 图像抓取事件处理方法
         /// </summary>
-        private void FrameGrabbedEventHandler(object sender,FrameGrabbedEventArgs frameData)
+        private void FrameGrabbedEventHandler(object sender,FrameGrabbedEventArgs e)
         {
             // 触发外部注册的事件
-            FrameGrabbedEvent?.Invoke(this, frameData);
+            FrameGrabbedEvent?.Invoke(this, e);
+            if (lastframeNum == -1)
+            {
+                lastframeNum = e.FrameOut.FrameNum;
+            }
+            else if (lastframeNum == e.FrameOut.FrameNum - 1)
+            {
+                lastframeNum = e.FrameOut.FrameNum;
+            }
+            else
+            {
+                //丢帧记录
+                TxtLog.log(string.Format("lost frame: Width[{0}] , Height[{1}] , FrameNum[{2}] ,Frevous[{3}]",
+                    e.FrameOut.Image.Width, e.FrameOut.Image.Height, e.FrameOut.FrameNum, lastframeNum), 6);
+                Console.WriteLine("lost frame: Width[{0}] , Height[{1}] , FrameNum[{2}] ,Frevous[{3}]",
+                    e.FrameOut.Image.Width, e.FrameOut.Image.Height, e.FrameOut.FrameNum, lastframeNum);
+                lastframeNum = e.FrameOut.FrameNum;
+            }
+            e.FrameOut.Dispose();
         }
         #endregion
     }

+ 9 - 3
MvvmScaffoldFrame48.DLL/ConfigTools/ConfigService.cs

@@ -8,13 +8,13 @@ using System.Threading.Tasks;
 
 namespace MvvmScaffoldFrame48.DLL.ConfigTools
 {
-    public class ConfigService : IConfigService
+    public class ConfigService
     {
         #region 属性
         /// <summary>
         /// 单例
         /// </summary>
-        private static ConfigService instance;
+        private static ConfigService instance = new ConfigService();
         public static ConfigService Instance => instance;
 
         /// <summary>
@@ -71,9 +71,12 @@ namespace MvvmScaffoldFrame48.DLL.ConfigTools
         #region 私有事件
         private ConfigService() { }
 
+        /// <summary>
+        /// 读取相机线程参数
+        /// </summary>
         private void GetCameraProcessConfig()
         {
-            if (File.Exists(".\\Config\\CameraConfig.xml"))
+            if (File.Exists(".\\Config\\CameraProcessConfig.xml"))
             {
                 _camerasConfig = XMLReadWrite.DeserializeFromXml<List<CameraProcessConfigModel>>(".\\Config\\CameraProcessConfig.xml");
             }
@@ -87,6 +90,9 @@ namespace MvvmScaffoldFrame48.DLL.ConfigTools
             }
         }
 
+        /// <summary>
+        /// 保存相机线程参数
+        /// </summary>
         private void SaveCameraProcessConfig()
         {
             XMLReadWrite.SerializeToXml(_camerasConfig, ".\\Config\\CameraProcessConfig.xml");

+ 2 - 3
MvvmScaffoldFrame48.DLL/ThreadManager/IImageProcessingAlgorithmHikVision.cs → MvvmScaffoldFrame48.DLL/ImageAlgorithm/IImageProcessingAlgorithmHikVision.cs

@@ -1,5 +1,4 @@
-// IImageProcessingAlgorithmHikVision.cs 创建于 2023/05/09 14:07:09
-// 算法接口,用于处理图像数据,可以继承此接口来实现新的算法,
+// 算法接口,用于处理图像数据,可以继承此接口来实现新的算法,
 using MvCameraControl;
 using System;
 using System.Collections.Generic;
@@ -7,7 +6,7 @@ using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 
-namespace MvvmScaffoldFrame48.DLL.ThreadManager
+namespace MvvmScaffoldFrame48.DLL.ImageAlgorithm
 {
     public interface IImageProcessingAlgorithmHikVision
     {

+ 2 - 1
MvvmScaffoldFrame48.DLL/ImageAlgorithm/ImageAlgorithmTools.cs

@@ -1,4 +1,5 @@
-using System;
+//图像处理工具
+using System;
 using System.Collections.Generic;
 using System.Drawing;
 using System.Drawing.Imaging;

+ 1 - 2
MvvmScaffoldFrame48.DLL/ThreadManager/ImageProcessingAlgorithmHikVisionFactory.cs → MvvmScaffoldFrame48.DLL/ImageAlgorithm/ImageProcessingAlgorithmHikVisionFactory.cs

@@ -1,12 +1,11 @@
 // ImageProcessingAlgorithmFactory.cs 识别算法工厂,用于注册算法实现
-using MvvmScaffoldFrame48.DLL.ImageAlgorithm;
 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
 
-namespace MvvmScaffoldFrame48.DLL.ThreadManager
+namespace MvvmScaffoldFrame48.DLL.ImageAlgorithm
 {
     public static class ImageProcessingAlgorithmHikVisionFactory
     {

+ 1 - 1
MvvmScaffoldFrame48.DLL/ImageAlgorithm/ProcessingAlgorithm.cs

@@ -10,7 +10,7 @@ using System.Text;
 using System.Threading;
 using System.Threading.Tasks;
 
-namespace MvvmScaffoldFrame48.DLL.ThreadManager
+namespace MvvmScaffoldFrame48.DLL.ImageAlgorithm
 {
     public class ProcessingAlgorithm : IImageProcessingAlgorithmHikVision
     {

+ 2 - 2
MvvmScaffoldFrame48.DLL/MvvmScaffoldFrame48.Dll.csproj

@@ -96,8 +96,8 @@
     <Compile Include="SystemTools\TimeStampTools.cs" />
     <Compile Include="ThreadManager\CameraGroup.cs" />
     <Compile Include="ThreadManager\CommunicationThread.cs" />
-    <Compile Include="ThreadManager\IImageProcessingAlgorithmHikVision.cs" />
-    <Compile Include="ThreadManager\ImageProcessingAlgorithmHikVisionFactory.cs" />
+    <Compile Include="ImageAlgorithm\IImageProcessingAlgorithmHikVision.cs" />
+    <Compile Include="ImageAlgorithm\ImageProcessingAlgorithmHikVisionFactory.cs" />
     <Compile Include="ImageAlgorithm\ProcessingAlgorithm.cs" />
     <Compile Include="ThreadManager\ThreadManager.cs" />
     <Compile Include="UserManager.cs" />

+ 12 - 180
MvvmScaffoldFrame48.DLL/ThreadManager/CameraGroup.cs

@@ -1,10 +1,12 @@
 // CameraGroup.cs 相机组线程管理类,控制相机采集和识别的线程运行,开放有算法的接口
 using MvCameraControl;
 using MvvmScaffoldFrame48.DLL.CameraTools;
+using MvvmScaffoldFrame48.DLL.ImageAlgorithm;
 using MvvmScaffoldFrame48.DLL.LogTools;
 using MvvmScaffoldFrame48.DLL.SystemTools;
 using MvvmScaffoldFrame48.Model.ResultModel;
 using MvvmScaffoldFrame48.Model.StorageModel.Configs;
+using MvvmScaffoldFrame48.Model.StorageModel.HikVisionCamera;
 using System;
 using System.Collections.Concurrent;
 using System.Collections.Generic;
@@ -74,25 +76,24 @@ namespace MvvmScaffoldFrame48.DLL.ThreadManager
             if (IsRunning)
                 return;
 
+            // 加载相机参数
+            LoadCameraConfiguration();
+
             // 根据配置加载算法
             LoadAlgorithmFromConfiguration();
 
+            //为相机增加回调方法
+            Camera.FrameGrabbedEvent += CameraCaptureLoop;
 
-            //Camera.StartReceiveFuntion();
-            Camera.FrameGrabbedEvent += CameraCaptureLoop2;
+            //开启相机采集
             Camera.StartReceiveFuntionSetFrameGrabedEvent();
 
             // 重置取消令牌
             CancellationTokenSource = new CancellationTokenSource();
             var token = CancellationTokenSource.Token;
 
-            // 启动相机采集线程
-            //CameraTask = Task.Factory.StartNew(() => CameraCaptureLoop(token),
-            //    token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
-
-
             // 启动图像处理线程
-            ProcessingTask = Task.Factory.StartNew(() => ImageProcessingbatchLoop2(token),
+            ProcessingTask = Task.Factory.StartNew(() => ImageProcessingbatchLoop(token),
                 token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
 
             IsRunning = true;
@@ -206,7 +207,7 @@ namespace MvvmScaffoldFrame48.DLL.ThreadManager
         { 
             if(Configuration != null&& !string.IsNullOrEmpty(Configuration.CameraParameters))
             {
-
+                Camera.LoadCameraConfig(Configuration.CameraParameters);
             }
         }
 
@@ -267,70 +268,6 @@ namespace MvvmScaffoldFrame48.DLL.ThreadManager
         #endregion
 
         #region 线程主体方法
-        /// <summary>
-        /// 相机采集循环
-        /// </summary>
-        private async void CameraCaptureLoop(CancellationToken token)
-        {
-            //int frameCount = 0;
-            try
-            {
-                while (!token.IsCancellationRequested)
-                {
-                    // 模拟相机图像采集(无休眠,持续采集)
-                    if (Camera.GetOnceImage(out IFrameOut imageData))
-                    {
-                        // 将图像放入队列
-                        ImageQueue.Enqueue(imageData.Clone() as IFrameOut);
-                        double QuTuYanshi = (DateTime.Now - TimeStampTools.FromUnixTimestamp((long)imageData.HostTimeStamp)).TotalMilliseconds;
-                        //Console.WriteLine($"相机 {CameraId} 采集到图像,帧号{imageData.FrameNum}");
-                        if(QuTuYanshi > 12)
-                        {
-                            Console.WriteLine($"识别落后时间{QuTuYanshi}");
-                        }
-                        QueueSemaphore.Release(); // 通知处理线程有新数据
-                        imageData.Dispose();
-                    }
-                    // 这里不添加休眠,保持最大帧率采集
-                    await Task.Delay(CameraSleepTime);
-                }
-            }
-            catch (OperationCanceledException)
-            {
-                // 线程被取消,正常退出
-            }
-            catch (Exception ex)
-            {
-                Console.WriteLine($"相机 {CameraId} 采集异常: {ex.Message}");
-            }
-        }
-
-        /// <summary>
-        /// 相机回调取图
-        /// 与循环取图二选一
-        /// </summary>
-        /// <param name="sender"></param>
-        /// <param name="e"></param>
-        private void CameraCaptureLoop(object sender, FrameGrabbedEventArgs e)
-        {
-            try
-            {
-                // 将图像放入队列
-                ImageQueue.Enqueue(e.FrameOut.Clone() as IFrameOut);
-                double QuTuYanshi = (DateTime.Now - TimeStampTools.FromUnixTimestamp((long)e.FrameOut.HostTimeStamp)).TotalMilliseconds;
-                //Console.WriteLine($"相机 {CameraId} 采集到图像,帧号{imageData.FrameNum}");
-                if (QuTuYanshi > 12)
-                {
-                    Console.WriteLine($"识别落后时间{QuTuYanshi}");
-                }
-                QueueSemaphore.Release(); // 通知处理线程有新数据
-                e.FrameOut.Dispose();
-            }
-            catch (Exception ex)
-            {
-                Console.WriteLine($"相机 {CameraId} 采集异常: {ex.Message}");
-            }
-        }
 
         /// <summary>
         /// 相机回调取图
@@ -338,7 +275,7 @@ namespace MvvmScaffoldFrame48.DLL.ThreadManager
         /// </summary>
         /// <param name="sender"></param>
         /// <param name="e"></param>
-        private void CameraCaptureLoop2(object sender, FrameGrabbedEventArgs e)
+        private void CameraCaptureLoop(object sender, FrameGrabbedEventArgs e)
         {
             try
             {
@@ -350,25 +287,7 @@ namespace MvvmScaffoldFrame48.DLL.ThreadManager
                 {
                     Console.WriteLine($"识别落后时间{QuTuYanshi}");
                 }
-                if (lastframeNum == -1)
-                {
-                    lastframeNum = e.FrameOut.FrameNum;
-                }
-                else if (lastframeNum == e.FrameOut.FrameNum - 1)
-                {
-                    lastframeNum = e.FrameOut.FrameNum;
-                }
-                else
-                {
-                    //丢帧记录
-                    TxtLog.log(string.Format("lost frame: Width[{0}] , Height[{1}] , FrameNum[{2}] ,Frevous[{3}]",
-                        e.FrameOut.Image.Width, e.FrameOut.Image.Height, e.FrameOut.FrameNum, lastframeNum), 6);
-                    Console.WriteLine("lost frame: Width[{0}] , Height[{1}] , FrameNum[{2}] ,Frevous[{3}]",
-                        e.FrameOut.Image.Width, e.FrameOut.Image.Height, e.FrameOut.FrameNum, lastframeNum);
-                    lastframeNum = e.FrameOut.FrameNum;
-                }
                 QueueSemaphore.Release(); // 通知处理线程有新数据
-                e.FrameOut.Dispose();
             }
             catch (Exception ex)
             {
@@ -376,48 +295,10 @@ namespace MvvmScaffoldFrame48.DLL.ThreadManager
             }
         }
 
-
-        /// <summary>
-        /// 图像处理循环
-        /// 适用取图频率不高的处理,或者处理速度远快于取图速度的方法
-        /// </summary>
-        private async void ImageProcessingLoop(CancellationToken token)
-        {
-            try
-            {
-                while (!token.IsCancellationRequested)
-                {
-                    // 等待图像数据
-                    await QueueSemaphore.WaitAsync(token);
-
-                    // 从队列获取图像
-                    if (ImageQueue.TryDequeue(out IFrameOut imageData))
-                    {
-                        // 执行图像处理逻辑
-                        ProcessImage(imageData, CameraId);
-                        imageData.Dispose();
-
-                        // 可以根据队列长度决定是否短暂休眠以避免过度占用CPU
-                        if (ImageQueue.Count == 0)
-                        {
-                            await Task.Delay(1, token); // 短暂让出CPU
-                        }
-                    }
-                }
-            }
-            catch (OperationCanceledException)
-            {
-                // 线程被取消,正常退出
-            }
-            catch (Exception ex)
-            {
-                Console.WriteLine($"相机 {CameraId} 处理异常: {ex.Message}");
-            }
-        }
-
         /// <summary>
         /// 图像处理循环-引入批处理
         /// 处理速度与取图速度的差不多的时候
+        /// 更换了存储图像的队列
         /// </summary>
         /// <param name="token"></param>
         private async void ImageProcessingbatchLoop(CancellationToken token)
@@ -425,55 +306,6 @@ namespace MvvmScaffoldFrame48.DLL.ThreadManager
             const int batchSize = 5; // 每批处理的最大图像数量
             var batch = new List<IFrameOut>(batchSize); // 存储当前批次的图像
 
-            try
-            {
-                while (!token.IsCancellationRequested)
-                {
-                    // 等待至少一张图像数据
-                    await QueueSemaphore.WaitAsync(token);
-
-                    // 收集一批图像(严格按队列顺序)
-                    while (batch.Count < batchSize && ImageQueue.TryDequeue(out IFrameOut imageData))
-                    {
-                        batch.Add(imageData);
-                        if (ImageQueue.Count > 0)
-                        {
-                            QueueSemaphore.Release(); // 提前释放信号量,唤醒其他等待线程
-                        }
-                    }
-
-                    // 顺序处理当前批次的所有图像
-                    foreach (var image in batch)
-                    {
-                        ProcessImage(image, CameraId); // 严格按顺序执行处理逻辑
-                        image.Dispose(); // 处理完成后立即释放资源
-                    }
-
-                    // 清空当前批次,准备下一轮处理
-                    batch.Clear();
-
-                    // 如果队列为空,短暂休眠以避免过度占用CPU
-                    if (ImageQueue.Count == 0)
-                    {
-                        await Task.Delay(1, token); // 固定短时间休眠
-                    }
-                }
-            }
-            catch (OperationCanceledException)
-            {
-                // 线程被取消,正常退出
-            }
-            catch (Exception ex)
-            {
-                Console.WriteLine($"相机 {CameraId} 处理异常: {ex.Message}");
-            }
-        }
-
-        private async void ImageProcessingbatchLoop2(CancellationToken token)
-        {
-            const int batchSize = 5; // 每批处理的最大图像数量
-            var batch = new List<IFrameOut>(batchSize); // 存储当前批次的图像
-
             try
             {
                 while (!token.IsCancellationRequested)

+ 1 - 0
MvvmScaffoldFrame48.DLL/ThreadManager/ThreadManager.cs

@@ -38,6 +38,7 @@ namespace MvvmScaffoldFrame48.DLL.ThreadManager
         {
             // 加载相机配置
             configService.LoadAsync();
+            configService.SaveAsync();
 
             // 获取相机列表
             HikVision.GetCameraList(out List<IDeviceInfo> cameraInfoList);

+ 2 - 1
MvvmScaffoldFrame48.MODEL/MvvmScaffoldFrame48.Model.csproj

@@ -64,10 +64,11 @@
     <Compile Include="ResultModel\CameraProcessEventArgsResultModel.cs" />
     <Compile Include="StorageModel\AuditTrail\ErrorMessageRecordModel.cs" />
     <Compile Include="StorageModel\AuditTrail\OperationRecordModel.cs" />
-    <Compile Include="StorageModel\Configs\IConfigService.cs" />
     <Compile Include="StorageModel\HikVisionCamera\CameraImageSizeCModel.cs" />
     <Compile Include="StorageModel\HikVisionCamera\CameraInfoModel.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
+    <Compile Include="StorageModel\HikVisionCamera\CameraParameterModel.cs" />
+    <Compile Include="StorageModel\HikVisionCamera\LinescanCameraParameterModel.cs" />
     <Compile Include="StorageModel\ImageAlgorithm\BoundingRectangleMdoel.cs" />
     <Compile Include="StorageModel\ImageAlgorithm\ShuLI\ActiveObjectClassModel.cs" />
     <Compile Include="StorageModel\Configs\ShuLiConfigClassModel.cs" />

+ 0 - 17
MvvmScaffoldFrame48.MODEL/StorageModel/Configs/IConfigService.cs

@@ -1,17 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace MvvmScaffoldFrame48.Model.StorageModel.Configs
-{
-    public interface IConfigService
-    {
-        List<CameraProcessConfigModel> CamerasProcessConfig { get; }
-        bool LoadAsync();
-        void SaveAsync();
-        event EventHandler LoadConfigEvent;
-        event EventHandler SaveConfigEvent;
-    }
-}

+ 16 - 0
MvvmScaffoldFrame48.MODEL/StorageModel/HikVisionCamera/CameraParameterModel.cs

@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MvvmScaffoldFrame48.Model.StorageModel.HikVisionCamera
+{
+    /// <summary>
+    /// 普通相机参数
+    /// </summary>
+    public class CameraParameterModel
+    {
+
+    }
+}

+ 54 - 0
MvvmScaffoldFrame48.MODEL/StorageModel/HikVisionCamera/LinescanCameraParameterModel.cs

@@ -0,0 +1,54 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MvvmScaffoldFrame48.Model.StorageModel.HikVisionCamera
+{
+    /// <summary>
+    /// 线阵相机参数
+    /// </summary>
+    public class LinescanCameraParameterModel
+    {
+        /// <summary>
+        /// 相机序列号
+        /// </summary>
+        public string CameraSNNum { get; set; } = string.Empty;
+
+        /// <summary>
+        /// 曝光时间
+        /// </summary>
+        public float ExposureTimeValue { get; set; } = 100;
+
+        /// <summary>
+        /// 采集行频
+        /// </summary>
+        public int AcquistionLineRateValue { get; set; } = 800;
+
+        /// <summary>
+        /// 图像宽度
+        /// </summary>
+        public int Width { get; set; } = 0;
+
+        /// <summary>
+        /// 图像宽度
+        /// </summary>
+        public int Height { get; set; } = 0;
+
+        /// <summary>
+        /// 图像X偏移
+        /// </summary>
+        public int OffsetX { get; set; } = 0;
+
+        /// <summary>
+        /// 相机名称
+        /// </summary>
+        public string CameraName { get; set; } = string.Empty;
+
+        /// <summary>
+        /// 设备名称
+        /// </summary>
+        public string DeviceName { get; set; } = string.Empty;
+    }
+}

+ 9 - 0
MvvmScaffoldFrame48.VIEWMODEL/ViewModel/CustomControlViewModel.cs

@@ -6,6 +6,7 @@ using MvvmScaffoldFrame48.Model.StorageModel.AuditTrail;
 using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
+using System.ComponentModel;
 using System.Linq;
 using System.Text;
 using System.Threading.Tasks;
@@ -78,6 +79,8 @@ namespace MvvmScaffoldFrame48.ViewModel.ViewModel
         public ICommand TestCommand { get; set; }
         public ICommand SwitchCommand { get; set; }
         public ICommand DoubleSwitchCommand { get; set; }
+
+        public ICommand Test2Command { get; set; }
         #endregion
 
         #region 属性
@@ -98,6 +101,11 @@ namespace MvvmScaffoldFrame48.ViewModel.ViewModel
         {
             IsActivated2 = !_isActivated2;
         }
+
+        public void Test2(object e)
+        {
+            Console.WriteLine("test2输出");
+        }
         #endregion
 
         #region 绑定用Predicate方法
@@ -113,6 +121,7 @@ namespace MvvmScaffoldFrame48.ViewModel.ViewModel
             TestCommand = new RelayCommand(Test, CanTrue);
             DoubleSwitchCommand = new RelayCommand(DoubleSwitchButton, CanTrue);
             SwitchCommand = new RelayCommand(SwitchButton, CanTrue);
+            Test2Command = new RelayCommand<object>(Test2);
             FormulationItems.Add("1");
         }
         #endregion

+ 2 - 3
MvvmScaffoldFrame48.VIEWMODEL/ViewModel/MainViewModel.cs

@@ -26,7 +26,7 @@ namespace MvvmScaffoldFrame48.ViewModel.ViewModel
         #endregion
 
         #region 绑定用Action方法
-        private void Window_Closing(CancelEventArgs e)
+        private void Window_Closing(object e)
         {
             if (MainThreadManager != null)
             {
@@ -52,8 +52,7 @@ namespace MvvmScaffoldFrame48.ViewModel.ViewModel
         public MainViewModel()
         {
             MainThreadManager = ThreadManager.Instance;
-            //ThreadManager MainThreadManager = ThreadManager.GetThreadManager
-            Window_ClosingCommand = new RelayCommand<CancelEventArgs>(Window_Closing);
+            Window_ClosingCommand = new RelayCommand<object>(Window_Closing);
             MainThreadManager.StartCameraGroup(0);
             MainThreadManager.StartCommunication();
         }

+ 2 - 1
MvvmScaffoldFrame48/WPFPage/CustomControlPage.xaml

@@ -4,6 +4,7 @@
       xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
       xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
       xmlns:local="clr-namespace:MvvmScaffoldFrame48.WPFPage"
+      xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
       mc:Ignorable="d" 
       d:DesignHeight="450" d:DesignWidth="800"
       Title="CustomControlPage">
@@ -118,7 +119,7 @@
             </StackPanel>
             <StackPanel Orientation ="Horizontal"  HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,120,0,0"> 
                 <Label Content="悬浮提示框:"/>
-                <Button Content="悬浮提示框" Name="PopupBtn" BorderThickness="1" HorizontalAlignment="Right" VerticalAlignment="Top" Width="100" Height="30" Click="PopupBtn_Click"/>
+                <Button Content="悬浮提示框" Name="PopupBtn" BorderThickness="1" HorizontalAlignment="Right" VerticalAlignment="Top" Width="100" Height="30"/>
                 <Popup Name="myPopup" Placement="Mouse" AllowsTransparency="True">
                     <Border Background="LightYellow" BorderBrush="Gray" BorderThickness="1">
                         <TextBlock Text="这是一个悬浮提示" Padding="10"/>