From 79e42aae9f41e90b909c29e6e19d28066cb72093 Mon Sep 17 00:00:00 2001 From: gobbo_a Date: Tue, 20 Feb 2024 10:45:50 +0100 Subject: [PATCH] StreamPanel resolve channel names do display child panels. --- src/main/java/ch/psi/pshell/bs/Stream.java | 20 +++++++++++++++++++ .../java/ch/psi/pshell/swing/StreamPanel.java | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/main/java/ch/psi/pshell/bs/Stream.java b/src/main/java/ch/psi/pshell/bs/Stream.java index 79408503..9d26f9de 100644 --- a/src/main/java/ch/psi/pshell/bs/Stream.java +++ b/src/main/java/ch/psi/pshell/bs/Stream.java @@ -936,6 +936,26 @@ public static List readChannels(List names, int modulo, int offset, int } } + public Device getChildFromChannelName(String channel) { + if (channel!=null){ + for (Device dev: getChildren()){ + if (dev instanceof StreamChannel){ + if (channel.equals(((StreamChannel)dev).getChannelName())){ + return dev; + } + } + } + for (Device dev: getChildren()){ + if (dev instanceof StreamChannel){ + if (channel.equals(((StreamChannel)dev).getId())){ + return dev; + } + } + } + } + return null; + } + @Override protected void doClose() throws IOException { stop(); diff --git a/src/main/java/ch/psi/pshell/swing/StreamPanel.java b/src/main/java/ch/psi/pshell/swing/StreamPanel.java index ea903d51..fc4f9d11 100644 --- a/src/main/java/ch/psi/pshell/swing/StreamPanel.java +++ b/src/main/java/ch/psi/pshell/swing/StreamPanel.java @@ -156,7 +156,7 @@ void plotChannel() { String channel = getCurrentChannel(); Stream device = getDevice(); if ((device != null) && (channel != null)) { - Device child = device.getChild(channel); + Device child = device.getChildFromChannelName(channel); showDevicePanel(child); } }