Genericized the VS* suite of classes, reducing redundancy.

Added a <state> element for variables in TV files.
Added a Trick 13 to Trick 15 TV file converter.
Updated .gitignore files.
fixes #21
This commit is contained in:
Derek Bankieris 2015-03-16 11:27:29 -05:00
parent 1dc020a47c
commit d41e7cb937
30 changed files with 373 additions and 601 deletions

1
.gitignore vendored
View File

@ -9,4 +9,5 @@ lib_Darwin_*
*.tab.c
*.tab.h
*.swp
*.dox
Makefile_jsc_dirs

42
bin/convert_tv_file Executable file
View File

@ -0,0 +1,42 @@
#!/usr/bin/python
import sys
import xml.etree.ElementTree as ET
arguments = sys.argv[1:]
if len(arguments) == 0:
print 'A utility script for converting TV files from Trick 13 to Trick 15.'
print 'usage: convert_tv_file <files>'
else:
types = (
('Boolean', 'boolean'),
('Byte', 'byte'),
('Double', 'double'),
('Enumeration', 'string'),
('Float', 'float'),
('Integer', 'int'),
('Long', 'long'),
('Short', 'short'),
('String', 'string')
)
for file in arguments:
print 'Converting ' + file
tree = ET.parse(file)
root = tree.getroot()
for variable in root.findall('variable'):
for type in types:
value = variable.find('tv' + type[0])
if value is not None:
value = value.find('value')
value.set('xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance')
value.set('xmlns:xs', 'http://www.w3.org/2001/XMLSchema')
value.set('xsi:type', 'xs:' + type[1])
break
if file.endswith('.tv'):
file = file[:-3]
newFile = file + '_15.tv'
tree.write(newFile)
print 'Converted to ' + newFile

2
docs/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
html
trick.tag

1
doxygen/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
warning_msgs

View File

