/* * Copyright (C) 2012, Katy Hilgenberg. * Special acknowledgments to: Knowledge & Data Engineering Group, University of Kassel (http://www.kde.cs.uni-kassel.de). * Contact: sdcf@cs.uni-kassel.de * * This file is part of the SDCFramework (Sensor Data Collection Framework) project. * * The SDCFramework is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * The SDCFramework 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with the SDCFramework. If not, see <http://www.gnu.org/licenses/>. */ package de.unikassel.android.sdcframework.data; import java.util.List; import java.util.Vector; import org.simpleframework.xml.Element; import org.simpleframework.xml.ElementList; import org.simpleframework.xml.Root; import de.unikassel.android.sdcframework.data.independent.GlobalSerializer; import de.unikassel.android.sdcframework.data.independent.SerializableData; /** * This class is the serializable representation of the default configuration * for the SDC framework. <br/> * <br/> * For each available sensor it is necessary to configure a * {@link SensorConfigurationEntry sensor configuration entry} in the * corresponding XML configuration file, which is located in the asset folder of * the project. <br/> * <br/> * An example for a valid SDC framework configuration file: <br/> * <blockquote> <sdcconfig> <blockquote> <font color="#008000"> <!-- * the time providers configuration section --> </font><br/> * <providers> <blockquote> * <provider>ptbtime1.ptb.de<provider> <br/> * </blockquote> </providers><br/> * <br/> * <font color="#008000"> <!-- the sensor configuration section --> * </font><br/> * <sensors> <blockquote> <sensor id="Accelerometer" enabled="true" * frequency="10000" prio="Level4"/><br/> * <sensor id="Bluetooth" enabled="true" frequency="60000" prio="Level3"/><br/> * <sensor id="Wifi" enabled="true" frequency="60000" prio="Level2"/><br/> * <sensor id="GPS" enabled="true" frequency="120000" prio="Level1"/><br/> * <sensor id="GSM" enabled="true" frequency="60000" prio="Level0"/> * </blockquote> </sensors><br/> * <br/> * <font color="#008000"> <!-- flag to indicate if sample broadcasting is * enabled or not --> </font><br/> * <broadcastSamples>true</broadcastSamples><br/> * <br/> * <font color="#008000"> <!-- flag to indicate if location information is * added to each sample --> </font><br/> * <addSampleLocation>true</addSampleLocation><br/> * <br/> * <font color="#008000"> <!-- flag to indicate if samples shall be stored * for transmission --> </font><br/> * <storeSamples>true</storeSamples><br/> * <br/> * <font color="#008000"> <!-- flag to indicate if samples shall be * transfered to a remote server from time to time --> </font><br/> * <transferSamples>true</transferSamples><br/> * <br/> * <font color="#008000"> <!-- flag to indicate if location information shall * be stored in each sample --> </font><br/> * <addSampleLocation>true</addSampleLocation><br/> * <br/> * <font color="#008000"> <!-- the database configuration section --> * </font><br/> * <dbConfig><blockquote> <font color="#008000"> <!-- the maximum * database size in bytes --> </font><br/> * <maxSize>10485760</maxSize><br/> * <br/> * <font color="#008000"> <!-- the database full strategy chain configuration * ( valid values are: wait_delete_notify or wait_notify_stopservice ) --> * </font><br/> * <dbFullStrategy>wait_delete_notify</dbFullStrategy><br/> * <br/> * <font color="#008000"> <!-- the wait time used by the wait strategy ( in * milliseconds ) --> </font><br/> * <waitStrategyMillis>10000</waitStrategyMillis><br/> * <br/> * <font color="#008000"> <!-- the record count to delete used by the sample * deletion strategy --> </font><br/> * <delStrategyRecordCount>1000</delStrategyRecordCount><br/> * <br/> * <font color="#008000"> <!-- the flag indicating if sample deletion is done * for lower priorities first by the sample deletion strategy ( if true the * oldest samples with the lowest priority will be selected first for deletion, * otherwise just the oldest samples ) --> </font><br/> * <delStrategyUsePrio>true</delStrategyUsePrio> </blockquote> * </dbConfig><br/> * <br/> * <font color="#008000"> <!-- the transmission configuration section --> * </font><br/> * <transferConfig><blockquote> <font color="#008000"> <!-- the minimum * count of samples for a single transmission --> </font><br/> * <minSampleCount>100</minSampleCount><br/> * <br/> * <font color="#008000"> <!-- the maximum count of samples for a single * transmission --> </font><br/> * <maxSampleCount>100</maxSampleCount><br/> * <br/> * <font color="#008000"> <!-- the minimum transmission frequency in seconds * --> </font><br/> * <minTransferFrequency>3600</minTransferFrequency><br/> * <br/> * <font color="#008000"> <!-- the archive type to use for file transmission * --> </font><br/> * <archiveType>zip</archiveType><br/> * <br/> * <protocolConfig><blockquote> <font color="#008000"> <!-- the URL to * transfer files to --> </font><br/> * <url>http://localhost</url><br/> * <br/> * <font color="#008000"> <!-- the user name for remote authentication --> * </font><br/> * <authName>Karli</authName><br/> * <br/> * <font color="#008000"> <!-- the user password for remote authentication * --> </font><br/> * <authPassword>unknown</authPassword><br/> * <br/> * <font color="#008000"> <!-- the transfer strategy to use ( e.g. just any * available wlan connection )--> </font><br/> * <transferStrategy>wlan</transferStrategy><br/> * </blockquote> </protocolConfig> </blockquote> </transferConfig> * </blockquote> </sdcconfig> </blockquote> * * @see SensorConfigurationEntry * @see DatabaseConfigurationEntry * @see de.unikassel.android.sdcframework.preferences.SDCConfigurationManager * @author Katy Hilgenberg * */ @Root( name = "sdcconfig" ) public final class SDCConfiguration implements SerializableData { /** * The time provider entries */ @Element( name = "timeProviders", required = false ) private TimeProviderConfigurationEntries timeProviderConfiguration; /** * The list of available sensors in the SDC service */ @ElementList( name = "sensors", required = false ) private List< SensorConfigurationEntry > sensorConfigurations; /** * The flag for the service sample broadcast behavior */ @Element( name = "broadcastSamples", required = false ) private Boolean isBroadcastingSamples; /** * The broadcast frequency in milliseconds. */ @Element( name = "broadcastFrequency", required = false ) private Long broadcastFrequency; /** * The flag for the sampling enabled state */ @Element( name = "samlingEnabled", required = false ) private Boolean isSamplingEnabled; /** * The flag to configure that each sample gets a location fix added */ @Element( name = "addSampleLocation", required = false ) private Boolean isAddingSampleLocation; /** * The flag for the service persistent storage behavior */ @Element( name = "storeSamples", required = false ) private Boolean isStoringSamples; /** * The flag for the service transmission behavior */ @Element( name = "transferSamples", required = false ) private Boolean isTransmittingSamples; /** * The database configuration */ @Element( name = "dbConfig", required = false ) private DatabaseConfigurationEntry databaseConfiguration; /** * The transmission service configuration */ @Element( name = "transferConfig", required = false ) private TransmissionConfigurationEntry transmissionConfiguration; /** * The log file transfer configuration */ @Element( name = "logTransferConfig", required = false ) private TransmissionProtocolConfigurationEntry logTransferConfiguration; /** * The weekly time schedule for the service. */ @Element( name = "weeklySchedule", required = false ) private WeeklySchedule weeklySchedule; /** * Constructor */ public SDCConfiguration() { setListSensorConfigurations( new Vector< SensorConfigurationEntry >() ); setDatabaseConfiguration( new DatabaseConfigurationEntry() ); setTransmissionConfiguration( new TransmissionConfigurationEntry() ); } /** * Getter for the sensorConfigurations * * @return the sensorConfigurations */ public final List< SensorConfigurationEntry > getListSensorConfigurations() { return sensorConfigurations; } /** * Setter for the sensorConfigurations * * @param sensorConfigurations * the sensorConfigurations to set */ public final void setListSensorConfigurations( List< SensorConfigurationEntry > sensorConfigurations ) { this.sensorConfigurations = sensorConfigurations; } /** * Getter for the NTP time provider entries * * @return the NTP time provider entries */ public TimeProviderConfigurationEntries getTimeProviderConfigEntries() { return timeProviderConfiguration; } /** * Setter for the NTP time provider entries * * @param timeProviders * the NTP time provider entries to set */ public void setTimeProviderConfigEntries( TimeProviderConfigurationEntries timeProviders ) { this.timeProviderConfiguration = timeProviders; } /** * Setter for flag for sample broadcasts behavior * * @param isBroadcastingSamples * the flag for sample broadcasts behavior to set */ public final void setBroadcastingSamples( Boolean isBroadcastingSamples ) { this.isBroadcastingSamples = isBroadcastingSamples; } /** * Getter for the flag for sample broadcasts behavior * * @return true if samples shall be broadcasted, false otherwise */ public final Boolean isBroadcastingSamples() { return isBroadcastingSamples; } /** * Getter for the broadcast frequency * * @return the broadcast frequency */ public Long getBroadcastFrequency() { return broadcastFrequency; } /** * Setter for the broadcast frequency * * @param broadcastFrequency * the broadcast frequency to set */ public void setBroadcastFrequency( Long broadcastFrequency ) { this.broadcastFrequency = broadcastFrequency; } /** * Setter for the isSamplingEnabled flag * * @param isSamplingEnabled * the isSamplingEnabled flag to set */ public void setIsSamplingEnabled( Boolean isSamplingEnabled ) { this.isSamplingEnabled = isSamplingEnabled; } /** * Getter for the isSamplingEnabled flag * * @return the isSamplingEnabled flag */ public Boolean isSamplingEnabled() { return isSamplingEnabled; } /** * Getter for the flag to configure location fix per sample * * @return the flag to configure location fix per sample */ public Boolean isAddingSampleLocation() { return isAddingSampleLocation; } /** * Setter for the flag to configure location fix per sample * * @param isAddingSampleLocation * the flag to configure location fix per sample */ public final void setIsAddingSampleLocation( Boolean isAddingSampleLocation ) { this.isAddingSampleLocation = isAddingSampleLocation; } /** * Setter for the flag for persistent storage behavior * * @param isStoringSamples * the flag for persistent storage behavior to set */ public final void setStoringSamples( Boolean isStoringSamples ) { this.isStoringSamples = isStoringSamples; } /** * Getter for the flag for persistent storage behavior * * @return true if samples will be stored persistent for transmission service */ public final Boolean isStoringSamples() { return isStoringSamples; } /** * Setter for the isTransmittingSamples * * @param isTransmittingSamples * the isTransmittingSamples to set */ public final void setTransmittingSamples( Boolean isTransmittingSamples ) { this.isTransmittingSamples = isTransmittingSamples; } /** * Getter for the isTransmittingSamples * * @return the isTransmittingSamples */ public final Boolean isTransmittingSamples() { return isTransmittingSamples; } /** * Getter for the database configuration * * @return the database configuration */ public final DatabaseConfigurationEntry getDatabaseConfiguration() { return databaseConfiguration; } /** * Setter for the database configuration * * @param databaseConfiguration * the database configuration to set */ public final void setDatabaseConfiguration( DatabaseConfigurationEntry databaseConfiguration ) { this.databaseConfiguration = databaseConfiguration; } /** * Getter for the transmissionConfiguration * * @return the transmissionConfiguration */ public final TransmissionConfigurationEntry getTransmissionConfiguration() { return transmissionConfiguration; } /** * Getter for the logTransferConfiguration * * @return the logTransferConfiguration */ public TransmissionProtocolConfigurationEntry getLogTransferConfiguration() { return logTransferConfiguration; } /** * Setter for the logTransferConfiguration * * @param logTransferConfiguration * the logTransferConfiguration to set */ public void setLogTransferConfiguration( TransmissionProtocolConfigurationEntry logTransferConfiguration ) { this.logTransferConfiguration = logTransferConfiguration; } /** * Setter for the transmissionConfiguration * * @param transmissionConfiguration * the transmissionConfiguration to set */ public final void setTransmissionConfiguration( TransmissionConfigurationEntry transmissionConfiguration ) { this.transmissionConfiguration = transmissionConfiguration; } /** * Setter for the weekly schedule. * @param weeklySchedule the weekly schedule to set */ public void setWeeklySchedule( WeeklySchedule weeklySchedule ) { this.weeklySchedule = weeklySchedule; } /** * Getter for the weekly schedule. * @return the weekly schedule */ public WeeklySchedule getWeeklySchedule() { return weeklySchedule; } /* * (non-Javadoc) * * @see de.unikassel.android.sdcframework.data.facade.SerializableData#toXML() */ @Override public final String toXML() throws Exception { return GlobalSerializer.toXml( this ); } }