From 80523d5947eee9542bce2bcf7f0ecdce10fddc06 Mon Sep 17 00:00:00 2001 From: Florian Lercher Date: Thu, 23 Sep 2021 11:55:53 +0000 Subject: [PATCH 1/7] Read available sensors from config files --- WebService/Sources/Demo/PhSensor.swift | 20 -------------------- WebService/Sources/Demo/Sensor.swift | 15 +++++---------- 2 files changed, 5 insertions(+), 30 deletions(-) delete mode 100644 WebService/Sources/Demo/PhSensor.swift diff --git a/WebService/Sources/Demo/PhSensor.swift b/WebService/Sources/Demo/PhSensor.swift deleted file mode 100644 index 3730d89..0000000 --- a/WebService/Sources/Demo/PhSensor.swift +++ /dev/null @@ -1,20 +0,0 @@ -import Apodini -import Foundation - - -struct PhSensor: Handler { - @Parameter var offset: Int = 0 - - - func handle() -> [String] { - let path = FileManager.default.currentDirectoryPath.appendingPathComponent("ph_values.txt") - do { - let data = try String(contentsOfFile: path, encoding: .utf8) - let lines = data.components(separatedBy: .newlines) - return Array(lines[offset...]) - } catch { - print("Error reading file") - return [] - } - } -} diff --git a/WebService/Sources/Demo/Sensor.swift b/WebService/Sources/Demo/Sensor.swift index d510a81..3d7ba18 100644 --- a/WebService/Sources/Demo/Sensor.swift +++ b/WebService/Sources/Demo/Sensor.swift @@ -1,17 +1,12 @@ import Apodini +import Foundation struct Sensor: Handler { - func handle() -> String { - """ - List of sensors: - pH - """ - } - - var content: some Component { - Group("ph") { - PhSensor() + func handle() -> [Int] { + guard let data = try? Data(contentsOf: URL(fileURLWithPath: "/buoy/available_sensors.json")) else { + return [] } + return (try? JSONDecoder().decode([Int].self, from: data)) ?? [] } } From 123768cc49b7f2d108a0d3e9683416bd4d981e28 Mon Sep 17 00:00:00 2001 From: Florian Lercher Date: Fri, 24 Sep 2021 21:21:13 +0000 Subject: [PATCH 2/7] Extract JSON parsing and structs --- WebService/Sources/Demo/JSONUtil.swift | 10 +++++++++ WebService/Sources/Demo/Sensor.swift | 5 +---- WebService/Sources/Demo/SensorData.swift | 27 ++++-------------------- WebService/Sources/Demo/SensorDump.swift | 19 +++++++++++++++++ 4 files changed, 34 insertions(+), 27 deletions(-) create mode 100644 WebService/Sources/Demo/JSONUtil.swift create mode 100644 WebService/Sources/Demo/SensorDump.swift diff --git a/WebService/Sources/Demo/JSONUtil.swift b/WebService/Sources/Demo/JSONUtil.swift new file mode 100644 index 0000000..18c8b38 --- /dev/null +++ b/WebService/Sources/Demo/JSONUtil.swift @@ -0,0 +1,10 @@ +import Foundation + +let mountDir = "/buoy" + +func readJSONFromFile(_ type: T.Type, filePath: String) -> T? where T: Decodable { + guard let data = try? Data(contentsOf: URL(fileURLWithPath: mountDir + "/" + filePath)) else { + return nil + } + return try? JSONDecoder().decode(T.self, from: data) +} diff --git a/WebService/Sources/Demo/Sensor.swift b/WebService/Sources/Demo/Sensor.swift index 3d7ba18..1c15d5f 100644 --- a/WebService/Sources/Demo/Sensor.swift +++ b/WebService/Sources/Demo/Sensor.swift @@ -4,9 +4,6 @@ import Foundation struct Sensor: Handler { func handle() -> [Int] { - guard let data = try? Data(contentsOf: URL(fileURLWithPath: "/buoy/available_sensors.json")) else { - return [] - } - return (try? JSONDecoder().decode([Int].self, from: data)) ?? [] + readJSONFromFile([Int].self, filePath: "available_sensors.json") ?? [] } } diff --git a/WebService/Sources/Demo/SensorData.swift b/WebService/Sources/Demo/SensorData.swift index 53ca731..89413d3 100644 --- a/WebService/Sources/Demo/SensorData.swift +++ b/WebService/Sources/Demo/SensorData.swift @@ -1,35 +1,16 @@ import Apodini import Foundation -struct MeasurementItem: Content, Decodable { - var sensorID: Int - var sensorType: Int - var measurement: Double -} - -struct SensorDump: Content, Decodable { - var buoyId: Int - var date: String - var location: Location - var measurements: [MeasurementItem] -} - -struct Location: Content, Decodable { - var latitude: Double - var longitude: Double -} struct SensorData: Handler { + static let dirPath = "data" + func handle() -> [SensorDump] { - let dirPath = "/buoy/data" - guard let files = try? FileManager.default.contentsOfDirectory(atPath: dirPath) else { + guard let files = try? FileManager.default.contentsOfDirectory(atPath: mountDir + "/" + SensorData.dirPath) else { return [] } return files.compactMap {fileName in - guard let data = try? Data(contentsOf: URL(fileURLWithPath: dirPath + "/" + fileName)) else { - return nil - } - return try? JSONDecoder().decode(SensorDump.self, from: data) + return readJSONFromFile(SensorDump.self, filePath: SensorData.dirPath + "/" + fileName) } } } diff --git a/WebService/Sources/Demo/SensorDump.swift b/WebService/Sources/Demo/SensorDump.swift new file mode 100644 index 0000000..b4b41fa --- /dev/null +++ b/WebService/Sources/Demo/SensorDump.swift @@ -0,0 +1,19 @@ +import Apodini + +struct MeasurementItem: Content, Decodable { + var sensorID: Int + var sensorType: Int + var measurement: Double +} + +struct SensorDump: Content, Decodable { + var buoyId: Int + var date: String + var location: Location + var measurements: [MeasurementItem] +} + +struct Location: Content, Decodable { + var latitude: Double + var longitude: Double +} From 200b0324f532e5f64872952c15860dd63f5c079a Mon Sep 17 00:00:00 2001 From: Florian Lercher Date: Fri, 24 Sep 2021 21:24:20 +0000 Subject: [PATCH 3/7] Extract more JSON functions and add sensor filter --- WebService/Sources/Demo/JSONUtil.swift | 19 +++++++++++++++++-- WebService/Sources/Demo/SensorData.swift | 11 ++++++----- WebService/Sources/Demo/SensorDump.swift | 21 +++++++++++++++------ WebService/Sources/Demo/TDSSensor.swift | 14 ++++++++++++++ 4 files changed, 52 insertions(+), 13 deletions(-) create mode 100644 WebService/Sources/Demo/TDSSensor.swift diff --git a/WebService/Sources/Demo/JSONUtil.swift b/WebService/Sources/Demo/JSONUtil.swift index 18c8b38..353ced9 100644 --- a/WebService/Sources/Demo/JSONUtil.swift +++ b/WebService/Sources/Demo/JSONUtil.swift @@ -1,10 +1,25 @@ import Foundation -let mountDir = "/buoy" +let mountDir = URL(fileURLWithPath: "/buoy") func readJSONFromFile(_ type: T.Type, filePath: String) -> T? where T: Decodable { - guard let data = try? Data(contentsOf: URL(fileURLWithPath: mountDir + "/" + filePath)) else { + readJSONFromFile(type, fileURL: mountDir.appendingPathComponent(filePath)) +} + +func readJSONFromFile(_ type: T.Type, fileURL: URL) -> T? where T: Decodable { + guard let data = try? Data(contentsOf: fileURL) else { return nil } return try? JSONDecoder().decode(T.self, from: data) } + +func readJSONDirectory(_ type: T.Type, dirPath: String) -> [T] where T: Decodable { + guard let files = try? FileManager.default.contentsOfDirectory(at: mountDir.appendingPathComponent(dirPath), + includingPropertiesForKeys: nil) + else { + return [] + } + return files.compactMap {fileURL in + return readJSONFromFile(T.self, fileURL: fileURL) + } +} diff --git a/WebService/Sources/Demo/SensorData.swift b/WebService/Sources/Demo/SensorData.swift index 89413d3..27bd96d 100644 --- a/WebService/Sources/Demo/SensorData.swift +++ b/WebService/Sources/Demo/SensorData.swift @@ -6,11 +6,12 @@ struct SensorData: Handler { static let dirPath = "data" func handle() -> [SensorDump] { - guard let files = try? FileManager.default.contentsOfDirectory(atPath: mountDir + "/" + SensorData.dirPath) else { - return [] - } - return files.compactMap {fileName in - return readJSONFromFile(SensorDump.self, filePath: SensorData.dirPath + "/" + fileName) + readJSONDirectory(SensorDump.self, dirPath: Self.dirPath) + } + + var content: some Component { + Group(String(TDSSensor.sensorType)) { + TDSSensor() } } } diff --git a/WebService/Sources/Demo/SensorDump.swift b/WebService/Sources/Demo/SensorDump.swift index b4b41fa..bc5b0fb 100644 --- a/WebService/Sources/Demo/SensorDump.swift +++ b/WebService/Sources/Demo/SensorDump.swift @@ -1,19 +1,28 @@ import Apodini -struct MeasurementItem: Content, Decodable { - var sensorID: Int - var sensorType: Int - var measurement: Double -} - struct SensorDump: Content, Decodable { var buoyId: Int var date: String var location: Location var measurements: [MeasurementItem] + + func filteredBySensorType(_ sensorType: Int) -> SensorDump { + SensorDump( + buoyId: self.buoyId, + date: self.date, + location: self.location, + measurements: self.measurements.filter { $0.sensorType == sensorType } + ) + } } struct Location: Content, Decodable { var latitude: Double var longitude: Double } + +struct MeasurementItem: Content, Decodable { + var sensorID: Int + var sensorType: Int + var measurement: Double +} diff --git a/WebService/Sources/Demo/TDSSensor.swift b/WebService/Sources/Demo/TDSSensor.swift new file mode 100644 index 0000000..1b3c7ee --- /dev/null +++ b/WebService/Sources/Demo/TDSSensor.swift @@ -0,0 +1,14 @@ +import Apodini +import Foundation + + +struct TDSSensor: Handler { + static let dirPath = "data" + static let sensorType: Int = 1 + + func handle() -> [SensorDump] { + readJSONDirectory(SensorDump.self, dirPath: Self.dirPath) + .map { $0.filteredBySensorType(Self.sensorType) } + .filter { !$0.measurements.isEmpty } + } +} From f4d2445e08af62f452eef2acb6ea9a9f4ff529d3 Mon Sep 17 00:00:00 2001 From: Florian Lercher Date: Sat, 25 Sep 2021 08:18:27 +0000 Subject: [PATCH 4/7] Add measurement value converters --- WebService/Sources/Demo/JSONUtil.swift | 2 +- .../Sources/Demo/MeasurementConverter.swift | 36 +++++++++++++++++++ WebService/Sources/Demo/SensorData.swift | 13 +++++++ WebService/Sources/Demo/SensorDump.swift | 11 ++++++ WebService/Sources/Demo/TDSSensor.swift | 5 +-- 5 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 WebService/Sources/Demo/MeasurementConverter.swift diff --git a/WebService/Sources/Demo/JSONUtil.swift b/WebService/Sources/Demo/JSONUtil.swift index 353ced9..e08feab 100644 --- a/WebService/Sources/Demo/JSONUtil.swift +++ b/WebService/Sources/Demo/JSONUtil.swift @@ -20,6 +20,6 @@ func readJSONDirectory(_ type: T.Type, dirPath: String) -> [T] where T: Decod return [] } return files.compactMap {fileURL in - return readJSONFromFile(T.self, fileURL: fileURL) + readJSONFromFile(T.self, fileURL: fileURL) } } diff --git a/WebService/Sources/Demo/MeasurementConverter.swift b/WebService/Sources/Demo/MeasurementConverter.swift new file mode 100644 index 0000000..41db610 --- /dev/null +++ b/WebService/Sources/Demo/MeasurementConverter.swift @@ -0,0 +1,36 @@ +import Apodini + + +protocol MeasurementConverter { + func convert(rawValue: Double) -> Double +} + +func getMeasurementConverterInstance(sensorType: Int) -> MeasurementConverter { + switch sensorType { + case TDSSensor.sensorType: + return PolynomialMeasurementConverter(configFilePath: "sensorconfig/TDSSensor.json") + default: + return NoopConverter() + } +} + +struct NoopConverter: MeasurementConverter { + func convert(rawValue: Double) -> Double { + rawValue + } +} + +struct PolynomialMeasurementConverter: MeasurementConverter { + var polynomialCoefficients: [Double] + + + init(configFilePath: String) { + self.polynomialCoefficients = readJSONFromFile([Double].self, filePath: configFilePath) ?? [] + } + + func convert(rawValue: Double) -> Double { + polynomialCoefficients.reduce(0) {result, coeff in + result * rawValue + coeff + } + } +} diff --git a/WebService/Sources/Demo/SensorData.swift b/WebService/Sources/Demo/SensorData.swift index 27bd96d..7239491 100644 --- a/WebService/Sources/Demo/SensorData.swift +++ b/WebService/Sources/Demo/SensorData.swift @@ -7,6 +7,19 @@ struct SensorData: Handler { func handle() -> [SensorDump] { readJSONDirectory(SensorDump.self, dirPath: Self.dirPath) + .map { + SensorDump( + buoyId: $0.buoyId, + date: $0.date, + location: $0.location, + measurements: $0.measurements.map { item in + MeasurementItem( + sensorID: item.sensorID, + sensorType: item.sensorType, + measurement: getMeasurementConverterInstance(sensorType: item.sensorType).convert(rawValue: item.measurement)) + } + ) + } } var content: some Component { diff --git a/WebService/Sources/Demo/SensorDump.swift b/WebService/Sources/Demo/SensorDump.swift index bc5b0fb..66df049 100644 --- a/WebService/Sources/Demo/SensorDump.swift +++ b/WebService/Sources/Demo/SensorDump.swift @@ -14,6 +14,17 @@ struct SensorDump: Content, Decodable { measurements: self.measurements.filter { $0.sensorType == sensorType } ) } + + func convertMeasurements(_ converter: MeasurementConverter) -> SensorDump { + SensorDump( + buoyId: self.buoyId, + date: self.date, + location: self.location, + measurements: self.measurements.map { item in + MeasurementItem(sensorID: item.sensorID, sensorType: item.sensorType, measurement: converter.convert(rawValue: item.measurement)) + } + ) + } } struct Location: Content, Decodable { diff --git a/WebService/Sources/Demo/TDSSensor.swift b/WebService/Sources/Demo/TDSSensor.swift index 1b3c7ee..d97d13b 100644 --- a/WebService/Sources/Demo/TDSSensor.swift +++ b/WebService/Sources/Demo/TDSSensor.swift @@ -4,11 +4,12 @@ import Foundation struct TDSSensor: Handler { static let dirPath = "data" - static let sensorType: Int = 1 + static let sensorType = 1 + static let converter = getMeasurementConverterInstance(sensorType: Self.sensorType) func handle() -> [SensorDump] { readJSONDirectory(SensorDump.self, dirPath: Self.dirPath) - .map { $0.filteredBySensorType(Self.sensorType) } + .map { $0.filteredBySensorType(Self.sensorType).convertMeasurements(Self.converter) } .filter { !$0.measurements.isEmpty } } } From 05ffa35f3d9d11dd8954fdaa4aa09b873ad66bf9 Mon Sep 17 00:00:00 2001 From: Florian Lercher Date: Sat, 25 Sep 2021 09:13:48 +0000 Subject: [PATCH 5/7] Convert sensor type to enum --- .../Sources/Demo/MeasurementConverter.swift | 6 +++--- WebService/Sources/Demo/SensorData.swift | 4 ++-- WebService/Sources/Demo/SensorDump.swift | 18 ++++++++++++++++-- WebService/Sources/Demo/TDSSensor.swift | 4 ++-- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/WebService/Sources/Demo/MeasurementConverter.swift b/WebService/Sources/Demo/MeasurementConverter.swift index 41db610..d4cb780 100644 --- a/WebService/Sources/Demo/MeasurementConverter.swift +++ b/WebService/Sources/Demo/MeasurementConverter.swift @@ -5,10 +5,10 @@ protocol MeasurementConverter { func convert(rawValue: Double) -> Double } -func getMeasurementConverterInstance(sensorType: Int) -> MeasurementConverter { +func getMeasurementConverterInstance(sensorType: SensorType) -> MeasurementConverter { switch sensorType { - case TDSSensor.sensorType: - return PolynomialMeasurementConverter(configFilePath: "sensorconfig/TDSSensor.json") + case ConductivitySensor.sensorType: + return PolynomialMeasurementConverter(configFilePath: "sensorconfig/ConductivitySensor.json") default: return NoopConverter() } diff --git a/WebService/Sources/Demo/SensorData.swift b/WebService/Sources/Demo/SensorData.swift index 7239491..1203f1d 100644 --- a/WebService/Sources/Demo/SensorData.swift +++ b/WebService/Sources/Demo/SensorData.swift @@ -23,8 +23,8 @@ struct SensorData: Handler { } var content: some Component { - Group(String(TDSSensor.sensorType)) { - TDSSensor() + Group(ConductivitySensor.sensorType.description) { + ConductivitySensor() } } } diff --git a/WebService/Sources/Demo/SensorDump.swift b/WebService/Sources/Demo/SensorDump.swift index 66df049..c951fc7 100644 --- a/WebService/Sources/Demo/SensorDump.swift +++ b/WebService/Sources/Demo/SensorDump.swift @@ -6,7 +6,7 @@ struct SensorDump: Content, Decodable { var location: Location var measurements: [MeasurementItem] - func filteredBySensorType(_ sensorType: Int) -> SensorDump { + func filteredBySensorType(_ sensorType: SensorType) -> SensorDump { SensorDump( buoyId: self.buoyId, date: self.date, @@ -34,6 +34,20 @@ struct Location: Content, Decodable { struct MeasurementItem: Content, Decodable { var sensorID: Int - var sensorType: Int + var sensorType: SensorType var measurement: Double } + +enum SensorType: Int, Content, Decodable, CustomStringConvertible { + case TEMPERATURE + case CONDUCTIVITY + case POTENTIAHYDROGENII + + var description: String { + switch self { + case .TEMPERATURE: return "temperature" + case .CONDUCTIVITY: return "conductivity" + case .POTENTIAHYDROGENII: return "ph" + } + } +} diff --git a/WebService/Sources/Demo/TDSSensor.swift b/WebService/Sources/Demo/TDSSensor.swift index d97d13b..1bf431b 100644 --- a/WebService/Sources/Demo/TDSSensor.swift +++ b/WebService/Sources/Demo/TDSSensor.swift @@ -2,9 +2,9 @@ import Apodini import Foundation -struct TDSSensor: Handler { +struct ConductivitySensor: Handler { static let dirPath = "data" - static let sensorType = 1 + static let sensorType: SensorType = .CONDUCTIVITY static let converter = getMeasurementConverterInstance(sensorType: Self.sensorType) func handle() -> [SensorDump] { From ed63e8a88b5ffa1a0faed71f47b99df522479738 Mon Sep 17 00:00:00 2001 From: Florian Lercher Date: Sat, 25 Sep 2021 09:42:58 +0000 Subject: [PATCH 6/7] Extract common functionality from sensor handlers --- WebService/Sources/Demo/ConductivitySensor.swift | 9 +++++++++ WebService/Sources/Demo/PhSensor.swift | 9 +++++++++ WebService/Sources/Demo/SensorData.swift | 8 ++++++++ .../Demo/{TDSSensor.swift => SensorHandler.swift} | 13 ++++++++----- WebService/Sources/Demo/TemperatureSensor.swift | 9 +++++++++ WebService/ph_values.txt | 4 ---- 6 files changed, 43 insertions(+), 9 deletions(-) create mode 100644 WebService/Sources/Demo/ConductivitySensor.swift create mode 100644 WebService/Sources/Demo/PhSensor.swift rename WebService/Sources/Demo/{TDSSensor.swift => SensorHandler.swift} (53%) create mode 100644 WebService/Sources/Demo/TemperatureSensor.swift delete mode 100644 WebService/ph_values.txt diff --git a/WebService/Sources/Demo/ConductivitySensor.swift b/WebService/Sources/Demo/ConductivitySensor.swift new file mode 100644 index 0000000..9a05974 --- /dev/null +++ b/WebService/Sources/Demo/ConductivitySensor.swift @@ -0,0 +1,9 @@ +import Apodini +import Foundation + + +struct ConductivitySensor: SensorHandler { + static let dirPath = "data" + static let sensorType: SensorType = .CONDUCTIVITY + static let converter = getMeasurementConverterInstance(sensorType: .CONDUCTIVITY) +} diff --git a/WebService/Sources/Demo/PhSensor.swift b/WebService/Sources/Demo/PhSensor.swift new file mode 100644 index 0000000..9f94a30 --- /dev/null +++ b/WebService/Sources/Demo/PhSensor.swift @@ -0,0 +1,9 @@ +import Apodini +import Foundation + + +struct PhSensor: SensorHandler { + static let dirPath = "data" + static let sensorType: SensorType = .POTENTIAHYDROGENII + static let converter = getMeasurementConverterInstance(sensorType: .POTENTIAHYDROGENII) +} diff --git a/WebService/Sources/Demo/SensorData.swift b/WebService/Sources/Demo/SensorData.swift index 1203f1d..5a2316e 100644 --- a/WebService/Sources/Demo/SensorData.swift +++ b/WebService/Sources/Demo/SensorData.swift @@ -23,8 +23,16 @@ struct SensorData: Handler { } var content: some Component { + Group(TemperatureSensor.sensorType.description) { + TemperatureSensor() + } + Group(ConductivitySensor.sensorType.description) { ConductivitySensor() } + + Group(PhSensor.sensorType.description) { + PhSensor() + } } } diff --git a/WebService/Sources/Demo/TDSSensor.swift b/WebService/Sources/Demo/SensorHandler.swift similarity index 53% rename from WebService/Sources/Demo/TDSSensor.swift rename to WebService/Sources/Demo/SensorHandler.swift index 1bf431b..510f18f 100644 --- a/WebService/Sources/Demo/TDSSensor.swift +++ b/WebService/Sources/Demo/SensorHandler.swift @@ -1,12 +1,15 @@ import Apodini -import Foundation -struct ConductivitySensor: Handler { - static let dirPath = "data" - static let sensorType: SensorType = .CONDUCTIVITY - static let converter = getMeasurementConverterInstance(sensorType: Self.sensorType) +protocol SensorHandler: Handler { + static var dirPath: String { get } + static var sensorType: SensorType { get } + static var converter: MeasurementConverter { get } + func handle() -> [SensorDump] +} + +extension SensorHandler { func handle() -> [SensorDump] { readJSONDirectory(SensorDump.self, dirPath: Self.dirPath) .map { $0.filteredBySensorType(Self.sensorType).convertMeasurements(Self.converter) } diff --git a/WebService/Sources/Demo/TemperatureSensor.swift b/WebService/Sources/Demo/TemperatureSensor.swift new file mode 100644 index 0000000..5ca6fc8 --- /dev/null +++ b/WebService/Sources/Demo/TemperatureSensor.swift @@ -0,0 +1,9 @@ +import Apodini +import Foundation + + +struct TemperatureSensor: SensorHandler { + static let dirPath = "data" + static let sensorType: SensorType = .TEMPERATURE + static let converter = getMeasurementConverterInstance(sensorType: .TEMPERATURE) +} diff --git a/WebService/ph_values.txt b/WebService/ph_values.txt deleted file mode 100644 index cc39385..0000000 --- a/WebService/ph_values.txt +++ /dev/null @@ -1,4 +0,0 @@ -0 7 -1 7.3 -2 7.2 -3 6.9 \ No newline at end of file From 86132d888a06cfdf83bc38ec836dbfaa16520706 Mon Sep 17 00:00:00 2001 From: Florian Lercher Date: Sat, 25 Sep 2021 09:50:06 +0000 Subject: [PATCH 7/7] Add config files for new sensors --- WebService/Sources/Demo/MeasurementConverter.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/WebService/Sources/Demo/MeasurementConverter.swift b/WebService/Sources/Demo/MeasurementConverter.swift index d4cb780..4fa3245 100644 --- a/WebService/Sources/Demo/MeasurementConverter.swift +++ b/WebService/Sources/Demo/MeasurementConverter.swift @@ -7,8 +7,12 @@ protocol MeasurementConverter { func getMeasurementConverterInstance(sensorType: SensorType) -> MeasurementConverter { switch sensorType { + case TemperatureSensor.sensorType: + return PolynomialMeasurementConverter(configFilePath: "sensorconfig/TemperatureSensor.json") case ConductivitySensor.sensorType: return PolynomialMeasurementConverter(configFilePath: "sensorconfig/ConductivitySensor.json") + case PhSensor.sensorType: + return PolynomialMeasurementConverter(configFilePath: "sensorconfig/PhSensor.json") default: return NoopConverter() }