@ -1,37 +1,18 @@
package trick.common.utils.vs;
import javax.xml.bind.annotation.XmlRootElement;
public class VSBoolean extends VSValue<Boolean> {
@XmlRootElement
public class VSBoolean extends VSValue {
private static final long serialVersionUID = 3720173025885361193L;
public boolean value;
public VSBoolean() {}
public VSBoolean(boolean value) {
this.value = value;
protected VSBoolean() {
this(false);
}
public boolean getValue() {
return value;
public VSBoolean(boolean value) {
super(value);
}
@Override
public void fromVariableServer(String string) {
value = Integer.parseInt(string.trim()) != 0;
}
@Override
public String toVariableServer() {
return value ? "1" : "0";
}
@Override
public String toString() {
return Boolean.toString(value);
setValue(Integer.parseInt(string.trim()) != 0);
}
}

View File

@ -2,38 +2,19 @@ package trick.common.utils.vs;
import java.math.BigInteger;
import javax.xml.bind.annotation.XmlRootElement;
public class VSByte extends VSValue<Byte> {
@XmlRootElement
public class VSByte extends VSValue {
private static final long serialVersionUID = 8405472938103497097L;
public byte value;
public VSByte() {}
public VSByte(byte value) {
this.value = value;
protected VSByte() {
this((byte)0);
}
public byte getValue() {
return value;
public VSByte(byte value) {
super(value);
}
@Override
public void fromVariableServer(String string) {
value = new BigInteger(string.trim(), 10).byteValue();
}
@Override
public String toVariableServer() {
return Byte.toString(value);
}
@Override
public String toString() {
return Byte.toString(value);
setValue(new BigInteger(string.trim(), 10).byteValue());
}
}

View File

@ -1,37 +1,23 @@
package trick.common.utils.vs;
import javax.xml.bind.annotation.XmlRootElement;
public class VSDouble extends VSValue<Double> {
@XmlRootElement
public class VSDouble extends VSValue {
private static final long serialVersionUID = -2895628958106970334L;
public double value;
public VSDouble() {}
public VSDouble(double value) {
this.value = value;
protected VSDouble() {
this(0);
}
public double getValue() {
return value;
public VSDouble(double value) {
super(value);
}
@Override
public void fromVariableServer(String string) {
value = Double.parseDouble(string.trim());
setValue(Double.parseDouble(string.trim()));
}
@Override
public String toVariableServer() {
return Double.toString(value);
}
@Override
public String toString() {
return Double.toString(value);
return toString();
}
}

View File

@ -1,37 +1,18 @@
package trick.common.utils.vs;
import javax.xml.bind.annotation.XmlRootElement;
public class VSFloat extends VSValue<Float> {
@XmlRootElement
public class VSFloat extends VSValue {
private static final long serialVersionUID = -4629816234119061148L;
public float value;
public VSFloat() {}
public VSFloat(float value) {
this.value = value;
protected VSFloat() {
this(0);
}
public float getValue() {
return value;
public VSFloat(float value) {
super(value);
}
@Override
public void fromVariableServer(String string) {
value = Float.parseFloat(string.trim());
}
@Override
public String toVariableServer() {
return Float.toString(value);
}
@Override
public String toString() {
return Float.toString(value);
setValue(Float.parseFloat(string.trim()));
}
}

View File

@ -2,38 +2,19 @@ package trick.common.utils.vs;
import java.math.BigInteger;
import javax.xml.bind.annotation.XmlRootElement;
public class VSInteger extends VSValue<Integer> {
@XmlRootElement
public class VSInteger extends VSValue {
private static final long serialVersionUID = 1314788741378939173L;
public int value;
public VSInteger() {}
public VSInteger(int value) {
this.value = value;
protected VSInteger() {
this(0);
}
public int getValue() {
return value;
public VSInteger(int value) {
super(value);
}
@Override
public void fromVariableServer(String string) {
value = new BigInteger(string.trim(), 10).intValue();
}
@Override
public String toVariableServer() {
return Integer.toString(value);
}
@Override
public String toString() {
return Integer.toString(value);
setValue(new BigInteger(string.trim(), 10).intValue());
}
}

View File

@ -2,38 +2,19 @@ package trick.common.utils.vs;
import java.math.BigInteger;
import javax.xml.bind.annotation.XmlRootElement;
public class VSLong extends VSValue<Long> {
@XmlRootElement
public class VSLong extends VSValue {
private static final long serialVersionUID = -7792501925528852232L;
public long value;
public VSLong() {}
public VSLong(long value) {
this.value = value;
protected VSLong() {
this(0);
}
public long getValue() {
return value;
public VSLong(long value) {
super(value);
}
@Override
public void fromVariableServer(String string) {
value = new BigInteger(string.trim(), 10).longValue();
}
@Override
public String toVariableServer() {
return Long.toString(value);
}
@Override
public String toString() {
return Long.toString(value);
setValue(new BigInteger(string.trim(), 10).longValue());
}
}

View File

@ -2,38 +2,19 @@ package trick.common.utils.vs;
import java.math.BigInteger;
import javax.xml.bind.annotation.XmlRootElement;
public class VSShort extends VSValue<Short> {
@XmlRootElement
public class VSShort extends VSValue {
private static final long serialVersionUID = 5431648313760456676L;
public short value;
public VSShort() {}
public VSShort(short value) {
this.value = value;
protected VSShort() {
this((short)0);
}
public short getValue() {
return value;
public VSShort(short value) {
super(value);
}
@Override
public void fromVariableServer(String string) {
value = new BigInteger(string.trim(), 10).shortValue();
}
@Override
public String toVariableServer() {
return Short.toString(value);
}
@Override
public String toString() {
return Short.toString(value);
setValue(new BigInteger(string.trim(), 10).shortValue());
}
}

View File

@ -1,37 +1,21 @@
package trick.common.utils.vs;
import javax.xml.bind.annotation.XmlRootElement;
public class VSString extends VSValue<String> {
@XmlRootElement
public class VSString extends VSValue {
private static final long serialVersionUID = 2238385297450301960L;
public String value;
public VSString() {}
protected VSString() {}
public VSString(String value) {
this.value = value;
}
public String getValue() {
return value;
super(value);
}
@Override
public void fromVariableServer(String string) {
value = string;
setValue(string);
}
@Override
public String toVariableServer() {
return "\"" + value + "\"";
}
@Override
public String toString() {
return value;
return "\"" + super.toVariableServer() + "\"";
}
}

View File

@ -1,6 +1,37 @@
package trick.common.utils.vs;
public abstract class VSValue implements VariableServerFluent, Cloneable {
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public abstract class VSValue<T> implements VariableServerFluent, Cloneable {
@XmlElement
private T value;
protected VSValue() {}
protected VSValue(T value) {
setValue(value);
}
public T getValue() {
return value;
}
protected void setValue(T value) {
this.value = value;
}
@Override
public String toVariableServer() {
return toString();
}
@Override
public String toString() {
return value.toString();
}
@Override
public VSValue clone() {

View File

@ -9,7 +9,6 @@ import java.io.Serializable;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementRef;
import javax.xml.bind.annotation.XmlElementRefs;
import trick.common.utils.VariableServerConnection;
@ -20,34 +19,22 @@ import trick.common.utils.VariableServerConnection;
*/
public class Variable<T extends VariableServerFluent> implements Serializable, Cloneable {
private static final long serialVersionUID = 4529167759720494026L;
/** possible states */
public enum State {Unknown, Invalid, Valid};
/** name */
@XmlElement(required = true)
public final String name;
/** value */
@XmlElementRefs({
@XmlElementRef(type=VSValue.class),
@XmlElementRef(type=VSBoolean.class),
@XmlElementRef(type=VSByte.class),
@XmlElementRef(type=VSDouble.class),
@XmlElementRef(type=VSFloat.class),
@XmlElementRef(type=VSInteger.class),
@XmlElementRef(type=VSLong.class),
@XmlElementRef(type=VSShort.class),
@XmlElementRef(type=VSString.class)
})
@XmlElementRef(type=VSValue.class)
public final T value;
/** units */
String units;
private String units;
/** state */
State state = State.Unknown;
@XmlElement
private State state = State.Unknown;
/**
* constructor
@ -80,30 +67,6 @@ public class Variable<T extends VariableServerFluent> implements Serializable, C
value = null;
}
/**
* sets this <code>Variable</code>'s value to <code>value</code>
*
* @param value the value to be set, expressed in Variable Server format
*/
public void setValue(String value) {
if (value.equals("BAD_REF")) {
state = State.Invalid;
}
else {
this.value.fromVariableServer(value);
state = State.Valid;
}
}
/**
* sets this <code>Variable</code>'s units to <code>units</code>
*
* @param units the units to be set
*/
public void setUnits(String units) {
this.units = units;
}
/**
* commands the Variable Server to set the variable's value to <code>value</code>
*
@ -145,6 +108,69 @@ public class Variable<T extends VariableServerFluent> implements Serializable, C
sendUnitsToVariableServer(units, variableServerConnection);
}
/**
* sets this <code>Variable</code>'s value to <code>value</code>
*
* @param value the value to be set, expressed in Variable Server format
*/
public void setValue(String value) {
if (value.equals("BAD_REF")) {
state = State.Invalid;
}
else {
this.value.fromVariableServer(value);
state = State.Valid;
}
}
/**
* returns the value
*
* @return the value
*/
public T getValue() {
return value;
}
/**
* sets this <code>Variable</code>'s units to <code>units</code>
*
* @param units the units to be set
*/
public void setUnits(String units) {
this.units = units;
}
/**
* returns the units
*
* @return the units
*/
public String getUnits() {
return units;
}
/**
* provided for JAXB compatibility
*/
private void setState(State state) {
this.state = state;
}
/**
* returns the state
*
* @return the state
*/
public State getState() {
return state;
}
@Override
public String toString() {
return name;
}
/**
* Equality among <code>Variable</code>s requires only that their names
* be equal as implemented by <code>String.equals</code>.
@ -169,43 +195,6 @@ public class Variable<T extends VariableServerFluent> implements Serializable, C
return name.hashCode();
}
/**
* returns the value
*
* @return the value
*/
public T getValue() {
return value;
}
/**
* returns the state
*
* @return the state
*/
public State getState() {
return state;
}
/**
* returns the name
*
* @return the name
*/
public String getName() {
return name;
}
/**
* returns the units
*
* @return the units
*/
@XmlElement(required = true)
public String getUnits() {
return units;
}
@Override
@SuppressWarnings("unchecked")
public Variable<T> clone() {
@ -220,9 +209,4 @@ public class Variable<T extends VariableServerFluent> implements Serializable, C
}
}
@Override
public String toString() {
return name;
}
}

View File

@ -46,7 +46,7 @@ public class VariableTracker extends SwingWorker<Void, String[]> {
*/
public void add(Variable variable) throws IOException {
if (variables.add(variable)) {
variableServerConnection.add(variable.name, variable.units);
variableServerConnection.add(variable.name, variable.getUnits());
}
}
@ -56,7 +56,7 @@ public class VariableTracker extends SwingWorker<Void, String[]> {
* @param variable the variable to stop tracking
*/
public void remove(Variable variable) throws IOException {
variableServerConnection.remove(variable.getName());
variableServerConnection.remove(variable.name);
variables.remove(variable);
}

View File

@ -138,7 +138,7 @@ public class StripChart extends JXPanel {
settingsPanel = new JXPanel(new GridBagLayout()) {{
final ValueAxis domainAxis = plot.getDomainAxis();
domainAxis.setLabel(domainVariable.getName());
domainAxis.setLabel(domainVariable.name);
final JRadioButton allRadioButton = new JRadioButton(new AbstractAction() {
{

View File

@ -70,7 +70,7 @@ public class StripChartManager {
Double.parseDouble(variable.getValue().toVariableServer());
}
catch (NumberFormatException numberFormatException) {
throw new IllegalArgumentException(variable.getName() + " cannot be parsed as a double.\n" +
throw new IllegalArgumentException(variable.name + " cannot be parsed as a double.\n" +
numberFormatException, numberFormatException);
}

View File

@ -121,42 +121,11 @@ import trick.tv.VariableTable.Position;
*/
public class TVApplication extends RunTimeTrickApplication implements VariableListener {
@Deprecated
private enum Mode {ALL, STRIP, FIXED};
@Deprecated
private enum VariableType {FIXED, FLOATING, CHARACTER, STRING, BOOLEAN, ENUMERATION, UNKNOWN};
@Deprecated
private enum Format {
DECIMAL("Decimal"),
OCTAL("Octal"),
HEXIDECIMAL("Hexidecimal"),
BOOLEAN("Boolean"),
ENUMERATION("Enumeration"),
STRING("String"),
CHARACTER("Character"),
UNKNOWN("Unknown");
private String name;
private Format(String name) {
this.name = name;
}
@Override
public String toString() {
return name;
}
}
/** simulation time tic value */
double timeTicValue;
/** simulation time tic count */
VSLong timeTicCount = new VSLong();
VSLong timeTicCount = new VSLong(0);
/** simulation time */
protected Variable<TVDouble> simulationTime =
@ -1262,7 +1231,7 @@ public class TVApplication extends RunTimeTrickApplication implements VariableLi
@SuppressWarnings("unchecked") // I know what I'm doing.
protected void addVariable(Variable<? extends TrickViewFluent> variable, boolean applyDefaults) {
// TV relies on time_tics being the first tracked variable, so don't let users manipulate it.
if (!variable.getName().equals("trick_sys.sched.time_tics")) {
if (!variable.name.equals("trick_sys.sched.time_tics")) {
try {
if (applyDefaults || variable.getValue().getFormat() == null) {
variable.getValue().setFormat(Enum.valueOf(variable.getValue().getFormatClass(),
@ -1769,83 +1738,12 @@ public class TVApplication extends RunTimeTrickApplication implements VariableLi
*/
protected void openFile(File file, boolean display, boolean set) {
try {
openFileAsBinary(file, display, set);
restoreState((TVBean)unmarshaller.unmarshal(new StreamSource(file), TVBean.class).getValue(), display, set);
}
catch (Exception binaryException) {
try {
restoreState((TVBean)unmarshaller.unmarshal(new StreamSource(file), TVBean.class).getValue(), display, set);
}
catch (Exception exception) {
JOptionPane.showMessageDialog(getMainFrame(), exception,
"Failed to Restore State", JOptionPane.ERROR_MESSAGE);
exception.printStackTrace(System.err);
}
}
}
/**
* gets the value of the first descendent of the specified element with the specified tag name
*
* @return the value of the first descendent of the specified element with the specified tag name, or null
*/
@Deprecated
String getElementValue(Element element, String tag) {
NodeList nodeList = element.getElementsByTagName(tag);
if (nodeList.getLength() > 0) {
Node node = nodeList.item(0).getFirstChild();
if (node != null) {
return node.getNodeValue();
}
}
return null;
}
/**
* attempts to open the file a binary serialization, displaying and setting the variable as specified
*
* @param file the file to be opened
* @param display whether or not to replace the current variable table contents with those in the file
* @param set whether or not to send the values in the file to the Variable Server
*/
@SuppressWarnings("unchecked") // readObject returns an Object which must be cast
@Deprecated
protected void openFileAsBinary(File file, boolean display, boolean set)
throws IOException, ClassNotFoundException {
ObjectInputStream objectInputStream = new ObjectInputStream(new FileInputStream(file));
ArrayList<Variable<TrickViewFluent>> variables =
(ArrayList<Variable<TrickViewFluent>>)objectInputStream.readObject();
if (display) {
removeAllStripCharts();
removeAllVariables();
for (Variable<TrickViewFluent> variable : variables) {
addVariable(variable);
}
setCyclePeriod(((Double)objectInputStream.readObject()).doubleValue());
}
if (set && getConnectionState()) {
try {
for (Variable variable : variables) {
variable.sendValueToVariableServer(variableServerConnection);
}
}
catch (IOException ioException) {
disconnect(ioException);
}
}
if (display) {
try {
for (StripChart stripChart : stripChartManager.loadStripCharts(objectInputStream)) {
launchStripChart(stripChart, (Rectangle)objectInputStream.readObject());
}
}
catch (IllegalArgumentException illegalArgumentException) {
JOptionPane.showMessageDialog(getMainFrame(), illegalArgumentException,
"Strip Chart Error", JOptionPane.ERROR_MESSAGE);
}
catch (Exception exception) {
JOptionPane.showMessageDialog(getMainFrame(), exception,
"Failed to Restore State", JOptionPane.ERROR_MESSAGE);
exception.printStackTrace(System.err);
}
}
@ -1883,7 +1781,7 @@ public class TVApplication extends RunTimeTrickApplication implements VariableLi
Variable domainVariable = simulationTime;
for (Variable variable : tvBean.variables) {
if (variable.getName().equals(stripChartBean.domainVariable)) {
if (variable.name.equals(stripChartBean.domainVariable)) {
domainVariable = variable;
break;
}
@ -1892,7 +1790,7 @@ public class TVApplication extends RunTimeTrickApplication implements VariableLi
ArrayList<Variable> plottedVariables = new ArrayList<Variable>();
for (String plottedVariable : stripChartBean.plottedVariables) {
for (Variable variable : tvBean.variables) {
if (variable.getName().equals(plottedVariable)) {
if (variable.name.equals(plottedVariable)) {
plottedVariables.add(variable);
break;
}
@ -2126,7 +2024,7 @@ public class TVApplication extends RunTimeTrickApplication implements VariableLi
for (Variable variable : pendingVariables) {
// If any variables are indexable, launch the dialog.
if (pattern.matcher(variable.getName()).find()) {
if (pattern.matcher(variable.name).find()) {
northPanel.removeAll();
for (Variable<TrickViewFluent> var : pendingVariables) {
northPanel.add(new VariablePanel(var));
@ -2186,7 +2084,7 @@ public class TVApplication extends RunTimeTrickApplication implements VariableLi
public VariablePanel(Variable<TrickViewFluent> variable) {
super(new GridBagLayout());
this.variable = variable;
matcher = pattern.matcher(variable.getName());
matcher = pattern.matcher(variable.name);
add(new JXButton(new AbstractAction() {
{
putValue(NAME, "Remove");
@ -2204,7 +2102,7 @@ public class TVApplication extends RunTimeTrickApplication implements VariableLi
}));
add(Box.createHorizontalStrut(5));
segments = pattern.split(variable.getName());
segments = pattern.split(variable.name);
while (matcher.find()) {
int arraySize = Integer.parseInt(matcher.group());
indices.add(arraySize == 0 ? new IndexTextField() : new DoubleComboBox(arraySize));

View File

@ -85,9 +85,9 @@ public class TVBean {
public StripChartBean() {}
public StripChartBean(StripChart stripChart) {
domainVariable = stripChart.getDomainVariable().getName();
domainVariable = stripChart.getDomainVariable().name;
for (Variable variable : stripChart.getPlottedVariables()) {
plottedVariables.add(variable.getName());
plottedVariables.add(variable.name);
}
mode = stripChart.getMode();
fixedAutoRange = stripChart.getFixedAutoRange();

View File

@ -23,7 +23,7 @@ public class TVBoolean extends VSBoolean implements TrickViewFluent<TVBoolean.Fo
Boolean {
public String format(boolean value) {
return java.lang.Boolean.toString(value);
return value ? "True" : "False";
}
};
@ -89,7 +89,7 @@ public class TVBoolean extends VSBoolean implements TrickViewFluent<TVBoolean.Fo
@Override
public String toString() {
return format.format(value);
return format.format(getValue());
}
static class BooleanRenderer extends JCheckBox implements TableCellRenderer {

View File

@ -118,11 +118,13 @@ public class TVByte extends VSByte implements TrickViewFluent<TVByte.Format> {
}
};
public boolean unsigned = false;
public final boolean unsigned;
Format format = Format.Decimal;
public TVByte() {}
public TVByte() {
this(false);
}
public TVByte(boolean unsigned) {
this.unsigned = unsigned;
@ -130,6 +132,7 @@ public class TVByte extends VSByte implements TrickViewFluent<TVByte.Format> {
public TVByte(byte value) {
super(value);
unsigned = false;
}
public Class<Format> getFormatClass() {
@ -154,12 +157,12 @@ public class TVByte extends VSByte implements TrickViewFluent<TVByte.Format> {
@Override
public String toVariableServer() {
return Format.Decimal.format(value, unsigned);
return Format.Decimal.format(getValue(), unsigned);
}
@Override
public String toString() {
return format.format(value, unsigned);
return format.format(getValue(), unsigned);
}
}

View File

@ -96,7 +96,7 @@ public class TVDouble extends VSDouble implements TrickViewFluent<TVDouble.Forma
@Override
public String toString() {
return format.format(value);
return format.format(getValue());
}
}

View File

@ -18,18 +18,13 @@ import trick.common.utils.vs.VSValue;
import trick.sie.utils.SieEnumeration;
@XmlRootElement
public class TVEnumeration extends VSValue implements TrickViewFluent<TVEnumeration.Format> {
private static final long serialVersionUID = 4708597538833537404L;
public class TVEnumeration extends VSValue<String> implements TrickViewFluent<TVEnumeration.Format> {
@XmlType(name = "")
public enum Format {
Enumeration {
public String format(String value, SieEnumeration enumeration) {
if (enumeration == null) {
return "<error, reload me>";
}
for (String key : enumeration.pairs.keySet()) {
if (enumeration.pairs.get(key).equals(value)) {
return key;
@ -43,9 +38,6 @@ public class TVEnumeration extends VSValue implements TrickViewFluent<TVEnumerat
}
@XmlElement(required = true)
public String value;
@XmlElement(required = true)
@XmlIDREF
public final SieEnumeration enumeration;
@ -93,15 +85,15 @@ public class TVEnumeration extends VSValue implements TrickViewFluent<TVEnumerat
public TVEnumeration(SieEnumeration enumeration, String value) {
this.enumeration = enumeration;
this.value = value;
setValue(value);
}
public void fromVariableServer(String string) {
value = string;
setValue(string);
}
public String toVariableServer() {
return value;
return getValue();
}
public Class<Format> getFormatClass() {
@ -128,13 +120,9 @@ public class TVEnumeration extends VSValue implements TrickViewFluent<TVEnumerat
return enumeration;
}
public String getValue() {
return value;
}
@Override
public String toString() {
return format.format(value, enumeration);
return format.format(getValue(), enumeration);
}
}

View File

@ -96,7 +96,7 @@ public class TVFloat extends VSFloat implements TrickViewFluent<TVFloat.Format>
@Override
public String toString() {
return format.format(value);
return format.format(getValue());
}
}

View File

@ -99,11 +99,13 @@ public class TVInteger extends VSInteger implements TrickViewFluent<TVInteger.Fo
}
};
public boolean unsigned = false;
public final boolean unsigned;
Format format = Format.Decimal;
public TVInteger() {}
public TVInteger() {
this(false);
}
public TVInteger(boolean unsigned) {
this.unsigned = unsigned;
@ -111,6 +113,7 @@ public class TVInteger extends VSInteger implements TrickViewFluent<TVInteger.Fo
public TVInteger(int value) {
super(value);
unsigned = false;
}
public Class<Format> getFormatClass() {
@ -135,12 +138,12 @@ public class TVInteger extends VSInteger implements TrickViewFluent<TVInteger.Fo
@Override
public String toVariableServer() {
return Format.Decimal.format(value, unsigned);
return Format.Decimal.format(getValue(), unsigned);
}
@Override
public String toString() {
return format.format(value, unsigned);
return format.format(getValue(), unsigned);
}
}

View File

@ -100,11 +100,13 @@ public class TVLong extends VSLong implements TrickViewFluent<TVLong.Format> {
}
};
public boolean unsigned = false;
public final boolean unsigned;
Format format = Format.Decimal;
public TVLong() {}
public TVLong() {
this(false);
}
public TVLong(boolean unsigned) {
this.unsigned = unsigned;
@ -112,6 +114,7 @@ public class TVLong extends VSLong implements TrickViewFluent<TVLong.Format> {
public TVLong(long value) {
super(value);
unsigned = false;
}
public Class<Format> getFormatClass() {
@ -136,12 +139,12 @@ public class TVLong extends VSLong implements TrickViewFluent<TVLong.Format> {
@Override
public String toVariableServer() {
return Format.Decimal.format(value, unsigned);
return Format.Decimal.format(getValue(), unsigned);
}
@Override
public String toString() {
return format.format(value, unsigned);
return format.format(getValue(), unsigned);
}
}

View File

@ -99,11 +99,13 @@ public class TVShort extends VSShort implements TrickViewFluent<TVShort.Format>
}
};
public boolean unsigned = false;
public final boolean unsigned;
Format format = Format.Decimal;
public TVShort() {}
public TVShort() {
this(false);
}
public TVShort(boolean unsigned) {
this.unsigned = unsigned;
@ -111,6 +113,7 @@ public class TVShort extends VSShort implements TrickViewFluent<TVShort.Format>
public TVShort(short value) {
super(value);
unsigned = false;
}
public Class<Format> getFormatClass() {
@ -135,12 +138,12 @@ public class TVShort extends VSShort implements TrickViewFluent<TVShort.Format>
@Override
public String toVariableServer() {
return Format.Decimal.format(value, unsigned);
return Format.Decimal.format(getValue(), unsigned);
}
@Override
public String toString() {
return format.format(value, unsigned);
return format.format(getValue(), unsigned);
}
}

View File

@ -82,7 +82,7 @@ public class TVString extends VSString implements TrickViewFluent<TVString.Forma
@Override
public String toString() {
return format.format(value);
return format.format(getValue());
}
}

View File

@ -460,7 +460,7 @@ public class VariableTable extends JXTable {
Variable<? extends TrickViewFluent> variable = variables.get(rowIndex);
switch (columnIndex) {
case 0:
return variable.getName();
return variable.name;
case 1:
switch (variable.getState()) {
case Invalid:

View File

@ -1,177 +1,134 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema version="1.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="trick.tv"
xmlns="trick.tv"
elementFormDefault="qualified">
<xs:element name="vsValue" type="vsValue"/>
<xs:complexType name="bounds">
<xs:sequence>
<xs:complexType name="title">
<xs:sequence>
<xs:element name="text" type="xs:string"/>
<xs:element name="font" type="font"/>
<xs:element name="rgb" type="xs:int"/>
</xs:sequence>
</xs:complexType>
<xs:element name="lower">
<xs:simpleType>
<xs:restriction base="xs:decimal" />
</xs:simpleType>
</xs:element>
<xs:complexType name="font">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="style" type="xs:int"/>
<xs:element name="size" type="xs:int"/>
</xs:sequence>
</xs:complexType>
<xs:element name="upper">
<xs:simpleType>
<xs:restriction base="xs:decimal" />
</xs:simpleType>
</xs:element>
<xs:complexType name="range">
<xs:sequence>
<xs:element name="lower" type="xs:double"/>
<xs:element name="upper" type="xs:double"/>
</xs:sequence>
</xs:complexType>
</xs:sequence>
</xs:complexType>
<xs:complexType name="axis">
<xs:sequence>
<xs:element name="label" type="xs:string"/>
<xs:element name="font" type="font"/>
<xs:element name="rgb" type="xs:int"/>
<xs:element name="areTickMarksVisible" type="xs:boolean"/>
<xs:element name="areTickLabelsVisible" type="xs:boolean"/>
<xs:element name="tickLabelFont" type="font"/>
<xs:element name="tickLabelRgb" type="xs:int"/>
<xs:element name="range" type="range"/>
</xs:sequence>
</xs:complexType>
<!-- The root element, representing an instance of Trick View. -->
<xs:element name="trickview">
<xs:complexType name="bounds">
<xs:sequence>
<xs:element name="x" type="xs:int"/>
<xs:element name="y" type="xs:int"/>
<xs:element name="width" type="xs:int"/>
<xs:element name="height" type="xs:int"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="stripChart">
<xs:sequence>
<xs:element name="domainVariable" type="xs:string"/>
<xs:element name="plottedVariable" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="mode" type="mode"/>
<xs:element name="fixedAutoRange" type="xs:double"/>
<xs:element name="areLinesVisible" type="xs:boolean"/>
<xs:element name="arePointsVisible" type="xs:boolean"/>
<xs:element name="isLegendVisible" type="xs:boolean"/>
<xs:element name="areSettingsVisible" type="xs:boolean"/>
<xs:element name="isAntiAliased" type="xs:boolean"/>
<xs:element name="isBackgroundSet" type="xs:boolean"/>
<xs:element name="backgroundRgb" type="xs:int"/>
<xs:element name="title" type="title" minOccurs="0"/>
<xs:element name="isHorizontal" type="xs:boolean"/>
<xs:element name="outlineRgb" type="xs:int"/>
<xs:element name="plotBackgroundRgb" type="xs:int"/>
<xs:element name="domainAxis" type="axis"/>
<xs:element name="rangeAxis" type="axis"/>
<xs:element name="bounds" type="bounds"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="tvBean">
<xs:sequence>
<xs:element name="cyclePeriod" type="xs:double"/>
<xs:element name="variable" type="variable" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="stripChart" type="stripChart" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="enumeration" type="enumeration" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="variable">
<xs:sequence>
<xs:element name="name" type="xs:string" minOccurs="0"/>
<xs:element ref="vsValue"/>
<xs:element name="state" type="state" minOccurs="0"/>
<xs:element name="units" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="vsValue" abstract="true">
<xs:sequence>
<xs:element name="value" type="xs:anyType" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="enumeration">
<xs:sequence>
<xs:element name="name" type="xs:ID"/>
<xs:element name="pairs">
<xs:complexType>
<xs:sequence>
<!-- Determines if variables are automatically set when loaded. -->
<xs:element name="set" type="xs:boolean" minOccurs="0"/>
<!-- Period at which variables are updated. -->
<xs:element name="cycle" minOccurs="0">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:minInclusive value="0"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<!-- Represents a single variable in the Variable Table. -->
<xs:element name="variable" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="value" type="xs:string"/>
<xs:element name="units" type="xs:string"/>
<xs:element name="format">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="Decimal"/>
<xs:enumeration value="Octal"/>
<xs:enumeration value="Hexidecimal"/>
<xs:enumeration value="Boolean"/>
<xs:enumeration value="Enumeration"/>
<xs:enumeration value="String"/>
<xs:enumeration value="Character"/>
<xs:enumeration value="Unknown"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="type">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="FIXED"/>
<xs:enumeration value="FLOATING"/>
<xs:enumeration value="CHARACTER"/>
<xs:enumeration value="STRING"/>
<xs:enumeration value="BOOLEAN"/>
<xs:enumeration value="ENUMERATION"/>
<xs:enumeration value="UNKNOWN"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="enumeration" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<!-- Represents a Stripchart's state. -->
<xs:element name="stripchart" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="title" type="xs:string"/>
<xs:element name="dependentVariable" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
<xs:element name="domainVariable" type="xs:string"/>
<xs:element name="mode">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="ALL"/>
<xs:enumeration value="STRIP"/>
<xs:enumeration value="FIXED"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="axes" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="domain" type="bounds"/>
<xs:element name="range" type="bounds"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="scrollWidth">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:minInclusive value="0"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="lines" type="xs:boolean"/>
<xs:element name="points" type="xs:boolean"/>
<xs:element name="legend" type="xs:boolean"/>
<xs:element name="bounds" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="x">
<xs:simpleType>
<xs:restriction base="xs:decimal" />
</xs:simpleType>
</xs:element>
<xs:element name="y">
<xs:simpleType>
<xs:restriction base="xs:decimal" />
</xs:simpleType>
</xs:element>
<xs:element name="width">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:minInclusive value="0"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="height">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:minInclusive value="0"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:sequence>
<xs:element name="entry" minOccurs="0" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="key" minOccurs="0" type="xs:string"/>
<xs:element name="value" minOccurs="0" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:element>
</xs:sequence>
</xs:complexType>
<xs:simpleType name="mode">
<xs:restriction base="xs:string">
<xs:enumeration value="All"/>
<xs:enumeration value="Strip"/>
<xs:enumeration value="Fixed"/>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="state">
<xs:restriction base="xs:string">
<xs:enumeration value="Unknown"/>
<xs:enumeration value="Invalid"/>
<xs:enumeration value="Valid"/>
</xs:restriction>
</xs:simpleType>
</xs:schema>