为DeviceManager和V8类中符合条件的字段添加readonly关键字,解决IDE0044警告

This commit is contained in:
zqm
2025-10-29 17:01:36 +08:00
parent 931381d36a
commit 236411ecae
2 changed files with 9 additions and 9 deletions

View File

@@ -169,9 +169,9 @@ namespace JoyD.Windows.CS.Toprie
// 当前设备ID // 当前设备ID
private int _currentDeviceId = -1; private int _currentDeviceId = -1;
// 默认设备IP // 默认设备IP
private string _deviceIp = "192.168.100.2"; private readonly string _deviceIp = "192.168.100.2";
// 设备端口 // 设备端口
private int _devicePort = 8080; private readonly int _devicePort = 8080;
// 设备连接状态 // 设备连接状态
private ConnectionStatus _connectionStatus = ConnectionStatus.Disconnected; private ConnectionStatus _connectionStatus = ConnectionStatus.Disconnected;
// 是否已初始化 // 是否已初始化
@@ -179,7 +179,7 @@ namespace JoyD.Windows.CS.Toprie
// 是否已释放 // 是否已释放
private bool _isDisposed = false; private bool _isDisposed = false;
// 图像模式 // 图像模式
private ImageMode _currentImageMode = ImageMode.Infrared; private readonly ImageMode _currentImageMode = ImageMode.Infrared;
// 当前色彩模式 // 当前色彩模式
private PaletteType _currentPaletteType = PaletteType.WhiteHot; private PaletteType _currentPaletteType = PaletteType.WhiteHot;
// 当前视频模式 // 当前视频模式
@@ -195,15 +195,15 @@ namespace JoyD.Windows.CS.Toprie
// 最大重连尝试次数 // 最大重连尝试次数
public static int MaxReconnectAttempts = 5; public static int MaxReconnectAttempts = 5;
// 连接检查定时器 // 连接检查定时器
private System.Threading.Timer _connectionCheckTimer; private readonly System.Threading.Timer _connectionCheckTimer;
// 心跳定时器 // 心跳定时器
private System.Threading.Timer _heartbeatTimer; private readonly System.Threading.Timer _heartbeatTimer;
// 连接超时时间(毫秒) // 连接超时时间(毫秒)
private const int ConnectionTimeout = 5000; private const int ConnectionTimeout = 5000;
// 连接检查间隔(毫秒) // 连接检查间隔(毫秒)
private const int ConnectionCheckInterval = 5000; private const int ConnectionCheckInterval = 5000;
// 心跳间隔(毫秒) // 心跳间隔(毫秒)
private int _heartbeatInterval = 5000; private readonly int _heartbeatInterval = 5000;
// 最后接收数据时间戳 // 最后接收数据时间戳
private DateTime _lastDataReceivedTime = DateTime.MinValue; private DateTime _lastDataReceivedTime = DateTime.MinValue;
// 数据接收超时时间(毫秒) // 数据接收超时时间(毫秒)
@@ -212,7 +212,7 @@ namespace JoyD.Windows.CS.Toprie
// 该变量已在文件上方定义,删除重复实现 // 该变量已在文件上方定义,删除重复实现
// 停止请求事件 // 停止请求事件
private ManualResetEvent _stopRequested = new ManualResetEvent(false); private readonly ManualResetEvent _stopRequested = new ManualResetEvent(false);
// 缓冲区 // 缓冲区
private byte[] _imageBuffer = new byte[4096]; private byte[] _imageBuffer = new byte[4096];
// 图像数据累积缓冲区 // 图像数据累积缓冲区
@@ -220,7 +220,7 @@ namespace JoyD.Windows.CS.Toprie
// 多部分请求边界 // 多部分请求边界
private string _multipartBoundary = string.Empty; private string _multipartBoundary = string.Empty;
// 锁对象 // 锁对象
private object _lockObject = new object(); private readonly object _lockObject = new object();
// 是否启用自动重连 // 是否启用自动重连
private bool _isAutoReconnectEnabled = true; private bool _isAutoReconnectEnabled = true;
// 最大重连次数 // 最大重连次数

View File

@@ -131,7 +131,7 @@ namespace JoyD.Windows.CS.Toprie
private string deviceIp; private string deviceIp;
private Socket socket = null; private Socket socket = null;
private static bool isSdkInitialized = false; private static bool isSdkInitialized = false;
private static Dictionary<string, V8> deviceInstances = new Dictionary<string, V8>(); private static readonly Dictionary<string, V8> deviceInstances = new Dictionary<string, V8>();
public V8(string ip) public V8(string ip)
{ {