SamsungMonitor.java
Go to the documentation of this file.
00001 
00009 package org.rosmultimedia.player.samsung.internal;
00010 
00011 import java.io.IOException;
00012 
00013 import org.rosbuilding.common.media.IMonitor;
00014 import org.rosmultimedia.player.samsung.SamsungCommand;
00015 import org.rosmultimedia.player.samsung.SamsungTvNode;
00016 
00017 import smarthome_media_msgs.MediaAction;
00018 import smarthome_media_msgs.StateData;
00019 
00025 public class SamsungMonitor implements IMonitor {
00026 
00027     public final static String TV    = "tv";
00028     public final static String HDMI  = "hdmi";
00029     public final static String HDMI1 = HDMI + "1";
00030     public final static String HDMI2 = "xbmc"; // HDMI + "2";
00031     public final static String HDMI3 = "ps3"; // HDMI + "3";
00032     public final static String HDMI4 = HDMI + "4";
00033 
00034     public final static String INFO  = "info";
00035     public final static String GUIDE = "guide";
00036     public final static String TOOLS = "tools";
00037 
00038     protected static final String PROTO_CHANNEL = "channel://";
00039     private SamsungTvNode node;
00040 
00041     public SamsungMonitor(SamsungTvNode owner) {
00042         this.node = owner;
00043     }
00044 
00045     @Override
00046     public void load(StateData stateData) {
00047         // TODO Auto-generated method stub
00048     }
00049 
00050     @Override
00051     public void callbackCmdAction(MediaAction message, StateData stateData)
00052             throws IOException, InterruptedException {
00053 
00054         switch (message.getMethod()) {
00055         case OP_CHANNEL:
00056             switch (message.getUri()) {
00057             case (PROTO_CHANNEL + TV):
00058                 this.node.pushEnum( SamsungCommand.KEY_TV, 2f );
00059                 break;
00060 
00061             case (PROTO_CHANNEL + HDMI1):
00062                 this.node.pushEnum( SamsungCommand.KEY_TV, 2f );
00063                 break;
00064 
00065             case (PROTO_CHANNEL + HDMI2): // Switch on XBMC
00066                 this.node.pushEnum( SamsungCommand.KEY_AUTO_ARC_PIP_WIDE, 2f);
00067                 break; //FIXME by hdmi2 resolv in 3th node
00068 
00069             case (PROTO_CHANNEL + HDMI3): // Switch on PS3
00070                 this.node.pushEnum( SamsungCommand.KEY_AUTO_ARC_PIP_RIGHT_BOTTOM, 2f);
00071                 break; //FIXME by hdmi3 resolv in 3th node
00072 
00073             case (PROTO_CHANNEL + HDMI2 + TV): //FIXME by tv-hdmi2 resolv in 3th node
00074             case (PROTO_CHANNEL + HDMI3 + TV): //FIXME by tv-hdmi3 resolv in 3th node
00075             case (PROTO_CHANNEL + TV + HDMI2):
00076             case (PROTO_CHANNEL + TV + HDMI3):
00077                 // Switch on HDMI
00078                 if ((PROTO_CHANNEL + HDMI2 + TV).equals(message.getUri())) {
00079                     this.node.pushEnum( SamsungCommand.KEY_AUTO_ARC_PIP_WIDE, 2f);
00080                 } else
00081 
00082                 if ((PROTO_CHANNEL + HDMI3 + TV).equals(message.getUri())) {
00083                     this.node.pushEnum( SamsungCommand.KEY_AUTO_ARC_PIP_RIGHT_BOTTOM, 2f);
00084                 }
00085 
00086                 // Activate PIP
00087                 this.node.pushEnum( SamsungCommand.KEY_PIP_ONOFF, 2f);
00088 
00089                 if (true) {
00090                     // Menu for Sound channel
00091                     this.node.pushEnum( SamsungCommand.KEY_TOOLS, 1f );
00092                     this.node.pushEnum( SamsungCommand.KEY_UP );
00093                     this.node.pushEnum( SamsungCommand.KEY_UP );
00094                     this.node.pushEnum( SamsungCommand.KEY_RIGHT, 0.75f);
00095                     this.node.pushEnum( SamsungCommand.KEY_UP );
00096                     this.node.pushEnum( SamsungCommand.KEY_RIGHT, 0.5f ); // Switch sound
00097                     this.node.pushEnum( SamsungCommand.KEY_RETURN, 0.75f );
00098                     this.node.pushEnum( SamsungCommand.KEY_RETURN );
00099                 }
00100                 break;
00101             }
00102 
00103             // Show Channel
00104             String subUri = message.getUri().replace(PROTO_CHANNEL, "");
00105             if ( SamsungTvNode.isInteger(subUri)) {
00106                 int value = Integer.valueOf(subUri);
00107                 int cent = value / 100 % 10;
00108                 int disa = value / 10 % 10;
00109                 int digit = value % 10;
00110 
00111 //                if (true == false) { // if not in TV mode
00112 //                    this.node.pushEnum( SamsungCommand.KEY_TV, 2f );
00113 //                }
00114 
00115                 if (true) {
00116                     float timeout = 0.4f;
00117                     if(digit > 0 || cent > 0) {
00118                         if (cent > 0) {
00119                             this.node.pushEnum(
00120                                     SamsungCommand.fromName(
00121                                             SamsungCommand.KEY + cent),
00122                                             timeout );
00123                         }
00124                         if (disa > 0 || cent > 0) {
00125                             this.node.pushEnum(
00126                                     SamsungCommand.fromName(
00127                                             SamsungCommand.KEY  + disa),
00128                                             timeout );
00129                         }
00130                     }
00131                     this.node.pushEnum(
00132                             SamsungCommand.fromName(
00133                                     SamsungCommand.KEY  + digit),
00134                                     timeout );
00135                     this.node.pushEnum( SamsungCommand.KEY_ENTER );
00136                 }
00137             }
00138             break;
00139 
00140             // Show Guide
00141         case GUIDE:
00142             this.node.pushEnum( SamsungCommand.KEY_GUIDE );
00143             break;
00144 
00145             // Show Tools
00146         case TOOLS:
00147             this.node.pushEnum( SamsungCommand.KEY_TOOLS );
00148             break;
00149 
00150 
00151         default:
00152             // Send internal command
00153             if (message.getMethod().contains(SamsungCommand.KEY )) {
00154                 SamsungCommand cmd = SamsungCommand.fromName(
00155                         message.getMethod());
00156                 if (cmd != null) {
00157                     this.node.pushEnum(cmd);
00158                 } else {
00159                     this.node.logE(
00160                             String.format("Key \"%s\" command not found",
00161                                     message.getMethod()));
00162                 }
00163             } else
00164 
00165             // Else bypass the command
00166             {
00167                 this.node.sendText( message.getMethod() );
00168             }
00169 
00170             break;
00171         }
00172 
00173     }
00174 }


smarthome_media_samsungtv_driver
Author(s): Mickael Gaillard , Erwan Le Huitouze
autogenerated on Thu Jun 6 2019 21:03:50