Skip to content

Commit 5c158f8

Browse files
authored
Merge pull request #13 from CDPTechnologies/fix-documentation-discrepancies
Fix documentation
2 parents 2845852 + 67a6a55 commit 5c158f8

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

DOCUMENTATION.md

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -146,14 +146,14 @@ A few notes on the above example:
146146

147147
- The `requestLoggedNodes()` call returns an array of node info objects. Each object has at least `{ name: string, routing: string }` and possibly a `tags` object if tags are supported and fetched. The `tags` object is a dictionary of tagName -> `{ value: any, source: string }`. For example, a node could have `node.tags.Unit = { value: "°C", source: "CDPStudio" }` indicating the engineering unit is degrees Celsius.
148148

149-
You can also request historical **data points** for one or more signals using `client.requestDataPoints(names, startTimeSec, endTimeSec, numberOfPoints)`. For example:
149+
You can also request historical **data points** for one or more signals using `client.requestDataPoints(nodeNames, startS, endS, noOfDataPoints, limit)`. For example:
150150

151151
```js
152152
const limits = await client.requestLogLimits();
153153
const start = limits.startS;
154154
const end = limits.endS;
155155
// Request 100 data points for signals "Temperature" and "Pressure" over the full range
156-
const dataPoints = await client.requestDataPoints(["Temperature", "Pressure"], start, end, 100);
156+
const dataPoints = await client.requestDataPoints(["Temperature", "Pressure"], start, end, 100, 0);
157157
dataPoints.forEach(point => {
158158
console.log("Timestamp:", point.timestamp);
159159
// Each point.value will contain an object with keys for each signal name:
@@ -169,11 +169,14 @@ dataPoints.forEach(point => {
169169
});
170170
```
171171

172-
The above demonstrates retrieving 100 aggregated data points between the earliest and latest logged times. Each data point might represent an interval of time within the range, with `min`, `max`, and `last` values of the signal during that interval (this is how the CDP Logger provides downsampled data). If you instead want full resolution data, you can specify `numberOfPoints = 0` to get all points (be careful with performance if the range is large). You can also specify a `limit` (max number of points) separate from the number of intervals, as well as request specific aggregation methods.
172+
The above demonstrates retrieving 100 aggregated data points between the earliest and latest logged times. Each data point might represent an interval of time within the range, with `min`, `max`, and `last` values of the signal during that interval (this is how the CDP Logger provides downsampled data). If you instead want full resolution data, you can specify `noOfDataPoints = 0` to get all points (be careful with performance if the range is large). You can also specify a `limit` (max number of points) separate from the number of intervals, as well as request specific aggregation methods.
173173

174174
Finally, to retrieve **events**, you can use `client.requestEvents(query)` along with constructing a query object. You can also use `client.countEvents(query)` to just get the count. Here’s a brief Node example for events:
175175

176176
```js
177+
// Helpful enums from the client for query construction
178+
const { MatchType, EventQueryFlags } = cdplogger.Client;
179+
177180
const query = { // Note: all query arguments are optional
178181
senderConditions: [
179182
{ value: "MyApp.AlarmManager", matchType: MatchType.Exact }
@@ -182,7 +185,7 @@ const query = { // Note: all query arguments are optional
182185
// Assume events have a field "Text" and we want those containing "Overheat"
183186
Text: ["Overheat*"] // '*' wildcard is the default option
184187
},
185-
timeRangeStart: Date.now()/1000 - 24*3600, // last 24 hours in seconds (if time filtering desired)
188+
timeRangeBegin: Date.now()/1000 - 24*3600, // last 24 hours in seconds (if time filtering desired)
186189
limit: 50, // max 50 events
187190
offset: 0, // start from the first match
188191
flags: EventQueryFlags.NewestFirst // get newest events first

0 commit comments

Comments
 (0)