This commit is contained in:
root
2018-06-18 16:44:57 +02:00
parent 7da4e32097
commit bd9eaaf4d2
12 changed files with 189 additions and 61 deletions

View File

@@ -47,6 +47,7 @@ import ch.psi.pshell.scripting.ScriptManager;
import ch.psi.pshell.swing.DeviceValueChart;
import ch.psi.pshell.swing.ValueSelection;
import ch.psi.pshell.swing.ValueSelection.ValueSelectionListener;
import ch.psi.pshell.ui.Console;
import ch.psi.utils.Arr;
import ch.psi.utils.ArrayProperties;
import ch.psi.utils.Convert;
@@ -254,6 +255,7 @@ public class ScreenPanel3 extends Panel {
Frame currentFrame;
int imageBufferLenght = 1;
Text imagePauseOverlay;
final Console console;
public ScreenPanel3() {
try {
@@ -550,10 +552,43 @@ public class ScreenPanel3 extends Panel {
});
if (MainFrame.isDark()) {
textState.setDisabledTextColor(textState.getForeground());
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
console = (!App.hasArgument("console")) ? null : new Console() {
/*
protected void onConsoleCommand(String name, String[] pars, String trimming) throws Exception {
switch (name) {
case "cam":
comboCameras.setSelectedItem(tokens[1]);
break;
}
}*/
@Override
protected void onConsoleCommand(String command) {
String[] tokens = command.split(" ");
if ((tokens.length > 1) && tokens[0].equals("cam")){
try{
if (!tokens[1].equals(comboCameras.getSelectedItem())){
setComboTypeSelection("All");
updateCameraList();
comboCameras.setSelectedItem(tokens[1]);
if (!tokens[1].equals(comboCameras.getSelectedItem())){
throw new Exception("Invalid camera name : " + tokens[1]);
}
System.out.println("Console set camera: " + tokens[1]);
}
} catch (Exception ex){
System.err.println(ex);
}
} else {
System.err.println("Invalid command: " + command);
}
}
};
}
void setIntegration(int frames) {
@@ -585,6 +620,9 @@ public class ScreenPanel3 extends Panel {
buttonServer.setSelected(!direct);
buttonDirect.setSelected(direct);
}
if (App.hasArgument("console")) {
console.start();
}
}
@Override
@@ -599,6 +637,13 @@ public class ScreenPanel3 extends Panel {
} catch (Exception ex) {
ex.printStackTrace();
}
try {
if (console != null) {
console.stop();
}
} catch (Exception ex) {
ex.printStackTrace();
}
super.onStop();
}
@@ -628,8 +673,8 @@ public class ScreenPanel3 extends Panel {
updateCameraList();
comboCameras.setEnabled(true);
comboType.setEnabled(true);
setComboCameraSelection(-1);
setComboTypeSelection(0);
setComboCameraSelection(null);
setComboTypeSelection("All");
if (comboCameras.getModel().getSize() > 0) {
try {
@@ -794,7 +839,7 @@ public class ScreenPanel3 extends Panel {
Thread devicesInitTask;
void setCamera(String cameraName) throws IOException, InterruptedException {
System.out.println("Initializing");
System.out.println("Initializing: " + cameraName);
parseUserOverlays();
errorOverlay = null;
lastMarkerPos = null;
@@ -3765,11 +3810,13 @@ public class ScreenPanel3 extends Panel {
private void comboTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_comboTypeActionPerformed
try {
updateCameraList();
if ((cameraName != null) && (!cameraName.equals(comboCameras.getSelectedItem()))) {
setCamera(null);
} else {
setCamera(cameraName);
if (!updatingCameraSelection) {
updateCameraList();
if ((cameraName != null) && (!cameraName.equals(comboCameras.getSelectedItem()))) {
setCamera(null);
} else {
setCamera(cameraName);
}
}
} catch (Exception ex) {