DCS/ruiyiweiUX/Assets/Scripts/Config/DCSSerialCommConfig.cs

118 lines
3.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// using UnityEngine;
// /// <summary>
// /// DCS串口通信配置文件
// /// </summary>
// [CreateAssetMenu(fileName = "DCSSerialCommConfig", menuName = "DCS/串口通信配置")]
// public class DCSSerialCommConfig : ScriptableObject
// {
// [Header("串口基本设置")]
// [Tooltip("默认串口名称")]
// public string defaultPortName = "COM1";
// [Tooltip("默认波特率")]
// public int defaultBaudRate = 115200;
// [Tooltip("启动时自动连接")]
// public bool autoConnectOnStart = true;
// [Header("超时设置")]
// [Tooltip("读取超时(毫秒)")]
// public int readTimeoutMs = 1000;
// [Tooltip("写入超时(毫秒)")]
// public int writeTimeoutMs = 1000;
// [Tooltip("心跳超时(秒)")]
// public int heartbeatTimeoutSec = 10;
// [Header("重连设置")]
// [Tooltip("启用自动重连")]
// public bool enableAutoReconnect = true;
// [Tooltip("重连间隔(秒)")]
// public float reconnectIntervalSec = 5f;
// [Tooltip("最大重连次数")]
// public int maxReconnectAttempts = 3;
// [Header("数据设置")]
// [Tooltip("启用数据日志")]
// public bool enableDataLogging = true;
// [Tooltip("BFI异常阈值(下限)")]
// public float bfiLowerThreshold = 30f;
// [Tooltip("BFI异常阈值(上限)")]
// public float bfiUpperThreshold = 70f;
// [Header("温度设置")]
// [Tooltip("温度异常阈值(下限°C)")]
// public float temperatureLowerThreshold = 20f;
// [Tooltip("温度异常阈值(上限°C)")]
// public float temperatureUpperThreshold = 40f;
// [Header("调试设置")]
// [Tooltip("启用详细日志")]
// public bool enableVerboseLogging = false;
// [Tooltip("启用帧数据十六进制显示")]
// public bool enableHexFrameLogging = false;
// [Tooltip("模拟模式(不使用真实串口)")]
// public bool simulationMode = false;
// /// <summary>
// /// 获取默认配置实例
// /// </summary>
// public static DCSSerialCommConfig GetDefault()
// {
// var config = Resources.Load<DCSSerialCommConfig>("DCSSerialCommConfig");
// if (config == null)
// {
// // 如果没有找到配置文件,创建默认配置
// config = CreateInstance<DCSSerialCommConfig>();
// Debug.LogWarning("未找到DCS串口通信配置文件使用默认配置");
// }
// return config;
// }
// /// <summary>
// /// 验证配置有效性
// /// </summary>
// public bool ValidateConfig()
// {
// if (string.IsNullOrEmpty(defaultPortName))
// {
// Debug.LogError("串口名称不能为空");
// return false;
// }
// if (defaultBaudRate <= 0)
// {
// Debug.LogError("波特率必须大于0");
// return false;
// }
// if (readTimeoutMs <= 0 || writeTimeoutMs <= 0)
// {
// Debug.LogError("超时设置必须大于0");
// return false;
// }
// if (bfiLowerThreshold >= bfiUpperThreshold)
// {
// Debug.LogError("BFI阈值设置错误");
// return false;
// }
// if (temperatureLowerThreshold >= temperatureUpperThreshold)
// {
// Debug.LogError("温度阈值设置错误");
// return false;
// }
// return true;
// }
// }