C8yMeasurementsService
public class C8yMeasurementsService : JcConnectionRequest<C8yCumulocityConnection>
Allows measurements to be fetched and posted to Cumulocity. Leverages the underlying api at endpoint ‘\/measurement/measurements’ and described here
-
Used when fetching
C8yMeasurement
s to determines the maximum number allowed in a single request, default is 50Declaration
Swift
public var pageSize: Int
-
Returns a page `C8yPagedMeasurements` of `C8yMeasurement` instances generated by a device for the given internal c8y id. - parameter forSource internal id of the `C8yManagedObject` that is the source of measurements to be returned - parameter pageNum The page to be fetched, total pages can be found in via the statistics property `statistics` defined by `C8yPageStatistics` of the returned `C8yPagedMeasurements` object - parameter from Date and time to search from - parameter to Date and time to search upto (use Date() to specify up to now) - parameter reverseDateOrder if false results are ordered date descending, specify true (default) for the opposite i.e. the last measurement will be first in the list
Declaration
Swift
public func get(forSource id: String, pageNum: Int, from: Date, to: Date, reverseDateOrder: Bool) -> AnyPublisher<JcRequestResponse<C8yPagedMeasurements>, APIError>
-
Returns a page
C8yPagedMeasurements
ofC8yMeasurement
instances generated by a device for the given internal c8y id for the given measurement typeDeclaration
Swift
public func get(forSource id: String, type: String, pageNum: Int, from: Date, to: Date, reverseDateOrder: Bool) -> AnyPublisher<JcRequestResponse<C8yPagedMeasurements>, APIError>
-
Returns an aggregrated series
C8yMeasurementSeries
of measurements generated by a device for the given internal c8y id for the given measurement type and sub value seriesDeclaration
Swift
public func getSeries(forSource id: String, type: String, series: String, from: Date, to: Date, aggregrationType: C8yMeasurementSeries.AggregateType) -> AnyPublisher<JcRequestResponse<C8yMeasurementSeries>, APIError>
-
Posts a set of new
C8yMeasurement
instances to cumulocity for the an associated deviceThrows
throws If any measurement is missing mandatory fields, or if associated Managed Objects do not exist in c8yDeclaration
Swift
public func post(_ measurements: [C8yMeasurement]) throws -> AnyPublisher<JcRequestResponse<Bool>, APIError>