Go to the documentation of this file.00001
00009 package org.rosmultimedia.player.onkyo;
00010
00011 import org.rosbuilding.common.ISystem;
00012 import org.rosmultimedia.player.onkyo.eiscp.OnkyoEiscp;
00013
00014 import de.csmp.jeiscp.eiscp.EiscpCommmandsConstants;
00015
00016 import smarthome_media_msgs.MediaAction;
00017 import smarthome_media_msgs.StateData;
00018
00025 public class OnkyoSystem implements ISystem<StateData, MediaAction> {
00029 private OnkyoNode onkyoNode;
00030
00034 private OnkyoEiscp onkyoEiscp;
00035
00041 public OnkyoSystem(OnkyoEiscp onkyoEiscp, OnkyoNode onkyoNode) {
00042 this.onkyoEiscp = onkyoEiscp;
00043 this.onkyoNode = onkyoNode;
00044 }
00045
00046 @Override
00047 public void load(StateData stateData) {
00048 String power = this.onkyoEiscp.sendCommand(
00049 EiscpCommmandsConstants.SYSTEM_POWER_QUERY_ISCP);
00050
00051 if (power.equals(EiscpCommmandsConstants.SYSTEM_POWER_ON_ISCP)) {
00052 stateData.setState(StateData.ENABLE);
00053 } else if (power.equals(EiscpCommmandsConstants.SYSTEM_POWER_STANDBY_ISCP)) {
00054 stateData.setState(StateData.SHUTDOWN);
00055 } else {
00056 stateData.setState(StateData.UNKNOWN);
00057 }
00058 }
00059
00060 @Override
00061 public void callbackCmdAction(MediaAction message, StateData stateData) {
00062 this.onkyoNode.logD("Onkyo System launch command : "
00063 + message.getMethod());
00064
00065 switch (message.getMethod()) {
00066 case OP_POWER:
00067 this.onkyoEiscp.sendCommand(
00068 EiscpCommmandsConstants.SYSTEM_POWER_ON_ISCP);
00069 break;
00070 case OP_SHUTDOWN:
00071 this.onkyoEiscp.sendCommand(
00072 EiscpCommmandsConstants.SYSTEM_POWER_STANDBY_ISCP);
00073 break;
00074 }
00075 }
00076 }