BowlerKernel
LinkConfiguration.java
Go to the documentation of this file.
1 package com.neuronrobotics.sdk.addons.kinematics;
2 
3 import java.util.ArrayList;
4 import java.util.HashMap;
5 import java.util.NoSuchElementException;
6 
7 import org.w3c.dom.Element;
8 import org.w3c.dom.Node;
9 import org.w3c.dom.NodeList;
10 
11 import com.neuronrobotics.sdk.addons.kinematics.math.ITransformNRChangeListener;
12 import com.neuronrobotics.sdk.addons.kinematics.math.RotationNR;
13 import com.neuronrobotics.sdk.addons.kinematics.math.TransformNR;
14 import com.neuronrobotics.sdk.addons.kinematics.xml.XmlFactory;
15 import com.neuronrobotics.sdk.common.Log;
16 //import org.w3c.dom.Node;
17 //import org.w3c.dom.NodeList;
18 import com.neuronrobotics.sdk.namespace.bcs.pid.IPidControlNamespace;
19 import com.neuronrobotics.sdk.pid.PIDConfiguration;
20 
21 // TODO: Auto-generated Javadoc
26  private ArrayList<ILinkConfigurationChangeListener> listeners = null;
27  private boolean pauseEvents=false;
29  private String name = "newLink";// = getTagValue("name",eElement);
30 
32  private String type = "virtual";
33 
35  private int index = 0;// = Double.parseDouble(getTagValue("index",eElement));
36 
38  private int totlaNumberOfLinks = 1;
39 
41  private int linkIndex = 0;
42 
44  // private double length;// =
45  // Double.parseDouble(getTagValue("length",eElement));
46  private double scale = 1.0;// = Double.parseDouble(getTagValue("scale",eElement));
47 
49  private double upperLimit = 100000;// = Double.parseDouble(getTagValue("upperLimit",eElement));
50 
52  private double lowerLimit = -100000;// = Double.parseDouble(getTagValue("lowerLimit",eElement));
53 
55  private double k[] = new double[] { 1, 0, 0 };
56 
58  private boolean inverted = false;
59 
61  private boolean isLatch = false;
62 
64  private double indexLatch = 0;
65 
67  private boolean isStopOnLatch = false;
68 
70  private int homingTicksPerSecond = 10000000;
71 
73  private double velocityLimit = 100000000;
74 
76  private String deviceScriptingName = "exampleDevice";
77  private double deviceTheoreticalMax = 180;
78  private double deviceTheoreticalMin = 0;
79  private double mass = 0.01;// KG
83  private double staticOffset = 0;
84 
85  private ArrayList<LinkConfiguration> slaveLinks = new ArrayList<LinkConfiguration>();
86 
91  private boolean invertVelocity = false;
92 
97  private boolean invertLimitVelocityPolarity = false;
98 
99  private HashMap<String, String[]> vitamins = new HashMap<String, String[]>();
100  private HashMap<String, String> vitaminVariant = new HashMap<String, String>();
101  private boolean passive = false;
102  private boolean newAbs = false;
103 
109  public LinkConfiguration(Element eElement) {
110  setName(XmlFactory.getTagValue("name", eElement));
111  setHardwareIndex(Integer.parseInt(XmlFactory.getTagValue("index", eElement)));
112  setScale(Double.parseDouble(XmlFactory.getTagValue("scale", eElement)));
113  try {
114  setDeviceTheoreticalMax(Double.parseDouble(XmlFactory.getTagValue("deviceTheoreticalMax", eElement)));
115  } catch (Exception e) {
116  newAbs = true;
117  }
118  try {
119  setDeviceTheoreticalMin(Double.parseDouble(XmlFactory.getTagValue("deviceTheoreticalMin", eElement)));
120  } catch (Exception e) {
121  newAbs = true;
122  }
123  setUpperLimit(Double.parseDouble(XmlFactory.getTagValue("upperLimit", eElement)));
124  setLowerLimit(Double.parseDouble(XmlFactory.getTagValue("lowerLimit", eElement)));
125  try {
126  setDeviceScriptingName(XmlFactory.getTagValue("deviceName", eElement));
127  } catch (NullPointerException e) {
128  // no device from connection engine specified
129  }
130  try {
131  invertLimitVelocityPolarity = XmlFactory.getTagValue("invertLimitVelocityPolarity", eElement)
132  .contains("true");
133 
134  } catch (NullPointerException e) {
135  // no device from connection engine specified
136  }
137  try {
138  setTypeString(XmlFactory.getTagValue("type", eElement));
139  try {
141  } catch (NoSuchElementException e) {
142  setTypeString(LinkType.VIRTUAL.getName());
143  setTypeString("virtual");
144  }
145  } catch (NullPointerException e) {
146  setTypeString(LinkType.PID.getName());
147  }
148  if (getTypeEnum() == LinkType.PID) {
149  try {
150  k[0] = Double.parseDouble(XmlFactory.getTagValue("pGain", eElement));
151  k[1] = Double.parseDouble(XmlFactory.getTagValue("iGain", eElement));
152  k[2] = Double.parseDouble(XmlFactory.getTagValue("dGain", eElement));
153  inverted = XmlFactory.getTagValue("isInverted", eElement).contains("true");
154  setHomingTicksPerSecond(Integer.parseInt(XmlFactory.getTagValue("homingTPS", eElement)));
155  } catch (Exception ex) {
156  }
157  }
158 
159  try {
160  setUpperVelocity(Double.parseDouble(XmlFactory.getTagValue("upperVelocity", eElement)));
161  } catch (Exception e) {
162 
163  }
164  try {
165  setStaticOffset(Double.parseDouble(XmlFactory.getTagValue("staticOffset", eElement)));
166  } catch (Exception e) {
167 
168  }
169 
170  try {
171  setMassKg(Double.parseDouble(XmlFactory.getTagValue("mass", eElement)));
172  } catch (Exception e) {
173 
174  }
175  try {
176  setElectroMechanicalType(XmlFactory.getTagValue("electroMechanicalType", eElement));
177  } catch (Exception e) {
178 
179  }
180 
181  try {
182  setElectroMechanicalSize(XmlFactory.getTagValue("electroMechanicalSize", eElement));
183  } catch (Exception e) {
184 
185  }
186  try {
187  setShaftType(XmlFactory.getTagValue("shaftType", eElement));
188  } catch (Exception e) {
189 
190  }
191 
192  try {
193  setShaftSize(XmlFactory.getTagValue("shaftSize", eElement));
194  } catch (Exception e) {
195 
196  }
197  try {
198  setPassive(Boolean.parseBoolean(XmlFactory.getTagValue("passive", eElement)));
199  } catch (Exception e) {
200 
201  }
202  NodeList nodListofLinks = eElement.getChildNodes();
203 
204  for (int i = 0; i < nodListofLinks.getLength(); i++) {
205  Node linkNode = nodListofLinks.item(i);
206  try {
207  if (linkNode.getNodeType() == Node.ELEMENT_NODE
208  && linkNode.getNodeName().contentEquals("centerOfMassFromCentroid")) {
209  Element cntr = (Element) linkNode;
210  setCenterOfMassFromCentroid(new TransformNR(Double.parseDouble(XmlFactory.getTagValue("x", cntr)),
211  Double.parseDouble(XmlFactory.getTagValue("y", cntr)),
212  Double.parseDouble(XmlFactory.getTagValue("z", cntr)),
213  new RotationNR(new double[] { Double.parseDouble(XmlFactory.getTagValue("rotw", cntr)),
214  Double.parseDouble(XmlFactory.getTagValue("rotx", cntr)),
215  Double.parseDouble(XmlFactory.getTagValue("roty", cntr)),
216  Double.parseDouble(XmlFactory.getTagValue("rotz", cntr)) })));
217  }
218  } catch (Exception e) {
219 
220  }
221  try {
222  if (linkNode.getNodeType() == Node.ELEMENT_NODE
223  && linkNode.getNodeName().contentEquals("imuFromCentroid")) {
224  Element cntr = (Element) linkNode;
225  setimuFromCentroid(new TransformNR(Double.parseDouble(XmlFactory.getTagValue("x", cntr)),
226  Double.parseDouble(XmlFactory.getTagValue("y", cntr)),
227  Double.parseDouble(XmlFactory.getTagValue("z", cntr)),
228  new RotationNR(new double[] { Double.parseDouble(XmlFactory.getTagValue("rotw", cntr)),
229  Double.parseDouble(XmlFactory.getTagValue("rotx", cntr)),
230  Double.parseDouble(XmlFactory.getTagValue("roty", cntr)),
231  Double.parseDouble(XmlFactory.getTagValue("rotz", cntr)) })));
232  }
233  } catch (Exception e) {
234 
235  }
236  try {
237  if (linkNode.getNodeType() == Node.ELEMENT_NODE && linkNode.getNodeName().contentEquals("vitamins")) {
238  getVitamins((Element) linkNode);
239  }
240  } catch (Exception e) {
241 
242  }
243  }
244  isLatch = XmlFactory.getTagValue("isLatch", eElement).contains("true");
245  setIndexLatch(Double.parseDouble(XmlFactory.getTagValue("indexLatch", eElement)));
246  isStopOnLatch = XmlFactory.getTagValue("isStopOnLatch", eElement).contains("true");
248  Log.error("PID group " + getHardwareIndex() + " staticOffset is " + staticOffset
249  + " but needs to be between " + getUpperLimit() + " and " + getLowerLimit());
250  // System.out.println("Interted"+ inverted);
251  }
252 
258  public LinkConfiguration(Object[] args) {
259  setName((String) args[6]);
260  setHardwareIndex((Integer) args[0]);
261  setScale((Double) args[5]);
262  setUpperLimit((Integer) args[4]);
263  setLowerLimit((Integer) args[3]);
264  setTypeString(LinkType.PID.getName());
265 
266  setTotlaNumberOfLinks((Integer) args[1]);
267  fireChangeEvent();
268  }
269 
275  protected void getVitamins(Element doc) {
276 
277  try {
278  NodeList nodListofLinks = doc.getChildNodes();
279  for (int i = 0; i < nodListofLinks.getLength(); i++) {
280  Node linkNode = nodListofLinks.item(i);
281  if (linkNode.getNodeType() == Node.ELEMENT_NODE && linkNode.getNodeName().contentEquals("vitamin")) {
282  Element e = (Element) linkNode;
283  setVitamin(XmlFactory.getTagValue("name", e), XmlFactory.getTagValue("type", e),
284  XmlFactory.getTagValue("id", e));
285  try {
287  } catch (Exception ex) {
288  }
289  }
290  }
291  return;
292  } catch (Exception e) {
293  e.printStackTrace();
294  }
295  return;
296  }
297 
306  public void setVitamin(String name, String type, String id) {
307  if (getVitamins().get(name) == null) {
308  getVitamins().put(name, new String[2]);
309  }
310  getVitamins().get(name)[0] = type;
311  getVitamins().get(name)[1] = id;
312  fireChangeEvent();
313  }
314 
321  public void setVitaminVariant(String name, String tagValue2) {
322  vitaminVariant.put(name, tagValue2);
323  fireChangeEvent();
324  }
325 
332  public String getVitaminVariant(String name) {
333  return vitaminVariant.get(name);
334  }
335 
339  public LinkConfiguration() {
340  // default values
341  }
342 
345 
346  for(int i=0;i<from.slaveLinks.size();i++){
347  slaveLinks.add(new LinkConfiguration(from.slaveLinks.get(i)));
348  }
349 
350  for(String key: from.getVitamins().keySet()){
351  getVitamins().put(key, from.getVitamins().get(key));
352  }
353  setName(from.getName());
354 
357  setScale(from.getScale());
364  setLatch(from.isLatch());
368  setPassive(from.isPassive());
369  setMassKg(from.getMassKg());
372 
373  }
374 
383  public LinkConfiguration(int home, int llimit, int ulimit, double d) {
384  setScale(d);
385  setUpperLimit(ulimit);
386  setLowerLimit(llimit);
387  setStaticOffset(home);
388  fireChangeEvent();
389  }
390 
391  /*
392  * (non-Javadoc)
393  *
394  * @see java.lang.Object#toString()
395  */
396  public String toString() {
397  String s = "LinkConfiguration: \n\tName: " + getName();
398  if (deviceScriptingName != null)
399  s = "Device Name: \n\tName: " + getDeviceScriptingName();
400  s += "\n\tType: " + getTypeEnum() + " " + getTypeString();
401  s += "\n\tHardware Board Index: " + getHardwareIndex();
402  s += "\n\tScale: " + getScale();
403  s += "\n\tUpper Limit: " + getUpperLimit();
404  s += "\n\tLower Limit: " + getLowerLimit();
405  s += "\n\tHoming Ticks Per Second: " + getHomingTicksPerSecond();
406  return s;
407  }
408 
414  /*
415  *
416  * Generate the xml configuration to generate a link of this configuration.
417  */
418  public String getXml() {
419  String DevStr = deviceScriptingName != null ? "<deviceName>" + getDeviceScriptingName() + "</deviceName>\n"
420  : "";
421  String slaves = "";
422  for (int i = 0; i < slaveLinks.size(); i++) {
423  slaves += "\n\t<slaveLink>\n" + slaveLinks.get(i).getXml() + "\n\t</slaveLink>\n";
424  }
425  String allVitamins = "";
426  for (String key : getVitamins().keySet()) {
427  String v = "\t\t<vitamin>\n";
428  v += "\t\t\t<name>" + key + "</name>\n" + "\t\t\t<type>" + getVitamins().get(key)[0] + "</type>\n"
429  + "\t\t\t<id>" + getVitamins().get(key)[1] + "</id>\n";
430  if (getVitaminVariant(key) != null) {
431  v += "\t\t\t<variant>" + getVitamins().get(key)[1] + "</variant>\n";
432  }
433  v += "\t\t</vitamin>\n";
434  allVitamins += v;
435  }
436 
437  return "\t<name>" + getName() + "</name>\n" + "\t" + DevStr + "\t<type>" + getTypeString() + "</type>\n"
438  + "\t<index>" + getHardwareIndex() + "</index>\n" + "\t<scale>" + getScale() + "</scale>\n"
439  + "\t<upperLimit>" + getUpperLimit() + "</upperLimit>\n" + "\t<lowerLimit>" + getLowerLimit()
440  + "</lowerLimit>\n" + "\t<upperVelocity>" + getUpperVelocity() + "</upperVelocity>\n"
441  + "\t<lowerVelocity>" + getLowerVelocity() + "</lowerVelocity>\n" + "\t<staticOffset>"
442  + getStaticOffset() + "</staticOffset>\n" + "\t<deviceTheoreticalMax>" + getDeviceTheoreticalMax()
443  + "</deviceTheoreticalMax>\n" + "\t<deviceTheoreticalMin>" + getDeviceTheoreticalMin()
444  + "</deviceTheoreticalMin>\n" + "\t<isLatch>" + isLatch() + "</isLatch>\n" + "\t<indexLatch>"
445  + getIndexLatch() + "</indexLatch>\n" + "\t<isStopOnLatch>" + isStopOnLatch() + "</isStopOnLatch>\n"
446  + "\t<homingTPS>" + getHomingTicksPerSecond() + "</homingTPS>\n" + "\n\t<vitamins>\n" + allVitamins
447  + "\n\t</vitamins>\n" + "\t<passive>" + isPassive() + "</passive>\n" + "\t<mass>" + getMassKg()
448  + "</mass>\n" + "\t<centerOfMassFromCentroid>" + getCenterOfMassFromCentroid().getXml()
449  + "</centerOfMassFromCentroid>\n" + "\t<imuFromCentroid>" + getimuFromCentroid().getXml()
450  + "</imuFromCentroid>\n" + slaves;
451  }
452 
458  public void setName(String name) {
459  Log.info("Setting controller name: " + name);
460  this.name = name;
461  fireChangeEvent();
462  }
463 
469  public String getName() {
470  return name;
471  }
472 
479  public void setHardwareIndex(int index) {
480  this.index = index;
481  fireChangeEvent();
482  }
483 
490  public int getHardwareIndex() {
491  return index;
492  }
493 
499  public void setScale(double scale) {
500  this.scale = scale;
501  fireChangeEvent();
502  }
503 
509  public double getScale() {
510  return scale;
511  }
512 
513  public double getDeviceTheoreticalMax() {
514  return deviceTheoreticalMax;
515  }
516 
518  this.deviceTheoreticalMax = deviceTheoreticalMax;
519  fireChangeEvent();
520  }
521 
522  public double getDeviceTheoreticalMin() {
523  return deviceTheoreticalMin;
524  }
525 
527  this.deviceTheoreticalMin = deviceTheoreticalMin;
528  fireChangeEvent();
529  }
530 
536  public void setUpperLimit(double upperLimit) {
537  this.upperLimit = upperLimit;
539  if (!newAbs)
540  this.upperLimit = getDeviceTheoreticalMax();
541  else
543 
544  }
545  fireChangeEvent();
546  }
547 
553  public double getUpperLimit() {
554  return upperLimit;
555  }
556 
562  public void setLowerLimit(double lowerLimit) {
563  this.lowerLimit = lowerLimit;
565  if (!newAbs) {
566  this.lowerLimit = getDeviceTheoreticalMin();
567  } else {
569  }
570  }
571 
572  fireChangeEvent();
573  }
574 
580  public double getLowerLimit() {
581  return lowerLimit;
582  }
583 
589  public double getKP() {
590  return k[0];
591  }
592 
598  public double getKI() {
599  return k[1];
600  }
601 
607  public double getKD() {
608  return k[2];
609  }
610 
616  public void setKP(double kP) {
617  k[0] = kP;
618  fireChangeEvent();
619  }
620 
626  public void setKI(double kI) {
627  k[1] = kI;
628  fireChangeEvent();
629  }
630 
636  public void setKD(double kD) {
637  k[2] = kD;
638  fireChangeEvent();
639  }
640 
646  public void setInverted(boolean inverted) {
647  this.inverted = inverted;
648  fireChangeEvent();
649  }
650 
656  public boolean isInverted() {
657  return inverted;
658  }
659 
665  public void setIndexLatch(double indexLatch) {
666 
671  this.indexLatch = indexLatch;
672  fireChangeEvent();
673  }
674 
680  public double getIndexLatch() {
681  return indexLatch;
682  }
683 
689  public void setLatch(boolean isLatch) {
690  this.isLatch = isLatch;
691  }
692 
698  public boolean isLatch() {
699  return isLatch;
700  }
701 
707  public void setStopOnLatch(boolean isStopOnLatch) {
708  this.isStopOnLatch = isStopOnLatch;
709  fireChangeEvent();
710  }
711 
717  public boolean isStopOnLatch() {
718  return isStopOnLatch;
719  }
720 
727  this.homingTicksPerSecond = homingTicksPerSecond;
728  fireChangeEvent();
729  }
730 
736  public int getHomingTicksPerSecond() {
737  return homingTicksPerSecond;
738  }
739 
745  LinkType getTypeEnum() {
746  return LinkType.fromString(type);
747  }
748 
754  public void setUpperVelocity(double upperVelocity) {
755  this.velocityLimit = upperVelocity;
756  fireChangeEvent();
757  }
758 
764  public double getUpperVelocity() {
765  return velocityLimit;
766  }
767 
773  public double getLowerVelocity() {
774  return -velocityLimit;
775  }
776 
782  public int getLinkIndex() {
783  return linkIndex;
784  }
785 
791  public void setLinkIndex(int linkIndex) {
792  this.linkIndex = linkIndex;
793  fireChangeEvent();
794  }
795 
801  public int getTotlaNumberOfLinks() {
802  return totlaNumberOfLinks;
803  }
804 
811  this.totlaNumberOfLinks = totlaNumberOfLinks;
812  fireChangeEvent();
813  }
814 
822  pid.setKD(getKD());
823  pid.setGroup(getHardwareIndex());
825  pid.setKI(getKI());
826  pid.setKP(getKP());
828  pid.setInverted(isInverted());
829  return pid;
830  }
831 
839  if (getTypeEnum() == LinkType.PID) {
840  k[0] = conf.getKP();
841  k[1] = conf.getKI();
842  k[2] = conf.getKD();
843  inverted = conf.isInverted();
845  }
846 
847  isLatch = conf.isUseLatch();
848  indexLatch = (int) conf.getIndexLatch();
849  isStopOnLatch = conf.isStopOnIndex();
850  fireChangeEvent();
851 // if(indexLatch>getUpperLimit() || indexLatch<getLowerLimit() )
852 // throw new RuntimeException("PID group "+getHardwareIndex()+" Index latch is "+indexLatch+" but needs to be between "+getUpperLimit()+" and "+getLowerLimit());
853 
854  }
855 
861  public String getDeviceScriptingName() {
862  return deviceScriptingName;
863  }
864 
871  this.deviceScriptingName = deviceScriptingName;
872  fireChangeEvent();
873  }
874 
880  public double getStaticOffset() {
881  return staticOffset;
882  }
883 
889  public void setStaticOffset(double staticOffset) {
890  if (staticOffset > getUpperLimit())
892  if (staticOffset < getLowerLimit())
894  this.staticOffset = staticOffset;
895  fireChangeEvent();
896  }
897 
898  public boolean isInvertLimitVelocityPolarity() {
900  }
901 
903  this.invertLimitVelocityPolarity = invertVelocity;
904  fireChangeEvent();
905  }
906 
907  public ArrayList<LinkConfiguration> getSlaveLinks() {
908  return slaveLinks;
909  }
910 
911  public void setSlaveLinks(ArrayList<LinkConfiguration> slaveLinks) {
912  this.slaveLinks = slaveLinks;
913  fireChangeEvent();
914  }
915 
916  public double getMassKg() {
917  return mass;
918  }
919 
920  public void setMassKg(double mass) {
921  this.mass = mass;
922  fireChangeEvent();
923  }
924 
927  }
928 
930  if (this.centerOfMassFromCentroid != null)
931  this.centerOfMassFromCentroid.removeChangeListener(this);
932  this.centerOfMassFromCentroid = com;
933  this.centerOfMassFromCentroid.addChangeListener(this);
934  fireChangeEvent();
935  }
936 
938  return imuFromCentroid;
939  }
940 
941  public void setimuFromCentroid(TransformNR imu) {
942  if (this.imuFromCentroid != null)
943  this.imuFromCentroid.removeChangeListener(this);
944  this.imuFromCentroid = imu;
945  this.imuFromCentroid.addChangeListener(this);
946  fireChangeEvent();
947  }
948 // private String electroMechanicalType = "hobbyServo";
949 // private String electroMechanicalSize = "standardMicro";
950 // private String shaftType = "hobbyServoHorn";
951 // private String shaftSize = "standardMicro1";
952 
953  private String[] getCoreShaftPart() {
954  if (vitamins.get("shaft") == null) {
955  vitamins.put("shaft", new String[] { "hobbyServoHorn", "standardMicro1" });
956  }
957  return vitamins.get("shaft");
958  }
959 
960  private String[] getCoreEmPart() {
961  if (vitamins.get("electroMechanical") == null) {
962  vitamins.put("electroMechanical", new String[] { "hobbyServo", "standardMicro" });
963  }
964  return vitamins.get("electroMechanical");
965  }
966 
967  public String getElectroMechanicalType() {
968  return getCoreEmPart()[0];
969  }
970 
971  public void setElectroMechanicalType(String electroMechanicalType) {
972  getCoreEmPart()[0] = electroMechanicalType;
973  fireChangeEvent();
974  }
975 
976  public String getElectroMechanicalSize() {
977  return getCoreEmPart()[1];
978  }
979 
980  public void setElectroMechanicalSize(String electroMechanicalSize) {
981  getCoreEmPart()[1] = electroMechanicalSize;
982  fireChangeEvent();
983  }
984 
985  public String getShaftType() {
986  return getCoreShaftPart()[0];
987  }
988 
989  public void setShaftType(String shaftType) {
990  getCoreShaftPart()[0] = shaftType;
991  fireChangeEvent();
992  }
993 
994  public String getShaftSize() {
995  return getCoreShaftPart()[1];
996  }
997 
998  public void setShaftSize(String shaftSize) {
999  getCoreShaftPart()[1] = shaftSize;
1000  fireChangeEvent();
1001  }
1002 
1003  public boolean isPassive() {
1004  return passive;
1005  }
1006 
1007  public void setPassive(boolean passive) {
1008  this.passive = passive;
1009  fireChangeEvent();
1010  }
1011 
1012  public HashMap<String, String[]> getVitamins() {
1013  return vitamins;
1014  }
1015 
1016  public void setVitamins(HashMap<String, String[]> vitamins) {
1017  this.vitamins = vitamins;
1018  fireChangeEvent();
1019  }
1020 
1021  public String getTypeString() {
1022  return type;
1023  }
1024 
1025  public void setTypeString(String typeString) {
1026  if (typeString == null)
1027  throw new NullPointerException();
1028  type = typeString;
1029  fireChangeEvent();
1030  }
1031 
1037  public boolean isVirtual() {
1038  switch (getTypeEnum()) {
1039 
1040  case DUMMY:
1041  case VIRTUAL:
1042  return true;
1043  case USERDEFINED:
1044  if (getTypeString().toLowerCase().contains("virtual")) {
1045  return true;
1046  }
1047  default:
1048  return false;
1049  }
1050  }
1051 
1057  public boolean isTool() {
1058  switch (getTypeEnum()) {
1059  case PID_TOOL:
1060  case GCODE_STEPPER_TOOL:
1061  case GCODE_HEATER_TOOL:
1062  return true;
1063  case USERDEFINED:
1064  if (getTypeString().toLowerCase().contains("tool")) {
1065  return true;
1066  }
1067  default:
1068  return false;
1069 
1070  }
1071  }
1072 
1078  public boolean isPrismatic() {
1079  switch (getTypeEnum()) {
1080  case ANALOG_PRISMATIC:
1081  case PID_PRISMATIC:
1082  case GCODE_STEPPER_PRISMATIC:
1083  return true;
1084  case USERDEFINED:
1085  if (getTypeString().toLowerCase().contains("prismatic")) {
1086  return true;
1087  }
1088  default:
1089  return false;
1090 
1091  }
1092  }
1093 
1095  if (!getListeners().contains(l))
1096  getListeners().add(l);
1097  }
1098 
1100  if (getListeners().contains(l))
1101  getListeners().remove(l);
1102  }
1103 
1104  public void clearChangeListener() {
1105  getListeners().clear();
1106  listeners = null;
1107  }
1108 
1109  public ArrayList<ILinkConfigurationChangeListener> getListeners() {
1110  if (listeners == null)
1111  listeners = new ArrayList<ILinkConfigurationChangeListener>();
1112  return listeners;
1113  }
1114 
1115  void fireChangeEvent() {
1116  if(pauseEvents)
1117  return;
1118  if (listeners != null) {
1119  for (int i = 0; i < listeners.size(); i++) {
1120  try {
1121  listeners.get(i).event(this);
1122  } catch (Throwable t) {
1123  t.printStackTrace();
1124  }
1125  }
1126  }
1127  }
1128 
1129  @Override
1130  public void event(TransformNR changed) {
1131  fireChangeEvent();
1132  }
1133 
1134  public boolean isPauseEvents() {
1135  return pauseEvents;
1136  }
1137 
1138  public void setPauseEvents(boolean pauseEvents) {
1139  this.pauseEvents = pauseEvents;
1140  }
1141 
1142 }
void addChangeListener(ILinkConfigurationChangeListener l)
ArrayList< ILinkConfigurationChangeListener > listeners
ArrayList< ILinkConfigurationChangeListener > getListeners()
LinkConfiguration(int home, int llimit, int ulimit, double d)
void setVitamin(String name, String type, String id)
void setSlaveLinks(ArrayList< LinkConfiguration > slaveLinks)
void removeChangeListener(ILinkConfigurationChangeListener l)
void setVitamins(HashMap< String, String[]> vitamins)
void addChangeListener(ITransformNRChangeListener l)
void removeChangeListener(ITransformNRChangeListener l)
static String getTagValue(String sTag, Element eElement)
Definition: XmlFactory.java:77
static void info(String message)
Definition: Log.java:110
static void error(String message)
Definition: Log.java:92