Implement global axis system and advanced motion logic
This commit is contained in:
62
types.ts
62
types.ts
@@ -27,22 +27,28 @@ export interface AxisPositionTrigger {
|
||||
targetInputPort: number; // Sets this Input bit when condition met
|
||||
}
|
||||
|
||||
export interface AxisData {
|
||||
id: number; // 0-7
|
||||
name: string;
|
||||
value: number;
|
||||
target: number;
|
||||
speed: number;
|
||||
type: 'linear' | 'rotary';
|
||||
}
|
||||
|
||||
export interface AxisObject extends BaseObject {
|
||||
type: ObjectType.AXIS_LINEAR | ObjectType.AXIS_ROTARY;
|
||||
axisIndex: number; // 0-7, Binds to Global Axis
|
||||
min: number;
|
||||
max: number;
|
||||
currentValue: number;
|
||||
targetValue: number;
|
||||
speed: number;
|
||||
isOscillating: boolean;
|
||||
triggers: AxisPositionTrigger[]; // Axis drives Inputs
|
||||
triggers: AxisPositionTrigger[]; // Triggers still belong to the physical object placement
|
||||
}
|
||||
|
||||
export interface CylinderObject extends BaseObject {
|
||||
type: ObjectType.CYLINDER;
|
||||
stroke: number;
|
||||
extended: boolean;
|
||||
currentPosition: number;
|
||||
extended: boolean;
|
||||
currentPosition: number;
|
||||
speed: number;
|
||||
outputPort: number; // Reads this Output bit to extend
|
||||
}
|
||||
@@ -64,24 +70,51 @@ export interface LedObject extends BaseObject {
|
||||
export type SimObject = AxisObject | CylinderObject | SwitchObject | LedObject;
|
||||
|
||||
// Logic Types
|
||||
export enum LogicTriggerType {
|
||||
INPUT_BIT = 'INPUT_BIT',
|
||||
AXIS_COMPARE = 'AXIS_COMPARE',
|
||||
}
|
||||
|
||||
export enum LogicActionType {
|
||||
OUTPUT_COIL = 'OUTPUT_COIL',
|
||||
AXIS_MOVE = 'AXIS_MOVE',
|
||||
}
|
||||
|
||||
export enum LogicCondition {
|
||||
IS_ON = 'IS_ON',
|
||||
IS_OFF = 'IS_OFF',
|
||||
GREATER = '>',
|
||||
LESS = '<',
|
||||
EQUAL = '==',
|
||||
GREATER_EQUAL = '>=',
|
||||
LESS_EQUAL = '<=',
|
||||
}
|
||||
|
||||
export enum LogicAction {
|
||||
SET_ON = 'ON',
|
||||
SET_OFF = 'OFF',
|
||||
TOGGLE = 'TOGGLE',
|
||||
SET_ON = 'ON',
|
||||
SET_OFF = 'OFF',
|
||||
TOGGLE = 'TOGGLE',
|
||||
MOVE_ABS = 'MOVE_ABS',
|
||||
MOVE_REL = 'MOVE_REL',
|
||||
}
|
||||
|
||||
export interface IOLogicRule {
|
||||
id: string;
|
||||
inputPort: number;
|
||||
condition: LogicCondition;
|
||||
outputPort: number;
|
||||
action: LogicAction;
|
||||
enabled: boolean;
|
||||
|
||||
// Trigger
|
||||
triggerType: LogicTriggerType;
|
||||
inputPort: number; // For INPUT_BIT
|
||||
triggerAxisIndex: number; // For AXIS_COMPARE
|
||||
triggerCompareOp: LogicCondition; // For AXIS_COMPARE (>, <, ==)
|
||||
triggerValue: number; // For AXIS_COMPARE
|
||||
|
||||
// Action
|
||||
actionType: LogicActionType;
|
||||
outputPort: number; // For OUTPUT_COIL
|
||||
action: LogicAction; // For OUTPUT_COIL (ON/OFF)
|
||||
targetAxisIndex: number; // For AXIS_MOVE
|
||||
targetAxisValue: number; // For AXIS_MOVE
|
||||
}
|
||||
|
||||
// Full Project Export Type
|
||||
@@ -91,4 +124,5 @@ export interface ProjectData {
|
||||
logicRules: IOLogicRule[];
|
||||
inputNames: string[];
|
||||
outputNames: string[];
|
||||
axes: AxisData[];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user