diff --git a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8View.java b/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8View.java index e3d7240d..56e87f33 100644 --- a/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8View.java +++ b/numass-control/cryotemp/src/main/java/inr/numass/cryotemp/PKT8View.java @@ -76,8 +76,7 @@ public class PKT8View extends DeviceViewConnection implements Initia public void open(@NotNull PKT8Device device) throws Exception { super.open(device); this.logFragment = new LogFragment(); - logFragment.addLogHandler(device.getContext().getLogger()); - logFragment.hookStd();//TODO to be removed later + logFragment.addRootLogHandler(); plotFragment = new PKT8PlotFragment(device); startStopButton.selectedProperty().setValue(getDevice().isMeasuring()); diff --git a/numass-control/msp/src/main/java/inr/numass/control/msp/fx/MspViewController.java b/numass-control/msp/src/main/java/inr/numass/control/msp/fx/MspViewController.java index ea21168e..b47ced1c 100644 --- a/numass-control/msp/src/main/java/inr/numass/control/msp/fx/MspViewController.java +++ b/numass-control/msp/src/main/java/inr/numass/control/msp/fx/MspViewController.java @@ -75,7 +75,7 @@ public class MspViewController extends DeviceViewConnection implement private final TimePlottableGroup plottables = new TimePlottableGroup(); // private Configuration viewConfig; private JFreeChartFrame plot; - private LogFragment logArea; + private LogFragment logFragment; private final ConfigChangeListener viewConfigObserver = new ConfigChangeListener() { @@ -118,8 +118,9 @@ public class MspViewController extends DeviceViewConnection implement */ @Override public void initialize(URL url, ResourceBundle rb) { - logArea = new LogFragment(); - new FragmentWindow(logArea).bindTo(consoleButton); + logFragment = new LogFragment(); + new FragmentWindow(logFragment).bindTo(consoleButton); + logFragment.addRootLogHandler(); fillamentSelector.setItems(FXCollections.observableArrayList(1, 2)); fillamentSelector.setConverter(new StringConverter() { @Override @@ -237,21 +238,21 @@ public class MspViewController extends DeviceViewConnection implement @Override public void acceptMessage(String message) { Platform.runLater(() -> { - logArea.appendLine("RECIEVE: " + message); + logFragment.appendLine("RECIEVE: " + message); }); } @Override public void acceptRequest(String message) { Platform.runLater(() -> { - logArea.appendLine("SEND: " + message); + logFragment.appendLine("SEND: " + message); }); } @Override public void error(String errorMessage, Throwable error) { Platform.runLater(() -> { - logArea.appendLine("ERROR: " + errorMessage); + logFragment.appendLine("ERROR: " + errorMessage); showError(errorMessage); }); diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/fx/ReadVac.java b/numass-control/vac/src/main/java/inr/numass/readvac/fx/ReadVac.java index 42860faf..d82970ff 100644 --- a/numass-control/vac/src/main/java/inr/numass/readvac/fx/ReadVac.java +++ b/numass-control/vac/src/main/java/inr/numass/readvac/fx/ReadVac.java @@ -38,135 +38,6 @@ public class ReadVac extends NumassControlApplication { protected boolean acceptDevice(Meta meta) { return Objects.equals(meta.getString("type", ""), "numass:vac"); } -// private VacCollectorDevice device; -// -// @Override -// public void start(Stage primaryStage) throws Exception { -// Locale.setDefault(Locale.US);// чтобы отделение десятичных знаков было точкой -// ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME); -// rootLogger.setLevel(Level.INFO); -// -// DeviceViewConnection controller = buildView(); -// -// Scene scene = new Scene(controller.getPane()); -// -// primaryStage.setScene(scene); -// primaryStage.show(); -// -// device = setupDevice(controller); -// primaryStage.setTitle("Numass vacuum measurements"); -// } -// -// -// private VacCollectorDevice setupDevice(DeviceConnection controller) { -// Meta config = NumassControlUtils.getConfig(this) -// .orElseGet(() -> NumassControlUtils.readResourceMeta("/config/devices.xml")); -// -// Context ctx = NumassControlUtils.setupContext(config); -// Meta mspConfig = NumassControlUtils.findDeviceMeta(config, this::acceptDevice) -// .orElseThrow(() -> new RuntimeException("Device configuration not found")); -// -// -// try { -// D d = getDeviceFactory().build(ctx, mspConfig); -// d.init(); -// NumassControlUtils.connectStorage(d, config); -// Platform.runLater(() -> { -// d.connect(controller, Roles.VIEW_ROLE, Roles.DEVICE_LISTENER_ROLE); -// }); -// return d; -// } catch (ControlException e) { -// throw new RuntimeException("Failed to build device", e); -// } -// } -// -// @Override -// public void stop() throws Exception { -// super.stop(); -// if (device != null) { -// device.shutdown(); -// device.getContext().close(); -// } -// } -// VacCollectorView controller; -// Logger logger = LoggerFactory.getLogger("ReadVac"); -// -// /** -// * @param args the command line arguments -// */ -// public static void main(String[] args) { -// launch(args); -// } -// -// @Override -// public void start(Stage primaryStage) throws Exception { -// String configFileName = getParameters().getNamed().get("config"); -// if (configFileName == null) { -// configFileName = "devices.xml"; -// } -// File configFile = new File(configFileName); -// Meta config; -// if (configFile.exists()) { -// config = MetaFileReader.read(configFile).build(); -// } else { -// config = Meta.empty(); -// } -// -// Context context = Global.instance(); -// - -// collector.init(); -// -// FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/VacCollector.fxml")); -// loader.load(); -// controller = loader.getController(); -// controller.setDevice(collector); -// controller.setLogger(logger); -// -// controller.setLoaderFactory((VacCollectorDevice device, Storage localStorage) -> { -// try { -// String runName = ClientUtils.getRunName(config); -//// String runName = device.meta().getString("numass.run", ""); -//// if (config.hasMeta("numass.server")) { -//// try { -//// logger.info("Obtaining run information from cetral server..."); -//// NumassClient client = new NumassClient(get); -//// runName = client.getCurrentRun().getString("path", ""); -//// logger.info("Run name is '{}'", runName); -//// } catch (Exception ex) { -//// logger.warn("Failed to download current run information", ex); -//// } -//// } -// -// TableFormatBuilder format = new TableFormatBuilder().setType("timestamp", ValueType.TIME); -// device.getSensors().stream().forEach((s) -> { -// format.setType(s.getName(), ValueType.NUMBER); -// }); -// -// PointLoader pl = LoaderFactory.buildPointLoder(localStorage, "vactms", runName, "timestamp", format.build()); -// return pl; -// -// } catch (StorageException ex) { -// throw new RuntimeException(ex); -// } -// }); -// Scene scene = new Scene(loader.getRoot(), 800, 700); -// -// primaryStage.setTitle("Numass vacuum measurements"); -// primaryStage.setScene(scene); -// primaryStage.show(); -//// controller.startMeasurement(); -// } -// -// @Override -// public void stop() throws Exception { -// if (controller != null) { -// controller.stopMeasurement(); -// controller.getDevice().shutdown(); -// } -// super.stop(); -// } - } diff --git a/numass-control/vac/src/main/java/inr/numass/readvac/fx/VacCollectorView.java b/numass-control/vac/src/main/java/inr/numass/readvac/fx/VacCollectorView.java index 21c4ed3a..8be02d0f 100644 --- a/numass-control/vac/src/main/java/inr/numass/readvac/fx/VacCollectorView.java +++ b/numass-control/vac/src/main/java/inr/numass/readvac/fx/VacCollectorView.java @@ -117,9 +117,9 @@ public class VacCollectorView extends DeviceViewConnection i } }); - LogFragment consoleWindow = new LogFragment(); - new FragmentWindow(consoleWindow).bindTo(logButton); - consoleWindow.hookStd(); + LogFragment logFragment = new LogFragment(); + new FragmentWindow(logFragment).bindTo(logButton); + logFragment.addRootLogHandler(); } @Override