/* =================================================================== * PowerDatum.java * * Created Aug 13, 2008 2:28:50 PM * * Copyright (c) 2008 Matt Magoffin. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as * published by the Free Software Foundation; either version 2 of * the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * 02111-1307 USA * =================================================================== * $Id$ * =================================================================== */ package net.solarnetwork.central.datum.domain; /** * Domain object for a unit of generation data collected from a node. * * @author matt * @version $Revision$ $Date$ */ public class PowerDatum extends BaseNodeDatum implements LocationDatum { private static final long serialVersionUID = -3789283457327334343L; private Long locationId = null; private Integer watts = null; // watts generated by PV private Float batteryVolts = null; // this is the volts on the battery private Float batteryAmpHours = null; // this is the storage level in amp hours on the battery private Long wattHourReading = null; // Wh today, or cumulative // these are for backwards compatibility only private Float pvVolts = null; // this is the volts on the PV private Float pvAmps = null; // this is the current in amps from the PV @Override public String toString() { return "PowerDatum{nodeId=" +getNodeId() +",sourceId=" +getSourceId() +",watts=" +getWatts() +",batVolts=" +this.batteryVolts +",wattHourReading=" +this.wattHourReading +'}'; } /** * For backwards compatibility, this field converts the value to Wh * and stores the value on the {@code wattHourReading} field. * * @param wattHoursToday */ public void setKWattHoursToday(Float kWattHoursToday) { if ( kWattHoursToday == null ) { wattHourReading = null; } else { wattHourReading = Long.valueOf(Math.round( kWattHoursToday.doubleValue() * 1000.0)); } } /** * Get the watts. * * <p>This will return the {@code watts} value if available, or * fall back to {@code amps} * {@code volts}.<?p> * * @return watts, or <em>null</em> if watts not available and * either amps or volts are null */ public Integer getWatts() { if ( watts != null ) { return watts; } if ( pvAmps == null || pvVolts == null ) { return null; } return Integer.valueOf((int)Math.round( pvAmps.doubleValue() * pvVolts.doubleValue())); } // for backwards compatibility only public void setPvVolts(Float pvVolts) { this.pvVolts = pvVolts; } // for backwards compatibility only public void setPvAmps(Float pvAmps) { this.pvAmps = pvAmps; } public Float getBatteryVolts() { return batteryVolts; } public void setBatteryVolts(Float batteryVolts) { this.batteryVolts = batteryVolts; } public Float getBatteryAmpHours() { return batteryAmpHours; } public void setBatteryAmpHours(Float batteryAmpHours) { this.batteryAmpHours = batteryAmpHours; } public Long getLocationId() { return locationId; } public void setLocationId(Long locationId) { this.locationId = locationId; } public Long getWattHourReading() { return wattHourReading; } public void setWattHourReading(Long wattHourReading) { this.wattHourReading = wattHourReading; } public void setWatts(Integer watts) { this.watts = watts; } }