-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support for Adeunis pulse historic data and analog
- Loading branch information
Showing
21 changed files
with
8,099 additions
and
2,755 deletions.
There are no files selected for viewing
This file contains 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
495 changes: 294 additions & 201 deletions
495
nodejs/c8y-codec-interface/src/lora/codec/DeviceCodec.ts
Large diffs are not rendered by default.
Oops, something went wrong.
154 changes: 93 additions & 61 deletions
154
nodejs/c8y-codec-interface/src/lora/codec/uplink/C8YData.ts
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,103 @@ | ||
import {IMeasurementCreate, IEvent, IAlarm, IManagedObject, Severity} from '@c8y/client'; | ||
import { | ||
IMeasurementCreate, | ||
IEvent, | ||
IAlarm, | ||
IManagedObject, | ||
Severity, | ||
} from "@c8y/client"; | ||
|
||
export class C8YData { | ||
measurements: Partial<IMeasurementCreate>[] = []; | ||
events: IEvent[] = []; | ||
alarms: IAlarm[] = []; | ||
alarmsToClear: string[] = []; | ||
morToUpdate?: IManagedObject; | ||
|
||
addMeasurement(mor: IManagedObject, fragment: string, series: string, unit: string, value: number, time: Date) { | ||
let m: Partial<IMeasurementCreate> = { | ||
sourceId: mor.id, | ||
type: fragment, | ||
time: time | ||
}; | ||
measurements: Partial<IMeasurementCreate>[] = []; | ||
events: IEvent[] = []; | ||
alarms: IAlarm[] = []; | ||
alarmsToClear: string[] = []; | ||
morToUpdate?: Partial<IManagedObject>; | ||
|
||
m[fragment] = {}; | ||
m[fragment][series] = {"value": value, "unit": unit}; | ||
addMeasurement( | ||
mor: Partial<IManagedObject>, | ||
fragment: string, | ||
series: string, | ||
unit: string, | ||
value: number, | ||
time: Date | ||
) { | ||
let m: Partial<IMeasurementCreate> = { | ||
sourceId: mor.id, | ||
type: fragment, | ||
time: time, | ||
}; | ||
|
||
this.measurements.push(m); | ||
} | ||
|
||
addMeasurements(mor: IManagedObject, fragment: string, serieses: string[], units: string[], values: number[], time: Date) { | ||
let m: Partial<IMeasurementCreate> = { | ||
sourceId: mor.id, | ||
type: fragment, | ||
time: time | ||
}; | ||
m[fragment] = {}; | ||
m[fragment][series] = { value: value, unit: unit }; | ||
|
||
m[fragment] = {} | ||
for(let i=0;i<serieses.length;i++) { | ||
m[fragment][serieses[i]] = {"value": values[i], "unit": units[i]}; | ||
} | ||
this.measurements.push(m); | ||
} | ||
|
||
this.measurements.push(m); | ||
} | ||
addMeasurements( | ||
mor: Partial<IManagedObject>, | ||
fragment: string, | ||
serieses: string[], | ||
units: string[], | ||
values: number[], | ||
time: Date | ||
) { | ||
let m: Partial<IMeasurementCreate> = { | ||
sourceId: mor.id, | ||
type: fragment, | ||
time: time, | ||
}; | ||
|
||
addEvent(mor:IManagedObject, eventType: string, eventText: string, properties: {}, dateTime: Date) { | ||
let event: IEvent = { | ||
source: { | ||
id: mor.id | ||
}, | ||
type: eventType, | ||
text: eventText, | ||
time: dateTime.toISOString() | ||
}; | ||
if (properties) { | ||
Object.assign(event, properties); | ||
} | ||
|
||
this.events.push(event); | ||
m[fragment] = {}; | ||
for (let i = 0; i < serieses.length; i++) { | ||
m[fragment][serieses[i]] = { value: values[i], unit: units[i] }; | ||
} | ||
|
||
addAlarm(mor: IManagedObject, alarmType: string, alarmText: string, severity: Severity, dateTime: Date) { | ||
let alarm: IAlarm = { | ||
source: { | ||
id: mor.id | ||
}, | ||
time: dateTime.toISOString(), | ||
text: alarmText, | ||
type: alarmType, | ||
severity: severity | ||
}; | ||
|
||
this.alarms.push(alarm); | ||
} | ||
this.measurements.push(m); | ||
} | ||
|
||
clearAlarm(alarmType: string) { | ||
this.alarmsToClear.push(alarmType); | ||
} | ||
} | ||
addEvent( | ||
mor: Partial<IManagedObject>, | ||
eventType: string, | ||
eventText: string, | ||
properties: {}, | ||
dateTime: Date | ||
) { | ||
let event: IEvent = { | ||
source: { | ||
id: mor.id, | ||
}, | ||
type: eventType, | ||
text: eventText, | ||
time: dateTime.toISOString(), | ||
}; | ||
if (properties) { | ||
Object.assign(event, properties); | ||
} | ||
|
||
this.events.push(event); | ||
} | ||
|
||
addAlarm( | ||
mor: Partial<IManagedObject>, | ||
alarmType: string, | ||
alarmText: string, | ||
severity: Severity, | ||
dateTime: Date | ||
) { | ||
let alarm: IAlarm = { | ||
source: { | ||
id: mor.id, | ||
}, | ||
time: dateTime.toISOString(), | ||
text: alarmText, | ||
type: alarmType, | ||
severity: severity, | ||
}; | ||
|
||
this.alarms.push(alarm); | ||
} | ||
|
||
clearAlarm(alarmType: string) { | ||
this.alarmsToClear.push(alarmType); | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
rm image.tar | ||
rm lora-codec-adeunis.zip | ||
cd .. | ||
docker build . -t lora-codec-adeunis -f lora-codec-adeunis/Dockerfile | ||
cd lora-codec-adeunis | ||
docker save lora-codec-adeunis -o image.tar | ||
zip lora-codec-adeunis image.tar cumulocity.json |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module.exports = { | ||
preset: "ts-jest", | ||
testEnvironment: "node" | ||
} |
Oops, something went wrong.