MediaStateDataComparator.java
Go to the documentation of this file.
00001 package org.rosbuilding.common.media;
00002 
00003 import smarthome_media_msgs.MonitorInfo;
00004 import smarthome_media_msgs.PlayerInfo;
00005 import smarthome_media_msgs.SpeakerInfo;
00006 import smarthome_media_msgs.StateData;
00007 
00008 import org.ros.node.ConnectedNode;
00009 import org.rosbuilding.common.StateDataComparator;
00010 
00011 public class MediaStateDataComparator implements StateDataComparator<StateData> {
00012 
00013     @Override
00014     public boolean isEquals(StateData state1, StateData state2) {
00015         boolean result = (state1 != null && state2 != null);
00016         if (result) {
00017             result &= state1.getState() == state2.getState();
00018             result &= isEqual(state1.getMonitor(),  state2.getMonitor());
00019             result &= isEqual(state1.getPlayer(),   state2.getPlayer());
00020             result &= isEqual(state1.getSpeaker(),  state2.getSpeaker());
00021         }
00022         return result;
00023     }
00024 
00025     @Override
00026     public StateData makeNewCopy(ConnectedNode conectedNode, String frameId,
00027             StateData stateData) {
00028         StateData result = conectedNode.getTopicMessageFactory().newFromType(StateData._TYPE);
00029         result.getHeader().setFrameId(frameId);
00030         result.getHeader().setStamp(conectedNode.getCurrentTime());
00031         result.setState(stateData.getState());
00032         result.setMonitor(makeNewCopy(conectedNode, stateData.getMonitor()));
00033         result.setPlayer(makeNewCopy(conectedNode, stateData.getPlayer()));
00034         result.setSpeaker(makeNewCopy(conectedNode, stateData.getSpeaker()));
00035 
00036         return result;
00037     }
00038 
00039     private static SpeakerInfo makeNewCopy(ConnectedNode conectedNode,
00040             SpeakerInfo speaker) {
00041         SpeakerInfo result = conectedNode.getTopicMessageFactory().newFromType(SpeakerInfo._TYPE);
00042         if (speaker != null) {
00043             result.setChannel(speaker.getChannel());
00044             result.setLevel(speaker.getLevel());
00045             result.setMuted(speaker.getMuted());
00046             result.setOutput(speaker.getOutput());
00047             result.setSource(speaker.getSource());
00048         }
00049         return result;
00050     }
00051 
00052     private static PlayerInfo makeNewCopy(ConnectedNode conectedNode,
00053             PlayerInfo player) {
00054         PlayerInfo result = conectedNode.getTopicMessageFactory().newFromType(PlayerInfo._TYPE);
00055         if (player != null) {
00056             result.setCanseek(player.getCanseek());
00057             result.setFile(player.getFile());
00058             result.setMediaid(player.getMediaid());
00059             result.getMediatype().setValue(player.getMediatype().getValue());;
00060             result.setSpeed(player.getSpeed());
00061             result.setStamp(player.getStamp());
00062             result.setState(player.getState());
00063             result.setSubtitleenabled(player.getSubtitleenabled());
00064             result.setThumbnail(player.getThumbnail());
00065             result.setTitle(player.getTitle());
00066             result.setTotaltime(player.getTotaltime());
00067         }
00068         return result;
00069     }
00070 
00071     private static MonitorInfo makeNewCopy(ConnectedNode conectedNode,
00072             MonitorInfo monitor) {
00073         MonitorInfo result = conectedNode.getTopicMessageFactory().newFromType(MonitorInfo._TYPE);
00074         if (monitor != null) {
00075             result.setHeight(monitor.getHeight());
00076             result.setWigth(monitor.getWigth());
00077             result.setSource(monitor.getSource());
00078         }
00079         return result;
00080     }
00081 
00082     private static boolean isEqual(SpeakerInfo speaker1, SpeakerInfo speaker2) {
00083         boolean result = (speaker1 != null && speaker2 != null);
00084         if (result) {
00085             result &= speaker1.getChannel().equals(speaker2.getChannel());
00086             result &= speaker1.getLevel() == speaker2.getLevel();
00087             result &= speaker1.getMuted() == speaker2.getMuted();
00088             result &= speaker1.getOutput() == speaker2.getOutput();
00089             result &= speaker1.getSource().equals(speaker1.getSource());
00090         }
00091         return result;
00092     }
00093 
00094     private static boolean isEqual(PlayerInfo player1, PlayerInfo player2) {
00095         boolean result = (player1 != null && player2 != null);
00096         if (result) {
00097             result &= player1.getCanseek() == player2.getCanseek();
00098             result &= player1.getSubtitleenabled() == player2.getSubtitleenabled();
00099             result &= player1.getFile().equals(player2.getFile());
00100             result &= player1.getMediaid() == player2.getMediaid();
00101             result &= player1.getMediatype().getValue().equals(player2.getMediatype().getValue());
00102             result &= player1.getSpeed() == player2.getSpeed();
00103             result &= player1.getStamp().equals(player2.getStamp());
00104             result &= player1.getState() == player2.getState();
00105             result &= player1.getThumbnail().equals(player2.getThumbnail());
00106             result &= player1.getTitle().equals(player2.getTitle());
00107             result &= player1.getTotaltime().equals(player2.getTotaltime());
00108         }
00109         return result;
00110     }
00111 
00112     private static boolean isEqual(MonitorInfo monitor1, MonitorInfo monitor2) {
00113         boolean result = (monitor1 != null && monitor2 != null);
00114         if (result) {
00115             result &= monitor1.getHeight() == monitor2.getHeight();
00116             result &= monitor1.getWigth() == monitor2.getWigth();
00117             result &= monitor1.getSource().equals(monitor2.getSource());
00118         }
00119         return result;
00120     }
00121 
00122 }


smarthome_common_driver
Author(s): Mickael Gaillard , Erwan Le Huitouze
autogenerated on Sat Jun 8 2019 19:35:17