85 lines
2.6 KiB
C#
85 lines
2.6 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using ThreatSource.Utils;
|
|
|
|
namespace ThreatSource.Simulation
|
|
{
|
|
/// <summary>
|
|
/// 仿真元素状态信息类,包含所有仿真元素的基本状态属性和扩展属性
|
|
/// </summary>
|
|
public class ElementStatusInfo
|
|
{
|
|
/// <summary>
|
|
/// 仿真元素的唯一标识符
|
|
/// </summary>
|
|
public string Id { get; set; }
|
|
|
|
/// <summary>
|
|
/// 仿真元素的类型名称
|
|
/// </summary>
|
|
public string ElementType { get; set; }
|
|
|
|
/// <summary>
|
|
/// 仿真元素的当前位置
|
|
/// </summary>
|
|
public Vector3D Position { get; set; }
|
|
|
|
/// <summary>
|
|
/// 仿真元素的当前朝向
|
|
/// </summary>
|
|
public Orientation Orientation { get; set; }
|
|
|
|
/// <summary>
|
|
/// 仿真元素的当前速度
|
|
/// </summary>
|
|
public double Speed { get; set; }
|
|
|
|
/// <summary>
|
|
/// 仿真元素是否处于活动状态
|
|
/// </summary>
|
|
public bool IsActive { get; set; }
|
|
|
|
/// <summary>
|
|
/// 状态信息的创建时间戳
|
|
/// </summary>
|
|
public long Timestamp { get; set; }
|
|
|
|
/// <summary>
|
|
/// 扩展属性字典,用于存储特定元素类型的额外属性
|
|
/// </summary>
|
|
public Dictionary<string, object> ExtendedProperties { get; set; }
|
|
|
|
/// <summary>
|
|
/// 初始化状态信息对象
|
|
/// </summary>
|
|
public ElementStatusInfo()
|
|
{
|
|
ExtendedProperties = new Dictionary<string, object>();
|
|
Timestamp = DateTime.UtcNow.Ticks;
|
|
|
|
// 初始化非空属性
|
|
Id = string.Empty;
|
|
ElementType = string.Empty;
|
|
Position = Vector3D.Zero;
|
|
Orientation = new Orientation();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 将状态信息转换为格式化的字符串表示
|
|
/// </summary>
|
|
/// <returns>状态的字符串表示</returns>
|
|
public override string ToString()
|
|
{
|
|
string baseInfo = $"仿真元素 {ElementType} {Id} at {Position}, Orientation: {Orientation}, Active: {IsActive}";
|
|
|
|
if (ExtendedProperties.Count > 0)
|
|
{
|
|
string extendedInfo = string.Join(", ", ExtendedProperties.Select(p => $"{p.Key}={p.Value}"));
|
|
return $"{baseInfo}, {extendedInfo}";
|
|
}
|
|
|
|
return baseInfo;
|
|
}
|
|
}
|
|
} |