Changeset 9627 in ntrip
- Timestamp:
- Feb 21, 2022, 10:07:55 AM (3 years ago)
- Location:
- trunk/BNC/scripts
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/scripts/Common.pm
r9597 r9627 205 205 } 206 206 207 # toLineProtocol($rcd) 208 # @brief converts $rcd to InfluxDB line protocol 209 # @see https://docs.influxdata.com/influxdb/v2.1/reference/syntax/line-protocol/ 210 sub toLineProtocol { 211 my ($rcd) = @_; 212 213 my $err = 0; 214 my $str = $rcd->{'measurement'} . ','; 215 216 # Tags (sort by key (in lexicographic order) for performance reasons) 217 foreach ( sort { lc ($a) cmp lc ($b) } keys %{ $rcd->{'tags'} } ) { 218 if ( !exists $rcd->{'tags'}->{$_} ) { 219 $err++; 220 #next; # ? 221 } 222 $str .= $_ . "=" . $rcd->{'tags'}->{$_} . ","; 223 } 224 chop $str; 225 $str .= " "; 226 227 # Fields 228 while ( my ( $k, $v ) = each %{ $rcd->{'fields'} } ) { 229 if ( !defined $v ) { 230 $err++; 231 } 232 $str .= $k . "=" . $v . ","; 233 } 234 chop $str; 235 $str .= " " . $rcd->{'time'}; # prec=s 236 if ($err) { 237 return 0; 238 } 239 return $str; 240 } 241 207 242 #** @function rms ($numbers) 208 243 # @brief Compute the Root mean square.
Note:
See TracChangeset
for help on using the changeset viewer.