|
| 1 | +/* |
| 2 | + * Copyright (c) 2023. Smart Operating Block |
| 3 | + * |
| 4 | + * Use of this source code is governed by an MIT-style |
| 5 | + * license that can be found in the LICENSE file or at |
| 6 | + * https://opensource.org/licenses/MIT. |
| 7 | + */ |
| 8 | + |
| 9 | +package entity.zone |
| 10 | + |
| 11 | +import entity.environment.Humidity |
| 12 | +import entity.environment.Luminosity |
| 13 | +import entity.environment.Presence |
| 14 | +import entity.environment.Temperature |
| 15 | + |
| 16 | +/** |
| 17 | + * It describes a room inside the Operating Block. |
| 18 | + * Each room is inside a Zone of the Operating Block identified by a [zoneId]. |
| 19 | + * Each room has a [type] and is identified by an [id] and optionally has a [name]. |
| 20 | + * The Building Management system has the objective to collect [environmentalData] |
| 21 | + * of the rooms withing the Operating Block. |
| 22 | + */ |
| 23 | +data class Room( |
| 24 | + val id: RoomID, |
| 25 | + val type: RoomType, |
| 26 | + val zoneId: ZoneID, |
| 27 | + val name: String? = null, |
| 28 | + val environmentalData: RoomEnvironmentalData = RoomEnvironmentalData(), |
| 29 | +) { |
| 30 | + override fun equals(other: Any?): Boolean = when { |
| 31 | + other === this -> true |
| 32 | + other is Room -> this.id == other.id |
| 33 | + else -> false |
| 34 | + } |
| 35 | + |
| 36 | + override fun hashCode(): Int = this.id.hashCode() |
| 37 | +} |
| 38 | + |
| 39 | +/** |
| 40 | + * Identification of a [Room]. |
| 41 | + * @param[value] the id. |
| 42 | + */ |
| 43 | +data class RoomID(val value: String) { |
| 44 | + init { |
| 45 | + // Constructor validation: The id must not be empty |
| 46 | + require(this.value.isNotEmpty()) |
| 47 | + } |
| 48 | +} |
| 49 | + |
| 50 | +/** |
| 51 | + * Wraps all the environmental data associated to a Room. |
| 52 | + * So it describe: |
| 53 | + * - the [temperature] inside the room |
| 54 | + * - the [humidity] inside the room |
| 55 | + * - the [luminosity] inside the room |
| 56 | + * - the [presence] of someone in the room |
| 57 | + * All the data may be not present. |
| 58 | + */ |
| 59 | +data class RoomEnvironmentalData( |
| 60 | + val temperature: Temperature? = null, |
| 61 | + val humidity: Humidity? = null, |
| 62 | + val luminosity: Luminosity? = null, |
| 63 | + val presence: Presence? = null, |
| 64 | +) |
| 65 | + |
| 66 | +/** |
| 67 | + * Describes the type of [Room]. |
| 68 | + */ |
| 69 | +enum class RoomType { |
| 70 | + /** It is the Pre/Post Operating Room. */ |
| 71 | + PRE_OPERATING_ROOM, |
| 72 | + /** It is the Operating Room. */ |
| 73 | + OPERATING_ROOM, |
| 74 | +} |
0 commit comments