Prepare merge to module exec.connected in mimis
This commit is contained in:
@@ -1,97 +1,97 @@
|
|||||||
package dummy;
|
package dummy;
|
||||||
|
|
||||||
import lirc.Lirc.Color;
|
import lirc.Lirc.Color;
|
||||||
import lirc.Lirc.Direction;
|
import lirc.Lirc.Direction;
|
||||||
import lirc.Lirc.Number;
|
import lirc.Lirc.Number;
|
||||||
import lirc.Lirc.Signal;
|
import lirc.Lirc.Signal;
|
||||||
import base.work.Listen;
|
import base.work.Listen;
|
||||||
|
|
||||||
import com.github.boukefalos.ibuddy.iBuddy;
|
import com.github.boukefalos.ibuddy.iBuddy;
|
||||||
import com.github.boukefalos.lirc.Lirc;
|
import com.github.boukefalos.lirc.Lirc;
|
||||||
import com.github.boukefalos.lirc.LircButton;
|
import com.github.boukefalos.lirc.LircButton;
|
||||||
import com.github.boukefalos.lirc.util.SignalObject;
|
import com.github.boukefalos.lirc.util.SignalObject;
|
||||||
|
|
||||||
public class Dummy extends Listen<Object> {
|
public class Dummy extends Listen<Object> {
|
||||||
protected Lirc lirc;
|
protected Lirc lirc;
|
||||||
protected iBuddy iBuddy;
|
protected iBuddy iBuddy;
|
||||||
|
|
||||||
public Dummy(Lirc lirc, iBuddy iBuddy) {
|
public Dummy(Lirc lirc, iBuddy iBuddy) {
|
||||||
this.lirc = lirc;
|
this.lirc = lirc;
|
||||||
this.iBuddy = iBuddy;
|
this.iBuddy = iBuddy;
|
||||||
lirc.register(this);
|
lirc.register(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void start() {
|
public void start() {
|
||||||
lirc.start();
|
lirc.start();
|
||||||
super.start();
|
super.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void input(SignalObject<Object> signalObject) {
|
public void input(SignalObject<Object> signalObject) {
|
||||||
Signal signal = signalObject.signal;
|
Signal signal = signalObject.signal;
|
||||||
Object object = signalObject.object;
|
Object object = signalObject.object;
|
||||||
System.out.println(object);
|
System.out.println(object);
|
||||||
try {
|
try {
|
||||||
// Move these mappings to config file?
|
// Move these mappings to config file?
|
||||||
if (object instanceof LircButton) {
|
if (object instanceof LircButton) {
|
||||||
LircButton lircButton = (LircButton) object;
|
LircButton lircButton = (LircButton) object;
|
||||||
String code = lircButton.code;
|
String code = lircButton.code;
|
||||||
logger.error(signal.name() + " : " + code + " @ " + lircButton.remote);
|
logger.error(signal.name() + " : " + code + " @ " + lircButton.remote);
|
||||||
} else if (object instanceof Color) {
|
} else if (object instanceof Color) {
|
||||||
Color color = (Color) object;
|
Color color = (Color) object;
|
||||||
System.err.println("Color: " + color);
|
System.err.println("Color: " + color);
|
||||||
try {
|
try {
|
||||||
switch (color) {
|
switch (color) {
|
||||||
case RED:
|
case RED:
|
||||||
iBuddy.setHeadRed(signal.equals(Signal.BEGIN));
|
iBuddy.setHeadRed(signal.equals(Signal.BEGIN));
|
||||||
break;
|
break;
|
||||||
case GREEN:
|
case GREEN:
|
||||||
iBuddy.setHeadGreen(signal.equals(Signal.BEGIN));
|
iBuddy.setHeadGreen(signal.equals(Signal.BEGIN));
|
||||||
break;
|
break;
|
||||||
case YELLOW:
|
case YELLOW:
|
||||||
if (signal.equals(Signal.BEGIN)) {
|
if (signal.equals(Signal.BEGIN)) {
|
||||||
iBuddy.setHead(proto.Ibuddy.Color.YELLOW);
|
iBuddy.setHead(proto.Ibuddy.Color.YELLOW);
|
||||||
} else {
|
} else {
|
||||||
iBuddy.setHead(proto.Ibuddy.Color.NONE);
|
iBuddy.setHead(proto.Ibuddy.Color.NONE);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case BLUE:
|
case BLUE:
|
||||||
iBuddy.setHeadBlue(signal.equals(Signal.BEGIN));
|
iBuddy.setHeadBlue(signal.equals(Signal.BEGIN));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {}
|
} catch (Exception e) {}
|
||||||
} else if (object instanceof Number) {
|
} else if (object instanceof Number) {
|
||||||
Number number = (Number) object;
|
Number number = (Number) object;
|
||||||
// Find way to reuse enum?
|
// Find way to reuse enum?
|
||||||
proto.Ibuddy.Color color = proto.Ibuddy.Color.valueOf(number.getNumber());
|
proto.Ibuddy.Color color = proto.Ibuddy.Color.valueOf(number.getNumber());
|
||||||
if (signal.equals(Signal.BEGIN)) {
|
if (signal.equals(Signal.BEGIN)) {
|
||||||
System.err.println("Number: " + number + " Color: " + color);
|
System.err.println("Number: " + number + " Color: " + color);
|
||||||
iBuddy.setHead(color);
|
iBuddy.setHead(color);
|
||||||
} else {
|
} else {
|
||||||
iBuddy.setHead(proto.Ibuddy.Color.NONE);
|
iBuddy.setHead(proto.Ibuddy.Color.NONE);
|
||||||
}
|
}
|
||||||
} else if (object instanceof Direction && signal.equals(Signal.BEGIN)) {
|
} else if (object instanceof Direction && signal.equals(Signal.BEGIN)) {
|
||||||
Direction direction = (Direction) object;
|
Direction direction = (Direction) object;
|
||||||
System.err.println("Direction: " + direction);
|
System.err.println("Direction: " + direction);
|
||||||
switch (direction) {
|
switch (direction) {
|
||||||
case LEFT:
|
case LEFT:
|
||||||
iBuddy.setRotateLeft();
|
iBuddy.setRotateLeft();
|
||||||
break;
|
break;
|
||||||
case RIGHT:
|
case RIGHT:
|
||||||
iBuddy.setRotateRight();
|
iBuddy.setRotateRight();
|
||||||
break;
|
break;
|
||||||
case UP:
|
case UP:
|
||||||
iBuddy.setWingsUp();
|
iBuddy.setWingsUp();
|
||||||
break;
|
break;
|
||||||
case DOWN:
|
case DOWN:
|
||||||
iBuddy.setWingsDown();
|
iBuddy.setWingsDown();
|
||||||
default:
|
default:
|
||||||
iBuddy.setRotateCenter();
|
iBuddy.setRotateCenter();
|
||||||
iBuddy.setWingsCenter();
|
iBuddy.setWingsCenter();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (Exception e) {}
|
} catch (Exception e) {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,65 +1,65 @@
|
|||||||
/**
|
/**
|
||||||
* Copyright (C) 2015 Rik Veenboer <rik.veenboer@gmail.com>
|
* Copyright (C) 2015 Rik Veenboer <rik.veenboer@gmail.com>
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
* (at your option) any later version.
|
* (at your option) any later version.
|
||||||
*
|
*
|
||||||
* This program is distributed in the hope that it will be useful,
|
* This program is distributed in the hope that it will be useful,
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
* GNU General Public License for more details.
|
* GNU General Public License for more details.
|
||||||
*
|
*
|
||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package extra;
|
package extra;
|
||||||
|
|
||||||
import com.github.boukefalos.lirc.input.Input;
|
import com.github.boukefalos.lirc.input.Input;
|
||||||
import com.github.boukefalos.lirc.util.Signal;
|
import com.github.boukefalos.lirc.util.Signal;
|
||||||
import com.github.boukefalos.lirc.value.Action;
|
import com.github.boukefalos.lirc.value.Action;
|
||||||
import com.github.boukefalos.lirc.value.Target;
|
import com.github.boukefalos.lirc.value.Target;
|
||||||
|
|
||||||
import extra.Task;
|
import extra.Task;
|
||||||
|
|
||||||
public class Task implements Input {
|
public class Task implements Input {
|
||||||
protected static final long serialVersionUID = 1L;
|
protected static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public static final Target TARGET = Target.ALL;
|
public static final Target TARGET = Target.ALL;
|
||||||
public static final Signal SIGNAL = Signal.NONE;
|
public static final Signal SIGNAL = Signal.NONE;
|
||||||
|
|
||||||
protected Target target;
|
protected Target target;
|
||||||
protected Action action;
|
protected Action action;
|
||||||
protected Signal signal;
|
protected Signal signal;
|
||||||
|
|
||||||
public Task(Action action) {
|
public Task(Action action) {
|
||||||
this(action, TARGET);
|
this(action, TARGET);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task(Action action, Target target) {
|
public Task(Action action, Target target) {
|
||||||
this(action, target, SIGNAL);
|
this(action, target, SIGNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task(Action action, Target target, Signal signal) {
|
public Task(Action action, Target target, Signal signal) {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
this.action = action;
|
this.action = action;
|
||||||
this.signal = signal;
|
this.signal = signal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Target getTarget() {
|
public Target getTarget() {
|
||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action getAction() {
|
public Action getAction() {
|
||||||
return action;
|
return action;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Signal getSignal() {
|
public Signal getSignal() {
|
||||||
return signal;
|
return signal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task setSignal(Signal signal) {
|
public Task setSignal(Signal signal) {
|
||||||
return new Task(action, target, signal);
|
return new Task(action, target, signal);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user