*** WIP WIP *** woks now for live and havg
This commit is contained in:
+23
-17
@@ -4,11 +4,9 @@
|
||||
import {returnOnError} from "../utilities/reporterror.js";
|
||||
import { getActData, getAvgData, getLongAvg, fetchFromInflux, calcRange} from "../actions/getsensorData.js"
|
||||
import checkParams from "../utilities/checkparams.js";
|
||||
import {getOneProperty} from "../actions/getproperties.js";
|
||||
import * as ERR from "../utilities/errortexts.js"
|
||||
import {DateTime} from 'luxon'
|
||||
import {getData4map} from "../actions/data4map.js";
|
||||
import {NODATA} from "../utilities/errortexts.js";
|
||||
import * as noiseChart from "./noiseChart.js";
|
||||
|
||||
const setoptionfromtable = (opt,tabval) => {
|
||||
let ret = opt
|
||||
@@ -25,6 +23,7 @@ export const getNoiseData = async (params, possibles, props) => {
|
||||
let {opts, err} = checkParams(params, {
|
||||
mandatory:[
|
||||
{name:'sensorid', type: 'int'},
|
||||
{name:'chart', type: 'bool'},
|
||||
],
|
||||
optional: possibles
|
||||
})
|
||||
@@ -44,6 +43,9 @@ export const getNoiseData = async (params, possibles, props) => {
|
||||
opts.start = start
|
||||
opts.stop = stop
|
||||
let erg = await x.func(opts) // get the data
|
||||
if (opts.chart) {
|
||||
return erg
|
||||
}
|
||||
ret = {
|
||||
err: erg.err,
|
||||
sid: opts.sensorid,
|
||||
@@ -92,8 +94,12 @@ export const getNoiseData = async (params, possibles, props) => {
|
||||
// ....
|
||||
//
|
||||
// *********************************************
|
||||
const getLiveData = async (opt) => {
|
||||
return await getActData(opt)
|
||||
const getLiveData = async (opts) => {
|
||||
const erg = await getActData(opts)
|
||||
if (!opts.chart || erg.err) {
|
||||
return erg
|
||||
}
|
||||
return noiseChart.liveData(opts, erg.values)
|
||||
}
|
||||
|
||||
|
||||
@@ -135,9 +141,10 @@ const gethavgData = async (opts, props) => {
|
||||
}
|
||||
}
|
||||
return csvStr
|
||||
} else {
|
||||
} else if (!opts.chart || erg.err) {
|
||||
return {err: erg.err, values: erg.values}
|
||||
|
||||
} else {
|
||||
return noiseChart.havgData(opts, erg.values)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -413,16 +420,6 @@ const getAPIprops = (opt) => {
|
||||
|
||||
}
|
||||
|
||||
const whatTable = [
|
||||
{'what':'live', 'span': 1, 'daystart': false, peak: false, 'func': getLiveData},
|
||||
{'what':'havg', 'span': 7, 'daystart': true, peak: true, 'func': gethavgData},
|
||||
{'what':'davg', 'span': 30, 'daystart': true, peak: true, 'func': getdavgData},
|
||||
{'what':'daynight', 'span': 30, 'daystart': true, peak: false, 'func': getdaynightData},
|
||||
{'what':'lden', 'span': 30, 'daystart': true, peak: false, 'func': getLdenData},
|
||||
{'what':'props', 'span': 0, 'daystart': true, peak:false, 'func': getAPIprops},
|
||||
];
|
||||
|
||||
|
||||
const getNoiseAVGData = async (opts) => {
|
||||
let ret = {err: null, values: []}
|
||||
let emptyValues = {n_AVG:-1}
|
||||
@@ -506,3 +503,12 @@ peak = data
|
||||
return { err: ret.err, values: hoursArr}
|
||||
}
|
||||
|
||||
const whatTable = [
|
||||
{'what':'live', 'span': 1, 'daystart': false, peak: false, 'func': getLiveData},
|
||||
{'what':'havg', 'span': 7, 'daystart': true, peak: true, 'func': gethavgData},
|
||||
{'what':'davg', 'span': 30, 'daystart': true, peak: true, 'func': getdavgData},
|
||||
{'what':'daynight', 'span': 30, 'daystart': true, peak: false, 'func': getdaynightData},
|
||||
{'what':'lden', 'span': 30, 'daystart': true, peak: false, 'func': getLdenData},
|
||||
{'what':'props', 'span': 0, 'daystart': true, peak:false, 'func': getAPIprops},
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user