Last active
December 8, 2021 00:14
-
-
Save vikingosegundo/d12b4d5078c9b1e9df7ad3ecc72d9a72 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
//MARK: - Message | |
enum Message { | |
case lighting(_Lighting) | |
case dashboard(_Dashboard) | |
case logging(_Logging) | |
} | |
//MARK: - Common Lighting DSL Elements | |
enum Outcome { case succeeded, failed(Error?) } | |
enum Items { case lights, rooms } | |
enum Loaded { case lights([Light]), rooms([Room]) } | |
enum Turn { case on, off } | |
enum Apply { case values(Light.Values) } | |
enum Alter { case name(String), display(Interface) } | |
enum Interface: Codable { case scrubbing, slider } | |
extension Double { var pt : Light.Value.Increment { .pt (self) } } | |
extension Int { var mirek: Light.Temperature { .mirek(self) } } | |
extension Int { var mk : Light.Temperature { .mirek(self) } } | |
extension Light { | |
enum Value { | |
case hue, saturation, brightness, colortemp | |
enum Increment { case pt(Double) } | |
} | |
enum Values { case hsb(Double, Double, Double), ct(Int, Double), bri(Double) } | |
} | |
//MARK: - Lighting Message | |
extension Message { | |
enum _Lighting { // Lighting Feature | |
// |------------------------ Command ----------------------| |---------------------------- Response ----------------------------| | |
case load (Items ), loading (Loaded, Outcome) | |
case turn (Light, Turn ), turning (Light, Turn, Outcome) | |
case apply (Apply, on:Light), applying (Apply, on:Light, Outcome) | |
case change (Alter, on:Light), changing (Alter, on:Light, Outcome) | |
case increase(Light.Value, by:Light.Value.Increment, on:Light), increasing(Light.Value, by:Light.Value.Increment, on:Light, Outcome) | |
case decrease(Light.Value, by:Light.Value.Increment, on:Light), decreasing(Light.Value, by:Light.Value.Increment, on:Light, Outcome) | |
} | |
} | |
extension Message { | |
enum _Dashboard { // Dashboard Feature | |
// |--- Command --| |---------- Response ------------| | |
case add (Favorite), favoriteAdded (Favorite, Outcome) | |
case remove(Favorite), favoriteRemoved(Favorite, Outcome) | |
} | |
} | |
extension Message { | |
enum _Logging { // Logging Feature | |
// |-- Command --| | |
case write(LogItem) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment