feat: Updates to newer psychrometrics package. Not yet a working example.

This commit is contained in:
2024-11-09 11:35:30 -05:00
parent e2683d3f06
commit a87addaf0b
13 changed files with 821 additions and 737 deletions

View File

@@ -1,41 +1,40 @@
@_exported import Client
import CoreUnitTypes
import Foundation
import Models
import MQTTNIO
import NIO
import Psychrometrics
public extension Client {
// The state passed in here needs to be a class or we get escaping errors in the `addListeners` method.
static func live(
client: MQTTNIO.MQTTClient,
state: State,
topics: Topics
) -> Self {
.init(
addListeners: {
state.addSensorListeners(to: client, topics: topics)
},
connect: {
client.connect()
.map { _ in }
},
publishSensor: { request in
client.publishDewPoint(request: request, state: state, topics: topics)
.publishEnthalpy()
.setHasProcessed()
},
shutdown: {
client.disconnect()
.map { try? client.syncShutdownGracefully() }
},
subscribe: {
// Sensor subscriptions
client.subscribe(to: .sensors(topics: topics))
.map { _ in }
}
)
}
}
// @_exported import Client
// import Foundation
// import Models
// import MQTTNIO
// import NIO
// import PsychrometricClient
//
// public extension Client {
//
// // The state passed in here needs to be a class or we get escaping errors in the `addListeners` method.
// static func live(
// client: MQTTNIO.MQTTClient,
// state: State,
// topics: Topics
// ) -> Self {
// .init(
// addListeners: {
// state.addSensorListeners(to: client, topics: topics)
// },
// connect: {
// client.connect()
// .map { _ in }
// },
// publishSensor: { request in
// client.publishDewPoint(request: request, state: state, topics: topics)
// .publishEnthalpy()
// .setHasProcessed()
// },
// shutdown: {
// client.disconnect()
// .map { try? client.syncShutdownGracefully() }
// },
// subscribe: {
// // Sensor subscriptions
// client.subscribe(to: .sensors(topics: topics))
// .map { _ in }
// }
// )
// }
// }