@@ -105,7 +105,12 @@ FullSignalK.prototype.addUpdate = function(context, contextPath, update) {
105
105
} else {
106
106
console . error ( "No source in delta update:" + JSON . stringify ( update ) ) ;
107
107
}
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
+ }
109
114
}
110
115
111
116
FullSignalK . prototype . updateDollarSource = function ( context , dollarSource , timestamp ) {
@@ -198,17 +203,13 @@ function addValue(context, contextPath, source, timestamp, pathValue) {
198
203
if ( ! previous [ pathPart ] ) {
199
204
previous [ pathPart ] = { } ;
200
205
}
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 ) {
208
209
_ . assign ( meta , previous [ pathPart ] . meta )
209
- previous [ pathPart ] . meta = meta
210
+ previous [ pathPart ] . meta = meta
210
211
}
211
- }
212
+ }
212
213
return previous [ pathPart ] ;
213
214
} , context ) ;
214
215
}
@@ -267,5 +268,17 @@ function setMessage(leaf, source) {
267
268
}
268
269
}
269
270
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
+
270
283
271
284
module . exports = FullSignalK ;
0 commit comments