Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eislam/sy 723 ni pilot support #641

Closed
wants to merge 51 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
0ba8d46
Merge branch 'eislam/sy-714-fix-driver-exit' of https://github.com/sy…
Lham42 Jun 5, 2024
0961a61
[driver] - reformat some things and add ni factory in main
Lham42 Jun 5, 2024
0d2df26
[driver] - refactor analog scaling code and build main
Lham42 Jun 5, 2024
30a7ba9
[driver] - fix some parsing typos
Lham42 Jun 5, 2024
e6fe6c3
[driver] - ni: linear scaling functionality verified
Lham42 Jun 6, 2024
f3fa073
[driver] - ni: refactor error logging to code dedup
Lham42 Jun 6, 2024
2361e2d
[driver] -ni : move scale init to scale struct responsibility
Lham42 Jun 6, 2024
d819d71
[driver] - ni map scale functionality verified
Lham42 Jun 6, 2024
aa86916
[driver] add in calls for the other scale creates
Lham42 Jun 6, 2024
5207c08
[driver] added parser checks to all ni scale consturctors
Lham42 Jun 6, 2024
c9a3d4f
[driver] add somoe comments to analog read
Lham42 Jun 6, 2024
7529c48
[driver] refactored analog_read tests and build and pass
Lham42 Jun 6, 2024
cef9756
[driver] updated test helper functions for analog read test
Lham42 Jun 6, 2024
a8eb210
[driver] - update ni digital_read tests
Lham42 Jun 7, 2024
dd9ddea
update scaling tests
Lham42 Jun 8, 2024
b94e782
[driver] all scaling types verified
Lham42 Jun 8, 2024
322b01d
checkpoint
Lham42 Jun 11, 2024
27f30bb
merge conflicts
Lham42 Jun 11, 2024
2fe49d4
Merge branch 'eislam/sy-723-ni-pilot-support' of github.com:synnaxlab…
Lham42 Jun 12, 2024
7ffcc5c
Merge branch 'synnax-21-rc' of github.com:synnaxlabs/synnax into eisl…
Lham42 Jun 12, 2024
2ff5fff
specify c++ versions for heartbeat and driver
Lham42 Jun 12, 2024
befd8b5
specify c++ versions for heartbeat and driver
Lham42 Jun 12, 2024
9b485f7
fix warnings and absolute typo
Lham42 Jun 12, 2024
c322ad5
refactor source and sink based on new driver elements
Lham42 Jun 12, 2024
fdb527d
[client/py] - implemented additional elements in NI console workflow
emilbon99 Jun 13, 2024
6512454
[console] - improvements to Form component
emilbon99 Jun 13, 2024
aec1c46
Merge branch 'eislam/sy-723-ni-pilot-support' of https://github.com/s…
Lham42 Jun 13, 2024
cb607ea
didnt save a file'
Lham42 Jun 13, 2024
968008a
Merge branch 'ebonilla/sy-755-outstanding-console-changes-for-ni-work…
Lham42 Jun 13, 2024
1ab201e
checkpoint
Lham42 Jun 13, 2024
fd93070
update analog read with valid read
Lham42 Jun 13, 2024
e00d111
update read workflow for better handling of spurious shutdowns
Lham42 Jun 13, 2024
46a93b0
add headers for scale and channels
Lham42 Jun 13, 2024
835a5ec
Merge branch 'eislam/sy-723-ni-pilot-support' of github.com:synnaxlab…
Lham42 Jun 13, 2024
0630a6f
checkpoint
Lham42 Jun 13, 2024
490a9a1
build with refactored channel code
Lham42 Jun 14, 2024
c0e18f5
checkpoint
Lham42 Jun 14, 2024
32f4d39
refactored analog channel builds and runs analog read task
Lham42 Jun 14, 2024
ddbb64c
Merge branch 'rc' into eislam/sy-723-ni-pilot-support
Lham42 Jun 14, 2024
c99a56e
[driver] reformat ni code
Lham42 Jun 14, 2024
37cef4b
Merge branch 'eislam/sy-723-ni-pilot-support' of github.com:synnaxlab…
Lham42 Jun 14, 2024
4e664dd
added windows specific main
Lham42 Jun 14, 2024
386e2dd
delete main
Lham42 Jun 15, 2024
2837df3
Merge branch 'rc' of github.com:synnaxlabs/synnax into eislam/sy-723-…
Lham42 Jun 15, 2024
4681d98
checkpoint
Lham42 Jun 15, 2024
7b45aa7
merge issues
Lham42 Jun 15, 2024
32caca5
build after backmerging rc
Lham42 Jun 15, 2024
2872852
checkpoint
Lham42 Jun 15, 2024
7c88948
added more comments to ni interface
Lham42 Jun 16, 2024
b18fab1
Merge branch 'eislam/sy-723-ni-pilot-support' of github.com:synnaxlab…
Lham42 Jun 17, 2024
9c9487c
added asserts
Lham42 Jun 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion client/cpp/telem/control.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
namespace synnax {
typedef std::uint8_t Authority;

const Authority AUTH_ABSOLUTE = 255;
// Do not fix this typo as it conflicts with an existing symbol, causing build to break.
const Authority ABSOLUTTE = 255;

struct ControlSubject {
std::string name;
Expand Down
9 changes: 9 additions & 0 deletions client/cpp/telem/series.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,15 @@ class Series {
pb->set_data(data.get(), byteSize());
}

[[nodiscard]] std::vector<uint8_t> uint8() const {
if (data_type != synnax::UINT8) {
throw std::runtime_error("invalid data type");
}
std::vector<uint8_t> v(size);
memcpy(v.data(), data.get(), size);
return v;
}

/// @brief returns the data as a vector of strings. This method can only be used
/// if the data type is STRING or JSON.
[[nodiscard]] std::vector<std::string> strings() const {
Expand Down
18 changes: 3 additions & 15 deletions client/py/examples/dev/rack_heartbeat.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,18 +57,6 @@
# }]
# })
for frame in s:
print(frame)

with client.new_streamer(["the.answer"]) as s:
# with client.new_writer(sy.TimeStamp.now(), ["sy_task_cmd"]) as w:
# w.write({
# "sy_task_cmd": [{
# "task": 281479271677954,
# "type": "scan",
# "args": {
# "endpoint": "opc.tcp://0.0.0.0:4840/freeopcua/server/",
# }
# }]
# })
for frame in s:
print(frame)
key = frame["sy_task_set"][0]
task = client.hardware.retrieve_task(keys=[key])
print(task)
31 changes: 30 additions & 1 deletion client/ts/src/channel/client.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 { type UnaryClient } from "@synnaxlabs/freighter";
import { sendRequired, type UnaryClient } from "@synnaxlabs/freighter";
import { type AsyncTermSearcher } from "@synnaxlabs/x/search";
import {
type CrudeDensity,
Expand All @@ -19,6 +19,7 @@
type TypedArray,
} from "@synnaxlabs/x/telem";
import { toArray } from "@synnaxlabs/x/toArray";
import { z } from "zod";

import {
type Key,
Expand All @@ -39,6 +40,8 @@
import { type Writer } from "@/channel/writer";
import { ValidationError } from "@/errors";
import { type framer } from "@/framer";
import { ontology } from "@/ontology";
import { group } from "@/ontology/group";
import { checkForMultipleOrNoResults } from "@/util/retrieve";

interface CreateOptions {
Expand Down Expand Up @@ -150,6 +153,13 @@
});
}

/***
* @returns the ontology ID of the channel
*/
get ontologyID(): ontology.ID {
return new ontology.ID({ type: "channel", key: this.key.toString() });
}

Check warning on line 161 in client/ts/src/channel/client.ts

View check run for this annotation

Codecov / codecov/patch

client/ts/src/channel/client.ts#L160-L161

Added lines #L160 - L161 were not covered by tests

/**
* Reads telemetry from the channel between the two timestamps.
*
Expand All @@ -172,6 +182,14 @@
}
}

const RETRIEVE_GROUP_ENDPOINT = "/channel/retrieve-group";

const retrieveGroupReqZ = z.object({});

const retrieveGroupResZ = z.object({
group: group.groupZ,
});

/**
* The core client class for executing channel operations against a Synnax
* cluster. This class should not be instantiated directly, and instead should be used
Expand Down Expand Up @@ -382,4 +400,15 @@
const { frameClient } = this;
return payloads.map((p) => new Channel({ ...p, frameClient }));
}

async retrieveGroup(): Promise<group.Group> {
const res = await sendRequired(
this.client,
RETRIEVE_GROUP_ENDPOINT,
{},
retrieveGroupReqZ,
retrieveGroupResZ,
);
return new group.Group(res.group.name, res.group.key);
}
}
6 changes: 6 additions & 0 deletions client/ts/src/framer/client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,10 @@ describe("Client", () => {
await client.write(start, data.key, 1);
});
});
describe("retrieveGroup", () => {
it("should correctly retrieve the main channel group", async () => {
const group = await client.channels.retrieveGroup();
expect(group.name).toEqual("Channels");
});
});
});
1 change: 1 addition & 0 deletions client/ts/src/ontology/group/external.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@

export * from "@/ontology/group/client";
export * from "@/ontology/group/group";
export * from "@/ontology/group/payload";
4 changes: 2 additions & 2 deletions client/ts/src/ontology/group/payload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ export type Keys = Key[];
export type Names = Name[];
export type Params = Key | Name | Keys | Names;

export const payloadZ = z.object({
export const groupZ = z.object({
key: keyZ,
name: z.string(),
});

export type Payload = z.infer<typeof payloadZ>;
export type Payload = z.infer<typeof groupZ>;

export type ParamAnalysisResult =
| {
Expand Down
4 changes: 2 additions & 2 deletions client/ts/src/ontology/group/writer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
import { type UnaryClient } from "@synnaxlabs/freighter";
import { z } from "zod";

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

const resZ = z.object({
group: payloadZ,
group: groupZ,
});

const createReqZ = z.object({
Expand Down
7 changes: 4 additions & 3 deletions console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@
"@tauri-apps/plugin-dialog": "2.0.0-beta.3",
"@tauri-apps/plugin-fs": "2.0.0-beta.3",
"@tauri-apps/plugin-process": "2.0.0-beta.3",
"@tauri-apps/plugin-updater": "2.0.0-beta.3",
"@tauri-apps/plugin-store": "2.0.0-beta.5",
"@tauri-apps/plugin-updater": "2.0.0-beta.3",
"async-mutex": "^0.5.0",
"nanoid": "^3.0.0",
"proxy-memoize": "1.2.0",
"react": "^18.2.0",
Expand All @@ -50,8 +51,8 @@
"@vitejs/plugin-react": "^4.3.0",
"eslint-config-synnaxlabs": "workspace:*",
"stylelint-config-synnaxlabs": "workspace:*",
"typescript": "^5.4.5",
"vite": "5.2.11",
"vite-tsconfig-paths": "4.3.2",
"typescript": "^5.4.5"
"vite-tsconfig-paths": "4.3.2"
}
}
61 changes: 50 additions & 11 deletions console/src/fs/LoadFileContents.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,22 @@
// included in the file licenses/APL.txt.

import { Icon } from "@synnaxlabs/media";
import { Align, Button, Input, Text } from "@synnaxlabs/pluto";
import { Align, Button, Input, state } from "@synnaxlabs/pluto";
import { binary } from "@synnaxlabs/x";
import { open } from "@tauri-apps/plugin-dialog";
import { ReactElement } from "react";
import { readFile } from "@tauri-apps/plugin-fs";
import { ReactElement, useEffect, useState } from "react";
import { z } from "zod";

export interface LoadFileContentsProps
export interface InputFilePathProps
extends Input.Control<string>,
Omit<Align.PackProps, "value" | "onChange"> {}

export const LoadFileContents = ({
export const InputFilePath = ({
value,
onChange,
...props
}: LoadFileContentsProps): ReactElement => {
}: InputFilePathProps): ReactElement => {
const path = value;
const handleClick = () => {
void (async () => {
Expand All @@ -29,26 +32,62 @@ export const LoadFileContents = ({
onChange(path.path);
})();
};

return (
<Align.Pack direction="x" {...props}>
<Text.WithIcon
<Button.Button
level="p"
style={{ padding: "0 2rem" }}
style={{ padding: "0 1.25rem", background: "var(--pluto-gray-l1)" }}
variant="outlined"
shade={path == null ? 7 : 9}
grow
onClick={handleClick}
startIcon={
path == null ? undefined : (
<Icon.Attachment style={{ color: "var(--pluto-gray-l7)" }} />
<Icon.Attachment style={{ color: "var(--pluto-gray-l6)" }} />
)
}
size="medium"
>
{path == null ? "No file selected" : path}
</Text.WithIcon>
<Button.Button variant="outlined" onClick={handleClick}>
</Button.Button>
<Button.Button
variant="outlined"
onClick={handleClick}
style={{ background: "var(--pluto-gray-l1)" }}
>
Select file
</Button.Button>
</Align.Pack>
);
};

export interface InputFileContentsProps<P extends z.ZodTypeAny = z.ZodString>
extends Omit<InputFilePathProps, "value" | "onChange"> {
onChange: (value: z.output<P>, path: string) => void;
initialPath?: string;
schema?: P;
decoder?: binary.EncoderDecoder;
}

export const InputFileContents = <P extends z.ZodTypeAny = z.ZodString>({
onChange,
decoder = binary.TEXT_ECD,
initialPath,
schema,
...props
}: InputFileContentsProps<P>): ReactElement => {
const [path, setPath] = useState<string>("");
useEffect(() => {
if (initialPath == null || initialPath === path) return;
handleChange(initialPath);
}, [initialPath]);
const handleChange = (path: string) => {
void (async () => {
const contents = await readFile(path);
if (contents == null) return;
onChange(decoder.decode<P>(contents, schema), path);
setPath(path);
})();
};
return <InputFilePath value={path} onChange={handleChange} {...props} />;
};
Loading
Loading