Initial commit

This commit is contained in:
2026-07-03 16:37:12 +07:00
commit 63b8c1ea8b
1931 changed files with 640587 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
using RobotNet10.Shared.Geometry;
namespace RobotNet10.RobotApp.Client.Shared.Devices;
/// <summary>
/// DTO cho Camera QR data
/// </summary>
public class CameraQrDataDto
{
public bool IsConnected { get; set; }
public Dictionary<string, PoseStamped> Codes { get; set; } = [];
}

View File

@@ -0,0 +1,23 @@
namespace RobotNet10.RobotApp.Client.Shared.Devices;
/// <summary>
/// DTO cho CiA402Servo data
/// </summary>
public struct CiA402ServoDataDto
{
public ushort Statusword { get; set; }
public string DriveState { get; set; }
public string OperationMode { get; set; }
public int Position { get; set; }
public int Velocity { get; set; }
public short Torque { get; set; }
public ushort ErrorCode { get; set; }
public bool IsConnected { get; set; }
/// <summary>Profile Speed (0x6081) - đọc từ drive khi GetServoData</summary>
public uint ProfileSpeed { get; set; }
/// <summary>Profile Acceleration (0x6083) - đọc từ drive khi GetServoData</summary>
public uint ProfileAcceleration { get; set; }
/// <summary>Profile Deceleration (0x6084) - đọc từ drive khi GetServoData</summary>
public uint ProfileDeceleration { get; set; }
}

View File

@@ -0,0 +1,25 @@
namespace RobotNet10.RobotApp.Client.Shared.Devices;
/// <summary>
/// DTO cho thông tin device để truyền qua SignalR
/// </summary>
public class DeviceDto
{
public string DeviceId { get; set; } = string.Empty;
public string DeviceName { get; set; } = string.Empty;
public DeviceType DeviceType { get; set; }
public string? Description { get; set; }
public DeviceStatus Status { get; set; }
public bool IsConnected { get; set; }
public DateTime LastUpdateTime { get; set; }
public DateTime? LastConnectedTime { get; set; }
public DateTime? LastDisconnectedTime { get; set; }
public string? LastError { get; set; }
public int ReconnectAttemptCount { get; set; }
public bool AutoReconnectEnabled { get; set; }
public int ReconnectDelayMs { get; set; }
public int MaxReconnectAttempts { get; set; }
public List<PropertyDescription> PropertyDescriptions { get; set; } = new();
public Dictionary<string, string> Properties { get; set; } = new();
}

View File

@@ -0,0 +1,11 @@
namespace RobotNet10.RobotApp.Client.Shared.Devices;
/// <summary>
/// DTO cho Device info (shared với server)
/// </summary>
public class DeviceInfoDto
{
public string DeviceId { get; set; } = string.Empty;
public string DeviceName { get; set; } = string.Empty;
}

View File

@@ -0,0 +1,53 @@
namespace RobotNet10.RobotApp.Client.Shared.Devices;
/// <summary>
/// Trạng thái của thiết bị (State Machine)
/// </summary>
public enum DeviceStatus
{
/// <summary>
/// Chưa khởi tạo
/// </summary>
Uninitialized = 0,
/// <summary>
/// Đang khởi tạo
/// </summary>
Initializing,
/// <summary>
/// Đang kết nối
/// </summary>
Connecting,
/// <summary>
/// Đã kết nối và sẵn sàng
/// </summary>
Connected,
/// <summary>
/// Đang ngắt kết nối
/// </summary>
Disconnecting,
/// <summary>
/// Đã ngắt kết nối
/// </summary>
Disconnected,
/// <summary>
/// Đang kết nối lại (auto-reconnect)
/// </summary>
Reconnecting,
/// <summary>
/// Lỗi - cần xử lý
/// </summary>
Error,
/// <summary>
/// Đã bị dispose
/// </summary>
Disposed
}

View File

@@ -0,0 +1,44 @@
namespace RobotNet10.RobotApp.Client.Shared.Devices;
/// <summary>
/// Loại thiết bị trong hệ thống AMR
/// </summary>
public enum DeviceType
{
/// <summary>
/// Servo motor theo chuẩn CiA402
/// </summary>
CiA402Servo = 0,
/// <summary>
/// LiDAR - cảm biến quét laser
/// </summary>
Lidar,
/// <summary>
/// IMU - Inertial Measurement Unit
/// </summary>
Imu,
/// <summary>
/// Pin/Battery
/// </summary>
Battery,
/// <summary>
/// ModbusTCP client/server
/// </summary>
ModbusTcp,
/// <summary>
/// Tay điều khiển RF (RF Handle)
/// </summary>
RfHandle,
/// <summary>
/// Camera phát hiện QR code
/// </summary>
CameraQr,
}

View File

