From 9c684790aaa25b12c8dd5c1cbe00b74ddf05a36a Mon Sep 17 00:00:00 2001
From: Sasha Aleshchenko <45843308+TheBigSasha@users.noreply.github.com>
Date: Mon, 2 Oct 2023 09:48:26 -0700
Subject: [PATCH 1/2] Rudimentary support for mecademic arms.
---
captain/routes/devices.py | 1 +
captain/services/hardware.py | 7 ++++++-
captain/types/devices.py | 6 ++++++
src/feature/device_panel/components/HardwareInfo.tsx | 10 ++++++++++
src/hooks/useHardwareDevices.ts | 6 ++++++
5 files changed, 29 insertions(+), 1 deletion(-)
diff --git a/captain/routes/devices.py b/captain/routes/devices.py
index ac2513536..e078374a4 100644
--- a/captain/routes/devices.py
+++ b/captain/routes/devices.py
@@ -13,4 +13,5 @@ async def get_devices():
cameras=device_finder.get_cameras(),
serialDevices=device_finder.get_serial_devices(),
visaDevices=device_finder.get_visa_devices(),
+ mecademicDevices=device_finder.get_mecademic_devices(),
)
diff --git a/captain/services/hardware.py b/captain/services/hardware.py
index 9632f7e6b..6d88934ac 100644
--- a/captain/services/hardware.py
+++ b/captain/services/hardware.py
@@ -4,7 +4,7 @@
import subprocess
from sys import platform
-from captain.types.devices import CameraDevice, SerialDevice, VISADevice
+from captain.types.devices import CameraDevice, SerialDevice, VISADevice, MecademicDevice
__all__ = ["get_device_finder"]
@@ -60,6 +60,11 @@ def get_visa_devices(self) -> list[VISADevice]:
return devices
+ def get_mecademic_devices(self) -> list[MecademicDevice]:
+ """Returns a list of Mecademic devices connected to the system."""
+ devices = [MecademicDevice(name="Flojoy's Mecademic Meca500", ip="192.168.0.100")]
+ return devices
+
class LinuxDeviceFinder(DefaultDeviceFinder):
def get_cameras(self) -> list[CameraDevice]:
diff --git a/captain/types/devices.py b/captain/types/devices.py
index 39aef3643..fe5857b98 100644
--- a/captain/types/devices.py
+++ b/captain/types/devices.py
@@ -21,7 +21,13 @@ class VISADevice(BaseModel):
description: str
+class MecademicDevice(BaseModel):
+ name: str
+ ip: str
+
+
class DeviceInfo(BaseModel):
cameras: list[CameraDevice]
serialDevices: list[SerialDevice]
visaDevices: list[VISADevice]
+ mecademicDevices: list[MecademicDevice]
diff --git a/src/feature/device_panel/components/HardwareInfo.tsx b/src/feature/device_panel/components/HardwareInfo.tsx
index 583c7f5e1..f99e4651c 100644
--- a/src/feature/device_panel/components/HardwareInfo.tsx
+++ b/src/feature/device_panel/components/HardwareInfo.tsx
@@ -53,6 +53,14 @@ export const HardwareInfo = () => {
}))
: undefined;
+ const mecademicDevices: DeviceCardProps[] | undefined =
+ devices.mecademicDevices.length > 0
+ ? devices.mecademicDevices.map((d) => ({
+ name: d.name,
+ port: d.ip,
+ }))
+ : undefined;
+
return (
@@ -62,6 +70,8 @@ export const HardwareInfo = () => {
+
+
);
};
diff --git a/src/hooks/useHardwareDevices.ts b/src/hooks/useHardwareDevices.ts
index 7876a18d9..c246b059c 100644
--- a/src/hooks/useHardwareDevices.ts
+++ b/src/hooks/useHardwareDevices.ts
@@ -25,12 +25,18 @@ const VISADevice = z.object({
description: z.string(),
});
+const MecademicDevice = z.object({
+ ip: z.string(),
+ name: z.string(),
+});
+
type VISADevice = z.infer;
const DeviceInfo = z.object({
cameras: z.array(CameraDevice),
serialDevices: z.array(SerialDevice),
visaDevices: z.array(VISADevice),
+ mecademicDevices: z.array(MecademicDevice),
});
type DeviceInfo = z.infer;
From fc421a6b8e0fd0a8ebe659e5b276f224f5f36060 Mon Sep 17 00:00:00 2001
From: Sasha Aleshchenko <45843308+TheBigSasha@users.noreply.github.com>
Date: Mon, 2 Oct 2023 10:11:07 -0700
Subject: [PATCH 2/2] Rudimentary support for mecademic arms.
---
captain/utils/manifest/build_manifest.py | 1 +
src/feature/common/types/ParamValueType.ts | 1 +
.../node-edit-menu/MecademicDeviceSelect.tsx | 18 ++++++++++++++++++
.../components/node-edit-menu/ParamField.tsx | 4 ++++
4 files changed, 24 insertions(+)
create mode 100644 src/feature/flow_chart_panel/components/node-edit-menu/MecademicDeviceSelect.tsx
diff --git a/captain/utils/manifest/build_manifest.py b/captain/utils/manifest/build_manifest.py
index e4b8846be..08382ed7c 100644
--- a/captain/utils/manifest/build_manifest.py
+++ b/captain/utils/manifest/build_manifest.py
@@ -52,6 +52,7 @@
SerialDevice,
VisaDevice,
CameraConnection,
+ MecademicConnection,
SerialConnection,
VisaConnection,
]
diff --git a/src/feature/common/types/ParamValueType.ts b/src/feature/common/types/ParamValueType.ts
index 6c192637e..4f6e1b8a2 100644
--- a/src/feature/common/types/ParamValueType.ts
+++ b/src/feature/common/types/ParamValueType.ts
@@ -15,4 +15,5 @@ export type ParamValueType =
| "CameraConnection"
| "SerialConnection"
| "VisaConnection"
+ | "MecademicConnection"
| "unknown";
diff --git a/src/feature/flow_chart_panel/components/node-edit-menu/MecademicDeviceSelect.tsx b/src/feature/flow_chart_panel/components/node-edit-menu/MecademicDeviceSelect.tsx
new file mode 100644
index 000000000..dd12f0763
--- /dev/null
+++ b/src/feature/flow_chart_panel/components/node-edit-menu/MecademicDeviceSelect.tsx
@@ -0,0 +1,18 @@
+import { useHardwareDevices } from "@src/hooks/useHardwareDevices";
+import { DeviceSelect, SelectProps } from "./DeviceSelect";
+
+export const MecademicDeviceSelect = (props: SelectProps) => {
+ const hardware = useHardwareDevices();
+ const mecas = hardware?.mecademicDevices;
+
+ return (
+ meca.ip.toString()}
+ valueSelector={(meca) => meca.ip.toString()}
+ nameSelector={(meca) => meca.name}
+ />
+ );
+};
diff --git a/src/feature/flow_chart_panel/components/node-edit-menu/ParamField.tsx b/src/feature/flow_chart_panel/components/node-edit-menu/ParamField.tsx
index a1cff9916..69f000db3 100644
--- a/src/feature/flow_chart_panel/components/node-edit-menu/ParamField.tsx
+++ b/src/feature/flow_chart_panel/components/node-edit-menu/ParamField.tsx
@@ -15,6 +15,8 @@ import { useHasUnsavedChanges } from "@src/hooks/useHasUnsavedChanges";
import { CameraSelect } from "./CameraSelect";
import { SerialDeviceSelect } from "./SerialDeviceSelect";
import { VisaDeviceSelect } from "./VisaDeviceSelect";
+import React from "react";
+import { MecademicDeviceSelect } from "@feature/flow_chart_panel/components/node-edit-menu/MecademicDeviceSelect";
type ParamFieldProps = {
nodeId: string;
@@ -129,6 +131,8 @@ const ParamField = ({
case "VisaDevice":
case "VisaConnection":
return ;
+ case "MecademicConnection":
+ return ;
case "str":
case "list[int]":
case "list[float]":