I am following the Web Development Tutotrial and trying to create an application that extracts two custom types of data from Cumulocity.
More specifically, I am trying to get existing as well as new incoming measurements from the backend. To do so, I created an Angular service and injected it with the InventoryService and the MeasurementsService from the Web SDK.
However, I want to create a method that uses the following 2 custom classes I modelled using the SmartRestTemplate:
Mode Usage
…and Tube Set Type
While I am confident with how I modeled my method to retrieve all records from C8Y with the instance of my InventoryService, I am less clear on how to reproduce the following method using my own MeasurementsService.
This is the method from the tutorial that I am referring to:
private async loadLatestMeasurement(
deviceId: string,
measurementFragment: string,
measurementSeries: string
) {
const filter = {
source: deviceId,
dateFrom: '1970-01-01',
dateTo: new Date().toISOString(),
valueFragmentType: measurementFragment,
valueFragmentSeries: measurementSeries,
pageSize: 1,
revert: true,
};
try {
const response = await this.measurementService.list(filter);
if (
!response.data ||
response.data.length != 1 ||
!has(response.data[0], `${measurementFragment}.${measurementSeries}`)
) {
return;
}
const temperatureValue: number = get(
response.data[0],
`${measurementFragment}.${measurementSeries}.value`
);
const temperatureUnit: string = get(
response.data[0],
`${measurementFragment}.${measurementSeries}.unit`
);
this.temperatureMeasurement$.next({ value: temperatureValue, unit: temperatureUnit });
} catch (error) {
console.error('Error occurred while loading the latest measurement: ', error);
}
}
I suppose my main question is where do I get correct fragment and series names from my own templates to use with my own version of the loadLatestMeasurement
method?