@@ -0,0 +1,17 @@
namespace RobotNet10.RobotApp.Client.Shared.Devices;
/// <summary>
/// DTO cho device update events qua SignalR
/// </summary>
public class DeviceUpdateDto
{
public string DeviceId { get; set; } = string.Empty;
public DeviceStatus? Status { get; set; }
public Dictionary<string, string>? Properties { get; set; }
public string? LastError { get; set; }
public DateTime? LastUpdateTime { get; set; }
public DateTime? LastConnectedTime { get; set; }
public DateTime? LastDisconnectedTime { get; set; }
public int? ReconnectAttemptCount { get; set; }
}

View File

@@ -0,0 +1,52 @@
namespace RobotNet10.RobotApp.Client.Shared.Devices;
/// <summary>
/// DTO cho Modbus value (register)
/// </summary>
public struct ModbusValue
{
public ushort Address { get; set; }
public ushort Index { get; set; }
public ushort Value { get; set; }
public string Name { get; set; }
}
/// <summary>
/// DTO cho Modbus bool value (coil/discrete input)
/// </summary>
public struct ModbusBoolValue
{
public ushort Address { get; set; }
public ushort Index { get; set; }
public bool Value { get; set; }
public string Name { get; set; }
}
/// <summary>
/// DTO cho Modbus range data
/// </summary>
public struct ModbusRangeData
{
public ushort StartAddress { get; set; }
public ushort Quantity { get; set; }
public string Name { get; set; }
public string[] ChildrenNames { get; set; }
public ModbusValue[] Values { get; set; }
public ModbusBoolValue[] BoolValues { get; set; }
}
/// <summary>
/// DTO cho ModbusTCP data
/// </summary>
public struct ModbusTcpData
{
public string IpAddress { get; set; }
public int Port { get; set; }
public byte SlaveId { get; set; }
public bool IsConnected { get; set; }
public ModbusRangeData[] HoldingRegisters { get; set; }
public ModbusRangeData[] InputRegisters { get; set; }
public ModbusRangeData[] Coils { get; set; }
public ModbusRangeData[] DiscreteInputs { get; set; }
}

View File

@@ -0,0 +1,69 @@
namespace RobotNet10.RobotApp.Client.Shared.Devices;
/// <summary>
/// Mô tả một property của thiết bị (dùng để hiển thị trên web UI)
/// </summary>
public class PropertyDescription
{
/// <summary>
/// Tên key của property (phải khớp với key trong Properties dictionary)
/// </summary>
public string Key { get; set; } = string.Empty;
/// <summary>
/// Tên hiển thị trên UI
/// </summary>
public string DisplayName { get; set; } = string.Empty;
/// <summary>
/// Mô tả chi tiết về property
/// </summary>
public string? Description { get; set; }
/// <summary>
/// Loại dữ liệu (ví dụ: "string", "number", "boolean", "date", "url", etc.)
/// </summary>
public string DataType { get; set; } = "string";
/// <summary>
/// Đơn vị đo (ví dụ: "V", "A", "Hz", "°C", "m/s", etc.) - null nếu không có
/// </summary>
public string? Unit { get; set; }
/// <summary>
/// Giá trị mặc định
/// </summary>
public string? DefaultValue { get; set; }
/// <summary>
/// Có thể chỉnh sửa trên UI hay không
/// </summary>
public bool IsReadOnly { get; set; } = false;
/// <summary>
/// Thứ tự hiển thị trên UI (số nhỏ hơn hiển thị trước)
/// </summary>
public int DisplayOrder { get; set; } = 0;
/// <summary>
/// Nhóm/category của property (để nhóm các properties lại với nhau trên UI)
/// </summary>
public string? Category { get; set; }
/// <summary>
/// Format string để hiển thị giá trị (ví dụ: "{0:F2}", "{0:yyyy-MM-dd}", etc.)
/// </summary>
public string? Format { get; set; }
public PropertyDescription()
{
}
public PropertyDescription(string key, string displayName, string? description = null)
{
Key = key ?? throw new ArgumentNullException(nameof(key));
DisplayName = displayName ?? throw new ArgumentNullException(nameof(displayName));
Description = description;
}
}

View File

@@ -0,0 +1,29 @@
namespace RobotNet10.RobotApp.Client.Shared.Devices;
// ======================================================================
// DTO LITE khớp 100% IRfHandle Lite + RfHandleHub Lite
// ======================================================================
public class RfHandleDataDto
{
public string DeviceId { get; set; } = "";
public int Heartbeat { get; set; }
public bool RemoteReady { get; set; }
public bool EStop { get; set; }
public bool LiftUp { get; set; }
public bool LiftDown { get; set; }
public bool RotateLeft { get; set; }
public bool RotateRight { get; set; }
public bool ModeSelect { get; set; }
public bool Enable { get; set; }
public int Speed { get; set; }
public double Linear { get; set; }
public double Angular { get; set; }
public string Mode { get; set; } = "Unknown";
public DateTime LastUpdateTime { get; set; }
}