Created
December 7, 2023 14:12
-
-
Save RWaltersMA/9abf47a03021e425e8a63df96368cdfb to your computer and use it in GitHub Desktop.
Atlas Stream Processing Solar Stream Sample Example
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
SAMPLE STREAM SOLAR | |
//Create the Stream Processor and add the sample_stream_solar connection registry connection first | |
//Create variablre for source connection | |
solar={$source:{connectionName:'sample_stream_solar', timeField: { $dateFromString: { dateString: '$timestamp' }}}} | |
// Observe sample data | |
sp.process([solar]) | |
//create a variable for the tumbling windoe | |
w = { $tumblingWindow: { | |
interval: {size: NumberInt(10), unit: "second"}, | |
"pipeline": [ | |
{ | |
$group: { | |
"_id" : { "device_id" : "$device_id"}, | |
max_temp : { $max : "$obs.temp"}, | |
max_watts : { $max : "$obs.watts"}, | |
min_watts : { $min : "$obs.watts"}, | |
avg_watts : { $avg : "$obs.watts"}, | |
median_watts : { $median :{ | |
input: "$obs.watts", | |
method: "approximate" | |
} } | |
} | |
} | |
], | |
} | |
} | |
//observe resuting tumbling window stream | |
sp.process([solar,w]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment