Skip to content

Commit

Permalink
chore: refactor dock tile definitions plus other changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jugglingcats committed Jun 27, 2024
1 parent 7c33cc2 commit 04bf995
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 51 deletions.
51 changes: 0 additions & 51 deletions src/modes/InnoboticsJogModeTileHelper.ts

This file was deleted.

42 changes: 42 additions & 0 deletions src/modes/InnoboticsJogTileWrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright (c) 2024. Glowbuzzer. All rights reserved
*/

import * as React from "react"
import { useDeadman, useManualKeyswitch } from "@glowbuzzer/awlib"
import { useConnection } from "@glowbuzzer/store"
import { DockTileDisabled, useGlowbuzzerMode, useOperationEnabled } from "@glowbuzzer/controls"

function get_message(op: boolean, keyswitch: boolean, mode: string, deadman: boolean) {
if (!op) {
return "Operation Not Enabled"
}
if (!keyswitch) {
return "Manual Keyswitch Not Engaged"
}
if (mode !== "jog") {
return "Jog Mode Not Selected"
}
if (!deadman) {
return "Deadman Not Engaged"
}
}

export const InnoboticsJogTileWrapper = ({ children }) => {
const [{ actValue: keyswitch }] = useManualKeyswitch()
const [{ actValue: deadman }] = useDeadman()
const { connected } = useConnection()
const op = useOperationEnabled()
const { mode } = useGlowbuzzerMode()

if (!connected) {
return <DockTileDisabled children={children} />
}

const message = get_message(op, keyswitch, mode, deadman)
if (message) {
return <DockTileDisabled children={children} content={message} />
}

return <>{children}</>
}

0 comments on commit 04bf995

Please sign in to comment.