-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[BIK-878] Add support for sensor export
- Loading branch information
Showing
3 changed files
with
260 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
libs/model/src/main/kotlin/de/cyface/model/ExportOptions.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* | ||
* Copyright 2024 Cyface GmbH | ||
* | ||
* This file is part of the Serialization. | ||
* | ||
* The Serialization 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 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* The Serialization 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 the Serialization. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package de.cyface.model | ||
|
||
/** | ||
* The options which describe which data should be exported. | ||
* | ||
* @author Armin Schnabel | ||
* @version 1.0.0 | ||
* @since 3.3.0 | ||
* @property format The format in which the data should be exported. | ||
* @property type The type of data which should be exported. | ||
* @property includeHeader `true` if the export should start with a header line, if supported by the [format]. | ||
* @property includeUserId `true` if the user id should be included in the export. | ||
* @property includeUsername `true` if the username should be included in the export. | ||
*/ | ||
class ExportOptions { | ||
var format: DataFormat = DataFormat.UNDEFINED | ||
var type: DataType = DataType.UNDEFINED | ||
var includeHeader: Boolean = false | ||
var includeUserId: Boolean = false | ||
var includeUsername: Boolean = false | ||
|
||
fun format(format: DataFormat): ExportOptions { | ||
this.format = format | ||
return this | ||
} | ||
|
||
fun type(type: DataType): ExportOptions { | ||
this.type = type | ||
return this | ||
} | ||
|
||
fun includeHeader(includeHeader: Boolean): ExportOptions { | ||
require(!includeHeader || format == DataFormat.CSV) { "Format without header support: $format" } | ||
this.includeHeader = includeHeader | ||
return this | ||
} | ||
|
||
fun includeUserId(includeUserId: Boolean): ExportOptions { | ||
this.includeUserId = includeUserId | ||
return this | ||
} | ||
|
||
fun includeUsername(includeUsername: Boolean): ExportOptions { | ||
this.includeUsername = includeUsername | ||
return this | ||
} | ||
} | ||
|
||
/** | ||
* Supported export data format. | ||
* | ||
* @author Armin Schnabel | ||
* @version 1.0.0 | ||
* @since 3.3.0 | ||
* @param parameterValue The parameter value which represents the enum option. | ||
*/ | ||
enum class DataFormat(@Suppress("MemberVisibilityCanBePrivate") val parameterValue: String) { | ||
/** | ||
* Default value when no format was specified. | ||
*/ | ||
UNDEFINED("undefined"), | ||
|
||
/** | ||
* Comma separated values. | ||
*/ | ||
CSV("csv"), | ||
|
||
/** | ||
* JSON format. | ||
*/ | ||
@Suppress("unused") // Used | ||
JSON("json") | ||
} | ||
|
||
/** | ||
* Supported data types which are used during data collection. | ||
* | ||
* @author Armin Schnabel | ||
* @version 1.0.0 | ||
* @since 3.3.0 | ||
* @param parameterValue The parameter value which represents the enum option. | ||
*/ | ||
enum class DataType(@Suppress("MemberVisibilityCanBePrivate") val parameterValue: String) { | ||
/** | ||
* Default value when no type was specified. | ||
*/ | ||
UNDEFINED("undefined"), | ||
|
||
/** | ||
* Data collected by the accelerometer. | ||
*/ | ||
ACCELERATION("acceleration"), | ||
|
||
/** | ||
* Data collected by the gyroscope. | ||
*/ | ||
ROTATION("rotation"), | ||
|
||
/** | ||
* Data collected by the magnetometer. | ||
*/ | ||
DIRECTION("direction"), | ||
|
||
/** | ||
* Location data, e.g. collected from a GNSS signal. | ||
*/ | ||
LOCATION("location") | ||
} |
Oops, something went wrong.