Skip to content

Commit

Permalink
Merge pull request #726 from synnaxlabs/sy-869-console-improved-opc-u…
Browse files Browse the repository at this point in the history
…a-config-workflow

Sy 869 console improved opc ua config workflow
  • Loading branch information
pjdotson authored Jul 17, 2024
2 parents 7268d4f + a6d76ec commit c23330d
Show file tree
Hide file tree
Showing 79 changed files with 1,398 additions and 1,751 deletions.
1 change: 0 additions & 1 deletion client/ts/src/errors.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { BaseTypedError, TypedError } from "@synnaxlabs/freighter";
import { MatchableErrorType } from "@synnaxlabs/freighter/src/errors";
import { describe, expect, test } from "vitest";

Expand Down
2 changes: 1 addition & 1 deletion client/ts/src/ontology/group/writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import { type UnaryClient } from "@synnaxlabs/freighter";
import { z } from "zod";

import { type Payload, groupZ } from "@/ontology/group/payload";
import { groupZ,type Payload } from "@/ontology/group/payload";
import { type ID, idZ } from "@/ontology/payload";

const resZ = z.object({
Expand Down
2 changes: 1 addition & 1 deletion client/ts/src/ontology/ontology.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// License, use of this software will be governed by the Apache License, Version 2.0,
// included in the file licenses/APL.txt.

import { describe, expect, it,test } from "vitest";
import { describe, expect, it, test } from "vitest";

import { ontology } from "@/ontology";
import { newClient } from "@/setupspecs";
Expand Down
2 changes: 1 addition & 1 deletion console/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@synnaxlabs/console",
"private": true,
"version": "0.25.0",
"version": "0.25.1",
"type": "module",
"scripts": {
"dev": "tauri dev",
Expand Down
1 change: 0 additions & 1 deletion console/src/docs/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

import { createSlice, type PayloadAction } from "@reduxjs/toolkit";
import { migrate } from "@synnaxlabs/x";
import { z } from "zod";

/**
* The name of the docs slice in a larger store.
Expand Down
2 changes: 1 addition & 1 deletion console/src/fs/LoadFileContents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// included in the file licenses/APL.txt.

import { Icon } from "@synnaxlabs/media";
import { Align, Button, Input, state } from "@synnaxlabs/pluto";
import { Align, Button, Input } from "@synnaxlabs/pluto";
import { binary } from "@synnaxlabs/x";
import { open } from "@tauri-apps/plugin-dialog";
import { readFile } from "@tauri-apps/plugin-fs";
Expand Down
11 changes: 7 additions & 4 deletions console/src/hardware/device/ontology.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import { nanoid } from "nanoid";
import { ReactElement } from "react";

import { Menu } from "@/components/menu";
import { Confirm } from "@/confirm";
import { Group } from "@/group";
import { NI } from "@/hardware/ni";
import { OPC } from "@/hardware/opc";
Expand All @@ -39,6 +38,7 @@ const CONTEXT_MENUS: Record<
(props: Ontology.TreeContextMenuProps) => ReactElement | null
> = {
[NI.MAKE]: NI.Device.ContextMenuItems,
[OPC.MAKE]: OPC.Device.ContextMenuItems,
};

export const handleSelect: Ontology.HandleSelect = () => {};
Expand Down Expand Up @@ -94,6 +94,7 @@ const TreeContextMenu: Ontology.TreeContextMenu = (props) => {
} = props;
if (nodes.length === 0) return null;
const singleResource = nodes.length === 1;
const first = resources[0];
const del = useDelete();
const handleLink = Link.useCopyToClipboard();
const handleSelect = {
Expand All @@ -119,9 +120,11 @@ const TreeContextMenu: Ontology.TreeContextMenu = (props) => {
<>
<Menu.RenameItem />
<PMenu.Divider />
<PMenu.Item itemKey="configure" startIcon={<Icon.Hardware />}>
Configure
</PMenu.Item>
{first.data?.configured !== true && (
<PMenu.Item itemKey="configure" startIcon={<Icon.Hardware />}>
Configure
</PMenu.Item>
)}
</>
)}
<PMenu.Divider />
Expand Down
33 changes: 20 additions & 13 deletions console/src/hardware/ni/device/ontology.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,46 +8,53 @@
// included in the file licenses/APL.txt.

import { Icon } from "@synnaxlabs/media";
import { Menu } from "@synnaxlabs/pluto";
import { Icon as PIcon, Menu } from "@synnaxlabs/pluto";

import { configureAnalogReadLayout } from "@/hardware/ni/task/AnalogRead";
import { configureDigitalReadLayout } from "@/hardware/ni/task/DigitalRead";
import { configureDigitalWriteLayout } from "@/hardware/ni/task/DigitalWrite";
import { Layout } from "@/layout";
import { Ontology } from "@/ontology";

export const ContextMenuItems = (props: Ontology.TreeContextMenuProps) => {
export const ContextMenuItems = () => {
const place = Layout.usePlacer();

const handleCreateDigitalReadTask = () => place(configureDigitalReadLayout(true));

const handleCreateAnalogReadTask = () => place(configureAnalogReadLayout(true));

const handleCreateDigitalWriteTask = () => place(configureDigitalWriteLayout(true));

return (
<>
<Menu.Divider />
<Menu.Item
startIcon={<Icon.Task />}
startIcon={
<PIcon.Create>
<Icon.Task />
</PIcon.Create>
}
itemKey="ni.analogReadTask"
onClick={handleCreateAnalogReadTask}
>
New Analog Read Task
Create Analog Read Task
</Menu.Item>
<Menu.Item
startIcon={<Icon.Task />}
startIcon={
<PIcon.Create>
<Icon.Task />
</PIcon.Create>
}
itemKey="ni.digitalReadTask"
onClick={handleCreateDigitalReadTask}
>
New Digital Read Task
Create Digital Read Task
</Menu.Item>
<Menu.Item
startIcon={<Icon.Task />}
startIcon={
<PIcon.Create>
<Icon.Task />
</PIcon.Create>
}
itemKey="ni.digitalWriteTask"
onClick={handleCreateDigitalWriteTask}
>
New Digital Write Task
Create Digital Write Task
</Menu.Item>
</>
);
Expand Down
1 change: 0 additions & 1 deletion console/src/hardware/ni/device/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// License, use of this software will be governed by the Apache License, Version 2.0,
// included in the file licenses/APL.txt.

import { task } from "@synnaxlabs/client";
import { z } from "zod";

// VENDOR
Expand Down
19 changes: 16 additions & 3 deletions console/src/hardware/ni/pallette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
// included in the file licenses/APL.txt.

import { Icon } from "@synnaxlabs/media";
import { Icon as PIcon } from "@synnaxlabs/pluto";

import { configureAnalogReadLayout } from "@/hardware/ni/task/AnalogRead";
import { configureDigitalReadLayout } from "@/hardware/ni/task/DigitalRead";
Expand All @@ -17,21 +18,33 @@ import { Command } from "@/palette/Palette";
export const createAnalogReadTaskCommand: Command = {
key: "ni-create-analog-read-task",
name: "Create an NI Analog Read Task",
icon: <Icon.Logo.NI />,
icon: (
<PIcon.Create>
<Icon.Logo.NI />
</PIcon.Create>
),
onSelect: ({ placeLayout }) => placeLayout(() => configureAnalogReadLayout(true)),
};

export const createDigitalWriteTaskCommand: Command = {
key: "ni-create-digital-write-task",
name: "Create an NI Digital Write Task",
icon: <Icon.Logo.NI />,
icon: (
<PIcon.Create>
<Icon.Logo.NI />
</PIcon.Create>
),
onSelect: ({ placeLayout }) => placeLayout(configureDigitalWriteLayout(true)),
};

export const createDigitalReadTaskCommand: Command = {
key: "ni-create-digital-read-task",
name: "Create an NI Digital Read Task",
icon: <Icon.Logo.NI />,
icon: (
<PIcon.Create>
<Icon.Logo.NI />
</PIcon.Create>
),
onSelect: ({ placeLayout }) => placeLayout(configureDigitalReadLayout(true)),
};

Expand Down
32 changes: 6 additions & 26 deletions console/src/hardware/ni/task/AnalogRead.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import { NotFoundError, QueryError } from "@synnaxlabs/client";
import { Icon } from "@synnaxlabs/media";
import { Button, Form, Header, Menu, Status, Synnax } from "@synnaxlabs/pluto";
import { Form, Header, Menu, Status, Synnax } from "@synnaxlabs/pluto";
import { Align } from "@synnaxlabs/pluto/align";
import { Input } from "@synnaxlabs/pluto/input";
import { List } from "@synnaxlabs/pluto/list";
Expand Down Expand Up @@ -44,6 +44,7 @@ import {
ChannelListEmptyContent,
ChannelListHeader,
Controls,
EnableDisableButton,
useCreate,
useObserveState,
WrappedTaskLayoutProps,
Expand Down Expand Up @@ -396,31 +397,10 @@ const ChannelListItem = ({
</Text.Text>
</Align.Space>
</Align.Space>
<Align.Space direction="x" size="small">
<Button.Toggle
checkedVariant="outlined"
uncheckedVariant="outlined"
value={childValues.enabled}
size="small"
onClick={(e) => e.stopPropagation()}
onChange={(v) => ctx.set(`${path}.enabled`, v)}
tooltip={
<Text.Text level="small" style={{ maxWidth: 300 }}>
Data acquisition for this channel is{" "}
{childValues.enabled ? "enabled" : "disabled"}. Click to
{childValues.enabled ? " disable" : " enable"} it.
</Text.Text>
}
>
<Status.Text
variant={childValues.enabled ? "success" : "disabled"}
level="small"
align="center"
>
{childValues.enabled ? "Enabled" : "Disabled"}
</Status.Text>
</Button.Toggle>
</Align.Space>
<EnableDisableButton
value={childValues.enabled}
onChange={(v) => ctx.set(`${path}.enabled`, v)}
/>
</List.ItemFrame>
);
};
Expand Down
2 changes: 1 addition & 1 deletion console/src/hardware/ni/task/DigitalRead.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
// License, use of this software will be governed by the Apache License, Version 2.0,
// included in the file licenses/APL.txt.

import { NotFoundError, QueryError } from "@synnaxlabs/client";
import { NotFoundError } from "@synnaxlabs/client";
import { Icon } from "@synnaxlabs/media";
import {
Align,
Expand Down
41 changes: 6 additions & 35 deletions console/src/hardware/ni/task/DigitalWrite.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,9 @@
// License, use of this software will be governed by the Apache License, Version 2.0,
// included in the file licenses/APL.txt.

import { NotFoundError, QueryError } from "@synnaxlabs/client";
import { NotFoundError } from "@synnaxlabs/client";
import { Icon } from "@synnaxlabs/media";
import {
Button,
Channel,
Form,
Header,
List,
Menu,
Status,
Synnax,
} from "@synnaxlabs/pluto";
import { Channel, Form, Header, List, Menu, Status, Synnax } from "@synnaxlabs/pluto";
import { Align } from "@synnaxlabs/pluto/align";
import { Input } from "@synnaxlabs/pluto/input";
import { Text } from "@synnaxlabs/pluto/text";
Expand Down Expand Up @@ -49,6 +40,7 @@ import {
ChannelListEmptyContent,
ChannelListHeader,
Controls,
EnableDisableButton,
useCreate,
useObserveState,
WrappedTaskLayoutProps,
Expand Down Expand Up @@ -480,31 +472,10 @@ const ChannelListItem = ({
</Text.Text>
</Align.Space>
</Align.Space>
<Button.Toggle
checkedVariant="outlined"
uncheckedVariant="outlined"
<EnableDisableButton
value={childValues.enabled}
size="small"
onClick={(e) => e.stopPropagation()}
onChange={(v) => {
ctx.set(`${path}.${props.index}.enabled`, v);
}}
tooltip={
<Text.Text level="small" style={{ maxWidth: 300 }}>
Data acquisition for this channel is{" "}
{childValues.enabled ? "enabled" : "disabled"}. Click to
{childValues.enabled ? " disable" : " enable"} it.
</Text.Text>
}
>
<Status.Text
variant={childValues.enabled ? "success" : "disabled"}
level="small"
align="center"
>
{childValues.enabled ? "Enabled" : "Disabled"}
</Status.Text>
</Button.Toggle>
onChange={(v) => ctx.set(`${path}.${props.index}.enabled`, v)}
/>
</List.ItemFrame>
);
};
Expand Down
4 changes: 0 additions & 4 deletions console/src/hardware/ni/task/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ export type UnitsInOz = z.infer<typeof unitsInOzZ>;
export const unitsFtLbsZ = z.literal("FootPounds");
export type UnitsFtLbs = z.infer<typeof unitsFtLbsZ>;

const resistanceZ = z.number().refine((val) => val > 0, {
message: "Value must be greater than 0",
});

export const unitsZ = z.union([
unitsVoltsZ,
unitsAmpsZ,
Expand Down
Loading

0 comments on commit c23330d

Please sign in to comment.