numass control update
This commit is contained in:
parent
5570afea77
commit
809c38689a
@ -28,9 +28,8 @@ task installAll(type: Copy) {
|
||||
def configRoot = new Node(null, "config");
|
||||
subprojects { sub ->
|
||||
//add device configuration file
|
||||
def cfgFile = sub.file("src/main/resources/config/devices.xml")
|
||||
if (cfgFile.exists()) {
|
||||
println "Found device config file ${cfgFile}"
|
||||
sub.fileTree(dir: 'src/main/resources/config', includes: ['**/*.xml']).each { cfgFile ->
|
||||
println "Found config file ${cfgFile}"
|
||||
parser.parse(cfgFile).children().each {
|
||||
configRoot.append(it as Node)
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
plugins{
|
||||
id "org.jetbrains.kotlin.jvm" version '1.1.2-2'
|
||||
id "org.jetbrains.kotlin.jvm" version '1.1.2'
|
||||
id "application"
|
||||
}
|
||||
|
||||
@ -8,7 +8,7 @@ repositories {
|
||||
}
|
||||
|
||||
if (!hasProperty('mainClass')) {
|
||||
ext.mainClass = 'inr.numass.viewer.Viewer'//"inr.numass.viewer.test.TestApp"
|
||||
ext.mainClass = 'inr.numass.control.ServerApp'//"inr.numass.viewer.test.TestApp"
|
||||
}
|
||||
|
||||
mainClassName = mainClass
|
||||
@ -22,11 +22,12 @@ compileKotlin.kotlinOptions.jvmTarget = "1.8"
|
||||
dependencies {
|
||||
compile project(':numass-core')
|
||||
compile project(':numass-control')
|
||||
compile project(':numass-server')
|
||||
|
||||
compile 'org.controlsfx:controlsfx:8.40.12'
|
||||
|
||||
compile "no.tornado:tornadofx:1.7.4"
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.2-3"
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jre8:1.1.2"
|
||||
}
|
||||
|
||||
apply plugin: 'kotlin'
|
||||
|
@ -0,0 +1,21 @@
|
||||
package inr.numass.control
|
||||
|
||||
import hep.dataforge.context.Global
|
||||
import javafx.scene.Scene
|
||||
import tornadofx.*
|
||||
|
||||
/**
|
||||
* Created by darksnake on 19-May-17.
|
||||
*/
|
||||
class ServerApp : App(ServerView::class) {
|
||||
|
||||
override fun createPrimaryScene(view: UIComponent): Scene {
|
||||
if (view is ServerView) {
|
||||
view.context = Global.getContext("NUMASS-SERVER")
|
||||
NumassControlUtils.getConfig(this).ifPresent { view.configure(it) }
|
||||
}
|
||||
return super.createPrimaryScene(view)
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,85 @@
|
||||
package inr.numass.control
|
||||
|
||||
import hep.dataforge.context.Context
|
||||
import hep.dataforge.exceptions.StorageException
|
||||
import hep.dataforge.meta.Meta
|
||||
import hep.dataforge.server.ServerManager
|
||||
import hep.dataforge.storage.commons.StorageFactory
|
||||
import inr.numass.client.ClientUtils
|
||||
import javafx.beans.property.SimpleObjectProperty
|
||||
import javafx.event.EventHandler
|
||||
import javafx.scene.control.Hyperlink
|
||||
import tornadofx.*
|
||||
|
||||
/**
|
||||
* Created by darksnake on 18-May-17.
|
||||
*/
|
||||
class ServerView() : View("Numass server controller") {
|
||||
val contextProperty = SimpleObjectProperty<Context>()
|
||||
var context by contextProperty
|
||||
|
||||
val serverManagerProperty = SimpleObjectProperty<ServerManager>()
|
||||
var serverManager: ServerManager by serverManagerProperty
|
||||
|
||||
|
||||
var label: Hyperlink by singleAssign();
|
||||
override val root = borderpane {
|
||||
center {
|
||||
hbox {
|
||||
togglebutton("Server") {
|
||||
isSelected = false
|
||||
disableProperty().bind(serverManagerProperty.isNull)
|
||||
action {
|
||||
if (isSelected) {
|
||||
serverManager.startServer()
|
||||
label.text = serverManager.link;
|
||||
} else {
|
||||
serverManager.stopServer()
|
||||
label.text = ""
|
||||
}
|
||||
}
|
||||
}
|
||||
label = hyperlink{
|
||||
action {
|
||||
hostServices.showDocument(serverManager.link);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
NumassControlUtils.setDFStageIcon(primaryStage)
|
||||
contextProperty.addListener { _, oldValue, newValue ->
|
||||
if (oldValue != newValue) {
|
||||
if (newValue != null) {
|
||||
serverManager = newValue.pluginManager().getOrLoad(ServerManager::class.java);
|
||||
} else {
|
||||
serverManagerProperty.set(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
primaryStage.onCloseRequest = EventHandler { serverManager.stopServer() }
|
||||
}
|
||||
|
||||
fun configure(meta: Meta) {
|
||||
meta.optMeta("storage").ifPresent { node ->
|
||||
context.logger.info("Creating storage for server with meta {}", node)
|
||||
//building storage in a separate thread
|
||||
runAsync {
|
||||
val numassRun = ClientUtils.getRunName(meta)
|
||||
var storage = StorageFactory.buildStorage(context, node)
|
||||
if (!numassRun.isEmpty()) {
|
||||
try {
|
||||
storage = storage.buildShelf(numassRun, Meta.empty())
|
||||
} catch (e: StorageException) {
|
||||
context.logger.error("Failed to build shelf", e)
|
||||
}
|
||||
|
||||
}
|
||||
serverManager.addStorage("numass", storage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<config>
|
||||
<server port="8337"/>
|
||||
</config>
|
@ -50,6 +50,8 @@ public class PKT8View extends DeviceViewConnection<PKT8Device> implements Initia
|
||||
@FXML
|
||||
private ToggleButton startStopButton;
|
||||
@FXML
|
||||
private ToggleButton storeButton;
|
||||
@FXML
|
||||
private ToggleButton consoleButton;
|
||||
@FXML
|
||||
private ToggleButton plotButton;
|
||||
@ -70,6 +72,7 @@ public class PKT8View extends DeviceViewConnection<PKT8Device> implements Initia
|
||||
sensorColumn.setCellValueFactory(new PropertyValueFactory<>("channel"));
|
||||
resColumn.setCellValueFactory(new PropertyValueFactory<>("rawString"));
|
||||
tempColumn.setCellValueFactory(new PropertyValueFactory<>("temperatureString"));
|
||||
bindBooleanToState("storing", storeButton.selectedProperty());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<config>
|
||||
<storage path="D:\\temp\\cryo"/>
|
||||
<device type="PKT8" name="thermo-1">
|
||||
<!-- Device configuration -->
|
||||
<port>192.168.111.36:4001</port>
|
||||
|
@ -19,15 +19,14 @@
|
||||
</center>
|
||||
<top>
|
||||
<ToolBar prefHeight="40.0" prefWidth="200.0" BorderPane.alignment="CENTER">
|
||||
<items>
|
||||
<ToggleButton fx:id="startStopButton" mnemonicParsing="false" onAction="#onStartStopClick"
|
||||
text="Start"/>
|
||||
<Separator orientation="VERTICAL"/>
|
||||
<Pane HBox.hgrow="ALWAYS"/>
|
||||
<Separator orientation="VERTICAL"/>
|
||||
<ToggleButton fx:id="plotButton" mnemonicParsing="false" text="Plot"/>
|
||||
<ToggleButton fx:id="consoleButton" mnemonicParsing="false" text="Console"/>
|
||||
</items>
|
||||
<ToggleButton fx:id="startStopButton" mnemonicParsing="false" onAction="#onStartStopClick"
|
||||
text="Start"/>
|
||||
<ToggleButton fx:id="storeButton" text="Store"/>
|
||||
<Separator orientation="VERTICAL"/>
|
||||
<Pane HBox.hgrow="ALWAYS"/>
|
||||
<Separator orientation="VERTICAL"/>
|
||||
<ToggleButton fx:id="plotButton" mnemonicParsing="false" text="Plot"/>
|
||||
<ToggleButton fx:id="consoleButton" mnemonicParsing="false" text="Console"/>
|
||||
</ToolBar>
|
||||
</top>
|
||||
<bottom>
|
||||
|
@ -42,12 +42,12 @@ public abstract class DeviceViewConnection<D extends Device> extends DeviceConne
|
||||
*/
|
||||
protected void bindBooleanToState(String state, BooleanProperty property) {
|
||||
getStateBinding(state).addListener((observable, oldValue, newValue) -> {
|
||||
if (oldValue != newValue) {
|
||||
if (isOpen() && oldValue != newValue) {
|
||||
property.setValue(newValue.booleanValue());
|
||||
}
|
||||
});
|
||||
property.addListener((observable, oldValue, newValue) -> {
|
||||
if (oldValue != newValue) {
|
||||
if (isOpen() && oldValue != newValue) {
|
||||
getDevice().setState(state, newValue);
|
||||
}
|
||||
});
|
||||
|
@ -1,16 +0,0 @@
|
||||
package inr.numass.control;
|
||||
|
||||
import hep.dataforge.control.devices.Device;
|
||||
import hep.dataforge.fx.fragments.FXFragment;
|
||||
import hep.dataforge.fx.fragments.LogFragment;
|
||||
import hep.dataforge.utils.MetaFactory;
|
||||
|
||||
/**
|
||||
* Created by darksnake on 20-Oct-16.
|
||||
*/
|
||||
public interface Framework<T extends Device> {
|
||||
LogFragment getLogFragment();
|
||||
FXFragment getPlotFragment();
|
||||
DeviceFragment<T> getDeviceFragment();
|
||||
MetaFactory<T> getDeviceFactory();
|
||||
}
|
@ -36,6 +36,7 @@ public abstract class NumassControlApplication<D extends Device> extends Applica
|
||||
primaryStage.show();
|
||||
|
||||
device = setupDevice(controller);
|
||||
NumassControlUtils.setDFStageIcon(primaryStage);
|
||||
setupStage(primaryStage, device);
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,8 @@ import hep.dataforge.storage.commons.StorageFactory;
|
||||
import hep.dataforge.storage.commons.StorageManager;
|
||||
import inr.numass.client.ClientUtils;
|
||||
import javafx.application.Application;
|
||||
import javafx.scene.image.Image;
|
||||
import javafx.stage.Stage;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -98,4 +100,8 @@ public class NumassControlUtils {
|
||||
return ctx;
|
||||
}
|
||||
|
||||
public static void setDFStageIcon(Stage stage){
|
||||
stage.getIcons().add(new Image(NumassControlUtils.class.getResourceAsStream("/img/df.png")));
|
||||
}
|
||||
|
||||
}
|
||||
|
BIN
numass-control/src/main/resources/img/df.png
Normal file
BIN
numass-control/src/main/resources/img/df.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 53 KiB |
@ -5,8 +5,6 @@
|
||||
*/
|
||||
package inr.numass.readvac.fx;
|
||||
|
||||
import hep.dataforge.values.Value;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
import javafx.fxml.FXML;
|
||||
import javafx.fxml.FXMLLoader;
|
||||
import javafx.scene.Node;
|
||||
@ -41,11 +39,9 @@ public class PoweredVacuumeterView extends VacuumeterView {
|
||||
|
||||
@Override
|
||||
public void initialize(URL location, ResourceBundle resources) {
|
||||
super.initialize(location,resources);
|
||||
unitLabel.setText(getDevice().meta().getString("units", "mbar"));
|
||||
deviceNameLabel.setText(getDevice().getName());
|
||||
powerSwitch.selectedProperty().addListener((ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
|
||||
getDevice().setState("power", Value.of(newValue));
|
||||
});
|
||||
bindBooleanToState("power", powerSwitch.selectedProperty());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import hep.dataforge.control.devices.Device;
|
||||
import hep.dataforge.control.measurements.Measurement;
|
||||
import hep.dataforge.control.measurements.MeasurementListener;
|
||||
import hep.dataforge.control.measurements.Sensor;
|
||||
import hep.dataforge.values.Value;
|
||||
import inr.numass.control.DeviceViewConnection;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.value.ObservableValue;
|
||||
@ -98,11 +97,6 @@ public class VacuumeterView extends DeviceViewConnection<Sensor<Double>> impleme
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyDeviceStateChanged(Device device, String name, Value state) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onMeasurementFailed(Measurement measurement, Throwable exception) {
|
||||
Platform.runLater(() -> {
|
||||
|
@ -2,7 +2,7 @@
|
||||
<config>
|
||||
<!--<storage path="D:/temp/test"/>-->
|
||||
<device type="numass:vac">
|
||||
<sensor name="P1" color="red" port="com::/dev/ttyUSB0" sensorType="mks"/>
|
||||
<sensor name="P1" color="red" port="tcp::192.168.111.33:4002" sensorType="mks"/>
|
||||
<sensor name="P2" color="blue" port="tcp::192.168.111.32:4002" sensorType="CM32"/>
|
||||
<sensor name="P3" color="green" port="tcp::192.168.111.32:4003" sensorType="CM32"/>
|
||||
<sensor name="Px" color="black" port="tcp::192.168.111.33:4003" sensorType="meradat" address="1"/>
|
||||
|
@ -37,7 +37,7 @@ public class TestServer {
|
||||
NumassStorage storage = new NumassStorage(context, FileStorageFactory.buildStorageMeta(path, true, true));
|
||||
serverManager.addObject("numass", storage, NumassStorageHandler::new);
|
||||
|
||||
serverManager.startSetver();
|
||||
serverManager.startServer();
|
||||
|
||||
String stopLine = "";
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user