Compare commits

...
Author SHA1 Message Date
snacj dc78ab80cb Fixed Formatting 2025-10-01 14:55:14 +02:00
snacj af21d05e6a Fixed merge issues 2025-10-01 14:49:51 +02:00
snacj aa54f94e94 fixed merge issues 2025-10-01 14:14:53 +02:00
snacj e00b0d2c3e Added Buffer Logic 2025-10-01 14:13:22 +02:00
snacj b338d71874 Changed Buffer Winder Mode 2025-10-01 14:13:22 +02:00
snacj fb650216d2 Added Buffer Mode to Winder frontend 2025-10-01 14:12:45 +02:00
snacj da823197d5 Finished Homing Routine 2025-10-01 14:12:45 +02:00
snacj fe5f109c89 Fixed step converter errors 2025-10-01 14:11:53 +02:00
snacj 1d86a42fb6 Fixed Merge Conflicts 2025-10-01 14:11:11 +02:00
snacj fb8eee4b8d Resolved merge conflicts 2025-10-01 14:09:59 +02:00
snacj 24cd1d857f Implemented Buffer state for Winder 2025-10-01 14:07:38 +02:00
snacj b7c4e1939d Changed Formatting and Removed unused imports 2025-10-01 14:06:35 +02:00
snacj 7d0a683c4b Added Puller frontend functions, hooks and Controlpage for Buffer 2025-10-01 14:04:25 +02:00
snacj fde51a95c8 Refactored to clean Act function in Winder2 2025-10-01 14:00:58 +02:00
snacj d88f45f81f Implemented Buffer Business Logic 2025-10-01 13:59:51 +02:00
snacj 8e0005d447 Added start of business logic for buffer lift 2025-10-01 13:56:22 +02:00
snacj 2bfa75810f Fixed Formatting 2025-10-01 13:30:52 +02:00
snacj b86130ec0d Fixed Rebase Issues and removed unused imports 2025-10-01 12:41:34 +02:00
snacj ad9305e1fd Fixed Formatting 2025-10-01 12:33:02 +02:00
snacj 191d022270 Fixed target speed communication between buffer and winder. 2025-10-01 12:33:02 +02:00
snacj 2d3a69852f Fixed merge issue 2025-10-01 12:33:02 +02:00
snacj d145bf547e Finished Homing Routine 2025-10-01 12:33:02 +02:00
snacj ed90b253f7 Removed unused top and bottom limits 2025-10-01 12:32:48 +02:00
snacj 4e78c6c912 Removed "Traverse Bar" 2025-10-01 12:32:48 +02:00
snacj 1efebc4a27 Fixed mode 2025-10-01 12:32:48 +02:00
snacj ea7d799cfc Fixed step converter errors 2025-10-01 12:32:48 +02:00
snacj 54ac5678ad Added Capability checks for moving 2025-10-01 12:32:48 +02:00
snacj 19ebbb77ac Fixed Comments 2025-10-01 12:32:48 +02:00
snacj 4bb2a73f6c Fixed State 2025-10-01 12:32:48 +02:00
snacj 972562b1d6 Added Control Functions 2025-10-01 12:32:48 +02:00
snacj 2a68a2da8f Adjusted Values and restructured controls 2025-10-01 12:32:48 +02:00
snacj 2d7b71ef5d Added Lift State frontend 2025-10-01 12:32:48 +02:00
snacj 0398bd0242 Added Lift Control functions 2025-10-01 12:32:48 +02:00
snacj 74e83d7cf5 Added Lift State and Mutations 2025-10-01 12:32:48 +02:00
snacj 25a1d3515d Added Lift State and Mutations 2025-10-01 12:32:48 +02:00
snacj 81d4b162e9 Fixed update speed function 2025-10-01 12:32:48 +02:00
snacj a790f15db9 Added Homing Routine Functions 2025-10-01 12:32:48 +02:00
snacj 50d7373f02 Fixed Merge Conflicts 2025-10-01 12:32:48 +02:00
snacj f1cd0c6216 Resolved merge conflicts 2025-10-01 12:32:32 +02:00
snacj eb7724a756 Implemented Buffer state for Winder 2025-10-01 12:31:56 +02:00
snacj df88eded18 Updated End Switch Logic 2025-10-01 12:31:34 +02:00
snacj 503a6b493e Fixed Formatting 2025-10-01 12:31:34 +02:00
snacj 4a7bb2abfd Added Digital Input switch for end Switch (Top) at Buffer 2025-10-01 12:31:34 +02:00
snacj 12a42eb0a6 Changed Formatting and Removed unused imports 2025-10-01 12:31:34 +02:00
snacj d3981d7276 Changed Mode names for Buffer + Added Hold Mode 2025-10-01 12:30:49 +02:00
snacj 89e702275e Added Comment 2025-10-01 12:30:49 +02:00
snacj 4a1239fa27 Update sync of puller speed and buffer input speed & Added description to helper function 2025-10-01 12:30:49 +02:00
snacj bd22c39b4a Added settings page to buffer route 2025-10-01 12:30:49 +02:00
snacj 96edca9f66 Added helper function to get Connected Machine reference. --Needs testing 2025-10-01 12:30:28 +02:00
snacj 2d198e0a44 Added Puller frontend functions, hooks and Controlpage for Buffer 2025-10-01 12:30:28 +02:00
snacj 9107e1372a Implemented Puller functions in Buffer Mod 2025-10-01 12:30:01 +02:00
snacj 8268eff39b Added pullerSpeed State Event 2025-10-01 12:30:01 +02:00
snacj 63910ab5be Renamed Function 2025-10-01 12:30:01 +02:00
snacj 91fdd7eb1e Added call to winder on buffering 2025-10-01 12:30:01 +02:00
snacj 8aa86a91ff Fixed Formatting 2025-10-01 12:30:01 +02:00
snacj 6f125ff0ab Refactored to clean Act function in Winder2 2025-10-01 12:30:01 +02:00
snacj 256c032b7c Changed updating speed logic to use JerkSpeedController 2025-10-01 12:29:36 +02:00
snacj 46a794d323 Implemented Buffer Business Logic 2025-10-01 12:29:36 +02:00
snacj a18b10bf50 Updated Act function to implement puller sync and buffer input speed 2025-10-01 12:28:01 +02:00
snacj 405a1f3c2f Added Puller Speed Controller to Buffer 2025-10-01 12:28:01 +02:00
snacj 3e09a00000 Added start of business logic for buffer lift 2025-10-01 12:28:01 +02:00
snacj b4ee86a88c Added current_input_speed state to test the calculation of buffer_lift_speed 2025-10-01 12:27:15 +02:00
snacj 1eeb3f8190 Changed name buffer_tower_controller -> buffer-lift_controller 2025-10-01 12:27:15 +02:00
19 changed files with 1619 additions and 112 deletions

