target
+src/main/doc
test-output
*.iml
.project
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<logback.version>1.1.7</logback.version>
<slf4j.version>1.7.21</slf4j.version>
- </properties>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+ </properties>
<dependencies>
+ <dependency>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.10.4</version>
+ </dependency>
<!-- logging -->
<dependency>
<groupId>org.slf4j</groupId>
</plugin>
</plugins>
</build>
-
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ <version>2.10.3</version>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-project-info-reports-plugin</artifactId>
+ <version>2.8</version>
+ </plugin>
+ </plugins>
+ </reporting>
</project>
*
* <pre>
* Syntax:
- * <expr> ::= <term> {<operator> <operand}*
- * <term> ::= '(' <expr> ')' | <constant> | <variable>
- * <constant> ::= <number>
- * <operator> ::= '+' | '-' | '*' | '/' | '%' | '**' | '='
+ * <expr> ::= <term> {<operator> <operand}*
+ * <term> ::= '(' <expr> ')' | <constant> | <variable>
+ * <constant> ::= <number>
+ * <operator> ::= '+' | '-' | '*' | '/' | '%' | '**' | '='
* </pre>
*
* @author hm
* formula text
* @return the result of the formula as long
* @throws ExpressionException
+ * illegal type
*/
public static long asLong(final String text) throws ExpressionException {
final Variant result = Expression.getInstance().expr(text);
* Calculates the value of the expression.
*
* <pre>
- * <expr> ::= <term> { <operator> <term> }*
+ * <expr> ::= <term> { <operator> <term> }*
* </pre>
*
* @return the value of the expression stored in a token
* @throws ParserException
+ * parser error found
*/
public Variant expr() throws ParserException {
final int entryStackLevel = this.operators.size();
* formula text
* @return the value of the expression
* @throws ParserException
+ * parser error detected
*/
public Variant expr(String text) throws ParserException {
final Variant rc = reset(text).expr();
* Calculates the value of the expression.
*
* <pre>
- * <term> ::= '(' <expr> ')' | <constant> | <variable> | <sign> <term>
- * <sign> ::= '+' | '-'
+ * <term> ::= '(' <expr> ')' | <constant> | <variable> | <sign> <term>
+ * <sign> ::= '+' | '-'
* </pre>
*
* @return the value of the term
* @throws ParserException
- * @throws VariantException
+ * parser error found
*/
public Variant term() throws ParserException {
Variant rc = null;
*
* @return the next token
* @throws ParserException
+ * parser error found
*/
public Token nextNotSpaceToken() throws ParserException {
Token token;
*
* @return the next token
* @throws ParserException
+ * parser error found
*/
public Token nextToken() throws ParserException {
final Token token = this.lastToken = this.tokens[this.indexToken++];
}
/**
- * Sets the token as identifier.
+ * Sets the token as end of string.
*
- * @param id
- * name of the identifier
- * @param delimiter
* @return the instance (for chaining)
*/
public Token setEndOfString() {
*
* @param id
* name of the identifier
- * @param delimiter
* @return the instance (for chaining)
*/
public Token setId(String id) {
/**
* Sets the token as string.
*
- * @param spaces
- * the space sequence
+ * @param string
+ * the string with replaced meta characters (like '\n')
+ * @param rawString
+ * the string as in source code inclusive delimiters
+ * @param delimiter
+ * the delimiter in the source code / input text
* @return the instance (for chaining)
*/
public Token setString(String string, String rawString, char delimiter) {
}
/**
- * Sets the token as space sequence.
+ * Sets the token as unknown type.
*
- * @param spaces
- * the space sequence
+ * @param info
+ * the unknown input text not belonging to other token types
* @return the instance (for chaining)
*/
public Token setUnknown(String info) {
* Assigns a new value to the instance.
*
* @param value
+ * the value to assign
*/
public void assign(Variant value) {
this.value.redefine(value);
/**
* Constructor.
*
- * @param longValue
+ * @param value
* the instance becomes the type INTEGER with this value
*/
public Variant(double value) {
public boolean isBasicType(DataType type) {
Variant value = this;
while (value.isType(DataType.VARIABLE)) {
- value = this.variableValue.getValue();
+ value = value.variableValue.getValue();
}
final boolean rc = value.isType(type);
return rc;
public Variant lValue() {
Variant rc = this;
while (rc.isType(DataType.VARIABLE)) {
- rc = this.variableValue.getValue();
+ rc = rc.variableValue.getValue();
if (!rc.isType(DataType.VARIABLE)) {
rc = rc.copy();
break;
protected Variant lValueImmutable() {
Variant rc = this;
while (rc.isType(DataType.VARIABLE)) {
- rc = this.variableValue.getValue();
+ rc = rc.variableValue.getValue();
}
return rc;
}
}
/**
- * Takes the datat ype from another instance.
+ * Takes the data type from another instance.
*
* @param source
+ * the source to copy
* @return the instance (for chaining)
*/
public Variant redefine(Variant source) {
*
* <pre>
* ----------------------------
- * |<-- vertic. scale
+ * |<-- vertic. scale
* |
* |
* |
/**
* Adds a channel to the sheet.
*
- * @param channel
- * the channel to add
+ * @param data
+ * the data for the channel (for displaying)
* @return the instance (for chaining)
*/
public MultiChannelSheet addChannel(IPairData data) {
* hostname of the address to compare
* @param port
* port of the address to compare
- * @return
+ * @return <i>true</i>: the instance have the same host/port as given
*/
public boolean sameAddress(String host, int port) {
return host.equals(this.host) && port == this.port;
/**
*
- * @param buffer
+ * @param message
* bytes to send
*/
public void send(DynBytes message) {
/**
* Starts the graphical user interface client.
+ *
+ * @param host
+ * the server name
+ * @param port
+ * the ip port: 1..65535
*/
public static void gui(String host, int port) {
final ControlCenter center = new ControlCenter();
* @param args
* program arguments
*/
- public static void main(String... args) throws Exception {
+ public static void main(String... args) {
Client.logger.info("start");
int port = 15000;
final String host = "127.0.0.1";
* Constructor.
*
* @param host
+ * the server name
* @param port
+ * the ip port: 1..65535
*/
public GpioClient(String host, int port) {
super(host, port);
*
* @param pin
* pin for output
- * @param clock
- * minimal time slice of the pwm period in microseconds
- * @param steps
- * number of time slices
+ * @param period
+ * the period of the pwm signal in microseconds
* @param startValue
* value of the first PWM period (in steps)
* @param function
* Finds the item by name
*
* @param name
- * @return
+ * the name of the pin to search
+ * @return <i>null</i>: not found<br>
+ * otherwise: the pin number
*/
public static PinNumber find(String name) {
PinNumber rc = null;
private OutputPwmPanel panelOutputPwmData;
private InputPanel panelInputData;
private InputPwmPanel panelInputPwmData;
+ private JPanel panelUndef;
private final ControlCenter center;
/**
+ * Constructor.
*
* @param center
- * @return
+ * the parent (control center)
*/
public GPIOSettings(ControlCenter center) {
super(new FlowLayout(FlowLayout.LEADING));
return this.panelOutputPwmData;
}
+ /**
+ * @return the panelUndef
+ */
+ public JPanel getPanelUndef() {
+ return this.panelUndef;
+ }
+
/**
* Populates the panel with the widgets.
*/
this.panelInputData.setVisible(false);
add(this.panelInputPwmData = new InputPwmPanel(this.center, panelPinData));
this.panelInputPwmData.setVisible(false);
+ add(this.panelUndef = new JPanel(new MigLayout("fillx", "[left]rel[grow,fill]", "[]7[]")));
+ this.panelUndef.setVisible(true);
+ this.panelUndef.add(new JLabel(I18N.tr("The pin is not initialized for input/output")), "wrap");
+ this.panelUndef.add(new JLabel(I18N.tr("Select an input/output mode")));
}
}
final int index = this.comboMode.getSelectedIndex();
if (this.currentPin.getMode() != index) {
final boolean isOutputPWM = index == PinButton.MODE_OUTPUT_PWM;
- this.logger.debug(
- "actionPerformed(); changing mode: " + index + " isOutPwm: " + String.valueOf(isOutputPWM));
this.currentPin.setMode(index);
boolean visible = index == PinButton.MODE_OUTPUT_BLINK;
this.parent.getGpioSettings().getPanelOutputBlinkData().setVisible(visible);
this.parent.getGpioSettings().getPanelInputData().setVisible(visible);
visible = index == PinButton.MODE_INPUT_PWM;
this.parent.getGpioSettings().getPanelInputPwmData().setVisible(visible);
+ this.parent.getGpioSettings().getPanelUndef().setVisible(index == PinButton.MODE_UNDEF);
}
}
}
* Constructor.
*
* @param capacity
+ * the capacity at the start
* @param blocksize
+ * the minimum size while enlarging the buffer
* @param minX
+ * the minimum of the x coordinate
* @param maxX
+ * the maximum ot the x coordinate
* @param dataWidth
+ * the number of bytes of one item: 1..8
*/
public BytePairData(int capacity, int blocksize, double minX, double maxX, int dataWidth) {
super(capacity, blocksize);
* @param name
* the name to set
*/
+ @Override
public void setName(String name) {
this.name = name;
}
/**
* Convert a (binary) buffer content into a readable form.
*
+ * @param buffer
+ * the buffer with the content to dump
* @param offset
* first index to dump: 0..length-1
* @param length
* Constructor.
*
* @param capacity
- * the initial capacity of the buffer. If <= 0 it will be set to
- * 16
+ * the initial capacity of the buffer. If <= 0 it will be set
+ * to 16
* @param blocksize
- * the initial blocksize. If <= 0 it will be set to 1
+ * the initial blocksize. If lower or equal to 0 it will be set
+ * to 1
*/
public DynBytes(int capacity, int blocksize) {
if (capacity <= 0) {
* the byte array to add
* @param offset
* the first index of <i>buffer</i> to add<br>
- * <i>0 <= offset < buffer.length</i><br>
+ * <i>0 <= offset < buffer.length</i><br>
* If offset is out of range nothing will be done
* @param length
* the number of bytes to add<br>
* the first index of the integer
* @param width
* the number of bytes of the integer
+ * @param defaultValue
+ * the return value if an error occurres, e.g. index error
* @return the value of the integer stored as little endian
*/
public int intAsLittleEndian(int index, int width, int defaultValue) {
* the first index of the integer
* @param width
* the number of bytes of the integer
+ * @param defaultValue
+ * the return value if an error occurres, e.g. index error
* @return the value of the integer stored as little endian
*/
public long longAsLittleEndian(int index, int width, long defaultValue) {
* Sets the blocksize.
*
* @param blocksize
- * the new blocksize. Values < 1 will be set to 1
+ * the new blocksize. Values < 1 will be set to 1
*/
public void setBlocksize(int blocksize) {
this.blocksize = blocksize;
* Sets the current length.
*
* @param length
- * < 0: the length is set to 0<br>
+ * < 0: the length is set to 0<br>
* otherwise: the new length
* @return the instance (for chaining)
*/
* text to translate
* @return the translated text
*/
- public static String tr(final String key) {
- return key;
+ public static String tr(final String text) {
+ return text;
}
}
*
* @param data
* data to inspect
- * @return the minimal of the y values
+ * @param minMax
+ * the buffer for the result
+ * @return <i>minMax</i> with the minimum and the maximum values
*/
public static DoublePair minMaxY(IPairData data, DoublePair minMax) {
double min = data.getY(0);
package de.republib.expr;
import org.testng.Assert;
+import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
public class ExpressionTest {
+ @BeforeSuite
+ public static void beforeSuite() {
+ System.out.println("Expression started");
+ }
@Test
public void shouldConstruct() throws ParserException {
package de.republib.expr;
import org.testng.Assert;
+import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
public class ScannerTest {
+ @BeforeSuite
+ public static void beforeSuite() {
+ System.out.println("Scanner started");
+ }
+
@Test
public void shouldConstruct() {
final Scanner scanner = new Scanner("");
package de.republib.expr;
import org.testng.Assert;
+import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
public class VariableTest {
+ @BeforeSuite
+ public static void beforeSuite() {
+ System.out.println("Variable started");
+ }
@Test
public void shouldAssign() {
package de.republib.expr;
import org.testng.Assert;
+import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
public class VariantTest extends Variant {
+ @BeforeSuite
+ public static void beforeSuite() {
+ System.out.println("Variant started");
+ }
+
VariantTest() {
super("Test");
}
Assert.assertTrue(val1.isType(DataType.VARIABLE));
Assert.assertTrue(val1.getVariableValue().getValue().isType(DataType.VARIABLE));
Assert.assertTrue(val1.isBasicType(DataType.LONG));
+ Assert.assertTrue(val1.lValue().isType(DataType.LONG));
+ Assert.assertEquals(val1.lValue().getLongValue(), 44L);
+ // changing lvalue() does not change the variable value:
+ val1.lValue().redefineLong(77L);
+ // Test now the unchanged variable value:
+ Assert.assertTrue(val1.lValueImmutable().isBasicType(DataType.LONG));
+ Assert.assertEquals(val1.lValueImmutable().getLongValue(), 44L);
}
@Test
import javax.swing.JTextField;
import org.testng.Assert;
+import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
public class GuiUtilsTest {
+ @BeforeSuite
+ public static void beforeSuite() {
+ System.out.println("GuiUtils started");
+ }
+
@Test
public void numberOf() {
final JTextField field = new JTextField();
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
+import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
/**
public class BytePairDataTest {
static Logger logger = LoggerFactory.getLogger(BytePairDataTest.class);
+ @BeforeSuite
+ public static void beforeSuite() {
+ System.out.println("BytePairData started");
+ }
+
@Test
public void BytePairData() {
for (int width = 1; width <= 8; width++) {
package de.republib.util;
import org.testng.Assert;
+import org.testng.annotations.BeforeSuite;
/**
* Tests the class <i>DynBytes</i>.
*/
public class DynBytesTest {
+ @BeforeSuite
+ public static void beforeSuite() {
+ System.out.println("DynBytes started");
+ }
+
@org.testng.annotations.BeforeMethod
public void setUp() throws Exception {
package de.republib.util;
import org.testng.Assert;
+import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
public class FunctionPairDataTest {
+ @BeforeSuite
+ public static void beforeSuite() {
+ System.out.println("FunctionPairData started");
+ }
void checkFunctionCos() {
final FunctionPairData data = new FunctionPairData(MathFunction.COS, 0.0, 4 * Math.PI / 4, 4);
package de.republib.util;
import org.testng.Assert;
+import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
public class PairDataTest {
+ @BeforeSuite
+ public static void beforeSuite() {
+ System.out.println("PairData started");
+ }
@Test
public void maxY() {
package de.republib.util;
import org.testng.Assert;
+import org.testng.annotations.BeforeSuite;
import org.testng.annotations.Test;
public class StringUtilsTest {
+ @BeforeSuite
+ public static void beforeSuite() {
+ System.out.println("StringUtils started");
+ }
private void checkPrec1() {
final double value = 1234567.77;