Skip to content

Commit

Permalink
new UI, gripper autodetection
Browse files Browse the repository at this point in the history
  • Loading branch information
girtslinde committed Jul 22, 2018
1 parent df66df4 commit 405a241
Show file tree
Hide file tree
Showing 32 changed files with 314 additions and 175 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<groupId>com.sakerobotics</groupId>
<artifactId>ezgripper-ur</artifactId>
<version>1.4.1</version>
<version>1.5.1</version>
<name>ezgripper-ur</name>
<packaging>bundle</packaging>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,12 @@
import com.ur.urcap.api.contribution.InstallationNodeContribution;

import java.awt.*;
import java.util.Arrays;
import java.util.Timer;
import java.util.TimerTask;

import org.apache.xmlrpc.XmlRpcException;

public class EzgripperInstallationNodeContribution implements InstallationNodeContribution {
private static final String XMLRPC_VARIABLE = "ezgripper_daemon";
private static final String ENABLED_KEY = "enabled";
Expand All @@ -53,6 +56,8 @@ public class EzgripperInstallationNodeContribution implements InstallationNodeCo
private final EzgripperDaemonService daemonService;
private XmlRpcEzgripperInterface xmlRpcDaemonInterface;
private Timer uiTimer;
private String servoIds = "";
private String devName = "";

public EzgripperInstallationNodeContribution(EzgripperDaemonService daemonService, DataModel model) {
this.daemonService = daemonService;
Expand All @@ -61,12 +66,12 @@ public EzgripperInstallationNodeContribution(EzgripperDaemonService daemonServic
applyDesiredDaemonStatus();
}

@Input(id = "btnEnableDaemon")
private InputButton enableDaemonButton;
@Input(id = "btnDisableDaemon")
private InputButton disableDaemonButton;
@Label(id = "lblDaemonStatus")
private LabelComponent daemonStatusLabel;
// @Input(id = "btnEnableDaemon")
// private InputButton enableDaemonButton;
// @Input(id = "btnDisableDaemon")
// private InputButton disableDaemonButton;
@Label(id = "lblStatus")
private LabelComponent lblStatus;

@Input(id = "btnCalibrate")
private InputButton calibrateButton;
Expand All @@ -85,21 +90,21 @@ public EzgripperInstallationNodeContribution(EzgripperDaemonService daemonServic
private InputButton execButton;


@Input(id = "btnEnableDaemon")
public void onStartClick(InputEvent event) {
if (event.getEventType() == InputEvent.EventType.ON_CHANGE) {
setDaemonEnabled(true);
applyDesiredDaemonStatus();
}
}

@Input(id = "btnDisableDaemon")
public void onStopClick(InputEvent event) {
if (event.getEventType() == InputEvent.EventType.ON_CHANGE) {
setDaemonEnabled(false);
applyDesiredDaemonStatus();
}
}
// @Input(id = "btnEnableDaemon")
// public void onStartClick(InputEvent event) {
// if (event.getEventType() == InputEvent.EventType.ON_CHANGE) {
// setDaemonEnabled(true);
// applyDesiredDaemonStatus();
// }
// }
//
// @Input(id = "btnDisableDaemon")
// public void onStopClick(InputEvent event) {
// if (event.getEventType() == InputEvent.EventType.ON_CHANGE) {
// setDaemonEnabled(false);
// applyDesiredDaemonStatus();
// }
// }

@Input(id = "btnCalibrate")
public void onCalibrateClick(InputEvent event) {
Expand Down Expand Up @@ -168,6 +173,12 @@ public void onExecClick(InputEvent event) {

@Override
public void openView() {
try {
servoIds = Arrays.toString(xmlRpcDaemonInterface.get_ids());
devName = xmlRpcDaemonInterface.get_devname();
} catch (XmlRpcException e) {
e.printStackTrace();
}
try {
outputField.setText(xmlRpcDaemonInterface.get_last_message());
} catch (Exception e) {}
Expand All @@ -188,29 +199,15 @@ public void run() {
}

private void updateUI() {
DaemonContribution.State state = getDaemonState();

if (state == DaemonContribution.State.RUNNING) {
enableDaemonButton.setEnabled(false);
disableDaemonButton.setEnabled(true);
} else {
enableDaemonButton.setEnabled(true);
disableDaemonButton.setEnabled(false);
}

String text = "";
switch (state) {
case RUNNING:
text = "Daemon runs";
break;
case STOPPED:
text = "Daemon stopped";
break;
case ERROR:
text = "Daemon failed";
break;
String statusString="";
try {
int[] pos = xmlRpcDaemonInterface.get_positions();
int[] temps = xmlRpcDaemonInterface.get_temperatures();
statusString = devName + " ids="+servoIds+" positions="+Arrays.toString(pos)+" temperatures="+Arrays.toString(temps);
} catch (XmlRpcException e) {
e.printStackTrace();
}
daemonStatusLabel.setText(text);
lblStatus.setText("Status: "+statusString);
}

@Override
Expand Down Expand Up @@ -255,9 +252,9 @@ private Boolean isDaemonEnabled() {
return model.get(ENABLED_KEY, true); //This daemon is enabled by default
}

private void setDaemonEnabled(Boolean enable) {
model.set(ENABLED_KEY, enable);
}
// private void setDaemonEnabled(Boolean enable) {
// model.set(ENABLED_KEY, enable);
// }

public String getXMLRPCVariable(){
return XMLRPC_VARIABLE;
Expand Down
Loading

0 comments on commit 405a241

Please sign in to comment.