|
@@ -3,76 +3,100 @@ package urgrip.installation;
|
|
|
import com.ur.urcap.api.contribution.InstallationNodeContribution;
|
|
|
import com.ur.urcap.api.contribution.installation.InstallationAPIProvider;
|
|
|
import com.ur.urcap.api.domain.data.DataModel;
|
|
|
+import com.ur.urcap.api.domain.io.IO;
|
|
|
import com.ur.urcap.api.domain.script.ScriptWriter;
|
|
|
import com.ur.urcap.api.domain.userinteraction.keyboard.KeyboardInputCallback;
|
|
|
import com.ur.urcap.api.domain.userinteraction.keyboard.KeyboardInputFactory;
|
|
|
import com.ur.urcap.api.domain.userinteraction.keyboard.KeyboardTextInput;
|
|
|
|
|
|
+import java.util.Collection;
|
|
|
+
|
|
|
public class HelloWorldInstallationNodeContribution implements InstallationNodeContribution {
|
|
|
|
|
|
- private static final String POPUPTITLE_KEY = "popuptitle";
|
|
|
- private static final String DEFAULT_VALUE = "Hello World";
|
|
|
private final HelloWorldInstallationNodeView view;
|
|
|
- private final KeyboardInputFactory keyboardFactory;
|
|
|
+ private final InstallationAPIProvider apiProvider;
|
|
|
+ public final static String KEY_GRIP="KEY_GRIP";
|
|
|
+ private final static String KEY_GRIP_DEFAULT="digital_out[0]";
|
|
|
+ public final static String KEY_BLOWOUT="KEY_BLOWOUT";
|
|
|
+ private final static String KEY_BLOWOUT_DEFAULT="digital_out[1]";
|
|
|
+ public final static String KEY_WAITFOR="KEY_WAITFOR";
|
|
|
+ private final static String KEY_WAITFOR_DEFAULT="digital_in[0]";
|
|
|
|
|
|
private DataModel model;
|
|
|
|
|
|
public HelloWorldInstallationNodeContribution(InstallationAPIProvider apiProvider, DataModel model, HelloWorldInstallationNodeView view) {
|
|
|
- this.keyboardFactory = apiProvider.getUserInterfaceAPI().getUserInteraction().getKeyboardInputFactory();
|
|
|
this.model = model;
|
|
|
this.view = view;
|
|
|
+ this.apiProvider=apiProvider;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void openView() {
|
|
|
- view.setPopupText(getPopupTitle());
|
|
|
+ Collection<IO> ios = apiProvider.getInstallationAPI().getIOModel().getIOs();
|
|
|
+ view.setIO(ios);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void closeView() {
|
|
|
+ setGripIO(getGripIO());
|
|
|
|
|
|
}
|
|
|
|
|
|
public boolean isDefined() {
|
|
|
- return !getPopupTitle().isEmpty();
|
|
|
+ if(getGripIO().isEmpty())
|
|
|
+ return false;
|
|
|
+ if(getBlowoutIO().isEmpty())
|
|
|
+ return false;
|
|
|
+ if(getWaitforIO().isEmpty())
|
|
|
+ return false;
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void generateScript(ScriptWriter writer) {
|
|
|
// Store the popup title in a global variable so it is globally available to all Hello World program nodes.
|
|
|
- writer.assign("hello_world_swing_popup_title", "\"" + getPopupTitle() + "\"");
|
|
|
+ // writer.assign("hello_world_swing_popup_title", "\"" + getPopupTitle() + "\"");
|
|
|
+ }
|
|
|
+
|
|
|
+ public String getGripIO() {
|
|
|
+ return model.get(KEY_GRIP, KEY_GRIP_DEFAULT);
|
|
|
}
|
|
|
|
|
|
- public String getPopupTitle() {
|
|
|
- return model.get(POPUPTITLE_KEY, DEFAULT_VALUE);
|
|
|
+ public String getBlowoutIO() {
|
|
|
+ return model.get(KEY_BLOWOUT, KEY_BLOWOUT_DEFAULT);
|
|
|
}
|
|
|
|
|
|
- public void setPopupTitle(String message) {
|
|
|
- if ("".equals(message)) {
|
|
|
- resetToDefaultValue();
|
|
|
+ public String getWaitforIO() {
|
|
|
+ return model.get(KEY_WAITFOR, KEY_WAITFOR_DEFAULT);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void setGripIO(String ioName) {
|
|
|
+ if ("".equals(ioName)) {
|
|
|
+ model.set(KEY_GRIP, KEY_GRIP_DEFAULT);
|
|
|
} else {
|
|
|
- model.set(POPUPTITLE_KEY, message);
|
|
|
+ model.set(KEY_GRIP, ioName);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void resetToDefaultValue() {
|
|
|
- view.setPopupText(DEFAULT_VALUE);
|
|
|
- model.set(POPUPTITLE_KEY, DEFAULT_VALUE);
|
|
|
+ public void setBlowoutIO(String ioName) {
|
|
|
+ if ("".equals(ioName)) {
|
|
|
+ model.set(KEY_BLOWOUT, KEY_BLOWOUT_DEFAULT);
|
|
|
+ } else {
|
|
|
+ model.set(KEY_BLOWOUT, ioName);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- public KeyboardTextInput getInputForTextField() {
|
|
|
- KeyboardTextInput keyboardInput = keyboardFactory.createStringKeyboardInput();
|
|
|
- keyboardInput.setInitialValue(getPopupTitle());
|
|
|
- return keyboardInput;
|
|
|
+ public void setWaitforIO(String ioName) {
|
|
|
+ if ("".equals(ioName)) {
|
|
|
+ model.set(KEY_WAITFOR, KEY_WAITFOR_DEFAULT);
|
|
|
+ } else {
|
|
|
+ model.set(KEY_WAITFOR, ioName);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
- public KeyboardInputCallback<String> getCallbackForTextField() {
|
|
|
- return new KeyboardInputCallback<String>() {
|
|
|
- @Override
|
|
|
- public void onOk(String value) {
|
|
|
- setPopupTitle(value);
|
|
|
- view.setPopupText(value);
|
|
|
- }
|
|
|
- };
|
|
|
+ private void resetToDefaultValue() {
|
|
|
+ model.set(KEY_GRIP, KEY_GRIP_DEFAULT);
|
|
|
+ model.set(KEY_BLOWOUT, KEY_BLOWOUT_DEFAULT);
|
|
|
+ model.set(KEY_WAITFOR, KEY_WAITFOR_DEFAULT);
|
|
|
}
|
|
|
}
|