remobe generated ts and load proto file directly
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import * as q from '../../../../../backend/src/Model'
|
||||
import * as React from 'react'
|
||||
import * as fs from 'fs'
|
||||
import CodeDiff from '../CodeDiff'
|
||||
import { AppState } from '../../../reducers'
|
||||
import { Base64Message } from '../../../../../backend/src/Model/Base64Message'
|
||||
import { Payload } from '../../../../../backend/src/Model/sparkplug'
|
||||
import { Payload } from '../../../../../backend/src/Model/sparkplugb'
|
||||
import { connect } from 'react-redux'
|
||||
import { ValueRendererDisplayMode } from '../../../reducers/Settings'
|
||||
import { Fade } from '@material-ui/core'
|
||||
@@ -50,8 +51,14 @@ class ValueRenderer extends React.Component<Props, State> {
|
||||
} catch (error) {
|
||||
try {
|
||||
//Sparkplugb
|
||||
let payload = Payload.decode(Base64Message.toUint8Array(msg))
|
||||
const json = Payload.toJSON(payload)
|
||||
if (Payload === undefined) {
|
||||
throw Error('sparkplugb.Payload is not loaded yet')
|
||||
}
|
||||
let json = Payload.toObject(Payload.decode(Base64Message.toUint8Array(msg)), {
|
||||
longs: String,
|
||||
enums: String,
|
||||
bytes: String,
|
||||
})
|
||||
return [JSON.stringify(json, undefined, ' '), 'json']
|
||||
} catch (error) {
|
||||
return [str, undefined]
|
||||
|
||||
@@ -5,7 +5,7 @@ import PlotHistory from './Chart/Chart'
|
||||
import { Base64Message } from '../../../backend/src/Model/Base64Message'
|
||||
import { toPlottableValue } from './Sidebar/CodeDiff/util'
|
||||
import { PlotCurveTypes } from '../reducers/Charts'
|
||||
import { Payload } from '../../../backend/src/Model/sparkplug'
|
||||
import { Payload } from '../../../backend/src/Model/sparkplugb'
|
||||
const parseDuration = require('parse-duration')
|
||||
|
||||
interface Props {
|
||||
@@ -41,12 +41,7 @@ function nodeDotPathToHistory(startTime: number | undefined, history: q.MessageH
|
||||
let json: any = {}
|
||||
try {
|
||||
json = message.payload ? JSON.parse(Base64Message.toUnicodeString(message.payload)) : {}
|
||||
} catch (ignore) {
|
||||
// sparkplugb
|
||||
try {
|
||||
json = message.payload ? Payload.toJSON(Payload.decode(Base64Message.toUint8Array(message.payload))) : {}
|
||||
} catch (ignore) {}
|
||||
}
|
||||
} catch (ignore) {}
|
||||
|
||||
const value = dotProp.get(json, dotPath)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user