Skip to content

Commit

Permalink
feat(history): add charge current fuel gauge reading
Browse files Browse the repository at this point in the history
  • Loading branch information
coderbyheart committed Oct 12, 2023
1 parent fbcf7c6 commit 41b6d90
Showing 1 changed file with 78 additions and 65 deletions.
143 changes: 78 additions & 65 deletions lambda/chartSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export type Summary = {
solGain?: Readings
// Fuel gauge readings
fgSoC?: Readings
fgI?: Readings
fgTTE?: Readings
fgTTF?: Readings
base: Date
Expand Down Expand Up @@ -98,85 +99,97 @@ export const createChartSummary = async ({
historicaldataDatabaseName: string
historicaldataTableName: string
}): Promise<Summaries> => {
const [bat, temp, solBat, solGain, fgSoC, fgTTE, fgTTF] = await Promise.all([
timestream.send(
new QueryCommand({
QueryString: summaryQuery({
db: historicaldataDatabaseName,
table: historicaldataTableName,
measureName: 'bat',
hours: 1,
const [bat, temp, solBat, solGain, fgSoC, fgI, fgTTE, fgTTF] =
await Promise.all([
timestream.send(
new QueryCommand({
QueryString: summaryQuery({
db: historicaldataDatabaseName,
table: historicaldataTableName,
measureName: 'bat',
hours: 1,
}),
}),
}),
),
timestream.send(
new QueryCommand({
QueryString: summaryQuery({
db: historicaldataDatabaseName,
table: historicaldataTableName,
measureName: 'env.temp',
hours: 1,
),
timestream.send(
new QueryCommand({
QueryString: summaryQuery({
db: historicaldataDatabaseName,
table: historicaldataTableName,
measureName: 'env.temp',
hours: 1,
}),
}),
}),
),
timestream.send(
new QueryCommand({
QueryString: summaryQuery({
db: historicaldataDatabaseName,
table: historicaldataTableName,
measureName: 'sol.bat',
hours: 1,
),
timestream.send(
new QueryCommand({
QueryString: summaryQuery({
db: historicaldataDatabaseName,
table: historicaldataTableName,
measureName: 'sol.bat',
hours: 1,
}),
}),
}),
),
timestream.send(
new QueryCommand({
QueryString: summaryQuery({
db: historicaldataDatabaseName,
table: historicaldataTableName,
measureName: 'sol.gain',
hours: 1,
),
timestream.send(
new QueryCommand({
QueryString: summaryQuery({
db: historicaldataDatabaseName,
table: historicaldataTableName,
measureName: 'sol.gain',
hours: 1,
}),
}),
}),
),
timestream.send(
new QueryCommand({
QueryString: summaryQuery({
db: historicaldataDatabaseName,
table: historicaldataTableName,
measureName: 'fg.SoC',
hours: 1,
),
timestream.send(
new QueryCommand({
QueryString: summaryQuery({
db: historicaldataDatabaseName,
table: historicaldataTableName,
measureName: 'fg.SoC',
hours: 1,
}),
}),
}),
),
timestream.send(
new QueryCommand({
QueryString: summaryQuery({
db: historicaldataDatabaseName,
table: historicaldataTableName,
measureName: 'fg.TTE',
hours: 1,
),
timestream.send(
new QueryCommand({
QueryString: summaryQuery({
db: historicaldataDatabaseName,
table: historicaldataTableName,
measureName: 'fg.I',
hours: 1,
}),
}),
}),
),
timestream.send(
new QueryCommand({
QueryString: summaryQuery({
db: historicaldataDatabaseName,
table: historicaldataTableName,
measureName: 'fg.TTF',
hours: 1,
),
timestream.send(
new QueryCommand({
QueryString: summaryQuery({
db: historicaldataDatabaseName,
table: historicaldataTableName,
measureName: 'fg.TTE',
hours: 1,
}),
}),
}),
),
])
),
timestream.send(
new QueryCommand({
QueryString: summaryQuery({
db: historicaldataDatabaseName,
table: historicaldataTableName,
measureName: 'fg.TTF',
hours: 1,
}),
}),
),
])
const now = new Date()
const summaries: Summaries = {}
groupResult(summaries, 'bat', bat, now, (v) => v / 1000)
groupResult(summaries, 'temp', temp, now)
groupResult(summaries, 'solBat', solBat, now)
groupResult(summaries, 'solGain', solGain, now)
groupResult(summaries, 'fgSoC', fgSoC, now)
groupResult(summaries, 'fgI', fgI, now)
groupResult(summaries, 'fgTTE', fgTTE, now)
groupResult(summaries, 'fgTTF', fgTTF, now)

Expand Down

0 comments on commit 41b6d90

Please sign in to comment.