Merge remote-tracking branch 'fb/multi-decoder/master' into feat/use-tahu-for-sparkplug-decoding
This commit is contained in:
@@ -8,6 +8,7 @@ import { PlotCurveTypes } from '../reducers/Charts'
|
||||
const parseDuration = require('parse-duration')
|
||||
|
||||
interface Props {
|
||||
node?: q.TreeNode<any>
|
||||
history: q.MessageHistory
|
||||
dotPath?: string
|
||||
timeInterval?: string
|
||||
@@ -25,22 +26,23 @@ function filterUsingTimeRange(startTime: number | undefined, data: Array<q.Messa
|
||||
return data
|
||||
}
|
||||
|
||||
function nodeToHistory(startTime: number | undefined, history: q.MessageHistory) {
|
||||
function nodeToHistory(startTime: number | undefined, history: q.MessageHistory, type: q.TopicDataType) {
|
||||
return filterUsingTimeRange(startTime, history.toArray())
|
||||
.map((message: q.Message) => {
|
||||
const value = message.payload ? toPlottableValue(Base64Message.toUnicodeString(message.payload)) : NaN
|
||||
const [value, ignore] = message.payload ? Base64Message.format(message.payload, type) : [NaN, undefined]
|
||||
// const value = message.payload ? toPlottableValue(Base64Message.toUnicodeString(message.payload)) : NaN
|
||||
return { x: message.received.getTime(), y: toPlottableValue(value) }
|
||||
})
|
||||
.filter(data => !isNaN(data.y as any)) as any
|
||||
}
|
||||
|
||||
function nodeDotPathToHistory(startTime: number | undefined, history: q.MessageHistory, dotPath: string) {
|
||||
function nodeDotPathToHistory(startTime: number | undefined, history: q.MessageHistory, dotPath: string, type: q.TopicDataType) {
|
||||
return filterUsingTimeRange(startTime, history.toArray())
|
||||
.map((message: q.Message) => {
|
||||
let json: any = {}
|
||||
try {
|
||||
json = message.payload ? JSON.parse(Base64Message.toUnicodeString(message.payload)) : {}
|
||||
} catch (ignore) {}
|
||||
} catch (ignore) { }
|
||||
|
||||
const value = dotProp.get(json, dotPath)
|
||||
|
||||
@@ -54,8 +56,8 @@ function TopicPlot(props: Props) {
|
||||
const data = React.useMemo(
|
||||
() =>
|
||||
props.dotPath
|
||||
? nodeDotPathToHistory(startOffset, props.history, props.dotPath)
|
||||
: nodeToHistory(startOffset, props.history),
|
||||
? nodeDotPathToHistory(startOffset, props.history, props.dotPath, props.node ? props.node.type : 'string')
|
||||
: nodeToHistory(startOffset, props.history, props.node ? props.node.type : 'string'),
|
||||
[props.history.last(), startOffset, props.dotPath]
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user