SensorTemperatureStateDataComparator.java
Go to the documentation of this file.
00001 package org.rosbuilding.common.temperature;
00002 
00003 import sensor_msgs.Temperature;
00004 
00005 import org.ros.node.ConnectedNode;
00006 import org.rosbuilding.common.StateDataComparator;
00007 
00008 import smarthome_heater_msgs.SensorTemperatureStateData;
00009 
00010 public class SensorTemperatureStateDataComparator implements StateDataComparator<SensorTemperatureStateData> {
00011 
00012     @Override
00013     public boolean isEquals(SensorTemperatureStateData state1, SensorTemperatureStateData state2) {
00014         boolean result = (state1 == null && state2 == null)
00015                 || (state1 != null && state2 != null
00016                         && state1.getTemperatureAmbiant().getTemperature()
00017                                 == state2.getTemperatureAmbiant().getTemperature()
00018                         && state1.getTemperatureAmbiant().getVariance()
00019                                 == state2.getTemperatureAmbiant().getVariance()
00020                         && state1.getTemperatureObject().getTemperature()
00021                                 == state2.getTemperatureObject().getTemperature()
00022                         && state1.getTemperatureObject().getVariance()
00023                                 == state2.getTemperatureObject().getVariance());
00024         return result;
00025     }
00026 
00027     @Override
00028     public SensorTemperatureStateData makeNewCopy(ConnectedNode connectedNode, String frameId,
00029             SensorTemperatureStateData stateData) {
00030         SensorTemperatureStateData result = connectedNode.getTopicMessageFactory()
00031                 .newFromType(SensorTemperatureStateData._TYPE);
00032         result.getHeader().setFrameId(frameId);
00033         result.getHeader().setStamp(connectedNode.getCurrentTime());
00034         result.setState(stateData.getState());
00035         result.setTemperatureAmbiant(makeNewCopy(connectedNode, frameId, stateData.getTemperatureAmbiant()));
00036         result.setTemperatureObject(makeNewCopy(connectedNode, frameId, stateData.getTemperatureObject()));
00037 
00038         return result;
00039     }
00040 
00041     public static Temperature makeNewCopy(
00042             ConnectedNode connectedNode,
00043             String frameId,
00044             Temperature temperature) {
00045 
00046         Temperature result = connectedNode.getTopicMessageFactory()
00047                 .newFromType(Temperature._TYPE);
00048 
00049         result.getHeader().setStamp(connectedNode.getCurrentTime());
00050         result.getHeader().setFrameId(frameId);
00051         result.setTemperature(temperature.getTemperature());
00052         result.setVariance(temperature.getVariance());
00053 
00054         return result;
00055     }
00056 
00057 }


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