Initial commit: Refactor AgvAutoRunControls
This commit is contained in:
282
types.ts
Normal file
282
types.ts
Normal file
@@ -0,0 +1,282 @@
|
||||
|
||||
|
||||
export enum ToolType {
|
||||
SELECT = 'SELECT',
|
||||
DRAW_LINE = 'DRAW_LINE', // Logical Edge
|
||||
DRAW_MAGNET_STRAIGHT = 'DRAW_MAGNET_STRAIGHT', // Physical Line
|
||||
DRAW_MAGNET_CURVE = 'DRAW_MAGNET_CURVE', // Physical Curve
|
||||
ADD_RFID = 'ADD_RFID',
|
||||
ADD_MARK = 'ADD_MARK',
|
||||
ERASER = 'ERASER',
|
||||
}
|
||||
|
||||
export interface Point {
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
// C# MapNode Type Enum (Internal use)
|
||||
export enum NodeType {
|
||||
Normal = 0,
|
||||
Loader = 1,
|
||||
UnLoader = 2,
|
||||
Charging = 3, // Used for Cleaner in new map
|
||||
Buffer = 4,
|
||||
ChargerStation = 5,
|
||||
Label = 6,
|
||||
Image = 7
|
||||
}
|
||||
|
||||
// React Internal Node Structure
|
||||
export interface MapNode extends Point {
|
||||
id: string; // NodeId
|
||||
type: number; // NodeType (Internal enum)
|
||||
name: string;
|
||||
rfidId: string; // RFID is property of Node
|
||||
connectedNodes: string[]; // Keep track for export
|
||||
|
||||
// Visual props
|
||||
labelText?: string;
|
||||
foreColor?: string;
|
||||
backColor?: string;
|
||||
imageBase64?: string;
|
||||
displayColor?: string;
|
||||
|
||||
// New props preservation
|
||||
fontSize?: number;
|
||||
}
|
||||
|
||||
export interface MapEdge {
|
||||
id: string;
|
||||
from: string;
|
||||
to: string;
|
||||
}
|
||||
|
||||
// Physical Magnet Line for AGV to follow
|
||||
export interface MagnetLine {
|
||||
id: string;
|
||||
type: 'STRAIGHT' | 'CURVE';
|
||||
p1: Point;
|
||||
p2: Point;
|
||||
controlPoint?: Point; // Required for CURVE (Quadratic Bezier control point)
|
||||
}
|
||||
|
||||
// Mark Sensor now needs rotation to be "crossed" on the line
|
||||
export interface FloorMark extends Point {
|
||||
id: string;
|
||||
rotation: number; // Degrees
|
||||
}
|
||||
|
||||
export interface SimulationMap {
|
||||
nodes: MapNode[];
|
||||
edges: MapEdge[]; // Logical Graph Connections
|
||||
magnets: MagnetLine[]; // Physical Guide Tape
|
||||
marks: FloorMark[];
|
||||
}
|
||||
|
||||
// --- C# Data Transfer Objects (New JSON Structure) ---
|
||||
|
||||
export interface CSharpNode {
|
||||
Id: string;
|
||||
Text: string;
|
||||
Position: string; // "x, y"
|
||||
Type: number; // Usually 0 for nodes
|
||||
StationType: number; // Functional type
|
||||
ConnectedNodes: string[];
|
||||
RfidId: string;
|
||||
NodeTextForeColor?: string;
|
||||
NodeTextFontSize?: number;
|
||||
// Flags (Optional for TS if not used logic-side, but good to preserve)
|
||||
CanDocking?: boolean;
|
||||
DockDirection?: number;
|
||||
CanTurnLeft?: boolean;
|
||||
CanTurnRight?: boolean;
|
||||
DisableCross?: boolean;
|
||||
IsActive?: boolean;
|
||||
SpeedLimit?: number;
|
||||
AliasName?: string;
|
||||
}
|
||||
|
||||
export interface CSharpLabel {
|
||||
Id: string;
|
||||
Type: number; // 1
|
||||
Text: string;
|
||||
Position: string;
|
||||
ForeColor: string;
|
||||
BackColor: string;
|
||||
FontFamily?: string;
|
||||
FontSize?: number;
|
||||
FontStyle?: number;
|
||||
Padding?: number;
|
||||
}
|
||||
|
||||
export interface CSharpImage {
|
||||
Id: string;
|
||||
Type: number; // 2
|
||||
Name: string;
|
||||
Position: string;
|
||||
ImagePath?: string;
|
||||
ImageBase64?: string;
|
||||
Scale?: string;
|
||||
Opacity?: number;
|
||||
Rotation?: number;
|
||||
}
|
||||
|
||||
export interface CSharpMagnet {
|
||||
Id: string;
|
||||
Type: number; // 4
|
||||
P1: { X: number; Y: number };
|
||||
P2: { X: number; Y: number };
|
||||
ControlPoint?: { X: number; Y: number } | null;
|
||||
}
|
||||
|
||||
export interface CSharpMark {
|
||||
Id: string;
|
||||
Type: number; // 3
|
||||
Position: string;
|
||||
X: number;
|
||||
Y: number;
|
||||
Rotation: number;
|
||||
}
|
||||
|
||||
export interface CSharpMapData {
|
||||
Nodes: CSharpNode[];
|
||||
Labels?: CSharpLabel[];
|
||||
Images?: CSharpImage[];
|
||||
Magnets: CSharpMagnet[];
|
||||
Marks: CSharpMark[];
|
||||
Settings?: any;
|
||||
Version: string;
|
||||
CreatedDate: string;
|
||||
}
|
||||
|
||||
export enum AgvMotionState {
|
||||
IDLE = 'IDLE',
|
||||
FORWARD = 'FORWARD',
|
||||
BACKWARD = 'BACKWARD',
|
||||
TURN_LEFT = 'TURN_LEFT',
|
||||
TURN_RIGHT = 'TURN_RIGHT',
|
||||
TURN_LEFT_180 = 'TURN_LEFT_180',
|
||||
TURN_RIGHT_180 = 'TURN_RIGHT_180',
|
||||
MARK_STOPPING = 'MARK_STOPPING',
|
||||
RUNNING = 'RUNNING',
|
||||
}
|
||||
|
||||
export interface AgvRunConfig {
|
||||
direction: 'FWD' | 'BWD';
|
||||
branch: 'STRAIGHT' | 'LEFT' | 'RIGHT';
|
||||
speedLevel: 'L' | 'M' | 'H';
|
||||
}
|
||||
|
||||
// --- Protocol Enums (Matched with C# DevAGV.cs) ---
|
||||
|
||||
export enum AgvError {
|
||||
Emergency = 0,
|
||||
Overcurrent = 1,
|
||||
Charger_run_error = 2,
|
||||
Charger_pos_error = 3,
|
||||
line_out_error = 4,
|
||||
runerror_by_no_magent_line = 5,
|
||||
agv_system_error=6,
|
||||
battery_low_voltage=7,
|
||||
lift_time_over=9,
|
||||
lift_driver_ocr=10,
|
||||
lift_driver_emg = 11,
|
||||
arrive_ctl_comm_error = 12,
|
||||
door_ctl_comm_error = 13,
|
||||
charger_comm_error = 14,
|
||||
cross_ctrl_comm_error = 15,
|
||||
}
|
||||
|
||||
export enum AgvSignal {
|
||||
front_gate_out = 0,
|
||||
rear_sensor_out = 1,
|
||||
mark_sensor_1 = 2,
|
||||
mark_sensor_2 = 3,
|
||||
lift_down_sensor = 4,
|
||||
lift_up_sensor = 5,
|
||||
magnet_relay = 6,
|
||||
charger_align_sensor = 7,
|
||||
front_center_sensor = 8,
|
||||
}
|
||||
|
||||
export enum SystemFlag0 {
|
||||
Memory_RW_State = 5,
|
||||
EXT_IO_Conn_State = 6,
|
||||
RFID_Conn_State = 7,
|
||||
M5E_Module_Run_State = 8,
|
||||
Front_Ultrasonic_Conn_State = 9,
|
||||
Front_Untrasonic_Sensor_State = 10,
|
||||
Side_Ultrasonic_Conn_State = 11,
|
||||
Side_Ultrasonic_Sensor_State = 12,
|
||||
Front_Guide_Sensor_State = 13,
|
||||
Rear_Guide_Sensor_State = 14,
|
||||
Battery_Level_Check = 15
|
||||
}
|
||||
|
||||
export enum SystemFlag1 {
|
||||
Side_Detect_Ignore = 3,
|
||||
Melody_check = 4,
|
||||
Mark2_check = 5,
|
||||
Mark1_check = 6,
|
||||
gateout_check = 7,
|
||||
Battery_charging = 8,
|
||||
re_Start = 9,
|
||||
front_detect_ignore = 10,
|
||||
front_detect_check = 11,
|
||||
stop_by_front_detect = 12,
|
||||
stop_by_cross_in = 13,
|
||||
agv_stop = 14,
|
||||
agv_run = 15
|
||||
}
|
||||
|
||||
export interface AgvState {
|
||||
x: number;
|
||||
y: number;
|
||||
rotation: number;
|
||||
targetRotation: number | null;
|
||||
speed: number;
|
||||
liftHeight: number;
|
||||
motionState: AgvMotionState;
|
||||
runConfig: AgvRunConfig;
|
||||
error: string | null;
|
||||
sensorStatus: string; // Corresponds to sts_sensor in C#
|
||||
|
||||
// Physical Sensors
|
||||
detectedRfid: string | null;
|
||||
sensorLineFront: boolean;
|
||||
sensorLineRear: boolean;
|
||||
sensorMark: boolean;
|
||||
|
||||
// New features
|
||||
magnetOn: boolean;
|
||||
liftStatus: 'IDLE' | 'UP' | 'DOWN';
|
||||
lidarEnabled: boolean; // 1=ON, 0=OFF
|
||||
|
||||
// Protocol Flags (Integers representing bitmaps)
|
||||
system0: number;
|
||||
system1: number;
|
||||
errorFlags: number;
|
||||
signalFlags: number;
|
||||
|
||||
// Battery
|
||||
batteryLevel: number; // Percentage 0-100
|
||||
maxCapacity: number; // Ah (Total Capacity)
|
||||
batteryTemp: number;
|
||||
cellVoltages: number[];
|
||||
}
|
||||
|
||||
export interface LogEntry {
|
||||
id: string;
|
||||
timestamp: string;
|
||||
type: 'INFO' | 'RX' | 'TX' | 'ERROR';
|
||||
source: 'AGV' | 'BMS' | 'ACS' | 'SYSTEM';
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface AcsPacket {
|
||||
id: number;
|
||||
command: number;
|
||||
data: number[];
|
||||
valid: boolean;
|
||||
}
|
||||
Reference in New Issue
Block a user