001/** 002 * Copyright 2018 Tampere University of Technology, Pori Department 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package service.tut.pori.apilta.shock.datatypes; 017 018import java.util.Date; 019 020import javax.xml.bind.annotation.XmlAccessType; 021import javax.xml.bind.annotation.XmlAccessorType; 022import javax.xml.bind.annotation.XmlElement; 023import javax.xml.bind.annotation.XmlRootElement; 024import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; 025 026import core.tut.pori.utils.ISODateAdapter; 027 028/** 029 * 030 * 031 */ 032@XmlRootElement(name=Definitions.ELEMENT_ACCELEROMETER_DATA) 033@XmlAccessorType(XmlAccessType.NONE) 034public class AccelerometerData { 035 @XmlElement(name = service.tut.pori.apilta.sensors.datatypes.Definitions.ELEMENT_MEASUREMENT_ID) 036 private String _measurementId = null; 037 @XmlElement(name=Definitions.ELEMENT_SYSTEMATIC_ERROR) 038 private Double _systematicError = null; 039 @XmlElement(name=Definitions.ELEMENT_X_ACCELERATION) 040 private Double _xAcceleration = null; 041 @XmlElement(name=Definitions.ELEMENT_Y_ACCELERATION) 042 private Double _yAcceleration = null; 043 @XmlElement(name=Definitions.ELEMENT_Z_ACCELERATION) 044 private Double _zAcceleration = null; 045 @XmlJavaTypeAdapter(ISODateAdapter.class) 046 @XmlElement(name=Definitions.ELEMENT_TIMESTAMP) 047 private Date _timestamp = null; 048 049 /** 050 * for sub-classing, use the static 051 * 052 * @return true if valid 053 * @see #isValid(AccelerometerData) 054 */ 055 protected boolean isValid() { 056 return (_xAcceleration != null && _xAcceleration != null && _yAcceleration != null); 057 } 058 059 /** 060 * 061 * @param data 062 * @return true if valid and not null 063 */ 064 public static boolean isValid(AccelerometerData data) { 065 return (data != null && data.isValid()); 066 } 067 068 /** 069 * @return the measurementId 070 */ 071 public String getMeasurementId() { 072 return _measurementId; 073 } 074 075 /** 076 * @param measurementId the measurementId to set 077 */ 078 public void setMeasurementId(String measurementId) { 079 _measurementId = measurementId; 080 } 081 082 /** 083 * @return the xAcceleration 084 */ 085 public Double getxAcceleration() { 086 return _xAcceleration; 087 } 088 089 /** 090 * @param xAcceleration the xAcceleration to set 091 */ 092 public void setxAcceleration(Double xAcceleration) { 093 _xAcceleration = xAcceleration; 094 } 095 096 /** 097 * @return the yAcceleration 098 */ 099 public Double getyAcceleration() { 100 return _yAcceleration; 101 } 102 103 /** 104 * @param yAcceleration the yAcceleration to set 105 */ 106 public void setyAcceleration(Double yAcceleration) { 107 _yAcceleration = yAcceleration; 108 } 109 110 /** 111 * @return the zAcceleration 112 */ 113 public Double getzAcceleration() { 114 return _zAcceleration; 115 } 116 117 /** 118 * @param zAcceleration the zAcceleration to set 119 */ 120 public void setzAcceleration(Double zAcceleration) { 121 _zAcceleration = zAcceleration; 122 } 123 124 /** 125 * @return the timestamp 126 */ 127 public Date getTimestamp() { 128 return _timestamp; 129 } 130 131 /** 132 * @param timestamp the timestamp to set 133 */ 134 public void setTimestamp(Date timestamp) { 135 _timestamp = timestamp; 136 } 137 138 /** 139 * @return the systematicError 140 */ 141 public Double getSystematicError() { 142 return _systematicError; 143 } 144 145 /** 146 * @param systematicError the systematicError to set 147 */ 148 public void setSystematicError(Double systematicError) { 149 _systematicError = systematicError; 150 } 151}