Formatting cleanup

This commit is contained in:
Ziver Koc 2021-03-23 21:54:29 +01:00
parent c7e286f51e
commit 5a1be3c2e4
50 changed files with 283 additions and 282 deletions

View file

@ -86,7 +86,7 @@ public class TellstickParser {
} else if (data.startsWith("+V")) {
if (data.length() > 2)
firmwareVersion = Integer.parseInt(data.substring(2));
}else {
} else {
logger.severe("Unknown prefix: " + data);
}
@ -96,7 +96,7 @@ public class TellstickParser {
/**
* This method blocks until a send command confirmation is received.
*/
public synchronized void waitSendConformation(){
public synchronized void waitSendConformation() {
try {
this.wait();
} catch (InterruptedException e) {

View file

@ -138,13 +138,13 @@ public class TellstickSerialComm implements Runnable,
private String readLine() throws IOException {
StringBuilder str = new StringBuilder(50);
int c;
while((c = in.read()) >= 0){
while ((c = in.read()) >= 0) {
switch(c) {
case -1:
return null;
case '\n':
case '\r':
if(str.length() > 0)
if (str.length() > 0)
return str.toString();
break;
default:
@ -153,7 +153,7 @@ public class TellstickSerialComm implements Runnable,
}
return str.toString();
}
protected void handleLine(String data){
protected void handleLine(String data) {
List<TellstickDecodedEntry> decodeList = parser.decode(data);
for (TellstickDecodedEntry entry : decodeList) {
if (entry.getData().getTimestamp() < 0)
@ -191,7 +191,7 @@ public class TellstickSerialComm implements Runnable,
@Override
public void send(HalEventConfig deviceConfig, HalEventData deviceData) {
if(deviceConfig instanceof TellstickDevice) {
if (deviceConfig instanceof TellstickDevice) {
TellstickDevice tellstickDevice = (TellstickDevice) deviceConfig;
TellstickProtocol prot = TellstickParser.getProtocolInstance(
tellstickDevice.getProtocolName(),
@ -208,7 +208,7 @@ public class TellstickSerialComm implements Runnable,
if (data == null)
return;
try {
for(int i=0; i<data.length();i++)
for (int i=0; i<data.length();i++)
out.write(0xFF & data.charAt(i));
out.write('\n');
out.flush();
@ -223,15 +223,15 @@ public class TellstickSerialComm implements Runnable,
@Override
public void register(HalDeviceConfig deviceConfig) {
if(deviceConfig instanceof TellstickDevice)
if (deviceConfig instanceof TellstickDevice)
registeredDevices.add(deviceConfig);
else throw new IllegalArgumentException(
"Device config is not an instance of " + TellstickDevice.class + ": " + deviceConfig.getClass());
}
public <T> List<T> getRegisteredDevices(Class<T> clazz){
public <T> List<T> getRegisteredDevices(Class<T> clazz) {
ArrayList<T> list = new ArrayList<>();
for (HalDeviceConfig device : registeredDevices){
for (HalDeviceConfig device : registeredDevices) {
if (clazz.isAssignableFrom(device.getClass()))
list.add((T) device);
}
@ -254,7 +254,7 @@ public class TellstickSerialComm implements Runnable,
}
public static TellstickSerialComm getInstance(){
public static TellstickSerialComm getInstance() {
return instance;
}
}

View file

@ -18,28 +18,28 @@ public class TellstickCmdExtendedSend implements TellstickCmd{
* @param timing set first timing in us
* @return an instance of itself
*/
public TellstickCmdExtendedSend setPulls0Timing(int timing){
public TellstickCmdExtendedSend setPulls0Timing(int timing) {
setPullsTiming(0, timing); return this;
}
/**
* @param timing set second timing in us
* @return an instance of itself
*/
public TellstickCmdExtendedSend setPulls1Timing(int timing){
public TellstickCmdExtendedSend setPulls1Timing(int timing) {
setPullsTiming(1, timing); return this;
}
/**
* @param timing set third timing in us
* @return an instance of itself
*/
public TellstickCmdExtendedSend setPulls2Timing(int timing){
public TellstickCmdExtendedSend setPulls2Timing(int timing) {
setPullsTiming(2, timing); return this;
}
/**
* @param timing set fourth timing in us
* @return an instance of itself
*/
public TellstickCmdExtendedSend setPulls3Timing(int timing){
public TellstickCmdExtendedSend setPulls3Timing(int timing) {
setPullsTiming(3, timing); return this;
}
/**
@ -47,29 +47,29 @@ public class TellstickCmdExtendedSend implements TellstickCmd{
* @param timing set first pulls length in us between 0-2550
* @return an instance of itself
*/
private void setPullsTiming(int i, int timing){ // TODO: should probably have high and low timing to be called pulls
private void setPullsTiming(int i, int timing) { // TODO: should probably have high and low timing to be called pulls
if (0 > timing || timing > 2550)
throw new IllegalArgumentException("Invalid pulls "+timing+" must be between 0-2550" );
cmd[OFFSET_TIMINGS + i] = (byte)(timing/10);
}
public TellstickCmdExtendedSend addPulls0(){
public TellstickCmdExtendedSend addPulls0() {
addPulls(0); return this;
}
public TellstickCmdExtendedSend addPulls1(){
public TellstickCmdExtendedSend addPulls1() {
addPulls(1); return this;
}
public TellstickCmdExtendedSend addPulls2(){
public TellstickCmdExtendedSend addPulls2() {
addPulls(2); return this;
}
public TellstickCmdExtendedSend addPulls3(){
public TellstickCmdExtendedSend addPulls3() {
addPulls(3); return this;
}
private void addPulls(int i) {
if (OFFSET_PULSES+(length/4) > cmd.length)
throw new IndexOutOfBoundsException("Maximum length "+cmd.length+" reached");
switch (length % 4){
switch (length % 4) {
case 0:
cmd[OFFSET_PULSES+ length/4] |= 0b1100_0000 & (i << 6); break;
case 1:
@ -83,7 +83,7 @@ public class TellstickCmdExtendedSend implements TellstickCmd{
}
public String getTransmissionString(){
public String getTransmissionString() {
cmd[0] = 'T';
cmd[OFFSET_PULSE_LENGTH] = (byte)length;
cmd[OFFSET_PULSES+(int)Math.ceil(length/4.0)] = '+';

View file

@ -27,7 +27,7 @@ public class TellstickCmdSend implements TellstickCmd{
}
public String getTransmissionString(){
public String getTransmissionString() {
cmd[0] = 'S';
cmd[OFFSET_PULSES+length] = '+';
return new String(cmd, 0, OFFSET_PULSES+length+1, StandardCharsets.ISO_8859_1);

View file

@ -91,8 +91,8 @@ public class NexaSelfLearning implements TellstickDevice, HalEventConfig, Tellst
}
@Override
public boolean equals(Object obj){
if(obj instanceof NexaSelfLearning)
public boolean equals(Object obj) {
if (obj instanceof NexaSelfLearning)
return ((NexaSelfLearning) obj).house == house &&
((NexaSelfLearning) obj).group == group &&
((NexaSelfLearning)obj).unit == unit;
@ -100,13 +100,13 @@ public class NexaSelfLearning implements TellstickDevice, HalEventConfig, Tellst
}
@Override
public boolean equalsGroup(TellstickDeviceGroup obj) {
if(obj instanceof NexaSelfLearning)
if (obj instanceof NexaSelfLearning)
return ((NexaSelfLearning) obj).house == house &&
(((NexaSelfLearning) obj).group || group );
return false;
}
@Override
public String toString(){
public String toString() {
return "house:" + house +
", group:" + group +
", unit:" + unit;

View file

@ -81,14 +81,14 @@ public class NexaSelfLearningDimmer implements TellstickDevice, HalEventConfig {
}
@Override
public boolean equals(Object obj){
if(obj instanceof NexaSelfLearningDimmer)
public boolean equals(Object obj) {
if (obj instanceof NexaSelfLearningDimmer)
return ((NexaSelfLearningDimmer) obj).house == house &&
((NexaSelfLearningDimmer)obj).unit == unit;
return false;
}
@Override
public String toString(){
public String toString() {
return "house:" + house +
", unit:" + unit;
}

View file

@ -90,14 +90,14 @@ public class Oregon0x1A2D implements TellstickDevice, HalSensorConfig {
}
@Override
public boolean equals(Object obj){
if(obj instanceof Oregon0x1A2D)
public boolean equals(Object obj) {
if (obj instanceof Oregon0x1A2D)
return ((Oregon0x1A2D)obj).address == this.address &&
((Oregon0x1A2D)obj).sensorType == this.sensorType;
return false;
}
@Override
public String toString(){
public String toString() {
return "address:" + address + ",sensorType:" + sensorType;
}

View file

@ -27,7 +27,7 @@ public class Oregon0x1A2DProtocol extends TellstickProtocol {
public Oregon0x1A2DProtocol(){
public Oregon0x1A2DProtocol() {
super(PROTOCOL, MODEL);
}
@ -84,7 +84,7 @@ public class Oregon0x1A2DProtocol extends TellstickProtocol {
OregonSensorType sensorType = device.getSensorType();
if (sensorType == null)
sensorType = OregonSensorType.POWER;
switch (sensorType){
switch (sensorType) {
case HUMIDITY:
dataObj = new HumiditySensorData(humidity, timestamp);
humidityFound = true;

View file

@ -27,7 +27,7 @@ public class TelstickSerialCommNexaOnOffTest {
OnOffEventData nexaData = new OnOffEventData();
System.out.println("Up and Running");
while(true) {
while (true) {
Thread.sleep(2000);
nexaData.turnOn();
nexaDevice.setUnit(0);