@@ -105,7 +105,12 @@ FullSignalK.prototype.addUpdate = function(context, contextPath, update) {
105105 } else {
106106 console . error ( "No source in delta update:" + JSON . stringify ( update ) ) ;
107107 }
108- addValues ( context , contextPath , update . source || update [ '$source' ] , update . timestamp , update . values ) ;
108+ if ( update . values ) {
109+ addValues ( context , contextPath , update . source || update [ '$source' ] , update . timestamp , update . values ) ;
110+ }
111+ if ( update . meta ) {
112+ addMetas ( context , contextPath , update . source || update [ '$source' ] , update . timestamp , update . meta ) ;
113+ }
109114}
110115
111116FullSignalK . prototype . updateDollarSource = function ( context , dollarSource , timestamp ) {
@@ -198,17 +203,13 @@ function addValue(context, contextPath, source, timestamp, pathValue) {
198203 if ( ! previous [ pathPart ] ) {
199204 previous [ pathPart ] = { } ;
200205 }
201- if ( i === splitPath . length - 1 && typeof previous [ pathPart ] . value === 'undefined' ) {
202- let meta = signalkSchema . getMetadata ( contextPath + '.' + pathValue . path )
203- if ( meta ) {
204- //ignore properties from keyswithmetadata.json
205- meta = JSON . parse ( JSON . stringify ( meta ) )
206- delete meta . properties
207-
206+ if ( i === splitPath . length - 1 && typeof previous [ pathPart ] . value === 'undefined' ) {
207+ let meta = signalkSchema . internalGetMetadata ( contextPath + '.' + pathValue . path )
208+ if ( meta ) {
208209 _ . assign ( meta , previous [ pathPart ] . meta )
209- previous [ pathPart ] . meta = meta
210+ previous [ pathPart ] . meta = meta
210211 }
211- }
212+ }
212213 return previous [ pathPart ] ;
213214 } , context ) ;
214215 }
@@ -267,5 +268,17 @@ function setMessage(leaf, source) {
267268 }
268269}
269270
271+ function addMetas ( context , contextPath , source , timestamp , metas ) {
272+ metas . forEach ( metaPathValue => addMeta ( context , contextPath , source , timestamp , metaPathValue ) )
273+ }
274+
275+ function addMeta ( context , contextPath , source , timestamp , pathValue ) {
276+ if ( _ . isUndefined ( pathValue . path ) || _ . isUndefined ( pathValue . value ) ) {
277+ console . error ( "Illegal value in delta:" + JSON . stringify ( pathValue ) ) ;
278+ return ;
279+ }
280+ signalkSchema . addMetaData ( contextPath , pathValue . path , pathValue . value )
281+ }
282+
270283
271284module . exports = FullSignalK ;
0 commit comments