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.HeatingStateData;
00009 import smarthome_heater_msgs.HeatingTemperatureSlot;
00010
00011 public class HeaterTemperatureStateDataComparator implements StateDataComparator<HeatingStateData> {
00012
00013 @Override
00014 public boolean isEquals(HeatingStateData stateData1, HeatingStateData stateData2) {
00015 boolean result = (stateData1 == null && stateData2 == null)
00016 || (stateData1 != null && stateData2 != null
00017 && stateData1.getProportional()
00018 == stateData2.getProportional()
00019 && stateData1.getIntegral()
00020 == stateData2.getIntegral()
00021 && stateData1.getDerivative()
00022 == stateData2.getDerivative()
00023 && isEquals(
00024 stateData1.getTemperatureGoal(),
00025 stateData2.getTemperatureGoal())
00026 && isEquals(
00027 stateData1.getTemperatureReal(),
00028 stateData2.getTemperatureReal())
00029 && isEquals(
00030 stateData1.getTimeSlotCurrent(),
00031 stateData2.getTimeSlotCurrent()));
00032
00033 return result;
00034 }
00035
00036 public boolean isEquals(HeatingTemperatureSlot stateData1, HeatingTemperatureSlot stateData2) {
00037
00038 boolean result = (stateData1 == null && stateData2 == null)
00039 || (stateData1 != null && stateData2 != null
00040 && stateData1.getDateBegin()
00041 == stateData2.getDateBegin()
00042 && stateData1.getDateEnd()
00043 == stateData2.getDateEnd()
00044 && stateData1.getFrequency()
00045 == stateData2.getFrequency()
00046 && stateData1.getFrequencyUnit()
00047 == stateData2.getFrequencyUnit()
00048 && stateData1.getPriority()
00049 == stateData2.getPriority()
00050 && stateData1.getTemperature()
00051 == stateData2.getTemperature());
00052
00053 return result;
00054 }
00055
00056 public boolean isEquals(Temperature stateData1, Temperature stateData2) {
00057
00058 boolean result = (stateData1 == null && stateData2 == null)
00059 || (stateData1 != null && stateData2 != null
00060 && stateData1.getTemperature()
00061 == stateData2.getTemperature()
00062 && stateData1.getVariance()
00063 == stateData2.getVariance());
00064
00065 return result;
00066 }
00067
00068 @Override
00069 public HeatingStateData makeNewCopy(
00070 ConnectedNode connectedNode,
00071 String frameId,
00072 HeatingStateData stateData) {
00073
00074 HeatingStateData result = connectedNode.getTopicMessageFactory()
00075 .newFromType(HeatingStateData._TYPE);
00076
00077 result.getHeader().setFrameId(frameId);
00078 result.getHeader().setStamp(connectedNode.getCurrentTime());
00079 result.setProportional(stateData.getProportional());
00080 result.setIntegral(stateData.getIntegral());
00081 result.setDerivative(stateData.getDerivative());
00082 result.setTemperatureGoal(SensorTemperatureStateDataComparator.makeNewCopy(connectedNode, frameId, stateData.getTemperatureGoal()));
00083 result.setTemperatureReal(SensorTemperatureStateDataComparator.makeNewCopy(connectedNode, frameId, stateData.getTemperatureReal()));
00084 result.setTimeSlotCurrent(makeNewCopy(connectedNode, frameId, stateData.getTimeSlotCurrent()));
00085
00086 return result;
00087 }
00088
00089 public static HeatingTemperatureSlot makeNewCopy(
00090 ConnectedNode connectedNode,
00091 String frameId,
00092 HeatingTemperatureSlot data) {
00093
00094 HeatingTemperatureSlot result = connectedNode.getTopicMessageFactory()
00095 .newFromType(HeatingTemperatureSlot._TYPE);
00096
00097 result.getHeader().setFrameId(frameId);
00098 result.getHeader().setStamp(connectedNode.getCurrentTime());
00099
00100 result.setDateBegin(data.getDateBegin());
00101 result.setDateEnd(data.getDateEnd());
00102 result.setFrequency(data.getFrequency());
00103 result.setFrequencyUnit(data.getFrequencyUnit());
00104 result.setPriority(data.getPriority());
00105 result.setTemperature(data.getTemperature());
00106
00107 return result;
00108 }
00109 }