StartStopSwitchUI.java
Go to the documentation of this file.
1 package grl;
2 
3 import java.util.ArrayList;
4 import java.util.List;
5 
6 import com.kuka.roboticsAPI.applicationModel.RoboticsAPIApplication;
7 import com.kuka.roboticsAPI.uiModel.userKeys.IUserKeyBar;
8 import com.kuka.roboticsAPI.uiModel.userKeys.IUserKeyListener;
9 import com.kuka.roboticsAPI.uiModel.userKeys.IUserKey;
10 import com.kuka.roboticsAPI.uiModel.userKeys.UserKeyAlignment;
11 import com.kuka.roboticsAPI.uiModel.userKeys.UserKeyEvent;
12 
13 public class StartStopSwitchUI {
14 
15  private RoboticsAPIApplication _app;
16  // configurable toolbars
17  private List<IUserKeyBar> generalKeyBars = new ArrayList<IUserKeyBar>();
18  private List<IUserKey> generalKeys = new ArrayList<IUserKey>();
19  private List<IUserKeyListener> generalKeyLists = new ArrayList<IUserKeyListener>();
20 
21  // gravity compensation stuff
22  private IUserKeyBar startstopKeybar;
23  private IUserKey startstopKey;
24  private IUserKeyListener startstopKeyList;
25  private boolean startstopEnabled = false;
26  private boolean startstopSwitched = false;
27 
28 public StartStopSwitchUI(RoboticsAPIApplication app)
29 {
30  _app = app;
31 
32 
33  // gravity compensation - only in ROSMonitor for safety
34  startstopKeybar = _app.getApplicationUI().createUserKeyBar("startstop");
35  startstopKeyList = new IUserKeyListener() {
36  @Override
37  public void onKeyEvent(IUserKey key, com.kuka.roboticsAPI.uiModel.userKeys.UserKeyEvent event) {
38  if (event == UserKeyEvent.FirstKeyDown) {
39  startstopEnabled = true;
40  startstopSwitched = true;
41  } else if (event == UserKeyEvent.SecondKeyDown) {
42  startstopEnabled = false;
43  startstopSwitched = true;
44  }
45  }
46  };
47  startstopKey = startstopKeybar.addDoubleUserKey(0, startstopKeyList, true);
48  startstopKey.setText(UserKeyAlignment.TopMiddle, "ON");
49  startstopKey.setText(UserKeyAlignment.BottomMiddle, "OFF");
50  startstopKeybar.publish();
51 }
52 
53 public boolean is_stopped()
54 {
55  return startstopEnabled;
56 }
57 
58 }
StartStopSwitchUI(RoboticsAPIApplication app)