152 lines
4.7 KiB
TypeScript
152 lines
4.7 KiB
TypeScript
import { Page } from "@/components/Page";
|
|
import { ControlGrid } from "@/control/ControlGrid";
|
|
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,
|
|
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" | "Hold" | "Filling" | "Emptying">
|
|
value={state?.mode_state.mode}
|
|
orientation="vertical"
|
|
className="grid h-full grid-cols-2 gap-2"
|
|
options={{
|
|
Standby: {
|
|
children: "Standby",
|
|
icon: "lu:CirclePause",
|
|
isActiveClassName: "bg-green-600",
|
|
className: "h-full",
|
|
},
|
|
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",
|
|
},
|
|
Emptying: {
|
|
children: "EmptyingBuffer",
|
|
icon: "lu:ArrowBigLeftDash",
|
|
isActiveClassName: "bg-green-600",
|
|
className: "h-full",
|
|
},
|
|
}}
|
|
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>
|
|
);
|
|
}
|