No files matched your search

@@ -5,15 +5,37 @@ import React from "react";
import { useBuffer1 } from "./useBuffer1";
import { ControlCard } from "@/control/ControlCard";
import { SelectionGroup } from "@/control/SelectionGroup";
import { EditValue } from "@/control/EditValue";
import { TimeSeriesValueNumeric } from "@/control/TimeSeriesValue";
import { roundToDecimals } from "@/lib/decimal";
import { Label } from "@/control/Label";
import { TouchButton } from "@/components/touch/TouchButton";
import { StatusBadge } from "@/control/StatusBadge";
export function Buffer1ControlPage() {
const { state, setBufferMode } = useBuffer1();
const {
state,
defaultState,
setBufferMode,
setCurrentInputSpeed,
pullerSpeed,
setPullerRegulationMode,
setPullerTargetSpeed,
liftPosition,
gotoLiftHome,
isLoading,
isDisabled,
} = useBuffer1();
const current_input_speed =
state?.current_input_speed_state.current_input_speed ?? 0.0;
const default_speed = 0.0;
return (
<Page>
<ControlGrid>
<ControlCard className="bg-red" title="Mode">
<SelectionGroup<"Standby" | "FillingBuffer" | "EmptyingBuffer">
<SelectionGroup<"Standby" | "Hold" | "Filling" | "Emptying">
value={state?.mode_state.mode}
orientation="vertical"
className="grid h-full grid-cols-2 gap-2"
@@ -24,13 +46,19 @@ export function Buffer1ControlPage() {
isActiveClassName: "bg-green-600",
className: "h-full",
},
FillingBuffer: {
children: "FillingBuffer",
Hold: {
children: "Hold",
icon: "lu:Pause",
isActiveClassName: "bg-green-600",
className: "h-full",
},
Filling: {
children: "Filling",
icon: "lu:Flame",
isActiveClassName: "bg-green-600",
className: "h-full",
},
EmptyingBuffer: {
Emptying: {
children: "EmptyingBuffer",
icon: "lu:ArrowBigLeftDash",
isActiveClassName: "bg-green-600",
@@ -40,6 +68,83 @@ export function Buffer1ControlPage() {
onChange={setBufferMode}
/>
</ControlCard>
<ControlCard title="Set Current Input Speed - (For Debugging)">
<EditValue
title="Input Speed"
unit="m/min"
value={current_input_speed}
defaultValue={default_speed}
min={0.0}
max={60.0}
step={0.1}
renderValue={(value) => roundToDecimals(value, 1)}
onChange={setCurrentInputSpeed}
/>
</ControlCard>
<ControlCard className="bg-red" height={2} title="Lift">
<TimeSeriesValueNumeric
label="Position"
unit="mm"
timeseries={liftPosition}
renderValue={(value) => roundToDecimals(value, 1)}
/>
<Label label="Home">
<TouchButton
variant="outline"
icon="lu:House"
onClick={() => gotoLiftHome()}
disabled={isDisabled}
isLoading={isLoading || state?.lift_state?.is_going_home}
>
Go to Home
</TouchButton>
{state?.lift_state?.is_homed !== true ? (
<StatusBadge variant={"error"}>{"Not Homed"}</StatusBadge>
) : null}
</Label>
</ControlCard>
<ControlCard className="bg-red" title="Puller">
<TimeSeriesValueNumeric
label="Speed"
unit="m/min"
timeseries={pullerSpeed}
renderValue={(value) => roundToDecimals(value, 1)}
/>
<Label label="Regulation">
<SelectionGroup
value={state?.puller_state?.regulation}
options={{
Speed: {
children: "Speed",
icon: "lu:Gauge",
},
Diameter: {
children: "Diameter",
icon: "lu:Sun",
disabled: true,
},
}}
onChange={setPullerRegulationMode}
disabled={isDisabled}
loading={isLoading}
/>
</Label>
<Label label="Target Speed">
<EditValue
value={state?.puller_state?.target_speed}
unit="m/min"
title="Target Speed"
defaultValue={defaultState?.puller_state?.target_speed}
min={0}
max={75}
step={0.1}
renderValue={(value) => roundToDecimals(value, 1)}
onChange={setPullerTargetSpeed}
/>
</Label>
</ControlCard>
</ControlGrid>
</Page>
);
@@ -16,23 +16,55 @@ import {
ThrottledStoreUpdater,
} from "../../../client/socketioStore";
import { MachineIdentificationUnique } from "@/machines/types";
import {
createTimeSeries,
TimeSeries,
TimeSeriesValue,
} from "@/lib/timeseries";
// ========== Event Schema Definitions ==========
/**
* Machine operation mode enum
*/
export const modeSchema = z.enum([
"Standby",
"FillingBuffer",
"EmptyingBuffer",
]);
export const modeSchema = z.enum(["Standby", "Hold", "Filling", "Emptying"]);
export type Mode = z.infer<typeof modeSchema>;
/**
* Consolidated live values event schema (30FPS data)
*/
export const liveValuesEventDataSchema = z.object({});
export const liveValuesEventDataSchema = z.object({
lift_position: z.number().nullable(),
puller_speed: z.number(),
});
/**
* Puller regulation type enum
*/
export const pullerRegulationSchema = z.enum(["Speed", "Diameter"]);
export type PullerRegulation = z.infer<typeof pullerRegulationSchema>;
/**
* Puller state event schmema
*/
export const pullerStateSchema = z.object({
regulation: pullerRegulationSchema,
target_speed: z.number(),
target_diameter: z.number(),
forward: z.boolean(),
});
/**
* Lift state schema
*/
export const liftStateSchema = z.object({
is_going_up: z.boolean(),
is_going_down: z.boolean(),
is_homed: z.boolean(),
is_going_home: z.boolean(),
is_buffering: z.boolean(),
step_size: z.number(),
});
/**
* Mode state event schema
@@ -41,6 +73,10 @@ export const modeStateSchema = z.object({
mode: modeSchema,
});
export const currentInputSpeedSchema = z.object({
current_input_speed: z.number(),
});
/**
* Connected machine state scheme
*/
@@ -65,7 +101,10 @@ export const connectedMachineStateSchema = z.object({
export const stateEventDataSchema = z.object({
mode_state: modeStateSchema,
lift_state: liftStateSchema,
puller_state: pullerStateSchema,
connected_machine_state: connectedMachineStateSchema,
current_input_speed_state: currentInputSpeedSchema,
});
// ========== Event Schemas with Wrappers ==========
@@ -80,8 +119,24 @@ export type StateEvent = z.infer<typeof stateEventSchema>;
export type Buffer1NamespaceStore = {
// State events (latest only)
state: StateEvent | null;
defaultState: StateEvent | null;
// Time series data for live values
liftPosition: TimeSeries;
pullerSpeed: TimeSeries;
};
// Constants for time durations
const TWENTY_MILLISECOND = 20;
const ONE_SECOND = 1000;
const FIVE_SECOND = 5 * ONE_SECOND;
const ONE_HOUR = 60 * 60 * ONE_SECOND;
const { initialTimeSeries: pullerSpeed, insert: addPullerSpeed } =
createTimeSeries(TWENTY_MILLISECOND, ONE_SECOND, FIVE_SECOND, ONE_HOUR);
const { initialTimeSeries: liftPosition, insert: addLiftPosition } =
createTimeSeries(TWENTY_MILLISECOND, ONE_SECOND, FIVE_SECOND, ONE_HOUR);
/**
* Creates a message handler for Buffer1 namespace events with validation and appropriate caching strategies
* @param store The store to update when messages are received
@@ -110,12 +165,41 @@ export function buffer1MessageHandler(
...state,
state: stateEvent,
}));
console.log(stateEvent);
} else if (eventName === "LiveValuesEvent") {
// Parse and validate the live values event
const liveValuesEvent = liveValuesEventSchema.parse(event);
const timestamp = event.ts;
updateStore((state) => ({
...state,
}));
// Extract values and add to time series
const { lift_position, puller_speed } = liveValuesEvent.data;
const timestamp = liveValuesEvent.ts;
updateStore((state) => {
const newState = { ...state };
// Add lift position if not null
if (lift_position !== null) {
const timeseriesValue: TimeSeriesValue = {
value: lift_position,
timestamp,
};
newState.liftPosition = addLiftPosition(
state.liftPosition,
timeseriesValue,
);
}
// Add puller speed
const pullerSpeedValue: TimeSeriesValue = {
value: puller_speed,
timestamp,
};
newState.pullerSpeed = addPullerSpeed(
state.pullerSpeed,
pullerSpeedValue,
);
return newState;
});
} else {
handleUnhandledEventError(eventName);
}
@@ -134,7 +218,13 @@ export const createBuffer1NamespaceStore =
(): StoreApi<Buffer1NamespaceStore> =>
create<Buffer1NamespaceStore>(() => {
return {
// State event from server
state: null,
defaultState: null,
// Time series data for live values
liftPosition,
pullerSpeed,
};
});
@@ -8,7 +8,13 @@ import {