Correct compilation errors from refactored base
This commit is contained in:
@@ -86,7 +86,7 @@ public abstract class Worker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void sleep() {
|
public void sleep() {
|
||||||
sleep(SLEEP);
|
sleep(SLEEP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package mimis;
|
package mimis;
|
||||||
|
|
||||||
import base.worker.Listener;
|
|
||||||
import mimis.input.Button;
|
import mimis.input.Button;
|
||||||
import mimis.input.Feedback;
|
import mimis.input.Feedback;
|
||||||
import mimis.input.Input;
|
import mimis.input.Input;
|
||||||
@@ -28,8 +27,10 @@ import mimis.parser.ParserInput;
|
|||||||
import mimis.router.Router;
|
import mimis.router.Router;
|
||||||
import mimis.state.TaskMap;
|
import mimis.state.TaskMap;
|
||||||
import mimis.value.Action;
|
import mimis.value.Action;
|
||||||
|
import base.work.Listen;
|
||||||
|
import base.worker.Worker.Type;
|
||||||
|
|
||||||
public abstract class Component extends Listener<Input> {
|
public abstract class Component extends Listen<Input> {
|
||||||
protected static final String TITLE = "Component";
|
protected static final String TITLE = "Component";
|
||||||
|
|
||||||
protected String title;
|
protected String title;
|
||||||
@@ -39,11 +40,15 @@ public abstract class Component extends Listener<Input> {
|
|||||||
this(TITLE);
|
this(TITLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Component(Type type) {
|
||||||
|
super(type);
|
||||||
|
}
|
||||||
|
|
||||||
public Component(String title) {
|
public Component(String title) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRouter(Router router) {
|
public void setRouter(Router router) {
|
||||||
this.router = router;
|
this.router = router;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class Gui extends Component {
|
|||||||
createFrame(buttonManagerArray);
|
createFrame(buttonManagerArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void activate() throws ActivateException {
|
public void activate() throws ActivateException {
|
||||||
listen(Feedback.class);
|
listen(Feedback.class);
|
||||||
super.activate();
|
super.activate();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ public class Main extends Mimis {
|
|||||||
end(Action.CURRENT);
|
end(Action.CURRENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deactivate() throws DeactivateException {
|
public void deactivate() throws DeactivateException {
|
||||||
super.deactivate();
|
super.deactivate();
|
||||||
|
|
||||||
logger.debug("Stop managers");
|
logger.debug("Stop managers");
|
||||||
@@ -112,6 +112,6 @@ public class Main extends Mimis {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
new Main().start(false);
|
new Main().start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,16 +16,17 @@
|
|||||||
*/
|
*/
|
||||||
package mimis;
|
package mimis;
|
||||||
|
|
||||||
import base.exception.worker.ActivateException;
|
|
||||||
import base.exception.worker.DeactivateException;
|
|
||||||
import mimis.input.Feedback;
|
import mimis.input.Feedback;
|
||||||
import mimis.input.Task;
|
import mimis.input.Task;
|
||||||
import mimis.manager.Manager;
|
import mimis.manager.Manager;
|
||||||
import mimis.parser.Parser;
|
import mimis.parser.Parser;
|
||||||
import mimis.router.Router;
|
import mimis.router.Router;
|
||||||
import mimis.util.ArrayCycle;
|
|
||||||
import mimis.value.Action;
|
import mimis.value.Action;
|
||||||
import mimis.value.Target;
|
import mimis.value.Target;
|
||||||
|
import base.exception.worker.ActivateException;
|
||||||
|
import base.exception.worker.DeactivateException;
|
||||||
|
import base.util.ArrayCycle;
|
||||||
|
import base.worker.Worker;
|
||||||
|
|
||||||
public abstract class Mimis extends Component {
|
public abstract class Mimis extends Component {
|
||||||
protected Component[] currentArray;
|
protected Component[] currentArray;
|
||||||
@@ -34,6 +35,7 @@ public abstract class Mimis extends Component {
|
|||||||
protected ArrayCycle<Component> componentCycle;
|
protected ArrayCycle<Component> componentCycle;
|
||||||
|
|
||||||
public Mimis(Component... currentArray) {
|
public Mimis(Component... currentArray) {
|
||||||
|
super(Worker.Type.FOREGROUND);
|
||||||
this.currentArray = initialize(false, currentArray);
|
this.currentArray = initialize(false, currentArray);
|
||||||
componentCycle = new ArrayCycle<Component>(currentArray);
|
componentCycle = new ArrayCycle<Component>(currentArray);
|
||||||
router = new Router();
|
router = new Router();
|
||||||
@@ -45,7 +47,7 @@ public abstract class Mimis extends Component {
|
|||||||
super.activate();
|
super.activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deactivate() throws DeactivateException {
|
public void deactivate() throws DeactivateException {
|
||||||
super.deactivate();
|
super.deactivate();
|
||||||
manager.stop();
|
manager.stop();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public abstract class CMDApplication extends Component implements Application {
|
|||||||
detect = true;
|
detect = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void activate() throws ActivateException {
|
public void activate() throws ActivateException {
|
||||||
detect = true;
|
detect = true;
|
||||||
if (!running) {
|
if (!running) {
|
||||||
String path = getPath();
|
String path = getPath();
|
||||||
@@ -64,15 +64,14 @@ public abstract class CMDApplication extends Component implements Application {
|
|||||||
public boolean active() {
|
public boolean active() {
|
||||||
if (detect) {
|
if (detect) {
|
||||||
running = Native.isRunning(program);
|
running = Native.isRunning(program);
|
||||||
if (!active && running) {
|
if (!running) {
|
||||||
active = true;
|
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return active;
|
return super.active();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected synchronized void deactivate() throws DeactivateException {
|
public synchronized void deactivate() throws DeactivateException {
|
||||||
detect = false;
|
detect = false;
|
||||||
super.deactivate();
|
super.deactivate();
|
||||||
if (process != null) {
|
if (process != null) {
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public abstract class WindowsApplication extends CMDApplication {
|
|||||||
handle = 0;
|
handle = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void activate() throws ActivateException {
|
public void activate() throws ActivateException {
|
||||||
if (program != null) {
|
if (program != null) {
|
||||||
super.activate();
|
super.activate();
|
||||||
}
|
}
|
||||||
@@ -51,14 +51,13 @@ public abstract class WindowsApplication extends CMDApplication {
|
|||||||
sleep(START_SLEEP);
|
sleep(START_SLEEP);
|
||||||
handle = Native.getHandle(window);
|
handle = Native.getHandle(window);
|
||||||
}
|
}
|
||||||
active = handle > 0;
|
if (handle < 0) {
|
||||||
if (!active) {
|
|
||||||
throw new ActivateException();
|
throw new ActivateException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean active() {
|
public boolean active() {
|
||||||
if (!active || program == null) {
|
if (!super.active() || program == null) {
|
||||||
handle = Native.getHandle(window);
|
handle = Native.getHandle(window);
|
||||||
if (handle > 0 && program == null) {
|
if (handle > 0 && program == null) {
|
||||||
start();
|
start();
|
||||||
@@ -67,13 +66,11 @@ public abstract class WindowsApplication extends CMDApplication {
|
|||||||
return program == null ? handle > 0 : super.active();
|
return program == null ? handle > 0 : super.active();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deactivate() throws DeactivateException {
|
public void deactivate() throws DeactivateException {
|
||||||
if (process == null) {
|
if (process != null) {
|
||||||
active = false;
|
close();
|
||||||
} else {
|
|
||||||
super.deactivate();
|
|
||||||
}
|
}
|
||||||
close();
|
super.deactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void close() {
|
protected void close() {
|
||||||
|
|||||||
@@ -16,12 +16,12 @@
|
|||||||
*/
|
*/
|
||||||
package mimis.application.cmd.windows.gomplayer;
|
package mimis.application.cmd.windows.gomplayer;
|
||||||
|
|
||||||
import base.exception.worker.ActivateException;
|
|
||||||
import base.exception.worker.DeactivateException;
|
|
||||||
import base.worker.ThreadWorker;
|
|
||||||
import mimis.application.cmd.windows.WindowsApplication;
|
import mimis.application.cmd.windows.WindowsApplication;
|
||||||
import mimis.value.Action;
|
import mimis.value.Action;
|
||||||
import mimis.value.Amount;
|
import mimis.value.Amount;
|
||||||
|
import base.exception.worker.ActivateException;
|
||||||
|
import base.exception.worker.DeactivateException;
|
||||||
|
import base.work.Work;
|
||||||
|
|
||||||
public class GomPlayerApplication extends WindowsApplication {
|
public class GomPlayerApplication extends WindowsApplication {
|
||||||
protected final static String PROGRAM = "GOM.exe";
|
protected final static String PROGRAM = "GOM.exe";
|
||||||
@@ -31,48 +31,50 @@ public class GomPlayerApplication extends WindowsApplication {
|
|||||||
protected static final int VOLUME_SLEEP = 100;
|
protected static final int VOLUME_SLEEP = 100;
|
||||||
protected static final int SEEK_SLEEP = 100;
|
protected static final int SEEK_SLEEP = 100;
|
||||||
|
|
||||||
protected VolumeWorker volumeWorker;
|
protected VolumeWork volumeWork;
|
||||||
protected SeekWorker seekWorker;
|
protected SeekWork seekWork;
|
||||||
|
|
||||||
public GomPlayerApplication() {
|
public GomPlayerApplication() {
|
||||||
super(PROGRAM, TITLE, WINDOW);
|
super(PROGRAM, TITLE, WINDOW);
|
||||||
volumeWorker = new VolumeWorker();
|
volumeWork = new VolumeWork();
|
||||||
seekWorker = new SeekWorker();
|
seekWork = new SeekWork();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deactivate() throws DeactivateException {
|
public void deactivate() throws DeactivateException {
|
||||||
super.deactivate();
|
super.deactivate();
|
||||||
volumeWorker.stop();
|
volumeWork.stop();
|
||||||
seekWorker.stop();
|
seekWork.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void exit() {
|
public void exit() {
|
||||||
super.exit();
|
super.exit();
|
||||||
volumeWorker.exit();
|
volumeWork.exit();
|
||||||
seekWorker.exit();
|
seekWork.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void begin(Action action) {
|
public void begin(Action action) {
|
||||||
logger.trace("GomPlayerApplication begin: " + action);
|
logger.trace("GomPlayerApplication begin: " + action);
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case VOLUME_UP:
|
case VOLUME_UP:
|
||||||
volumeWorker.start();
|
volumeWork.start();
|
||||||
break;
|
break;
|
||||||
case VOLUME_DOWN:
|
case VOLUME_DOWN:
|
||||||
volumeWorker.start();
|
volumeWork.start();
|
||||||
break;
|
break;
|
||||||
case FORWARD:
|
case FORWARD:
|
||||||
seekWorker.start(Amount.SMALL, 1);
|
seekWork.start(Amount.SMALL, 1);
|
||||||
break;
|
break;
|
||||||
case REWIND:
|
case REWIND:
|
||||||
seekWorker.start(Amount.SMALL, -1);
|
seekWork.start(Amount.SMALL, -1);
|
||||||
break;
|
break;
|
||||||
case NEXT:
|
case NEXT:
|
||||||
seekWorker.start(Amount.MEDIUM, 1);
|
seekWork.start(Amount.MEDIUM, 1);
|
||||||
break;
|
break;
|
||||||
case PREVIOUS:
|
case PREVIOUS:
|
||||||
seekWorker.start(Amount.MEDIUM, -1);
|
seekWork.start(Amount.MEDIUM, -1);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,19 +91,21 @@ public class GomPlayerApplication extends WindowsApplication {
|
|||||||
case REWIND:
|
case REWIND:
|
||||||
case NEXT:
|
case NEXT:
|
||||||
case PREVIOUS:
|
case PREVIOUS:
|
||||||
seekWorker.stop();
|
seekWork.stop();
|
||||||
break;
|
break;
|
||||||
case VOLUME_UP:
|
case VOLUME_UP:
|
||||||
case VOLUME_DOWN:
|
case VOLUME_DOWN:
|
||||||
volumeWorker.stop();
|
volumeWork.stop();
|
||||||
break;
|
break;
|
||||||
case FULLSCREEN:
|
case FULLSCREEN:
|
||||||
command(0x8154);
|
command(0x8154);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class VolumeWorker extends ThreadWorker {
|
protected class VolumeWork extends Work {
|
||||||
protected int volumeChangeSign;
|
protected int volumeChangeSign;
|
||||||
|
|
||||||
public void start(int volumeChangeSign) throws ActivateException {
|
public void start(int volumeChangeSign) throws ActivateException {
|
||||||
@@ -115,7 +119,7 @@ public class GomPlayerApplication extends WindowsApplication {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected class SeekWorker extends ThreadWorker {
|
protected class SeekWork extends Work {
|
||||||
protected Amount amount;
|
protected Amount amount;
|
||||||
protected int seekDirection;
|
protected int seekDirection;
|
||||||
|
|
||||||
|
|||||||
@@ -16,12 +16,12 @@
|
|||||||
*/
|
*/
|
||||||
package mimis.application.cmd.windows.photoviewer;
|
package mimis.application.cmd.windows.photoviewer;
|
||||||
|
|
||||||
import base.exception.worker.DeactivateException;
|
|
||||||
import base.worker.ThreadWorker;
|
|
||||||
import mimis.application.cmd.windows.WindowsApplication;
|
import mimis.application.cmd.windows.WindowsApplication;
|
||||||
import mimis.value.Action;
|
import mimis.value.Action;
|
||||||
import mimis.value.Key;
|
import mimis.value.Key;
|
||||||
import mimis.value.Type;
|
import mimis.value.Type;
|
||||||
|
import base.exception.worker.DeactivateException;
|
||||||
|
import base.work.Work;
|
||||||
|
|
||||||
public class PhotoViewerApplication extends WindowsApplication {
|
public class PhotoViewerApplication extends WindowsApplication {
|
||||||
protected final static String TITLE = "Photo Viewer";
|
protected final static String TITLE = "Photo Viewer";
|
||||||
@@ -30,33 +30,35 @@ public class PhotoViewerApplication extends WindowsApplication {
|
|||||||
protected static final int ZOOM_SLEEP = 100;
|
protected static final int ZOOM_SLEEP = 100;
|
||||||
protected static final int DELETE_SLEEP = 2000;
|
protected static final int DELETE_SLEEP = 2000;
|
||||||
|
|
||||||
protected ZoomWorker zoomWorker;
|
protected ZoomWork zoomWork;
|
||||||
protected boolean fullscreen;
|
protected boolean fullscreen;
|
||||||
|
|
||||||
public PhotoViewerApplication() {
|
public PhotoViewerApplication() {
|
||||||
super(TITLE, WINDOW);
|
super(TITLE, WINDOW);
|
||||||
zoomWorker = new ZoomWorker();
|
zoomWork = new ZoomWork();
|
||||||
fullscreen = false;
|
fullscreen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deactivate() throws DeactivateException {
|
public void deactivate() throws DeactivateException {
|
||||||
super.deactivate();
|
super.deactivate();
|
||||||
zoomWorker.stop();
|
zoomWork.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void exit() {
|
public void exit() {
|
||||||
super.exit();
|
super.exit();
|
||||||
zoomWorker.exit();
|
zoomWork.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void begin(Action action) {
|
public void begin(Action action) {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case VOLUME_UP:
|
case VOLUME_UP:
|
||||||
zoomWorker.start(1);
|
zoomWork.start(1);
|
||||||
break;
|
break;
|
||||||
case VOLUME_DOWN:
|
case VOLUME_DOWN:
|
||||||
zoomWorker.start(-1);
|
zoomWork.start(-1);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,7 +67,7 @@ public class PhotoViewerApplication extends WindowsApplication {
|
|||||||
switch (action) {
|
switch (action) {
|
||||||
case VOLUME_UP:
|
case VOLUME_UP:
|
||||||
case VOLUME_DOWN:
|
case VOLUME_DOWN:
|
||||||
zoomWorker.stop();
|
zoomWork.stop();
|
||||||
break;
|
break;
|
||||||
case NEXT:
|
case NEXT:
|
||||||
key(Type.DOWN, Key.RIGHT);
|
key(Type.DOWN, Key.RIGHT);
|
||||||
@@ -106,10 +108,12 @@ public class PhotoViewerApplication extends WindowsApplication {
|
|||||||
end(Action.FULLSCREEN);
|
end(Action.FULLSCREEN);
|
||||||
}*/
|
}*/
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class ZoomWorker extends ThreadWorker {
|
protected class ZoomWork extends Work {
|
||||||
protected int zoomDirection;
|
protected int zoomDirection;
|
||||||
|
|
||||||
public void start(int zoomDirection) {
|
public void start(int zoomDirection) {
|
||||||
|
|||||||
@@ -16,11 +16,11 @@
|
|||||||
*/
|
*/
|
||||||
package mimis.application.cmd.windows.winamp;
|
package mimis.application.cmd.windows.winamp;
|
||||||
|
|
||||||
import base.exception.worker.DeactivateException;
|
|
||||||
import base.worker.ThreadWorker;
|
|
||||||
import mimis.application.cmd.windows.WindowsApplication;
|
import mimis.application.cmd.windows.WindowsApplication;
|
||||||
import mimis.value.Action;
|
import mimis.value.Action;
|
||||||
import mimis.value.Command;
|
import mimis.value.Command;
|
||||||
|
import base.exception.worker.DeactivateException;
|
||||||
|
import base.work.Work;
|
||||||
|
|
||||||
public class WinampApplication extends WindowsApplication {
|
public class WinampApplication extends WindowsApplication {
|
||||||
protected final static String PROGRAM = "winamp.exe";
|
protected final static String PROGRAM = "winamp.exe";
|
||||||
@@ -52,8 +52,8 @@ public class WinampApplication extends WindowsApplication {
|
|||||||
protected static final int VOLUME_SLEEP = 50;
|
protected static final int VOLUME_SLEEP = 50;
|
||||||
protected static final int SEEK_SLEEP = 100;
|
protected static final int SEEK_SLEEP = 100;
|
||||||
|
|
||||||
protected VolumeWorker volumeWorker;
|
protected VolumeWork volumeWork;
|
||||||
protected SeekWorker seekWorker;
|
protected SeekWork seekWork;
|
||||||
protected double volume;
|
protected double volume;
|
||||||
protected boolean muted;
|
protected boolean muted;
|
||||||
|
|
||||||
@@ -61,37 +61,39 @@ public class WinampApplication extends WindowsApplication {
|
|||||||
super(PROGRAM, TITLE, WINDOW);
|
super(PROGRAM, TITLE, WINDOW);
|
||||||
volume = getVolume();
|
volume = getVolume();
|
||||||
muted = volume == 0;
|
muted = volume == 0;
|
||||||
volumeWorker = new VolumeWorker();
|
volumeWork = new VolumeWork();
|
||||||
seekWorker = new SeekWorker();
|
seekWork = new SeekWork();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deactivate() throws DeactivateException {
|
public void deactivate() throws DeactivateException {
|
||||||
super.deactivate();
|
super.deactivate();
|
||||||
volumeWorker.stop();
|
volumeWork.stop();
|
||||||
seekWorker.stop();
|
seekWork.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void exit() {
|
public void exit() {
|
||||||
super.exit();
|
super.exit();
|
||||||
volumeWorker.exit();
|
volumeWork.exit();
|
||||||
seekWorker.exit();
|
seekWork.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void begin(Action action) {
|
public void begin(Action action) {
|
||||||
logger.trace("WinampApplication begin: " + action);
|
logger.trace("WinampApplication begin: " + action);
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case VOLUME_UP:
|
case VOLUME_UP:
|
||||||
volumeWorker.start(1);
|
volumeWork.start(1);
|
||||||
break;
|
break;
|
||||||
case VOLUME_DOWN:
|
case VOLUME_DOWN:
|
||||||
volumeWorker.start(-1);
|
volumeWork.start(-1);
|
||||||
break;
|
break;
|
||||||
case FORWARD:
|
case FORWARD:
|
||||||
seekWorker.start(1);
|
seekWork.start(1);
|
||||||
break;
|
break;
|
||||||
case REWIND:
|
case REWIND:
|
||||||
seekWorker.start(-1);
|
seekWork.start(-1);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -117,7 +119,7 @@ public class WinampApplication extends WindowsApplication {
|
|||||||
break;
|
break;
|
||||||
case FORWARD:
|
case FORWARD:
|
||||||
case REWIND:
|
case REWIND:
|
||||||
seekWorker.stop();
|
seekWork.stop();
|
||||||
break;
|
break;
|
||||||
case MUTE:
|
case MUTE:
|
||||||
if (muted) {
|
if (muted) {
|
||||||
@@ -130,7 +132,7 @@ public class WinampApplication extends WindowsApplication {
|
|||||||
break;
|
break;
|
||||||
case VOLUME_UP:
|
case VOLUME_UP:
|
||||||
case VOLUME_DOWN:
|
case VOLUME_DOWN:
|
||||||
volumeWorker.stop();
|
volumeWork.stop();
|
||||||
break;
|
break;
|
||||||
case SHUFFLE:
|
case SHUFFLE:
|
||||||
command(WINAMP_FILE_SHUFFLE);
|
command(WINAMP_FILE_SHUFFLE);
|
||||||
@@ -148,6 +150,8 @@ public class WinampApplication extends WindowsApplication {
|
|||||||
system(Command.System.MAXIMIZE);
|
system(Command.System.MAXIMIZE);
|
||||||
command(WINAMP_VISPLUGIN);
|
command(WINAMP_VISPLUGIN);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,7 +171,7 @@ public class WinampApplication extends WindowsApplication {
|
|||||||
return user(0, IPC_GETOUTPUTTIME) / 1000;
|
return user(0, IPC_GETOUTPUTTIME) / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class VolumeWorker extends ThreadWorker {
|
protected class VolumeWork extends Work {
|
||||||
protected int volumeChangeSign;
|
protected int volumeChangeSign;
|
||||||
|
|
||||||
public void start(int volumeChangeSign) {
|
public void start(int volumeChangeSign) {
|
||||||
@@ -181,7 +185,7 @@ public class WinampApplication extends WindowsApplication {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected class SeekWorker extends ThreadWorker {
|
protected class SeekWork extends Work {
|
||||||
protected int seekDirection;
|
protected int seekDirection;
|
||||||
|
|
||||||
public void start(int seekDirection) {
|
public void start(int seekDirection) {
|
||||||
|
|||||||
@@ -16,9 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package mimis.application.cmd.windows.wmp;
|
package mimis.application.cmd.windows.wmp;
|
||||||
|
|
||||||
import base.worker.ThreadWorker;
|
|
||||||
import mimis.application.cmd.windows.WindowsApplication;
|
import mimis.application.cmd.windows.WindowsApplication;
|
||||||
import mimis.value.Action;
|
import mimis.value.Action;
|
||||||
|
import base.work.Work;
|
||||||
|
|
||||||
public class WMPApplication extends WindowsApplication {
|
public class WMPApplication extends WindowsApplication {
|
||||||
protected final static String PROGRAM = "wmplayer.exe";
|
protected final static String PROGRAM = "wmplayer.exe";
|
||||||
@@ -27,11 +27,11 @@ public class WMPApplication extends WindowsApplication {
|
|||||||
|
|
||||||
protected static final int VOLUME_SLEEP = 120;
|
protected static final int VOLUME_SLEEP = 120;
|
||||||
|
|
||||||
protected VolumeWorker volumeWorker;
|
protected VolumeWork volumeWork;
|
||||||
|
|
||||||
public WMPApplication() {
|
public WMPApplication() {
|
||||||
super(PROGRAM, TITLE, WINDOW);
|
super(PROGRAM, TITLE, WINDOW);
|
||||||
volumeWorker = new VolumeWorker();
|
volumeWork = new VolumeWork();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void begin(Action action) {
|
public void begin(Action action) {
|
||||||
@@ -56,17 +56,19 @@ public class WMPApplication extends WindowsApplication {
|
|||||||
command(18817);
|
command(18817);
|
||||||
break;
|
break;
|
||||||
case VOLUME_UP:
|
case VOLUME_UP:
|
||||||
volumeWorker.start(1);
|
volumeWork.start(1);
|
||||||
break;
|
break;
|
||||||
case VOLUME_DOWN:
|
case VOLUME_DOWN:
|
||||||
volumeWorker.start(-1);
|
volumeWork.start(-1);
|
||||||
break;
|
break;
|
||||||
case SHUFFLE:
|
case SHUFFLE:
|
||||||
command(18842);
|
command(18842);
|
||||||
break;
|
break;
|
||||||
case REPEAT:
|
case REPEAT:
|
||||||
command(18843);
|
command(18843);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -81,12 +83,14 @@ public class WMPApplication extends WindowsApplication {
|
|||||||
break;
|
break;
|
||||||
case VOLUME_UP:
|
case VOLUME_UP:
|
||||||
case VOLUME_DOWN:
|
case VOLUME_DOWN:
|
||||||
volumeWorker.stop();
|
volumeWork.stop();
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class VolumeWorker extends ThreadWorker {
|
protected class VolumeWork extends Work {
|
||||||
protected int volumeChangeSign;
|
protected int volumeChangeSign;
|
||||||
|
|
||||||
public void start(int volumeChangeSign) {
|
public void start(int volumeChangeSign) {
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import mimis.application.Application;
|
|||||||
import mimis.value.Action;
|
import mimis.value.Action;
|
||||||
import base.exception.worker.ActivateException;
|
import base.exception.worker.ActivateException;
|
||||||
import base.exception.worker.DeactivateException;
|
import base.exception.worker.DeactivateException;
|
||||||
import base.worker.ThreadWorker;
|
import base.work.Work;
|
||||||
|
|
||||||
import com.dt.iTunesController.ITCOMDisabledReason;
|
import com.dt.iTunesController.ITCOMDisabledReason;
|
||||||
import com.dt.iTunesController.ITTrack;
|
import com.dt.iTunesController.ITTrack;
|
||||||
@@ -38,7 +38,7 @@ public class iTunesApplication extends Component implements Application, iTunesE
|
|||||||
protected static final String PLAYLIST_DISLIKE = "Dislike";
|
protected static final String PLAYLIST_DISLIKE = "Dislike";
|
||||||
|
|
||||||
protected iTunes iTunes;
|
protected iTunes iTunes;
|
||||||
protected VolumeWorker volumeWorker;
|
protected VolumeWork volumeWork;
|
||||||
protected boolean events;
|
protected boolean events;
|
||||||
|
|
||||||
public iTunesApplication() {
|
public iTunesApplication() {
|
||||||
@@ -48,10 +48,10 @@ public class iTunesApplication extends Component implements Application, iTunesE
|
|||||||
public iTunesApplication(boolean events) {
|
public iTunesApplication(boolean events) {
|
||||||
super(TITLE);
|
super(TITLE);
|
||||||
this.events = events;
|
this.events = events;
|
||||||
volumeWorker = new VolumeWorker();
|
volumeWork = new VolumeWork();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected synchronized void activate() throws ActivateException {
|
public synchronized void activate() throws ActivateException {
|
||||||
iTunes = new iTunes();
|
iTunes = new iTunes();
|
||||||
iTunes.connect();
|
iTunes.connect();
|
||||||
if (events) {
|
if (events) {
|
||||||
@@ -63,19 +63,18 @@ public class iTunesApplication extends Component implements Application, iTunesE
|
|||||||
public synchronized boolean active() {
|
public synchronized boolean active() {
|
||||||
try {
|
try {
|
||||||
iTunes.getMute();
|
iTunes.getMute();
|
||||||
active = true;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
active = false;
|
stop();
|
||||||
}
|
}
|
||||||
return active;
|
return super.active();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected synchronized void deactivate() throws DeactivateException {
|
public synchronized void deactivate() throws DeactivateException {
|
||||||
if (events) {
|
if (events) {
|
||||||
exit();
|
exit();
|
||||||
} else {
|
} else {
|
||||||
super.deactivate();
|
super.deactivate();
|
||||||
volumeWorker.stop();
|
volumeWork.stop();
|
||||||
try {
|
try {
|
||||||
iTunes.release();
|
iTunes.release();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -89,13 +88,13 @@ public class iTunesApplication extends Component implements Application, iTunesE
|
|||||||
try {
|
try {
|
||||||
iTunes.quit();
|
iTunes.quit();
|
||||||
} catch (Exception e) {}
|
} catch (Exception e) {}
|
||||||
volumeWorker.exit();
|
volumeWork.exit();
|
||||||
super.exit();
|
super.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void begin(Action action) {
|
protected void begin(Action action) {
|
||||||
logger.trace("iTunesApplication begin: " + action);
|
logger.trace("iTunesApplication begin: " + action);
|
||||||
if (!active) return;
|
if (!active()) return;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case FORWARD:
|
case FORWARD:
|
||||||
iTunes.fastForward();
|
iTunes.fastForward();
|
||||||
@@ -104,17 +103,19 @@ public class iTunesApplication extends Component implements Application, iTunesE
|
|||||||
iTunes.rewind();
|
iTunes.rewind();
|
||||||
break;
|
break;
|
||||||
case VOLUME_UP:
|
case VOLUME_UP:
|
||||||
volumeWorker.start(VOLUME_CHANGE_RATE);
|
volumeWork.start(VOLUME_CHANGE_RATE);
|
||||||
break;
|
break;
|
||||||
case VOLUME_DOWN:
|
case VOLUME_DOWN:
|
||||||
volumeWorker.start(-VOLUME_CHANGE_RATE);
|
volumeWork.start(-VOLUME_CHANGE_RATE);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void end(Action action) {
|
protected void end(Action action) {
|
||||||
logger.trace("iTunesApplication end: " + action);
|
logger.trace("iTunesApplication end: " + action);
|
||||||
if (!active) return;
|
if (!active()) return;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case PLAY:
|
case PLAY:
|
||||||
iTunes.playPause();
|
iTunes.playPause();
|
||||||
@@ -136,7 +137,7 @@ public class iTunesApplication extends Component implements Application, iTunesE
|
|||||||
break;
|
break;
|
||||||
case VOLUME_UP:
|
case VOLUME_UP:
|
||||||
case VOLUME_DOWN:
|
case VOLUME_DOWN:
|
||||||
volumeWorker.stop();
|
volumeWork.stop();
|
||||||
break;
|
break;
|
||||||
case SHUFFLE:
|
case SHUFFLE:
|
||||||
iTunes.toggleShuffle();
|
iTunes.toggleShuffle();
|
||||||
@@ -150,6 +151,8 @@ public class iTunesApplication extends Component implements Application, iTunesE
|
|||||||
case DISLIKE:
|
case DISLIKE:
|
||||||
iTunes.playlistAddCurrentTrack(PLAYLIST_DISLIKE);
|
iTunes.playlistAddCurrentTrack(PLAYLIST_DISLIKE);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -159,13 +162,13 @@ public class iTunesApplication extends Component implements Application, iTunesE
|
|||||||
|
|
||||||
public void onDatabaseChangedEvent(int[][] deletedObjectIDs, int[][] changedObjectIDs) {}
|
public void onDatabaseChangedEvent(int[][] deletedObjectIDs, int[][] changedObjectIDs) {}
|
||||||
public void onPlayerPlayEvent(ITTrack iTrack) {
|
public void onPlayerPlayEvent(ITTrack iTrack) {
|
||||||
if (active) {
|
if (active()) {
|
||||||
logger.trace("iTunesEvent: play");
|
logger.trace("iTunesEvent: play");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onPlayerStopEvent(ITTrack iTrack) {
|
public void onPlayerStopEvent(ITTrack iTrack) {
|
||||||
if (active) {
|
if (active()) {
|
||||||
logger.trace("iTunesEvent: stop");
|
logger.trace("iTunesEvent: stop");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -177,7 +180,7 @@ public class iTunesApplication extends Component implements Application, iTunesE
|
|||||||
public void onAboutToPromptUserToQuitEvent() {}
|
public void onAboutToPromptUserToQuitEvent() {}
|
||||||
public void onSoundVolumeChangedEvent(int newVolume) {}
|
public void onSoundVolumeChangedEvent(int newVolume) {}
|
||||||
|
|
||||||
protected class VolumeWorker extends ThreadWorker {
|
protected class VolumeWork extends Work {
|
||||||
protected int volumeChangeRate;
|
protected int volumeChangeRate;
|
||||||
|
|
||||||
public void start(int volumeChangeRate) {
|
public void start(int volumeChangeRate) {
|
||||||
|
|||||||
@@ -39,10 +39,10 @@ public class LircApplication extends Component implements Application {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean active() {
|
public boolean active() {
|
||||||
return active = lircService.active();
|
return lircService.active();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deactivate() throws DeactivateException {
|
public void deactivate() throws DeactivateException {
|
||||||
super.deactivate();
|
super.deactivate();
|
||||||
lircService.stop();
|
lircService.stop();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,58 +16,60 @@
|
|||||||
*/
|
*/
|
||||||
package mimis.application.lirc.ipod;
|
package mimis.application.lirc.ipod;
|
||||||
|
|
||||||
import base.exception.worker.ActivateException;
|
|
||||||
import base.exception.worker.DeactivateException;
|
|
||||||
import base.worker.ThreadWorker;
|
|
||||||
import mimis.application.lirc.LircApplication;
|
import mimis.application.lirc.LircApplication;
|
||||||
import mimis.device.lirc.remote.WC02IPOButton;
|
import mimis.device.lirc.remote.WC02IPOButton;
|
||||||
import mimis.value.Action;
|
import mimis.value.Action;
|
||||||
|
import base.exception.worker.ActivateException;
|
||||||
|
import base.exception.worker.DeactivateException;
|
||||||
|
import base.work.Work;
|
||||||
|
|
||||||
public class iPodApplication extends LircApplication {
|
public class iPodApplication extends LircApplication {
|
||||||
protected static final String TITLE = "iPod";
|
protected static final String TITLE = "iPod";
|
||||||
protected static final int VOLUME_SLEEP = 100;
|
protected static final int VOLUME_SLEEP = 100;
|
||||||
|
|
||||||
protected VolumeWorker volumeWorker;
|
protected VolumeWork volumeWork;
|
||||||
|
|
||||||
public iPodApplication() {
|
public iPodApplication() {
|
||||||
super(TITLE);
|
super(TITLE);
|
||||||
volumeWorker = new VolumeWorker();
|
volumeWork = new VolumeWork();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deactivate() throws DeactivateException {
|
public void deactivate() throws DeactivateException {
|
||||||
super.deactivate();
|
super.deactivate();
|
||||||
volumeWorker.stop();
|
volumeWork.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void exit() {
|
public void exit() {
|
||||||
super.exit();
|
super.exit();
|
||||||
volumeWorker.exit();
|
volumeWork.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void begin(Action action) {
|
protected void begin(Action action) {
|
||||||
logger.trace("iPodApplication begin: " + action);
|
logger.trace("iPodApplication begin: " + action);
|
||||||
if (!active) return;
|
if (!active()) return;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case VOLUME_UP:
|
case VOLUME_UP:
|
||||||
try {
|
try {
|
||||||
volumeWorker.activate(1);
|
volumeWork.activate(1);
|
||||||
} catch (ActivateException e) {
|
} catch (ActivateException e) {
|
||||||
logger.error("", e);
|
logger.error("", e);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case VOLUME_DOWN:
|
case VOLUME_DOWN:
|
||||||
try {
|
try {
|
||||||
volumeWorker.activate(-1);
|
volumeWork.activate(-1);
|
||||||
} catch (ActivateException e) {
|
} catch (ActivateException e) {
|
||||||
logger.error("", e);
|
logger.error("", e);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void end(Action action) {
|
protected void end(Action action) {
|
||||||
logger.trace("iPodApplication end: " + action);
|
logger.trace("iPodApplication end: " + action);
|
||||||
if (!active) return;
|
if (!active()) return;
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case PLAY:
|
case PLAY:
|
||||||
send(WC02IPOButton.PLAY);
|
send(WC02IPOButton.PLAY);
|
||||||
@@ -80,12 +82,14 @@ public class iPodApplication extends LircApplication {
|
|||||||
break;
|
break;
|
||||||
case VOLUME_UP:
|
case VOLUME_UP:
|
||||||
case VOLUME_DOWN:
|
case VOLUME_DOWN:
|
||||||
volumeWorker.stop();
|
volumeWork.stop();
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class VolumeWorker extends ThreadWorker {
|
protected class VolumeWork extends Work {
|
||||||
protected int volumeChangeRate;
|
protected int volumeChangeRate;
|
||||||
|
|
||||||
public void activate(int volumeChangeRate) throws ActivateException {
|
public void activate(int volumeChangeRate) throws ActivateException {
|
||||||
|
|||||||
@@ -16,9 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
package mimis.application.mpc;
|
package mimis.application.mpc;
|
||||||
|
|
||||||
import base.worker.ThreadWorker;
|
|
||||||
import mimis.application.cmd.windows.WindowsApplication;
|
import mimis.application.cmd.windows.WindowsApplication;
|
||||||
import mimis.value.Action;
|
import mimis.value.Action;
|
||||||
|
import base.work.Work;
|
||||||
|
|
||||||
public class MPCApplication extends WindowsApplication {
|
public class MPCApplication extends WindowsApplication {
|
||||||
protected final static String PROGRAM = "mpc-hc.exe";
|
protected final static String PROGRAM = "mpc-hc.exe";
|
||||||
@@ -28,30 +28,32 @@ public class MPCApplication extends WindowsApplication {
|
|||||||
protected static final int VOLUME_SLEEP = 50;
|
protected static final int VOLUME_SLEEP = 50;
|
||||||
protected static final int SEEK_SLEEP = 50;
|
protected static final int SEEK_SLEEP = 50;
|
||||||
|
|
||||||
protected VolumeWorker volumeWorker;
|
protected VolumeWork volumeWork;
|
||||||
protected SeekWorker seekWorker;
|
protected SeekWork seekWork;
|
||||||
|
|
||||||
public MPCApplication() {
|
public MPCApplication() {
|
||||||
super(PROGRAM, TITLE, WINDOW);
|
super(PROGRAM, TITLE, WINDOW);
|
||||||
volumeWorker = new VolumeWorker();
|
volumeWork = new VolumeWork();
|
||||||
seekWorker = new SeekWorker();
|
seekWork = new SeekWork();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void begin(Action action) {
|
public void begin(Action action) {
|
||||||
logger.trace("MPCApplication: " + action);
|
logger.trace("MPCApplication: " + action);
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case FORWARD:
|
case FORWARD:
|
||||||
seekWorker.start(1);
|
seekWork.start(1);
|
||||||
break;
|
break;
|
||||||
case REWIND:
|
case REWIND:
|
||||||
seekWorker.start(-1);
|
seekWork.start(-1);
|
||||||
break;
|
break;
|
||||||
case VOLUME_UP:
|
case VOLUME_UP:
|
||||||
volumeWorker.start(1);
|
volumeWork.start(1);
|
||||||
break;
|
break;
|
||||||
case VOLUME_DOWN:
|
case VOLUME_DOWN:
|
||||||
volumeWorker.start(-1);
|
volumeWork.start(-1);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,18 +71,20 @@ public class MPCApplication extends WindowsApplication {
|
|||||||
break;
|
break;
|
||||||
case FORWARD:
|
case FORWARD:
|
||||||
case REWIND:
|
case REWIND:
|
||||||
seekWorker.stop();
|
seekWork.stop();
|
||||||
break;
|
break;
|
||||||
case MUTE:
|
case MUTE:
|
||||||
command(909);
|
command(909);
|
||||||
break;
|
break;
|
||||||
case VOLUME_UP:
|
case VOLUME_UP:
|
||||||
case VOLUME_DOWN:
|
case VOLUME_DOWN:
|
||||||
volumeWorker.stop();
|
volumeWork.stop();
|
||||||
break;
|
break;
|
||||||
case FULLSCREEN:
|
case FULLSCREEN:
|
||||||
command(830);
|
command(830);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,7 +92,7 @@ public class MPCApplication extends WindowsApplication {
|
|||||||
return TITLE;
|
return TITLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class VolumeWorker extends ThreadWorker {
|
protected class VolumeWork extends Work {
|
||||||
protected int volumeChangeSign;
|
protected int volumeChangeSign;
|
||||||
|
|
||||||
public void start(int volumeChangeSign) {
|
public void start(int volumeChangeSign) {
|
||||||
@@ -100,9 +104,9 @@ public class MPCApplication extends WindowsApplication {
|
|||||||
command(volumeChangeSign > 0 ? 907 : 908);
|
command(volumeChangeSign > 0 ? 907 : 908);
|
||||||
sleep(VOLUME_SLEEP);
|
sleep(VOLUME_SLEEP);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
protected class SeekWorker extends ThreadWorker {
|
protected class SeekWork extends Work {
|
||||||
protected int seekDirection;
|
protected int seekDirection;
|
||||||
|
|
||||||
public void start(int seekDirection) {
|
public void start(int seekDirection) {
|
||||||
|
|||||||
@@ -23,14 +23,14 @@ import java.net.URL;
|
|||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import base.exception.worker.ActivateException;
|
|
||||||
import base.exception.worker.DeactivateException;
|
|
||||||
import base.worker.ThreadWorker;
|
|
||||||
import mimis.application.cmd.CMDApplication;
|
import mimis.application.cmd.CMDApplication;
|
||||||
import mimis.util.Native;
|
import mimis.util.Native;
|
||||||
import mimis.value.Action;
|
import mimis.value.Action;
|
||||||
import mimis.value.Amount;
|
import mimis.value.Amount;
|
||||||
import mimis.value.Registry;
|
import mimis.value.Registry;
|
||||||
|
import base.exception.worker.ActivateException;
|
||||||
|
import base.exception.worker.DeactivateException;
|
||||||
|
import base.work.Work;
|
||||||
|
|
||||||
public class VLCApplication extends CMDApplication {
|
public class VLCApplication extends CMDApplication {
|
||||||
protected final static Registry REGISTRY = Registry.CLASSES_ROOT;
|
protected final static Registry REGISTRY = Registry.CLASSES_ROOT;
|
||||||
@@ -47,16 +47,16 @@ public class VLCApplication extends CMDApplication {
|
|||||||
protected static final int VOLUME_SLEEP = 100;
|
protected static final int VOLUME_SLEEP = 100;
|
||||||
protected static final int SEEK_SLEEP = 100;
|
protected static final int SEEK_SLEEP = 100;
|
||||||
|
|
||||||
protected VolumeWorker volumeWorker;
|
protected VolumeWork volumeWorker;
|
||||||
protected SeekWorker seekWorker;
|
protected SeekWork seekWorker;
|
||||||
|
|
||||||
protected int volume = 255;
|
protected int volume = 255;
|
||||||
protected boolean muted = false;
|
protected boolean muted = false;
|
||||||
|
|
||||||
public VLCApplication() {
|
public VLCApplication() {
|
||||||
super(PROGRAM, TITLE);
|
super(PROGRAM, TITLE);
|
||||||
volumeWorker = new VolumeWorker();
|
volumeWorker = new VolumeWork();
|
||||||
seekWorker = new SeekWorker();
|
seekWorker = new SeekWork();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPath() {
|
public String getPath() {
|
||||||
@@ -79,7 +79,7 @@ public class VLCApplication extends CMDApplication {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deactivate() throws DeactivateException {
|
public void deactivate() throws DeactivateException {
|
||||||
super.deactivate();
|
super.deactivate();
|
||||||
volumeWorker.stop();
|
volumeWorker.stop();
|
||||||
seekWorker.stop();
|
seekWorker.stop();
|
||||||
@@ -108,6 +108,8 @@ public class VLCApplication extends CMDApplication {
|
|||||||
case REWIND:
|
case REWIND:
|
||||||
seekWorker.start(Amount.SMALL, "-");
|
seekWorker.start(Amount.SMALL, "-");
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} catch (ActivateException e) {
|
} catch (ActivateException e) {
|
||||||
logger.error("", e);
|
logger.error("", e);
|
||||||
@@ -146,6 +148,8 @@ public class VLCApplication extends CMDApplication {
|
|||||||
case REPEAT:
|
case REPEAT:
|
||||||
command("command=pl_repeat");
|
command("command=pl_repeat");
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,7 +175,7 @@ public class VLCApplication extends CMDApplication {
|
|||||||
return TITLE;
|
return TITLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class VolumeWorker extends ThreadWorker {
|
protected class VolumeWork extends Work {
|
||||||
protected String volumeChangeSign;
|
protected String volumeChangeSign;
|
||||||
|
|
||||||
public void activate(String volumeChangeSign) throws ActivateException {
|
public void activate(String volumeChangeSign) throws ActivateException {
|
||||||
@@ -186,7 +190,7 @@ public class VLCApplication extends CMDApplication {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
protected class SeekWorker extends ThreadWorker {
|
protected class SeekWork extends Work {
|
||||||
protected Amount amount;
|
protected Amount amount;
|
||||||
protected String seekDirection;
|
protected String seekDirection;
|
||||||
|
|
||||||
|
|||||||
@@ -44,20 +44,19 @@ public abstract class JavaInputDevice extends Component implements Device {
|
|||||||
protected JavaInputListener javaInputListener;
|
protected JavaInputListener javaInputListener;
|
||||||
protected Button previousDirectionalButton;
|
protected Button previousDirectionalButton;
|
||||||
|
|
||||||
protected void activate() throws ActivateException {
|
public void activate() throws ActivateException {
|
||||||
super.activate();
|
|
||||||
try {
|
try {
|
||||||
JXInputDevice jxinputDevice = getDevice(name);
|
JXInputDevice jxinputDevice = getDevice(name);
|
||||||
logger.debug(jxinputDevice.getName());
|
logger.debug(jxinputDevice.getName());
|
||||||
javaInputListener = new JavaInputListener(this, jxinputDevice);
|
javaInputListener = new JavaInputListener(this, jxinputDevice);
|
||||||
} catch (DeviceNotFoundException e) {
|
} catch (DeviceNotFoundException e) {
|
||||||
active = false;
|
|
||||||
throw new ActivateException();
|
throw new ActivateException();
|
||||||
}
|
}
|
||||||
javaInputListener.start();
|
javaInputListener.start();
|
||||||
|
super.activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deactivate() throws DeactivateException {
|
public void deactivate() throws DeactivateException {
|
||||||
super.deactivate();
|
super.deactivate();
|
||||||
javaInputListener.stop();
|
javaInputListener.stop();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ package mimis.device.javainput;
|
|||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.Queue;
|
import java.util.Queue;
|
||||||
|
|
||||||
import base.worker.ThreadWorker;
|
|
||||||
import mimis.exception.ButtonException;
|
import mimis.exception.ButtonException;
|
||||||
|
import base.work.Work;
|
||||||
import de.hardcode.jxinput.Button;
|
import de.hardcode.jxinput.Button;
|
||||||
import de.hardcode.jxinput.Directional;
|
import de.hardcode.jxinput.Directional;
|
||||||
import de.hardcode.jxinput.JXInputDevice;
|
import de.hardcode.jxinput.JXInputDevice;
|
||||||
@@ -33,7 +33,7 @@ import de.hardcode.jxinput.event.JXInputDirectionalEvent;
|
|||||||
import de.hardcode.jxinput.event.JXInputDirectionalEventListener;
|
import de.hardcode.jxinput.event.JXInputDirectionalEventListener;
|
||||||
import de.hardcode.jxinput.event.JXInputEventManager;
|
import de.hardcode.jxinput.event.JXInputEventManager;
|
||||||
|
|
||||||
public class JavaInputListener extends ThreadWorker implements Runnable, JXInputAxisEventListener, JXInputButtonEventListener, JXInputDirectionalEventListener {
|
public class JavaInputListener extends Work implements JXInputAxisEventListener, JXInputButtonEventListener, JXInputDirectionalEventListener {
|
||||||
protected JavaInputDevice javaInputDevice;
|
protected JavaInputDevice javaInputDevice;
|
||||||
protected JXInputDevice jxinputDevice;
|
protected JXInputDevice jxinputDevice;
|
||||||
protected Queue<JXInputAxisEvent> axisEventQueue;
|
protected Queue<JXInputAxisEvent> axisEventQueue;
|
||||||
@@ -95,7 +95,7 @@ public class JavaInputListener extends ThreadWorker implements Runnable, JXInput
|
|||||||
javaInputDevice.processEvent(directionalEventQueue.poll());
|
javaInputDevice.processEvent(directionalEventQueue.poll());
|
||||||
} catch (ButtonException e) {}
|
} catch (ButtonException e) {}
|
||||||
} else {
|
} else {
|
||||||
sleep();
|
worker.sleep();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,11 +37,11 @@ public class Extreme3DDevice extends JavaInputDevice {
|
|||||||
taskMapCycle = new Extreme3DTaskMapCycle();
|
taskMapCycle = new Extreme3DTaskMapCycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void activate() throws ActivateException {
|
public void activate() throws ActivateException {
|
||||||
super.activate();
|
|
||||||
parser(Action.ADD, taskMapCycle.mimis);
|
parser(Action.ADD, taskMapCycle.mimis);
|
||||||
parser(Action.ADD, taskMapCycle.player);
|
parser(Action.ADD, taskMapCycle.player);
|
||||||
parser(Action.ADD, taskMapCycle.like);
|
parser(Action.ADD, taskMapCycle.like);
|
||||||
|
super.activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Button getButton(JXInputButtonEvent event) throws UnknownButtonException {
|
protected Button getButton(JXInputButtonEvent event) throws UnknownButtonException {
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class RumblepadDevice extends JavaInputDevice {
|
|||||||
taskMapCycle = new RumblepadTaskMapCycle();
|
taskMapCycle = new RumblepadTaskMapCycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void activate() throws ActivateException {
|
public void activate() throws ActivateException {
|
||||||
super.activate();
|
super.activate();
|
||||||
parser(Action.ADD, taskMapCycle.mimis);
|
parser(Action.ADD, taskMapCycle.mimis);
|
||||||
parser(Action.ADD, taskMapCycle.player);
|
parser(Action.ADD, taskMapCycle.player);
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ public class JIntellitypeDevice extends Component implements Device, HotkeyListe
|
|||||||
taskMapCycle = new JIntellitypeTaskMapCycle();
|
taskMapCycle = new JIntellitypeTaskMapCycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void activate() throws ActivateException {
|
public void activate() throws ActivateException {
|
||||||
super.activate();
|
super.activate();
|
||||||
jit.addHotKeyListener(this);
|
jit.addHotKeyListener(this);
|
||||||
jit.addIntellitypeListener(this);
|
jit.addIntellitypeListener(this);
|
||||||
@@ -55,7 +55,7 @@ public class JIntellitypeDevice extends Component implements Device, HotkeyListe
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onIntellitype(int command) {
|
public void onIntellitype(int command) {
|
||||||
if (active) {
|
if (active()) {
|
||||||
try {
|
try {
|
||||||
CommandButton commandButton = CommandButton.create(command);
|
CommandButton commandButton = CommandButton.create(command);
|
||||||
route(new Press(commandButton));
|
route(new Press(commandButton));
|
||||||
@@ -67,14 +67,14 @@ public class JIntellitypeDevice extends Component implements Device, HotkeyListe
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onHotKey(int id) {
|
public void onHotKey(int id) {
|
||||||
if (active) {
|
if (active()) {
|
||||||
Hotkey hotkey = hotkeyList.get(id);
|
Hotkey hotkey = hotkeyList.get(id);
|
||||||
route(new Press(hotkey));
|
route(new Press(hotkey));
|
||||||
route(new Release(hotkey));
|
route(new Release(hotkey));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deactivate() throws DeactivateException {
|
public void deactivate() throws DeactivateException {
|
||||||
super.deactivate();
|
super.deactivate();
|
||||||
jit.removeHotKeyListener(this);
|
jit.removeHotKeyListener(this);
|
||||||
jit.removeIntellitypeListener(this);
|
jit.removeIntellitypeListener(this);
|
||||||
|
|||||||
@@ -16,8 +16,6 @@
|
|||||||
*/
|
*/
|
||||||
package mimis.device.lirc;
|
package mimis.device.lirc;
|
||||||
|
|
||||||
import base.exception.worker.ActivateException;
|
|
||||||
import base.exception.worker.DeactivateException;
|
|
||||||
import mimis.application.cmd.CMDApplication;
|
import mimis.application.cmd.CMDApplication;
|
||||||
import mimis.device.Device;
|
import mimis.device.Device;
|
||||||
import mimis.device.lirc.remote.DenonRC176Button;
|
import mimis.device.lirc.remote.DenonRC176Button;
|
||||||
@@ -33,6 +31,8 @@ import mimis.util.Native;
|
|||||||
import mimis.util.multiplexer.SignalListener;
|
import mimis.util.multiplexer.SignalListener;
|
||||||
import mimis.value.Action;
|
import mimis.value.Action;
|
||||||
import mimis.value.Signal;
|
import mimis.value.Signal;
|
||||||
|
import base.exception.worker.ActivateException;
|
||||||
|
import base.exception.worker.DeactivateException;
|
||||||
|
|
||||||
public class LircDevice extends CMDApplication implements Device, LircButtonListener, SignalListener<Button> {
|
public class LircDevice extends CMDApplication implements Device, LircButtonListener, SignalListener<Button> {
|
||||||
protected final static String PROGRAM = "winlirc.exe";
|
protected final static String PROGRAM = "winlirc.exe";
|
||||||
@@ -53,7 +53,7 @@ public class LircDevice extends CMDApplication implements Device, LircButtonList
|
|||||||
taskMapCycle = new LircTaskMapCycle();
|
taskMapCycle = new LircTaskMapCycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void activate() throws ActivateException {
|
public void activate() throws ActivateException {
|
||||||
super.activate();
|
super.activate();
|
||||||
lircService.start();
|
lircService.start();
|
||||||
parser(Action.ADD, taskMapCycle.denonRC176);
|
parser(Action.ADD, taskMapCycle.denonRC176);
|
||||||
@@ -63,19 +63,19 @@ public class LircDevice extends CMDApplication implements Device, LircButtonList
|
|||||||
|
|
||||||
public boolean active() {
|
public boolean active() {
|
||||||
if (detect) {
|
if (detect) {
|
||||||
if (active && !lircService.active()) {
|
if (active() && !lircService.active()) {
|
||||||
stop();
|
stop();
|
||||||
} else if (!active) {
|
} else if (!active()) {
|
||||||
running = Native.isRunning(PROGRAM);
|
running = Native.isRunning(PROGRAM);
|
||||||
if (running) {
|
if (running) {
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return active;
|
return super.active();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deactivate() throws DeactivateException {
|
public void deactivate() throws DeactivateException {
|
||||||
logger.debug("Deactivate LircDevice");
|
logger.debug("Deactivate LircDevice");
|
||||||
super.deactivate();
|
super.deactivate();
|
||||||
lircService.stop();
|
lircService.stop();
|
||||||
@@ -105,6 +105,8 @@ public class LircDevice extends CMDApplication implements Device, LircButtonList
|
|||||||
case END:
|
case END:
|
||||||
route(new Release(button));
|
route(new Release(button));
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (general) {
|
if (general) {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class LircService extends TcpClient {
|
|||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
LircService lircService = new LircService();
|
LircService lircService = new LircService();
|
||||||
lircService.start(false);
|
lircService.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
public LircService() {
|
public LircService() {
|
||||||
|
|||||||
@@ -25,9 +25,6 @@ import java.net.ServerSocket;
|
|||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
|
|
||||||
import base.exception.worker.ActivateException;
|
|
||||||
import base.exception.worker.DeactivateException;
|
|
||||||
import base.worker.ThreadWorker;
|
|
||||||
import mimis.Component;
|
import mimis.Component;
|
||||||
import mimis.device.Device;
|
import mimis.device.Device;
|
||||||
import mimis.input.Feedback;
|
import mimis.input.Feedback;
|
||||||
@@ -35,6 +32,9 @@ import mimis.input.Input;
|
|||||||
import mimis.input.Task;
|
import mimis.input.Task;
|
||||||
import mimis.value.Action;
|
import mimis.value.Action;
|
||||||
import mimis.value.Target;
|
import mimis.value.Target;
|
||||||
|
import base.exception.worker.ActivateException;
|
||||||
|
import base.exception.worker.DeactivateException;
|
||||||
|
import base.work.Work;
|
||||||
|
|
||||||
public class NetworkDevice extends Component implements Device {
|
public class NetworkDevice extends Component implements Device {
|
||||||
protected static final String TITLE = "Network";
|
protected static final String TITLE = "Network";
|
||||||
@@ -53,7 +53,7 @@ public class NetworkDevice extends Component implements Device {
|
|||||||
this(PORT);
|
this(PORT);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void activate() throws ActivateException {
|
public void activate() throws ActivateException {
|
||||||
server.start();
|
server.start();
|
||||||
super.activate();
|
super.activate();
|
||||||
}
|
}
|
||||||
@@ -64,10 +64,10 @@ public class NetworkDevice extends Component implements Device {
|
|||||||
client.stop();
|
client.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return active = server.active();
|
return server.active();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deactivate() throws DeactivateException {
|
public void deactivate() throws DeactivateException {
|
||||||
super.deactivate();
|
super.deactivate();
|
||||||
server.stop();
|
server.stop();
|
||||||
}
|
}
|
||||||
@@ -83,7 +83,7 @@ public class NetworkDevice extends Component implements Device {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class Server extends ThreadWorker {
|
protected class Server extends Work {
|
||||||
protected ServerSocket serverSocket;
|
protected ServerSocket serverSocket;
|
||||||
protected int port;
|
protected int port;
|
||||||
|
|
||||||
@@ -91,7 +91,7 @@ public class NetworkDevice extends Component implements Device {
|
|||||||
this.port = port;
|
this.port = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void activate() throws ActivateException {
|
public void activate() throws ActivateException {
|
||||||
try {
|
try {
|
||||||
serverSocket = new ServerSocket(port);
|
serverSocket = new ServerSocket(port);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -101,10 +101,10 @@ public class NetworkDevice extends Component implements Device {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean active() {
|
public synchronized boolean active() {
|
||||||
return active = serverSocket != null && !serverSocket.isClosed();
|
return serverSocket != null && !serverSocket.isClosed();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected synchronized void deactivate() throws DeactivateException {
|
public synchronized void deactivate() throws DeactivateException {
|
||||||
super.deactivate();
|
super.deactivate();
|
||||||
try {
|
try {
|
||||||
route(new Feedback("[NetworkDevice] Closing server socket"));
|
route(new Feedback("[NetworkDevice] Closing server socket"));
|
||||||
@@ -138,7 +138,7 @@ public class NetworkDevice extends Component implements Device {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected class Client extends ThreadWorker {
|
protected class Client extends Work {
|
||||||
protected Socket socket;
|
protected Socket socket;
|
||||||
protected InputStream inputStream;
|
protected InputStream inputStream;
|
||||||
protected OutputStream outputStream;
|
protected OutputStream outputStream;
|
||||||
@@ -153,7 +153,7 @@ public class NetworkDevice extends Component implements Device {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean active() {
|
public boolean active() {
|
||||||
return active = socket.isConnected();
|
return socket.isConnected();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void work() {
|
public void work() {
|
||||||
@@ -176,7 +176,7 @@ public class NetworkDevice extends Component implements Device {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deactivate() throws DeactivateException {
|
public void deactivate() throws DeactivateException {
|
||||||
super.deactivate();
|
super.deactivate();
|
||||||
send(new Task(Action.STOP, Target.SELF));
|
send(new Task(Action.STOP, Target.SELF));
|
||||||
clientList.remove(this);
|
clientList.remove(this);
|
||||||
|
|||||||
@@ -34,17 +34,17 @@ public class PanelDevice extends Component implements Device {
|
|||||||
taskMapCycle = new PanelTaskMapCycle();
|
taskMapCycle = new PanelTaskMapCycle();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void activate() throws ActivateException {
|
public void activate() throws ActivateException {
|
||||||
panel = new Panel(this);
|
panel = new Panel(this);
|
||||||
parser(Action.ADD, taskMapCycle.player);
|
parser(Action.ADD, taskMapCycle.player);
|
||||||
super.activate();
|
super.activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean active() {
|
public boolean active() {
|
||||||
return active = panel != null;
|
return panel != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deactivate() throws DeactivateException {
|
public void deactivate() throws DeactivateException {
|
||||||
super.deactivate();
|
super.deactivate();
|
||||||
panel.dispose();
|
panel.dispose();
|
||||||
panel = null;
|
panel = null;
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ import mimis.input.Button;
|
|||||||
import mimis.input.Feedback;
|
import mimis.input.Feedback;
|
||||||
import mimis.input.state.Press;
|
import mimis.input.state.Press;
|
||||||
import mimis.input.state.Release;
|
import mimis.input.state.Release;
|
||||||
import mimis.util.ArrayCycle;
|
|
||||||
import mimis.value.Action;
|
import mimis.value.Action;
|
||||||
import mimis.value.Signal;
|
import mimis.value.Signal;
|
||||||
|
|
||||||
@@ -40,7 +39,8 @@ import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
|||||||
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
import wiiusej.wiiusejevents.physicalevents.WiimoteButtonsEvent;
|
||||||
import base.exception.worker.ActivateException;
|
import base.exception.worker.ActivateException;
|
||||||
import base.exception.worker.DeactivateException;
|
import base.exception.worker.DeactivateException;
|
||||||
import base.worker.ThreadWorker;
|
import base.util.ArrayCycle;
|
||||||
|
import base.work.Work;
|
||||||
|
|
||||||
public class WiimoteDevice extends Component implements Device, GestureListener {
|
public class WiimoteDevice extends Component implements Device, GestureListener {
|
||||||
protected static final String TITLE = "Wiimote";
|
protected static final String TITLE = "Wiimote";
|
||||||
@@ -56,7 +56,7 @@ public class WiimoteDevice extends Component implements Device, GestureListener
|
|||||||
protected GestureDevice gestureDevice;
|
protected GestureDevice gestureDevice;
|
||||||
protected MotionDevice motionDevice;
|
protected MotionDevice motionDevice;
|
||||||
protected int gestureId;
|
protected int gestureId;
|
||||||
protected LedWorker ledWorker;
|
protected LedWork ledWork;
|
||||||
protected boolean disconnect;
|
protected boolean disconnect;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
@@ -71,11 +71,11 @@ public class WiimoteDevice extends Component implements Device, GestureListener
|
|||||||
gestureDevice.add(this);
|
gestureDevice.add(this);
|
||||||
motionDevice = new MotionDevice(this);
|
motionDevice = new MotionDevice(this);
|
||||||
gestureId = 0;
|
gestureId = 0;
|
||||||
ledWorker = new LedWorker();
|
ledWork = new LedWork();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Worker */
|
/* Worker */
|
||||||
protected void activate() throws ActivateException {
|
public void activate() throws ActivateException {
|
||||||
if (wiimote == null) {
|
if (wiimote == null) {
|
||||||
motionDevice.setRouter(router);
|
motionDevice.setRouter(router);
|
||||||
motionDevice.start();
|
motionDevice.start();
|
||||||
@@ -107,12 +107,12 @@ public class WiimoteDevice extends Component implements Device, GestureListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return active;
|
return super.active();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deactivate() throws DeactivateException {
|
public void deactivate() throws DeactivateException {
|
||||||
super.deactivate();
|
super.deactivate();
|
||||||
ledWorker.stop();
|
ledWork.stop();
|
||||||
motionDevice.stop();
|
motionDevice.stop();
|
||||||
if (disconnect && wiimote != null) {
|
if (disconnect && wiimote != null) {
|
||||||
wiimote.disconnect();
|
wiimote.disconnect();
|
||||||
@@ -122,7 +122,7 @@ public class WiimoteDevice extends Component implements Device, GestureListener
|
|||||||
|
|
||||||
public void exit() {
|
public void exit() {
|
||||||
super.exit();
|
super.exit();
|
||||||
ledWorker.exit();
|
ledWork.exit();
|
||||||
if (wiimote != null) {
|
if (wiimote != null) {
|
||||||
wiimote.disconnect();
|
wiimote.disconnect();
|
||||||
wiimote = null;
|
wiimote = null;
|
||||||
@@ -170,6 +170,8 @@ public class WiimoteDevice extends Component implements Device, GestureListener
|
|||||||
gestureDevice.loadGesture("tmp/gesture #" + gestureId);
|
gestureDevice.loadGesture("tmp/gesture #" + gestureId);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -187,6 +189,8 @@ public class WiimoteDevice extends Component implements Device, GestureListener
|
|||||||
logger.debug("Gesture close release");
|
logger.debug("Gesture close release");
|
||||||
gestureDevice.close(Signal.END);
|
gestureDevice.close(Signal.END);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -202,12 +206,12 @@ public class WiimoteDevice extends Component implements Device, GestureListener
|
|||||||
wiimote = wiimoteService.getDevice(this);
|
wiimote = wiimoteService.getDevice(this);
|
||||||
//wiimote.activateContinuous();
|
//wiimote.activateContinuous();
|
||||||
//wiimote.activateMotionSensing();
|
//wiimote.activateMotionSensing();
|
||||||
ledWorker.start();
|
ledWork.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Listeners */
|
/* Listeners */
|
||||||
public void onButtonsEvent(WiimoteButtonsEvent event) {
|
public void onButtonsEvent(WiimoteButtonsEvent event) {
|
||||||
if (!active) {
|
if (!active()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
int pressed = event.getButtonsJustPressed() - event.getButtonsHeld();
|
int pressed = event.getButtonsJustPressed() - event.getButtonsHeld();
|
||||||
@@ -226,7 +230,7 @@ public class WiimoteDevice extends Component implements Device, GestureListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onMotionSensingEvent(MotionSensingEvent event) {
|
public void onMotionSensingEvent(MotionSensingEvent event) {
|
||||||
if (!active) {
|
if (!active()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gestureDevice.add(event.getGforce());
|
gestureDevice.add(event.getGforce());
|
||||||
@@ -243,10 +247,10 @@ public class WiimoteDevice extends Component implements Device, GestureListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class LedWorker extends ThreadWorker {
|
class LedWork extends Work {
|
||||||
protected ArrayCycle<Integer> ledCycle;
|
protected ArrayCycle<Integer> ledCycle;
|
||||||
|
|
||||||
public LedWorker() {
|
public LedWork() {
|
||||||
ledCycle = new ArrayCycle<Integer>();
|
ledCycle = new ArrayCycle<Integer>();
|
||||||
ledCycle.add(1);
|
ledCycle.add(1);
|
||||||
ledCycle.add(3);
|
ledCycle.add(3);
|
||||||
@@ -269,7 +273,7 @@ public class WiimoteDevice extends Component implements Device, GestureListener
|
|||||||
setLeds(1);
|
setLeds(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void work() {
|
public void work() {
|
||||||
setLeds(ledCycle.next());
|
setLeds(ledCycle.next());
|
||||||
sleep(LED_SLEEP);
|
sleep(LED_SLEEP);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,12 +19,12 @@ package mimis.device.wiimote;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
import mimis.exception.device.DeviceNotFoundException;
|
||||||
import base.exception.worker.ActivateException;
|
import base.exception.worker.ActivateException;
|
||||||
import base.exception.worker.DeactivateException;
|
import base.exception.worker.DeactivateException;
|
||||||
import base.worker.ThreadWorker;
|
import base.work.Work;
|
||||||
import mimis.exception.device.DeviceNotFoundException;
|
|
||||||
|
|
||||||
public class WiimoteDiscovery extends ThreadWorker {
|
public class WiimoteDiscovery extends Work {
|
||||||
protected static final String WIISCAN = "wiiscan";
|
protected static final String WIISCAN = "wiiscan";
|
||||||
protected static final int TIMEOUT = 1000;
|
protected static final int TIMEOUT = 1000;
|
||||||
protected WiimoteDevice wiimoteDevice;
|
protected WiimoteDevice wiimoteDevice;
|
||||||
@@ -54,11 +54,14 @@ public class WiimoteDiscovery extends ThreadWorker {
|
|||||||
String line = scanner.nextLine();
|
String line = scanner.nextLine();
|
||||||
if (line.contains("error: BluetoothSetServiceState()")) {
|
if (line.contains("error: BluetoothSetServiceState()")) {
|
||||||
disconnect = true;
|
disconnect = true;
|
||||||
|
scanner.close();
|
||||||
return false;
|
return false;
|
||||||
} else if (line.contains("[OK]")) {
|
} else if (line.contains("[OK]")) {
|
||||||
|
scanner.close();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
scanner.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
logger.error("", e);
|
logger.error("", e);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -78,7 +81,7 @@ public class WiimoteDiscovery extends ThreadWorker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void work() {
|
public void work() {
|
||||||
if (disconnect) {
|
if (disconnect) {
|
||||||
disconnect();
|
disconnect();
|
||||||
disconnect = false;
|
disconnect = false;
|
||||||
|
|||||||
@@ -24,9 +24,6 @@ import java.io.ObjectInputStream;
|
|||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import base.exception.worker.ActivateException;
|
|
||||||
import base.exception.worker.DeactivateException;
|
|
||||||
import base.worker.ThreadWorker;
|
|
||||||
import mimis.Component;
|
import mimis.Component;
|
||||||
import mimis.device.lirc.LircButton;
|
import mimis.device.lirc.LircButton;
|
||||||
import mimis.device.lirc.remote.PhiliphsRCLE011Button;
|
import mimis.device.lirc.remote.PhiliphsRCLE011Button;
|
||||||
@@ -37,6 +34,9 @@ import mimis.input.button.NumberButton;
|
|||||||
import mimis.input.state.State;
|
import mimis.input.state.State;
|
||||||
import mimis.value.Action;
|
import mimis.value.Action;
|
||||||
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
import wiiusej.wiiusejevents.physicalevents.MotionSensingEvent;
|
||||||
|
import base.exception.worker.ActivateException;
|
||||||
|
import base.exception.worker.DeactivateException;
|
||||||
|
import base.work.Work;
|
||||||
|
|
||||||
public class MotionDevice extends Component {
|
public class MotionDevice extends Component {
|
||||||
protected WiimoteDevice wiimoteDevice;
|
protected WiimoteDevice wiimoteDevice;
|
||||||
@@ -45,7 +45,7 @@ public class MotionDevice extends Component {
|
|||||||
protected boolean replay;
|
protected boolean replay;
|
||||||
protected Action action;
|
protected Action action;
|
||||||
|
|
||||||
public ReplayWorker replayWorker;
|
public ReplayWork replayWork;
|
||||||
public ArrayList<MotionData> motionList;
|
public ArrayList<MotionData> motionList;
|
||||||
|
|
||||||
public MotionDevice(WiimoteDevice wiimoteDevice) {
|
public MotionDevice(WiimoteDevice wiimoteDevice) {
|
||||||
@@ -54,7 +54,7 @@ public class MotionDevice extends Component {
|
|||||||
start = -1;
|
start = -1;
|
||||||
replay = false;
|
replay = false;
|
||||||
action = Action.TRAIN;
|
action = Action.TRAIN;
|
||||||
replayWorker = new ReplayWorker();
|
replayWork = new ReplayWork();
|
||||||
motionList = new ArrayList<MotionData>();
|
motionList = new ArrayList<MotionData>();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,13 +64,13 @@ public class MotionDevice extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void deactivate() throws DeactivateException {
|
public void deactivate() throws DeactivateException {
|
||||||
replayWorker.stop();
|
replayWork.stop();
|
||||||
super.deactivate();
|
super.deactivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void exit() {
|
public void exit() {
|
||||||
super.exit();
|
super.exit();
|
||||||
replayWorker.exit();
|
replayWork.exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void release(Button button) {
|
public void release(Button button) {
|
||||||
@@ -93,6 +93,8 @@ public class MotionDevice extends Component {
|
|||||||
case SCREEN_DOWN:
|
case SCREEN_DOWN:
|
||||||
wiimoteDevice.begin(Action.LOAD);
|
wiimoteDevice.begin(Action.LOAD);
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} else if (button instanceof NumberButton) {
|
} else if (button instanceof NumberButton) {
|
||||||
NumberButton numberButton = (NumberButton) button;
|
NumberButton numberButton = (NumberButton) button;
|
||||||
@@ -113,9 +115,9 @@ public class MotionDevice extends Component {
|
|||||||
start = System.currentTimeMillis();
|
start = System.currentTimeMillis();
|
||||||
break;
|
break;
|
||||||
case RED:
|
case RED:
|
||||||
if (replayWorker.active()) {
|
if (replayWork.active()) {
|
||||||
logger.debug("Stop replaying motion");
|
logger.debug("Stop replaying motion");
|
||||||
replayWorker.stop();
|
replayWork.stop();
|
||||||
} else {
|
} else {
|
||||||
logger.debug("Writing motion to file #" + id);
|
logger.debug("Writing motion to file #" + id);
|
||||||
try {
|
try {
|
||||||
@@ -136,8 +138,10 @@ public class MotionDevice extends Component {
|
|||||||
case YELLOW:
|
case YELLOW:
|
||||||
logger.debug("Replaying motion from file #" + id);
|
logger.debug("Replaying motion from file #" + id);
|
||||||
replay = true;
|
replay = true;
|
||||||
replayWorker.start();
|
replayWork.start();
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -151,11 +155,11 @@ public class MotionDevice extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class ReplayWorker extends ThreadWorker {
|
class ReplayWork extends Work {
|
||||||
protected ObjectInputStream objectInputStream;
|
protected ObjectInputStream objectInputStream;
|
||||||
protected int count, i, time;
|
protected int count, i, time;
|
||||||
|
|
||||||
protected void activate() throws ActivateException {
|
public void activate() throws ActivateException {
|
||||||
try {
|
try {
|
||||||
FileInputStream fileInputStream = new FileInputStream(String.format("tmp/motion #%d.bin", id));
|
FileInputStream fileInputStream = new FileInputStream(String.format("tmp/motion #%d.bin", id));
|
||||||
objectInputStream = new ObjectInputStream(fileInputStream);
|
objectInputStream = new ObjectInputStream(fileInputStream);
|
||||||
@@ -173,7 +177,7 @@ public class MotionDevice extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deactivate() throws DeactivateException {
|
public void deactivate() throws DeactivateException {
|
||||||
logger.debug(String.format("Replay stopped (%d ms)", time));
|
logger.debug(String.format("Replay stopped (%d ms)", time));
|
||||||
wiimoteDevice.end(action);
|
wiimoteDevice.end(action);
|
||||||
replay = false;
|
replay = false;
|
||||||
@@ -184,7 +188,8 @@ public class MotionDevice extends Component {
|
|||||||
}
|
}
|
||||||
super.deactivate();
|
super.deactivate();
|
||||||
}
|
}
|
||||||
protected void work() {
|
|
||||||
|
public void work() {
|
||||||
if (i++ < count) {
|
if (i++ < count) {
|
||||||
try {
|
try {
|
||||||
Object object = objectInputStream.readObject();
|
Object object = objectInputStream.readObject();
|
||||||
@@ -202,5 +207,4 @@ public class MotionDevice extends Component {
|
|||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
||||||
@@ -25,20 +25,20 @@ import javax.swing.JPanel;
|
|||||||
import javax.swing.JToggleButton;
|
import javax.swing.JToggleButton;
|
||||||
import javax.swing.border.TitledBorder;
|
import javax.swing.border.TitledBorder;
|
||||||
|
|
||||||
import base.worker.ThreadWorker;
|
import base.work.Work;
|
||||||
|
|
||||||
public class ButtonManager extends Manager {
|
public class ButtonManager extends Manager {
|
||||||
protected static final String TITLE = "Workers";
|
protected static final String TITLE = "Workers";
|
||||||
|
|
||||||
protected String title;
|
protected String title;
|
||||||
protected Map<ThreadWorker, WorkerButton> buttonMap;
|
protected Map<Work, WorkerButton> buttonMap;
|
||||||
|
|
||||||
public ButtonManager(ThreadWorker... workerArray) {
|
public ButtonManager(Work... workArray) {
|
||||||
this(TITLE, workerArray);
|
this(TITLE, workArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ButtonManager(String title, ThreadWorker... workerArray) {
|
public ButtonManager(String title, Work... workArray) {
|
||||||
super(workerArray);
|
super(workArray);
|
||||||
this.title = title;
|
this.title = title;
|
||||||
createButtons();
|
createButtons();
|
||||||
}
|
}
|
||||||
@@ -52,8 +52,8 @@ public class ButtonManager extends Manager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void createButtons() {
|
protected void createButtons() {
|
||||||
buttonMap = new HashMap<ThreadWorker, WorkerButton>();
|
buttonMap = new HashMap<Work, WorkerButton>();
|
||||||
for (ThreadWorker worker : workerList) {
|
for (Work worker : workList) {
|
||||||
WorkerButton button = new WorkerButton(worker);
|
WorkerButton button = new WorkerButton(worker);
|
||||||
buttonMap.put(worker, button);
|
buttonMap.put(worker, button);
|
||||||
}
|
}
|
||||||
@@ -84,8 +84,8 @@ public class ButtonManager extends Manager {
|
|||||||
return panel;
|
return panel;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void work() {
|
public void work() {
|
||||||
for (ThreadWorker worker : workerList) {
|
for (Work worker : workList) {
|
||||||
buttonMap.get(worker).setPressed(worker.active());
|
buttonMap.get(worker).setPressed(worker.active());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,25 +29,25 @@ import javax.swing.JPanel;
|
|||||||
import javax.swing.JRadioButton;
|
import javax.swing.JRadioButton;
|
||||||
import javax.swing.border.TitledBorder;
|
import javax.swing.border.TitledBorder;
|
||||||
|
|
||||||
import base.worker.ThreadWorker;
|
|
||||||
import mimis.Component;
|
import mimis.Component;
|
||||||
import mimis.input.Task;
|
import mimis.input.Task;
|
||||||
import mimis.router.Router;
|
import mimis.router.Router;
|
||||||
import mimis.util.ArrayCycle;
|
|
||||||
import mimis.value.Action;
|
import mimis.value.Action;
|
||||||
import mimis.value.Signal;
|
import mimis.value.Signal;
|
||||||
import mimis.value.Target;
|
import mimis.value.Target;
|
||||||
|
import base.util.ArrayCycle;
|
||||||
|
import base.work.Work;
|
||||||
|
|
||||||
public class CurrentButtonManager extends ButtonManager implements ActionListener {
|
public class CurrentButtonManager extends ButtonManager implements ActionListener {
|
||||||
protected Router router;
|
protected Router router;
|
||||||
protected ArrayCycle<Component> componentCycle;
|
protected ArrayCycle<Component> componentCycle;
|
||||||
protected Map<JRadioButton, ThreadWorker> radioButtonMap;
|
protected Map<JRadioButton, Work> radioButtonMap;
|
||||||
|
|
||||||
public CurrentButtonManager(Router router, ArrayCycle<Component> componentCycle, String title, ThreadWorker... workerArray) {
|
public CurrentButtonManager(Router router, ArrayCycle<Component> componentCycle, String title, Work... workArray) {
|
||||||
super(title, workerArray);
|
super(title, workArray);
|
||||||
this.componentCycle = componentCycle;
|
this.componentCycle = componentCycle;
|
||||||
this.router = router;
|
this.router = router;
|
||||||
radioButtonMap = new HashMap<JRadioButton, ThreadWorker>();
|
radioButtonMap = new HashMap<JRadioButton, Work>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public JPanel createPanel() {
|
public JPanel createPanel() {
|
||||||
@@ -77,7 +77,7 @@ public class CurrentButtonManager extends ButtonManager implements ActionListene
|
|||||||
JRadioButton radioButton = new JRadioButton();
|
JRadioButton radioButton = new JRadioButton();
|
||||||
buttonGroup.add(radioButton);
|
buttonGroup.add(radioButton);
|
||||||
radioButton.addActionListener(this);
|
radioButton.addActionListener(this);
|
||||||
radioButtonMap.put(radioButton, button.worker);
|
radioButtonMap.put(radioButton, button.work);
|
||||||
gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
|
gridBagConstraints.gridwidth = GridBagConstraints.REMAINDER;
|
||||||
gridBagConstraints.weightx = 0;
|
gridBagConstraints.weightx = 0;
|
||||||
gridBagLayout.setConstraints(radioButton, gridBagConstraints);
|
gridBagLayout.setConstraints(radioButton, gridBagConstraints);
|
||||||
@@ -89,7 +89,7 @@ public class CurrentButtonManager extends ButtonManager implements ActionListene
|
|||||||
public void actionPerformed(ActionEvent event) {
|
public void actionPerformed(ActionEvent event) {
|
||||||
JRadioButton radioButton = (JRadioButton) event.getSource();
|
JRadioButton radioButton = (JRadioButton) event.getSource();
|
||||||
if (radioButtonMap.containsKey(radioButton)) {
|
if (radioButtonMap.containsKey(radioButton)) {
|
||||||
ThreadWorker worker = radioButtonMap.get(radioButton);
|
Work worker = radioButtonMap.get(radioButton);
|
||||||
if (componentCycle.contains(worker)) {
|
if (componentCycle.contains(worker)) {
|
||||||
while (!componentCycle.current().equals(worker)) {
|
while (!componentCycle.current().equals(worker)) {
|
||||||
componentCycle.next();
|
componentCycle.next();
|
||||||
@@ -100,9 +100,9 @@ public class CurrentButtonManager extends ButtonManager implements ActionListene
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void currentChanged() {
|
public void currentChanged() {
|
||||||
ThreadWorker worker = componentCycle.current();
|
Work worker = componentCycle.current();
|
||||||
if (radioButtonMap.containsValue(worker)) {
|
if (radioButtonMap.containsValue(worker)) {
|
||||||
for (Entry<JRadioButton, ThreadWorker> entry : radioButtonMap.entrySet()) {
|
for (Entry<JRadioButton, Work> entry : radioButtonMap.entrySet()) {
|
||||||
if (entry.getValue().equals(worker)) {
|
if (entry.getValue().equals(worker)) {
|
||||||
JRadioButton radioButton = (JRadioButton) entry.getKey();
|
JRadioButton radioButton = (JRadioButton) entry.getKey();
|
||||||
radioButton.setSelected(true);
|
radioButton.setSelected(true);
|
||||||
|
|||||||
@@ -20,47 +20,47 @@ import java.util.ArrayList;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import base.exception.worker.DeactivateException;
|
import base.exception.worker.DeactivateException;
|
||||||
import base.worker.ThreadIntervalWorker;
|
import base.work.Work;
|
||||||
import base.worker.ThreadWorker;
|
import base.worker.IntervalWork;
|
||||||
|
|
||||||
public class Manager extends ThreadIntervalWorker {
|
public class Manager extends IntervalWork {
|
||||||
protected static final int INTERVAL = 1000;
|
protected static final int INTERVAL = 1000;
|
||||||
|
|
||||||
protected ArrayList<ThreadWorker> workerList;
|
protected ArrayList<Work> workList;
|
||||||
|
|
||||||
public Manager(ThreadWorker... workerArray) {
|
public Manager(Work... workArray) {
|
||||||
workerList = new ArrayList<ThreadWorker>();
|
workList = new ArrayList<Work>();
|
||||||
add(workerArray);
|
add(workArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void add(ThreadWorker... workerArray) {
|
public void add(Work... workArray) {
|
||||||
workerList.addAll(Arrays.asList(workerArray));
|
workList.addAll(Arrays.asList(workArray));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void remove(ThreadWorker... workerArray) {
|
public void remove(Work... workArray) {
|
||||||
workerList.removeAll(Arrays.asList(workerArray));
|
workList.removeAll(Arrays.asList(workArray));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deactivate() throws DeactivateException {
|
public void deactivate() throws DeactivateException {
|
||||||
super.deactivate();
|
super.deactivate();
|
||||||
for (ThreadWorker worker : workerList) {
|
for (Work worker : workList) {
|
||||||
worker.stop();
|
worker.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void exit() {
|
public void exit() {
|
||||||
super.exit();
|
super.exit();
|
||||||
for (ThreadWorker worker : workerList) {
|
for (Work worker : workList) {
|
||||||
worker.exit();
|
worker.exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int count() {
|
public int count() {
|
||||||
return workerList.size();
|
return workList.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void work() {
|
public void work() {
|
||||||
for (ThreadWorker worker : workerList) {
|
for (Work worker : workList) {
|
||||||
worker.active();
|
worker.active();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,16 +26,16 @@ import mimis.Component;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import base.worker.ThreadWorker;
|
import base.work.Work;
|
||||||
|
|
||||||
public class WorkerButton extends JToggleButton implements MouseListener {
|
public class WorkerButton extends JToggleButton implements MouseListener {
|
||||||
protected static final long serialVersionUID = 1L;
|
protected static final long serialVersionUID = 1L;
|
||||||
protected Logger logger = LoggerFactory.getLogger(getClass());
|
protected Logger logger = LoggerFactory.getLogger(getClass());
|
||||||
|
|
||||||
protected ThreadWorker worker;
|
protected Work work;
|
||||||
|
|
||||||
public WorkerButton(ThreadWorker worker) {
|
public WorkerButton(Work worker) {
|
||||||
this.worker = worker;
|
this.work = worker;
|
||||||
setFocusable(false);
|
setFocusable(false);
|
||||||
addMouseListener(this);
|
addMouseListener(this);
|
||||||
if (worker instanceof Component) {
|
if (worker instanceof Component) {
|
||||||
@@ -44,12 +44,12 @@ public class WorkerButton extends JToggleButton implements MouseListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void mouseClicked(MouseEvent event) {
|
public void mouseClicked(MouseEvent event) {
|
||||||
if (worker.active()) {
|
if (work.active()) {
|
||||||
logger.trace("Stop");
|
logger.trace("Stop");
|
||||||
worker.stop();
|
work.stop();
|
||||||
} else {
|
} else {
|
||||||
logger.trace("Start");
|
logger.trace("Start");
|
||||||
worker.start();
|
work.start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,11 +21,11 @@ import java.io.ObjectInputStream;
|
|||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
|
||||||
import base.exception.worker.ActivateException;
|
|
||||||
import base.exception.worker.DeactivateException;
|
|
||||||
import base.worker.ThreadWorker;
|
|
||||||
import mimis.input.Feedback;
|
import mimis.input.Feedback;
|
||||||
import mimis.input.Task;
|
import mimis.input.Task;
|
||||||
|
import base.exception.worker.ActivateException;
|
||||||
|
import base.exception.worker.DeactivateException;
|
||||||
|
import base.work.Work;
|
||||||
|
|
||||||
public class GlobalRouter extends Router {
|
public class GlobalRouter extends Router {
|
||||||
protected String ip;
|
protected String ip;
|
||||||
@@ -37,7 +37,7 @@ public class GlobalRouter extends Router {
|
|||||||
this.port = port;
|
this.port = port;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void activate() throws ActivateException {
|
public void activate() throws ActivateException {
|
||||||
try {
|
try {
|
||||||
client = new Client(ip, port);
|
client = new Client(ip, port);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
@@ -47,7 +47,7 @@ public class GlobalRouter extends Router {
|
|||||||
super.activate();
|
super.activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deactivate() throws DeactivateException {
|
public void deactivate() throws DeactivateException {
|
||||||
super.deactivate();
|
super.deactivate();
|
||||||
client.stop();
|
client.stop();
|
||||||
}
|
}
|
||||||
@@ -60,7 +60,7 @@ public class GlobalRouter extends Router {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class Client extends ThreadWorker {
|
class Client extends Work {
|
||||||
protected Socket socket;
|
protected Socket socket;
|
||||||
protected ObjectInputStream objectInputStream;
|
protected ObjectInputStream objectInputStream;
|
||||||
protected ObjectOutputStream objectOutputStream;
|
protected ObjectOutputStream objectOutputStream;
|
||||||
@@ -87,7 +87,7 @@ public class GlobalRouter extends Router {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void deactivate() throws DeactivateException {
|
public void deactivate() throws DeactivateException {
|
||||||
super.deactivate();
|
super.deactivate();
|
||||||
try {
|
try {
|
||||||
objectInputStream.close();
|
objectInputStream.close();
|
||||||
|
|||||||
@@ -17,11 +17,12 @@
|
|||||||
package mimis.state;
|
package mimis.state;
|
||||||
|
|
||||||
import mimis.input.Input;
|
import mimis.input.Input;
|
||||||
import mimis.util.ArrayCycle;
|
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import base.util.ArrayCycle;
|
||||||
|
|
||||||
public class TaskMapCycle extends ArrayCycle<TaskMap> implements Input {
|
public class TaskMapCycle extends ArrayCycle<TaskMap> implements Input {
|
||||||
protected static final long serialVersionUID = 1L;
|
protected static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ package mimis.util.swing;
|
|||||||
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
import mimis.util.ArrayCycle;
|
import base.util.ArrayCycle;
|
||||||
|
|
||||||
|
|
||||||
public class CycleButton extends HoldButton {
|
public class CycleButton extends HoldButton {
|
||||||
|
|||||||
@@ -18,8 +18,7 @@ package mimis.util.swing;
|
|||||||
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
import mimis.util.ArrayCycle;
|
import base.util.ArrayCycle;
|
||||||
|
|
||||||
|
|
||||||
public class ToggleButton extends CycleButton {
|
public class ToggleButton extends CycleButton {
|
||||||
protected static final long serialVersionUID = 1L;
|
protected static final long serialVersionUID = 1L;
|
||||||
|
|||||||
Reference in New Issue
Block a user