DCS/ruiyiweiUX/Assets/Scripts/Configuration/DataSourceConfig.cs

103 lines
3.6 KiB
C#

// using UnityEngine;
// /// <summary>
// /// 数据源配置管理器
// /// 用于控制系统使用真实串口数据还是模拟数据
// /// </summary>
// [CreateAssetMenu(fileName = "DataSourceConfig", menuName = "DCS/Data Source Config")]
// public class DataSourceConfig : ScriptableObject
// {
// [Header("数据源设置")]
// [Tooltip("是否启用真实串口通信")]
// public bool UseRealSerialData = true;
// [Tooltip("是否允许在串口失败时使用模拟数据作为备用")]
// public bool AllowSimulatedFallback = false;
// [Tooltip("是否强制使用模拟数据(仅用于测试)")]
// public bool ForceSimulatedData = false;
// [Header("串口设置")]
// [Tooltip("串口名称")]
// public string SerialPortName = "COM1";
// [Tooltip("波特率")]
// public int BaudRate = 115200;
// [Header("模拟数据设置")]
// [Tooltip("模拟BFI数据范围")]
// public Vector2 SimulatedBFIRange = new Vector2(20f, 80f);
// [Tooltip("模拟血流数据范围")]
// public Vector2 SimulatedBloodFlowRange = new Vector2(50f, 150f);
// [Tooltip("模拟电池电量起始值")]
// public float SimulatedBatteryLevel = 80f;
// [Tooltip("数据更新间隔(秒)")]
// public float DataUpdateInterval = 1f;
// [Header("调试设置")]
// [Tooltip("是否输出详细的串口通信日志")]
// public bool VerboseSerialLogging = true;
// [Tooltip("是否输出模拟数据日志")]
// public bool VerboseSimulationLogging = false;
// /// <summary>
// /// 获取是否应该使用模拟数据
// /// </summary>
// public bool ShouldUseSimulatedData => ForceSimulatedData || (!UseRealSerialData);
// /// <summary>
// /// 获取数据源描述
// /// </summary>
// public string GetDataSourceDescription()
// {
// if (ForceSimulatedData)
// return "强制模拟数据模式";
// else if (!UseRealSerialData)
// return "模拟数据模式";
// else if (AllowSimulatedFallback)
// return "串口数据(允许模拟备用)";
// else
// return "纯串口数据模式";
// }
// /// <summary>
// /// 创建默认配置
// /// </summary>
// public static DataSourceConfig CreateDefault()
// {
// var config = CreateInstance<DataSourceConfig>();
// config.UseRealSerialData = true;
// config.AllowSimulatedFallback = false;
// config.ForceSimulatedData = false;
// #if UNITY_ANDROID && !UNITY_EDITOR
// config.SerialPortName = "/dev/ttyS4";
// #elif UNITY_STANDALONE_WIN || UNITY_EDITOR_WIN
// config.SerialPortName = "COM1";
// #else
// config.SerialPortName = "/dev/ttyS4";
// #endif
// config.BaudRate = 115200;
// config.VerboseSerialLogging = true;
// return config;
// }
// void OnValidate()
// {
// // 确保数值范围合理
// SimulatedBFIRange.x = Mathf.Clamp(SimulatedBFIRange.x, 0f, 100f);
// SimulatedBFIRange.y = Mathf.Clamp(SimulatedBFIRange.y, SimulatedBFIRange.x, 100f);
// SimulatedBloodFlowRange.x = Mathf.Clamp(SimulatedBloodFlowRange.x, 0f, 300f);
// SimulatedBloodFlowRange.y = Mathf.Clamp(SimulatedBloodFlowRange.y, SimulatedBloodFlowRange.x, 300f);
// SimulatedBatteryLevel = Mathf.Clamp(SimulatedBatteryLevel, 0f, 100f);
// DataUpdateInterval = Mathf.Max(0.1f, DataUpdateInterval);
// }
// }