diff --git a/.clang-tidy b/.clang-tidy index 425050765..d71c07a3b 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,4 +1,62 @@ --- Checks: '-*,boost-use-to-string,cert-dcl21-cpp,cert-dcl58-cpp,cert-env33-c,cert-err52-cpp,cert-err60-cpp,cert-flp30-c,clang-analyzer-cplusplus*,cppcoreguidelines-pro-type-static-cast-downcast,cppcoreguidelines-slicing,google-build-namespaces,google-runtime-int,google-runtime-references,misc-misplaced-const,misc-new-delete-overloads,misc-non-copyable-objects,misc-static-assert,misc-throw-by-value-catch-by-reference,misc-uniqueptr-reset-release,modernize-loop-convert,modernize-pass-by-value,modernize-raw-string-literal,modernize-use-auto,modernize-use-bool-literals,modernize-use-equals-default,modernize-use-equals-delete,modernize-use-noexcept,modernize-use-nullptr,performance-faster-string-find,performance-inefficient-algorithm,performance-move-const-arg,performance-type-promotion-in-math-fn,performance-unnecessary-copy-initialization,performance-unnecessary-value-param,readability-container-size-empty,readability-named-parameter,readability-non-const-parameter,readability-string-compare' -HeaderFilterRegex: '.*' +WarningsAsErrors: '' +HeaderFilterRegex: '' +AnalyzeTemporaryDtors: false FormatStyle: 'file' +CheckOptions: + - key: google-build-namespaces.HeaderFileExtensions + value: ',h' + - key: google-readability-braces-around-statements.ShortStatementLines + value: '1' + - key: google-readability-function-size.StatementThreshold + value: '800' + - key: google-readability-namespace-comments.ShortNamespaceLines + value: '10' + - key: google-readability-namespace-comments.SpacesBeforeComments + value: '2' + - key: google-runtime-int.SignedTypePrefix + value: int + - key: google-runtime-int.TypeSuffix + value: '_t' + - key: google-runtime-int.UnsignedTypePrefix + value: uint + - key: google-runtime-references.WhiteListTypes + value: '' + - key: misc-throw-by-value-catch-by-reference.CheckThrowTemporaries + value: '1' + - key: modernize-loop-convert.MaxCopySize + value: '16' + - key: modernize-loop-convert.MinConfidence + value: reasonable + - key: modernize-loop-convert.NamingStyle + value: CamelCase + - key: modernize-pass-by-value.IncludeStyle + value: llvm + - key: modernize-pass-by-value.ValuesOnly + value: '0' + - key: modernize-raw-string-literal.ReplaceShorterLiterals + value: '0' + - key: modernize-replace-auto-ptr.IncludeStyle + value: llvm + - key: modernize-use-auto.MinTypeNameLength + value: '5' + - key: modernize-use-auto.RemoveStars + value: '0' + - key: modernize-use-equals-default.IgnoreMacros + value: '1' + - key: modernize-use-noexcept.ReplacementString + value: '' + - key: modernize-use-noexcept.UseNoexceptFalse + value: '1' + - key: modernize-use-nullptr.NullMacros + value: 'NULL' + - key: performance-faster-string-find.StringLikeClasses + value: 'std::basic_string' + - key: performance-move-const-arg.CheckTriviallyCopyableMove + value: '1' + - key: performance-type-promotion-in-math-fn.IncludeStyle + value: llvm + - key: performance-unnecessary-value-param.IncludeStyle + value: llvm +... diff --git a/src/algorithms/PVT/adapters/rtklib_pvt.cc b/src/algorithms/PVT/adapters/rtklib_pvt.cc index 560ff1ca8..33e6e5acc 100644 --- a/src/algorithms/PVT/adapters/rtklib_pvt.cc +++ b/src/algorithms/PVT/adapters/rtklib_pvt.cc @@ -190,58 +190,174 @@ RtklibPvt::RtklibPvt(ConfigurationInterface* configuration, int glo_2G_count = configuration->property("Channels_2G.count", 0); int bds_B1_count = configuration->property("Channels_B1.count", 0); - if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 1; // L1 - if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 2; - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count != 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 3; // L5 - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 4; // E1 - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count != 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 5; // E5a - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count != 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 6; - - if ((gps_1C_count != 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 7; - if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count != 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 8; // L1+L5 - if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 9; // L1+E1 - if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count != 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 10; - if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count != 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 11; - if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 12; - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count != 0) && (gal_1B_count == 0) && (gal_E5a_count != 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 13; // L5+E5a - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count != 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 14; - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count != 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 15; + if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 1; // L1 + } + if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 2; + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count != 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 3; // L5 + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 4; // E1 + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count != 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 5; // E5a + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count != 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 6; + } + if ((gps_1C_count != 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 7; + } + if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count != 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 8; // L1+L5 + } + if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 9; // L1+E1 + } + if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count != 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 10; + } + if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count != 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 11; + } + if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 12; + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count != 0) && (gal_1B_count == 0) && (gal_E5a_count != 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 13; // L5+E5a + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count != 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 14; + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count != 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 15; + } //if( (gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0)) pvt_output_parameters.type_of_receiver = 16; - if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count != 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 17; - if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count != 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 18; + if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count != 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 17; + } + if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count != 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 18; + } //if( (gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0)) pvt_output_parameters.type_of_receiver = 19; //if( (gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0)) pvt_output_parameters.type_of_receiver = 20; - if ((gps_1C_count != 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 21; + if ((gps_1C_count != 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 21; + } //if( (gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count = 0)) pvt_output_parameters.type_of_receiver = 22; - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 23; - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count != 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 24; - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count != 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 25; - if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 26; - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 27; - if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 28; - if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count != 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 29; - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count != 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 30; - if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count != 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 31; + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 23; + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count != 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 24; + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count != 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 25; + } + if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 26; + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 27; + } + if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 28; + } + if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count != 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 29; + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count != 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 30; + } + if ((gps_1C_count == 0) && (gps_2S_count != 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count != 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 31; + } - if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count != 0) && (gal_1B_count != 0) && (gal_E5a_count != 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) pvt_output_parameters.type_of_receiver = 32; // L1+E1+L5+E5a + if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count != 0) && (gal_1B_count != 0) && (gal_E5a_count != 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count == 0)) + { + pvt_output_parameters.type_of_receiver = 32; // L1+E1+L5+E5a + } // BeiDou B1I Receiver - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count != 0)) pvt_output_parameters.type_of_receiver = 50; - if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count != 0)) pvt_output_parameters.type_of_receiver = 51; - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count != 0)) pvt_output_parameters.type_of_receiver = 52; - if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count == 0) && (bds_B1_count != 0)) pvt_output_parameters.type_of_receiver = 53; - if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count != 0)) pvt_output_parameters.type_of_receiver = 54; - if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count == 0) && (bds_B1_count != 0)) pvt_output_parameters.type_of_receiver = 55; + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count != 0)) + { + pvt_output_parameters.type_of_receiver = 50; + } + if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count != 0)) + { + pvt_output_parameters.type_of_receiver = 51; + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count != 0)) + { + pvt_output_parameters.type_of_receiver = 52; + } + if ((gps_1C_count == 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count == 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count == 0) && (bds_B1_count != 0)) + { + pvt_output_parameters.type_of_receiver = 53; + } + if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count == 0) && (glo_2G_count == 0) && (bds_B1_count != 0)) + { + pvt_output_parameters.type_of_receiver = 54; + } + if ((gps_1C_count != 0) && (gps_2S_count == 0) && (gps_L5_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0) && (glo_1G_count != 0) && (glo_2G_count == 0) && (bds_B1_count != 0)) + { + pvt_output_parameters.type_of_receiver = 55; + } // RTKLIB PVT solver options // Settings 1 int positioning_mode = -1; std::string default_pos_mode("Single"); std::string positioning_mode_str = configuration->property(role + ".positioning_mode", default_pos_mode); // (PMODE_XXX) see src/algorithms/libs/rtklib/rtklib.h - if (positioning_mode_str == "Single") positioning_mode = PMODE_SINGLE; - if (positioning_mode_str == "Static") positioning_mode = PMODE_STATIC; - if (positioning_mode_str == "Kinematic") positioning_mode = PMODE_KINEMA; - if (positioning_mode_str == "PPP_Static") positioning_mode = PMODE_PPP_STATIC; - if (positioning_mode_str == "PPP_Kinematic") positioning_mode = PMODE_PPP_KINEMA; + if (positioning_mode_str == "Single") + { + positioning_mode = PMODE_SINGLE; + } + if (positioning_mode_str == "Static") + { + positioning_mode = PMODE_STATIC; + } + if (positioning_mode_str == "Kinematic") + { + positioning_mode = PMODE_KINEMA; + } + if (positioning_mode_str == "PPP_Static") + { + positioning_mode = PMODE_PPP_STATIC; + } + if (positioning_mode_str == "PPP_Kinematic") + { + positioning_mode = PMODE_PPP_KINEMA; + } if (positioning_mode == -1) { @@ -255,10 +371,22 @@ RtklibPvt::RtklibPvt(ConfigurationInterface* configuration, int num_bands = 0; - if ((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0) || (bds_B1_count > 0)) num_bands = 1; - if (((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0)) && ((gps_2S_count > 0) || (glo_2G_count > 0))) num_bands = 2; - if (((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0)) && ((gal_E5a_count > 0) || (gal_E5b_count > 0) || (gps_L5_count > 0))) num_bands = 2; - if (((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0)) && ((gps_2S_count > 0) || (glo_2G_count > 0)) && ((gal_E5a_count > 0) || (gal_E5b_count > 0) || (gps_L5_count > 0))) num_bands = 3; + if ((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0) || (bds_B1_count > 0)) + { + num_bands = 1; + } + if (((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0)) && ((gps_2S_count > 0) || (glo_2G_count > 0))) + { + num_bands = 2; + } + if (((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0)) && ((gal_E5a_count > 0) || (gal_E5b_count > 0) || (gps_L5_count > 0))) + { + num_bands = 2; + } + if (((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0)) && ((gps_2S_count > 0) || (glo_2G_count > 0)) && ((gal_E5a_count > 0) || (gal_E5b_count > 0) || (gps_L5_count > 0))) + { + num_bands = 3; + } int number_of_frequencies = configuration->property(role + ".num_bands", num_bands); /* (1:L1, 2:L1+L2, 3:L1+L2+L5) */ if ((number_of_frequencies < 1) || (number_of_frequencies > 3)) @@ -286,12 +414,30 @@ RtklibPvt::RtklibPvt(ConfigurationInterface* configuration, std::string default_iono_model("OFF"); std::string iono_model_str = configuration->property(role + ".iono_model", default_iono_model); /* (IONOOPT_XXX) see src/algorithms/libs/rtklib/rtklib.h */ int iono_model = -1; - if (iono_model_str == "OFF") iono_model = IONOOPT_OFF; - if (iono_model_str == "Broadcast") iono_model = IONOOPT_BRDC; - if (iono_model_str == "SBAS") iono_model = IONOOPT_SBAS; - if (iono_model_str == "Iono-Free-LC") iono_model = IONOOPT_IFLC; - if (iono_model_str == "Estimate_STEC") iono_model = IONOOPT_EST; - if (iono_model_str == "IONEX") iono_model = IONOOPT_TEC; + if (iono_model_str == "OFF") + { + iono_model = IONOOPT_OFF; + } + if (iono_model_str == "Broadcast") + { + iono_model = IONOOPT_BRDC; + } + if (iono_model_str == "SBAS") + { + iono_model = IONOOPT_SBAS; + } + if (iono_model_str == "Iono-Free-LC") + { + iono_model = IONOOPT_IFLC; + } + if (iono_model_str == "Estimate_STEC") + { + iono_model = IONOOPT_EST; + } + if (iono_model_str == "IONEX") + { + iono_model = IONOOPT_TEC; + } if (iono_model == -1) { //warn user and set the default @@ -305,11 +451,26 @@ RtklibPvt::RtklibPvt(ConfigurationInterface* configuration, std::string default_trop_model("OFF"); int trop_model = -1; std::string trop_model_str = configuration->property(role + ".trop_model", default_trop_model); /* (TROPOPT_XXX) see src/algorithms/libs/rtklib/rtklib.h */ - if (trop_model_str == "OFF") trop_model = TROPOPT_OFF; - if (trop_model_str == "Saastamoinen") trop_model = TROPOPT_SAAS; - if (trop_model_str == "SBAS") trop_model = TROPOPT_SBAS; - if (trop_model_str == "Estimate_ZTD") trop_model = TROPOPT_EST; - if (trop_model_str == "Estimate_ZTD_Grad") trop_model = TROPOPT_ESTG; + if (trop_model_str == "OFF") + { + trop_model = TROPOPT_OFF; + } + if (trop_model_str == "Saastamoinen") + { + trop_model = TROPOPT_SAAS; + } + if (trop_model_str == "SBAS") + { + trop_model = TROPOPT_SBAS; + } + if (trop_model_str == "Estimate_ZTD") + { + trop_model = TROPOPT_EST; + } + if (trop_model_str == "Estimate_ZTD_Grad") + { + trop_model = TROPOPT_ESTG; + } if (trop_model == -1) { //warn user and set the default @@ -339,10 +500,22 @@ RtklibPvt::RtklibPvt(ConfigurationInterface* configuration, int earth_tide = configuration->property(role + ".earth_tide", 0); int nsys = 0; - if ((gps_1C_count > 0) || (gps_2S_count > 0) || (gps_L5_count > 0)) nsys += SYS_GPS; - if ((gal_1B_count > 0) || (gal_E5a_count > 0) || (gal_E5b_count > 0)) nsys += SYS_GAL; - if ((glo_1G_count > 0) || (glo_2G_count > 0)) nsys += SYS_GLO; - if ((bds_B1_count > 0)) nsys += SYS_BDS; + if ((gps_1C_count > 0) || (gps_2S_count > 0) || (gps_L5_count > 0)) + { + nsys += SYS_GPS; + } + if ((gal_1B_count > 0) || (gal_E5a_count > 0) || (gal_E5b_count > 0)) + { + nsys += SYS_GAL; + } + if ((glo_1G_count > 0) || (glo_2G_count > 0)) + { + nsys += SYS_GLO; + } + if ((bds_B1_count > 0)) + { + nsys += SYS_BDS; + } int navigation_system = configuration->property(role + ".navigation_system", nsys); /* (SYS_XXX) see src/algorithms/libs/rtklib/rtklib.h */ if ((navigation_system < 1) || (navigation_system > 255)) /* GPS: 1 SBAS: 2 GPS+SBAS: 3 Galileo: 8 Galileo+GPS: 9 GPS+SBAS+Galileo: 11 All: 255 */ @@ -356,11 +529,26 @@ RtklibPvt::RtklibPvt(ConfigurationInterface* configuration, std::string default_gps_ar("Continuous"); std::string integer_ambiguity_resolution_gps_str = configuration->property(role + ".AR_GPS", default_gps_ar); /* Integer Ambiguity Resolution mode for GPS (0:off,1:continuous,2:instantaneous,3:fix and hold,4:ppp-ar) */ int integer_ambiguity_resolution_gps = -1; - if (integer_ambiguity_resolution_gps_str == "OFF") integer_ambiguity_resolution_gps = ARMODE_OFF; - if (integer_ambiguity_resolution_gps_str == "Continuous") integer_ambiguity_resolution_gps = ARMODE_CONT; - if (integer_ambiguity_resolution_gps_str == "Instantaneous") integer_ambiguity_resolution_gps = ARMODE_INST; - if (integer_ambiguity_resolution_gps_str == "Fix-and-Hold") integer_ambiguity_resolution_gps = ARMODE_FIXHOLD; - if (integer_ambiguity_resolution_gps_str == "PPP-AR") integer_ambiguity_resolution_gps = ARMODE_PPPAR; + if (integer_ambiguity_resolution_gps_str == "OFF") + { + integer_ambiguity_resolution_gps = ARMODE_OFF; + } + if (integer_ambiguity_resolution_gps_str == "Continuous") + { + integer_ambiguity_resolution_gps = ARMODE_CONT; + } + if (integer_ambiguity_resolution_gps_str == "Instantaneous") + { + integer_ambiguity_resolution_gps = ARMODE_INST; + } + if (integer_ambiguity_resolution_gps_str == "Fix-and-Hold") + { + integer_ambiguity_resolution_gps = ARMODE_FIXHOLD; + } + if (integer_ambiguity_resolution_gps_str == "PPP-AR") + { + integer_ambiguity_resolution_gps = ARMODE_PPPAR; + } if (integer_ambiguity_resolution_gps == -1) { //warn user and set the default diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc index 2e0bec8d5..151c667c8 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc @@ -176,9 +176,18 @@ void rtklib_pvt_cc::msg_handler_telemetry(const pmt::pmt_t& msg) Galileo_Almanac sv2 = galileo_almanac_helper->get_almanac(2); Galileo_Almanac sv3 = galileo_almanac_helper->get_almanac(3); - if (sv1.i_satellite_PRN != 0) d_pvt_solver->galileo_almanac_map[sv1.i_satellite_PRN] = sv1; - if (sv2.i_satellite_PRN != 0) d_pvt_solver->galileo_almanac_map[sv2.i_satellite_PRN] = sv2; - if (sv3.i_satellite_PRN != 0) d_pvt_solver->galileo_almanac_map[sv3.i_satellite_PRN] = sv3; + if (sv1.i_satellite_PRN != 0) + { + d_pvt_solver->galileo_almanac_map[sv1.i_satellite_PRN] = sv1; + } + if (sv2.i_satellite_PRN != 0) + { + d_pvt_solver->galileo_almanac_map[sv2.i_satellite_PRN] = sv2; + } + if (sv3.i_satellite_PRN != 0) + { + d_pvt_solver->galileo_almanac_map[sv3.i_satellite_PRN] = sv3; + } DLOG(INFO) << "New Galileo Almanac data have arrived "; } else if (pmt::any_ref(msg).type() == typeid(std::shared_ptr)) @@ -605,7 +614,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() xml << boost::serialization::make_nvp("GNSS-SDR_cnav_ephemeris_map", d_pvt_solver->gps_cnav_ephemeris_map); LOG(INFO) << "Saved GPS L2CM or L5 Ephemeris map data"; } - catch (const boost::archive::archive_exception e) + catch (const boost::archive::archive_exception& e) { LOG(WARNING) << e.what(); } @@ -631,7 +640,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() xml << boost::serialization::make_nvp("GNSS-SDR_ephemeris_map", d_pvt_solver->gps_ephemeris_map); LOG(INFO) << "Saved GPS L1 CA Ephemeris map data"; } - catch (const boost::archive::archive_exception e) + catch (const boost::archive::archive_exception& e) { LOG(WARNING) << e.what(); } @@ -657,7 +666,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() xml << boost::serialization::make_nvp("GNSS-SDR_gal_ephemeris_map", d_pvt_solver->galileo_ephemeris_map); LOG(INFO) << "Saved Galileo E1 Ephemeris map data"; } - catch (const boost::archive::archive_exception e) + catch (const boost::archive::archive_exception& e) { LOG(WARNING) << e.what(); } @@ -687,7 +696,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() xml << boost::serialization::make_nvp("GNSS-SDR_gnav_ephemeris_map", d_pvt_solver->glonass_gnav_ephemeris_map); LOG(INFO) << "Saved GLONASS GNAV Ephemeris map data"; } - catch (const boost::archive::archive_exception e) + catch (const boost::archive::archive_exception& e) { LOG(WARNING) << e.what(); } @@ -721,7 +730,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() { LOG(WARNING) << "Problem opening output XML file"; } - catch (const boost::archive::archive_exception e) + catch (const boost::archive::archive_exception& e) { LOG(WARNING) << e.what(); } @@ -747,7 +756,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() xml << boost::serialization::make_nvp("GNSS-SDR_gal_utc_model", d_pvt_solver->galileo_utc_model); LOG(INFO) << "Saved Galileo UTC model parameters"; } - catch (const boost::archive::archive_exception e) + catch (const boost::archive::archive_exception& e) { LOG(WARNING) << e.what(); } @@ -777,7 +786,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() xml << boost::serialization::make_nvp("GNSS-SDR_iono_model", d_pvt_solver->gps_iono); LOG(INFO) << "Saved GPS ionospheric model parameters"; } - catch (const boost::archive::archive_exception e) + catch (const boost::archive::archive_exception& e) { LOG(WARNING) << e.what(); } @@ -807,7 +816,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() xml << boost::serialization::make_nvp("GNSS-SDR_cnav_iono_model", d_pvt_solver->gps_cnav_iono); LOG(INFO) << "Saved GPS CNAV ionospheric model parameters"; } - catch (const boost::archive::archive_exception e) + catch (const boost::archive::archive_exception& e) { LOG(WARNING) << e.what(); } @@ -837,7 +846,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() xml << boost::serialization::make_nvp("GNSS-SDR_gal_iono_model", d_pvt_solver->galileo_iono); LOG(INFO) << "Saved Galileo ionospheric model parameters"; } - catch (const boost::archive::archive_exception e) + catch (const boost::archive::archive_exception& e) { LOG(WARNING) << e.what(); } @@ -867,7 +876,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() xml << boost::serialization::make_nvp("GNSS-SDR_gps_almanac_map", d_pvt_solver->gps_almanac_map); LOG(INFO) << "Saved GPS almanac map data"; } - catch (const boost::archive::archive_exception e) + catch (const boost::archive::archive_exception& e) { LOG(WARNING) << e.what(); } @@ -897,7 +906,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() xml << boost::serialization::make_nvp("GNSS-SDR_gal_almanac_map", d_pvt_solver->galileo_almanac_map); LOG(INFO) << "Saved Galileo almanac data"; } - catch (const boost::archive::archive_exception e) + catch (const boost::archive::archive_exception& e) { LOG(WARNING) << e.what(); } @@ -927,7 +936,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() xml << boost::serialization::make_nvp("GNSS-SDR_cnav_utc_model", d_pvt_solver->gps_cnav_utc_model); LOG(INFO) << "Saved GPS CNAV UTC model parameters"; } - catch (const boost::archive::archive_exception e) + catch (const boost::archive::archive_exception& e) { LOG(WARNING) << e.what(); } @@ -957,7 +966,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() xml << boost::serialization::make_nvp("GNSS-SDR_gnav_ephemeris_map", d_pvt_solver->glonass_gnav_ephemeris_map); LOG(INFO) << "Saved GLONASS GNAV ephemeris map data"; } - catch (const boost::archive::archive_exception e) + catch (const boost::archive::archive_exception& e) { LOG(WARNING) << e.what(); } @@ -987,7 +996,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() xml << boost::serialization::make_nvp("GNSS-SDR_gnav_utc_model", d_pvt_solver->glonass_gnav_utc_model); LOG(INFO) << "Saved GLONASS UTC model parameters"; } - catch (const boost::archive::archive_exception e) + catch (const boost::archive::archive_exception& e) { LOG(WARNING) << e.what(); } @@ -1017,7 +1026,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() xml << boost::serialization::make_nvp("GNSS-SDR_bds_dnav_ephemeris_map", d_pvt_solver->beidou_dnav_ephemeris_map); LOG(INFO) << "Saved BeiDou DNAV Ephemeris map data"; } - catch (const boost::archive::archive_exception e) + catch (const boost::archive::archive_exception& e) { LOG(WARNING) << e.what(); } @@ -1047,7 +1056,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() xml << boost::serialization::make_nvp("GNSS-SDR_bds_dnav_iono_model", d_pvt_solver->beidou_dnav_iono); LOG(INFO) << "Saved BeiDou DNAV ionospheric model parameters"; } - catch (const boost::archive::archive_exception e) + catch (const boost::archive::archive_exception& e) { LOG(WARNING) << e.what(); } @@ -1077,7 +1086,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() xml << boost::serialization::make_nvp("GNSS-SDR_bds_dnav_almanac_map", d_pvt_solver->beidou_dnav_almanac_map); LOG(INFO) << "Saved BeiDou DNAV almanac map data"; } - catch (const boost::archive::archive_exception e) + catch (const boost::archive::archive_exception& e) { LOG(WARNING) << e.what(); } @@ -1107,7 +1116,7 @@ rtklib_pvt_cc::~rtklib_pvt_cc() xml << boost::serialization::make_nvp("GNSS-SDR_bds_dnav_utc_model", d_pvt_solver->beidou_dnav_utc_model); LOG(INFO) << "Saved BeiDou DNAV UTC model parameters"; } - catch (const boost::archive::archive_exception e) + catch (const boost::archive::archive_exception& e) { LOG(WARNING) << e.what(); } @@ -1421,10 +1430,22 @@ int rtklib_pvt_cc::work(int noutput_items, gr_vector_const_void_star& input_item send_sys_v_ttff_msg(ttff); first_fix = false; } - if (d_kml_output_enabled) d_kml_dump->print_position(d_pvt_solver, false); - if (d_gpx_output_enabled) d_gpx_dump->print_position(d_pvt_solver, false); - if (d_geojson_output_enabled) d_geojson_printer->print_position(d_pvt_solver, false); - if (d_nmea_output_file_enabled) d_nmea_printer->Print_Nmea_Line(d_pvt_solver, false); + if (d_kml_output_enabled) + { + d_kml_dump->print_position(d_pvt_solver, false); + } + if (d_gpx_output_enabled) + { + d_gpx_dump->print_position(d_pvt_solver, false); + } + if (d_geojson_output_enabled) + { + d_geojson_printer->print_position(d_pvt_solver, false); + } + if (d_nmea_output_file_enabled) + { + d_nmea_printer->Print_Nmea_Line(d_pvt_solver, false); + } /* * TYPE | RECEIVER @@ -1638,7 +1659,9 @@ int rtklib_pvt_cc::work(int noutput_items, gr_vector_const_void_star& input_item std::string glo_signal("1G"); rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal); if (d_rinex_version == 3) - rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + { + rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + } if (d_rinex_version == 2) { rp->rinex_nav_header(rp->navFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model); @@ -1672,7 +1695,9 @@ int rtklib_pvt_cc::work(int noutput_items, gr_vector_const_void_star& input_item std::string glo_signal("2G"); rp->rinex_obs_header(rp->obsFile, gps_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal); if (d_rinex_version == 3) - rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + { + rp->rinex_nav_header(rp->navMixFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model, d_pvt_solver->glonass_gnav_utc_model, d_pvt_solver->glonass_gnav_almanac); + } if (d_rinex_version == 2) { rp->rinex_nav_header(rp->navFile, d_pvt_solver->gps_iono, d_pvt_solver->gps_utc_model); @@ -1780,7 +1805,9 @@ int rtklib_pvt_cc::work(int noutput_items, gr_vector_const_void_star& input_item break; case 26: // GPS L1 C/A + GLONASS L1 C/A if (d_rinex_version == 3) - rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->gps_ephemeris_map, d_pvt_solver->glonass_gnav_ephemeris_map); + { + rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->gps_ephemeris_map, d_pvt_solver->glonass_gnav_ephemeris_map); + } if (d_rinex_version == 2) { rp->log_rinex_nav(rp->navFile, d_pvt_solver->gps_ephemeris_map); @@ -1795,7 +1822,9 @@ int rtklib_pvt_cc::work(int noutput_items, gr_vector_const_void_star& input_item break; case 29: // GPS L1 C/A + GLONASS L2 C/A if (d_rinex_version == 3) - rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->gps_ephemeris_map, d_pvt_solver->glonass_gnav_ephemeris_map); + { + rp->log_rinex_nav(rp->navMixFile, d_pvt_solver->gps_ephemeris_map, d_pvt_solver->glonass_gnav_ephemeris_map); + } if (d_rinex_version == 2) { rp->log_rinex_nav(rp->navFile, d_pvt_solver->gps_ephemeris_map); diff --git a/src/algorithms/PVT/libs/geojson_printer.cc b/src/algorithms/PVT/libs/geojson_printer.cc index 22da08606..504393422 100644 --- a/src/algorithms/PVT/libs/geojson_printer.cc +++ b/src/algorithms/PVT/libs/geojson_printer.cc @@ -221,7 +221,10 @@ bool GeoJSON_Printer::close_file() // if nothing is written, erase the file if (first_pos == true) { - if (remove(filename_.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(filename_.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } return true; } diff --git a/src/algorithms/PVT/libs/gpx_printer.cc b/src/algorithms/PVT/libs/gpx_printer.cc index 8075b21fa..1e2fddf01 100644 --- a/src/algorithms/PVT/libs/gpx_printer.cc +++ b/src/algorithms/PVT/libs/gpx_printer.cc @@ -171,7 +171,10 @@ bool Gpx_Printer::print_position(const std::shared_ptr& position, double vdop = position_->get_vdop(); double pdop = position_->get_pdop(); std::string utc_time = to_iso_extended_string(position_->get_position_UTC_time()); - if (utc_time.length() < 23) utc_time += "."; + if (utc_time.length() < 23) + { + utc_time += "."; + } utc_time.resize(23, '0'); // time up to ms utc_time.append("Z"); // UTC time zone @@ -229,6 +232,9 @@ Gpx_Printer::~Gpx_Printer() } if (!positions_printed) { - if (remove(gpx_filename.c_str()) != 0) LOG(INFO) << "Error deleting temporary GPX file"; + if (remove(gpx_filename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary GPX file"; + } } } diff --git a/src/algorithms/PVT/libs/kml_printer.cc b/src/algorithms/PVT/libs/kml_printer.cc index 627e26416..f7f48aae3 100644 --- a/src/algorithms/PVT/libs/kml_printer.cc +++ b/src/algorithms/PVT/libs/kml_printer.cc @@ -229,7 +229,10 @@ bool Kml_Printer::print_position(const std::shared_ptr& position, double vdop = position_->get_vdop(); double pdop = position_->get_pdop(); std::string utc_time = to_iso_extended_string(position_->get_position_UTC_time()); - if (utc_time.length() < 23) utc_time += "."; + if (utc_time.length() < 23) + { + utc_time += "."; + } utc_time.resize(23, '0'); // time up to ms utc_time.append("Z"); // UTC time zone @@ -330,6 +333,9 @@ Kml_Printer::~Kml_Printer() } if (!positions_printed) { - if (remove(kml_filename.c_str()) != 0) LOG(INFO) << "Error deleting temporary KML file"; + if (remove(kml_filename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary KML file"; + } } } diff --git a/src/algorithms/PVT/libs/ls_pvt.cc b/src/algorithms/PVT/libs/ls_pvt.cc index 9077dcd68..3ca239972 100644 --- a/src/algorithms/PVT/libs/ls_pvt.cc +++ b/src/algorithms/PVT/libs/ls_pvt.cc @@ -253,7 +253,10 @@ arma::vec Ls_Pvt::leastSquarePos(const arma::mat& satpos, const arma::vec& obs, { //--- Find delay due to troposphere (in meters) Ls_Pvt::tropo(&trop, sin(*elev * GPS_PI / 180.0), h / 1000.0, 1013.0, 293.0, 50.0, 0.0, 0.0, 0.0); - if (trop > 5.0) trop = 0.0; //check for erratic values + if (trop > 5.0) + { + trop = 0.0; //check for erratic values + } } } } diff --git a/src/algorithms/PVT/libs/monitor_pvt_udp_sink.cc b/src/algorithms/PVT/libs/monitor_pvt_udp_sink.cc index d46259cc8..3dc8c8b08 100644 --- a/src/algorithms/PVT/libs/monitor_pvt_udp_sink.cc +++ b/src/algorithms/PVT/libs/monitor_pvt_udp_sink.cc @@ -36,7 +36,7 @@ Monitor_Pvt_Udp_Sink::Monitor_Pvt_Udp_Sink(std::vector addresses, const uint16_t& port) : socket{io_service} { - for (auto address : addresses) + for (const auto& address : addresses) { boost::asio::ip::udp::endpoint endpoint(boost::asio::ip::address::from_string(address, error), port); endpoints.push_back(endpoint); @@ -50,7 +50,7 @@ bool Monitor_Pvt_Udp_Sink::write_monitor_pvt(Monitor_Pvt monitor_pvt) oa << monitor_pvt; std::string outbound_data = archive_stream.str(); - for (auto endpoint : endpoints) + for (const auto& endpoint : endpoints) { socket.open(endpoint.protocol(), error); socket.connect(endpoint, error); diff --git a/src/algorithms/PVT/libs/nmea_printer.cc b/src/algorithms/PVT/libs/nmea_printer.cc index 39b374bc7..3d4ebc74a 100644 --- a/src/algorithms/PVT/libs/nmea_printer.cc +++ b/src/algorithms/PVT/libs/nmea_printer.cc @@ -161,10 +161,16 @@ int Nmea_Printer::init_serial(const std::string& serial_device) int64_t PARITY; fd = open(serial_device.c_str(), O_RDWR | O_NOCTTY | O_NDELAY | O_CLOEXEC); - if (fd == -1) return fd; // failed to open TTY port + if (fd == -1) + { + return fd; // failed to open TTY port + } - if (fcntl(fd, F_SETFL, 0) == -1) LOG(INFO) << "Error enabling direct I/O"; // clear all flags on descriptor, enable direct I/O - tcgetattr(fd, &options); // read serial port options + if (fcntl(fd, F_SETFL, 0) == -1) + { + LOG(INFO) << "Error enabling direct I/O"; // clear all flags on descriptor, enable direct I/O + } + tcgetattr(fd, &options); // read serial port options BAUD = B9600; // BAUD = B38400; @@ -367,13 +373,22 @@ std::string Nmea_Printer::get_UTC_NMEA_time(boost::posix_time::ptime d_position_ utc_seconds = td.seconds(); utc_milliseconds = td.total_milliseconds() - td.total_seconds() * 1000; - if (utc_hours < 10) sentence_str << "0"; // two digits for hours + if (utc_hours < 10) + { + sentence_str << "0"; // two digits for hours + } sentence_str << utc_hours; - if (utc_mins < 10) sentence_str << "0"; // two digits for minutes + if (utc_mins < 10) + { + sentence_str << "0"; // two digits for minutes + } sentence_str << utc_mins; - if (utc_seconds < 10) sentence_str << "0"; // two digits for seconds + if (utc_seconds < 10) + { + sentence_str << "0"; // two digits for seconds + } sentence_str << utc_seconds; if (utc_milliseconds < 10) diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index dfa3aaa08..415cae4a7 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -230,31 +230,52 @@ Rinex_Printer::~Rinex_Printer() // If nothing written, erase the files. if (posn == 0) { - if (remove(navfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(navfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } if (poso == 0) { - if (remove(obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(obsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } if (poss == 0) { - if (remove(sbsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(sbsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } if (posng == 0) { - if (remove(navGalfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(navGalfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } if (posmn == 0) { - if (remove(navMixfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(navMixfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } if (posnr == 0) { - if (remove(navGlofilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(navGlofilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } if (posnc == 0) { - if (remove(navBdsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(navBdsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } } @@ -277,8 +298,14 @@ std::string Rinex_Printer::createFilename(const std::string& type) boost::gregorian::date today = boost::gregorian::day_clock::local_day(); const int32_t dayOfTheYear = today.day_of_year(); std::stringstream strm0; - if (dayOfTheYear < 100) strm0 << "0"; // three digits for day of the year - if (dayOfTheYear < 10) strm0 << "0"; // three digits for day of the year + if (dayOfTheYear < 100) + { + strm0 << "0"; // three digits for day of the year + } + if (dayOfTheYear < 10) + { + strm0 << "0"; // three digits for day of the year + } strm0 << dayOfTheYear; std::string dayOfTheYearTag = strm0.str(); @@ -332,7 +359,10 @@ std::string Rinex_Printer::createFilename(const std::string& type) int32_t local_minute = pt_tm.tm_min; std::stringstream strm2; - if (local_minute < 10) strm2 << "0"; // at least two digits for minutes + if (local_minute < 10) + { + strm2 << "0"; // at least two digits for minutes + } strm2 << local_minute; std::string minTag = strm2.str(); @@ -374,12 +404,18 @@ std::string Rinex_Printer::getLocalTime() std::stringstream strmHour; int32_t utc_hour = pt_tm.tm_hour; - if (utc_hour < 10) strmHour << "0"; // two digits for hours + if (utc_hour < 10) + { + strmHour << "0"; // two digits for hours + } strmHour << utc_hour; std::stringstream strmMin; int32_t utc_minute = pt_tm.tm_min; - if (utc_minute < 10) strmMin << "0"; // two digits for minutes + if (utc_minute < 10) + { + strmMin << "0"; // two digits for minutes + } strmMin << utc_minute; if (version == 2) @@ -421,7 +457,10 @@ std::string Rinex_Printer::getLocalTime() std::stringstream strm2; int32_t utc_seconds = pt_tm.tm_sec; - if (utc_seconds < 10) strm2 << "0"; // two digits for seconds + if (utc_seconds < 10) + { + strm2 << "0"; // two digits for seconds + } strm2 << utc_seconds; line += strm2.str(); line += std::string(1, ' '); @@ -1716,19 +1755,31 @@ void Rinex_Printer::rinex_sbs_header(std::fstream& out) strYear << utc_year; std::stringstream strMonth; int32_t utc_month = pt.date().month().as_number(); - if (utc_month < 10) strMonth << "0"; // two digits for months + if (utc_month < 10) + { + strMonth << "0"; // two digits for months + } strMonth << utc_month; std::stringstream strmDay; int32_t utc_day = pt.date().day().as_number(); - if (utc_day < 10) strmDay << "0"; // two digits for days + if (utc_day < 10) + { + strmDay << "0"; // two digits for days + } strmDay << utc_day; std::stringstream strmHour; int32_t utc_hour = pt_tm.tm_hour; - if (utc_hour < 10) strmHour << "0"; // two digits for hours + if (utc_hour < 10) + { + strmHour << "0"; // two digits for hours + } strmHour << utc_hour; std::stringstream strmMin; int32_t utc_minute = pt_tm.tm_min; - if (utc_minute < 10) strmMin << "0"; // two digits for minutes + if (utc_minute < 10) + { + strmMin << "0"; // two digits for minutes + } strmMin << utc_minute; std::string time_str; time_str += strmDay.str(); @@ -2959,7 +3010,10 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.i_satellite_PRN < 10) line += std::string("0"); + if (gps_ephemeris_iter->second.i_satellite_PRN < 10) + { + line += std::string("0"); + } line += std::to_string(gps_ephemeris_iter->second.i_satellite_PRN); std::string year(timestring, 0, 4); line += std::string(1, ' '); @@ -3156,12 +3210,30 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.satelliteBlock.at(gps_ephemeris_iter->second.i_satellite_PRN) == "IIA") { // Block II/IIA (Table 20-XI IS-GPS-200E ) - if ((gps_ephemeris_iter->second.d_IODC > 239) && (gps_ephemeris_iter->second.d_IODC < 248)) curve_fit_interval = 8; - if (((gps_ephemeris_iter->second.d_IODC > 247) && (gps_ephemeris_iter->second.d_IODC < 256)) || (gps_ephemeris_iter->second.d_IODC == 496)) curve_fit_interval = 14; - if ((gps_ephemeris_iter->second.d_IODC > 496) && (gps_ephemeris_iter->second.d_IODC < 504)) curve_fit_interval = 26; - if ((gps_ephemeris_iter->second.d_IODC > 503) && (gps_ephemeris_iter->second.d_IODC < 511)) curve_fit_interval = 50; - if (((gps_ephemeris_iter->second.d_IODC > 751) && (gps_ephemeris_iter->second.d_IODC < 757)) || (gps_ephemeris_iter->second.d_IODC == 511)) curve_fit_interval = 74; - if (gps_ephemeris_iter->second.d_IODC == 757) curve_fit_interval = 98; + if ((gps_ephemeris_iter->second.d_IODC > 239) && (gps_ephemeris_iter->second.d_IODC < 248)) + { + curve_fit_interval = 8; + } + if (((gps_ephemeris_iter->second.d_IODC > 247) && (gps_ephemeris_iter->second.d_IODC < 256)) || (gps_ephemeris_iter->second.d_IODC == 496)) + { + curve_fit_interval = 14; + } + if ((gps_ephemeris_iter->second.d_IODC > 496) && (gps_ephemeris_iter->second.d_IODC < 504)) + { + curve_fit_interval = 26; + } + if ((gps_ephemeris_iter->second.d_IODC > 503) && (gps_ephemeris_iter->second.d_IODC < 511)) + { + curve_fit_interval = 50; + } + if (((gps_ephemeris_iter->second.d_IODC > 751) && (gps_ephemeris_iter->second.d_IODC < 757)) || (gps_ephemeris_iter->second.d_IODC == 511)) + { + curve_fit_interval = 74; + } + if (gps_ephemeris_iter->second.d_IODC == 757) + { + curve_fit_interval = 98; + } } if ((gps_ephemeris_iter->second.satelliteBlock.at(gps_ephemeris_iter->second.i_satellite_PRN) == "IIR") || @@ -3170,9 +3242,18 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.satelliteBlock.at(gps_ephemeris_iter->second.i_satellite_PRN) == "IIIA")) { // Block IIR/IIR-M/IIF/IIIA (Table 20-XII IS-GPS-200E ) - if ((gps_ephemeris_iter->second.d_IODC > 239) && (gps_ephemeris_iter->second.d_IODC < 248)) curve_fit_interval = 8; - if (((gps_ephemeris_iter->second.d_IODC > 247) && (gps_ephemeris_iter->second.d_IODC < 256)) || (gps_ephemeris_iter->second.d_IODC == 496)) curve_fit_interval = 14; - if (((gps_ephemeris_iter->second.d_IODC > 496) && (gps_ephemeris_iter->second.d_IODC < 504)) || ((gps_ephemeris_iter->second.d_IODC > 1020) && (gps_ephemeris_iter->second.d_IODC < 1024))) curve_fit_interval = 26; + if ((gps_ephemeris_iter->second.d_IODC > 239) && (gps_ephemeris_iter->second.d_IODC < 248)) + { + curve_fit_interval = 8; + } + if (((gps_ephemeris_iter->second.d_IODC > 247) && (gps_ephemeris_iter->second.d_IODC < 256)) || (gps_ephemeris_iter->second.d_IODC == 496)) + { + curve_fit_interval = 14; + } + if (((gps_ephemeris_iter->second.d_IODC > 496) && (gps_ephemeris_iter->second.d_IODC < 504)) || ((gps_ephemeris_iter->second.d_IODC > 1020) && (gps_ephemeris_iter->second.d_IODC < 1024))) + { + curve_fit_interval = 26; + } } line += Rinex_Printer::doub2for(curve_fit_interval, 18, 2); line += std::string(1, ' '); @@ -3208,7 +3289,10 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.i_satellite_PRN < 10) line += std::string("0"); + if (gps_ephemeris_iter->second.i_satellite_PRN < 10) + { + line += std::string("0"); + } line += std::to_string(gps_ephemeris_iter->second.i_satellite_PRN); std::string year(timestring, 0, 4); line += std::string(1, ' '); @@ -3242,7 +3326,10 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.i_satellite_PRN < 10) line += std::string("0"); + if (galileo_ephemeris_iter->second.i_satellite_PRN < 10) + { + line += std::string("0"); + } line += std::to_string(galileo_ephemeris_iter->second.i_satellite_PRN); std::string year(timestring, 0, 4); line += std::string(1, ' '); @@ -3470,22 +3560,58 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.E1B_HS_5 == 0) E1B_HS = "00"; - if (galileo_ephemeris_iter->second.E1B_HS_5 == 1) E1B_HS = "01"; - if (galileo_ephemeris_iter->second.E1B_HS_5 == 2) E1B_HS = "10"; - if (galileo_ephemeris_iter->second.E1B_HS_5 == 3) E1B_HS = "11"; - if (galileo_ephemeris_iter->second.E5b_HS_5 == 0) E5B_HS = "00"; - if (galileo_ephemeris_iter->second.E5b_HS_5 == 1) E5B_HS = "01"; - if (galileo_ephemeris_iter->second.E5b_HS_5 == 2) E5B_HS = "10"; - if (galileo_ephemeris_iter->second.E5b_HS_5 == 3) E5B_HS = "11"; + if (galileo_ephemeris_iter->second.E1B_HS_5 == 0) + { + E1B_HS = "00"; + } + if (galileo_ephemeris_iter->second.E1B_HS_5 == 1) + { + E1B_HS = "01"; + } + if (galileo_ephemeris_iter->second.E1B_HS_5 == 2) + { + E1B_HS = "10"; + } + if (galileo_ephemeris_iter->second.E1B_HS_5 == 3) + { + E1B_HS = "11"; + } + if (galileo_ephemeris_iter->second.E5b_HS_5 == 0) + { + E5B_HS = "00"; + } + if (galileo_ephemeris_iter->second.E5b_HS_5 == 1) + { + E5B_HS = "01"; + } + if (galileo_ephemeris_iter->second.E5b_HS_5 == 2) + { + E5B_HS = "10"; + } + if (galileo_ephemeris_iter->second.E5b_HS_5 == 3) + { + E5B_HS = "11"; + } - if (E1B_HS == "11") LOG(WARNING) << "Signal Component currently in Test"; - if (E1B_HS == "10") LOG(WARNING) << "Signal will be out of service"; - if (E1B_HS == "01") LOG(WARNING) << "Signal out of service"; + if (E1B_HS == "11") + { + LOG(WARNING) << "Signal Component currently in Test"; + } + if (E1B_HS == "10") + { + LOG(WARNING) << "Signal will be out of service"; + } + if (E1B_HS == "01") + { + LOG(WARNING) << "Signal out of service"; + } E1B_HS = "00"; // *************** CHANGE THIS WHEN GALILEO SIGNAL IS VALID std::string E1B_DVS = std::to_string(galileo_ephemeris_iter->second.E1B_DVS_5); - if (E1B_DVS == "1") LOG(WARNING) << "Navigation data without guarantee"; + if (E1B_DVS == "1") + { + LOG(WARNING) << "Navigation data without guarantee"; + } E1B_DVS = "0"; // *************** CHANGE THIS WHEN GALILEO SIGNAL IS VALID std::string SVhealth_str = E5B_HS + std::to_string(galileo_ephemeris_iter->second.E5b_DVS_5) + "11" + "1" + E1B_DVS + E1B_HS + std::to_string(galileo_ephemeris_iter->second.E1B_DVS_5); @@ -3607,7 +3733,10 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.i_satellite_PRN < 10) line += std::string("0"); + if (glonass_gnav_ephemeris_iter->second.i_satellite_PRN < 10) + { + line += std::string("0"); + } line += std::to_string(glonass_gnav_ephemeris_iter->second.i_satellite_PRN); std::string year(timestring, 0, 4); line += std::string(1, ' '); @@ -3773,7 +3902,10 @@ void Rinex_Printer::log_rinex_nav(std::fstream& out, const std::mapsecond.i_satellite_PRN < 10) line += std::string("0"); + if (bds_ephemeris_iter->second.i_satellite_PRN < 10) + { + line += std::string("0"); + } line += std::to_string(bds_ephemeris_iter->second.i_satellite_PRN); std::string year(timestring, 0, 4); line += std::string(1, ' '); @@ -4009,7 +4141,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Glonass_Gnav_Ephem line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property //line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) gnss_sdr_version.resize(9, ' '); + if (gnss_sdr_version.length() > 20) + { + gnss_sdr_version.resize(9, ' '); + } line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); lengthCheck(line); @@ -4332,7 +4467,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property //line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) gnss_sdr_version.resize(9, ' '); + if (gnss_sdr_version.length() > 20) + { + gnss_sdr_version.resize(9, ' '); + } line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); lengthCheck(line); @@ -4684,7 +4822,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property //line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) gnss_sdr_version.resize(9, ' '); + if (gnss_sdr_version.length() > 20) + { + gnss_sdr_version.resize(9, ' '); + } line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); lengthCheck(line); @@ -4990,7 +5131,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property //line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) gnss_sdr_version.resize(9, ' '); + if (gnss_sdr_version.length() > 20) + { + gnss_sdr_version.resize(9, ' '); + } line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); lengthCheck(line); @@ -5310,7 +5454,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property //line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) gnss_sdr_version.resize(9, ' '); + if (gnss_sdr_version.length() > 20) + { + gnss_sdr_version.resize(9, ' '); + } line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); lengthCheck(line); @@ -5564,7 +5711,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property //line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) gnss_sdr_version.resize(9, ' '); + if (gnss_sdr_version.length() > 20) + { + gnss_sdr_version.resize(9, ' '); + } line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); lengthCheck(line); @@ -5812,7 +5962,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& eph line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property //line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) gnss_sdr_version.resize(9, ' '); + if (gnss_sdr_version.length() > 20) + { + gnss_sdr_version.resize(9, ' '); + } line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); lengthCheck(line); @@ -6090,7 +6243,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property //line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) gnss_sdr_version.resize(9, ' '); + if (gnss_sdr_version.length() > 20) + { + gnss_sdr_version.resize(9, ' '); + } line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); lengthCheck(line); @@ -6433,7 +6589,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_CNAV_Ephemeris line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property //line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) gnss_sdr_version.resize(9, ' '); + if (gnss_sdr_version.length() > 20) + { + gnss_sdr_version.resize(9, ' '); + } line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); lengthCheck(line); @@ -6748,7 +6907,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Galileo_Ephemeris& line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property //line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) gnss_sdr_version.resize(9, ' '); + if (gnss_sdr_version.length() > 20) + { + gnss_sdr_version.resize(9, ' '); + } line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); lengthCheck(line); @@ -7012,7 +7174,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Gps_Ephemeris& gps line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property //line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) gnss_sdr_version.resize(9, ' '); + if (gnss_sdr_version.length() > 20) + { + gnss_sdr_version.resize(9, ' '); + } line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); lengthCheck(line); @@ -7291,7 +7456,10 @@ void Rinex_Printer::rinex_obs_header(std::fstream& out, const Beidou_Dnav_Epheme line += Rinex_Printer::leftJustify("GNSS-SDR", 20); // add flag and property line += Rinex_Printer::leftJustify("Software Receiver", 20); // add flag and property //line += Rinex_Printer::leftJustify(google::VersionString(), 20); // add flag and property - if (gnss_sdr_version.length() > 20) gnss_sdr_version.resize(9, ' '); + if (gnss_sdr_version.length() > 20) + { + gnss_sdr_version.resize(9, ' '); + } line += Rinex_Printer::leftJustify(gnss_sdr_version, 20); line += Rinex_Printer::leftJustify("REC # / TYPE / VERS", 20); lengthCheck(line); @@ -7779,7 +7947,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri observables_iter++) { line += satelliteSystem["GLONASS"]; - if (static_cast(observables_iter->second.PRN) < 10) line += std::string(1, '0'); + if (static_cast(observables_iter->second.PRN) < 10) + { + line += std::string(1, '0'); + } line += std::to_string(static_cast(observables_iter->second.PRN)); } // Receiver clock offset (optional) @@ -7837,7 +8008,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); //GLONASS L1 SIGNAL STRENGTH lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } } @@ -7893,7 +8067,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri std::string lineObs; lineObs.clear(); lineObs += satelliteSystem["GLONASS"]; - if (static_cast(observables_iter->second.PRN) < 10) lineObs += std::string(1, '0'); + if (static_cast(observables_iter->second.PRN) < 10) + { + lineObs += std::string(1, '0'); + } lineObs += std::to_string(static_cast(observables_iter->second.PRN)); //lineObs += std::string(2, ' '); lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); @@ -7941,7 +8118,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Glonass_Gnav_Ephemeri //GLONASS L1 SIGNAL STRENGTH lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } } @@ -8104,7 +8284,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep observables_iter++) { line += satelliteSystem["GPS"]; - if (static_cast(observables_iter->second.PRN) < 10) line += std::string(1, '0'); + if (static_cast(observables_iter->second.PRN) < 10) + { + line += std::string(1, '0'); + } line += std::to_string(static_cast(observables_iter->second.PRN)); } // Add list of GLONASS L1 satellites @@ -8113,7 +8296,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep observables_iter++) { line += satelliteSystem["GLONASS"]; - if (static_cast(observables_iter->second.PRN) < 10) line += std::string(1, '0'); + if (static_cast(observables_iter->second.PRN) < 10) + { + line += std::string(1, '0'); + } line += std::to_string(static_cast(observables_iter->second.PRN)); } // Add list of GLONASS L2 satellites @@ -8122,7 +8308,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep observables_iter++) { line += satelliteSystem["GLONASS"]; - if (static_cast(observables_iter->second.PRN) < 10) line += std::string(1, '0'); + if (static_cast(observables_iter->second.PRN) < 10) + { + line += std::string(1, '0'); + } line += std::to_string(static_cast(observables_iter->second.PRN)); } } @@ -8143,9 +8332,18 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep if (version == 3) { // Specify system only if in version 3 - if (s == "G") lineObs += satelliteSystem["GPS"]; - if (s == "R") lineObs += satelliteSystem["GLONASS"]; // should not happen - if (static_cast(observables_iter->second.PRN) < 10) lineObs += std::string(1, '0'); + if (s == "G") + { + lineObs += satelliteSystem["GPS"]; + } + if (s == "R") + { + lineObs += satelliteSystem["GLONASS"]; // should not happen + } + if (static_cast(observables_iter->second.PRN) < 10) + { + lineObs += std::string(1, '0'); + } lineObs += std::to_string(static_cast(observables_iter->second.PRN)); } @@ -8194,7 +8392,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep // SIGNAL STRENGTH lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } @@ -8207,7 +8408,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep if (version == 3) { lineObs += satelliteSystem["GLONASS"]; - if (static_cast(*it) < 10) lineObs += std::string(1, '0'); + if (static_cast(*it) < 10) + { + lineObs += std::string(1, '0'); + } lineObs += std::to_string(static_cast(*it)); } ret = total_glo_map.equal_range(*it); @@ -8260,7 +8464,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); } - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } } @@ -8386,9 +8593,18 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g s.assign(1, observables_iter->second.System); // Specify system only if in version 3 - if (s == "G") lineObs += satelliteSystem["GPS"]; - if (s == "R") lineObs += satelliteSystem["GLONASS"]; // should not happen - if (static_cast(observables_iter->second.PRN) < 10) lineObs += std::string(1, '0'); + if (s == "G") + { + lineObs += satelliteSystem["GPS"]; + } + if (s == "R") + { + lineObs += satelliteSystem["GLONASS"]; // should not happen + } + if (static_cast(observables_iter->second.PRN) < 10) + { + lineObs += std::string(1, '0'); + } lineObs += std::to_string(static_cast(observables_iter->second.PRN)); // Pseudorange Measurements @@ -8436,7 +8652,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g // SIGNAL STRENGTH lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } @@ -8447,7 +8666,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g { lineObs.clear(); lineObs += satelliteSystem["GLONASS"]; - if (static_cast(*it) < 10) lineObs += std::string(1, '0'); + if (static_cast(*it) < 10) + { + lineObs += std::string(1, '0'); + } lineObs += std::to_string(static_cast(*it)); ret = total_glo_map.equal_range(*it); @@ -8500,7 +8722,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& g lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); } - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } } @@ -8626,9 +8851,18 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga lineObs.clear(); s.assign(1, observables_iter->second.System); - if (s == "E") lineObs += satelliteSystem["Galileo"]; - if (s == "R") lineObs += satelliteSystem["GLONASS"]; // should not happen - if (static_cast(observables_iter->second.PRN) < 10) lineObs += std::string(1, '0'); + if (s == "E") + { + lineObs += satelliteSystem["Galileo"]; + } + if (s == "R") + { + lineObs += satelliteSystem["GLONASS"]; // should not happen + } + if (static_cast(observables_iter->second.PRN) < 10) + { + lineObs += std::string(1, '0'); + } lineObs += std::to_string(static_cast(observables_iter->second.PRN)); lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); @@ -8674,7 +8908,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga // SIGNAL STRENGTH lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } @@ -8685,7 +8922,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga { lineObs.clear(); lineObs += satelliteSystem["Galileo"]; - if (static_cast(*it) < 10) lineObs += std::string(1, '0'); + if (static_cast(*it) < 10) + { + lineObs += std::string(1, '0'); + } lineObs += std::to_string(static_cast(*it)); ret = total_glo_map.equal_range(*it); for (auto iter = ret.first; iter != ret.second; ++iter) @@ -8735,7 +8975,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ga lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); } - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } } @@ -8812,7 +9055,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c observables_iter++) { line += satelliteSystem["GPS"]; - if (static_cast(observables_iter->second.PRN) < 10) line += std::string(1, '0'); + if (static_cast(observables_iter->second.PRN) < 10) + { + line += std::string(1, '0'); + } line += std::to_string(static_cast(observables_iter->second.PRN)); } // Receiver clock offset (optional) @@ -8870,7 +9116,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c lineObs += Rinex_Printer::rightJustify(Rinex_Printer::asString(ssi), 1); //GPS L1 SIGNAL STRENGTH lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } } @@ -8927,7 +9176,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c std::string lineObs; lineObs.clear(); lineObs += satelliteSystem["GPS"]; - if (static_cast(observables_iter->second.PRN) < 10) lineObs += std::string(1, '0'); + if (static_cast(observables_iter->second.PRN) < 10) + { + lineObs += std::string(1, '0'); + } lineObs += std::to_string(static_cast(observables_iter->second.PRN)); //lineObs += std::string(2, ' '); lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); @@ -8975,7 +9227,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c //GPS L1 SIGNAL STRENGTH lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } } @@ -9048,7 +9303,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e std::string lineObs; lineObs.clear(); lineObs += satelliteSystem["GPS"]; - if (static_cast(observables_iter->second.PRN) < 10) lineObs += std::string(1, '0'); + if (static_cast(observables_iter->second.PRN) < 10) + { + lineObs += std::string(1, '0'); + } lineObs += std::to_string(static_cast(observables_iter->second.PRN)); //lineObs += std::string(2, ' '); //GPS L2 PSEUDORANGE @@ -9097,7 +9355,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e //GPS L2 SIGNAL STRENGTH lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } } @@ -9266,7 +9527,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c { lineObs.clear(); lineObs += satelliteSystem["GPS"]; - if (static_cast(*it) < 10) lineObs += std::string(1, '0'); + if (static_cast(*it) < 10) + { + lineObs += std::string(1, '0'); + } lineObs += std::to_string(static_cast(*it)); ret = total_mmap.equal_range(*it); for (auto iter = ret.first; iter != ret.second; ++iter) @@ -9316,7 +9580,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& eph, c lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); } - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } } @@ -9506,7 +9773,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep { lineObs.clear(); lineObs += satelliteSystem["Galileo"]; - if (static_cast(*it) < 10) lineObs += std::string(1, '0'); + if (static_cast(*it) < 10) + { + lineObs += std::string(1, '0'); + } lineObs += std::to_string(static_cast(*it)); ret = total_map.equal_range(*it); for (auto iter = ret.first; iter != ret.second; ++iter) @@ -9556,7 +9826,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Galileo_Ephemeris& ep lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); } - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } } @@ -9701,9 +9974,18 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep lineObs.clear(); s.assign(1, observables_iter->second.System); - if (s == "G") lineObs += satelliteSystem["GPS"]; - if (s == "E") lineObs += satelliteSystem["Galileo"]; // should not happen - if (static_cast(observables_iter->second.PRN) < 10) lineObs += std::string(1, '0'); + if (s == "G") + { + lineObs += satelliteSystem["GPS"]; + } + if (s == "E") + { + lineObs += satelliteSystem["Galileo"]; // should not happen + } + if (static_cast(observables_iter->second.PRN) < 10) + { + lineObs += std::string(1, '0'); + } lineObs += std::to_string(static_cast(observables_iter->second.PRN)); lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.Pseudorange_m, 3), 14); @@ -9749,7 +10031,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep // SIGNAL STRENGTH lineObs += Rinex_Printer::rightJustify(asString(observables_iter->second.CN0_dB_hz, 3), 14); - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } @@ -9760,7 +10045,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep { lineObs.clear(); lineObs += satelliteSystem["Galileo"]; - if (static_cast(*it) < 10) lineObs += std::string(1, '0'); + if (static_cast(*it) < 10) + { + lineObs += std::string(1, '0'); + } lineObs += std::to_string(static_cast(*it)); ret = total_gal_map.equal_range(*it); for (auto iter = ret.first; iter != ret.second; ++iter) @@ -9810,7 +10098,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); } - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } } @@ -9989,7 +10280,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e { lineObs.clear(); lineObs += satelliteSystem["GPS"]; - if (static_cast(*it) < 10) lineObs += std::string(1, '0'); + if (static_cast(*it) < 10) + { + lineObs += std::string(1, '0'); + } lineObs += std::to_string(static_cast(*it)); ret = total_gps_map.equal_range(*it); for (auto iter = ret.first; iter != ret.second; ++iter) @@ -10048,7 +10342,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_CNAV_Ephemeris& e { lineObs.clear(); lineObs += satelliteSystem["Galileo"]; - if (static_cast(*it) < 10) lineObs += std::string(1, '0'); + if (static_cast(*it) < 10) + { + lineObs += std::string(1, '0'); + } lineObs += std::to_string(static_cast(*it)); ret = total_gal_map.equal_range(*it); for (auto iter = ret.first; iter != ret.second; ++iter) @@ -10298,7 +10595,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep { lineObs.clear(); lineObs += satelliteSystem["GPS"]; - if (static_cast(*it) < 10) lineObs += std::string(1, '0'); + if (static_cast(*it) < 10) + { + lineObs += std::string(1, '0'); + } lineObs += std::to_string(static_cast(*it)); ret = total_gps_map.equal_range(*it); for (auto iter = ret.first; iter != ret.second; ++iter) @@ -10357,7 +10657,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Gps_Ephemeris& gps_ep { lineObs.clear(); lineObs += satelliteSystem["Galileo"]; - if (static_cast(*it) < 10) lineObs += std::string(1, '0'); + if (static_cast(*it) < 10) + { + lineObs += std::string(1, '0'); + } lineObs += std::to_string(static_cast(*it)); ret = total_gal_map.equal_range(*it); for (auto iter = ret.first; iter != ret.second; ++iter) @@ -10539,7 +10842,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Beidou_Dnav_Ephemeris { lineObs.clear(); lineObs += satelliteSystem["Beidou"]; - if (static_cast(*it) < 10) lineObs += std::string(1, '0'); + if (static_cast(*it) < 10) + { + lineObs += std::string(1, '0'); + } lineObs += std::to_string(static_cast(*it)); ret = total_map.equal_range(*it); for (auto iter = ret.first; iter != ret.second; ++iter) @@ -10577,7 +10883,10 @@ void Rinex_Printer::log_rinex_obs(std::fstream& out, const Beidou_Dnav_Ephemeris lineObs += Rinex_Printer::rightJustify(asString(iter->second.CN0_dB_hz, 3), 14); } - if (lineObs.size() < 80) lineObs += std::string(80 - lineObs.size(), ' '); + if (lineObs.size() < 80) + { + lineObs += std::string(80 - lineObs.size(), ' '); + } out << lineObs << std::endl; } } diff --git a/src/algorithms/PVT/libs/rinex_printer.h b/src/algorithms/PVT/libs/rinex_printer.h index b5ea3357d..1c4475592 100644 --- a/src/algorithms/PVT/libs/rinex_printer.h +++ b/src/algorithms/PVT/libs/rinex_printer.h @@ -676,8 +676,15 @@ inline std::string Rinex_Printer::doub2for(const double& d, short exponentLength = expLen; /* Validate the assumptions regarding the input arguments */ - if (exponentLength < 0) exponentLength = 1; - if (exponentLength > 3 && checkSwitch) exponentLength = 3; + if (exponentLength < 0) + { + exponentLength = 1; + } + + if (exponentLength > 3 && checkSwitch) + { + exponentLength = 3; + } std::string toReturn = doub2sci(d, length, exponentLength, true, checkSwitch); sci2for(toReturn, 0, length, exponentLength, checkSwitch); @@ -696,8 +703,15 @@ inline std::string Rinex_Printer::doub2sci(const double& d, short exponentLength = expLen; /* Validate the assumptions regarding the input arguments */ - if (exponentLength < 0) exponentLength = 1; - if (exponentLength > 3 && checkSwitch) exponentLength = 3; + if (exponentLength < 0) + { + exponentLength = 1; + } + + if (exponentLength > 3 && checkSwitch) + { + exponentLength = 3; + } std::stringstream c; c.setf(std::ios::scientific, std::ios::floatfield); @@ -709,7 +723,10 @@ inline std::string Rinex_Printer::doub2sci(const double& d, // an extra -1 for '-' or ' ' if it's positive or negative int expSize = 0; if (showSign) - expSize = 1; + { + expSize = 1; + } + c.precision(length - 3 - exponentLength - 1 - expSize); c << d; c >> toReturn; @@ -751,7 +768,9 @@ inline std::string& Rinex_Printer::sci2for(std::string& aStr, aStr[idx - 1] = '.'; // Only add one to the exponent if the number is non-zero if (asDouble(aStr.substr(startPos, length)) != 0.0) - expAdd = 1; + { + expAdd = 1; + } } idx = aStr.find('e', startPos); @@ -766,9 +785,13 @@ inline std::string& Rinex_Printer::sci2for(std::string& aStr, // Change the exponent character to D normally, or E of checkSwitch is false. if (checkSwitch) - aStr[idx] = 'D'; + { + aStr[idx] = 'D'; + } else - aStr[idx] = 'E'; + { + aStr[idx] = 'E'; + } // Change the exponent itself if (redoexp) @@ -784,7 +807,10 @@ inline std::string& Rinex_Printer::sci2for(std::string& aStr, iexp -= iexp * 2; } else - aStr += "+"; + { + aStr += "+"; + } + aStr += Rinex_Printer::rightJustify(asString(iexp), expLen, '0'); } diff --git a/src/algorithms/PVT/libs/rtcm_printer.cc b/src/algorithms/PVT/libs/rtcm_printer.cc index 39c7fe650..d3416be6e 100644 --- a/src/algorithms/PVT/libs/rtcm_printer.cc +++ b/src/algorithms/PVT/libs/rtcm_printer.cc @@ -201,7 +201,10 @@ Rtcm_Printer::~Rtcm_Printer() } if (pos == 0) { - if (remove(rtcm_filename.c_str()) != 0) LOG(INFO) << "Error deleting temporary RTCM file"; + if (remove(rtcm_filename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary RTCM file"; + } } } try @@ -368,10 +371,16 @@ int Rtcm_Printer::init_serial(const std::string& serial_device) int64_t PARITY; fd = open(serial_device.c_str(), O_RDWR | O_NOCTTY | O_NDELAY | O_CLOEXEC); - if (fd == -1) return fd; // failed to open TTY port + if (fd == -1) + { + return fd; // failed to open TTY port + } - if (fcntl(fd, F_SETFL, 0) == -1) LOG(INFO) << "Error enabling direct I/O"; // clear all flags on descriptor, enable direct I/O - tcgetattr(fd, &options); // read serial port options + if (fcntl(fd, F_SETFL, 0) == -1) + { + LOG(INFO) << "Error enabling direct I/O"; // clear all flags on descriptor, enable direct I/O + } + tcgetattr(fd, &options); // read serial port options BAUD = B9600; //BAUD = B38400; diff --git a/src/algorithms/PVT/libs/rtklib_solver.cc b/src/algorithms/PVT/libs/rtklib_solver.cc index 6057276ab..aeabc0517 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.cc +++ b/src/algorithms/PVT/libs/rtklib_solver.cc @@ -76,7 +76,10 @@ rtklib_solver::rtklib_solver(int nchannels, std::string dump_filename, bool flag count_valid_position = 0; this->set_averaging_flag(false); rtk_ = rtk; - for (double &i : dop_) i = 0.0; + for (double &i : dop_) + { + i = 0.0; + } pvt_sol = {{0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, '0', '0', '0', 0, 0, 0}; ssat_t ssat0 = {0, 0, {0.0}, {0.0}, {0.0}, {'0'}, {'0'}, {'0'}, {'0'}, {'0'}, {}, {}, {}, {}, 0.0, 0.0, 0.0, 0.0, {{{0, 0}}, {{0, 0}}}, {{}, {}}}; for (auto &i : pvt_ssat) @@ -505,7 +508,10 @@ bool rtklib_solver::get_PVT(const std::map &gnss_observables_ } } } - if (band1 == true and band2 == true) gps_dual_band = true; + if (band1 == true and band2 == true) + { + gps_dual_band = true; + } for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); @@ -864,7 +870,10 @@ bool rtklib_solver::get_PVT(const std::map &gnss_observables_ } } - if (index_aux > 0) dops(index_aux, azel.data(), 0.0, dop_.data()); + if (index_aux > 0) + { + dops(index_aux, azel.data(), 0.0, dop_.data()); + } this->set_valid_position(true); arma::vec rx_position_and_time(4); rx_position_and_time(0) = pvt_sol.rr[0]; // [m] @@ -893,7 +902,10 @@ bool rtklib_solver::get_PVT(const std::map &gnss_observables_ if (ground_speed_ms >= 1.0) { new_cog = atan2(enuv[0], enuv[1]) * R2D; - if (new_cog < 0.0) new_cog += 360.0; + if (new_cog < 0.0) + { + new_cog += 360.0; + } this->set_course_over_ground(new_cog); } diff --git a/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.cc index 84de3096b..7ee2a7277 100644 --- a/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.cc @@ -68,7 +68,10 @@ BeidouB1iPcpsAcquisition::BeidouB1iPcpsAcquisition( blocking_ = configuration_->property(role + ".blocking", true); acq_parameters.blocking = blocking_; doppler_max_ = configuration_->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } acq_parameters.doppler_max = doppler_max_; sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 1); acq_parameters.sampled_ms = sampled_ms_; diff --git a/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h b/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h index a0312ebe6..334aff555 100644 --- a/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h +++ b/src/algorithms/acquisition/adapters/beidou_b1i_pcps_acquisition.h @@ -41,8 +41,8 @@ #include #include #include -#include #include +#include class ConfigurationInterface; @@ -164,7 +164,7 @@ private: uint32_t doppler_step_; uint32_t sampled_ms_; uint32_t max_dwells_; - int64_t fs_in_; + int64_t fs_in_; bool dump_; bool blocking_; std::string dump_filename_; diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.cc index 7af5d228f..0f6449ff0 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_8ms_ambiguous_acquisition.cc @@ -61,7 +61,10 @@ GalileoE1Pcps8msAmbiguousAcquisition::GalileoE1Pcps8msAmbiguousAcquisition( fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); dump_ = configuration_->property(role + ".dump", false); doppler_max_ = configuration_->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 4); if (sampled_ms_ % 4 != 0) @@ -145,7 +148,10 @@ void GalileoE1Pcps8msAmbiguousAcquisition::set_threshold(float threshold) { float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0); - if (pfa == 0.0) pfa = configuration_->property(role_ + ".pfa", 0.0); + if (pfa == 0.0) + { + pfa = configuration_->property(role_ + ".pfa", 0.0); + } if (pfa == 0.0) { diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc index 79e25061c..5f4137f7d 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_ambiguous_acquisition.cc @@ -62,7 +62,10 @@ GalileoE1PcpsAmbiguousAcquisition::GalileoE1PcpsAmbiguousAcquisition( fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); acq_parameters_.fs_in = fs_in_; doppler_max_ = configuration_->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } acq_parameters_.doppler_max = doppler_max_; acq_parameters_.ms_per_code = 4; sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", acq_parameters_.ms_per_code); @@ -187,7 +190,10 @@ void GalileoE1PcpsAmbiguousAcquisition::set_threshold(float threshold) { float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0); - if (pfa == 0.0) pfa = configuration_->property(role_ + ".pfa", 0.0); + if (pfa == 0.0) + { + pfa = configuration_->property(role_ + ".pfa", 0.0); + } if (pfa == 0.0) { diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.cc index 76869f266..a0de0804d 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_cccwsr_ambiguous_acquisition.cc @@ -60,7 +60,10 @@ GalileoE1PcpsCccwsrAmbiguousAcquisition::GalileoE1PcpsCccwsrAmbiguousAcquisition fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); dump_ = configuration_->property(role + ".dump", false); doppler_max_ = configuration_->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 4); if (sampled_ms_ % 4 != 0) diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.cc index b409eee0b..7437faa8c 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_quicksync_ambiguous_acquisition.cc @@ -61,7 +61,10 @@ GalileoE1PcpsQuickSyncAmbiguousAcquisition::GalileoE1PcpsQuickSyncAmbiguousAcqui fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); dump_ = configuration_->property(role + ".dump", false); doppler_max_ = configuration_->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 8); /*--- Find number of samples per spreading code (4 ms) -----------------*/ @@ -179,7 +182,10 @@ void GalileoE1PcpsQuickSyncAmbiguousAcquisition::set_threshold(float threshold) { float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0); - if (pfa == 0.0) pfa = configuration_->property(role_ + ".pfa", 0.0); + if (pfa == 0.0) + { + pfa = configuration_->property(role_ + ".pfa", 0.0); + } if (pfa == 0.0) { diff --git a/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.cc index 20418f7ef..bdc0c3971 100644 --- a/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e1_pcps_tong_ambiguous_acquisition.cc @@ -61,7 +61,10 @@ GalileoE1PcpsTongAmbiguousAcquisition::GalileoE1PcpsTongAmbiguousAcquisition( fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); dump_ = configuration_->property(role + ".dump", false); doppler_max_ = configuration_->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 4); if (sampled_ms_ % 4 != 0) @@ -149,7 +152,10 @@ void GalileoE1PcpsTongAmbiguousAcquisition::set_threshold(float threshold) { float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0); - if (pfa == 0.0) pfa = configuration_->property(role_ + ".pfa", 0.0); + if (pfa == 0.0) + { + pfa = configuration_->property(role_ + ".pfa", 0.0); + } if (pfa == 0.0) { diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.cc b/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.cc index c6c4f663d..8d65ea52a 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_noncoherent_iq_acquisition_caf.cc @@ -66,7 +66,10 @@ GalileoE5aNoncoherentIQAcquisitionCaf::GalileoE5aNoncoherentIQAcquisitionCaf( fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); dump_ = configuration_->property(role + ".dump", false); doppler_max_ = configuration_->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } CAF_window_hz_ = configuration_->property(role + ".CAF_window_hz", 0); Zero_padding = configuration_->property(role + ".Zero_padding", 0); sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 1); @@ -155,7 +158,10 @@ void GalileoE5aNoncoherentIQAcquisitionCaf::set_threshold(float threshold) { float pfa = configuration_->property(role_ + std::to_string(channel_) + ".pfa", 0.0); - if (pfa == 0.0) pfa = configuration_->property(role_ + ".pfa", 0.0); + if (pfa == 0.0) + { + pfa = configuration_->property(role_ + ".pfa", 0.0); + } if (pfa == 0.0) { diff --git a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.cc index 4b7abfc8f..079599926 100644 --- a/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/galileo_e5a_pcps_acquisition.cc @@ -70,7 +70,10 @@ GalileoE5aPcpsAcquisition::GalileoE5aPcpsAcquisition(ConfigurationInterface* con acq_parameters_.dump = dump_; acq_parameters_.dump_channel = configuration_->property(role + ".dump_channel", 0); doppler_max_ = configuration_->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } acq_parameters_.doppler_max = doppler_max_; sampled_ms_ = 1; max_dwells_ = configuration_->property(role + ".max_dwells", 1); diff --git a/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.cc index 050190ee7..4480fd30b 100644 --- a/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.cc @@ -71,7 +71,10 @@ GlonassL1CaPcpsAcquisition::GlonassL1CaPcpsAcquisition( blocking_ = configuration_->property(role + ".blocking", true); acq_parameters.blocking = blocking_; doppler_max_ = configuration_->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } acq_parameters.doppler_max = doppler_max_; sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 1); acq_parameters.sampled_ms = sampled_ms_; diff --git a/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.cc index 93aa9736d..6770310d7 100644 --- a/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.cc @@ -70,7 +70,10 @@ GlonassL2CaPcpsAcquisition::GlonassL2CaPcpsAcquisition( blocking_ = configuration_->property(role + ".blocking", true); acq_parameters.blocking = blocking_; doppler_max_ = configuration_->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } acq_parameters.doppler_max = doppler_max_; sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 1); bit_transition_flag_ = configuration_->property(role + ".bit_transition_flag", false); diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc index ce0ea4065..e27f37581 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition.cc @@ -70,7 +70,10 @@ GpsL1CaPcpsAcquisition::GpsL1CaPcpsAcquisition( blocking_ = configuration_->property(role + ".blocking", true); acq_parameters_.blocking = blocking_; doppler_max_ = configuration_->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } acq_parameters_.doppler_max = doppler_max_; sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 1); acq_parameters_.sampled_ms = sampled_ms_; diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.cc index 4e16b54ec..4fb0e46cf 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_acquisition_fine_doppler.cc @@ -67,7 +67,10 @@ GpsL1CaPcpsAcquisitionFineDoppler::GpsL1CaPcpsAcquisitionFineDoppler( dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename); acq_parameters.dump_filename = dump_filename_; doppler_max_ = configuration->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } acq_parameters.doppler_max = doppler_max_; sampled_ms_ = configuration->property(role + ".coherent_integration_time_ms", 1); acq_parameters.sampled_ms = sampled_ms_; diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.cc index fb7a140b7..3770b7c7a 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_assisted_acquisition.cc @@ -61,7 +61,10 @@ GpsL1CaPcpsAssistedAcquisition::GpsL1CaPcpsAssistedAcquisition( fs_in_ = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); dump_ = configuration->property(role + ".dump", false); doppler_max_ = configuration->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } doppler_min_ = configuration->property(role + ".doppler_min", -doppler_max_); sampled_ms_ = configuration->property(role + ".coherent_integration_time_ms", 1); max_dwells_ = configuration->property(role + ".max_dwells", 1); diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.cc index a3d896ccc..2691b1161 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_quicksync_acquisition.cc @@ -61,7 +61,10 @@ GpsL1CaPcpsQuickSyncAcquisition::GpsL1CaPcpsQuickSyncAcquisition( fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); dump_ = configuration_->property(role + ".dump", false); doppler_max_ = configuration->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 4); //--- Find number of samples per spreading code ------------------------- diff --git a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.cc index 0b3a627ba..162ea96ae 100644 --- a/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l1_ca_pcps_tong_acquisition.cc @@ -61,7 +61,10 @@ GpsL1CaPcpsTongAcquisition::GpsL1CaPcpsTongAcquisition( fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); dump_ = configuration_->property(role + ".dump", false); doppler_max_ = configuration->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 1); tong_init_val_ = configuration->property(role + ".tong_init_val", 1); diff --git a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.cc index dcf663121..00fcb7624 100644 --- a/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l2_m_pcps_acquisition.cc @@ -68,7 +68,10 @@ GpsL2MPcpsAcquisition::GpsL2MPcpsAcquisition( blocking_ = configuration_->property(role + ".blocking", true); acq_parameters_.blocking = blocking_; doppler_max_ = configuration->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } acq_parameters_.doppler_max = doppler_max_; bit_transition_flag_ = configuration_->property(role + ".bit_transition_flag", false); acq_parameters_.bit_transition_flag = bit_transition_flag_; diff --git a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.cc index f436da1d4..d3b722823 100644 --- a/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/gps_l5i_pcps_acquisition.cc @@ -69,7 +69,10 @@ GpsL5iPcpsAcquisition::GpsL5iPcpsAcquisition( blocking_ = configuration_->property(role + ".blocking", true); acq_parameters_.blocking = blocking_; doppler_max_ = configuration->property(role + ".doppler_max", 5000); - if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + if (FLAGS_doppler_max != 0) + { + doppler_max_ = FLAGS_doppler_max; + } acq_parameters_.doppler_max = doppler_max_; bit_transition_flag_ = configuration_->property(role + ".bit_transition_flag", false); acq_parameters_.bit_transition_flag = bit_transition_flag_; diff --git a/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc index c6f14d597..84e517a09 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/galileo_e5a_noncoherent_iq_acquisition_caf_cc.cc @@ -60,7 +60,7 @@ galileo_e5a_noncoherentIQ_acquisition_caf_cc_sptr galileo_e5a_noncoherentIQ_make { return galileo_e5a_noncoherentIQ_acquisition_caf_cc_sptr( new galileo_e5a_noncoherentIQ_acquisition_caf_cc(sampled_ms, max_dwells, doppler_max, fs_in, samples_per_ms, - samples_per_code, bit_transition_flag, dump, std::move(dump_filename), both_signal_components_, CAF_window_hz_, Zero_padding_)); + samples_per_code, bit_transition_flag, dump, dump_filename, both_signal_components_, CAF_window_hz_, Zero_padding_)); } @@ -153,7 +153,7 @@ galileo_e5a_noncoherentIQ_acquisition_caf_cc::galileo_e5a_noncoherentIQ_acquisit // For dumping samples into a file d_dump = dump; - d_dump_filename = std::move(dump_filename); + d_dump_filename = dump_filename; d_doppler_resolution = 0; d_threshold = 0; diff --git a/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc index 05ac683e0..7b5566aba 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/galileo_pcps_8ms_acquisition_cc.cc @@ -51,7 +51,7 @@ galileo_pcps_8ms_acquisition_cc_sptr galileo_pcps_8ms_make_acquisition_cc( { return galileo_pcps_8ms_acquisition_cc_sptr( new galileo_pcps_8ms_acquisition_cc(sampled_ms, max_dwells, doppler_max, fs_in, samples_per_ms, - samples_per_code, dump, std::move(dump_filename))); + samples_per_code, dump, dump_filename)); } @@ -95,7 +95,7 @@ galileo_pcps_8ms_acquisition_cc::galileo_pcps_8ms_acquisition_cc( // For dumping samples into a file d_dump = dump; - d_dump_filename = std::move(dump_filename); + d_dump_filename = dump_filename; d_doppler_resolution = 0; d_threshold = 0; @@ -134,7 +134,7 @@ galileo_pcps_8ms_acquisition_cc::~galileo_pcps_8ms_acquisition_cc() d_dump_file.close(); } } - catch (const std::ifstream::failure &e) + catch (const std::ofstream::failure &e) { std::cerr << "Problem closing Acquisition dump file: " << d_dump_filename << '\n'; } diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc index d95bb24cb..8a806c80f 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc @@ -317,7 +317,10 @@ void pcps_acquisition::init() d_num_doppler_bins = static_cast(std::ceil(static_cast(static_cast(acq_parameters.doppler_max) - static_cast(-acq_parameters.doppler_max)) / static_cast(d_doppler_step))); // Create the carrier Doppler wipeoff signals - if (d_grid_doppler_wipeoffs == nullptr) d_grid_doppler_wipeoffs = new gr_complex*[d_num_doppler_bins]; + if (d_grid_doppler_wipeoffs == nullptr) + { + d_grid_doppler_wipeoffs = new gr_complex*[d_num_doppler_bins]; + } if (acq_parameters.make_2_steps && (d_grid_doppler_wipeoffs_step_two == nullptr)) { d_grid_doppler_wipeoffs_step_two = new gr_complex*[d_num_doppler_bins_step2]; @@ -629,7 +632,10 @@ float pcps_acquisition::first_vs_second_peak_statistic(uint32_t& indext, int32_t { d_tmp_buffer[idx] = 0.0; idx++; - if (idx == static_cast(d_fft_size)) idx = 0; + if (idx == static_cast(d_fft_size)) + { + idx = 0; + } } while (idx != excludeRangeIndex2); @@ -842,7 +848,10 @@ void pcps_acquisition::acquisition_core(uint64_t samp_count) if (d_num_noncoherent_integrations_counter == acq_parameters.max_dwells) { - if (d_state != 0) send_negative_acquisition(); + if (d_state != 0) + { + send_negative_acquisition(); + } d_state = 0; d_active = false; d_step_two = false; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc index c7a67b47c..db21bbc2b 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc @@ -313,7 +313,10 @@ double pcps_acquisition_fine_doppler_cc::compute_CAF() { d_grid_data[index_doppler][idx] = 0.0; idx++; - if (idx == static_cast(d_fft_size)) idx = 0; + if (idx == static_cast(d_fft_size)) + { + idx = 0; + } } while (idx != excludeRangeIndex2); diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc index 1934ee5e8..413b7af10 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_assisted_acquisition_cc.cc @@ -53,7 +53,7 @@ pcps_assisted_acquisition_cc_sptr pcps_make_assisted_acquisition_cc( { return pcps_assisted_acquisition_cc_sptr( new pcps_assisted_acquisition_cc(max_dwells, sampled_ms, doppler_max, doppler_min, - fs_in, samples_per_ms, dump, std::move(dump_filename))); + fs_in, samples_per_ms, dump, dump_filename)); } @@ -90,7 +90,7 @@ pcps_assisted_acquisition_cc::pcps_assisted_acquisition_cc( // For dumping samples into a file d_dump = dump; - d_dump_filename = std::move(dump_filename); + d_dump_filename = dump_filename; d_doppler_resolution = 0; d_threshold = 0; @@ -392,7 +392,10 @@ int pcps_assisted_acquisition_cc::general_work(int noutput_items, switch (d_state) { case 0: // S0. StandBy - if (d_active == true) d_state = 1; + if (d_active == true) + { + d_state = 1; + } d_sample_counter += static_cast(ninput_items[0]); // sample counter consume_each(ninput_items[0]); break; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc index 17082ae25..918bc5aa2 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_cccwsr_acquisition_cc.cc @@ -57,7 +57,7 @@ pcps_cccwsr_acquisition_cc_sptr pcps_cccwsr_make_acquisition_cc( { return pcps_cccwsr_acquisition_cc_sptr( new pcps_cccwsr_acquisition_cc(sampled_ms, max_dwells, doppler_max, fs_in, - samples_per_ms, samples_per_code, dump, std::move(dump_filename))); + samples_per_ms, samples_per_code, dump, dump_filename)); } @@ -105,7 +105,7 @@ pcps_cccwsr_acquisition_cc::pcps_cccwsr_acquisition_cc( // For dumping samples into a file d_dump = dump; - d_dump_filename = std::move(dump_filename); + d_dump_filename = dump_filename; d_doppler_resolution = 0; d_threshold = 0; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc index 48ae578e6..d04c71495 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc @@ -61,7 +61,7 @@ pcps_quicksync_acquisition_cc_sptr pcps_quicksync_make_acquisition_cc( fs_in, samples_per_ms, samples_per_code, bit_transition_flag, - dump, std::move(dump_filename))); + dump, dump_filename)); } @@ -114,7 +114,7 @@ pcps_quicksync_acquisition_cc::pcps_quicksync_acquisition_cc( // For dumping samples into a file d_dump = dump; - d_dump_filename = std::move(dump_filename); + d_dump_filename = dump_filename; d_corr_acumulator = nullptr; d_signal_folded = nullptr; @@ -218,7 +218,10 @@ void pcps_quicksync_acquisition_cc::init() d_mag = 0.0; d_input_power = 0.0; - if (d_doppler_step == 0) d_doppler_step = 250; + if (d_doppler_step == 0) + { + d_doppler_step = 250; + } // Count the number of bins d_num_doppler_bins = 0; @@ -545,7 +548,10 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, DLOG(INFO) << "test statistics threshold " << d_threshold; DLOG(INFO) << "folding factor " << d_folding_factor; DLOG(INFO) << "possible delay correlation output"; - for (int32_t i = 0; i < static_cast(d_folding_factor); i++) DLOG(INFO) << d_possible_delay[i] << "\t\t\t" << d_corr_output_f[i]; + for (int32_t i = 0; i < static_cast(d_folding_factor); i++) + { + DLOG(INFO) << d_possible_delay[i] << "\t\t\t" << d_corr_output_f[i]; + } DLOG(INFO) << "code phase " << d_gnss_synchro->Acq_delay_samples; DLOG(INFO) << "doppler " << d_gnss_synchro->Acq_doppler_hz; DLOG(INFO) << "magnitude folded " << d_mag; @@ -574,7 +580,10 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, DLOG(INFO) << "test statistics threshold " << d_threshold; DLOG(INFO) << "folding factor " << d_folding_factor; DLOG(INFO) << "possible delay corr output"; - for (int32_t i = 0; i < static_cast(d_folding_factor); i++) DLOG(INFO) << d_possible_delay[i] << "\t\t\t" << d_corr_output_f[i]; + for (int32_t i = 0; i < static_cast(d_folding_factor); i++) + { + DLOG(INFO) << d_possible_delay[i] << "\t\t\t" << d_corr_output_f[i]; + } DLOG(INFO) << "code phase " << d_gnss_synchro->Acq_delay_samples; DLOG(INFO) << "doppler " << d_gnss_synchro->Acq_doppler_hz; DLOG(INFO) << "magnitude folded " << d_mag; diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc index 7fc685028..319525ca3 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_tong_acquisition_cc.cc @@ -73,7 +73,7 @@ pcps_tong_acquisition_cc_sptr pcps_tong_make_acquisition_cc( { return pcps_tong_acquisition_cc_sptr( new pcps_tong_acquisition_cc(sampled_ms, doppler_max, fs_in, samples_per_ms, samples_per_code, - tong_init_val, tong_max_val, tong_max_dwells, dump, std::move(dump_filename))); + tong_init_val, tong_max_val, tong_max_dwells, dump, dump_filename)); } @@ -121,7 +121,7 @@ pcps_tong_acquisition_cc::pcps_tong_acquisition_cc( // For dumping samples into a file d_dump = dump; - d_dump_filename = std::move(dump_filename); + d_dump_filename = dump_filename; d_doppler_resolution = 0; d_threshold = 0; diff --git a/src/algorithms/channel/adapters/channel.cc b/src/algorithms/channel/adapters/channel.cc index 946f17a65..12fafc3de 100644 --- a/src/algorithms/channel/adapters/channel.cc +++ b/src/algorithms/channel/adapters/channel.cc @@ -75,14 +75,23 @@ Channel::Channel(ConfigurationInterface* configuration, uint32_t channel, std::s // IMPORTANT: Do not change the order between set_doppler_step and set_threshold uint32_t doppler_step = configuration->property("Acquisition_" + implementation_ + std::to_string(channel_) + ".doppler_step", 0); - if (doppler_step == 0) doppler_step = configuration->property("Acquisition_" + implementation_ + ".doppler_step", 500); - if (FLAGS_doppler_step != 0) doppler_step = static_cast(FLAGS_doppler_step); + if (doppler_step == 0) + { + doppler_step = configuration->property("Acquisition_" + implementation_ + ".doppler_step", 500); + } + if (FLAGS_doppler_step != 0) + { + doppler_step = static_cast(FLAGS_doppler_step); + } DLOG(INFO) << "Channel " << channel_ << " Doppler_step = " << doppler_step; acq_->set_doppler_step(doppler_step); float threshold = configuration->property("Acquisition_" + implementation_ + std::to_string(channel_) + ".threshold", 0.0); - if (threshold == 0.0) threshold = configuration->property("Acquisition_" + implementation_ + ".threshold", 0.0); + if (threshold == 0.0) + { + threshold = configuration->property("Acquisition_" + implementation_ + ".threshold", 0.0); + } acq_->set_threshold(threshold); diff --git a/src/algorithms/libs/beidou_b1i_signal_processing.cc b/src/algorithms/libs/beidou_b1i_signal_processing.cc index b9618223e..d95b2844e 100644 --- a/src/algorithms/libs/beidou_b1i_signal_processing.cc +++ b/src/algorithms/libs/beidou_b1i_signal_processing.cc @@ -58,7 +58,9 @@ void beidou_b1i_code_gen_int(int32_t* _dest, int32_t _prn, uint32_t _chip_shift) /* A simple error check */ if ((prn_idx < 0) || (prn_idx > 51)) - return; + { + return; + } /*for (lcv = 0; lcv < 11; lcv++) { diff --git a/src/algorithms/libs/beidou_b1i_signal_processing.h b/src/algorithms/libs/beidou_b1i_signal_processing.h index 16c842523..2e420eaae 100644 --- a/src/algorithms/libs/beidou_b1i_signal_processing.h +++ b/src/algorithms/libs/beidou_b1i_signal_processing.h @@ -34,8 +34,8 @@ #define GNSS_SDR_BEIDOU_B1I_SDR_SIGNAL_PROCESSING_H_ #include -#include #include +#include //! Generates int32_t GPS L1 C/A code for the desired SV ID and code shift void beidou_b1i_code_gen_int(int32_t* _dest, int32_t _prn, uint32_t _chip_shift); diff --git a/src/algorithms/libs/geofunctions.cc b/src/algorithms/libs/geofunctions.cc index bf67e07f8..48137050b 100644 --- a/src/algorithms/libs/geofunctions.cc +++ b/src/algorithms/libs/geofunctions.cc @@ -304,8 +304,14 @@ arma::vec CTM_to_Euler(const arma::mat &C) arma::mat CTM(C); arma::vec eul = arma::zeros(3, 1); eul(0) = atan2(CTM(1, 2), CTM(2, 2)); // roll - if (CTM(0, 2) < -1.0) CTM(0, 2) = -1.0; - if (CTM(0, 2) > 1.0) CTM(0, 2) = 1.0; + if (CTM(0, 2) < -1.0) + { + CTM(0, 2) = -1.0; + } + if (CTM(0, 2) > 1.0) + { + CTM(0, 2) = 1.0; + } eul(1) = -asin(CTM(0, 2)); // pitch eul(2) = atan2(CTM(0, 1), CTM(0, 0)); // yaw return eul; @@ -614,7 +620,10 @@ void cart2utm(const arma::vec &r_eb_e, int zone, arma::vec &r_enu) // Ellipsoidal latitude, longitude to spherical latitude, longitude bool neg_geo = false; - if (B < 0.0) neg_geo = true; + if (B < 0.0) + { + neg_geo = true; + } double Bg_r = fabs(B); double res_clensin = clsin(bg, 4, 2.0 * Bg_r); @@ -732,10 +741,14 @@ int findUtmZone(double latitude_deg, double longitude_deg) // Check value bounds if ((longitude_deg > 180.0) || (longitude_deg < -180.0)) - std::cout << "Longitude value exceeds limits (-180:180).\n"; + { + std::cout << "Longitude value exceeds limits (-180:180).\n"; + } if ((latitude_deg > 84.0) || (latitude_deg < -80.0)) - std::cout << "Latitude value exceeds limits (-80:84).\n"; + { + std::cout << "Latitude value exceeds limits (-80:84).\n"; + } // // Find zone @@ -769,7 +782,9 @@ int findUtmZone(double latitude_deg, double longitude_deg) { // Correction for zone 32 if ((longitude_deg >= 3.0) && (longitude_deg < 12.0)) - utmZone = 32; + { + utmZone = 32; + } } return utmZone; } diff --git a/src/algorithms/libs/gnss_sdr_flags.cc b/src/algorithms/libs/gnss_sdr_flags.cc index 3eba67822..e44812281 100644 --- a/src/algorithms/libs/gnss_sdr_flags.cc +++ b/src/algorithms/libs/gnss_sdr_flags.cc @@ -69,8 +69,10 @@ DEFINE_double(pll_bw_hz, 0.0, "If defined, bandwidth of the PLL low pass filter, static bool ValidateC(const char* flagname, const std::string& value) { - if (boost::filesystem::exists(value) or value == "-") // value is ok - return true; + if (boost::filesystem::exists(value) or value == "-") + { // value is ok + return true; + } std::cout << "Invalid value for flag -" << flagname << ". The file '" << value << "' does not exist." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; return false; @@ -78,8 +80,10 @@ static bool ValidateC(const char* flagname, const std::string& value) static bool ValidateConfigFile(const char* flagname, const std::string& value) { - if (boost::filesystem::exists(value) or value == std::string(GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/default.conf")) // value is ok - return true; + if (boost::filesystem::exists(value) or value == std::string(GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/default.conf")) + { // value is ok + return true; + } std::cout << "Invalid value for flag -" << flagname << ". The file '" << value << "' does not exist." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; return false; @@ -87,8 +91,10 @@ static bool ValidateConfigFile(const char* flagname, const std::string& value) static bool ValidateS(const char* flagname, const std::string& value) { - if (boost::filesystem::exists(value) or value == "-") // value is ok - return true; + if (boost::filesystem::exists(value) or value == "-") + { // value is ok + return true; + } std::cout << "Invalid value for flag -" << flagname << ". The file '" << value << "' does not exist." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; return false; @@ -96,8 +102,10 @@ static bool ValidateS(const char* flagname, const std::string& value) static bool ValidateSignalSource(const char* flagname, const std::string& value) { - if (boost::filesystem::exists(value) or value == "-") // value is ok - return true; + if (boost::filesystem::exists(value) or value == "-") + { // value is ok + return true; + } std::cout << "Invalid value for flag -" << flagname << ". The file '" << value << "' does not exist." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; return false; @@ -106,8 +114,10 @@ static bool ValidateSignalSource(const char* flagname, const std::string& value) static bool ValidateDopplerMax(const char* flagname, int32_t value) { const int32_t max_value = 1000000; - if (value >= 0 && value < max_value) // value is ok - return true; + if (value >= 0 && value < max_value) + { // value is ok + return true; + } std::cout << "Invalid value for flag -" << flagname << ": " << value << ". Allowed range is 0 < " << flagname << " < " << max_value << " Hz." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; return false; @@ -116,8 +126,10 @@ static bool ValidateDopplerMax(const char* flagname, int32_t value) static bool ValidateDopplerStep(const char* flagname, int32_t value) { const int32_t max_value = 10000; - if (value >= 0 && value < max_value) // value is ok - return true; + if (value >= 0 && value < max_value) + { // value is ok + return true; + } std::cout << "Invalid value for flag -" << flagname << ": " << value << ". Allowed range is 0 < " << flagname << " < " << max_value << " Hz." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; return false; @@ -126,8 +138,10 @@ static bool ValidateDopplerStep(const char* flagname, int32_t value) static bool ValidateCn0Samples(const char* flagname, int32_t value) { const int32_t max_value = 10000; - if (value > 0 && value < max_value) // value is ok - return true; + if (value > 0 && value < max_value) + { // value is ok + return true; + } std::cout << "Invalid value for flag -" << flagname << ": " << value << ". Allowed range is 0 < " << flagname << " < " << max_value << " samples." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; return false; @@ -136,8 +150,10 @@ static bool ValidateCn0Samples(const char* flagname, int32_t value) static bool ValidateCn0Min(const char* flagname, int32_t value) { const int32_t max_value = 100; - if (value > 0 && value < max_value) // value is ok - return true; + if (value > 0 && value < max_value) + { // value is ok + return true; + } std::cout << "Invalid value for flag -" << flagname << ": " << value << ". Allowed range is 0 < " << flagname << " < " << max_value << " dB-Hz." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; return false; @@ -146,8 +162,10 @@ static bool ValidateCn0Min(const char* flagname, int32_t value) static bool ValidateMaxLockFail(const char* flagname, int32_t value) { const int32_t max_value = 10000; - if (value > 0 && value < max_value) // value is ok - return true; + if (value > 0 && value < max_value) + { // value is ok + return true; + } std::cout << "Invalid value for flag -" << flagname << ": " << value << ". Allowed range is 0 < " << flagname << " < " << max_value << " fails." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; return false; @@ -156,8 +174,10 @@ static bool ValidateMaxLockFail(const char* flagname, int32_t value) static bool ValidateCarrierLockTh(const char* flagname, double value) { const double max_value = 1.508; - if (value > 0.0 && value < max_value) // value is ok - return true; + if (value > 0.0 && value < max_value) + { // value is ok + return true; + } std::cout << "Invalid value for flag -" << flagname << ": " << value << ". Allowed range is 0 < " << flagname << " < " << max_value << " rad." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; return false; @@ -166,8 +186,10 @@ static bool ValidateCarrierLockTh(const char* flagname, double value) static bool ValidateDllBw(const char* flagname, double value) { const double max_value = 10000.0; - if (value >= 0.0 && value < max_value) // value is ok - return true; + if (value >= 0.0 && value < max_value) + { // value is ok + return true; + } std::cout << "Invalid value for flag -" << flagname << ": " << value << ". Allowed range is 0 < " << flagname << " < " << max_value << " Hz." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; return false; @@ -176,8 +198,10 @@ static bool ValidateDllBw(const char* flagname, double value) static bool ValidatePllBw(const char* flagname, double value) { const double max_value = 10000.0; - if (value >= 0.0 && value < max_value) // value is ok - return true; + if (value >= 0.0 && value < max_value) + { // value is ok + return true; + } std::cout << "Invalid value for flag -" << flagname << ": " << value << ". Allowed range is 0 < " << flagname << " < " << max_value << " Hz." << std::endl; std::cout << "GNSS-SDR program ended." << std::endl; return false; diff --git a/src/algorithms/libs/gps_sdr_signal_processing.cc b/src/algorithms/libs/gps_sdr_signal_processing.cc index e87593f6e..945be5607 100644 --- a/src/algorithms/libs/gps_sdr_signal_processing.cc +++ b/src/algorithms/libs/gps_sdr_signal_processing.cc @@ -64,7 +64,9 @@ void gps_l1_ca_code_gen_int(int32_t* _dest, int32_t _prn, uint32_t _chip_shift) /* A simple error check */ if ((prn_idx < 0) || (prn_idx > 51)) - return; + { + return; + } for (lcv = 0; lcv < 10; lcv++) { diff --git a/src/algorithms/libs/rtcm.cc b/src/algorithms/libs/rtcm.cc index 9adda308a..72015187e 100644 --- a/src/algorithms/libs/rtcm.cc +++ b/src/algorithms/libs/rtcm.cc @@ -344,8 +344,14 @@ int32_t Rtcm::bin_to_sint(const std::string& s) const // Find the sign for glonass data fields (neg = 1, pos = 0) static inline uint64_t glo_sgn(double val) { - if (val < 0) return 1; // If value is negative return 1 - if (val == 0) return 0; // Positive or equal to zero return 0 + if (val < 0) + { + return 1; // If value is negative return 1 + } + if (val == 0) + { + return 0; // Positive or equal to zero return 0 + } return 0; } @@ -2283,10 +2289,22 @@ std::string Rtcm::print_MSM_1(const Gps_Ephemeris& gps_eph, bool more_messages) { uint32_t msg_number = 0; - if (gps_eph.i_satellite_PRN != 0) msg_number = 1071; - if (gps_cnav_eph.i_satellite_PRN != 0) msg_number = 1071; - if (glo_gnav_eph.i_satellite_PRN != 0) msg_number = 1081; - if (gal_eph.i_satellite_PRN != 0) msg_number = 1091; + if (gps_eph.i_satellite_PRN != 0) + { + msg_number = 1071; + } + if (gps_cnav_eph.i_satellite_PRN != 0) + { + msg_number = 1071; + } + if (glo_gnav_eph.i_satellite_PRN != 0) + { + msg_number = 1081; + } + if (gal_eph.i_satellite_PRN != 0) + { + msg_number = 1091; + } if (((gps_eph.i_satellite_PRN != 0) || (gps_cnav_eph.i_satellite_PRN != 0)) && (gal_eph.i_satellite_PRN != 0) && (glo_gnav_eph.i_satellite_PRN != 0)) { LOG(WARNING) << "MSM messages for observables from different systems are not defined"; //print two messages? @@ -2466,10 +2484,22 @@ std::string Rtcm::print_MSM_2(const Gps_Ephemeris& gps_eph, bool more_messages) { uint32_t msg_number = 0; - if (gps_eph.i_satellite_PRN != 0) msg_number = 1072; - if (gps_cnav_eph.i_satellite_PRN != 0) msg_number = 1072; - if (glo_gnav_eph.i_satellite_PRN != 0) msg_number = 1082; - if (gal_eph.i_satellite_PRN != 0) msg_number = 1092; + if (gps_eph.i_satellite_PRN != 0) + { + msg_number = 1072; + } + if (gps_cnav_eph.i_satellite_PRN != 0) + { + msg_number = 1072; + } + if (glo_gnav_eph.i_satellite_PRN != 0) + { + msg_number = 1082; + } + if (gal_eph.i_satellite_PRN != 0) + { + msg_number = 1092; + } if (((gps_eph.i_satellite_PRN != 0) || (gps_cnav_eph.i_satellite_PRN != 0)) && (gal_eph.i_satellite_PRN != 0) && (glo_gnav_eph.i_satellite_PRN != 0)) { LOG(WARNING) << "MSM messages for observables from different systems are not defined"; //print two messages? @@ -2567,10 +2597,22 @@ std::string Rtcm::print_MSM_3(const Gps_Ephemeris& gps_eph, bool more_messages) { uint32_t msg_number = 0; - if (gps_eph.i_satellite_PRN != 0) msg_number = 1073; - if (gps_cnav_eph.i_satellite_PRN != 0) msg_number = 1073; - if (glo_gnav_eph.i_satellite_PRN != 0) msg_number = 1083; - if (gal_eph.i_satellite_PRN != 0) msg_number = 1093; + if (gps_eph.i_satellite_PRN != 0) + { + msg_number = 1073; + } + if (gps_cnav_eph.i_satellite_PRN != 0) + { + msg_number = 1073; + } + if (glo_gnav_eph.i_satellite_PRN != 0) + { + msg_number = 1083; + } + if (gal_eph.i_satellite_PRN != 0) + { + msg_number = 1093; + } if (((gps_eph.i_satellite_PRN != 0) || (gps_cnav_eph.i_satellite_PRN != 0)) && (gal_eph.i_satellite_PRN != 0) && (glo_gnav_eph.i_satellite_PRN != 0)) { LOG(WARNING) << "MSM messages for observables from different systems are not defined"; //print two messages? @@ -2671,10 +2713,22 @@ std::string Rtcm::print_MSM_4(const Gps_Ephemeris& gps_eph, bool more_messages) { uint32_t msg_number = 0; - if (gps_eph.i_satellite_PRN != 0) msg_number = 1074; - if (gps_cnav_eph.i_satellite_PRN != 0) msg_number = 1074; - if (glo_gnav_eph.i_satellite_PRN != 0) msg_number = 1084; - if (gal_eph.i_satellite_PRN != 0) msg_number = 1094; + if (gps_eph.i_satellite_PRN != 0) + { + msg_number = 1074; + } + if (gps_cnav_eph.i_satellite_PRN != 0) + { + msg_number = 1074; + } + if (glo_gnav_eph.i_satellite_PRN != 0) + { + msg_number = 1084; + } + if (gal_eph.i_satellite_PRN != 0) + { + msg_number = 1094; + } if (((gps_eph.i_satellite_PRN != 0) || (gps_cnav_eph.i_satellite_PRN != 0)) && (gal_eph.i_satellite_PRN != 0) && (glo_gnav_eph.i_satellite_PRN != 0)) { LOG(WARNING) << "MSM messages for observables from different systems are not defined"; //print two messages? @@ -2818,10 +2872,22 @@ std::string Rtcm::print_MSM_5(const Gps_Ephemeris& gps_eph, bool more_messages) { uint32_t msg_number = 0; - if (gps_eph.i_satellite_PRN != 0) msg_number = 1075; - if (gps_cnav_eph.i_satellite_PRN != 0) msg_number = 1075; - if (glo_gnav_eph.i_satellite_PRN != 0) msg_number = 1085; - if (gal_eph.i_satellite_PRN != 0) msg_number = 1095; + if (gps_eph.i_satellite_PRN != 0) + { + msg_number = 1075; + } + if (gps_cnav_eph.i_satellite_PRN != 0) + { + msg_number = 1075; + } + if (glo_gnav_eph.i_satellite_PRN != 0) + { + msg_number = 1085; + } + if (gal_eph.i_satellite_PRN != 0) + { + msg_number = 1095; + } if (((gps_eph.i_satellite_PRN != 0) || (gps_cnav_eph.i_satellite_PRN != 0)) && (gal_eph.i_satellite_PRN != 0) && (glo_gnav_eph.i_satellite_PRN != 0)) { LOG(WARNING) << "MSM messages for observables from different systems are not defined"; //print two messages? @@ -2974,10 +3040,22 @@ std::string Rtcm::print_MSM_6(const Gps_Ephemeris& gps_eph, bool more_messages) { uint32_t msg_number = 0; - if (gps_eph.i_satellite_PRN != 0) msg_number = 1076; - if (gps_cnav_eph.i_satellite_PRN != 0) msg_number = 1076; - if (glo_gnav_eph.i_satellite_PRN != 0) msg_number = 1086; - if (gal_eph.i_satellite_PRN != 0) msg_number = 1096; + if (gps_eph.i_satellite_PRN != 0) + { + msg_number = 1076; + } + if (gps_cnav_eph.i_satellite_PRN != 0) + { + msg_number = 1076; + } + if (glo_gnav_eph.i_satellite_PRN != 0) + { + msg_number = 1086; + } + if (gal_eph.i_satellite_PRN != 0) + { + msg_number = 1096; + } if (((gps_eph.i_satellite_PRN != 0) || (gps_cnav_eph.i_satellite_PRN != 0)) && (gal_eph.i_satellite_PRN != 0) && (glo_gnav_eph.i_satellite_PRN != 0)) { LOG(WARNING) << "MSM messages for observables from different systems are not defined"; //print two messages? @@ -3081,10 +3159,22 @@ std::string Rtcm::print_MSM_7(const Gps_Ephemeris& gps_eph, bool more_messages) { uint32_t msg_number = 0; - if (gps_eph.i_satellite_PRN != 0) msg_number = 1077; - if (gps_cnav_eph.i_satellite_PRN != 0) msg_number = 1077; - if (glo_gnav_eph.i_satellite_PRN != 0) msg_number = 1087; - if (gal_eph.i_satellite_PRN != 0) msg_number = 1097; + if (gps_eph.i_satellite_PRN != 0) + { + msg_number = 1077; + } + if (gps_cnav_eph.i_satellite_PRN != 0) + { + msg_number = 1077; + } + if (glo_gnav_eph.i_satellite_PRN != 0) + { + msg_number = 1087; + } + if (gal_eph.i_satellite_PRN != 0) + { + msg_number = 1097; + } if (((gps_eph.i_satellite_PRN != 0) || (gps_cnav_eph.i_satellite_PRN != 0)) && (glo_gnav_eph.i_satellite_PRN != 0) && (gal_eph.i_satellite_PRN != 0)) { LOG(WARNING) << "MSM messages for observables from different systems are not defined"; //print two messages? @@ -3461,13 +3551,34 @@ uint32_t Rtcm::lock_time(const Glonass_Gnav_Ephemeris& eph, double obs_time, con uint32_t Rtcm::lock_time_indicator(uint32_t lock_time_period_s) { // Table 3.4-2 - if (lock_time_period_s <= 0) return 0; - if (lock_time_period_s < 24) return lock_time_period_s; - if (lock_time_period_s < 72) return (lock_time_period_s + 24) / 2; - if (lock_time_period_s < 168) return (lock_time_period_s + 120) / 4; - if (lock_time_period_s < 360) return (lock_time_period_s + 408) / 8; - if (lock_time_period_s < 744) return (lock_time_period_s + 1176) / 16; - if (lock_time_period_s < 937) return (lock_time_period_s + 3096) / 32; + if (lock_time_period_s <= 0) + { + return 0; + } + if (lock_time_period_s < 24) + { + return lock_time_period_s; + } + if (lock_time_period_s < 72) + { + return (lock_time_period_s + 24) / 2; + } + if (lock_time_period_s < 168) + { + return (lock_time_period_s + 120) / 4; + } + if (lock_time_period_s < 360) + { + return (lock_time_period_s + 408) / 8; + } + if (lock_time_period_s < 744) + { + return (lock_time_period_s + 1176) / 16; + } + if (lock_time_period_s < 937) + { + return (lock_time_period_s + 3096) / 32; + } return 127; } @@ -3475,21 +3586,66 @@ uint32_t Rtcm::lock_time_indicator(uint32_t lock_time_period_s) uint32_t Rtcm::msm_lock_time_indicator(uint32_t lock_time_period_s) { // Table 3.5-74 - if (lock_time_period_s < 32) return 0; - if (lock_time_period_s < 64) return 1; - if (lock_time_period_s < 128) return 2; - if (lock_time_period_s < 256) return 3; - if (lock_time_period_s < 512) return 4; - if (lock_time_period_s < 1024) return 5; - if (lock_time_period_s < 2048) return 6; - if (lock_time_period_s < 4096) return 7; - if (lock_time_period_s < 8192) return 8; - if (lock_time_period_s < 16384) return 9; - if (lock_time_period_s < 32768) return 10; - if (lock_time_period_s < 65536) return 11; - if (lock_time_period_s < 131072) return 12; - if (lock_time_period_s < 262144) return 13; - if (lock_time_period_s < 524288) return 14; + if (lock_time_period_s < 32) + { + return 0; + } + if (lock_time_period_s < 64) + { + return 1; + } + if (lock_time_period_s < 128) + { + return 2; + } + if (lock_time_period_s < 256) + { + return 3; + } + if (lock_time_period_s < 512) + { + return 4; + } + if (lock_time_period_s < 1024) + { + return 5; + } + if (lock_time_period_s < 2048) + { + return 6; + } + if (lock_time_period_s < 4096) + { + return 7; + } + if (lock_time_period_s < 8192) + { + return 8; + } + if (lock_time_period_s < 16384) + { + return 9; + } + if (lock_time_period_s < 32768) + { + return 10; + } + if (lock_time_period_s < 65536) + { + return 11; + } + if (lock_time_period_s < 131072) + { + return 12; + } + if (lock_time_period_s < 262144) + { + return 13; + } + if (lock_time_period_s < 524288) + { + return 14; + } return 15; } @@ -3520,8 +3676,8 @@ uint32_t Rtcm::msm_extended_lock_time_indicator(uint32_t lock_time_period_s) if( 16777216 <= lock_time_period_s && lock_time_period_s < 33554432 ) return (640 + (lock_time_period_s - 16777216) / 524288 ); if( 33554432 <= lock_time_period_s && lock_time_period_s < 67108864 ) return (672 + (lock_time_period_s - 33554432) / 1048576); if( 67108864 <= lock_time_period_s ) return (704 ); - return 1023; // will never happen -} + return 1023; // will never happen + } // clang-format on // ***************************************************************************************************** @@ -5182,8 +5338,14 @@ int32_t Rtcm::set_DF399(const Gnss_Synchro& gnss_synchro) } double rough_phase_range_rate_ms = std::round(-gnss_synchro.Carrier_Doppler_hz * lambda); - if (rough_phase_range_rate_ms < -8191) rough_phase_range_rate_ms = -8192; - if (rough_phase_range_rate_ms > 8191) rough_phase_range_rate_ms = -8192; + if (rough_phase_range_rate_ms < -8191) + { + rough_phase_range_rate_ms = -8192; + } + if (rough_phase_range_rate_ms > 8191) + { + rough_phase_range_rate_ms = -8192; + } DF399 = std::bitset<14>(static_cast(rough_phase_range_rate_ms)); return 0; diff --git a/src/algorithms/libs/rtcm.h b/src/algorithms/libs/rtcm.h index 64eeb2d26..d390dc568 100644 --- a/src/algorithms/libs/rtcm.h +++ b/src/algorithms/libs/rtcm.h @@ -553,7 +553,9 @@ private: { body_length_ = new_length; if (body_length_ > max_body_length) - body_length_ = max_body_length; + { + body_length_ = max_body_length; + } } inline bool decode_header() @@ -609,7 +611,9 @@ private: { participants_.insert(participant); for (auto msg : recent_msgs_) - participant->deliver(msg); + { + participant->deliver(msg); + } } inline void leave(const std::shared_ptr& participant) @@ -621,10 +625,14 @@ private: { recent_msgs_.push_back(msg); while (recent_msgs_.size() > max_recent_msgs) - recent_msgs_.pop_front(); + { + recent_msgs_.pop_front(); + } - for (auto participant : participants_) - participant->deliver(msg); + for (const auto& participant : participants_) + { + participant->deliver(msg); + } } private: @@ -854,7 +862,11 @@ private: std::string message; Rtcm_Message msg; queue_->wait_and_pop(message); //message += '\n'; - if (message == "Goodbye") break; + if (message == "Goodbye") + { + break; + } + const char* char_msg = message.c_str(); msg.body_length(message.length()); std::memcpy(msg.body(), char_msg, msg.body_length()); @@ -918,7 +930,10 @@ private: LOG(INFO) << "Serving client from " << remote_addr; } } - if (start_session) std::make_shared(std::move(socket_), room_)->start(); + if (start_session) + { + std::make_shared(std::move(socket_), room_)->start(); + } } else { diff --git a/src/algorithms/libs/rtklib/rtklib.h b/src/algorithms/libs/rtklib/rtklib.h index 7edb5786b..00ba91be2 100644 --- a/src/algorithms/libs/rtklib/rtklib.h +++ b/src/algorithms/libs/rtklib/rtklib.h @@ -343,7 +343,7 @@ const int POSOPT_RINEX = 3; //!< pos option: rinex header pos const int MAXSTRPATH = 1024; //!< max length of stream path const int MAXSTRMSG = 1024; //!< max length of stream message -using fatalfunc_t = void (const char *); //!< fatal callback function type +using fatalfunc_t = void(const char *); //!< fatal callback function type #define STR_MODE_R 0x1 /* stream mode: read */ #define STR_MODE_W 0x2 /* stream mode: write */ diff --git a/src/algorithms/libs/rtklib/rtklib_conversions.cc b/src/algorithms/libs/rtklib/rtklib_conversions.cc index 0f732e3cd..ffd595c44 100644 --- a/src/algorithms/libs/rtklib/rtklib_conversions.cc +++ b/src/algorithms/libs/rtklib/rtklib_conversions.cc @@ -49,8 +49,14 @@ obsd_t insert_obs_to_rtklib(obsd_t& rtklib_obs, const Gnss_Synchro& gnss_synchro break; } double CN0_dB_Hz_est = gnss_synchro.CN0_dB_hz; - if (CN0_dB_Hz_est > 63.75) CN0_dB_Hz_est = 63.75; - if (CN0_dB_Hz_est < 0.0) CN0_dB_Hz_est = 0.0; + if (CN0_dB_Hz_est > 63.75) + { + CN0_dB_Hz_est = 63.75; + } + if (CN0_dB_Hz_est < 0.0) + { + CN0_dB_Hz_est = 0.0; + } auto CN0_dB_Hz = static_cast(std::round(CN0_dB_Hz_est / 0.25)); rtklib_obs.SNR[band] = CN0_dB_Hz; //Galileo is the third satellite system for RTKLIB, so, add the required offset to discriminate Galileo ephemeris diff --git a/src/algorithms/libs/rtklib/rtklib_ephemeris.cc b/src/algorithms/libs/rtklib/rtklib_ephemeris.cc index c942c0d2c..bd72b7f9f 100644 --- a/src/algorithms/libs/rtklib/rtklib_ephemeris.cc +++ b/src/algorithms/libs/rtklib/rtklib_ephemeris.cc @@ -99,8 +99,14 @@ double var_uraeph(int ura) double var_urassr(int ura) { double std_; - if (ura <= 0) return std::pow(DEFURASSR, 2.0); - if (ura >= 63) return std::pow(5.4665, 2.0); + if (ura <= 0) + { + return std::pow(DEFURASSR, 2.0); + } + if (ura >= 63) + { + return std::pow(5.4665, 2.0); + } std_ = (std::pow((ura >> 3) & 7, 2.0) * (1.0 + (ura & 7) / 4.0) - 1.0) * 1e-3; return std::pow(std_, 2.0); } @@ -323,13 +329,25 @@ void glorbit(double t, double *x, const double *acc) int i; deq(x, k1, acc); - for (i = 0; i < 6; i++) w[i] = x[i] + k1[i] * t / 2.0; + for (i = 0; i < 6; i++) + { + w[i] = x[i] + k1[i] * t / 2.0; + } deq(w, k2, acc); - for (i = 0; i < 6; i++) w[i] = x[i] + k2[i] * t / 2.0; + for (i = 0; i < 6; i++) + { + w[i] = x[i] + k2[i] * t / 2.0; + } deq(w, k3, acc); - for (i = 0; i < 6; i++) w[i] = x[i] + k3[i] * t; + for (i = 0; i < 6; i++) + { + w[i] = x[i] + k3[i] * t; + } deq(w, k4, acc); - for (i = 0; i < 6; i++) x[i] += (k1[i] + 2.0 * k2[i] + 2.0 * k3[i] + k4[i]) * t / 6.0; + for (i = 0; i < 6; i++) + { + x[i] += (k1[i] + 2.0 * k2[i] + 2.0 * k3[i] + k4[i]) * t / 6.0; + } } @@ -386,10 +404,16 @@ void geph2pos(gtime_t time, const geph_t *geph, double *rs, double *dts, } for (tt = t < 0.0 ? -TSTEP : TSTEP; fabs(t) > 1e-9; t -= tt) { - if (fabs(t) < TSTEP) tt = t; + if (fabs(t) < TSTEP) + { + tt = t; + } glorbit(tt, x, geph->acc); } - for (i = 0; i < 3; i++) rs[i] = x[i]; + for (i = 0; i < 3; i++) + { + rs[i] = x[i]; + } *var = std::pow(ERREPH_GLO, 2.0); } @@ -476,10 +500,22 @@ eph_t *seleph(gtime_t time, int sat, int iode, const nav_t *nav) for (i = 0; i < nav->n; i++) { - if (nav->eph[i].sat != sat) continue; - if (iode >= 0 && nav->eph[i].iode != iode) continue; - if ((t = fabs(timediff(nav->eph[i].toe, time))) > tmax) continue; - if (iode >= 0) return nav->eph + i; + if (nav->eph[i].sat != sat) + { + continue; + } + if (iode >= 0 && nav->eph[i].iode != iode) + { + continue; + } + if ((t = fabs(timediff(nav->eph[i].toe, time))) > tmax) + { + continue; + } + if (iode >= 0) + { + return nav->eph + i; + } if (t <= tmin) { j = i; @@ -506,10 +542,22 @@ geph_t *selgeph(gtime_t time, int sat, int iode, const nav_t *nav) for (i = 0; i < nav->ng; i++) { - if (nav->geph[i].sat != sat) continue; - if (iode >= 0 && nav->geph[i].iode != iode) continue; - if ((t = fabs(timediff(nav->geph[i].toe, time))) > tmax) continue; - if (iode >= 0) return nav->geph + i; + if (nav->geph[i].sat != sat) + { + continue; + } + if (iode >= 0 && nav->geph[i].iode != iode) + { + continue; + } + if ((t = fabs(timediff(nav->geph[i].toe, time))) > tmax) + { + continue; + } + if (iode >= 0) + { + return nav->geph + i; + } if (t <= tmin) { j = i; @@ -536,8 +584,14 @@ seph_t *selseph(gtime_t time, int sat, const nav_t *nav) for (i = 0; i < nav->ns; i++) { - if (nav->seph[i].sat != sat) continue; - if ((t = fabs(timediff(nav->seph[i].t0, time))) > tmax) continue; + if (nav->seph[i].sat != sat) + { + continue; + } + if ((t = fabs(timediff(nav->seph[i].t0, time))) > tmax) + { + continue; + } if (t <= tmin) { j = i; @@ -568,21 +622,32 @@ int ephclk(gtime_t time, gtime_t teph, int sat, const nav_t *nav, if (sys == SYS_GPS || sys == SYS_GAL || sys == SYS_QZS || sys == SYS_BDS) { - if (!(eph = seleph(teph, sat, -1, nav))) return 0; + if (!(eph = seleph(teph, sat, -1, nav))) + { + return 0; + } *dts = eph2clk(time, eph); } else if (sys == SYS_GLO) { - if (!(geph = selgeph(teph, sat, -1, nav))) return 0; + if (!(geph = selgeph(teph, sat, -1, nav))) + { + return 0; + } *dts = geph2clk(time, geph); } else if (sys == SYS_SBS) { - if (!(seph = selseph(teph, sat, nav))) return 0; + if (!(seph = selseph(teph, sat, nav))) + { + return 0; + } *dts = seph2clk(time, seph); } else - return 0; + { + return 0; + } return 1; } @@ -606,7 +671,10 @@ int ephpos(gtime_t time, gtime_t teph, int sat, const nav_t *nav, if (sys == SYS_GPS || sys == SYS_GAL || sys == SYS_QZS || sys == SYS_BDS) { - if (!(eph = seleph(teph, sat, iode, nav))) return 0; + if (!(eph = seleph(teph, sat, iode, nav))) + { + return 0; + } eph2pos(time, eph, rs, dts, var); time = timeadd(time, tt); @@ -615,7 +683,10 @@ int ephpos(gtime_t time, gtime_t teph, int sat, const nav_t *nav, } else if (sys == SYS_GLO) { - if (!(geph = selgeph(teph, sat, iode, nav))) return 0; + if (!(geph = selgeph(teph, sat, iode, nav))) + { + return 0; + } geph2pos(time, geph, rs, dts, var); time = timeadd(time, tt); geph2pos(time, geph, rst, dtst, var); @@ -623,7 +694,10 @@ int ephpos(gtime_t time, gtime_t teph, int sat, const nav_t *nav, } else if (sys == SYS_SBS) { - if (!(seph = selseph(teph, sat, nav))) return 0; + if (!(seph = selseph(teph, sat, nav))) + { + return 0; + } seph2pos(time, seph, rs, dts, var); time = timeadd(time, tt); @@ -631,10 +705,15 @@ int ephpos(gtime_t time, gtime_t teph, int sat, const nav_t *nav, *svh = seph->svh; } else - return 0; + { + return 0; + } /* satellite velocity and clock drift by differential approx */ - for (i = 0; i < 3; i++) rs[i + 3] = (rst[i] - rs[i]) / tt; + for (i = 0; i < 3; i++) + { + rs[i + 3] = (rst[i] - rs[i]) / tt; + } dts[1] = (dtst[0] - dts[0]) / tt; return 1; @@ -654,7 +733,10 @@ int satpos_sbas(gtime_t time, gtime_t teph, int sat, const nav_t *nav, for (i = 0; i < nav->sbssat.nsat; i++) { sbs = nav->sbssat.sat + i; - if (sbs->sat == sat) break; + if (sbs->sat == sat) + { + break; + } } if (i >= nav->sbssat.nsat) { @@ -664,10 +746,16 @@ int satpos_sbas(gtime_t time, gtime_t teph, int sat, const nav_t *nav, return 0; } /* satellite position and clock by broadcast ephemeris */ - if (!ephpos(time, teph, sat, nav, sbs->lcorr.iode, rs, dts, var, svh)) return 0; + if (!ephpos(time, teph, sat, nav, sbs->lcorr.iode, rs, dts, var, svh)) + { + return 0; + } /* sbas satellite correction (long term and fast) */ - if (sbssatcorr(time, sat, nav, rs, dts, var)) return 1; + if (sbssatcorr(time, sat, nav, rs, dts, var)) + { + return 1; + } *svh = -1; return 0; } @@ -716,10 +804,19 @@ int satpos_ssr(gtime_t time, gtime_t teph, int sat, const nav_t *nav, *svh = -1; return 0; } - if (ssr->udi[0] >= 1.0) t1 -= ssr->udi[0] / 2.0; - if (ssr->udi[1] >= 1.0) t2 -= ssr->udi[0] / 2.0; + if (ssr->udi[0] >= 1.0) + { + t1 -= ssr->udi[0] / 2.0; + } + if (ssr->udi[1] >= 1.0) + { + t2 -= ssr->udi[0] / 2.0; + } - for (i = 0; i < 3; i++) deph[i] = ssr->deph[i] + ssr->ddeph[i] * t1; + for (i = 0; i < 3; i++) + { + deph[i] = ssr->deph[i] + ssr->ddeph[i] * t1; + } dclk = ssr->dclk[0] + ssr->dclk[1] * t2 + ssr->dclk[2] * t2 * t2; /* ssr highrate clock correction (ref [4]) */ @@ -735,13 +832,19 @@ int satpos_ssr(gtime_t time, gtime_t teph, int sat, const nav_t *nav, return 0; } /* satellite position and clock by broadcast ephemeris */ - if (!ephpos(time, teph, sat, nav, ssr->iode, rs, dts, var, svh)) return 0; + if (!ephpos(time, teph, sat, nav, ssr->iode, rs, dts, var, svh)) + { + return 0; + } /* satellite clock for gps, galileo and qzss */ sys = satsys(sat, nullptr); if (sys == SYS_GPS || sys == SYS_GAL || sys == SYS_QZS || sys == SYS_BDS) { - if (!(eph = seleph(teph, sat, ssr->iode, nav))) return 0; + if (!(eph = seleph(teph, sat, ssr->iode, nav))) + { + return 0; + } /* satellite clock by clock parameters */ tk = timediff(time, eph->toc); @@ -752,7 +855,10 @@ int satpos_ssr(gtime_t time, gtime_t teph, int sat, const nav_t *nav, dts[0] -= 2.0 * dot(rs, rs + 3, 3) / SPEED_OF_LIGHT / SPEED_OF_LIGHT; } /* radial-along-cross directions in ecef */ - if (!normv3(rs + 3, ea)) return 0; + if (!normv3(rs + 3, ea)) + { + return 0; + } cross3(rs, rs + 3, rc); if (!normv3(rc, ec)) { @@ -819,9 +925,13 @@ int satpos(gtime_t time, gtime_t teph, int sat, int ephopt, return satpos_ssr(time, teph, sat, nav, 1, rs, dts, var, svh); case EPHOPT_PREC: if (!peph2pos(time, sat, nav, 1, rs, dts, var)) - break; + { + break; + } else - return 1; + { + return 1; + } //TODO: enable lex //case EPHOPT_LEX : // if (!lexeph2pos(time, sat, nav, rs, dts, var)) break; else return 1; @@ -866,14 +976,25 @@ void satposs(gtime_t teph, const obsd_t *obs, int n, const nav_t *nav, for (i = 0; i < n && i < MAXOBS; i++) { - for (j = 0; j < 6; j++) rs[j + i * 6] = 0.0; - for (j = 0; j < 2; j++) dts[j + i * 2] = 0.0; + for (j = 0; j < 6; j++) + { + rs[j + i * 6] = 0.0; + } + for (j = 0; j < 2; j++) + { + dts[j + i * 2] = 0.0; + } var[i] = 0.0; svh[i] = 0; /* search any pseudorange */ for (j = 0, pr = 0.0; j < NFREQ; j++) - if ((pr = obs[i].P[j]) != 0.0) break; + { + if ((pr = obs[i].P[j]) != 0.0) + { + break; + } + } if (j >= NFREQ) { @@ -901,7 +1022,10 @@ void satposs(gtime_t teph, const obsd_t *obs, int n, const nav_t *nav, /* if no precise clock available, use broadcast clock instead */ if (dts[i * 2] == 0.0) { - if (!ephclk(time[i], teph, obs[i].sat, nav, dts + i * 2)) continue; + if (!ephclk(time[i], teph, obs[i].sat, nav, dts + i * 2)) + { + continue; + } dts[1 + i * 2] = 0.0; *var = std::pow(STD_BRDCCLK, 2.0); } diff --git a/src/algorithms/libs/rtklib/rtklib_ionex.cc b/src/algorithms/libs/rtklib/rtklib_ionex.cc index ab02c788f..8ba2bb950 100644 --- a/src/algorithms/libs/rtklib/rtklib_ionex.cc +++ b/src/algorithms/libs/rtklib/rtklib_ionex.cc @@ -64,9 +64,18 @@ /* get index -----------------------------------------------------------------*/ int getindex(double value, const double *range) { - if (range[2] == 0.0) return 0; - if (range[1] > 0.0 && (value < range[0] || range[1] < value)) return -1; - if (range[1] < 0.0 && (value < range[1] || range[0] < value)) return -1; + if (range[2] == 0.0) + { + return 0; + } + if (range[1] > 0.0 && (value < range[0] || range[1] < value)) + { + return -1; + } + if (range[1] < 0.0 && (value < range[1] || range[0] < value)) + { + return -1; + } return static_cast(floor((value - range[0]) / range[2] + 0.5)); } @@ -81,7 +90,10 @@ int nitem(const double *range) /* data index (i:lat,j:lon,k:hgt) --------------------------------------------*/ int dataindex(int i, int j, int k, const int *ndata) { - if (i < 0 || ndata[0] <= i || j < 0 || ndata[1] <= j || k < 0 || ndata[2] <= k) return -1; + if (i < 0 || ndata[0] <= i || j < 0 || ndata[1] <= j || k < 0 || ndata[2] <= k) + { + return -1; + } return i + ndata[0] * (j + ndata[1] * k); } @@ -99,7 +111,10 @@ tec_t *addtec(const double *lats, const double *lons, const double *hgts, ndata[0] = nitem(lats); ndata[1] = nitem(lons); ndata[2] = nitem(hgts); - if (ndata[0] <= 1 || ndata[1] <= 1 || ndata[2] <= 0) return nullptr; + if (ndata[0] <= 1 || ndata[1] <= 1 || ndata[2] <= 0) + { + return nullptr; + } if (nav->nt >= nav->ntmax) { @@ -149,11 +164,17 @@ void readionexdcb(FILE *fp, double *dcb, double *rms) trace(3, "readionexdcb:\n"); - for (i = 0; i < MAXSAT; i++) dcb[i] = rms[i] = 0.0; + for (i = 0; i < MAXSAT; i++) + { + dcb[i] = rms[i] = 0.0; + } while (fgets(buff, sizeof(buff), fp)) { - if (strlen(buff) < 60) continue; + if (strlen(buff) < 60) + { + continue; + } label = buff + 60; if (strstr(label, "PRN / BIAS / RMS") == label) @@ -170,7 +191,9 @@ void readionexdcb(FILE *fp, double *dcb, double *rms) rms[sat - 1] = str2num(buff, 16, 10); } else if (strstr(label, "END OF AUX DATA") == label) - break; + { + break; + } } } @@ -186,12 +209,18 @@ double readionexh(FILE *fp, double *lats, double *lons, double *hgts, while (fgets(buff, sizeof(buff), fp)) { - if (strlen(buff) < 60) continue; + if (strlen(buff) < 60) + { + continue; + } label = buff + 60; if (strstr(label, "IONEX VERSION / TYPE") == label) { - if (buff[20] == 'I') ver = str2num(buff, 0, 8); + if (buff[20] == 'I') + { + ver = str2num(buff, 0, 8); + } } else if (strstr(label, "BASE RADIUS") == label) { @@ -247,11 +276,17 @@ int readionexb(FILE *fp, const double *lats, const double *lons, while (fgets(buff, sizeof(buff), fp)) { - if (strlen(buff) < 60) continue; + if (strlen(buff) < 60) + { + continue; + } if (strstr(label, "START OF TEC MAP") == label) { - if ((p = addtec(lats, lons, hgts, rb, nav))) type = 1; + if ((p = addtec(lats, lons, hgts, rb, nav))) + { + type = 1; + } } else if (strstr(label, "END OF TEC MAP") == label) { @@ -279,13 +314,18 @@ int readionexb(FILE *fp, const double *lats, const double *lons, { for (i = nav->nt - 1; i >= 0; i--) { - if (fabs(timediff(time, nav->tec[i].time)) >= 1.0) continue; + if (fabs(timediff(time, nav->tec[i].time)) >= 1.0) + { + continue; + } p = nav->tec + i; break; } } else if (p) - p->time = time; + { + p->time = time; + } } else if (strstr(label, "LAT/LON1/LON2/DLON/H") == label && p) { @@ -301,17 +341,30 @@ int readionexb(FILE *fp, const double *lats, const double *lons, for (m = 0; m < n; m++) { - if (m % 16 == 0 && !fgets(buff, sizeof(buff), fp)) break; + if (m % 16 == 0 && !fgets(buff, sizeof(buff), fp)) + { + break; + } j = getindex(lon[0] + lon[2] * m, p->lons); - if ((index = dataindex(i, j, k, p->ndata)) < 0) continue; + if ((index = dataindex(i, j, k, p->ndata)) < 0) + { + continue; + } - if ((x = str2num(buff, m % 16 * 5, 5)) == 9999.0) continue; + if ((x = str2num(buff, m % 16 * 5, 5)) == 9999.0) + { + continue; + } if (type == 1) - p->data[index] = x * std::pow(10.0, nexp); + { + p->data[index] = x * std::pow(10.0, nexp); + } else - p->rms[index] = static_cast(x * std::pow(10.0, nexp)); + { + p->rms[index] = static_cast(x * std::pow(10.0, nexp)); + } } } } @@ -387,7 +440,10 @@ void readtec(const char *file, nav_t *nav, int opt) { if (!(efiles[i] = static_cast(malloc(1024)))) { - for (i--; i >= 0; i--) free(efiles[i]); + for (i--; i >= 0; i--) + { + free(efiles[i]); + } return; } } @@ -414,10 +470,16 @@ void readtec(const char *file, nav_t *nav, int opt) readionexb(fp, lats, lons, hgts, rb, nexp, nav); fclose(fp); } - for (i = 0; i < MAXEXFILE; i++) free(efiles[i]); + for (i = 0; i < MAXEXFILE; i++) + { + free(efiles[i]); + } /* combine tec grid data */ - if (nav->nt > 0) combtec(nav); + if (nav->nt > 0) + { + combtec(nav); + } /* P1-P2 dcb */ for (i = 0; i < MAXSAT; i++) @@ -437,14 +499,21 @@ int interptec(const tec_t *tec, int k, const double *posp, double *value, trace(3, "interptec: k=%d posp=%.2f %.2f\n", k, posp[0] * R2D, posp[1] * R2D); *value = *rms = 0.0; - if (tec->lats[2] == 0.0 || tec->lons[2] == 0.0) return 0; + if (tec->lats[2] == 0.0 || tec->lons[2] == 0.0) + { + return 0; + } dlat = posp[0] * R2D - tec->lats[0]; dlon = posp[1] * R2D - tec->lons[0]; if (tec->lons[2] > 0.0) - dlon -= floor(dlon / 360) * 360.0; /* 0 <= dlon<360 */ + { + dlon -= floor(dlon / 360) * 360.0; /* 0 <= dlon<360 */ + } else - dlon += floor(-dlon / 360) * 360.0; /* -360lats[2]; b = dlon / tec->lons[2]; @@ -456,7 +525,10 @@ int interptec(const tec_t *tec, int k, const double *posp, double *value, /* get gridded tec data */ for (n = 0; n < 4; n++) { - if ((index = dataindex(i + (n % 2), j + (n < 2 ? 0 : 1), k, tec->ndata)) < 0) continue; + if ((index = dataindex(i + (n % 2), j + (n < 2 ? 0 : 1), k, tec->ndata)) < 0) + { + continue; + } d[n] = tec->data[index]; r[n] = tec->rms[index]; } @@ -491,13 +563,18 @@ int interptec(const tec_t *tec, int k, const double *posp, double *value, { i = 0; for (n = 0; n < 4; n++) - if (d[n] > 0.0) - { - i++; - *value += d[n]; - *rms += r[n]; - } - if (i == 0) return 0; + { + if (d[n] > 0.0) + { + i++; + *value += d[n]; + *rms += r[n]; + } + } + if (i == 0) + { + return 0; + } *value /= i; *rms /= i; } @@ -537,7 +614,10 @@ int iondelay(gtime_t time, const tec_t *tec, const double *pos, posp[1] += 2.0 * PI * timediff(time, tec->time) / 86400.0; } /* interpolate tec grid data */ - if (!interptec(tec, i, posp, &vtec, &rms)) return 0; + if (!interptec(tec, i, posp, &vtec, &rms)) + { + return 0; + } *delay += fact * fs * vtec; *var += fact * fact * fs * fs * rms * rms; @@ -580,7 +660,10 @@ int iontec(gtime_t time, const nav_t *nav, const double *pos, } for (i = 0; i < nav->nt; i++) { - if (timediff(nav->tec[i].time, time) > 0.0) break; + if (timediff(nav->tec[i].time, time) > 0.0) + { + break; + } } if (i == 0 || i >= nav->nt) { diff --git a/src/algorithms/libs/rtklib/rtklib_lambda.cc b/src/algorithms/libs/rtklib/rtklib_lambda.cc index c493e05e5..8aaba735f 100644 --- a/src/algorithms/libs/rtklib/rtklib_lambda.cc +++ b/src/algorithms/libs/rtklib/rtklib_lambda.cc @@ -69,13 +69,27 @@ int LD(int n, const double *Q, double *L, double *D) break; } a = sqrt(D[i]); - for (j = 0; j <= i; j++) L[i + j * n] = A[i + j * n] / a; + for (j = 0; j <= i; j++) + { + L[i + j * n] = A[i + j * n] / a; + } for (j = 0; j <= i - 1; j++) - for (k = 0; k <= j; k++) A[j + k * n] -= L[i + k * n] * L[i + j * n]; - for (j = 0; j <= i; j++) L[i + j * n] /= L[i + i * n]; + { + for (k = 0; k <= j; k++) + { + A[j + k * n] -= L[i + k * n] * L[i + j * n]; + } + } + for (j = 0; j <= i; j++) + { + L[i + j * n] /= L[i + i * n]; + } } free(A); - if (info) fprintf(stderr, "%s : LD factorization error\n", __FILE__); + if (info) + { + fprintf(stderr, "%s : LD factorization error\n", __FILE__); + } return info; } @@ -87,8 +101,14 @@ void gauss(int n, double *L, double *Z, int i, int j) if ((mu = static_cast ROUND_LAMBDA(L[i + j * n])) != 0) { - for (k = i; k < n; k++) L[k + n * j] -= static_cast(mu) * L[k + i * n]; - for (k = 0; k < n; k++) Z[k + n * j] -= static_cast(mu) * Z[k + i * n]; + for (k = i; k < n; k++) + { + L[k + n * j] -= static_cast(mu) * L[k + i * n]; + } + for (k = 0; k < n; k++) + { + Z[k + n * j] -= static_cast(mu) * Z[k + i * n]; + } } } @@ -111,8 +131,14 @@ void perm(int n, double *L, double *D, int j, double del, double *Z) L[j + 1 + k * n] = eta * a0 + lam * a1; } L[j + 1 + j * n] = lam; - for (k = j + 2; k < n; k++) SWAP_LAMBDA(L[k + j * n], L[k + (j + 1) * n]); - for (k = 0; k < n; k++) SWAP_LAMBDA(Z[k + j * n], Z[k + (j + 1) * n]); + for (k = j + 2; k < n; k++) + { + SWAP_LAMBDA(L[k + j * n], L[k + (j + 1) * n]); + } + for (k = 0; k < n; k++) + { + SWAP_LAMBDA(Z[k + j * n], Z[k + (j + 1) * n]); + } } @@ -127,7 +153,12 @@ void reduction(int n, double *L, double *D, double *Z) while (j >= 0) { if (j <= k) - for (i = j + 1; i < n; i++) gauss(n, L, Z, i, j); + { + for (i = j + 1; i < n; i++) + { + gauss(n, L, Z, i, j); + } + } del = D[j] + L[j + 1 + j * n] * L[j + 1 + j * n] * D[j + 1]; if (del + 1E-6 < D[j + 1]) { /* compared considering numerical error */ @@ -136,7 +167,9 @@ void reduction(int n, double *L, double *D, double *Z) j = n - 2; } else - j--; + { + j--; + } } } @@ -164,7 +197,9 @@ int search(int n, int m, const double *L, const double *D, { dist[--k] = newdist; for (i = 0; i <= k; i++) - S[k + i * n] = S[k + 1 + i * n] + (z[k + 1] - zb[k + 1]) * L[k + 1 + i * n]; + { + S[k + i * n] = S[k + 1 + i * n] + (z[k + 1] - zb[k + 1]) * L[k + 1 + i * n]; + } zb[k] = zs[k] + S[k + k * n]; z[k] = ROUND_LAMBDA(zb[k]); y = zb[k] - z[k]; @@ -174,18 +209,32 @@ int search(int n, int m, const double *L, const double *D, { if (nn < m) { - if (nn == 0 || newdist > s[imax]) imax = nn; - for (i = 0; i < n; i++) zn[i + nn * n] = z[i]; + if (nn == 0 || newdist > s[imax]) + { + imax = nn; + } + for (i = 0; i < n; i++) + { + zn[i + nn * n] = z[i]; + } s[nn++] = newdist; } else { if (newdist < s[imax]) { - for (i = 0; i < n; i++) zn[i + imax * n] = z[i]; + for (i = 0; i < n; i++) + { + zn[i + imax * n] = z[i]; + } s[imax] = newdist; for (i = imax = 0; i < m; i++) - if (s[imax] < s[i]) imax = i; + { + if (s[imax] < s[i]) + { + imax = i; + } + } } maxdist = s[imax]; } @@ -197,7 +246,9 @@ int search(int n, int m, const double *L, const double *D, else { if (k == n - 1) - break; + { + break; + } k++; z[k] += step[k]; @@ -209,9 +260,15 @@ int search(int n, int m, const double *L, const double *D, { /* sort by s */ for (j = i + 1; j < m; j++) { - if (s[i] < s[j]) continue; + if (s[i] < s[j]) + { + continue; + } SWAP_LAMBDA(s[i], s[j]); - for (k = 0; k < n; k++) SWAP_LAMBDA(zn[k + i * n], zn[k + j * n]); + for (k = 0; k < n; k++) + { + SWAP_LAMBDA(zn[k + i * n], zn[k + j * n]); + } } } free(S); @@ -247,7 +304,10 @@ int lambda(int n, int m, const double *a, const double *Q, double *F, int info; double *L, *D, *Z, *z, *E; - if (n <= 0 || m <= 0) return -1; + if (n <= 0 || m <= 0) + { + return -1; + } L = zeros(n, n); D = mat(n, 1); Z = eye(n); @@ -288,16 +348,21 @@ int lambda_reduction(int n, const double *Q, double *Z) double *L, *D; int i, j, info; - if (n <= 0) return -1; + if (n <= 0) + { + return -1; + } L = zeros(n, n); D = mat(n, 1); for (i = 0; i < n; i++) - for (j = 0; j < n; j++) - { - Z[i + j * n] = i == j ? 1.0 : 0.0; - } + { + for (j = 0; j < n; j++) + { + Z[i + j * n] = i == j ? 1.0 : 0.0; + } + } /* LD factorization */ if ((info = LD(n, Q, L, D))) { @@ -330,7 +395,10 @@ int lambda_search(int n, int m, const double *a, const double *Q, double *L, *D; int info; - if (n <= 0 || m <= 0) return -1; + if (n <= 0 || m <= 0) + { + return -1; + } L = zeros(n, n); D = mat(n, 1); diff --git a/src/algorithms/libs/rtklib/rtklib_pntpos.cc b/src/algorithms/libs/rtklib/rtklib_pntpos.cc index d143cb302..58c1192e5 100644 --- a/src/algorithms/libs/rtklib/rtklib_pntpos.cc +++ b/src/algorithms/libs/rtklib/rtklib_pntpos.cc @@ -62,7 +62,10 @@ double varerr(const prcopt_t *opt, double el, int sys) double fact, varr; fact = sys == SYS_GLO ? EFACT_GLO : (sys == SYS_SBS ? EFACT_SBS : EFACT_GPS); varr = std::pow(opt->err[0], 2.0) * (std::pow(opt->err[1], 2.0) + std::pow(opt->err[2], 2.0) / sin(el)); - if (opt->ionoopt == IONOOPT_IFLC) varr *= std::pow(2, 3.0); /* iono-free */ + if (opt->ionoopt == IONOOPT_IFLC) + { + varr *= std::pow(2, 3.0); /* iono-free */ + } return std::pow(fact, 2.0) * varr; } @@ -73,7 +76,10 @@ double gettgd(int sat, const nav_t *nav) int i; for (i = 0; i < nav->n; i++) { - if (nav->eph[i].sat != sat) continue; + if (nav->eph[i].sat != sat) + { + continue; + } return SPEED_OF_LIGHT * nav->eph[i].tgd[0]; } return 0.0; @@ -84,7 +90,10 @@ double getiscl1(int sat, const nav_t *nav) { for (int i = 0; i < nav->n; i++) { - if (nav->eph[i].sat != sat) continue; + if (nav->eph[i].sat != sat) + { + continue; + } return SPEED_OF_LIGHT * nav->eph[i].isc[0]; } return 0.0; @@ -94,7 +103,10 @@ double getiscl2(int sat, const nav_t *nav) { for (int i = 0; i < nav->n; i++) { - if (nav->eph[i].sat != sat) continue; + if (nav->eph[i].sat != sat) + { + continue; + } return SPEED_OF_LIGHT * nav->eph[i].isc[1]; } return 0.0; @@ -104,7 +116,10 @@ double getiscl5i(int sat, const nav_t *nav) { for (int i = 0; i < nav->n; i++) { - if (nav->eph[i].sat != sat) continue; + if (nav->eph[i].sat != sat) + { + continue; + } return SPEED_OF_LIGHT * nav->eph[i].isc[2]; } return 0.0; @@ -114,7 +129,10 @@ double getiscl5q(int sat, const nav_t *nav) { for (int i = 0; i < nav->n; i++) { - if (nav->eph[i].sat != sat) continue; + if (nav->eph[i].sat != sat) + { + continue; + } return SPEED_OF_LIGHT * nav->eph[i].isc[3]; } return 0.0; @@ -407,7 +425,10 @@ int rescode(int iter, const obsd_t *obs, int n, const double *rs, trace(3, "resprng : n=%d\n", n); - for (i = 0; i < 3; i++) rr[i] = x[i]; + for (i = 0; i < 3; i++) + { + rr[i] = x[i]; + } dtr = x[3]; ecef2pos(rr, pos); @@ -417,7 +438,10 @@ int rescode(int iter, const obsd_t *obs, int n, const double *rs, vsat[i] = 0; azel[i * 2] = azel[1 + i * 2] = resp[i] = 0.0; - if (!(sys = satsys(obs[i].sat, nullptr))) continue; + if (!(sys = satsys(obs[i].sat, nullptr))) + { + continue; + } /* reject duplicated observation data */ if (i < n - 1 && i < MAXOBS - 1 && obs[i].sat == obs[i + 1].sat) @@ -477,7 +501,10 @@ int rescode(int iter, const obsd_t *obs, int n, const double *rs, v[nv] = P - (r + dtr - SPEED_OF_LIGHT * dts[i * 2] + dion + dtrp); /* design matrix */ - for (j = 0; j < NX; j++) H[j + nv * NX] = j < 3 ? -e[j] : (j == 3 ? 1.0 : 0.0); + for (j = 0; j < NX; j++) + { + H[j + nv * NX] = j < 3 ? -e[j] : (j == 3 ? 1.0 : 0.0); + } /* time system and receiver bias offset correction */ if (sys == SYS_GLO) @@ -499,7 +526,9 @@ int rescode(int iter, const obsd_t *obs, int n, const double *rs, mask[3] = 1; } else - mask[0] = 1; + { + mask[0] = 1; + } vsat[i] = 1; resp[i] = v[nv]; @@ -514,9 +543,15 @@ int rescode(int iter, const obsd_t *obs, int n, const double *rs, /* constraint to avoid rank-deficient */ for (i = 0; i < 4; i++) { - if (mask[i]) continue; + if (mask[i]) + { + continue; + } v[nv] = 0.0; - for (j = 0; j < NX; j++) H[j + nv * NX] = j == i + 3 ? 1.0 : 0.0; + for (j = 0; j < NX; j++) + { + H[j + nv * NX] = j == i + 3 ? 1.0 : 0.0; + } var[nv++] = 0.01; } return nv; @@ -544,7 +579,10 @@ int valsol(const double *azel, const int *vsat, int n, /* large gdop check */ for (i = ns = 0; i < n; i++) { - if (!vsat[i]) continue; + if (!vsat[i]) + { + continue; + } azels[ns * 2] = azel[i * 2]; azels[1 + ns * 2] = azel[1 + i * 2]; ns++; @@ -574,7 +612,10 @@ int estpos(const obsd_t *obs, int n, const double *rs, const double *dts, H = mat(NX, n + 4); var = mat(n + 4, 1); - for (i = 0; i < 3; i++) x[i] = sol->rr[i]; + for (i = 0; i < 3; i++) + { + x[i] = sol->rr[i]; + } for (i = 0; i < MAXITR; i++) { @@ -591,7 +632,10 @@ int estpos(const obsd_t *obs, int n, const double *rs, const double *dts, { sig = sqrt(var[j]); v[j] /= sig; - for (k = 0; k < NX; k++) H[k + j * NX] /= sig; + for (k = 0; k < NX; k++) + { + H[k + j * NX] /= sig; + } } /* least square estimation */ if ((info = lsq(H, v, NX, nv, dx, Q))) @@ -599,7 +643,10 @@ int estpos(const obsd_t *obs, int n, const double *rs, const double *dts, sprintf(msg, "lsq error info=%d", info); break; } - for (j = 0; j < NX; j++) x[j] += dx[j]; + for (j = 0; j < NX; j++) + { + x[j] += dx[j]; + } if (norm_rtk(dx, NX) < 1e-4) { @@ -609,8 +656,14 @@ int estpos(const obsd_t *obs, int n, const double *rs, const double *dts, sol->dtr[1] = x[4] / SPEED_OF_LIGHT; /* glo-gps time offset (s) */ sol->dtr[2] = x[5] / SPEED_OF_LIGHT; /* gal-gps time offset (s) */ sol->dtr[3] = x[6] / SPEED_OF_LIGHT; /* bds-gps time offset (s) */ - for (j = 0; j < 6; j++) sol->rr[j] = j < 3 ? x[j] : 0.0; - for (j = 0; j < 3; j++) sol->qr[j] = static_cast(Q[j + j * NX]); + for (j = 0; j < 6; j++) + { + sol->rr[j] = j < 3 ? x[j] : 0.0; + } + for (j = 0; j < 3; j++) + { + sol->qr[j] = static_cast(Q[j + j * NX]); + } sol->qr[3] = static_cast(Q[1]); /* cov xy */ sol->qr[4] = static_cast(Q[2 + NX]); /* cov yz */ sol->qr[5] = static_cast(Q[2]); /* cov zx */ @@ -629,7 +682,10 @@ int estpos(const obsd_t *obs, int n, const double *rs, const double *dts, return stat; } } - if (i >= MAXITR) sprintf(msg, "iteration divergent i=%d", i); + if (i >= MAXITR) + { + sprintf(msg, "iteration divergent i=%d", i); + } free(v); free(H); @@ -653,7 +709,10 @@ int raim_fde(const obsd_t *obs, int n, const double *rs, trace(3, "raim_fde: %s n=%2d\n", time_str(obs[0].time, 0), n); - if (!(obs_e = static_cast(malloc(sizeof(obsd_t) * n)))) return 0; + if (!(obs_e = static_cast(malloc(sizeof(obsd_t) * n)))) + { + return 0; + } rs_e = mat(6, n); dts_e = mat(2, n); vare_e = mat(1, n); @@ -667,7 +726,10 @@ int raim_fde(const obsd_t *obs, int n, const double *rs, /* satellite exclution */ for (j = k = 0; j < n; j++) { - if (j == i) continue; + if (j == i) + { + continue; + } obs_e[k] = obs[j]; matcpy(rs_e + 6 * k, rs + 6 * j, 6, 1); matcpy(dts_e + 2 * k, dts + 2 * j, 2, 1); @@ -683,7 +745,10 @@ int raim_fde(const obsd_t *obs, int n, const double *rs, } for (j = nvsat = 0, rms_e = 0.0; j < n - 1; j++) { - if (!vsat_e[j]) continue; + if (!vsat_e[j]) + { + continue; + } rms_e += std::pow(resp_e[j], 2.0); nvsat++; } @@ -697,12 +762,18 @@ int raim_fde(const obsd_t *obs, int n, const double *rs, trace(3, "raim_fde: exsat=%2d rms=%8.3f\n", obs[i].sat, rms_e); - if (rms_e > rms) continue; + if (rms_e > rms) + { + continue; + } /* save result */ for (j = k = 0; j < n; j++) { - if (j == i) continue; + if (j == i) + { + continue; + } matcpy(azel + 2 * j, azel_e + 2 * k, 2, 1); vsat[j] = vsat_e[k]; resp[j] = resp_e[k++]; @@ -749,9 +820,18 @@ int resdop(const obsd_t *obs, int n, const double *rs, const double *dts, for (i = 0; i < n && i < MAXOBS; i++) { - if (obs[i].code[0] != CODE_NONE) band = 0; - if (obs[i].code[1] != CODE_NONE) band = 1; - if (obs[i].code[2] != CODE_NONE) band = 2; + if (obs[i].code[0] != CODE_NONE) + { + band = 0; + } + if (obs[i].code[1] != CODE_NONE) + { + band = 1; + } + if (obs[i].code[2] != CODE_NONE) + { + band = 2; + } lam = nav->lam[obs[i].sat - 1][band]; if (obs[i].D[band] == 0.0 || lam == 0.0 || !vsat[i] || norm_rtk(rs + 3 + i * 6, 3) <= 0.0) @@ -766,7 +846,10 @@ int resdop(const obsd_t *obs, int n, const double *rs, const double *dts, matmul("TN", 3, 1, 3, 1.0, E, a, 0.0, e); /* satellite velocity relative to receiver in ecef */ - for (j = 0; j < 3; j++) vs[j] = rs[j + 3 + i * 6] - x[j]; + for (j = 0; j < 3; j++) + { + vs[j] = rs[j + 3 + i * 6] - x[j]; + } /* range rate with earth rotation correction */ rate = dot(vs, e, 3) + DEFAULT_OMEGA_EARTH_DOT / SPEED_OF_LIGHT * (rs[4 + i * 6] * rr[0] + rs[1 + i * 6] * x[0] - rs[3 + i * 6] * rr[1] - rs[i * 6] * x[1]); @@ -775,7 +858,10 @@ int resdop(const obsd_t *obs, int n, const double *rs, const double *dts, v[nv] = -lam * obs[i].D[band] - (rate + x[3] - SPEED_OF_LIGHT * dts[1 + i * 2]); /* design matrix */ - for (j = 0; j < 4; j++) H[j + nv * 4] = j < 3 ? -e[j] : 1.0; + for (j = 0; j < 4; j++) + { + H[j + nv * 4] = j < 3 ? -e[j] : 1.0; + } nv++; } @@ -804,13 +890,22 @@ void estvel(const obsd_t *obs, int n, const double *rs, const double *dts, break; } /* least square estimation */ - if (lsq(H, v, 4, nv, dx, Q)) break; + if (lsq(H, v, 4, nv, dx, Q)) + { + break; + } - for (j = 0; j < 4; j++) x[j] += dx[j]; + for (j = 0; j < 4; j++) + { + x[j] += dx[j]; + } if (norm_rtk(dx, 4) < 1e-6) { - for (i = 0; i < 3; i++) sol->rr[i + 3] = x[i]; + for (i = 0; i < 3; i++) + { + sol->rr[i + 3] = x[i]; + } break; } } @@ -882,11 +977,17 @@ int pntpos(const obsd_t *obs, int n, const nav_t *nav, stat = raim_fde(obs, n, rs, dts, var, svh, nav, &opt_, sol, azel_, vsat, resp, msg); } /* estimate receiver velocity with doppler */ - if (stat) estvel(obs, n, rs, dts, nav, &opt_, sol, azel_, vsat); + if (stat) + { + estvel(obs, n, rs, dts, nav, &opt_, sol, azel_, vsat); + } if (azel) { - for (i = 0; i < n * 2; i++) azel[i] = azel_[i]; + for (i = 0; i < n * 2; i++) + { + azel[i] = azel_[i]; + } } if (ssat) { @@ -902,7 +1003,10 @@ int pntpos(const obsd_t *obs, int n, const nav_t *nav, ssat[obs[i].sat - 1].azel[0] = azel_[i * 2]; ssat[obs[i].sat - 1].azel[1] = azel_[1 + i * 2]; ssat[obs[i].sat - 1].snr[0] = obs[i].SNR[0]; - if (!vsat[i]) continue; + if (!vsat[i]) + { + continue; + } ssat[obs[i].sat - 1].vs = 1; ssat[obs[i].sat - 1].resp[0] = resp[i]; } diff --git a/src/algorithms/libs/rtklib/rtklib_ppp.cc b/src/algorithms/libs/rtklib/rtklib_ppp.cc index d6bbed928..9f7ee252f 100644 --- a/src/algorithms/libs/rtklib/rtklib_ppp.cc +++ b/src/algorithms/libs/rtklib/rtklib_ppp.cc @@ -117,8 +117,14 @@ double p_gamma(double a, double x, double log_gamma_a) double y, w; int i; - if (x == 0.0) return 0.0; - if (x >= a + 1.0) return 1.0 - q_gamma(a, x, log_gamma_a); + if (x == 0.0) + { + return 0.0; + } + if (x >= a + 1.0) + { + return 1.0 - q_gamma(a, x, log_gamma_a); + } y = w = exp(a * log(x) - x - log_gamma_a) / a; @@ -126,7 +132,10 @@ double p_gamma(double a, double x, double log_gamma_a) { w *= x / (a + i); y += w; - if (fabs(w) < 1E-15) break; + if (fabs(w) < 1E-15) + { + break; + } } return y; } @@ -137,7 +146,10 @@ double q_gamma(double a, double x, double log_gamma_a) double y, w, la = 1.0, lb = x + 1.0 - a, lc; int i; - if (x < a + 1.0) return 1.0 - p_gamma(a, x, log_gamma_a); + if (x < a + 1.0) + { + return 1.0 - p_gamma(a, x, log_gamma_a); + } w = exp(-x + a * log(x) - log_gamma_a); y = w / lb; for (i = 2; i < 100; i++) @@ -147,7 +159,10 @@ double q_gamma(double a, double x, double log_gamma_a) lb = lc; w *= (i - 1 - a) / i; y += w / la / lb; - if (fabs(w / la / lb) < 1E-15) break; + if (fabs(w / la / lb) < 1E-15) + { + break; + } } return y; } @@ -186,9 +201,15 @@ void average_LC(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav __attribu { sat = obs[i].sat; - if (azel[1 + 2 * i] < rtk->opt.elmin) continue; + if (azel[1 + 2 * i] < rtk->opt.elmin) + { + continue; + } - if (satsys(sat, nullptr) != SYS_GPS) continue; + if (satsys(sat, nullptr) != SYS_GPS) + { + continue; + } /* triple-freq carrier and code LC (m) */ LC1 = L_LC(1, -1, 0, obs[i].L) - P_LC(1, 1, 0, obs[i].P); @@ -212,7 +233,10 @@ void average_LC(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav __attribu amb->LC[0] = amb->LC[1] = amb->LC[2] = 0.0; amb->LCv[0] = amb->LCv[1] = amb->LCv[2] = 0.0; amb->fixcnt = 0; - for (j = 0; j < MAXSAT; j++) amb->flags[j] = 0; + for (j = 0; j < MAXSAT; j++) + { + amb->flags[j] = 0; + } } /* averaging */ if (LC1) @@ -246,7 +270,10 @@ int fix_amb_WL(rtk_t *rtk, const nav_t *nav, int sat1, int sat2, int *NW) amb1 = rtk->ambc + sat1 - 1; amb2 = rtk->ambc + sat2 - 1; - if (!amb1->n[0] || !amb2->n[0]) return 0; + if (!amb1->n[0] || !amb2->n[0]) + { + return 0; + } /* wide-lane ambiguity */ #ifndef REV_WL_FCB @@ -285,15 +312,27 @@ int is_depend(int sat1, int sat2, int *flgs, int *max_flg) else if (flgs[sat1 - 1] > flgs[sat2 - 1]) { for (i = 0; i < MAXSAT; i++) - if (flgs[i] == flgs[sat2 - 1]) flgs[i] = flgs[sat1 - 1]; + { + if (flgs[i] == flgs[sat2 - 1]) + { + flgs[i] = flgs[sat1 - 1]; + } + } } else if (flgs[sat1 - 1] < flgs[sat2 - 1]) { for (i = 0; i < MAXSAT; i++) - if (flgs[i] == flgs[sat1 - 1]) flgs[i] = flgs[sat2 - 1]; + { + if (flgs[i] == flgs[sat1 - 1]) + { + flgs[i] = flgs[sat2 - 1]; + } + } } else - return 0; /* linear depenent */ + { + return 0; /* linear depenent */ + } return 1; } @@ -305,18 +344,26 @@ int sel_amb(int *sat1, int *sat2, double *N, double *var, int n) /* sort by variance */ for (i = 0; i < n; i++) - for (j = 1; j < n - i; j++) - { - if (var[j] >= var[j - 1]) continue; - SWAP_I(sat1[j], sat1[j - 1]); - SWAP_I(sat2[j], sat2[j - 1]); - SWAP_D(N[j], N[j - 1]); - SWAP_D(var[j], var[j - 1]); - } + { + for (j = 1; j < n - i; j++) + { + if (var[j] >= var[j - 1]) + { + continue; + } + SWAP_I(sat1[j], sat1[j - 1]); + SWAP_I(sat2[j], sat2[j - 1]); + SWAP_D(N[j], N[j - 1]); + SWAP_D(var[j], var[j - 1]); + } + } /* select linearly independent satellite pair */ for (i = j = 0; i < n; i++) { - if (!is_depend(sat1[i], sat2[i], flgs, &max_flg)) continue; + if (!is_depend(sat1[i], sat2[i], flgs, &max_flg)) + { + continue; + } sat1[j] = sat1[i]; sat2[j] = sat2[i]; N[j] = N[i]; @@ -333,7 +380,10 @@ int fix_sol(rtk_t *rtk, const int *sat1, const int *sat2, double *v, *H, *R; int i, j, k, info; - if (n <= 0) return 0; + if (n <= 0) + { + return 0; + } v = zeros(n, 1); H = zeros(rtk->nx, n); @@ -420,7 +470,10 @@ int fix_amb_ROUND(rtk_t *rtk, int *sat1, int *sat2, const int *NW, int n) /* check residuals */ v = rtk->ssat[sat1[i] - 1].resc[0] - rtk->ssat[sat2[i] - 1].resc[0]; vc = v + (BC - (rtk->x[j] - rtk->x[k])); - if (fabs(vc) > THRES_RES) continue; + if (fabs(vc) > THRES_RES) + { + continue; + } sat1[m] = sat1[i]; sat2[m] = sat2[i]; @@ -461,7 +514,10 @@ int fix_amb_ILS(rtk_t *rtk, int *sat1, int *sat2, int *NW, int n) for (i = 0; i < n; i++) { /* check linear independency */ - if (!is_depend(sat1[i], sat2[i], flgs, &max_flg)) continue; + if (!is_depend(sat1[i], sat2[i], flgs, &max_flg)) + { + continue; + } j = IB_PPP(sat1[i], &rtk->opt); k = IB_PPP(sat2[i], &rtk->opt); @@ -471,7 +527,10 @@ int fix_amb_ILS(rtk_t *rtk, int *sat1, int *sat2, int *NW, int n) N1[m] = ROUND_PPP(B1[m]); /* validation of narrow-lane ambiguity */ - if (fabs(N1[m] - B1[m]) > rtk->opt.thresar[2]) continue; + if (fabs(N1[m] - B1[m]) > rtk->opt.thresar[2]) + { + continue; + } /* narrow-lane ambiguity transformation matrix */ D[j + m * rtk->nx] = 1.0 / lam_NL; @@ -562,7 +621,10 @@ int pppamb(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav, double elmask; int i, j, m = 0, stat = 0, *NW, *sat1, *sat2; - if (n <= 0 || rtk->opt.ionoopt != IONOOPT_IFLC || rtk->opt.nf < 2) return 0; + if (n <= 0 || rtk->opt.ionoopt != IONOOPT_IFLC || rtk->opt.nf < 2) + { + return 0; + } trace(3, "pppamb: time=%s n=%d\n", time_str(obs[0].time, 0), n); @@ -577,20 +639,28 @@ int pppamb(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav, /* fix wide-lane ambiguity */ for (i = 0; i < n - 1; i++) - for (j = i + 1; j < n; j++) - { - if (!rtk->ssat[obs[i].sat - 1].vsat[0] || - !rtk->ssat[obs[j].sat - 1].vsat[0] || - azel[1 + i * 2] < elmask || azel[1 + j * 2] < elmask) continue; + { + for (j = i + 1; j < n; j++) + { + if (!rtk->ssat[obs[i].sat - 1].vsat[0] || + !rtk->ssat[obs[j].sat - 1].vsat[0] || + azel[1 + i * 2] < elmask || azel[1 + j * 2] < elmask) + { + continue; + } #if 0 /* test already fixed */ if (rtk->ambc[obs[i].sat-1].flags[obs[j].sat-1] && rtk->ambc[obs[j].sat-1].flags[obs[i].sat-1]) continue; #endif - sat1[m] = obs[i].sat; - sat2[m] = obs[j].sat; - if (fix_amb_WL(rtk, nav, sat1[m], sat2[m], NW + m)) m++; - } + sat1[m] = obs[i].sat; + sat2[m] = obs[j].sat; + if (fix_amb_WL(rtk, nav, sat1[m], sat2[m], NW + m)) + { + m++; + } + } + } /* fix narrow-lane ambiguity */ if (rtk->opt.modear == ARMODE_PPPAR) { @@ -615,7 +685,10 @@ void pppoutsolstat(rtk_t *rtk, int level, FILE *fp) int i, j, week, nfreq = 1; char id[32]; - if (level <= 0 || !fp) return; + if (level <= 0 || !fp) + { + return; + } trace(3, "pppoutsolstat:\n"); @@ -654,13 +727,19 @@ void pppoutsolstat(rtk_t *rtk, int level, FILE *fp) fprintf(fp, "$TRPG,%d,%.3f,%d,%d,%.5f,%.5f,%.5f,%.5f\n", week, tow, rtk->sol.stat, 1, rtk->x[i + 1], rtk->x[i + 2], 0.0, 0.0); } - if (rtk->sol.stat == SOLQ_NONE || level <= 1) return; + if (rtk->sol.stat == SOLQ_NONE || level <= 1) + { + return; + } /* residuals and status */ for (i = 0; i < MAXSAT; i++) { ssat = rtk->ssat + i; - if (!ssat->vs) continue; + if (!ssat->vs) + { + continue; + } satno2id(i + 1, id); for (j = 0; j < nfreq; j++) { @@ -685,16 +764,25 @@ void testeclipse(const obsd_t *obs, int n, const nav_t *nav, double *rs) /* unit vector of sun direction (ecef) */ sunmoonpos(gpst2utc(obs[0].time), erpv, rsun, nullptr, nullptr); - if (normv3(rsun, esun) == 0) trace(1, "Error computing the norm"); + if (normv3(rsun, esun) == 0) + { + trace(1, "Error computing the norm"); + } for (i = 0; i < n; i++) { type = nav->pcvs[obs[i].sat - 1].type; - if ((r = norm_rtk(rs + i * 6, 3)) <= 0.0) continue; + if ((r = norm_rtk(rs + i * 6, 3)) <= 0.0) + { + continue; + } #if 1 /* only block IIA */ - if (*type && !strstr(type, "BLOCK IIA")) continue; + if (*type && !strstr(type, "BLOCK IIA")) + { + continue; + } #endif /* sun-earth-satellite angle */ cosa = dot(rs + i * 6, esun, 3) / r; @@ -702,12 +790,18 @@ void testeclipse(const obsd_t *obs, int n, const nav_t *nav, double *rs) ang = acos(cosa); /* test eclipse */ - if (ang < PI / 2.0 || r * sin(ang) > RE_WGS84) continue; + if (ang < PI / 2.0 || r * sin(ang) > RE_WGS84) + { + continue; + } trace(2, "eclipsing sat excluded %s sat=%2d\n", time_str(obs[0].time, 0), obs[i].sat); - for (j = 0; j < 3; j++) rs[j + i * 6] = 0.0; + for (j = 0; j < 3; j++) + { + rs[j + i * 6] = 0.0; + } } } @@ -746,9 +840,15 @@ double varerr(int sat __attribute__((unused)), int sys, double el, int type, con } else { /* normal error model */ - if (type == 1) fact *= opt->eratio[0]; + if (type == 1) + { + fact *= opt->eratio[0]; + } fact *= sys == SYS_GLO ? EFACT_GLO : (sys == SYS_SBS ? EFACT_SBS : EFACT_GPS); - if (opt->ionoopt == IONOOPT_IFLC) fact *= 3.0; + if (opt->ionoopt == IONOOPT_IFLC) + { + fact *= 3.0; + } a = fact * opt->err[1]; b = fact * opt->err[2]; } @@ -780,9 +880,15 @@ int ifmeas(const obsd_t *obs, const nav_t *nav, const double *azel, trace(4, "ifmeas :\n"); /* L1-L2 for GPS/GLO/QZS, L1-L5 for GAL/SBS */ - if (NFREQ >= 3 && (satsys(obs->sat, nullptr) & (SYS_GAL | SYS_SBS))) j = 2; + if (NFREQ >= 3 && (satsys(obs->sat, nullptr) & (SYS_GAL | SYS_SBS))) + { + j = 2; + } - if (NFREQ < 2 || lam[i] == 0.0 || lam[j] == 0.0) return 0; + if (NFREQ < 2 || lam[i] == 0.0 || lam[j] == 0.0) + { + return 0; + } /* test snr mask */ if (testsnr(0, i, azel[1], obs->SNR[i] * 0.25, &opt->snrmask) || @@ -804,18 +910,30 @@ int ifmeas(const obsd_t *obs, const nav_t *nav, const double *azel, { P1_C1 = nav->lexeph[obs->sat - 1].isc[0] * SPEED_OF_LIGHT; /* ISC_L1C/A */ } - if (L1 == 0.0 || L2 == 0.0 || P1 == 0.0 || P2 == 0.0) return 0; + if (L1 == 0.0 || L2 == 0.0 || P1 == 0.0 || P2 == 0.0) + { + return 0; + } /* iono-free phase with windup correction */ meas[0] = c1 * L1 + c2 * L2 - (c1 * lam[i] + c2 * lam[j]) * phw; /* iono-free code with dcb correction */ - if (obs->code[i] == CODE_L1C) P1 += P1_C1; /* C1->P1 */ - if (obs->code[j] == CODE_L2C) P2 += P2_C2; /* C2->P2 */ + if (obs->code[i] == CODE_L1C) + { + P1 += P1_C1; /* C1->P1 */ + } + if (obs->code[j] == CODE_L2C) + { + P2 += P2_C2; /* C2->P2 */ + } meas[1] = c1 * P1 + c2 * P2; var[1] = std::pow(ERR_CBIAS, 2.0); - if (opt->sateph == EPHOPT_SBAS) meas[1] -= P1_C1; /* sbas clock based C1 */ + if (opt->sateph == EPHOPT_SBAS) + { + meas[1] -= P1_C1; /* sbas clock based C1 */ + } /* gps-glonass h/w bias correction for code */ if (opt->exterr.ena[3] && satsys(obs->sat, nullptr) == SYS_GLO) @@ -825,8 +943,14 @@ int ifmeas(const obsd_t *obs, const nav_t *nav, const double *azel, /* antenna phase center variation correction */ for (k = 0; k < 2; k++) { - if (dants) meas[k] -= c1 * dants[i] + c2 * dants[j]; - if (dantr) meas[k] -= c1 * dantr[i] + c2 * dantr[j]; + if (dants) + { + meas[k] -= c1 * dants[i] + c2 * dants[j]; + } + if (dantr) + { + meas[k] -= c1 * dantr[i] + c2 * dantr[j]; + } } return 1; } @@ -838,7 +962,10 @@ double gettgd_ppp(int sat, const nav_t *nav) int i; for (i = 0; i < nav->n; i++) { - if (nav->eph[i].sat != sat) continue; + if (nav->eph[i].sat != sat) + { + continue; + } return SPEED_OF_LIGHT * nav->eph[i].tgd[0]; } return 0.0; @@ -903,9 +1030,15 @@ int corrmeas(const obsd_t *obs, const nav_t *nav, const double *pos, { return ifmeas(obs, nav, azel, opt, dantr, dants, phw, meas, var); } - if (lam[0] == 0.0 || obs->L[0] == 0.0 || obs->P[0] == 0.0) return 0; + if (lam[0] == 0.0 || obs->L[0] == 0.0 || obs->P[0] == 0.0) + { + return 0; + } - if (testsnr(0, 0, azel[1], obs->SNR[0] * 0.25, &opt->snrmask)) return 0; + if (testsnr(0, 0, azel[1], obs->SNR[0] * 0.25, &opt->snrmask)) + { + return 0; + } L1 = obs->L[0] * lam[0]; P1 = obs->P[0]; @@ -918,8 +1051,11 @@ int corrmeas(const obsd_t *obs, const nav_t *nav, const double *pos, { P1_P2 = (1.0 - gamma) * gettgd_ppp(obs->sat, nav); } - if (obs->code[0] == CODE_L1C) P1 += P1_C1; /* C1->P1 */ - PC = P1 - P1_P2 / (1.0 - gamma); /* P1->PC */ + if (obs->code[0] == CODE_L1C) + { + P1 += P1_C1; /* C1->P1 */ + } + PC = P1 - P1_P2 / (1.0 - gamma); /* P1->PC */ /* slant ionospheric delay L1 (m) */ if (!corr_ion(obs->time, nav, obs->sat, pos, azel, opt->ionoopt, &ion, &vari, brk)) @@ -938,8 +1074,14 @@ int corrmeas(const obsd_t *obs, const nav_t *nav, const double *pos, /* antenna phase center variation correction */ for (i = 0; i < 2; i++) { - if (dants) meas[i] -= dants[0]; - if (dantr) meas[i] -= dantr[0]; + if (dants) + { + meas[i] -= dants[0]; + } + if (dantr) + { + meas[i] -= dantr[0]; + } } return 1; } @@ -950,7 +1092,10 @@ double gfmeas(const obsd_t *obs, const nav_t *nav) { const double *lam = nav->lam[obs->sat - 1]; - if (lam[0] == 0.0 || lam[1] == 0.0 || obs->L[0] == 0.0 || obs->L[1] == 0.0) return 0.0; + if (lam[0] == 0.0 || lam[1] == 0.0 || obs->L[0] == 0.0 || obs->L[1] == 0.0) + { + return 0.0; + } return lam[0] * obs->L[0] - lam[1] * obs->L[1]; } @@ -966,16 +1111,25 @@ void udpos_ppp(rtk_t *rtk) /* fixed mode */ if (rtk->opt.mode == PMODE_PPP_FIXED) { - for (i = 0; i < 3; i++) initx(rtk, rtk->opt.ru[i], 1E-8, i); + for (i = 0; i < 3; i++) + { + initx(rtk, rtk->opt.ru[i], 1E-8, i); + } return; } /* initialize position for first epoch */ if (norm_rtk(rtk->x, 3) <= 0.0) { - for (i = 0; i < 3; i++) initx(rtk, rtk->sol.rr[i], VAR_POS_PPP, i); + for (i = 0; i < 3; i++) + { + initx(rtk, rtk->sol.rr[i], VAR_POS_PPP, i); + } } /* static ppp mode */ - if (rtk->opt.mode == PMODE_PPP_STATIC) return; + if (rtk->opt.mode == PMODE_PPP_STATIC) + { + return; + } /* kinmatic mode without dynamics */ for (i = 0; i < 3; i++) @@ -1027,7 +1181,10 @@ void udtrop_ppp(rtk_t *rtk) if (rtk->opt.tropopt >= TROPOPT_ESTG) { - for (j = 0; j < 2; j++) initx(rtk, 1E-6, VAR_GRA_PPP, ++i); + for (j = 0; j < 2; j++) + { + initx(rtk, 1E-6, VAR_GRA_PPP, ++i); + } } } else @@ -1053,14 +1210,19 @@ void detslp_ll(rtk_t *rtk, const obsd_t *obs, int n) trace(3, "detslp_ll: n=%d\n", n); for (i = 0; i < n && i < MAXOBS; i++) - for (j = 0; j < rtk->opt.nf; j++) - { - if (obs[i].L[j] == 0.0 || !(obs[i].LLI[j] & 3)) continue; + { + for (j = 0; j < rtk->opt.nf; j++) + { + if (obs[i].L[j] == 0.0 || !(obs[i].LLI[j] & 3)) + { + continue; + } - trace(3, "detslp_ll: slip detected sat=%2d f=%d\n", obs[i].sat, j + 1); + trace(3, "detslp_ll: slip detected sat=%2d f=%d\n", obs[i].sat, j + 1); - rtk->ssat[obs[i].sat - 1].slip[j] = 1; - } + rtk->ssat[obs[i].sat - 1].slip[j] = 1; + } + } } @@ -1074,7 +1236,10 @@ void detslp_gf(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) for (i = 0; i < n && i < MAXOBS; i++) { - if ((g1 = gfmeas(obs + i, nav)) == 0.0) continue; + if ((g1 = gfmeas(obs + i, nav)) == 0.0) + { + continue; + } g0 = rtk->ssat[obs[i].sat - 1].gf; rtk->ssat[obs[i].sat - 1].gf = g1; @@ -1086,7 +1251,10 @@ void detslp_gf(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) trace(3, "detslip_gf: slip detected sat=%2d gf=%8.3f->%8.3f\n", obs[i].sat, g0, g1); - for (j = 0; j < rtk->opt.nf; j++) rtk->ssat[obs[i].sat - 1].slip[j] |= 1; + for (j = 0; j < rtk->opt.nf; j++) + { + rtk->ssat[obs[i].sat - 1].slip[j] |= 1; + } } } } @@ -1101,10 +1269,12 @@ void udbias_ppp(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) trace(3, "udbias : n=%d\n", n); for (i = 0; i < MAXSAT; i++) - for (j = 0; j < rtk->opt.nf; j++) - { - rtk->ssat[i].slip[j] = 0; - } + { + for (j = 0; j < rtk->opt.nf; j++) + { + rtk->ssat[i].slip[j] = 0; + } + } /* detect cycle slip by LLI */ detslp_ll(rtk, obs, n); @@ -1126,7 +1296,10 @@ void udbias_ppp(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) sat = obs[i].sat; j = IB_PPP(sat, &rtk->opt); if (!corrmeas(obs + i, nav, pos, rtk->ssat[sat - 1].azel, &rtk->opt, nullptr, nullptr, - 0.0, meas, var, &brk)) continue; + 0.0, meas, var, &brk)) + { + continue; + } if (brk) { @@ -1135,7 +1308,10 @@ void udbias_ppp(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) } bias[i] = meas[0] - meas[1]; if (rtk->x[j] == 0.0 || - rtk->ssat[sat - 1].slip[0] || rtk->ssat[sat - 1].slip[1]) continue; + rtk->ssat[sat - 1].slip[0] || rtk->ssat[sat - 1].slip[1]) + { + continue; + } offset += bias[i] - rtk->x[j]; k++; } @@ -1145,7 +1321,10 @@ void udbias_ppp(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) for (i = 0; i < MAXSAT; i++) { j = IB_PPP(i + 1, &rtk->opt); - if (rtk->x[j] != 0.0) rtk->x[j] += offset / k; + if (rtk->x[j] != 0.0) + { + rtk->x[j] += offset / k; + } } trace(2, "phase-code jump corrected: %s n=%2d dt=%12.9fs\n", time_str(rtk->sol.time, 0), k, offset / k / SPEED_OF_LIGHT); @@ -1158,9 +1337,15 @@ void udbias_ppp(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) rtk->P[j + j * rtk->nx] += std::pow(rtk->opt.prn[0], 2.0) * fabs(rtk->tt); if (rtk->x[j] != 0.0 && - !rtk->ssat[sat - 1].slip[0] && !rtk->ssat[sat - 1].slip[1]) continue; + !rtk->ssat[sat - 1].slip[0] && !rtk->ssat[sat - 1].slip[1]) + { + continue; + } - if (bias[i] == 0.0) continue; + if (bias[i] == 0.0) + { + continue; + } /* reinitialize phase-bias if detecting cycle slip */ initx(rtk, bias[i], VAR_BIAS, IB_PPP(sat, &rtk->opt)); @@ -1203,7 +1388,10 @@ void satantpcv(const double *rs, const double *rr, const pcv_t *pcv, ru[i] = rr[i] - rs[i]; rz[i] = -rs[i]; } - if (!normv3(ru, eu) || !normv3(rz, ez)) return; + if (!normv3(ru, eu) || !normv3(rz, ez)) + { + return; + } cosa = dot(eu, ez, 3); cosa = cosa < -1.0 ? -1.0 : (cosa > 1.0 ? 1.0 : cosa); @@ -1256,9 +1444,15 @@ int res_ppp(int iter __attribute__((unused)), const obsd_t *obs, int n, const do trace(3, "res_ppp : n=%d nx=%d\n", n, nx); - for (i = 0; i < MAXSAT; i++) rtk->ssat[i].vsat[0] = 0; + for (i = 0; i < MAXSAT; i++) + { + rtk->ssat[i].vsat[0] = 0; + } - for (i = 0; i < 3; i++) rr[i] = x[i]; + for (i = 0; i < 3; i++) + { + rr[i] = x[i]; + } /* earth tides correction */ if (opt->tidecorr) @@ -1267,21 +1461,33 @@ int res_ppp(int iter __attribute__((unused)), const obsd_t *obs, int n, const do tidedisp(gpst2utc(obs[0].time), rr, tideopt, &nav->erp, opt->odisp[0], disp); - for (i = 0; i < 3; i++) rr[i] += disp[i]; + for (i = 0; i < 3; i++) + { + rr[i] += disp[i]; + } } ecef2pos(rr, pos); for (i = 0; i < n && i < MAXOBS; i++) { sat = obs[i].sat; - if (!(sys = satsys(sat, nullptr)) || !rtk->ssat[sat - 1].vs) continue; + if (!(sys = satsys(sat, nullptr)) || !rtk->ssat[sat - 1].vs) + { + continue; + } /* geometric distance/azimuth/elevation angle */ if ((r = geodist(rs + i * 6, rr, e)) <= 0.0 || - satazel(pos, e, azel + i * 2) < opt->elmin) continue; + satazel(pos, e, azel + i * 2) < opt->elmin) + { + continue; + } /* excluded satellite? */ - if (satexclude(obs[i].sat, svh[i], opt)) continue; + if (satexclude(obs[i].sat, svh[i], opt)) + { + continue; + } /* tropospheric delay correction */ if (opt->tropopt == TROPOPT_SAAS) @@ -1330,13 +1536,22 @@ int res_ppp(int iter __attribute__((unused)), const obsd_t *obs, int n, const do for (j = 0; j < 2; j++) { /* for phase and code */ - if (meas[j] == 0.0) continue; + if (meas[j] == 0.0) + { + continue; + } - for (k = 0; k < nx; k++) H[k + nx * nv] = 0.0; + for (k = 0; k < nx; k++) + { + H[k + nx * nv] = 0.0; + } v[nv] = meas[j] - r; - for (k = 0; k < 3; k++) H[k + nx * nv] = -e[k]; + for (k = 0; k < 3; k++) + { + H[k + nx * nv] = -e[k]; + } if (sys != SYS_GLO) { @@ -1363,9 +1578,13 @@ int res_ppp(int iter __attribute__((unused)), const obsd_t *obs, int n, const do var[nv] = varerr(obs[i].sat, sys, azel[1 + i * 2], j, opt) + varm[j] + vare[i] + vart; if (j == 0) - rtk->ssat[sat - 1].resc[0] = v[nv]; + { + rtk->ssat[sat - 1].resc[0] = v[nv]; + } else - rtk->ssat[sat - 1].resp[0] = v[nv]; + { + rtk->ssat[sat - 1].resp[0] = v[nv]; + } /* test innovation */ #if 0 @@ -1380,15 +1599,20 @@ int res_ppp(int iter __attribute__((unused)), const obsd_t *obs, int n, const do rtk->ssat[sat - 1].rejc[0]++; continue; } - if (j == 0) rtk->ssat[sat - 1].vsat[0] = 1; + if (j == 0) + { + rtk->ssat[sat - 1].vsat[0] = 1; + } nv++; } } for (i = 0; i < nv; i++) - for (j = 0; j < nv; j++) - { - R[i + j * nv] = i == j ? var[i] : 0.0; - } + { + for (j = 0; j < nv; j++) + { + R[i + j * nv] = i == j ? var[i] : 0.0; + } + } trace(5, "x=\n"); tracemat(5, x, 1, nx, 8, 3); trace(5, "v=\n"); @@ -1422,7 +1646,10 @@ void pppos(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) var = mat(1, n); azel = zeros(2, n); - for (i = 0; i < MAXSAT; i++) rtk->ssat[i].fix[0] = 0; + for (i = 0; i < MAXSAT; i++) + { + rtk->ssat[i].fix[0] = 0; + } /* temporal update of states */ udstate_ppp(rtk, obs, n, nav); @@ -1449,7 +1676,10 @@ void pppos(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) for (i = 0; i < rtk->opt.niter; i++) { /* phase and code residuals */ - if ((nv = res_ppp(i, obs, n, rs, dts, var, svh, nav, xp, rtk, v, H, R, azel)) <= 0) break; + if ((nv = res_ppp(i, obs, n, rs, dts, var, svh, nav, xp, rtk, v, H, R, azel)) <= 0) + { + break; + } /* measurement update */ matcpy(Pp, rtk->P, rtk->nx, rtk->nx); @@ -1476,13 +1706,19 @@ void pppos(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) /* ambiguity resolution in ppp */ if (opt->modear == ARMODE_PPPAR || opt->modear == ARMODE_PPPAR_ILS) { - if (pppamb(rtk, obs, n, nav, azel)) stat = SOLQ_FIX; + if (pppamb(rtk, obs, n, nav, azel)) + { + stat = SOLQ_FIX; + } } /* update solution status */ rtk->sol.ns = 0; for (i = 0; i < n && i < MAXOBS; i++) { - if (!rtk->ssat[obs[i].sat - 1].vsat[0]) continue; + if (!rtk->ssat[obs[i].sat - 1].vsat[0]) + { + continue; + } rtk->ssat[obs[i].sat - 1].lock[0]++; rtk->ssat[obs[i].sat - 1].outc[0] = 0; rtk->ssat[obs[i].sat - 1].fix[0] = 4; @@ -1506,7 +1742,10 @@ void pppos(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) } for (i = 0; i < MAXSAT; i++) { - if (rtk->ssat[i].slip[0] & 3) rtk->ssat[i].slipc[0]++; + if (rtk->ssat[i].slip[0] & 3) + { + rtk->ssat[i].slipc[0]++; + } } } free(rs); diff --git a/src/algorithms/libs/rtklib/rtklib_preceph.cc b/src/algorithms/libs/rtklib/rtklib_preceph.cc index 3c9f34c40..61217a8ae 100644 --- a/src/algorithms/libs/rtklib/rtklib_preceph.cc +++ b/src/algorithms/libs/rtklib/rtklib_preceph.cc @@ -67,12 +67,30 @@ /* satellite code to satellite system ----------------------------------------*/ int code2sys(char code) { - if (code == 'G' || code == ' ') return SYS_GPS; - if (code == 'R') return SYS_GLO; - if (code == 'E') return SYS_GAL; /* extension to sp3-c */ - if (code == 'J') return SYS_QZS; /* extension to sp3-c */ - if (code == 'C') return SYS_BDS; /* extension to sp3-c */ - if (code == 'L') return SYS_LEO; /* extension to sp3-c */ + if (code == 'G' || code == ' ') + { + return SYS_GPS; + } + if (code == 'R') + { + return SYS_GLO; + } + if (code == 'E') + { + return SYS_GAL; /* extension to sp3-c */ + } + if (code == 'J') + { + return SYS_QZS; /* extension to sp3-c */ + } + if (code == 'C') + { + return SYS_BDS; /* extension to sp3-c */ + } + if (code == 'L') + { + return SYS_LEO; /* extension to sp3-c */ + } return SYS_NONE; } @@ -88,12 +106,18 @@ int readsp3h(FILE *fp, gtime_t *time, char *type, int *sats, for (i = 0; i < 22; i++) { - if (!fgets(buff, sizeof(buff), fp)) break; + if (!fgets(buff, sizeof(buff), fp)) + { + break; + } if (i == 0) { *type = buff[2]; - if (str2time(buff, 3, 28, time)) return 0; + if (str2time(buff, 3, 28, time)) + { + return 0; + } } else if (2 <= i && i <= 6) { @@ -105,7 +129,10 @@ int readsp3h(FILE *fp, gtime_t *time, char *type, int *sats, { sys = code2sys(buff[9 + 3 * j]); prn = static_cast(str2num(buff, 10 + 3 * j, 2)); - if (k < MAXSAT) sats[k++] = satno(sys, prn); + if (k < MAXSAT) + { + sats[k++] = satno(sys, prn); + } } } else if (i == 12) @@ -160,14 +187,20 @@ void readsp3b(FILE *fp, char type, int *sats __attribute__((unused)), int ns, co while (fgets(buff, sizeof(buff), fp)) { - if (!strncmp(buff, "EOF", 3)) break; + if (!strncmp(buff, "EOF", 3)) + { + break; + } if (buff[0] != '*' || str2time(buff, 3, 28, &time)) { trace(2, "sp3 invalid epoch %31.31s\n", buff); continue; } - if (!strcmp(tsys, "UTC")) time = utc2gpst(time); /* utc->gpst */ + if (!strcmp(tsys, "UTC")) + { + time = utc2gpst(time); /* utc->gpst */ + } peph.time = time; peph.index = index; @@ -188,16 +221,26 @@ void readsp3b(FILE *fp, char type, int *sats __attribute__((unused)), int ns, co } for (i = pred_o = pred_c = v = 0; i < n && fgets(buff, sizeof(buff), fp); i++) { - if (strlen(buff) < 4 || (buff[0] != 'P' && buff[0] != 'V')) continue; + if (strlen(buff) < 4 || (buff[0] != 'P' && buff[0] != 'V')) + { + continue; + } sys = buff[1] == ' ' ? SYS_GPS : code2sys(buff[1]); prn = static_cast(str2num(buff, 2, 2)); if (sys == SYS_SBS) - prn += 100; + { + prn += 100; + } else if (sys == SYS_QZS) - prn += 192; /* extension to sp3-c */ + { + prn += 192; /* extension to sp3-c */ + } - if (!(sat = satno(sys, prn))) continue; + if (!(sat = satno(sys, prn))) + { + continue; + } if (buff[0] == 'P') { @@ -207,10 +250,22 @@ void readsp3b(FILE *fp, char type, int *sats __attribute__((unused)), int ns, co for (j = 0; j < 4; j++) { /* read option for predicted value */ - if (j < 3 && (opt & 1) && pred_o) continue; - if (j < 3 && (opt & 2) && !pred_o) continue; - if (j == 3 && (opt & 1) && pred_c) continue; - if (j == 3 && (opt & 2) && !pred_c) continue; + if (j < 3 && (opt & 1) && pred_o) + { + continue; + } + if (j < 3 && (opt & 2) && !pred_o) + { + continue; + } + if (j == 3 && (opt & 1) && pred_c) + { + continue; + } + if (j == 3 && (opt & 2) && !pred_c) + { + continue; + } val = str2num(buff, 4 + j * 14, 14); std = str2num(buff, 61 + j * 3, j < 3 ? 2 : 3); @@ -242,7 +297,10 @@ void readsp3b(FILE *fp, char type, int *sats __attribute__((unused)), int ns, co } if (v) { - if (!addpeph(nav, &peph)) return; + if (!addpeph(nav, &peph)) + { + return; + } } } } @@ -266,7 +324,10 @@ void combpeph(nav_t *nav, int opt) qsort(nav->peph, nav->ne, sizeof(peph_t), cmppeph); - if (opt & 4) return; + if (opt & 4) + { + return; + } for (i = 0, j = 1; j < nav->ne; j++) { @@ -274,15 +335,32 @@ void combpeph(nav_t *nav, int opt) { for (k = 0; k < MAXSAT; k++) { - if (norm_rtk(nav->peph[j].pos[k], 4) <= 0.0) continue; - for (m = 0; m < 4; m++) nav->peph[i].pos[k][m] = nav->peph[j].pos[k][m]; - for (m = 0; m < 4; m++) nav->peph[i].std[k][m] = nav->peph[j].std[k][m]; - for (m = 0; m < 4; m++) nav->peph[i].vel[k][m] = nav->peph[j].vel[k][m]; - for (m = 0; m < 4; m++) nav->peph[i].vst[k][m] = nav->peph[j].vst[k][m]; + if (norm_rtk(nav->peph[j].pos[k], 4) <= 0.0) + { + continue; + } + for (m = 0; m < 4; m++) + { + nav->peph[i].pos[k][m] = nav->peph[j].pos[k][m]; + } + for (m = 0; m < 4; m++) + { + nav->peph[i].std[k][m] = nav->peph[j].std[k][m]; + } + for (m = 0; m < 4; m++) + { + nav->peph[i].vel[k][m] = nav->peph[j].vel[k][m]; + } + for (m = 0; m < 4; m++) + { + nav->peph[i].vst[k][m] = nav->peph[j].vst[k][m]; + } } } else if (++i < j) - nav->peph[i] = nav->peph[j]; + { + nav->peph[i] = nav->peph[j]; + } } nav->ne = i + 1; @@ -318,7 +396,10 @@ void readsp3(const char *file, nav_t *nav, int opt) { if (!(efiles[i] = static_cast(malloc(1024)))) { - for (i--; i >= 0; i--) free(efiles[i]); + for (i--; i >= 0; i--) + { + free(efiles[i]); + } return; } } @@ -327,10 +408,16 @@ void readsp3(const char *file, nav_t *nav, int opt) for (i = j = 0; i < n; i++) { - if (!(ext = strrchr(efiles[i], '.'))) continue; + if (!(ext = strrchr(efiles[i], '.'))) + { + continue; + } if (!strstr(ext + 1, "sp3") && !strstr(ext + 1, ".SP3") && - !strstr(ext + 1, "eph") && !strstr(ext + 1, ".EPH")) continue; + !strstr(ext + 1, "eph") && !strstr(ext + 1, ".EPH")) + { + continue; + } if (!(fp = fopen(efiles[i], "re"))) { @@ -345,10 +432,16 @@ void readsp3(const char *file, nav_t *nav, int opt) fclose(fp); } - for (i = 0; i < MAXEXFILE; i++) free(efiles[i]); + for (i = 0; i < MAXEXFILE; i++) + { + free(efiles[i]); + } /* combine precise ephemeris */ - if (nav->ne > 0) combpeph(nav, opt); + if (nav->ne > 0) + { + combpeph(nav, opt); + } } @@ -368,7 +461,10 @@ int readsap(const char *file, gtime_t time, nav_t *nav) trace(3, "readsap : file=%s time=%s\n", file, time_str(time, 0)); - if (!readpcv(file, &pcvs)) return 0; + if (!readpcv(file, &pcvs)) + { + return 0; + } for (i = 0; i < MAXSAT; i++) { @@ -398,21 +494,36 @@ int readdcbf(const char *file, nav_t *nav, const sta_t *sta) while (fgets(buff, sizeof(buff), fp)) { if (strstr(buff, "DIFFERENTIAL (P1-P2) CODE BIASES")) - type = 1; + { + type = 1; + } else if (strstr(buff, "DIFFERENTIAL (P1-C1) CODE BIASES")) - type = 2; + { + type = 2; + } else if (strstr(buff, "DIFFERENTIAL (P2-C2) CODE BIASES")) - type = 3; + { + type = 3; + } - if (!type || sscanf(buff, "%s %s", str1, str2) < 1) continue; + if (!type || sscanf(buff, "%s %s", str1, str2) < 1) + { + continue; + } - if ((cbias = str2num(buff, 26, 9)) == 0.0) continue; + if ((cbias = str2num(buff, 26, 9)) == 0.0) + { + continue; + } if (sta && (!strcmp(str1, "G") || !strcmp(str1, "R"))) { /* receiver dcb */ for (i = 0; i < MAXRCV; i++) { - if (!strcmp(sta[i].name, str2)) break; + if (!strcmp(sta[i].name, str2)) + { + break; + } } if (i < MAXRCV) { @@ -448,15 +559,20 @@ int readdcb(const char *file, nav_t *nav, const sta_t *sta) trace(3, "readdcb : file=%s\n", file); for (i = 0; i < MAXSAT; i++) - for (j = 0; j < 3; j++) - { - nav->cbias[i][j] = 0.0; - } + { + for (j = 0; j < 3; j++) + { + nav->cbias[i][j] = 0.0; + } + } for (i = 0; i < MAXEXFILE; i++) { if (!(efiles[i] = static_cast(malloc(1024)))) { - for (i--; i >= 0; i--) free(efiles[i]); + for (i--; i >= 0; i--) + { + free(efiles[i]); + } return 0; } } @@ -466,7 +582,10 @@ int readdcb(const char *file, nav_t *nav, const sta_t *sta) { readdcbf(efiles[i], nav, sta); } - for (i = 0; i < MAXEXFILE; i++) free(efiles[i]); + for (i = 0; i < MAXEXFILE; i++) + { + free(efiles[i]); + } return 1; } @@ -500,10 +619,12 @@ int addfcb(nav_t *nav, gtime_t ts, gtime_t te, int sat, nav->fcb = nav_fcb; } for (i = 0; i < MAXSAT; i++) - for (j = 0; j < 3; j++) - { - nav->fcb[nav->nf].bias[i][j] = nav->fcb[nav->nf].std[i][j] = 0.0; - } + { + for (j = 0; j < 3; j++) + { + nav->fcb[nav->nf].bias[i][j] = nav->fcb[nav->nf].std[i][j] = 0.0; + } + } for (i = 0; i < 3; i++) { nav->fcb[nav->nf].bias[sat - 1][i] = bias[i]; @@ -533,14 +654,23 @@ int readfcbf(const char *file, nav_t *nav) } while (fgets(buff, sizeof(buff), fp)) { - if ((p = strchr(buff, '#'))) *p = '\0'; + if ((p = strchr(buff, '#'))) + { + *p = '\0'; + } if (sscanf(buff, "%lf/%lf/%lf %lf:%lf:%lf %lf/%lf/%lf %lf:%lf:%lf %s" "%lf %lf %lf %lf %lf %lf", ep1, ep1 + 1, ep1 + 2, ep1 + 3, ep1 + 4, ep1 + 5, ep2, ep2 + 1, ep2 + 2, ep2 + 3, ep2 + 4, ep2 + 5, str, bias, std, bias + 1, std + 1, - bias + 2, std + 2) < 17) continue; - if (!(sat = satid2no(str))) continue; + bias + 2, std + 2) < 17) + { + continue; + } + if (!(sat = satid2no(str))) + { + continue; + } ts = epoch2time(ep1); te = epoch2time(ep2); if (!addfcb(nav, ts, te, sat, bias, std)) @@ -581,7 +711,10 @@ int readfcb(const char *file, nav_t *nav) { if (!(efiles[i] = static_cast(malloc(1024)))) { - for (i--; i >= 0; i--) free(efiles[i]); + for (i--; i >= 0; i--) + { + free(efiles[i]); + } return 0; } } @@ -591,7 +724,10 @@ int readfcb(const char *file, nav_t *nav) { readfcbf(efiles[i], nav); } - for (i = 0; i < MAXEXFILE; i++) free(efiles[i]); + for (i = 0; i < MAXEXFILE; i++) + { + free(efiles[i]); + } if (nav->nf > 1) { @@ -640,18 +776,26 @@ int pephpos(gtime_t time, int sat, const nav_t *nav, double *rs, { k = (i + j) / 2; if (timediff(nav->peph[k].time, time) < 0.0) - i = k + 1; + { + i = k + 1; + } else - j = k; + { + j = k; + } } index = i <= 0 ? 0 : i - 1; /* polynomial interpolation for orbit */ i = index - (NMAX + 1) / 2; if (i < 0) - i = 0; + { + i = 0; + } else if (i + NMAX >= nav->ne) - i = nav->ne - NMAX - 1; + { + i = nav->ne - NMAX - 1; + } for (j = 0; j <= NMAX; j++) { @@ -683,14 +827,21 @@ int pephpos(gtime_t time, int sat, const nav_t *nav, double *rs, } if (vare) { - for (i = 0; i < 3; i++) s[i] = nav->peph[index].std[sat - 1][i]; + for (i = 0; i < 3; i++) + { + s[i] = nav->peph[index].std[sat - 1][i]; + } std = norm_rtk(s, 3); /* extrapolation error for orbit */ if (t[0] > 0.0) - std += EXTERR_EPH * std::pow(t[0], 2.0) / 2.0; + { + std += EXTERR_EPH * std::pow(t[0], 2.0) / 2.0; + } else if (t[NMAX] < 0.0) - std += EXTERR_EPH * std::pow(t[NMAX], 2.0) / 2.0; + { + std += EXTERR_EPH * std::pow(t[NMAX], 2.0) / 2.0; + } *vare = std::pow(std, 2.0); } /* linear interpolation for clock */ @@ -723,7 +874,10 @@ int pephpos(gtime_t time, int sat, const nav_t *nav, double *rs, { dts[0] = 0.0; } - if (varc) *varc = std::pow(std, 2.0); + if (varc) + { + *varc = std::pow(std, 2.0); + } return 1; } @@ -749,9 +903,13 @@ int pephclk(gtime_t time, int sat, const nav_t *nav, double *dts, { k = (i + j) / 2; if (timediff(nav->pclk[k].time, time) < 0.0) - i = k + 1; + { + i = k + 1; + } else - j = k; + { + j = k; + } } index = i <= 0 ? 0 : i - 1; @@ -763,12 +921,18 @@ int pephclk(gtime_t time, int sat, const nav_t *nav, double *dts, if (t[0] <= 0.0) { - if ((dts[0] = c[0]) == 0.0) return 0; + if ((dts[0] = c[0]) == 0.0) + { + return 0; + } std = nav->pclk[index].std[sat - 1][0] * SPEED_OF_LIGHT - EXTERR_CLK * t[0]; } else if (t[1] >= 0.0) { - if ((dts[0] = c[1]) == 0.0) return 0; + if ((dts[0] = c[1]) == 0.0) + { + return 0; + } std = nav->pclk[index + 1].std[sat - 1][0] * SPEED_OF_LIGHT + EXTERR_CLK * t[1]; } else if (c[0] != 0.0 && c[1] != 0.0) @@ -782,7 +946,10 @@ int pephclk(gtime_t time, int sat, const nav_t *nav, double *dts, trace(3, "prec clock outage %s sat=%2d\n", time_str(time, 0), sat); return 0; } - if (varc) *varc = std::pow(std, 2.0); + if (varc) + { + *varc = std::pow(std, 2.0); + } return 1; } @@ -813,17 +980,38 @@ void satantoff(gtime_t time, const double *rs, int sat, const nav_t *nav, sunmoonpos(gpst2utc(time), erpv, rsun, nullptr, &gmst); /* unit vectors of satellite fixed coordinates */ - for (i = 0; i < 3; i++) r[i] = -rs[i]; - if (!normv3(r, ez)) return; - for (i = 0; i < 3; i++) r[i] = rsun[i] - rs[i]; - if (!normv3(r, es)) return; + for (i = 0; i < 3; i++) + { + r[i] = -rs[i]; + } + if (!normv3(r, ez)) + { + return; + } + for (i = 0; i < 3; i++) + { + r[i] = rsun[i] - rs[i]; + } + if (!normv3(r, es)) + { + return; + } cross3(ez, es, r); - if (!normv3(r, ey)) return; + if (!normv3(r, ey)) + { + return; + } cross3(ey, ez, ex); - if (NFREQ >= 3 && (satsys(sat, nullptr) & (SYS_GAL | SYS_SBS))) k = 2; + if (NFREQ >= 3 && (satsys(sat, nullptr) & (SYS_GAL | SYS_SBS))) + { + k = 2; + } - if (NFREQ < 2 || lam[j] == 0.0 || lam[k] == 0.0) return; + if (NFREQ < 2 || lam[j] == 0.0 || lam[k] == 0.0) + { + return; + } gamma = std::pow(lam[k], 2.0) / std::pow(lam[j], 2.0); C1 = gamma / (gamma - 1.0); @@ -865,15 +1053,24 @@ int peph2pos(gtime_t time, int sat, const nav_t *nav, int opt, trace(4, "peph2pos: time=%s sat=%2d opt=%d\n", time_str(time, 3), sat, opt); - if (sat <= 0 || MAXSAT < sat) return 0; + if (sat <= 0 || MAXSAT < sat) + { + return 0; + } /* satellite position and clock bias */ if (!pephpos(time, sat, nav, rss, dtss, &vare, &varc) || - !pephclk(time, sat, nav, dtss, &varc)) return 0; + !pephclk(time, sat, nav, dtss, &varc)) + { + return 0; + } time = timeadd(time, tt); if (!pephpos(time, sat, nav, rst, dtst, nullptr, nullptr) || - !pephclk(time, sat, nav, dtst, nullptr)) return 0; + !pephclk(time, sat, nav, dtst, nullptr)) + { + return 0; + } /* satellite antenna offset correction */ if (opt) @@ -895,7 +1092,10 @@ int peph2pos(gtime_t time, int sat, const nav_t *nav, int opt, { /* no precise clock */ dts[0] = dts[1] = 0.0; } - if (var) *var = vare + varc; + if (var) + { + *var = vare + varc; + } return 1; } diff --git a/src/algorithms/libs/rtklib/rtklib_rtcm.cc b/src/algorithms/libs/rtklib/rtklib_rtcm.cc index c82065d2c..53c34663d 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtcm.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtcm.cc @@ -94,19 +94,30 @@ int init_rtcm(rtcm_t *rtcm) rtcm->ssr[i] = ssr0; } rtcm->msg[0] = rtcm->msgtype[0] = rtcm->opt[0] = '\0'; - for (i = 0; i < 6; i++) rtcm->msmtype[i][0] = '\0'; + for (i = 0; i < 6; i++) + { + rtcm->msmtype[i][0] = '\0'; + } rtcm->obsflag = rtcm->ephsat = 0; for (i = 0; i < MAXSAT; i++) - for (j = 0; j < NFREQ + NEXOBS; j++) - { - rtcm->cp[i][j] = 0.0; - rtcm->lock[i][j] = rtcm->loss[i][j] = 0; - rtcm->lltime[i][j] = time0; - } + { + for (j = 0; j < NFREQ + NEXOBS; j++) + { + rtcm->cp[i][j] = 0.0; + rtcm->lock[i][j] = rtcm->loss[i][j] = 0; + rtcm->lltime[i][j] = time0; + } + } rtcm->nbyte = rtcm->nbit = rtcm->len = 0; rtcm->word = 0; - for (i = 0; i < 100; i++) rtcm->nmsg2[i] = 0; - for (i = 0; i < 300; i++) rtcm->nmsg3[i] = 0; + for (i = 0; i < 100; i++) + { + rtcm->nmsg2[i] = 0; + } + for (i = 0; i < 300; i++) + { + rtcm->nmsg3[i] = 0; + } rtcm->obs.data = nullptr; rtcm->nav.eph = nullptr; @@ -123,9 +134,18 @@ int init_rtcm(rtcm_t *rtcm) rtcm->obs.n = 0; rtcm->nav.n = MAXSAT; rtcm->nav.ng = MAXPRNGLO; - for (i = 0; i < MAXOBS; i++) rtcm->obs.data[i] = data0; - for (i = 0; i < MAXSAT; i++) rtcm->nav.eph[i] = eph0; - for (i = 0; i < MAXPRNGLO; i++) rtcm->nav.geph[i] = geph0; + for (i = 0; i < MAXOBS; i++) + { + rtcm->obs.data[i] = data0; + } + for (i = 0; i < MAXSAT; i++) + { + rtcm->nav.eph[i] = eph0; + } + for (i = 0; i < MAXPRNGLO; i++) + { + rtcm->nav.geph[i] = geph0; + } return 1; } @@ -173,7 +193,10 @@ int input_rtcm2(rtcm_t *rtcm, unsigned char data) trace(5, "input_rtcm2: data=%02x\n", data); - if ((data & 0xC0) != 0x40) return 0; /* ignore if upper 2bit != 01 */ + if ((data & 0xC0) != 0x40) + { + return 0; /* ignore if upper 2bit != 01 */ + } for (i = 0; i < 6; i++, data >>= 1) { /* decode 6-of-8 form */ @@ -183,17 +206,28 @@ int input_rtcm2(rtcm_t *rtcm, unsigned char data) if (rtcm->nbyte == 0) { preamb = static_cast(rtcm->word >> 22); - if (rtcm->word & 0x40000000) preamb ^= 0xFF; /* decode preamble */ - if (preamb != RTCM2PREAMB) continue; + if (rtcm->word & 0x40000000) + { + preamb ^= 0xFF; /* decode preamble */ + } + if (preamb != RTCM2PREAMB) + { + continue; + } /* check parity */ - if (!decode_word(rtcm->word, rtcm->buff)) continue; + if (!decode_word(rtcm->word, rtcm->buff)) + { + continue; + } rtcm->nbyte = 3; rtcm->nbit = 0; continue; } if (++rtcm->nbit < 30) - continue; + { + continue; + } rtcm->nbit = 0; @@ -206,8 +240,14 @@ int input_rtcm2(rtcm_t *rtcm, unsigned char data) continue; } rtcm->nbyte += 3; - if (rtcm->nbyte == 6) rtcm->len = (rtcm->buff[5] >> 3) * 3 + 6; - if (rtcm->nbyte < rtcm->len) continue; + if (rtcm->nbyte == 6) + { + rtcm->len = (rtcm->buff[5] >> 3) * 3 + 6; + } + if (rtcm->nbyte < rtcm->len) + { + continue; + } rtcm->nbyte = 0; rtcm->word &= 0x3; @@ -290,7 +330,10 @@ int input_rtcm3(rtcm_t *rtcm, unsigned char data) /* synchronize frame */ if (rtcm->nbyte == 0) { - if (data != RTCM3PREAMB) return 0; + if (data != RTCM3PREAMB) + { + return 0; + } rtcm->buff[rtcm->nbyte++] = data; return 0; } @@ -300,7 +343,10 @@ int input_rtcm3(rtcm_t *rtcm, unsigned char data) { rtcm->len = getbitu(rtcm->buff, 14, 10) + 3; /* length without parity */ } - if (rtcm->nbyte < 3 || rtcm->nbyte < rtcm->len + 3) return 0; + if (rtcm->nbyte < 3 || rtcm->nbyte < rtcm->len + 3) + { + return 0; + } rtcm->nbyte = 0; /* check parity */ @@ -329,8 +375,14 @@ int input_rtcm2f(rtcm_t *rtcm, FILE *fp) for (i = 0; i < 4096; i++) { - if ((data = fgetc(fp)) == EOF) return -2; - if ((ret = input_rtcm2(rtcm, static_cast(data)))) return ret; + if ((data = fgetc(fp)) == EOF) + { + return -2; + } + if ((ret = input_rtcm2(rtcm, static_cast(data)))) + { + return ret; + } } return 0; /* return at every 4k bytes */ } @@ -351,8 +403,14 @@ int input_rtcm3f(rtcm_t *rtcm, FILE *fp) for (i = 0; i < 4096; i++) { - if ((data = fgetc(fp)) == EOF) return -2; - if ((ret = input_rtcm3(rtcm, static_cast(data)))) return ret; + if ((data = fgetc(fp)) == EOF) + { + return -2; + } + if ((ret = input_rtcm3(rtcm, static_cast(data)))) + { + return ret; + } } return 0; /* return at every 4k bytes */ } diff --git a/src/algorithms/libs/rtklib/rtklib_rtcm2.cc b/src/algorithms/libs/rtklib/rtklib_rtcm2.cc index c7af88ccd..24528c762 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtcm2.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtcm2.cc @@ -63,14 +63,21 @@ void adjhour(rtcm_t *rtcm, double zcnt) int week; /* if no time, get cpu time */ - if (rtcm->time.time == 0) rtcm->time = utc2gpst(timeget()); + if (rtcm->time.time == 0) + { + rtcm->time = utc2gpst(timeget()); + } tow = time2gpst(rtcm->time, &week); hour = floor(tow / 3600.0); sec = tow - hour * 3600.0; if (zcnt < sec - 1800.0) - zcnt += 3600.0; + { + zcnt += 3600.0; + } else if (zcnt > sec + 1800.0) - zcnt -= 3600.0; + { + zcnt -= 3600.0; + } rtcm->time = gpst2time(week, hour * 3600 + zcnt); } @@ -82,9 +89,15 @@ int obsindex(obs_t *obs, gtime_t time, int sat) for (i = 0; i < obs->n; i++) { - if (obs->data[i].sat == sat) return i; /* field already exists */ + if (obs->data[i].sat == sat) + { + return i; /* field already exists */ + } + } + if (i >= MAXOBS) + { + return -1; /* overflow */ } - if (i >= MAXOBS) return -1; /* overflow */ /* add new field */ obs->data[i].time = time; @@ -122,7 +135,10 @@ int decode_type1(rtcm_t *rtcm) i += 8; iod = getbits(rtcm->buff, i, 8); i += 8; - if (prn == 0) prn = 32; + if (prn == 0) + { + prn = 32; + } if (prc == 0x80000000 || rrc == 0xFFFF8000) { trace(2, "rtcm2 1 prc/rrc indicates satellite problem: prn=%d\n", prn); @@ -290,7 +306,10 @@ int decode_type17(rtcm_t *rtcm) trace(2, "rtcm2 17 length error: len=%d\n", rtcm->len); return -1; } - if (prn == 0) prn = 32; + if (prn == 0) + { + prn = 32; + } sat = satno(SYS_GPS, prn); eph.sat = sat; eph.week = adjgpsweek(week); @@ -346,14 +365,20 @@ int decode_type18(rtcm_t *rtcm) i += 5; cp = getbits(rtcm->buff, i, 32); i += 32; - if (prn == 0) prn = 32; + if (prn == 0) + { + prn = 32; + } if (!(sat = satno(sys ? SYS_GLO : SYS_GPS, prn))) { trace(2, "rtcm2 18 satellite number error: sys=%d prn=%d\n", sys, prn); continue; } time = timeadd(rtcm->time, usec * 1E-6); - if (sys) time = utc2gpst(time); /* convert glonass time to gpst */ + if (sys) + { + time = utc2gpst(time); /* convert glonass time to gpst */ + } tt = timediff(rtcm->obs.data[0].time, time); if (rtcm->obsflag || fabs(tt) > 1E-9) @@ -414,14 +439,20 @@ int decode_type19(rtcm_t *rtcm) i += 5 + 8; pr = getbitu(rtcm->buff, i, 32); i += 32; - if (prn == 0) prn = 32; + if (prn == 0) + { + prn = 32; + } if (!(sat = satno(sys ? SYS_GLO : SYS_GPS, prn))) { trace(2, "rtcm2 19 satellite number error: sys=%d prn=%d\n", sys, prn); continue; } time = timeadd(rtcm->time, usec * 1E-6); - if (sys) time = utc2gpst(time); /* convert glonass time to gpst */ + if (sys) + { + time = utc2gpst(time); /* convert glonass time to gpst */ + } tt = timediff(rtcm->obs.data[0].time, time); if (rtcm->obsflag || fabs(tt) > 1E-9) @@ -479,7 +510,10 @@ int decode_type22(rtcm_t *rtcm) del[1][2] = getbits(rtcm->buff, i, 8) / 1600.0; } rtcm->sta.deltype = 1; /* xyz */ - for (j = 0; j < 3; j++) rtcm->sta.del[j] = del[0][j]; + for (j = 0; j < 3; j++) + { + rtcm->sta.del[j] = del[0][j]; + } rtcm->sta.hgt = hgt; return 5; } @@ -640,9 +674,13 @@ int decode_rtcm2(rtcm_t *rtcm) if (ret >= 0) { if (1 <= type && type <= 99) - rtcm->nmsg2[type]++; + { + rtcm->nmsg2[type]++; + } else - rtcm->nmsg2[0]++; + { + rtcm->nmsg2[0]++; + } } return ret; } diff --git a/src/algorithms/libs/rtklib/rtklib_rtcm3.cc b/src/algorithms/libs/rtklib/rtklib_rtcm3.cc index abda7995f..42721e641 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtcm3.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtcm3.cc @@ -115,12 +115,19 @@ void adjweek(rtcm_t *rtcm, double tow) int week; /* if no time, get cpu time */ - if (rtcm->time.time == 0) rtcm->time = utc2gpst(timeget()); + if (rtcm->time.time == 0) + { + rtcm->time = utc2gpst(timeget()); + } tow_p = time2gpst(rtcm->time, &week); if (tow < tow_p - 302400.0) - tow += 604800.0; + { + tow += 604800.0; + } else if (tow > tow_p + 302400.0) - tow -= 604800.0; + { + tow -= 604800.0; + } rtcm->time = gpst2time(week, tow); } @@ -130,7 +137,10 @@ int adjbdtweek(int week) { int w; (void)time2bdt(gpst2bdt(utc2gpst(timeget())), &w); - if (w < 1) w = 1; /* use 2006/1/1 if time is earlier than 2006/1/1 */ + if (w < 1) + { + w = 1; /* use 2006/1/1 if time is earlier than 2006/1/1 */ + } return week + (w - week + 512) / 1024 * 1024; } @@ -142,15 +152,22 @@ void adjday_glot(rtcm_t *rtcm, double tod) double tow, tod_p; int week; - if (rtcm->time.time == 0) rtcm->time = utc2gpst(timeget()); + if (rtcm->time.time == 0) + { + rtcm->time = utc2gpst(timeget()); + } time = timeadd(gpst2utc(rtcm->time), 10800.0); /* glonass time */ tow = time2gpst(time, &week); tod_p = fmod(tow, 86400.0); tow -= tod_p; if (tod < tod_p - 43200.0) - tod += 86400.0; + { + tod += 86400.0; + } else if (tod > tod_p + 43200.0) - tod -= 86400.0; + { + tod -= 86400.0; + } time = gpst2time(week, tow + tod); rtcm->time = utc2gpst(timeadd(time, -10800.0)); } @@ -160,11 +177,17 @@ void adjday_glot(rtcm_t *rtcm, double tod) double adjcp(rtcm_t *rtcm, int sat, int freq, double cp) { if (rtcm->cp[sat - 1][freq] == 0.0) - ; + { + ; + } else if (cp < rtcm->cp[sat - 1][freq] - 750.0) - cp += 1500.0; + { + cp += 1500.0; + } else if (cp > rtcm->cp[sat - 1][freq] + 750.0) - cp -= 1500.0; + { + cp -= 1500.0; + } rtcm->cp[sat - 1][freq] = cp; return cp; } @@ -193,9 +216,15 @@ int obsindex3(obs_t *obs, gtime_t time, int sat) for (i = 0; i < obs->n; i++) { - if (obs->data[i].sat == sat) return i; /* field already exists */ + if (obs->data[i].sat == sat) + { + return i; /* field already exists */ + } + } + if (i >= MAXOBS) + { + return -1; /* overflow */ } - if (i >= MAXOBS) return -1; /* overflow */ /* add new field */ obs->data[i].time = time; @@ -220,7 +249,10 @@ int test_staid(rtcm_t *rtcm, int staid) /* test station id option */ if ((p = strstr(rtcm->opt, "-STA=")) && sscanf(p, "-STA=%d", &id) == 1) { - if (staid != id) return 0; + if (staid != id) + { + return 0; + } } /* save station id */ if (rtcm->staid == 0 || rtcm->obsflag) @@ -266,7 +298,10 @@ int decode_head1001(rtcm_t *rtcm, int *sync) return -1; } /* test station id */ - if (!test_staid(rtcm, staid)) return -1; + if (!test_staid(rtcm, staid)) + { + return -1; + } adjweek(rtcm, tow); @@ -287,7 +322,10 @@ int decode_head1001(rtcm_t *rtcm, int *sync) int decode_type1001(rtcm_t *rtcm) { int sync; - if (decode_head1001(rtcm, &sync) < 0) return -1; + if (decode_head1001(rtcm, &sync) < 0) + { + return -1; + } rtcm->obsflag = !sync; return sync ? 0 : 1; } @@ -299,7 +337,10 @@ int decode_type1002(rtcm_t *rtcm) double pr1, cnr1, tt, cp1; int i = 24 + 64, j, index, nsat, sync, prn, code, sat, ppr1, lock1, amb, sys; - if ((nsat = decode_head1001(rtcm, &sync)) < 0) return -1; + if ((nsat = decode_head1001(rtcm, &sync)) < 0) + { + return -1; + } for (j = 0; j < nsat && rtcm->obs.n < MAXOBS && i + 74 <= rtcm->len * 8; j++) { @@ -336,7 +377,10 @@ int decode_type1002(rtcm_t *rtcm) { rtcm->obs.n = rtcm->obsflag = 0; } - if ((index = obsindex3(&rtcm->obs, rtcm->time, sat)) < 0) continue; + if ((index = obsindex3(&rtcm->obs, rtcm->time, sat)) < 0) + { + continue; + } pr1 = pr1 * 0.02 + amb * PRUNIT_GPS; if (ppr1 != static_cast(0xFFF80000)) { @@ -356,7 +400,10 @@ int decode_type1002(rtcm_t *rtcm) int decode_type1003(rtcm_t *rtcm) { int sync; - if (decode_head1001(rtcm, &sync) < 0) return -1; + if (decode_head1001(rtcm, &sync) < 0) + { + return -1; + } rtcm->obsflag = !sync; return sync ? 0 : 1; } @@ -370,7 +417,10 @@ int decode_type1004(rtcm_t *rtcm) int i = 24 + 64, j, index, nsat, sync, prn, sat, code1, code2, pr21, ppr1, ppr2; int lock1, lock2, amb, sys; - if ((nsat = decode_head1001(rtcm, &sync)) < 0) return -1; + if ((nsat = decode_head1001(rtcm, &sync)) < 0) + { + return -1; + } for (j = 0; j < nsat && rtcm->obs.n < MAXOBS && i + 125 <= rtcm->len * 8; j++) { @@ -417,7 +467,10 @@ int decode_type1004(rtcm_t *rtcm) { rtcm->obs.n = rtcm->obsflag = 0; } - if ((index = obsindex3(&rtcm->obs, rtcm->time, sat)) < 0) continue; + if ((index = obsindex3(&rtcm->obs, rtcm->time, sat)) < 0) + { + continue; + } pr1 = pr1 * 0.02 + amb * PRUNIT_GPS; if (ppr1 != static_cast(0xFFF80000)) { @@ -481,13 +534,19 @@ int decode_type1005(rtcm_t *rtcm) if (rtcm->outtype) { msg = rtcm->msgtype + strlen(rtcm->msgtype); - for (j = 0; j < 3; j++) re[j] = rr[j] * 0.0001; + for (j = 0; j < 3; j++) + { + re[j] = rr[j] * 0.0001; + } ecef2pos(re, pos); sprintf(msg, " staid=%4d pos=%.8f %.8f %.3f", staid, pos[0] * R2D, pos[1] * R2D, pos[2]); } /* test station id */ - if (!test_staid(rtcm, staid)) return -1; + if (!test_staid(rtcm, staid)) + { + return -1; + } rtcm->sta.deltype = 0; /* xyz */ for (j = 0; j < 3; j++) @@ -530,13 +589,19 @@ int decode_type1006(rtcm_t *rtcm) if (rtcm->outtype) { msg = rtcm->msgtype + strlen(rtcm->msgtype); - for (j = 0; j < 3; j++) re[j] = rr[j] * 0.0001; + for (j = 0; j < 3; j++) + { + re[j] = rr[j] * 0.0001; + } ecef2pos(re, pos); sprintf(msg, " staid=%4d pos=%.8f %.8f %.3f anth=%.3f", staid, pos[0] * R2D, pos[1] * R2D, pos[2], anth); } /* test station id */ - if (!test_staid(rtcm, staid)) return -1; + if (!test_staid(rtcm, staid)) + { + return -1; + } rtcm->sta.deltype = 1; /* xyz */ for (j = 0; j < 3; j++) @@ -581,7 +646,10 @@ int decode_type1007(rtcm_t *rtcm) sprintf(msg, " staid=%4d", staid); } /* test station id */ - if (!test_staid(rtcm, staid)) return -1; + if (!test_staid(rtcm, staid)) + { + return -1; + } strncpy(rtcm->sta.antdes, des, n); rtcm->sta.antdes[n] = '\0'; @@ -629,7 +697,10 @@ int decode_type1008(rtcm_t *rtcm) sprintf(msg, " staid=%4d", staid); } /* test station id */ - if (!test_staid(rtcm, staid)) return -1; + if (!test_staid(rtcm, staid)) + { + return -1; + } strncpy(rtcm->sta.antdes, des, n); rtcm->sta.antdes[n] = '\0'; @@ -666,7 +737,10 @@ int decode_head1009(rtcm_t *rtcm, int *sync) return -1; } /* test station id */ - if (!test_staid(rtcm, staid)) return -1; + if (!test_staid(rtcm, staid)) + { + return -1; + } adjday_glot(rtcm, tod); @@ -687,7 +761,10 @@ int decode_head1009(rtcm_t *rtcm, int *sync) int decode_type1009(rtcm_t *rtcm) { int sync; - if (decode_head1009(rtcm, &sync) < 0) return -1; + if (decode_head1009(rtcm, &sync) < 0) + { + return -1; + } rtcm->obsflag = !sync; return sync ? 0 : 1; } @@ -699,7 +776,10 @@ int decode_type1010(rtcm_t *rtcm) double pr1, cnr1, tt, cp1, lam1; int i = 24 + 61, j, index, nsat, sync, prn, sat, code, freq, ppr1, lock1, amb, sys = SYS_GLO; - if ((nsat = decode_head1009(rtcm, &sync)) < 0) return -1; + if ((nsat = decode_head1009(rtcm, &sync)) < 0) + { + return -1; + } for (j = 0; j < nsat && rtcm->obs.n < MAXOBS && i + 79 <= rtcm->len * 8; j++) { @@ -729,7 +809,10 @@ int decode_type1010(rtcm_t *rtcm) { rtcm->obs.n = rtcm->obsflag = 0; } - if ((index = obsindex3(&rtcm->obs, rtcm->time, sat)) < 0) continue; + if ((index = obsindex3(&rtcm->obs, rtcm->time, sat)) < 0) + { + continue; + } pr1 = pr1 * 0.02 + amb * PRUNIT_GLO; if (ppr1 != static_cast(0xFFF80000)) { @@ -750,7 +833,10 @@ int decode_type1010(rtcm_t *rtcm) int decode_type1011(rtcm_t *rtcm) { int sync; - if (decode_head1009(rtcm, &sync) < 0) return -1; + if (decode_head1009(rtcm, &sync) < 0) + { + return -1; + } rtcm->obsflag = !sync; return sync ? 0 : 1; } @@ -763,7 +849,10 @@ int decode_type1012(rtcm_t *rtcm) int i = 24 + 61, j, index, nsat, sync, prn, sat, freq, code1, code2, pr21, ppr1, ppr2; int lock1, lock2, amb, sys = SYS_GLO; - if ((nsat = decode_head1009(rtcm, &sync)) < 0) return -1; + if ((nsat = decode_head1009(rtcm, &sync)) < 0) + { + return -1; + } for (j = 0; j < nsat && rtcm->obs.n < MAXOBS && i + 130 <= rtcm->len * 8; j++) { @@ -803,7 +892,10 @@ int decode_type1012(rtcm_t *rtcm) { rtcm->obs.n = rtcm->obsflag = 0; } - if ((index = obsindex3(&rtcm->obs, rtcm->time, sat)) < 0) continue; + if ((index = obsindex3(&rtcm->obs, rtcm->time, sat)) < 0) + { + continue; + } pr1 = pr1 * 0.02 + amb * PRUNIT_GLO; if (ppr1 != static_cast(0xFFF80000)) { @@ -945,7 +1037,10 @@ int decode_type1019(rtcm_t *rtcm) eph.A = sqrtA * sqrtA; if (!strstr(rtcm->opt, "-EPHALL")) { - if (eph.iode == rtcm->nav.eph[sat - 1].iode) return 0; /* unchanged */ + if (eph.iode == rtcm->nav.eph[sat - 1].iode) + { + return 0; /* unchanged */ + } } rtcm->nav.eph[sat - 1] = eph; rtcm->ephsat = sat; @@ -1021,27 +1116,41 @@ int decode_type1020(rtcm_t *rtcm) geph.sat = sat; geph.svh = bn; geph.iode = tb & 0x7F; - if (rtcm->time.time == 0) rtcm->time = utc2gpst(timeget()); + if (rtcm->time.time == 0) + { + rtcm->time = utc2gpst(timeget()); + } tow = time2gpst(gpst2utc(rtcm->time), &week); tod = fmod(tow, 86400.0); tow -= tod; tof = tk_h * 3600.0 + tk_m * 60.0 + tk_s - 10800.0; /* lt->utc */ if (tof < tod - 43200.0) - tof += 86400.0; + { + tof += 86400.0; + } else if (tof > tod + 43200.0) - tof -= 86400.0; + { + tof -= 86400.0; + } geph.tof = utc2gpst(gpst2time(week, tow + tof)); toe = tb * 900.0 - 10800.0; /* lt->utc */ if (toe < tod - 43200.0) - toe += 86400.0; + { + toe += 86400.0; + } else if (toe > tod + 43200.0) - toe -= 86400.0; + { + toe -= 86400.0; + } geph.toe = utc2gpst(gpst2time(week, tow + toe)); /* utc->gpst */ if (!strstr(rtcm->opt, "-EPHALL")) { if (fabs(timediff(geph.toe, rtcm->nav.geph[prn - 1].toe)) < 1.0 && - geph.svh == rtcm->nav.geph[prn - 1].svh) return 0; /* unchanged */ + geph.svh == rtcm->nav.geph[prn - 1].svh) + { + return 0; /* unchanged */ + } } rtcm->nav.geph[prn - 1] = geph; rtcm->ephsat = sat; @@ -1230,7 +1339,10 @@ int decode_type1033(rtcm_t *rtcm) sprintf(msg, " staid=%4d", staid); } /* test station id */ - if (!test_staid(rtcm, staid)) return -1; + if (!test_staid(rtcm, staid)) + { + return -1; + } strncpy(rtcm->sta.antdes, des, n); rtcm->sta.antdes[n] = '\0'; @@ -1386,7 +1498,10 @@ int decode_type1044(rtcm_t *rtcm) if (!strstr(rtcm->opt, "-EPHALL")) { if (eph.iode == rtcm->nav.eph[sat - 1].iode && - eph.iodc == rtcm->nav.eph[sat - 1].iodc) return 0; /* unchanged */ + eph.iodc == rtcm->nav.eph[sat - 1].iodc) + { + return 0; /* unchanged */ + } } rtcm->nav.eph[sat - 1] = eph; rtcm->ephsat = sat; @@ -1490,7 +1605,10 @@ int decode_type1045(rtcm_t *rtcm) eph.code = 2; /* data source = f/nav e5a */ if (!strstr(rtcm->opt, "-EPHALL")) { - if (eph.iode == rtcm->nav.eph[sat - 1].iode) return 0; /* unchanged */ + if (eph.iode == rtcm->nav.eph[sat - 1].iode) + { + return 0; /* unchanged */ + } } rtcm->nav.eph[sat - 1] = eph; rtcm->ephsat = sat; @@ -1594,7 +1712,10 @@ int decode_type1046(rtcm_t *rtcm) eph.code = 2; /* data source = f/nav e5a */ if (!strstr(rtcm->opt, "-EPHALL")) { - if (eph.iode == rtcm->nav.eph[sat - 1].iode) return 0; /* unchanged */ + if (eph.iode == rtcm->nav.eph[sat - 1].iode) + { + return 0; /* unchanged */ + } } rtcm->nav.eph[sat - 1] = eph; rtcm->ephsat = sat; @@ -1704,7 +1825,10 @@ int decode_type1047(rtcm_t *rtcm) { if (timediff(eph.toe, rtcm->nav.eph[sat - 1].toe) == 0.0 && eph.iode == rtcm->nav.eph[sat - 1].iode && - eph.iodc == rtcm->nav.eph[sat - 1].iodc) return 0; /* unchanged */ + eph.iodc == rtcm->nav.eph[sat - 1].iodc) + { + return 0; /* unchanged */ + } } rtcm->nav.eph[sat - 1] = eph; rtcm->ephsat = sat; @@ -1809,7 +1933,10 @@ int decode_type63(rtcm_t *rtcm) { if (timediff(eph.toe, rtcm->nav.eph[sat - 1].toe) == 0.0 && eph.iode == rtcm->nav.eph[sat - 1].iode && - eph.iodc == rtcm->nav.eph[sat - 1].iodc) return 0; /* unchanged */ + eph.iodc == rtcm->nav.eph[sat - 1].iodc) + { + return 0; /* unchanged */ + } } rtcm->nav.eph[sat - 1] = eph; rtcm->ephsat = sat; @@ -1828,7 +1955,10 @@ int decode_ssr1_head(rtcm_t *rtcm, int sys, int *sync, int *iod, #ifndef SSR_QZSS_DRAFT_V05 ns = sys == SYS_QZS ? 4 : 6; #endif - if (i + (sys == SYS_GLO ? 53 : 50 + ns) > rtcm->len * 8) return -1; + if (i + (sys == SYS_GLO ? 53 : 50 + ns) > rtcm->len * 8) + { + return -1; + } if (sys == SYS_GLO) { @@ -1883,7 +2013,10 @@ int decode_ssr2_head(rtcm_t *rtcm, int sys, int *sync, int *iod, #ifndef SSR_QZSS_DRAFT_V05 ns = sys == SYS_QZS ? 4 : 6; #endif - if (i + (sys == SYS_GLO ? 52 : 49 + ns) > rtcm->len * 8) return -1; + if (i + (sys == SYS_GLO ? 52 : 49 + ns) > rtcm->len * 8) + { + return -1; + } if (sys == SYS_GLO) { @@ -1936,7 +2069,10 @@ int decode_ssr7_head(rtcm_t *rtcm, int sys, int *sync, int *iod, #ifndef SSR_QZSS_DRAFT_V05 ns = sys == SYS_QZS ? 4 : 6; #endif - if (i + (sys == SYS_GLO ? 54 : 51 + ns) > rtcm->len * 8) return -1; + if (i + (sys == SYS_GLO ? 54 : 51 + ns) > rtcm->len * 8) + { + return -1; + } if (sys == SYS_GLO) { @@ -2214,7 +2350,10 @@ int decode_ssr3(rtcm_t *rtcm, int sys) nbias = getbitu(rtcm->buff, i, 5); i += 5; - for (k = 0; k < MAXCODE; k++) cbias[k] = 0.0; + for (k = 0; k < MAXCODE; k++) + { + cbias[k] = 0.0; + } for (k = 0; k < nbias && i + 19 <= rtcm->len * 8; k++) { mode = getbitu(rtcm->buff, i, 5); @@ -2544,7 +2683,10 @@ int decode_ssr7(rtcm_t *rtcm, int sys) yaw_rate = getbits(rtcm->buff, i, 8); i += 8; - for (k = 0; k < MAXCODE; k++) pbias[k] = stdpb[k] = 0.0; + for (k = 0; k < MAXCODE; k++) + { + pbias[k] = stdpb[k] = 0.0; + } for (k = 0; k < nbias && i + 49 <= rtcm->len * 8; k++) { mode = getbitu(rtcm->buff, i, 5); @@ -2596,7 +2738,10 @@ void sigindex(int sys, const unsigned char *code, const int *freq, int n, /* test code priority */ for (i = 0; i < n; i++) { - if (!code[i]) continue; + if (!code[i]) + { + continue; + } if (freq[i] > NFREQ) { /* save as extended signal if freq > NFREQ */ @@ -2609,20 +2754,29 @@ void sigindex(int sys, const unsigned char *code, const int *freq, int n, /* select highest priority signal */ if (pri > pri_h[freq[i] - 1]) { - if (index[freq[i] - 1]) ex[index[freq[i] - 1] - 1] = 1; + if (index[freq[i] - 1]) + { + ex[index[freq[i] - 1] - 1] = 1; + } pri_h[freq[i] - 1] = pri; index[freq[i] - 1] = i + 1; } else - ex[i] = 1; + { + ex[i] = 1; + } } /* signal index in obs data */ for (i = nex = 0; i < n; i++) { if (ex[i] == 0) - ind[i] = freq[i] - 1; + { + ind[i] = freq[i] - 1; + } else if (nex < NEXOBS) - ind[i] = NFREQ + nex++; + { + ind[i] = NFREQ + nex++; + } else { /* no space in obs data */ trace(2, "rtcm msm: no space in obs data sys=%d code=%d\n", sys, code[i]); @@ -2704,17 +2858,27 @@ void save_msm_obs(rtcm_t *rtcm, int sys, msm_h_t *h, const double *r, if (sys == SYS_BDS) { if (freq[i] == 5) - freq[i] = 2; /* B2 */ + { + freq[i] = 2; /* B2 */ + } else if (freq[i] == 4) - freq[i] = 3; /* B3 */ + { + freq[i] = 3; /* B3 */ + } } if (code[i] != CODE_NONE) { - if (q) q += sprintf(q, "L%s%s", sig[i], i < h->nsig - 1 ? ", " : ""); + if (q) + { + q += sprintf(q, "L%s%s", sig[i], i < h->nsig - 1 ? ", " : ""); + } } else { - if (q) q += sprintf(q, "(%d)%s", h->sigs[i], i < h->nsig - 1 ? ", " : ""); + if (q) + { + q += sprintf(q, "(%d)%s", h->sigs[i], i < h->nsig - 1 ? ", " : ""); + } trace(2, "rtcm3 %d: unknown signal id=%2d\n", type, h->sigs[i]); } @@ -2728,9 +2892,13 @@ void save_msm_obs(rtcm_t *rtcm, int sys, msm_h_t *h, const double *r, { prn = h->sats[i]; if (sys == SYS_QZS) - prn += MINPRNQZS - 1; + { + prn += MINPRNQZS - 1; + } else if (sys == SYS_SBS) - prn += MINPRNSBS - 1; + { + prn += MINPRNSBS - 1; + } if ((sat = satno(sys, prn))) { @@ -2747,7 +2915,10 @@ void save_msm_obs(rtcm_t *rtcm, int sys, msm_h_t *h, const double *r, } for (k = 0; k < h->nsig; k++) { - if (!h->cellmask[k + i * h->nsig]) continue; + if (!h->cellmask[k + i * h->nsig]) + { + continue; + } if (sat && index >= 0 && ind[k] >= 0) { @@ -2843,13 +3014,19 @@ int decode_msm_head(rtcm_t *rtcm, int sys, int *sync, int *iod, { mask = getbitu(rtcm->buff, i, 1); i += 1; - if (mask) h->sats[h->nsat++] = j; + if (mask) + { + h->sats[h->nsat++] = j; + } } for (j = 1; j <= 32; j++) { mask = getbitu(rtcm->buff, i, 1); i += 1; - if (mask) h->sigs[h->nsig++] = j; + if (mask) + { + h->sigs[h->nsig++] = j; + } } } else @@ -2858,7 +3035,10 @@ int decode_msm_head(rtcm_t *rtcm, int sys, int *sync, int *iod, return -1; } /* test station id */ - if (!test_staid(rtcm, staid)) return -1; + if (!test_staid(rtcm, staid)) + { + return -1; + } if (h->nsat * h->nsig > 64) { @@ -2876,7 +3056,10 @@ int decode_msm_head(rtcm_t *rtcm, int sys, int *sync, int *iod, { h->cellmask[j] = getbitu(rtcm->buff, i, 1); i += 1; - if (h->cellmask[j]) ncell++; + if (h->cellmask[j]) + { + ncell++; + } } *hsize = i; @@ -2898,7 +3081,10 @@ int decode_msm0(rtcm_t *rtcm, int sys) { msm_h_t h = {0, 0, 0, 0, 0, 0, 0, 0, {0}, {0}, {0}}; int i, sync, iod; - if (decode_msm_head(rtcm, sys, &sync, &iod, &h, &i) < 0) return -1; + if (decode_msm_head(rtcm, sys, &sync, &iod, &h, &i) < 0) + { + return -1; + } rtcm->obsflag = !sync; return sync ? 0 : 1; } @@ -2914,7 +3100,10 @@ int decode_msm4(rtcm_t *rtcm, int sys) type = getbitu(rtcm->buff, 24, 12); /* decode msm header */ - if ((ncell = decode_msm_head(rtcm, sys, &sync, &iod, &h, &i)) < 0) return -1; + if ((ncell = decode_msm_head(rtcm, sys, &sync, &iod, &h, &i)) < 0) + { + return -1; + } if (i + h.nsat * 18 + ncell * 48 > rtcm->len * 8) { @@ -2922,34 +3111,52 @@ int decode_msm4(rtcm_t *rtcm, int sys) ncell, rtcm->len); return -1; } - for (j = 0; j < h.nsat; j++) r[j] = 0.0; - for (j = 0; j < ncell; j++) pr[j] = cp[j] = -1E16; + for (j = 0; j < h.nsat; j++) + { + r[j] = 0.0; + } + for (j = 0; j < ncell; j++) + { + pr[j] = cp[j] = -1E16; + } /* decode satellite data */ for (j = 0; j < h.nsat; j++) { /* range */ rng = getbitu(rtcm->buff, i, 8); i += 8; - if (rng != 255) r[j] = rng * RANGE_MS; + if (rng != 255) + { + r[j] = rng * RANGE_MS; + } } for (j = 0; j < h.nsat; j++) { rng_m = getbitu(rtcm->buff, i, 10); i += 10; - if (r[j] != 0.0) r[j] += rng_m * TWO_N10 * RANGE_MS; + if (r[j] != 0.0) + { + r[j] += rng_m * TWO_N10 * RANGE_MS; + } } /* decode signal data */ for (j = 0; j < ncell; j++) { /* pseudorange */ prv = getbits(rtcm->buff, i, 15); i += 15; - if (prv != -16384) pr[j] = prv * TWO_N24 * RANGE_MS; + if (prv != -16384) + { + pr[j] = prv * TWO_N24 * RANGE_MS; + } } for (j = 0; j < ncell; j++) { /* phaserange */ cpv = getbits(rtcm->buff, i, 22); i += 22; - if (cpv != -2097152) cp[j] = cpv * TWO_N29 * RANGE_MS; + if (cpv != -2097152) + { + cp[j] = cpv * TWO_N29 * RANGE_MS; + } } for (j = 0; j < ncell; j++) { /* lock time */ @@ -2985,7 +3192,10 @@ int decode_msm5(rtcm_t *rtcm, int sys) type = getbitu(rtcm->buff, 24, 12); /* decode msm header */ - if ((ncell = decode_msm_head(rtcm, sys, &sync, &iod, &h, &i)) < 0) return -1; + if ((ncell = decode_msm_head(rtcm, sys, &sync, &iod, &h, &i)) < 0) + { + return -1; + } if (i + h.nsat * 36 + ncell * 63 > rtcm->len * 8) { @@ -2998,14 +3208,20 @@ int decode_msm5(rtcm_t *rtcm, int sys) r[j] = rr[j] = 0.0; ex[j] = 15; } - for (j = 0; j < ncell; j++) pr[j] = cp[j] = rrf[j] = -1E16; + for (j = 0; j < ncell; j++) + { + pr[j] = cp[j] = rrf[j] = -1E16; + } /* decode satellite data */ for (j = 0; j < h.nsat; j++) { /* range */ rng = getbitu(rtcm->buff, i, 8); i += 8; - if (rng != 255) r[j] = rng * RANGE_MS; + if (rng != 255) + { + r[j] = rng * RANGE_MS; + } } for (j = 0; j < h.nsat; j++) { /* extended info */ @@ -3016,26 +3232,38 @@ int decode_msm5(rtcm_t *rtcm, int sys) { rng_m = getbitu(rtcm->buff, i, 10); i += 10; - if (r[j] != 0.0) r[j] += rng_m * TWO_N10 * RANGE_MS; + if (r[j] != 0.0) + { + r[j] += rng_m * TWO_N10 * RANGE_MS; + } } for (j = 0; j < h.nsat; j++) { /* phaserangerate */ rate = getbits(rtcm->buff, i, 14); i += 14; - if (rate != -8192) rr[j] = rate * 1.0; + if (rate != -8192) + { + rr[j] = rate * 1.0; + } } /* decode signal data */ for (j = 0; j < ncell; j++) { /* pseudorange */ prv = getbits(rtcm->buff, i, 15); i += 15; - if (prv != -16384) pr[j] = prv * TWO_N24 * RANGE_MS; + if (prv != -16384) + { + pr[j] = prv * TWO_N24 * RANGE_MS; + } } for (j = 0; j < ncell; j++) { /* phaserange */ cpv = getbits(rtcm->buff, i, 22); i += 22; - if (cpv != -2097152) cp[j] = cpv * TWO_N29 * RANGE_MS; + if (cpv != -2097152) + { + cp[j] = cpv * TWO_N29 * RANGE_MS; + } } for (j = 0; j < ncell; j++) { /* lock time */ @@ -3056,7 +3284,10 @@ int decode_msm5(rtcm_t *rtcm, int sys) { /* phaserangerate */ rrv = getbits(rtcm->buff, i, 15); i += 15; - if (rrv != -16384) rrf[j] = rrv * 0.0001; + if (rrv != -16384) + { + rrf[j] = rrv * 0.0001; + } } /* save obs data in msm message */ save_msm_obs(rtcm, sys, &h, r, pr, cp, rr, rrf, cnr, lock, ex, half); @@ -3076,7 +3307,10 @@ int decode_msm6(rtcm_t *rtcm, int sys) type = getbitu(rtcm->buff, 24, 12); /* decode msm header */ - if ((ncell = decode_msm_head(rtcm, sys, &sync, &iod, &h, &i)) < 0) return -1; + if ((ncell = decode_msm_head(rtcm, sys, &sync, &iod, &h, &i)) < 0) + { + return -1; + } if (i + h.nsat * 18 + ncell * 65 > rtcm->len * 8) { @@ -3084,34 +3318,52 @@ int decode_msm6(rtcm_t *rtcm, int sys) ncell, rtcm->len); return -1; } - for (j = 0; j < h.nsat; j++) r[j] = 0.0; - for (j = 0; j < ncell; j++) pr[j] = cp[j] = -1E16; + for (j = 0; j < h.nsat; j++) + { + r[j] = 0.0; + } + for (j = 0; j < ncell; j++) + { + pr[j] = cp[j] = -1E16; + } /* decode satellite data */ for (j = 0; j < h.nsat; j++) { /* range */ rng = getbitu(rtcm->buff, i, 8); i += 8; - if (rng != 255) r[j] = rng * RANGE_MS; + if (rng != 255) + { + r[j] = rng * RANGE_MS; + } } for (j = 0; j < h.nsat; j++) { rng_m = getbitu(rtcm->buff, i, 10); i += 10; - if (r[j] != 0.0) r[j] += rng_m * TWO_N10 * RANGE_MS; + if (r[j] != 0.0) + { + r[j] += rng_m * TWO_N10 * RANGE_MS; + } } /* decode signal data */ for (j = 0; j < ncell; j++) { /* pseudorange */ prv = getbits(rtcm->buff, i, 20); i += 20; - if (prv != -524288) pr[j] = prv * TWO_N29 * RANGE_MS; + if (prv != -524288) + { + pr[j] = prv * TWO_N29 * RANGE_MS; + } } for (j = 0; j < ncell; j++) { /* phaserange */ cpv = getbits(rtcm->buff, i, 24); i += 24; - if (cpv != -8388608) cp[j] = cpv * TWO_N31 * RANGE_MS; + if (cpv != -8388608) + { + cp[j] = cpv * TWO_N31 * RANGE_MS; + } } for (j = 0; j < ncell; j++) { /* lock time */ @@ -3147,7 +3399,10 @@ int decode_msm7(rtcm_t *rtcm, int sys) type = getbitu(rtcm->buff, 24, 12); /* decode msm header */ - if ((ncell = decode_msm_head(rtcm, sys, &sync, &iod, &h, &i)) < 0) return -1; + if ((ncell = decode_msm_head(rtcm, sys, &sync, &iod, &h, &i)) < 0) + { + return -1; + } if (i + h.nsat * 36 + ncell * 80 > rtcm->len * 8) { @@ -3160,14 +3415,20 @@ int decode_msm7(rtcm_t *rtcm, int sys) r[j] = rr[j] = 0.0; ex[j] = 15; } - for (j = 0; j < ncell; j++) pr[j] = cp[j] = rrf[j] = -1E16; + for (j = 0; j < ncell; j++) + { + pr[j] = cp[j] = rrf[j] = -1E16; + } /* decode satellite data */ for (j = 0; j < h.nsat; j++) { /* range */ rng = getbitu(rtcm->buff, i, 8); i += 8; - if (rng != 255) r[j] = rng * RANGE_MS; + if (rng != 255) + { + r[j] = rng * RANGE_MS; + } } for (j = 0; j < h.nsat; j++) { /* extended info */ @@ -3178,26 +3439,38 @@ int decode_msm7(rtcm_t *rtcm, int sys) { rng_m = getbitu(rtcm->buff, i, 10); i += 10; - if (r[j] != 0.0) r[j] += rng_m * TWO_N10 * RANGE_MS; + if (r[j] != 0.0) + { + r[j] += rng_m * TWO_N10 * RANGE_MS; + } } for (j = 0; j < h.nsat; j++) { /* phaserangerate */ rate = getbits(rtcm->buff, i, 14); i += 14; - if (rate != -8192) rr[j] = rate * 1.0; + if (rate != -8192) + { + rr[j] = rate * 1.0; + } } /* decode signal data */ for (j = 0; j < ncell; j++) { /* pseudorange */ prv = getbits(rtcm->buff, i, 20); i += 20; - if (prv != -524288) pr[j] = prv * TWO_N29 * RANGE_MS; + if (prv != -524288) + { + pr[j] = prv * TWO_N29 * RANGE_MS; + } } for (j = 0; j < ncell; j++) { /* phaserange */ cpv = getbits(rtcm->buff, i, 24); i += 24; - if (cpv != -8388608) cp[j] = cpv * TWO_N31 * RANGE_MS; + if (cpv != -8388608) + { + cp[j] = cpv * TWO_N31 * RANGE_MS; + } } for (j = 0; j < ncell; j++) { /* lock time */ @@ -3218,7 +3491,10 @@ int decode_msm7(rtcm_t *rtcm, int sys) { /* phaserangerate */ rrv = getbits(rtcm->buff, i, 15); i += 15; - if (rrv != -16384) rrf[j] = rrv * 0.0001; + if (rrv != -16384) + { + rrf[j] = rrv * 0.0001; + } } /* save obs data in msm message */ save_msm_obs(rtcm, sys, &h, r, pr, cp, rr, rrf, cnr, lock, ex, half); @@ -3624,11 +3900,17 @@ int decode_rtcm3(rtcm_t *rtcm) { type -= 1000; if (1 <= type && type <= 299) - rtcm->nmsg3[type]++; /* 1001-1299 */ + { + rtcm->nmsg3[type]++; /* 1001-1299 */ + } else if (1000 <= type && type <= 1099) - rtcm->nmsg3[type - 700]++; /* 2000-2099 */ + { + rtcm->nmsg3[type - 700]++; /* 2000-2099 */ + } else - rtcm->nmsg3[0]++; + { + rtcm->nmsg3[0]++; + } } return ret; } diff --git a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc index 03a391700..70b854400 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc @@ -263,33 +263,60 @@ void fatalerr(const char *format, ...) *-----------------------------------------------------------------------------*/ int satno(int sys, int prn) { - if (prn <= 0) return 0; + if (prn <= 0) + { + return 0; + } switch (sys) { case SYS_GPS: - if (prn < MINPRNGPS || MAXPRNGPS < prn) return 0; + if (prn < MINPRNGPS || MAXPRNGPS < prn) + { + return 0; + } return prn - MINPRNGPS + 1; case SYS_GLO: - if (prn < MINPRNGLO || MAXPRNGLO < prn) return 0; + if (prn < MINPRNGLO || MAXPRNGLO < prn) + { + return 0; + } return NSATGPS + prn - MINPRNGLO + 1; case SYS_GAL: - if (prn < MINPRNGAL || MAXPRNGAL < prn) return 0; + if (prn < MINPRNGAL || MAXPRNGAL < prn) + { + return 0; + } return NSATGPS + NSATGLO + prn - MINPRNGAL + 1; case SYS_QZS: - if (prn < MINPRNQZS || MAXPRNQZS < prn) return 0; + if (prn < MINPRNQZS || MAXPRNQZS < prn) + { + return 0; + } return NSATGPS + NSATGLO + NSATGAL + prn - MINPRNQZS + 1; case SYS_BDS: - if (prn < MINPRNBDS || MAXPRNBDS < prn) return 0; + if (prn < MINPRNBDS || MAXPRNBDS < prn) + { + return 0; + } return NSATGPS + NSATGLO + NSATGAL + NSATQZS + prn - MINPRNBDS + 1; case SYS_IRN: - if (prn < MINPRNIRN || MAXPRNIRN < prn) return 0; + if (prn < MINPRNIRN || MAXPRNIRN < prn) + { + return 0; + } return NSATGPS + NSATGLO + NSATGAL + NSATQZS + NSATBDS + prn - MINPRNIRN + 1; case SYS_LEO: - if (prn < MINPRNLEO || MAXPRNLEO < prn) return 0; + if (prn < MINPRNLEO || MAXPRNLEO < prn) + { + return 0; + } return NSATGPS + NSATGLO + NSATGAL + NSATQZS + NSATBDS + NSATIRN + prn - MINPRNLEO + 1; case SYS_SBS: - if (prn < MINPRNSBS || MAXPRNSBS < prn) return 0; + if (prn < MINPRNSBS || MAXPRNSBS < prn) + { + return 0; + } return NSATGPS + NSATGLO + NSATGAL + NSATQZS + NSATBDS + NSATIRN + NSATLEO + prn - MINPRNSBS + 1; } @@ -307,7 +334,9 @@ int satsys(int sat, int *prn) { int sys = SYS_NONE; if (sat <= 0 || MAXSAT < sat) - sat = 0; + { + sat = 0; + } else if (sat <= NSATGPS) { sys = SYS_GPS; @@ -349,8 +378,13 @@ int satsys(int sat, int *prn) sat += MINPRNSBS - 1; } else - sat = 0; - if (prn) *prn = sat; + { + sat = 0; + } + if (prn) + { + *prn = sat; + } return sys; } @@ -369,16 +403,27 @@ int satid2no(const char *id) if (sscanf(id, "%d", &prn) == 1) { if (MINPRNGPS <= prn && prn <= MAXPRNGPS) - sys = SYS_GPS; + { + sys = SYS_GPS; + } else if (MINPRNSBS <= prn && prn <= MAXPRNSBS) - sys = SYS_SBS; + { + sys = SYS_SBS; + } else if (MINPRNQZS <= prn && prn <= MAXPRNQZS) - sys = SYS_QZS; + { + sys = SYS_QZS; + } else - return 0; + { + return 0; + } return satno(sys, prn); } - if (sscanf(id, "%c%d", &code, &prn) < 2) return 0; + if (sscanf(id, "%c%d", &code, &prn) < 2) + { + return 0; + } switch (code) { @@ -485,14 +530,20 @@ int satexclude(int sat, int svh, const prcopt_t *opt) trace(3, "excluded satellite: sat=%3d svh=%02X\n", sat, svh); return 1; /* excluded satellite */ } - if (opt->exsats[sat - 1] == 2) return 0; /* included satellite */ + if (opt->exsats[sat - 1] == 2) + { + return 0; /* included satellite */ + } if (!(sys & opt->navsys)) { trace(3, "unselected sat sys: sat=%3d svh=%02X\n", sat, svh); return 1; /* unselected sat sys */ } } - if (sys == SYS_QZS) svh &= 0xFE; /* mask QZSS LEX health */ + if (sys == SYS_QZS) + { + svh &= 0xFE; /* mask QZSS LEX health */ + } if (svh) { trace(3, "unhealthy satellite: sat=%3d svh=%02X\n", sat, svh); @@ -517,17 +568,26 @@ int testsnr(int base, int freq, double el, double snr, double minsnr, a; int i; - if (!mask->ena[base] || freq < 0 || freq >= NFREQ) return 0; + if (!mask->ena[base] || freq < 0 || freq >= NFREQ) + { + return 0; + } a = (el * R2D + 5.0) / 10.0; i = static_cast(floor(a)); a -= i; if (i < 1) - minsnr = mask->mask[freq][0]; + { + minsnr = mask->mask[freq][0]; + } else if (i > 8) - minsnr = mask->mask[freq][8]; + { + minsnr = mask->mask[freq][8]; + } else - minsnr = (1.0 - a) * mask->mask[freq][i - 1] + a * mask->mask[freq][i]; + { + minsnr = (1.0 - a) * mask->mask[freq][i - 1] + a * mask->mask[freq][i]; + } return snr < minsnr; } @@ -544,11 +604,20 @@ int testsnr(int base, int freq, double el, double snr, unsigned char obs2code(const char *obs, int *freq) { int i; - if (freq) *freq = 0; + if (freq) + { + *freq = 0; + } for (i = 1; *obscodes[i]; i++) { - if (strcmp(obscodes[i], obs) != 0) continue; - if (freq) *freq = obsfreqs[i]; + if (strcmp(obscodes[i], obs) != 0) + { + continue; + } + if (freq) + { + *freq = obsfreqs[i]; + } return static_cast(i); } return CODE_NONE; @@ -566,9 +635,18 @@ unsigned char obs2code(const char *obs, int *freq) *-----------------------------------------------------------------------------*/ char *code2obs(unsigned char code, int *freq) { - if (freq) *freq = 0; - if (code <= CODE_NONE || MAXCODE < code) return (char *)""; - if (freq) *freq = obsfreqs[code]; + if (freq) + { + *freq = 0; + } + if (code <= CODE_NONE || MAXCODE < code) + { + return (char *)""; + } + if (freq) + { + *freq = obsfreqs[code]; + } return obscodes[code]; } @@ -585,16 +663,40 @@ void setcodepri(int sys, int freq, const char *pri) { trace(3, "setcodepri : sys=%d freq=%d pri=%s\n", sys, freq, pri); - if (freq <= 0 || MAXFREQ < freq) return; + if (freq <= 0 || MAXFREQ < freq) + { + return; + } if (strlen(pri) < 17) { - if (sys & SYS_GPS) strcpy(codepris[0][freq - 1], pri); - if (sys & SYS_GLO) strcpy(codepris[1][freq - 1], pri); - if (sys & SYS_GAL) strcpy(codepris[2][freq - 1], pri); - if (sys & SYS_QZS) strcpy(codepris[3][freq - 1], pri); - if (sys & SYS_SBS) strcpy(codepris[4][freq - 1], pri); - if (sys & SYS_BDS) strcpy(codepris[5][freq - 1], pri); - if (sys & SYS_IRN) strcpy(codepris[6][freq - 1], pri); + if (sys & SYS_GPS) + { + strcpy(codepris[0][freq - 1], pri); + } + if (sys & SYS_GLO) + { + strcpy(codepris[1][freq - 1], pri); + } + if (sys & SYS_GAL) + { + strcpy(codepris[2][freq - 1], pri); + } + if (sys & SYS_QZS) + { + strcpy(codepris[3][freq - 1], pri); + } + if (sys & SYS_SBS) + { + strcpy(codepris[4][freq - 1], pri); + } + if (sys & SYS_BDS) + { + strcpy(codepris[5][freq - 1], pri); + } + if (sys & SYS_IRN) + { + strcpy(codepris[6][freq - 1], pri); + } } else { @@ -654,7 +756,10 @@ int getcodepri(int sys, unsigned char code, const char *opt) /* parse code options */ for (p = opt; p && (p = strchr(p, '-')); p++) { - if (sscanf(p, optstr, str) < 1 || str[0] != obs[0]) continue; + if (sscanf(p, optstr, str) < 1 || str[0] != obs[0]) + { + continue; + } return str[1] == obs[1] ? 15 : 0; } /* search code priority */ @@ -673,7 +778,10 @@ unsigned int getbitu(const unsigned char *buff, int pos, int len) { unsigned int bits = 0; int i; - for (i = pos; i < pos + len; i++) bits = (bits << 1) + ((buff[i / 8] >> (7 - i % 8)) & 1u); + for (i = pos; i < pos + len; i++) + { + bits = (bits << 1) + ((buff[i / 8] >> (7 - i % 8)) & 1u); + } return bits; } @@ -681,7 +789,10 @@ unsigned int getbitu(const unsigned char *buff, int pos, int len) int getbits(const unsigned char *buff, int pos, int len) { unsigned int bits = getbitu(buff, pos, len); - if (len <= 0 || 32 <= len || !(bits & (1u << (len - 1)))) return static_cast(bits); + if (len <= 0 || 32 <= len || !(bits & (1u << (len - 1)))) + { + return static_cast(bits); + } return static_cast(bits | (~0u << len)); /* extend sign */ } @@ -698,13 +809,20 @@ void setbitu(unsigned char *buff, int pos, int len, unsigned int data) { unsigned int mask = 1u << (len - 1); int i; - if (len <= 0 || 32 < len) return; + if (len <= 0 || 32 < len) + { + return; + } for (i = pos; i < pos + len; i++, mask >>= 1) { if (data & mask) - buff[i / 8] |= 1u << (7 - i % 8); + { + buff[i / 8] |= 1u << (7 - i % 8); + } else - buff[i / 8] &= ~(1u << (7 - i % 8)); + { + buff[i / 8] &= ~(1u << (7 - i % 8)); + } } } @@ -712,9 +830,13 @@ void setbitu(unsigned char *buff, int pos, int len, unsigned int data) void setbits(unsigned char *buff, int pos, int len, int data) { if (data < 0) - data |= 1 << (len - 1); + { + data |= 1 << (len - 1); + } else - data &= ~(1 << (len - 1)); /* set sign bit */ + { + data &= ~(1 << (len - 1)); /* set sign bit */ + } setbitu(buff, pos, len, static_cast(data)); } @@ -739,9 +861,13 @@ unsigned int rtk_crc32(const unsigned char *buff, int len) for (j = 0; j < 8; j++) { if (crc & 1) - crc = (crc >> 1) ^ POLYCRC32; + { + crc = (crc >> 1) ^ POLYCRC32; + } else - crc >>= 1; + { + crc >>= 1; + } } } return crc; @@ -762,7 +888,10 @@ unsigned int rtk_crc24q(const unsigned char *buff, int len) trace(4, "rtk_crc24q: len=%d\n", len); - for (i = 0; i < len; i++) crc = ((crc << 8) & 0xFFFFFF) ^ tbl_CRC24Q[(crc >> 16) ^ buff[i]]; + for (i = 0; i < len; i++) + { + crc = ((crc << 8) & 0xFFFFFF) ^ tbl_CRC24Q[(crc >> 16) ^ buff[i]]; + } return crc; } @@ -807,16 +936,28 @@ int decode_word(unsigned int word, unsigned char *data) trace(5, "decodeword: word=%08x\n", word); - if (word & 0x40000000) word ^= 0x3FFFFFC0; + if (word & 0x40000000) + { + word ^= 0x3FFFFFC0; + } for (i = 0; i < 6; i++) { parity <<= 1; - for (w = (word & hamming[i]) >> 6; w; w >>= 1) parity ^= w & 1; + for (w = (word & hamming[i]) >> 6; w; w >>= 1) + { + parity ^= w & 1; + } + } + if (parity != (word & 0x3F)) + { + return 0; } - if (parity != (word & 0x3F)) return 0; - for (i = 0; i < 3; i++) data[i] = static_cast(word >> (22 - i * 8)); + for (i = 0; i < 3; i++) + { + data[i] = static_cast(word >> (22 - i * 8)); + } return 1; } @@ -830,7 +971,10 @@ double *mat(int n, int m) { double *p; - if (n <= 0 || m <= 0) return nullptr; + if (n <= 0 || m <= 0) + { + return nullptr; + } if (!(p = static_cast(malloc(sizeof(double) * n * m)))) { fatalerr("matrix memory allocation error: n=%d,m=%d\n", n, m); @@ -848,7 +992,10 @@ int *imat(int n, int m) { int *p; - if (n <= 0 || m <= 0) return nullptr; + if (n <= 0 || m <= 0) + { + return nullptr; + } if (!(p = static_cast(malloc(sizeof(int) * n * m)))) { fatalerr("integer matrix memory allocation error: n=%d,m=%d\n", n, m); @@ -870,7 +1017,10 @@ double *zeros(int n, int m) if ((p = mat(n, m))) for (n = n * m - 1; n >= 0; n--) p[n] = 0.0; #else - if (n <= 0 || m <= 0) return nullptr; + if (n <= 0 || m <= 0) + { + return nullptr; + } if (!(p = static_cast(calloc(sizeof(double), n * m)))) { fatalerr("matrix memory allocation error: n=%d,m=%d\n", n, m); @@ -891,7 +1041,12 @@ double *eye(int n) int i; if ((p = zeros(n, n))) - for (i = 0; i < n; i++) p[i + i * n] = 1.0; + { + for (i = 0; i < n; i++) + { + p[i + i * n] = 1.0; + } + } return p; } @@ -906,7 +1061,10 @@ double dot(const double *a, const double *b, int n) { double c = 0.0; - while (--n >= 0) c += a[n] * b[n]; + while (--n >= 0) + { + c += a[n] * b[n]; + } return c; } @@ -946,7 +1104,10 @@ void cross3(const double *a, const double *b, double *c) int normv3(const double *a, double *b) { double r; - if ((r = norm_rtk(a, 3)) <= 0.0) return 0; + if ((r = norm_rtk(a, 3)) <= 0.0) + { + return 0; + } b[0] = a[0] / r; b[1] = a[1] / r; b[2] = a[2] / r; @@ -1002,7 +1163,10 @@ int matinv(double *A, int n) work = mat(lwork, 1); dgetrf_(&n, &n, A, &n, ipiv, &info); - if (!info) dgetri_(&n, A, &n, ipiv, work, &lwork, &info); + if (!info) + { + dgetri_(&n, A, &n, ipiv, work, &lwork, &info); + } free(ipiv); free(work); return info; @@ -1029,7 +1193,10 @@ int solve(const char *tr, const double *A, const double *Y, int n, matcpy(B, A, n, n); matcpy(X, Y, n, m); dgetrf_(&n, &n, B, &n, ipiv, &info); - if (!info) dgetrs_(const_cast(tr), &n, &m, B, &n, ipiv, X, &n, &info); + if (!info) + { + dgetrs_(const_cast(tr), &n, &m, B, &n, ipiv, X, &n, &info); + } free(ipiv); free(B); return info; @@ -1055,11 +1222,17 @@ int lsq(const double *A, const double *y, int n, int m, double *x, double *Ay; int info; - if (m < n) return -1; + if (m < n) + { + return -1; + } Ay = mat(n, 1); - matmul("NN", n, 1, m, 1.0, A, y, 0.0, Ay); /* Ay=A*y */ - matmul("NT", n, n, m, 1.0, A, A, 0.0, Q); /* Q=A*A' */ - if (!(info = matinv(Q, n))) matmul("NN", n, 1, n, 1.0, Q, Ay, 0.0, x); /* x=Q^-1*Ay */ + matmul("NN", n, 1, m, 1.0, A, y, 0.0, Ay); /* Ay=A*y */ + matmul("NT", n, n, m, 1.0, A, A, 0.0, Q); /* Q=A*A' */ + if (!(info = matinv(Q, n))) + { + matmul("NN", n, 1, n, 1.0, Q, Ay, 0.0, x); /* x=Q^-1*Ay */ + } free(Ay); return info; } @@ -1116,7 +1289,12 @@ int filter(double *x, double *P, const double *H, const double *v, ix = imat(n, 1); for (i = k = 0; i < n; i++) - if (x[i] != 0.0 && P[i + i * n] > 0.0) ix[k++] = i; + { + if (x[i] != 0.0 && P[i + i * n] > 0.0) + { + ix[k++] = i; + } + } x_ = mat(k, 1); xp_ = mat(k, 1); P_ = mat(k, k); @@ -1125,14 +1303,23 @@ int filter(double *x, double *P, const double *H, const double *v, for (i = 0; i < k; i++) { x_[i] = x[ix[i]]; - for (j = 0; j < k; j++) P_[i + j * k] = P[ix[i] + ix[j] * n]; - for (j = 0; j < m; j++) H_[i + j * k] = H[ix[i] + j * n]; + for (j = 0; j < k; j++) + { + P_[i + j * k] = P[ix[i] + ix[j] * n]; + } + for (j = 0; j < m; j++) + { + H_[i + j * k] = H[ix[i] + j * n]; + } } info = filter_(x_, P_, H_, v, R, k, m, xp_, Pp_); for (i = 0; i < k; i++) { x[ix[i]] = xp_[i]; - for (j = 0; j < k; j++) P[ix[i] + ix[j] * n] = Pp_[i + j * k]; + for (j = 0; j < k; j++) + { + P[ix[i] + ix[j] * n] = Pp_[i + j * k]; + } } free(ix); free(x_); @@ -1170,7 +1357,10 @@ int smoother(const double *xf, const double *Qf, const double *xb, matcpy(invQb, Qb, n, n); if (!matinv(invQf, n) && !matinv(invQb, n)) { - for (i = 0; i < n * n; i++) Qs[i] = invQf[i] + invQb[i]; + for (i = 0; i < n * n; i++) + { + Qs[i] = invQf[i] + invQb[i]; + } if (!(info = matinv(Qs, n))) { matmul("NN", n, 1, n, 1.0, invQf, xf, 0.0, xx); @@ -1200,7 +1390,10 @@ void matfprint(const double A[], int n, int m, int p, int q, FILE *fp) for (i = 0; i < n; i++) { - for (j = 0; j < m; j++) fprintf(fp, " %*.*f", p, q, A[i + j * n]); + for (j = 0; j < m; j++) + { + fprintf(fp, " %*.*f", p, q, A[i + j * n]); + } fprintf(fp, "\n"); } } @@ -1240,7 +1433,10 @@ double str2num(const char *s, int i, int n) double value; char str[256], *p = str; - if (i < 0 || static_cast(strlen(s)) < i || static_cast(sizeof(str)) - 1 < n) return 0.0; + if (i < 0 || static_cast(strlen(s)) < i || static_cast(sizeof(str)) - 1 < n) + { + return 0.0; + } for (s += i; *s && --n >= 0; s++) { *p++ = *s == 'd' || *s == 'D' ? 'E' : *s; @@ -1262,15 +1458,23 @@ int str2time(const char *s, int i, int n, gtime_t *t) double ep[6]; char str[256], *p = str; - if (i < 0 || static_cast(strlen(s)) < i || static_cast(sizeof(str)) - 1 < i) return -1; + if (i < 0 || static_cast(strlen(s)) < i || static_cast(sizeof(str)) - 1 < i) + { + return -1; + } for (s += i; *s && --n >= 0;) { *p++ = *s++; } *p = '\0'; if (sscanf(str, "%lf %lf %lf %lf %lf %lf", ep, ep + 1, ep + 2, ep + 3, ep + 4, ep + 5) < 6) - return -1; - if (ep[0] < 100.0) ep[0] += ep[0] < 80.0 ? 2000.0 : 1900.0; + { + return -1; + } + if (ep[0] < 100.0) + { + ep[0] += ep[0] < 80.0 ? 2000.0 : 1900.0; + } *t = epoch2time(ep); return 0; } @@ -1288,7 +1492,10 @@ gtime_t epoch2time(const double *ep) gtime_t time = {0, 0}; int days, sec, year = static_cast(ep[0]), mon = static_cast(ep[1]), day = static_cast(ep[2]); - if (year < 1970 || 2099 < year || mon < 1 || 12 < mon) return time; + if (year < 1970 || 2099 < year || mon < 1 || 12 < mon) + { + return time; + } /* leap year if year%4==0 in 1901-2099 */ days = (year - 1970) * 365 + (year - 1969) / 4 + doy[mon - 1] + day - 2 + (year % 4 == 0 && mon >= 3 ? 1 : 0); @@ -1319,9 +1526,13 @@ void time2epoch(gtime_t t, double *ep) for (day = days % 1461, mon = 0; mon < 48; mon++) { if (day >= mday[mon]) - day -= mday[mon]; + { + day -= mday[mon]; + } else - break; + { + break; + } } ep[0] = 1970 + days / 1461 * 4 + mon / 12; ep[1] = mon % 12 + 1; @@ -1342,7 +1553,10 @@ gtime_t gpst2time(int week, double sec) { gtime_t t = epoch2time(gpst0); - if (sec < -1e9 || 1e9 < sec) sec = 0.0; + if (sec < -1e9 || 1e9 < sec) + { + sec = 0.0; + } t.time += static_cast(86400) * 7 * week + static_cast(sec); t.sec = sec - static_cast(sec); return t; @@ -1361,7 +1575,10 @@ double time2gpst(gtime_t t, int *week) time_t sec = t.time - t0.time; int w = static_cast(sec / 604800); - if (week) *week = w; + if (week) + { + *week = w; + } return (static_cast(sec - static_cast(w * 604800)) + t.sec); } @@ -1376,7 +1593,10 @@ gtime_t gst2time(int week, double sec) { gtime_t t = epoch2time(gst0); - if (sec < -1e9 || 1e9 < sec) sec = 0.0; + if (sec < -1e9 || 1e9 < sec) + { + sec = 0.0; + } t.time += static_cast(86400) * 7 * week + static_cast(sec); t.sec = sec - static_cast(sec); return t; @@ -1395,7 +1615,10 @@ double time2gst(gtime_t t, int *week) time_t sec = t.time - t0.time; int w = static_cast(sec / (86400 * 7)); - if (week) *week = w; + if (week) + { + *week = w; + } return (sec - static_cast(w) * 86400 * 7) + t.sec; } @@ -1410,7 +1633,10 @@ gtime_t bdt2time(int week, double sec) { gtime_t t = epoch2time(bdt0); - if (sec < -1e9 || 1e9 < sec) sec = 0.0; + if (sec < -1e9 || 1e9 < sec) + { + sec = 0.0; + } t.time += static_cast(86400) * 7 * week + static_cast(sec); t.sec = sec - static_cast(sec); return t; @@ -1429,7 +1655,10 @@ double time2bdt(gtime_t t, int *week) time_t sec = t.time - t0.time; int w = static_cast(sec / (86400 * 7)); - if (week) *week = w; + if (week) + { + *week = w; + } return (sec - static_cast(w) * 86400 * 7) + t.sec; } @@ -1518,10 +1747,19 @@ int read_leaps_text(FILE *fp) while (fgets(buff, sizeof(buff), fp) && n < MAXLEAPS) { - if ((p = strchr(buff, '#'))) *p = '\0'; + if ((p = strchr(buff, '#'))) + { + *p = '\0'; + } if (sscanf(buff, "%d %d %d %d %d %d %d", ep, ep + 1, ep + 2, ep + 3, ep + 4, ep + 5, - &ls) < 7) continue; - for (i = 0; i < 6; i++) leaps[n][i] = ep[i]; + &ls) < 7) + { + continue; + } + for (i = 0; i < 6; i++) + { + leaps[n][i] = ep[i]; + } leaps[n++][6] = ls; } return n; @@ -1542,21 +1780,37 @@ int read_leaps_usno(FILE *fp) while (fgets(buff, sizeof(buff), fp) && n < MAXLEAPS) { if (sscanf(buff, "%d %s %d =JD %lf TAI-UTC= %lf", &y, month, &d, &jd, - &tai_utc) < 5) continue; - if (y < 1980) continue; + &tai_utc) < 5) + { + continue; + } + if (y < 1980) + { + continue; + } for (m = 1; m <= 12; m++) - if (!strcmp(months[m - 1], month)) break; - if (m >= 13) continue; + { + if (!strcmp(months[m - 1], month)) + { + break; + } + } + if (m >= 13) + { + continue; + } ls[n][0] = y; ls[n][1] = m; ls[n][2] = d; ls[n++][6] = static_cast(19.0 - tai_utc); } for (i = 0; i < n; i++) - for (j = 0; j < 7; j++) - { - leaps[i][j] = ls[n - i - 1][j]; - } + { + for (j = 0; j < 7; j++) + { + leaps[i][j] = ls[n - i - 1][j]; + } + } return n; } @@ -1577,7 +1831,10 @@ int read_leaps(const char *file) FILE *fp; int i, n; - if (!(fp = fopen(file, "re"))) return 0; + if (!(fp = fopen(file, "re"))) + { + return 0; + } /* read leap seconds table by text or usno */ if (!(n = read_leaps_text(fp)) && !(n = read_leaps_usno(fp))) @@ -1585,7 +1842,10 @@ int read_leaps(const char *file) fclose(fp); return 0; } - for (i = 0; i < 7; i++) leaps[n][i] = 0.0; + for (i = 0; i < 7; i++) + { + leaps[n][i] = 0.0; + } fclose(fp); return 1; } @@ -1605,7 +1865,10 @@ gtime_t gpst2utc(gtime_t t) for (i = 0; leaps[i][0] > 0; i++) { tu = timeadd(t, leaps[i][6]); - if (timediff(tu, epoch2time(leaps[i])) >= 0.0) return tu; + if (timediff(tu, epoch2time(leaps[i])) >= 0.0) + { + return tu; + } } return t; } @@ -1623,7 +1886,10 @@ gtime_t utc2gpst(gtime_t t) for (i = 0; leaps[i][0] > 0; i++) { - if (timediff(t, epoch2time(leaps[i])) >= 0.0) return timeadd(t, -leaps[i][6]); + if (timediff(t, epoch2time(leaps[i])) >= 0.0) + { + return timeadd(t, -leaps[i][6]); + } } return t; } @@ -1703,9 +1969,13 @@ void time2str(gtime_t t, char *s, int n) double ep[6]; if (n < 0) - n = 0; + { + n = 0; + } else if (n > 12) - n = 12; + { + n = 12; + } if (1.0 - t.sec < 0.5 / pow(10.0, n)) { t.time++; @@ -1757,7 +2027,10 @@ int adjgpsweek(int week) { int w; (void)time2gpst(utc2gpst(timeget()), &w); - if (w < 1560) w = 1560; /* use 2009/12/1 if time is earlier than 2009/12/1 */ + if (w < 1560) + { + w = 1560; /* use 2009/12/1 if time is earlier than 2009/12/1 */ + } return week + (w - week + 512) / 1024 * 1024; } @@ -1796,7 +2069,10 @@ unsigned int tickget(void) void sleepms(int ms) { struct timespec ts = {0, 0}; - if (ms <= 0) return; + if (ms <= 0) + { + return; + } ts.tv_sec = static_cast(ms / 1000); ts.tv_nsec = static_cast(ms % 1000 * 1000000); nanosleep(&ts, nullptr); @@ -1998,11 +2274,17 @@ void ast_args(double t, double *f) double tt[4]; int i, j; - for (tt[0] = t, i = 1; i < 4; i++) tt[i] = tt[i - 1] * t; + for (tt[0] = t, i = 1; i < 4; i++) + { + tt[i] = tt[i - 1] * t; + } for (i = 0; i < 5; i++) { f[i] = fc[i][0] * 3600.0; - for (j = 0; j < 4; j++) f[i] += fc[i][j + 1] * tt[j]; + for (j = 0; j < 4; j++) + { + f[i] += fc[i][j + 1] * tt[j]; + } f[i] = fmod(f[i] * AS2R, 2.0 * PI); } } @@ -2126,7 +2408,10 @@ void nut_iau1980(double t, const double *f, double *dpsi, double *deps) for (i = 0; i < 106; i++) { ang = 0.0; - for (j = 0; j < 5; j++) ang += nut[i][j] * f[j]; + for (j = 0; j < 5; j++) + { + ang += nut[i][j] * f[j]; + } *dpsi += (nut[i][6] + nut[i][7] * t) * sin(ang); *deps += (nut[i][8] + nut[i][9] * t) * cos(ang); } @@ -2160,8 +2445,14 @@ void eci2ecef(gtime_t tutc, const double *erpv, double *U, double *gmst) if (fabs(timediff(tutc, tutc_)) < 0.01) { /* read cache */ - for (i = 0; i < 9; i++) U[i] = U_[i]; - if (gmst) *gmst = gmst_; + for (i = 0; i < 9; i++) + { + U[i] = U_[i]; + } + if (gmst) + { + *gmst = gmst_; + } return; } tutc_ = tutc; @@ -2208,8 +2499,14 @@ void eci2ecef(gtime_t tutc, const double *erpv, double *U, double *gmst) matmul("NN", 3, 3, 3, 1.0, N, P, 0.0, NP); matmul("NN", 3, 3, 3, 1.0, R, NP, 0.0, U_); /* U=W*Rz(gast)*N*P */ - for (i = 0; i < 9; i++) U[i] = U_[i]; - if (gmst) *gmst = gmst_; + for (i = 0; i < 9; i++) + { + U[i] = U_[i]; + } + if (gmst) + { + *gmst = gmst_; + } trace(5, "gmst=%.12f gast=%.12f\n", gmst_, gast); trace(5, "P=\n"); @@ -2228,7 +2525,10 @@ int decodef(char *p, int n, double *v) { int i; - for (i = 0; i < n; i++) v[i] = 0.0; + for (i = 0; i < n; i++) + { + v[i] = 0.0; + } for (i = 0, p = strtok(p, " "); p && i < n; p = strtok(nullptr, " ")) { v[i++] = atof(p) * 1e-3; @@ -2276,9 +2576,15 @@ int readngspcv(const char *file, pcvs_t *pcvs) } while (fgets(buff, sizeof(buff), fp)) { - if (strlen(buff) >= 62 && buff[61] == '|') continue; + if (strlen(buff) >= 62 && buff[61] == '|') + { + continue; + } - if (buff[0] != ' ') n = 0; /* start line */ + if (buff[0] != ' ') + { + n = 0; /* start line */ + } if (++n == 1) { pcv = pcv0; @@ -2287,25 +2593,36 @@ int readngspcv(const char *file, pcvs_t *pcvs) } else if (n == 2) { - if (decodef(buff, 3, neu) < 3) continue; + if (decodef(buff, 3, neu) < 3) + { + continue; + } pcv.off[0][0] = neu[1]; pcv.off[0][1] = neu[0]; pcv.off[0][2] = neu[2]; } else if (n == 3) - decodef(buff, 10, pcv.var[0]); + { + decodef(buff, 10, pcv.var[0]); + } else if (n == 4) - decodef(buff, 9, pcv.var[0] + 10); + { + decodef(buff, 9, pcv.var[0] + 10); + } else if (n == 5) { - if (decodef(buff, 3, neu) < 3) continue; - ; + if (decodef(buff, 3, neu) < 3) + { + continue; + }; pcv.off[1][0] = neu[1]; pcv.off[1][1] = neu[0]; pcv.off[1][2] = neu[2]; } else if (n == 6) - decodef(buff, 10, pcv.var[1]); + { + decodef(buff, 10, pcv.var[1]); + } else if (n == 7) { decodef(buff, 9, pcv.var[1] + 10); @@ -2337,7 +2654,10 @@ int readantex(const char *file, pcvs_t *pcvs) } while (fgets(buff, sizeof(buff), fp)) { - if (strlen(buff) < 60 || strstr(buff + 60, "COMMENT")) continue; + if (strlen(buff) < 60 || strstr(buff + 60, "COMMENT")) + { + continue; + } if (strstr(buff + 60, "START OF ANTENNA")) { @@ -2349,7 +2669,10 @@ int readantex(const char *file, pcvs_t *pcvs) addpcv(&pcv, pcvs); state = 0; } - if (!state) continue; + if (!state) + { + continue; + } if (strstr(buff + 60, "TYPE / SERIAL NO")) { @@ -2364,18 +2687,35 @@ int readantex(const char *file, pcvs_t *pcvs) } else if (strstr(buff + 60, "VALID FROM")) { - if (!str2time(buff, 0, 43, &pcv.ts)) continue; + if (!str2time(buff, 0, 43, &pcv.ts)) + { + continue; + } } else if (strstr(buff + 60, "VALID UNTIL")) { - if (!str2time(buff, 0, 43, &pcv.te)) continue; + if (!str2time(buff, 0, 43, &pcv.te)) + { + continue; + } } else if (strstr(buff + 60, "START OF FREQUENCY")) { - if (sscanf(buff + 4, "%d", &f) < 1) continue; + if (sscanf(buff + 4, "%d", &f) < 1) + { + continue; + } for (i = 0; i < NFREQ; i++) - if (freqs[i] == f) break; - if (i < NFREQ) freq = i + 1; + { + if (freqs[i] == f) + { + break; + } + } + if (i < NFREQ) + { + freq = i + 1; + } } else if (strstr(buff + 60, "END OF FREQUENCY")) { @@ -2383,17 +2723,32 @@ int readantex(const char *file, pcvs_t *pcvs) } else if (strstr(buff + 60, "NORTH / EAST / UP")) { - if (freq < 1 || NFREQ < freq) continue; - if (decodef(buff, 3, neu) < 3) continue; + if (freq < 1 || NFREQ < freq) + { + continue; + } + if (decodef(buff, 3, neu) < 3) + { + continue; + } pcv.off[freq - 1][0] = neu[pcv.sat ? 0 : 1]; /* x or e */ pcv.off[freq - 1][1] = neu[pcv.sat ? 1 : 0]; /* y or n */ pcv.off[freq - 1][2] = neu[2]; /* z or u */ } else if (strstr(buff, "NOAZI")) { - if (freq < 1 || NFREQ < freq) continue; - if ((i = decodef(buff + 8, 19, pcv.var[freq - 1])) <= 0) continue; - for (; i < 19; i++) pcv.var[freq - 1][i] = pcv.var[freq - 1][i - 1]; + if (freq < 1 || NFREQ < freq) + { + continue; + } + if ((i = decodef(buff + 8, 19, pcv.var[freq - 1])) <= 0) + { + continue; + } + for (; i < 19; i++) + { + pcv.var[freq - 1][i] = pcv.var[freq - 1][i - 1]; + } } } fclose(fp); @@ -2466,36 +2821,64 @@ pcv_t *searchpcv(int sat, const char *type, gtime_t time, for (i = 0; i < pcvs->n; i++) { pcv = pcvs->pcv + i; - if (pcv->sat != sat) continue; - if (pcv->ts.time != 0 && timediff(pcv->ts, time) > 0.0) continue; - if (pcv->te.time != 0 && timediff(pcv->te, time) < 0.0) continue; + if (pcv->sat != sat) + { + continue; + } + if (pcv->ts.time != 0 && timediff(pcv->ts, time) > 0.0) + { + continue; + } + if (pcv->te.time != 0 && timediff(pcv->te, time) < 0.0) + { + continue; + } return pcv; } } else { if (strlen(type) < MAXANT + 1) - strcpy(buff, type); + { + strcpy(buff, type); + } else { trace(1, "type array is too long"); } - for (p = strtok(buff, " "); p && n < 2; p = strtok(nullptr, " ")) types[n++] = p; - if (n <= 0) return nullptr; + for (p = strtok(buff, " "); p && n < 2; p = strtok(nullptr, " ")) + { + types[n++] = p; + } + if (n <= 0) + { + return nullptr; + } /* search receiver antenna with radome at first */ for (i = 0; i < pcvs->n; i++) { pcv = pcvs->pcv + i; for (j = 0; j < n; j++) - if (!strstr(pcv->type, types[j])) break; - if (j >= n) return pcv; + { + if (!strstr(pcv->type, types[j])) + { + break; + } + } + if (j >= n) + { + return pcv; + } } /* search receiver antenna without radome */ for (i = 0; i < pcvs->n; i++) { pcv = pcvs->pcv + i; - if (strstr(pcv->type, types[0]) != pcv->type) continue; + if (strstr(pcv->type, types[0]) != pcv->type) + { + continue; + } trace(2, "pcv without radome is used type=%s\n", type); return pcv; @@ -2531,9 +2914,15 @@ void readpos(const char *file, const char *rcv, double *pos) } while (np < 2048 && fgets(buff, sizeof(buff), fp)) { - if (buff[0] == '%' || buff[0] == '#') continue; + if (buff[0] == '%' || buff[0] == '#') + { + continue; + } if (sscanf(buff, "%lf %lf %lf %s", &poss[np][0], &poss[np][1], &poss[np][2], - str) < 4) continue; + str) < 4) + { + continue; + } // strncpy(stas[np], str, 15); This line triggers a warning. Replaced by: memcpy(stas[np], str, 15 * sizeof(stas[np][0])); stas[np++][15] = '\0'; @@ -2542,8 +2931,14 @@ void readpos(const char *file, const char *rcv, double *pos) len = static_cast(strlen(rcv)); for (i = 0; i < np; i++) { - if (strncmp(stas[i], rcv, len) != 0) continue; - for (j = 0; j < 3; j++) pos[j] = poss[i][j]; + if (strncmp(stas[i], rcv, len) != 0) + { + continue; + } + for (j = 0; j < 3; j++) + { + pos[j] = poss[i][j]; + } pos[0] *= D2R; pos[1] *= D2R; return; @@ -2561,11 +2956,23 @@ int readblqrecord(FILE *fp, double *odisp) while (fgets(buff, sizeof(buff), fp)) { - if (!strncmp(buff, "$$", 2)) continue; + if (!strncmp(buff, "$$", 2)) + { + continue; + } if (sscanf(buff, "%lf %lf %lf %lf %lf %lf %lf %lf %lf %lf %lf", - v, v + 1, v + 2, v + 3, v + 4, v + 5, v + 6, v + 7, v + 8, v + 9, v + 10) < 11) continue; - for (i = 0; i < 11; i++) odisp[n + i * 6] = v[i]; - if (++n == 6) return 1; + v, v + 1, v + 2, v + 3, v + 4, v + 5, v + 6, v + 7, v + 8, v + 9, v + 10) < 11) + { + continue; + } + for (i = 0; i < 11; i++) + { + odisp[n + i * 6] = v[i]; + } + if (++n == 6) + { + return 1; + } } return 0; } @@ -2586,7 +2993,9 @@ int readblq(const char *file, const char *sta, double *odisp) /* station name to upper case */ sscanf(sta, "%16s", staname); for (p = staname; (*p = static_cast(toupper(static_cast(*p)))); p++) - ; + { + ; + } if (!(fp = fopen(file, "re"))) { @@ -2595,12 +3004,23 @@ int readblq(const char *file, const char *sta, double *odisp) } while (fgets(buff, sizeof(buff), fp)) { - if (!strncmp(buff, "$$", 2) || strlen(buff) < 2) continue; + if (!strncmp(buff, "$$", 2) || strlen(buff) < 2) + { + continue; + } - if (sscanf(buff + 2, "%16s", name) < 1) continue; + if (sscanf(buff + 2, "%16s", name) < 1) + { + continue; + } for (p = name; (*p = static_cast(toupper(static_cast(*p)))); p++) - ; - if (strcmp(name, staname) != 0) continue; + { + ; + } + if (strcmp(name, staname) != 0) + { + continue; + } /* read blq record */ if (readblqrecord(fp, odisp)) @@ -2684,7 +3104,10 @@ int geterp(const erp_t *erp, gtime_t time, double *erpv) trace(4, "geterp:\n"); - if (erp->n <= 0) return 0; + if (erp->n <= 0) + { + return 0; + } mjd = 51544.5 + (timediff(gpst2utc(time), epoch2time(ep))) / 86400.0; @@ -2710,9 +3133,13 @@ int geterp(const erp_t *erp, gtime_t time, double *erpv) { i = (j + k) / 2; if (mjd < erp->data[i].mjd) - k = i; + { + k = i; + } else - j = i; + { + j = i; + } } if (erp->data[j].mjd == erp->data[j + 1].mjd) { @@ -2745,7 +3172,10 @@ void uniqeph(nav_t *nav) trace(3, "uniqeph: n=%d\n", nav->n); - if (nav->n <= 0) return; + if (nav->n <= 0) + { + return; + } qsort(nav->eph, nav->n, sizeof(eph_t), cmpeph); @@ -2790,7 +3220,10 @@ void uniqgeph(nav_t *nav) trace(3, "uniqgeph: ng=%d\n", nav->ng); - if (nav->ng <= 0) return; + if (nav->ng <= 0) + { + return; + } qsort(nav->geph, nav->ng, sizeof(geph_t), cmpgeph); @@ -2836,7 +3269,10 @@ void uniqseph(nav_t *nav) trace(3, "uniqseph: ns=%d\n", nav->ns); - if (nav->ns <= 0) return; + if (nav->ns <= 0) + { + return; + } qsort(nav->seph, nav->ns, sizeof(seph_t), cmpseph); @@ -2883,10 +3319,12 @@ void uniqnav(nav_t *nav) /* update carrier wave length */ for (i = 0; i < MAXSAT; i++) - for (j = 0; j < NFREQ; j++) - { - nav->lam[i][j] = satwavelen(i + 1, j, nav); - } + { + for (j = 0; j < NFREQ; j++) + { + nav->lam[i][j] = satwavelen(i + 1, j, nav); + } + } } @@ -2895,8 +3333,14 @@ int cmpobs(const void *p1, const void *p2) { auto *q1 = (obsd_t *)p1, *q2 = (obsd_t *)p2; double tt = timediff(q1->time, q2->time); - if (fabs(tt) > DTTOL) return tt < 0 ? -1 : 1; - if (q1->rcv != q2->rcv) return static_cast(q1->rcv) - static_cast(q2->rcv); + if (fabs(tt) > DTTOL) + { + return tt < 0 ? -1 : 1; + } + if (q1->rcv != q2->rcv) + { + return static_cast(q1->rcv) - static_cast(q2->rcv); + } return static_cast(q1->sat) - static_cast(q2->sat); } @@ -2912,7 +3356,10 @@ int sortobs(obs_t *obs) trace(3, "sortobs: nobs=%d\n", obs->n); - if (obs->n <= 0) return 0; + if (obs->n <= 0) + { + return 0; + } qsort(obs->data, obs->n, sizeof(obsd_t), cmpobs); @@ -2932,7 +3379,10 @@ int sortobs(obs_t *obs) { for (j = i + 1; j < obs->n; j++) { - if (timediff(obs->data[j].time, obs->data[i].time) > DTTOL) break; + if (timediff(obs->data[j].time, obs->data[i].time) > DTTOL) + { + break; + } } } return n; @@ -2973,14 +3423,23 @@ int readnav(const char *file, nav_t *nav) trace(3, "loadnav: file=%s\n", file); - if (!(fp = fopen(file, "re"))) return 0; + if (!(fp = fopen(file, "re"))) + { + return 0; + } while (fgets(buff, sizeof(buff), fp)) { if (!strncmp(buff, "IONUTC", 6)) { - for (i = 0; i < 8; i++) nav->ion_gps[i] = 0.0; - for (i = 0; i < 4; i++) nav->utc_gps[i] = 0.0; + for (i = 0; i < 8; i++) + { + nav->ion_gps[i] = 0.0; + } + for (i = 0; i < 4; i++) + { + nav->utc_gps[i] = 0.0; + } nav->leaps = 0; sscanf(buff, "IONUTC,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf,%d", &nav->ion_gps[0], &nav->ion_gps[1], &nav->ion_gps[2], &nav->ion_gps[3], @@ -2990,10 +3449,17 @@ int readnav(const char *file, nav_t *nav) continue; } if ((p = strchr(buff, ','))) - *p = '\0'; + { + *p = '\0'; + } else - continue; - if (!(sat = satid2no(buff))) continue; + { + continue; + } + if (!(sat = satid2no(buff))) + { + continue; + } if (satsys(sat, &prn) == SYS_GLO) { nav->geph[prn - 1] = geph0; @@ -3049,11 +3515,17 @@ int savenav(const char *file, const nav_t *nav) trace(3, "savenav: file=%s\n", file); - if (!(fp = fopen(file, "we"))) return 0; + if (!(fp = fopen(file, "we"))) + { + return 0; + } for (i = 0; i < MAXSAT; i++) { - if (nav->eph[i].ttr.time == 0) continue; + if (nav->eph[i].ttr.time == 0) + { + continue; + } satno2id(nav->eph[i].sat, id); fprintf(fp, "%s,%d,%d,%d,%d,%d,%d,%d,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E," @@ -3071,7 +3543,10 @@ int savenav(const char *file, const nav_t *nav) } for (i = 0; i < MAXPRNGLO; i++) { - if (nav->geph[i].tof.time == 0) continue; + if (nav->geph[i].tof.time == 0) + { + continue; + } satno2id(nav->geph[i].sat, id); fprintf(fp, "%s,%d,%d,%d,%d,%d,%d,%d,%.14E,%.14E,%.14E,%.14E,%.14E,%.14E," @@ -3203,7 +3678,10 @@ void traceswap(void) rtk_unlock(&lock_trace); return; } - if (fp_trace) fclose(fp_trace); + if (fp_trace) + { + fclose(fp_trace); + } if (!(fp_trace = fopen(path, "we"))) { @@ -3219,11 +3697,18 @@ void traceopen(const char *file) char path[1024]; reppath(file, path, time, "", ""); - if (!*path || !(fp_trace = fopen(path, "we"))) fp_trace = stderr; + if (!*path || !(fp_trace = fopen(path, "we"))) + { + fp_trace = stderr; + } if (strlen(file) < 1025) - strcpy(file_trace, file); + { + strcpy(file_trace, file); + } else - trace(1, "file array is too long"); + { + trace(1, "file array is too long"); + } tick_trace = tickget(); time_trace = time; initlock(&lock_trace); @@ -3232,7 +3717,10 @@ void traceopen(const char *file) void traceclose(void) { - if (fp_trace && fp_trace != stderr) fclose(fp_trace); + if (fp_trace && fp_trace != stderr) + { + fclose(fp_trace); + } fp_trace = nullptr; file_trace[0] = '\0'; } @@ -3260,7 +3748,10 @@ void tracelevel(int level) void tracet(int level, const char *format, ...) { va_list ap; - if (!fp_trace || level > level_trace) return; + if (!fp_trace || level > level_trace) + { + return; + } traceswap(); fprintf(fp_trace, "%d %9.3f: ", level, (tickget() - tick_trace) / 1000.0); va_start(ap, format); @@ -3437,13 +3928,23 @@ void createdir(const char *path) //tracet(3, "createdir: path=%s\n", path); if (strlen(path) < 1025) - strcpy(buff, path); + { + strcpy(buff, path); + } else - trace(1, "path is too long"); - if (!(p = strrchr(buff, FILEPATHSEP))) return; + { + trace(1, "path is too long"); + } + if (!(p = strrchr(buff, FILEPATHSEP))) + { + return; + } *p = '\0'; - if (mkdir(buff, 0777) != 0) trace(1, "Error creating folder"); + if (mkdir(buff, 0777) != 0) + { + trace(1, "Error creating folder"); + } } @@ -3455,17 +3956,27 @@ int repstr(char *str, const char *pat, const char *rep) for (p = str, r = buff; *p; p = q + len) { - if (!(q = strstr(p, pat))) break; + if (!(q = strstr(p, pat))) + { + break; + } strncpy(r, p, q - p); r += q - p; r += sprintf(r, "%s", rep); } - if (p <= str) return 0; + if (p <= str) + { + return 0; + } if (strlen(p) < 1025) - strcpy(r, p); + { + strcpy(r, p); + } else - trace(1, "pat array is too long"); + { + trace(1, "pat array is too long"); + } strcpy(str, buff); return 1; } @@ -3508,9 +4019,18 @@ int reppath(const char *path, char *rpath, gtime_t time, const char *rov, strcpy(rpath, path); - if (!strstr(rpath, "%")) return 0; - if (*rov) stat |= repstr(rpath, "%r", rov); - if (*base) stat |= repstr(rpath, "%b", base); + if (!strstr(rpath, "%")) + { + return 0; + } + if (*rov) + { + stat |= repstr(rpath, "%r", rov); + } + if (*base) + { + stat |= repstr(rpath, "%b", base); + } if (time.time != 0) { time2epoch(time, ep); @@ -3583,12 +4103,19 @@ int reppaths(const char *path, char *rpath[], int nmax, gtime_t ts, trace(3, "reppaths: path =%s nmax=%d rov=%s base=%s\n", path, nmax, rov, base); - if (ts.time == 0 || te.time == 0 || timediff(ts, te) > 0.0) return 0; + if (ts.time == 0 || te.time == 0 || timediff(ts, te) > 0.0) + { + return 0; + } if (strstr(path, "%S") || strstr(path, "%M") || strstr(path, "%t")) - tint = 900.0; + { + tint = 900.0; + } else if (strstr(path, "%h") || strstr(path, "%H")) - tint = 3600.0; + { + tint = 3600.0; + } tow = time2gpst(ts, &week); time = gpst2time(week, floor(tow / tint) * tint); @@ -3596,10 +4123,16 @@ int reppaths(const char *path, char *rpath[], int nmax, gtime_t ts, while (timediff(time, te) <= 0.0 && n < nmax) { reppath(path, rpath[n], time, rov, base); - if (n == 0 || strcmp(rpath[n], rpath[n - 1]) != 0) n++; + if (n == 0 || strcmp(rpath[n], rpath[n - 1]) != 0) + { + n++; + } time = timeadd(time, tint); } - for (i = 0; i < n; i++) trace(3, "reppaths: rpath=%s\n", rpath[i]); + for (i = 0; i < n; i++) + { + trace(3, "reppaths: rpath=%s\n", rpath[i]); + } return n; } @@ -3623,7 +4156,10 @@ double satwavelen(int sat, int frq, const nav_t *nav) { for (i = 0; i < nav->ng; i++) { - if (nav->geph[i].sat != sat) continue; + if (nav->geph[i].sat != sat) + { + continue; + } return SPEED_OF_LIGHT / (freq_glo[frq] + dfrq_glo[frq] * nav->geph[i].frq); } } @@ -3635,28 +4171,48 @@ double satwavelen(int sat, int frq, const nav_t *nav) else if (sys == SYS_BDS) { if (frq == 0) - return SPEED_OF_LIGHT / FREQ1_BDS; /* B1 */ + { + return SPEED_OF_LIGHT / FREQ1_BDS; /* B1 */ + } if (frq == 1) - return SPEED_OF_LIGHT / FREQ2_BDS; /* B2 */ + { + return SPEED_OF_LIGHT / FREQ2_BDS; /* B2 */ + } if (frq == 2) - return SPEED_OF_LIGHT / FREQ3_BDS; /* B3 */ + { + return SPEED_OF_LIGHT / FREQ3_BDS; /* B3 */ + } } else { if (frq == 0) - return SPEED_OF_LIGHT / FREQ1; /* L1/E1 */ + { + return SPEED_OF_LIGHT / FREQ1; /* L1/E1 */ + } if (frq == 1) - return SPEED_OF_LIGHT / FREQ2; /* L2 */ + { + return SPEED_OF_LIGHT / FREQ2; /* L2 */ + } if (frq == 2) - return SPEED_OF_LIGHT / FREQ5; /* L5/E5a */ + { + return SPEED_OF_LIGHT / FREQ5; /* L5/E5a */ + } if (frq == 3) - return SPEED_OF_LIGHT / FREQ6; /* L6/LEX */ + { + return SPEED_OF_LIGHT / FREQ6; /* L6/LEX */ + } if (frq == 4) - return SPEED_OF_LIGHT / FREQ7; /* E5b */ + { + return SPEED_OF_LIGHT / FREQ7; /* E5b */ + } if (frq == 5) - return SPEED_OF_LIGHT / FREQ8; /* E5a+b */ + { + return SPEED_OF_LIGHT / FREQ8; /* E5a+b */ + } else if (frq == 6) - return SPEED_OF_LIGHT / FREQ9; /* S */ + { + return SPEED_OF_LIGHT / FREQ9; /* S */ + } } return 0.0; } @@ -3675,10 +4231,19 @@ double geodist(const double *rs, const double *rr, double *e) double r; int i; - if (norm_rtk(rs, 3) < RE_WGS84) return -1.0; - for (i = 0; i < 3; i++) e[i] = rs[i] - rr[i]; + if (norm_rtk(rs, 3) < RE_WGS84) + { + return -1.0; + } + for (i = 0; i < 3; i++) + { + e[i] = rs[i] - rr[i]; + } r = norm_rtk(e, 3); - for (i = 0; i < 3; i++) e[i] /= r; + for (i = 0; i < 3; i++) + { + e[i] /= r; + } return r + DEFAULT_OMEGA_EARTH_DOT * (rs[0] * rr[1] - rs[1] * rr[0]) / SPEED_OF_LIGHT; } @@ -3699,7 +4264,10 @@ double satazel(const double *pos, const double *e, double *azel) { ecef2enu(pos, e, enu); az = dot(enu, enu, 2) < 1e-12 ? 0.0 : atan2(enu[0], enu[1]); - if (az < 0.0) az += 2 * PI; + if (az < 0.0) + { + az += 2 * PI; + } el = asin(enu[2]); } if (azel) @@ -3725,10 +4293,16 @@ void dops(int ns, const double *azel, double elmin, double *dop) double H[4 * MAXSAT], Q[16], cosel, sinel; int i, n; - for (i = 0; i < 4; i++) dop[i] = 0.0; + for (i = 0; i < 4; i++) + { + dop[i] = 0.0; + } for (i = n = 0; i < ns && i < MAXSAT; i++) { - if (azel[1 + i * 2] < elmin || azel[1 + i * 2] <= 0.0) continue; + if (azel[1 + i * 2] < elmin || azel[1 + i * 2] <= 0.0) + { + continue; + } cosel = cos(azel[1 + i * 2]); sinel = sin(azel[1 + i * 2]); H[4 * n] = cosel * sin(azel[i * 2]); @@ -3736,7 +4310,10 @@ void dops(int ns, const double *azel, double elmin, double *dop) H[2 + 4 * n] = sinel; H[3 + 4 * n++] = 1.0; } - if (n < 4) return; + if (n < 4) + { + return; + } matmul("NT", 4, 4, n, 1.0, H, H, 0.0, Q); if (!matinv(Q, 4)) @@ -3766,8 +4343,14 @@ double ionmodel(gtime_t t, const double *ion, const double *pos, double tt, f, psi, phi, lam, amp, per, x; int week; - if (pos[2] < -1e3 || azel[1] <= 0) return 0.0; - if (norm_rtk(ion, 8) <= 0.0) ion = ion_default; + if (pos[2] < -1e3 || azel[1] <= 0) + { + return 0.0; + } + if (norm_rtk(ion, 8) <= 0.0) + { + ion = ion_default; + } /* earth centered angle (semi-circle) */ psi = 0.0137 / (azel[1] / PI + 0.11) - 0.022; @@ -3775,9 +4358,13 @@ double ionmodel(gtime_t t, const double *ion, const double *pos, /* subionospheric latitude/longitude (semi-circle) */ phi = pos[0] / PI + psi * cos(azel[0]); if (phi > 0.416) - phi = 0.416; + { + phi = 0.416; + } else if (phi < -0.416) - phi = -0.416; + { + phi = -0.416; + } lam = pos[1] / PI + psi * sin(azel[0]) / cos(phi * PI); /* geomagnetic latitude (semi-circle) */ @@ -3809,7 +4396,10 @@ double ionmodel(gtime_t t, const double *ion, const double *pos, *-----------------------------------------------------------------------------*/ double ionmapf(const double *pos, const double *azel) { - if (pos[2] >= HION) return 1.0; + if (pos[2] >= HION) + { + return 1.0; + } return 1.0 / cos(asin((RE_WGS84 + pos[2]) / (RE_WGS84 + HION) * sin(PI / 2.0 - azel[1]))); } @@ -3864,7 +4454,10 @@ double tropmodel(gtime_t time __attribute__((unused)), const double *pos, const const double temp0 = 15.0; /* temparature at sea level */ double hgt, pres, temp, e, z, trph, trpw; - if (pos[2] < -100.0 || 1e4 < pos[2] || azel[1] <= 0) return 0.0; + if (pos[2] < -100.0 || 1e4 < pos[2] || azel[1] <= 0) + { + return 0.0; + } /* standard atmosphere */ hgt = pos[2] < 0.0 ? 0.0 : pos[2]; @@ -3886,9 +4479,13 @@ double interpc(const double coef[], double lat) { int i = static_cast(lat / 15.0); if (i < 1) - return coef[0]; + { + return coef[0]; + } if (i > 4) - return coef[4]; + { + return coef[4]; + } return coef[i - 1] * (1.0 - lat / 15.0 + i) + coef[i] * (lat / 15.0 - i); } @@ -3924,7 +4521,10 @@ double nmf(gtime_t time, const double pos[], const double azel[], if (el <= 0.0) { - if (mapfw) *mapfw = 0.0; + if (mapfw) + { + *mapfw = 0.0; + } return 0.0; } /* year from doy 28, added half a year for southern latitudes */ @@ -3941,7 +4541,10 @@ double nmf(gtime_t time, const double pos[], const double azel[], /* ellipsoidal height is used instead of height above sea level */ dm = (1.0 / sin(el) - mapf(el, aht[0], aht[1], aht[2])) * hgt / 1e3; - if (mapfw) *mapfw = mapf(el, aw[0], aw[1], aw[2]); + if (mapfw) + { + *mapfw = mapf(el, aw[0], aw[1], aw[2]); + } return mapf(el, ah[0], ah[1], ah[2]) + dm; } @@ -3972,7 +4575,10 @@ double tropmapf(gtime_t time, const double pos[], const double azel[], if (pos[2] < -1000.0 || pos[2] > 20000.0) { - if (mapfw) *mapfw = 0.0; + if (mapfw) + { + *mapfw = 0.0; + } return 0.0; } #ifdef IERS_MODEL @@ -3999,9 +4605,13 @@ double interpvar(double ang, const double *var) double a = ang / 5.0; /* ang=0-90 */ int i = static_cast(a); if (i < 0) - return var[0]; + { + return var[0]; + } if (i >= 18) - return var[18]; + { + return var[18]; + } return var[i] * (1.0 - a + i) + var[i + 1] * (a - i); } @@ -4029,7 +4639,10 @@ void antmodel(const pcv_t *pcv, const double *del, const double *azel, for (i = 0; i < NFREQ; i++) { - for (j = 0; j < 3; j++) off[j] = pcv->off[i][j] + del[j]; + for (j = 0; j < 3; j++) + { + off[j] = pcv->off[i][j] + del[j]; + } dant[i] = -dot(off, e, 3) + (opt ? interpvar(90.0 - azel[1] * R2D, pcv->var[i]) : 0.0); } @@ -4139,9 +4752,18 @@ void sunmoonpos(gtime_t tutc, const double *erpv, double *rsun, eci2ecef(tutc, erpv, U, &gmst_); /* sun and moon position in ecef */ - if (rsun) matmul("NN", 3, 1, 3, 1.0, U, rs, 0.0, rsun); - if (rmoon) matmul("NN", 3, 1, 3, 1.0, U, rm, 0.0, rmoon); - if (gmst) *gmst = gmst_; + if (rsun) + { + matmul("NN", 3, 1, 3, 1.0, U, rs, 0.0, rsun); + } + if (rmoon) + { + matmul("NN", 3, 1, 3, 1.0, U, rm, 0.0, rmoon); + } + if (gmst) + { + *gmst = gmst_; + } } @@ -4166,20 +4788,35 @@ void csmooth(obs_t *obs, int ns) r = p->rcv; for (j = 0; j < NFREQ; j++) { - if (s <= 0 || MAXSAT < s || r <= 0 || 2 < r) continue; - if (p->P[j] == 0.0 || p->L[j] == 0.0) continue; - if (p->LLI[j]) n[r - 1][s - 1][j] = 0; + if (s <= 0 || MAXSAT < s || r <= 0 || 2 < r) + { + continue; + } + if (p->P[j] == 0.0 || p->L[j] == 0.0) + { + continue; + } + if (p->LLI[j]) + { + n[r - 1][s - 1][j] = 0; + } if (n[r - 1][s - 1][j] == 0) - Ps[r - 1][s - 1][j] = p->P[j]; + { + Ps[r - 1][s - 1][j] = p->P[j]; + } else { dcp = lam_carr[j] * (p->L[j] - Lp[r - 1][s - 1][j]); Ps[r - 1][s - 1][j] = p->P[j] / ns + (Ps[r - 1][s - 1][j] + dcp) * (ns - 1) / ns; } if (++n[r - 1][s - 1][j] < ns) - p->P[j] = 0.0; + { + p->P[j] = 0.0; + } else - p->P[j] = Ps[r - 1][s - 1][j]; + { + p->P[j] = Ps[r - 1][s - 1][j]; + } Lp[r - 1][s - 1][j] = p->L[j]; } } @@ -4202,10 +4839,17 @@ int rtk_uncompress(const char *file, char *uncfile) trace(3, "rtk_uncompress: file=%s\n", file); if (strlen(file) < 1025) - strcpy(tmpfile, file); + { + strcpy(tmpfile, file); + } else - trace(1, "file array is too long"); - if (!(p = strrchr(tmpfile, '.'))) return 0; + { + trace(1, "file array is too long"); + } + if (!(p = strrchr(tmpfile, '.'))) + { + return 0; + } /* uncompress by gzip */ if (!strcmp(p, ".z") || !strcmp(p, ".Z") || @@ -4218,10 +4862,16 @@ int rtk_uncompress(const char *file, char *uncfile) if (execcmd(cmd)) { - if (remove(uncfile) != 0) trace(1, "Error removing file"); + if (remove(uncfile) != 0) + { + trace(1, "Error removing file"); + } return -1; } - if (strlen(uncfile) < 1025) strcpy(tmpfile, uncfile); + if (strlen(uncfile) < 1025) + { + strcpy(tmpfile, uncfile); + } stat = 1; } /* extract tar file */ @@ -4246,16 +4896,31 @@ int rtk_uncompress(const char *file, char *uncfile) std::string s_aux = temp.str(); int n = s_aux.length(); if (n < 2048) - for (int i = 0; i < n; i++) cmd[i] = s_aux[i]; + { + for (int i = 0; i < n; i++) + { + cmd[i] = s_aux[i]; + } + } if (execcmd(cmd)) { if (stat) - if (remove(tmpfile) != 0) trace(1, "Error removing file"); + { + if (remove(tmpfile) != 0) + { + trace(1, "Error removing file"); + } + } return -1; } if (stat) - if (remove(tmpfile) != 0) trace(1, "Error removing file"); + { + if (remove(tmpfile) != 0) + { + trace(1, "Error removing file"); + } + } stat = 1; } /* extract hatanaka-compressed file by cnx2rnx */ @@ -4267,13 +4932,26 @@ int rtk_uncompress(const char *file, char *uncfile) if (execcmd(cmd)) { - if (remove(uncfile) != 0) trace(1, "Error removing file"); + if (remove(uncfile) != 0) + { + trace(1, "Error removing file"); + } if (stat) - if (remove(tmpfile) != 0) trace(1, "Error removing file"); + { + if (remove(tmpfile) != 0) + { + trace(1, "Error removing file"); + } + } return -1; } if (stat) - if (remove(tmpfile) != 0) trace(1, "Error removing file"); + { + if (remove(tmpfile) != 0) + { + trace(1, "Error removing file"); + } + } stat = 1; } trace(3, "rtk_uncompress: stat=%d\n", stat); @@ -4304,23 +4982,42 @@ int expath(const char *path, char *paths[], int nmax) //if ((p=strrchr(path,'/')) || (p=strrchr(path,'\\'))) { // file=p+1; strncpy(dir,path,p-path+1); dir[p-path+1]='\0'; //} - if (!(dp = opendir(*dir ? dir : "."))) return 0; + if (!(dp = opendir(*dir ? dir : "."))) + { + return 0; + } while ((d = readdir(dp))) { - if (*(d->d_name) == '.') continue; + if (*(d->d_name) == '.') + { + continue; + } sprintf(s1, "^%s$", d->d_name); sprintf(s2, "^%s$", file); - for (p = s1; *p; p++) *p = static_cast(tolower(static_cast(*p))); - for (p = s2; *p; p++) *p = static_cast(tolower(static_cast(*p))); + for (p = s1; *p; p++) + { + *p = static_cast(tolower(static_cast(*p))); + } + for (p = s2; *p; p++) + { + *p = static_cast(tolower(static_cast(*p))); + } for (p = s1, q = strtok_r(s2, "*", &r); q; q = strtok_r(nullptr, "*", &r)) { if ((p = strstr(p, q))) - p += strlen(q); + { + p += strlen(q); + } else - break; + { + break; + } + } + if (p && n < nmax) + { + sprintf(paths[n++], "%s%s", dir, d->d_name); } - if (p && n < nmax) sprintf(paths[n++], "%s%s", dir, d->d_name); } closedir(dp); /* sort paths in alphabetical order */ @@ -4331,7 +5028,9 @@ int expath(const char *path, char *paths[], int nmax) if (strcmp(paths[i], paths[j]) > 0) { if (strlen(paths[i]) < 1025) - strcpy(tmp, paths[i]); + { + strcpy(tmp, paths[i]); + } else { trace(1, "Path is too long"); @@ -4341,7 +5040,10 @@ int expath(const char *path, char *paths[], int nmax) } } } - for (i = 0; i < n; i++) trace(3, "expath : file=%s\n", paths[i]); + for (i = 0; i < n; i++) + { + trace(3, "expath : file=%s\n", paths[i]); + } return n; } @@ -4359,16 +5061,37 @@ void windupcorr(gtime_t time, const double *rs, const double *rr, double *phw) sunmoonpos(gpst2utc(time), erpv, rsun, nullptr, nullptr); /* unit vector satellite to receiver */ - for (i = 0; i < 3; i++) r[i] = rr[i] - rs[i]; - if (!normv3(r, ek)) return; + for (i = 0; i < 3; i++) + { + r[i] = rr[i] - rs[i]; + } + if (!normv3(r, ek)) + { + return; + } /* unit vectors of satellite antenna */ - for (i = 0; i < 3; i++) r[i] = -rs[i]; - if (!normv3(r, ezs)) return; - for (i = 0; i < 3; i++) r[i] = rsun[i] - rs[i]; - if (!normv3(r, ess)) return; + for (i = 0; i < 3; i++) + { + r[i] = -rs[i]; + } + if (!normv3(r, ezs)) + { + return; + } + for (i = 0; i < 3; i++) + { + r[i] = rsun[i] - rs[i]; + } + if (!normv3(r, ess)) + { + return; + } cross3(ezs, ess, r); - if (!normv3(r, eys)) return; + if (!normv3(r, eys)) + { + return; + } cross3(eys, ezs, exs); /* unit vectors of receiver antenna */ @@ -4391,12 +5114,19 @@ void windupcorr(gtime_t time, const double *rs, const double *rr, double *phw) } cosp = dot(ds, dr, 3) / norm_rtk(ds, 3) / norm_rtk(dr, 3); if (cosp < -1.0) - cosp = -1.0; + { + cosp = -1.0; + } else if (cosp > 1.0) - cosp = 1.0; + { + cosp = 1.0; + } ph = acos(cosp) / 2.0 / PI; cross3(ds, dr, drs); - if (dot(ek, drs, 3) < 0.0) ph = -ph; + if (dot(ek, drs, 3) < 0.0) + { + ph = -ph; + } *phw = ph + floor(*phw - ph + 0.5); /* in cycle */ } diff --git a/src/algorithms/libs/rtklib/rtklib_rtkpos.cc b/src/algorithms/libs/rtklib/rtklib_rtkpos.cc index dde3e2a95..4ff70803e 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkpos.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkpos.cc @@ -148,7 +148,10 @@ int rtkopenstat(const char *file, int level) trace(3, "rtkopenstat: file=%s level=%d\n", file, level); - if (level <= 0) return 0; + if (level <= 0) + { + return 0; + } reppath(file, path, time, "", ""); @@ -158,9 +161,13 @@ int rtkopenstat(const char *file, int level) return 0; } if (strlen(file) < 1025) - strcpy(file_stat, file); + { + strcpy(file_stat, file); + } else - trace(1, "File name is too long"); + { + trace(1, "File name is too long"); + } time_stat = time; statlevel = level; return 1; @@ -176,7 +183,10 @@ void rtkclosestat(void) { trace(3, "rtkclosestat:\n"); - if (fp_stat) fclose(fp_stat); + if (fp_stat) + { + fclose(fp_stat); + } fp_stat = nullptr; file_stat[0] = '\0'; statlevel = 0; @@ -191,7 +201,10 @@ void rtkoutstat(rtk_t *rtk, char *buff __attribute__((unused))) int i, j, week, est, nfreq, nf = NF_RTK(&rtk->opt); char id[32]; - if (statlevel <= 0 || !fp_stat) return; + if (statlevel <= 0 || !fp_stat) + { + return; + } trace(3, "outsolstat:\n"); @@ -205,7 +218,10 @@ void rtkoutstat(rtk_t *rtk, char *buff __attribute__((unused))) /* receiver position */ if (est) { - for (i = 0; i < 3; i++) xa[i] = i < rtk->na ? rtk->xa[i] : 0.0; + for (i = 0; i < 3; i++) + { + xa[i] = i < rtk->na ? rtk->xa[i] : 0.0; + } fprintf(fp_stat, "$POS,%d,%.3f,%d,%.4f,%.4f,%.4f,%.4f,%.4f,%.4f\n", week, tow, rtk->sol.stat, rtk->x[0], rtk->x[1], rtk->x[2], xa[0], xa[1], xa[2]); } @@ -221,8 +237,14 @@ void rtkoutstat(rtk_t *rtk, char *buff __attribute__((unused))) ecef2pos(rtk->sol.rr, pos); ecef2enu(pos, rtk->x + 3, vel); ecef2enu(pos, rtk->x + 6, acc); - if (rtk->na >= 6) ecef2enu(pos, rtk->xa + 3, vela); - if (rtk->na >= 9) ecef2enu(pos, rtk->xa + 6, acca); + if (rtk->na >= 6) + { + ecef2enu(pos, rtk->xa + 3, vela); + } + if (rtk->na >= 9) + { + ecef2enu(pos, rtk->xa + 6, acca); + } fprintf(fp_stat, "$VELACC,%d,%.3f,%d,%.4f,%.4f,%.4f,%.5f,%.5f,%.5f,%.4f,%.4f,%.4f,%.5f,%.5f,%.5f\n", week, tow, rtk->sol.stat, vel[0], vel[1], vel[2], acc[0], acc[1], acc[2], vela[0], vela[1], vela[2], acca[0], acca[1], acca[2]); @@ -246,7 +268,10 @@ void rtkoutstat(rtk_t *rtk, char *buff __attribute__((unused))) for (i = 0; i < MAXSAT; i++) { ssat = rtk->ssat + i; - if (!ssat->vs) continue; + if (!ssat->vs) + { + continue; + } satno2id(i + 1, id); j = II_RTK(i + 1, &rtk->opt); xa[0] = j < rtk->na ? rtk->xa[j] : 0.0; @@ -276,13 +301,19 @@ void rtkoutstat(rtk_t *rtk, char *buff __attribute__((unused))) i + 1, rtk->x[j], xa[0]); } } - if (rtk->sol.stat == SOLQ_NONE || statlevel <= 1) return; + if (rtk->sol.stat == SOLQ_NONE || statlevel <= 1) + { + return; + } /* residuals and status */ for (i = 0; i < MAXSAT; i++) { ssat = rtk->ssat + i; - if (!ssat->vs) continue; + if (!ssat->vs) + { + continue; + } satno2id(i + 1, id); for (j = 0; j < nfreq; j++) { @@ -313,7 +344,10 @@ void swapsolstat(void) { return; } - if (fp_stat) fclose(fp_stat); + if (fp_stat) + { + fclose(fp_stat); + } if (!(fp_stat = fopen(path, "we"))) { @@ -332,7 +366,10 @@ void outsolstat(rtk_t *rtk) int i, j, week, est, nfreq, nf = NF_RTK(&rtk->opt); char id[32]; - if (statlevel <= 0 || !fp_stat) return; + if (statlevel <= 0 || !fp_stat) + { + return; + } trace(3, "outsolstat:\n"); @@ -346,7 +383,10 @@ void outsolstat(rtk_t *rtk) /* receiver position */ if (est) { - for (i = 0; i < 3; i++) xa[i] = i < rtk->na ? rtk->xa[i] : 0.0; + for (i = 0; i < 3; i++) + { + xa[i] = i < rtk->na ? rtk->xa[i] : 0.0; + } fprintf(fp_stat, "$POS,%d,%.3f,%d,%.4f,%.4f,%.4f,%.4f,%.4f,%.4f\n", week, tow, rtk->sol.stat, rtk->x[0], rtk->x[1], rtk->x[2], xa[0], xa[1], xa[2]); } @@ -362,8 +402,14 @@ void outsolstat(rtk_t *rtk) ecef2pos(rtk->sol.rr, pos); ecef2enu(pos, rtk->x + 3, vel); ecef2enu(pos, rtk->x + 6, acc); - if (rtk->na >= 6) ecef2enu(pos, rtk->xa + 3, vela); - if (rtk->na >= 9) ecef2enu(pos, rtk->xa + 6, acca); + if (rtk->na >= 6) + { + ecef2enu(pos, rtk->xa + 3, vela); + } + if (rtk->na >= 9) + { + ecef2enu(pos, rtk->xa + 6, acca); + } fprintf(fp_stat, "$VELACC,%d,%.3f,%d,%.4f,%.4f,%.4f,%.5f,%.5f,%.5f,%.4f,%.4f,%.4f,%.5f,%.5f,%.5f\n", week, tow, rtk->sol.stat, vel[0], vel[1], vel[2], acc[0], acc[1], acc[2], vela[0], vela[1], vela[2], acca[0], acca[1], acca[2]); @@ -387,7 +433,10 @@ void outsolstat(rtk_t *rtk) for (i = 0; i < MAXSAT; i++) { ssat = rtk->ssat + i; - if (!ssat->vs) continue; + if (!ssat->vs) + { + continue; + } satno2id(i + 1, id); j = II_RTK(i + 1, &rtk->opt); xa[0] = j < rtk->na ? rtk->xa[j] : 0.0; @@ -417,13 +466,19 @@ void outsolstat(rtk_t *rtk) i + 1, rtk->x[j], xa[0]); } } - if (rtk->sol.stat == SOLQ_NONE || statlevel <= 1) return; + if (rtk->sol.stat == SOLQ_NONE || statlevel <= 1) + { + return; + } /* residuals and status */ for (i = 0; i < MAXSAT; i++) { ssat = rtk->ssat + i; - if (!ssat->vs) continue; + if (!ssat->vs) + { + continue; + } satno2id(i + 1, id); for (j = 0; j < nfreq; j++) { @@ -510,8 +565,14 @@ double varerr(int sat __attribute((unused)), int sys, double el, double bl, doub } else { /* normal error model */ - if (f >= nf) fact = opt->eratio[f - nf]; - if (fact <= 0.0) fact = opt->eratio[0]; + if (f >= nf) + { + fact = opt->eratio[f - nf]; + } + if (fact <= 0.0) + { + fact = opt->eratio[0]; + } fact *= sys == SYS_GLO ? EFACT_GLO : (sys == SYS_SBS ? EFACT_SBS : EFACT_GPS); a = fact * opt->err[1]; b = fact * opt->err[2]; @@ -524,7 +585,10 @@ double varerr(int sat __attribute((unused)), int sys, double el, double bl, doub double baseline(const double *ru, const double *rb, double *dr) { int i; - for (i = 0; i < 3; i++) dr[i] = ru[i] - rb[i]; + for (i = 0; i < 3; i++) + { + dr[i] = ru[i] - rb[i]; + } return norm_rtk(dr, 3); } @@ -552,9 +616,13 @@ int selsat(const obsd_t *obs, const double *azel, int nu, int nr, for (i = 0, j = nu; i < nu && j < nu + nr; i++, j++) { if (obs[i].sat < obs[j].sat) - j--; + { + j--; + } else if (obs[i].sat > obs[j].sat) - i--; + { + i--; + } else if (azel[1 + j * 2] >= opt->elmin) { /* elevation at base station */ sat[k] = obs[i].sat; @@ -578,26 +646,44 @@ void udpos(rtk_t *rtk, double tt) /* fixed mode */ if (rtk->opt.mode == PMODE_FIXED) { - for (i = 0; i < 3; i++) initx_rtk(rtk, rtk->opt.ru[i], 1E-8, i); + for (i = 0; i < 3; i++) + { + initx_rtk(rtk, rtk->opt.ru[i], 1E-8, i); + } return; } /* initialize position for first epoch */ if (norm_rtk(rtk->x, 3) <= 0.0) { - for (i = 0; i < 3; i++) initx_rtk(rtk, rtk->sol.rr[i], VAR_POS, i); + for (i = 0; i < 3; i++) + { + initx_rtk(rtk, rtk->sol.rr[i], VAR_POS, i); + } if (rtk->opt.dynamics) { - for (i = 3; i < 6; i++) initx_rtk(rtk, rtk->sol.rr[i], VAR_VEL, i); - for (i = 6; i < 9; i++) initx_rtk(rtk, 1E-6, VAR_ACC, i); + for (i = 3; i < 6; i++) + { + initx_rtk(rtk, rtk->sol.rr[i], VAR_VEL, i); + } + for (i = 6; i < 9; i++) + { + initx_rtk(rtk, 1E-6, VAR_ACC, i); + } } } /* static mode */ - if (rtk->opt.mode == PMODE_STATIC) return; + if (rtk->opt.mode == PMODE_STATIC) + { + return; + } /* kinmatic mode without dynamics */ if (!rtk->opt.dynamics) { - for (i = 0; i < 3; i++) initx_rtk(rtk, rtk->sol.rr[i], VAR_POS, i); + for (i = 0; i < 3; i++) + { + initx_rtk(rtk, rtk->sol.rr[i], VAR_POS, i); + } return; } /* check variance of estimated position */ @@ -610,9 +696,18 @@ void udpos(rtk_t *rtk, double tt) if (var > VAR_POS) { /* reset position with large variance */ - for (i = 0; i < 3; i++) initx_rtk(rtk, rtk->sol.rr[i], VAR_POS, i); - for (i = 3; i < 6; i++) initx_rtk(rtk, rtk->sol.rr[i], VAR_VEL, i); - for (i = 6; i < 9; i++) initx_rtk(rtk, 1E-6, VAR_ACC, i); + for (i = 0; i < 3; i++) + { + initx_rtk(rtk, rtk->sol.rr[i], VAR_POS, i); + } + for (i = 3; i < 6; i++) + { + initx_rtk(rtk, rtk->sol.rr[i], VAR_VEL, i); + } + for (i = 6; i < 9; i++) + { + initx_rtk(rtk, 1E-6, VAR_ACC, i); + } trace(2, "reset rtk position due to large variance: var=%.3f\n", var); return; } @@ -637,10 +732,12 @@ void udpos(rtk_t *rtk, double tt) ecef2pos(rtk->x, pos); covecef(pos, Q, Qv); for (i = 0; i < 3; i++) - for (j = 0; j < 3; j++) - { - rtk->P[i + 6 + (j + 6) * rtk->nx] += Qv[i + j * 3]; - } + { + for (j = 0; j < 3; j++) + { + rtk->P[i + 6 + (j + 6) * rtk->nx] += Qv[i + j * 3]; + } + } free(F); free(FP); free(xp); @@ -660,7 +757,9 @@ void udion(rtk_t *rtk, double tt, double bl, const int *sat, int ns) j = II_RTK(i, &rtk->opt); if (rtk->x[j] != 0.0 && rtk->ssat[i - 1].outc[0] > GAP_RESION && rtk->ssat[i - 1].outc[1] > GAP_RESION) - rtk->x[j] = 0.0; + { + rtk->x[j] = 0.0; + } } for (i = 0; i < ns; i++) { @@ -698,7 +797,10 @@ void udtrop(rtk_t *rtk, double tt, double bl __attribute((unused))) if (rtk->opt.tropopt >= TROPOPT_ESTG) { - for (k = 0; k < 2; k++) initx_rtk(rtk, 1e-6, VAR_GRA, ++j); + for (k = 0; k < 2; k++) + { + initx_rtk(rtk, 1e-6, VAR_GRA, ++j); + } } } else @@ -755,13 +857,20 @@ void detslp_ll(rtk_t *rtk, const obsd_t *obs, int i, int rcv) for (f = 0; f < rtk->opt.nf; f++) { - if (obs[i].L[f] == 0.0) continue; + if (obs[i].L[f] == 0.0) + { + continue; + } /* restore previous LLI */ if (rcv == 1) - LLI = getbitu(&rtk->ssat[sat - 1].slip[f], 0, 2); /* rover */ + { + LLI = getbitu(&rtk->ssat[sat - 1].slip[f], 0, 2); /* rover */ + } else - LLI = getbitu(&rtk->ssat[sat - 1].slip[f], 2, 2); /* base */ + { + LLI = getbitu(&rtk->ssat[sat - 1].slip[f], 2, 2); /* base */ + } /* detect slip by cycle slip flag in LLI */ if (rtk->tt >= 0.0) @@ -791,9 +900,13 @@ void detslp_ll(rtk_t *rtk, const obsd_t *obs, int i, int rcv) } /* save current LLI */ if (rcv == 1) - setbitu(&rtk->ssat[sat - 1].slip[f], 0, 2, obs[i].LLI[f]); + { + setbitu(&rtk->ssat[sat - 1].slip[f], 0, 2, obs[i].LLI[f]); + } else - setbitu(&rtk->ssat[sat - 1].slip[f], 2, 2, obs[i].LLI[f]); + { + setbitu(&rtk->ssat[sat - 1].slip[f], 2, 2, obs[i].LLI[f]); + } /* save slip and half-cycle valid flag */ rtk->ssat[sat - 1].slip[f] |= static_cast(slip); @@ -811,7 +924,10 @@ void detslp_gf_L1L2(rtk_t *rtk, const obsd_t *obs, int i, int j, trace(3, "detslp_gf_L1L2: i=%d j=%d\n", i, j); - if (rtk->opt.nf <= 1 || (g1 = gfobs_L1L2(obs, i, j, nav->lam[sat - 1])) == 0.0) return; + if (rtk->opt.nf <= 1 || (g1 = gfobs_L1L2(obs, i, j, nav->lam[sat - 1])) == 0.0) + { + return; + } g0 = rtk->ssat[sat - 1].gf; rtk->ssat[sat - 1].gf = g1; @@ -835,7 +951,10 @@ void detslp_gf_L1L5(rtk_t *rtk, const obsd_t *obs, int i, int j, trace(3, "detslp_gf_L1L5: i=%d j=%d\n", i, j); - if (rtk->opt.nf <= 2 || (g1 = gfobs_L1L5(obs, i, j, nav->lam[sat - 1])) == 0.0) return; + if (rtk->opt.nf <= 2 || (g1 = gfobs_L1L5(obs, i, j, nav->lam[sat - 1])) == 0.0) + { + return; + } g0 = rtk->ssat[sat - 1].gf2; rtk->ssat[sat - 1].gf2 = g1; @@ -900,7 +1019,10 @@ void udbias(rtk_t *rtk, double tt, const obsd_t *obs, const int *sat, for (i = 0; i < ns; i++) { /* detect cycle slip by LLI */ - for (f = 0; f < rtk->opt.nf; f++) rtk->ssat[sat[i] - 1].slip[f] &= 0xFC; + for (f = 0; f < rtk->opt.nf; f++) + { + rtk->ssat[sat[i] - 1].slip[f] &= 0xFC; + } detslp_ll(rtk, obs, iu[i], 1); detslp_ll(rtk, obs, ir[i], 2); @@ -947,8 +1069,14 @@ void udbias(rtk_t *rtk, double tt, const obsd_t *obs, const int *sat, j = IB_RTK(sat[i], f, &rtk->opt); rtk->P[j + j * rtk->nx] += rtk->opt.prn[0] * rtk->opt.prn[0] * tt; slip = rtk->ssat[sat[i] - 1].slip[f]; - if (rtk->opt.ionoopt == IONOOPT_IFLC) slip |= rtk->ssat[sat[i] - 1].slip[1]; - if (rtk->opt.modear == ARMODE_INST || !(slip & 1)) continue; + if (rtk->opt.ionoopt == IONOOPT_IFLC) + { + slip |= rtk->ssat[sat[i] - 1].slip[1]; + } + if (rtk->opt.modear == ARMODE_INST || !(slip & 1)) + { + continue; + } rtk->x[j] = 0.0; rtk->ssat[sat[i] - 1].lock[f] = -rtk->opt.minlock; } @@ -962,7 +1090,10 @@ void udbias(rtk_t *rtk, double tt, const obsd_t *obs, const int *sat, cp = sdobs(obs, iu[i], ir[i], f); /* cycle */ pr = sdobs(obs, iu[i], ir[i], f + NFREQ); lami = nav->lam[sat[i] - 1][f]; - if (cp == 0.0 || pr == 0.0 || lami <= 0.0) continue; + if (cp == 0.0 || pr == 0.0 || lami <= 0.0) + { + continue; + } bias[i] = cp - pr / lami; } @@ -974,7 +1105,10 @@ void udbias(rtk_t *rtk, double tt, const obsd_t *obs, const int *sat, pr2 = sdobs(obs, iu[i], ir[i], NFREQ + 1); lam1 = nav->lam[sat[i] - 1][0]; lam2 = nav->lam[sat[i] - 1][1]; - if (cp1 == 0.0 || cp2 == 0.0 || pr1 == 0.0 || pr2 == 0.0 || lam1 <= 0.0 || lam2 <= 0.0) continue; + if (cp1 == 0.0 || cp2 == 0.0 || pr1 == 0.0 || pr2 == 0.0 || lam1 <= 0.0 || lam2 <= 0.0) + { + continue; + } C1 = std::pow(lam2, 2.0) / (std::pow(lam2, 2.0) - std::pow(lam1, 2.0)); C2 = -std::pow(lam1, 2.0) / (std::pow(lam2, 2.0) - std::pow(lam1, 2.0)); @@ -991,13 +1125,19 @@ void udbias(rtk_t *rtk, double tt, const obsd_t *obs, const int *sat, { for (i = 1; i <= MAXSAT; i++) { - if (rtk->x[IB_RTK(i, f, &rtk->opt)] != 0.0) rtk->x[IB_RTK(i, f, &rtk->opt)] += offset / j; + if (rtk->x[IB_RTK(i, f, &rtk->opt)] != 0.0) + { + rtk->x[IB_RTK(i, f, &rtk->opt)] += offset / j; + } } } /* set initial states of phase-bias */ for (i = 0; i < ns; i++) { - if (bias[i] == 0.0 || rtk->x[IB_RTK(sat[i], f, &rtk->opt)] != 0.0) continue; + if (bias[i] == 0.0 || rtk->x[IB_RTK(sat[i], f, &rtk->opt)] != 0.0) + { + continue; + } initx_rtk(rtk, bias[i], std::pow(rtk->opt.std[0], 2.0), IB_RTK(sat[i], f, &rtk->opt)); } free(bias); @@ -1051,10 +1191,16 @@ void zdres_sat(int base, double r, const obsd_t *obs, const nav_t *nav, if (opt->ionoopt == IONOOPT_IFLC) { /* iono-free linear combination */ - if (lam[0] == 0.0 || lam[1] == 0.0) return; + if (lam[0] == 0.0 || lam[1] == 0.0) + { + return; + } if (testsnr(base, 0, azel[1], obs->SNR[0] * 0.25, &opt->snrmask) || - testsnr(base, 1, azel[1], obs->SNR[1] * 0.25, &opt->snrmask)) return; + testsnr(base, 1, azel[1], obs->SNR[1] * 0.25, &opt->snrmask)) + { + return; + } f1 = SPEED_OF_LIGHT / lam[0]; f2 = SPEED_OF_LIGHT / lam[1]; @@ -1075,7 +1221,10 @@ void zdres_sat(int base, double r, const obsd_t *obs, const nav_t *nav, { for (i = 0; i < nf; i++) { - if (lam[i] == 0.0) continue; + if (lam[i] == 0.0) + { + continue; + } /* check snr mask */ if (testsnr(base, i, azel[1], obs->SNR[i] * 0.25, &opt->snrmask)) @@ -1083,8 +1232,14 @@ void zdres_sat(int base, double r, const obsd_t *obs, const nav_t *nav, continue; } /* residuals = observable - pseudorange */ - if (obs->L[i] != 0.0) y[i] = obs->L[i] * lam[i] - r - dant[i]; - if (obs->P[i] != 0.0) y[i + nf] = obs->P[i] - r - dant[i]; + if (obs->L[i] != 0.0) + { + y[i] = obs->L[i] * lam[i] - r - dant[i]; + } + if (obs->P[i] != 0.0) + { + y[i + nf] = obs->P[i] - r - dant[i]; + } } } } @@ -1102,29 +1257,50 @@ int zdres(int base, const obsd_t *obs, int n, const double *rs, trace(3, "zdres : n=%d\n", n); - for (i = 0; i < n * nf * 2; i++) y[i] = 0.0; + for (i = 0; i < n * nf * 2; i++) + { + y[i] = 0.0; + } - if (norm_rtk(rr, 3) <= 0.0) return 0; /* no receiver position */ + if (norm_rtk(rr, 3) <= 0.0) + { + return 0; /* no receiver position */ + } - for (i = 0; i < 3; i++) rr_[i] = rr[i]; + for (i = 0; i < 3; i++) + { + rr_[i] = rr[i]; + } /* earth tide correction */ if (opt->tidecorr) { tidedisp(gpst2utc(obs[0].time), rr_, opt->tidecorr, &nav->erp, opt->odisp[base], disp); - for (i = 0; i < 3; i++) rr_[i] += disp[i]; + for (i = 0; i < 3; i++) + { + rr_[i] += disp[i]; + } } ecef2pos(rr_, pos); for (i = 0; i < n; i++) { /* compute geometric-range and azimuth/elevation angle */ - if ((r = geodist(rs + i * 6, rr_, e + i * 3)) <= 0.0) continue; - if (satazel(pos, e + i * 3, azel + i * 2) < opt->elmin) continue; + if ((r = geodist(rs + i * 6, rr_, e + i * 3)) <= 0.0) + { + continue; + } + if (satazel(pos, e + i * 3, azel + i * 2) < opt->elmin) + { + continue; + } /* excluded satellite? */ - if (satexclude(obs[i].sat, svh[i], opt)) continue; + if (satexclude(obs[i].sat, svh[i], opt)) + { + continue; + } /* satellite clock-bias */ r += -SPEED_OF_LIGHT * dts[i * 2]; @@ -1172,14 +1348,19 @@ void ddcov(const int *nb, int n, const double *Ri, const double *Rj, trace(3, "ddcov : n=%d\n", n); - for (i = 0; i < nv * nv; i++) R[i] = 0.0; + for (i = 0; i < nv * nv; i++) + { + R[i] = 0.0; + } for (b = 0; b < n; k += nb[b++]) { for (i = 0; i < nb[b]; i++) - for (j = 0; j < nb[b]; j++) - { - R[k + i + (k + j) * nv] = Ri[k + i] + (i == j ? Rj[k + i] : 0.0); - } + { + for (j = 0; j < nb[b]; j++) + { + R[k + i + (k + j) * nv] = Ri[k + i] + (i == j ? Rj[k + i] : 0.0); + } + } } trace(5, "R=\n"); tracemat(5, R, nv, nv, 8, 6); @@ -1197,7 +1378,10 @@ int constbl(rtk_t *rtk, const double *x, const double *P, double *v, trace(3, "constbl : \n"); /* no constraint */ - if (rtk->opt.baseline[0] <= 0.0) return 0; + if (rtk->opt.baseline[0] <= 0.0) + { + return 0; + } /* time-adjusted baseline vector and length */ for (i = 0; i < 3; i++) @@ -1226,7 +1410,10 @@ int constbl(rtk_t *rtk, const double *x, const double *P, double *v, v[index] = rtk->opt.baseline[0] - bb; if (H) { - for (i = 0; i < 3; i++) H[i + index * rtk->nx] = b[i] / bb; + for (i = 0; i < 3; i++) + { + H[i + index * rtk->nx] = b[i] / bb; + } } Ri[index] = 0.0; Rj[index] = std::pow(rtk->opt.baseline[1], 2.0); @@ -1259,7 +1446,9 @@ double prectrop(gtime_t time, const double *pos, int r, dtdx[2] = grad_e * x[i]; } else - dtdx[1] = dtdx[2] = 0.0; + { + dtdx[1] = dtdx[2] = 0.0; + } dtdx[0] = m_w; return m_w * x[i]; } @@ -1271,7 +1460,10 @@ double gloicbcorr(int sat1 __attribute((unused)), int sat2 __attribute((unused)) { double dfreq; - if (f >= NFREQGLO || f >= opt->nf || !opt->exterr.ena[2]) return 0.0; + if (f >= NFREQGLO || f >= opt->nf || !opt->exterr.ena[2]) + { + return 0.0; + } dfreq = (SPEED_OF_LIGHT / lam1 - SPEED_OF_LIGHT / lam2) / (f == 0 ? DFRQ1_GLO : DFRQ2_GLO); @@ -1327,10 +1519,12 @@ int ddres(rtk_t *rtk, const nav_t *nav, double dt, const double *x, dtdxr = mat(ns, 3); for (i = 0; i < MAXSAT; i++) - for (j = 0; j < NFREQ; j++) - { - rtk->ssat[i].resp[j] = rtk->ssat[i].resc[j] = 0.0; - } + { + for (j = 0; j < NFREQ; j++) + { + rtk->ssat[i].resp[j] = rtk->ssat[i].resc[j] = 0.0; + } + } /* compute factors of ionospheric and tropospheric delay */ for (i = 0; i < ns; i++) { @@ -1344,145 +1538,186 @@ int ddres(rtk_t *rtk, const nav_t *nav, double dt, const double *x, tropr[i] = prectrop(rtk->sol.time, posr, 1, azel + ir[i] * 2, opt, x, dtdxr + i * 3); } } - for (m = 0; m < 4; m++) /* m=0:gps/qzs/sbs, 1:glo, 2:gal, 3:bds */ + for (m = 0; m < 4; m++) + { /* m=0:gps/qzs/sbs, 1:glo, 2:gal, 3:bds */ - for (f = opt->mode > PMODE_DGPS ? 0 : nf; f < nf * 2; f++) - { - /* search reference satellite with highest elevation */ - for (i = -1, j = 0; j < ns; j++) - { - sysi = rtk->ssat[sat[j] - 1].sys; - if (!test_sys(sysi, m)) continue; - if (!validobs(iu[j], ir[j], f, nf, y)) continue; - if (i < 0 || azel[1 + iu[j] * 2] >= azel[1 + iu[i] * 2]) i = j; - } - if (i < 0) continue; + for (f = opt->mode > PMODE_DGPS ? 0 : nf; f < nf * 2; f++) + { + /* search reference satellite with highest elevation */ + for (i = -1, j = 0; j < ns; j++) + { + sysi = rtk->ssat[sat[j] - 1].sys; + if (!test_sys(sysi, m)) + { + continue; + } + if (!validobs(iu[j], ir[j], f, nf, y)) + { + continue; + } + if (i < 0 || azel[1 + iu[j] * 2] >= azel[1 + iu[i] * 2]) + { + i = j; + } + } + if (i < 0) + { + continue; + } - /* make double difference */ - for (j = 0; j < ns; j++) - { - if (i == j) continue; - sysi = rtk->ssat[sat[i] - 1].sys; - sysj = rtk->ssat[sat[j] - 1].sys; - if (!test_sys(sysj, m)) continue; - if (!validobs(iu[j], ir[j], f, nf, y)) continue; + /* make double difference */ + for (j = 0; j < ns; j++) + { + if (i == j) + { + continue; + } + sysi = rtk->ssat[sat[i] - 1].sys; + sysj = rtk->ssat[sat[j] - 1].sys; + if (!test_sys(sysj, m)) + { + continue; + } + if (!validobs(iu[j], ir[j], f, nf, y)) + { + continue; + } - ff = f % nf; - lami = nav->lam[sat[i] - 1][ff]; - lamj = nav->lam[sat[j] - 1][ff]; - if (lami <= 0.0 || lamj <= 0.0) continue; - if (H) - { - Hi = H + nv * rtk->nx; - for (k = 0; k < rtk->nx; k++) Hi[k] = 0.0; - } - /* double-differenced residual */ - v[nv] = (y[f + iu[i] * nf * 2] - y[f + ir[i] * nf * 2]) - - (y[f + iu[j] * nf * 2] - y[f + ir[j] * nf * 2]); + ff = f % nf; + lami = nav->lam[sat[i] - 1][ff]; + lamj = nav->lam[sat[j] - 1][ff]; + if (lami <= 0.0 || lamj <= 0.0) + { + continue; + } + if (H) + { + Hi = H + nv * rtk->nx; + for (k = 0; k < rtk->nx; k++) + { + Hi[k] = 0.0; + } + } + /* double-differenced residual */ + v[nv] = (y[f + iu[i] * nf * 2] - y[f + ir[i] * nf * 2]) - + (y[f + iu[j] * nf * 2] - y[f + ir[j] * nf * 2]); - /* partial derivatives by rover position */ - if (H) - { - for (k = 0; k < 3; k++) - { - Hi[k] = -e[k + iu[i] * 3] + e[k + iu[j] * 3]; - } - } - /* double-differenced ionospheric delay term */ - if (opt->ionoopt == IONOOPT_EST) - { - fi = lami / lam_carr[0]; - fj = lamj / lam_carr[0]; - didxi = (f < nf ? -1.0 : 1.0) * fi * fi * im[i]; - didxj = (f < nf ? -1.0 : 1.0) * fj * fj * im[j]; - v[nv] -= didxi * x[II_RTK(sat[i], opt)] - didxj * x[II_RTK(sat[j], opt)]; - if (H) - { - Hi[II_RTK(sat[i], opt)] = didxi; - Hi[II_RTK(sat[j], opt)] = -didxj; - } - } - /* double-differenced tropospheric delay term */ - if (opt->tropopt == TROPOPT_EST || opt->tropopt == TROPOPT_ESTG) - { - v[nv] -= (tropu[i] - tropu[j]) - (tropr[i] - tropr[j]); - for (k = 0; k < (opt->tropopt < TROPOPT_ESTG ? 1 : 3); k++) - { - if (!H) continue; - Hi[IT_RTK(0, opt) + k] = (dtdxu[k + i * 3] - dtdxu[k + j * 3]); - Hi[IT_RTK(1, opt) + k] = -(dtdxr[k + i * 3] - dtdxr[k + j * 3]); - } - } - /* double-differenced phase-bias term */ - if (f < nf) - { - if (opt->ionoopt != IONOOPT_IFLC) - { - v[nv] -= lami * x[IB_RTK(sat[i], f, opt)] - lamj * x[IB_RTK(sat[j], f, opt)]; - if (H) - { - Hi[IB_RTK(sat[i], f, opt)] = lami; - Hi[IB_RTK(sat[j], f, opt)] = -lamj; - } - } - else - { - v[nv] -= x[IB_RTK(sat[i], f, opt)] - x[IB_RTK(sat[j], f, opt)]; - if (H) - { - Hi[IB_RTK(sat[i], f, opt)] = 1.0; - Hi[IB_RTK(sat[j], f, opt)] = -1.0; - } - } - } - /* glonass receiver h/w bias term */ - if (rtk->opt.glomodear == 2 && sysi == SYS_GLO && sysj == SYS_GLO && ff < NFREQGLO) - { - df = (SPEED_OF_LIGHT / lami - SPEED_OF_LIGHT / lamj) / 1E6; /* freq-difference (MHz) */ - v[nv] -= df * x[IL_RTK(ff, opt)]; - if (H) Hi[IL_RTK(ff, opt)] = df; - } - /* glonass interchannel bias correction */ - else if (sysi == SYS_GLO && sysj == SYS_GLO) - { - v[nv] -= gloicbcorr(sat[i], sat[j], &rtk->opt, lami, lamj, f); - } - if (f < nf) - rtk->ssat[sat[j] - 1].resc[f] = v[nv]; - else - rtk->ssat[sat[j] - 1].resp[f - nf] = v[nv]; + /* partial derivatives by rover position */ + if (H) + { + for (k = 0; k < 3; k++) + { + Hi[k] = -e[k + iu[i] * 3] + e[k + iu[j] * 3]; + } + } + /* double-differenced ionospheric delay term */ + if (opt->ionoopt == IONOOPT_EST) + { + fi = lami / lam_carr[0]; + fj = lamj / lam_carr[0]; + didxi = (f < nf ? -1.0 : 1.0) * fi * fi * im[i]; + didxj = (f < nf ? -1.0 : 1.0) * fj * fj * im[j]; + v[nv] -= didxi * x[II_RTK(sat[i], opt)] - didxj * x[II_RTK(sat[j], opt)]; + if (H) + { + Hi[II_RTK(sat[i], opt)] = didxi; + Hi[II_RTK(sat[j], opt)] = -didxj; + } + } + /* double-differenced tropospheric delay term */ + if (opt->tropopt == TROPOPT_EST || opt->tropopt == TROPOPT_ESTG) + { + v[nv] -= (tropu[i] - tropu[j]) - (tropr[i] - tropr[j]); + for (k = 0; k < (opt->tropopt < TROPOPT_ESTG ? 1 : 3); k++) + { + if (!H) + { + continue; + } + Hi[IT_RTK(0, opt) + k] = (dtdxu[k + i * 3] - dtdxu[k + j * 3]); + Hi[IT_RTK(1, opt) + k] = -(dtdxr[k + i * 3] - dtdxr[k + j * 3]); + } + } + /* double-differenced phase-bias term */ + if (f < nf) + { + if (opt->ionoopt != IONOOPT_IFLC) + { + v[nv] -= lami * x[IB_RTK(sat[i], f, opt)] - lamj * x[IB_RTK(sat[j], f, opt)]; + if (H) + { + Hi[IB_RTK(sat[i], f, opt)] = lami; + Hi[IB_RTK(sat[j], f, opt)] = -lamj; + } + } + else + { + v[nv] -= x[IB_RTK(sat[i], f, opt)] - x[IB_RTK(sat[j], f, opt)]; + if (H) + { + Hi[IB_RTK(sat[i], f, opt)] = 1.0; + Hi[IB_RTK(sat[j], f, opt)] = -1.0; + } + } + } + /* glonass receiver h/w bias term */ + if (rtk->opt.glomodear == 2 && sysi == SYS_GLO && sysj == SYS_GLO && ff < NFREQGLO) + { + df = (SPEED_OF_LIGHT / lami - SPEED_OF_LIGHT / lamj) / 1E6; /* freq-difference (MHz) */ + v[nv] -= df * x[IL_RTK(ff, opt)]; + if (H) + { + Hi[IL_RTK(ff, opt)] = df; + } + } + /* glonass interchannel bias correction */ + else if (sysi == SYS_GLO && sysj == SYS_GLO) + { + v[nv] -= gloicbcorr(sat[i], sat[j], &rtk->opt, lami, lamj, f); + } + if (f < nf) + { + rtk->ssat[sat[j] - 1].resc[f] = v[nv]; + } + else + { + rtk->ssat[sat[j] - 1].resp[f - nf] = v[nv]; + } - /* test innovation */ - if (opt->maxinno > 0.0 && fabs(v[nv]) > opt->maxinno) - { - if (f < nf) - { - rtk->ssat[sat[i] - 1].rejc[f]++; - rtk->ssat[sat[j] - 1].rejc[f]++; - } - errmsg(rtk, "outlier rejected (sat=%3d-%3d %s%d v=%.3f)\n", - sat[i], sat[j], f < nf ? "L" : "P", f % nf + 1, v[nv]); - continue; - } - /* single-differenced measurement error variances */ - Ri[nv] = varerr(sat[i], sysi, azel[1 + iu[i] * 2], bl, dt, f, opt); - Rj[nv] = varerr(sat[j], sysj, azel[1 + iu[j] * 2], bl, dt, f, opt); + /* test innovation */ + if (opt->maxinno > 0.0 && fabs(v[nv]) > opt->maxinno) + { + if (f < nf) + { + rtk->ssat[sat[i] - 1].rejc[f]++; + rtk->ssat[sat[j] - 1].rejc[f]++; + } + errmsg(rtk, "outlier rejected (sat=%3d-%3d %s%d v=%.3f)\n", + sat[i], sat[j], f < nf ? "L" : "P", f % nf + 1, v[nv]); + continue; + } + /* single-differenced measurement error variances */ + Ri[nv] = varerr(sat[i], sysi, azel[1 + iu[i] * 2], bl, dt, f, opt); + Rj[nv] = varerr(sat[j], sysj, azel[1 + iu[j] * 2], bl, dt, f, opt); - /* set valid data flags */ - if (opt->mode > PMODE_DGPS) - { - if (f < nf) rtk->ssat[sat[i] - 1].vsat[f] = rtk->ssat[sat[j] - 1].vsat[f] = 1; - } - else - { - rtk->ssat[sat[i] - 1].vsat[f - nf] = rtk->ssat[sat[j] - 1].vsat[f - nf] = 1; - } - trace(4, "sat=%3d-%3d %s%d v=%13.3f R=%8.6f %8.6f\n", sat[i], - sat[j], f < nf ? "L" : "P", f % nf + 1, v[nv], Ri[nv], Rj[nv]); + /* set valid data flags */ + if (opt->mode > PMODE_DGPS) + { + if (f < nf) + { + rtk->ssat[sat[i] - 1].vsat[f] = rtk->ssat[sat[j] - 1].vsat[f] = 1; + } + } + else + { + rtk->ssat[sat[i] - 1].vsat[f - nf] = rtk->ssat[sat[j] - 1].vsat[f - nf] = 1; + } + trace(4, "sat=%3d-%3d %s%d v=%13.3f R=%8.6f %8.6f\n", sat[i], + sat[j], f < nf ? "L" : "P", f % nf + 1, v[nv], Ri[nv], Rj[nv]); - vflg[nv++] = (sat[i] << 16) | (sat[j] << 8) | ((f < nf ? 0 : 1) << 4) | (f % nf); - nb[b]++; - } + vflg[nv++] = (sat[i] << 16) | (sat[j] << 8) | ((f < nf ? 0 : 1) << 4) | (f % nf); + nb[b]++; + } #if 0 /* residuals referenced to reference satellite (2.4.2 p11) */ /* restore single-differenced residuals assuming sum equal zero */ if (f opt->maxtdiff * 2.0 || ttb == tt) return tt; + if (fabs(ttb) > opt->maxtdiff * 2.0 || ttb == tt) + { + return tt; + } satposs(time, obsb, nb, nav, opt->sateph, rs, dts, var, svh); @@ -1568,14 +1810,26 @@ double intpres(gtime_t time, const obsd_t *obs, int n, const nav_t *nav, for (i = 0; i < n; i++) { for (j = 0; j < nb; j++) - if (obsb[j].sat == obs[i].sat) break; - if (j >= nb) continue; + { + if (obsb[j].sat == obs[i].sat) + { + break; + } + } + if (j >= nb) + { + continue; + } for (k = 0, p = y + i * nf * 2, q = yb + j * nf * 2; k < nf * 2; k++, p++, q++) { if (*p == 0.0 || *q == 0.0) - *p = 0.0; + { + *p = 0.0; + } else - *p = (ttb * (*p) - tt * (*q)) / (ttb - tt); + { + *p = (ttb * (*p) - tt * (*q)) / (ttb - tt); + } } } return fabs(ttb) > fabs(tt) ? ttb : tt; @@ -1590,11 +1844,16 @@ int ddmat(rtk_t *rtk, double *D) trace(3, "ddmat :\n"); for (i = 0; i < MAXSAT; i++) - for (j = 0; j < NFREQ; j++) - { - rtk->ssat[i].fix[j] = 0; - } - for (i = 0; i < na; i++) D[i + i * nx] = 1.0; + { + for (j = 0; j < NFREQ; j++) + { + rtk->ssat[i].fix[j] = 0; + } + } + for (i = 0; i < na; i++) + { + D[i + i * nx] = 1.0; + } for (m = 0; m < 4; m++) { /* m=0:gps/qzs/sbs, 1:glo, 2:gal, 3:bds */ @@ -1636,7 +1895,9 @@ int ddmat(rtk_t *rtk, double *D) rtk->ssat[j - k].fix[f] = 2; /* fix */ } else - rtk->ssat[j - k].fix[f] = 1; + { + rtk->ssat[j - k].fix[f] = 1; + } } } } @@ -1654,29 +1915,40 @@ void restamb(rtk_t *rtk, const double *bias, int nb __attribute((unused)), doubl trace(3, "restamb :\n"); - for (i = 0; i < rtk->nx; i++) xa[i] = rtk->x[i]; - for (i = 0; i < rtk->na; i++) xa[i] = rtk->xa[i]; + for (i = 0; i < rtk->nx; i++) + { + xa[i] = rtk->x[i]; + } + for (i = 0; i < rtk->na; i++) + { + xa[i] = rtk->xa[i]; + } for (m = 0; m < 4; m++) - for (f = 0; f < nf; f++) - { - for (n = i = 0; i < MAXSAT; i++) - { - if (!test_sys(rtk->ssat[i].sys, m) || rtk->ssat[i].fix[f] != 2) - { - continue; - } - index[n++] = IB_RTK(i + 1, f, &rtk->opt); - } - if (n < 2) continue; + { + for (f = 0; f < nf; f++) + { + for (n = i = 0; i < MAXSAT; i++) + { + if (!test_sys(rtk->ssat[i].sys, m) || rtk->ssat[i].fix[f] != 2) + { + continue; + } + index[n++] = IB_RTK(i + 1, f, &rtk->opt); + } + if (n < 2) + { + continue; + } - xa[index[0]] = rtk->x[index[0]]; + xa[index[0]] = rtk->x[index[0]]; - for (i = 1; i < n; i++) - { - xa[index[i]] = xa[index[0]] - bias[nv++]; - } - } + for (i = 1; i < n; i++) + { + xa[index[i]] = xa[index[0]] - bias[nv++]; + } + } + } } @@ -1692,32 +1964,37 @@ void holdamb(rtk_t *rtk, const double *xa) H = zeros(nb, rtk->nx); for (m = 0; m < 4; m++) - for (f = 0; f < nf; f++) - { - for (n = i = 0; i < MAXSAT; i++) - { - if (!test_sys(rtk->ssat[i].sys, m) || rtk->ssat[i].fix[f] != 2 || - rtk->ssat[i].azel[1] < rtk->opt.elmaskhold) - { - continue; - } - index[n++] = IB_RTK(i + 1, f, &rtk->opt); - rtk->ssat[i].fix[f] = 3; /* hold */ - } - /* constraint to fixed ambiguity */ - for (i = 1; i < n; i++) - { - v[nv] = (xa[index[0]] - xa[index[i]]) - (rtk->x[index[0]] - rtk->x[index[i]]); + { + for (f = 0; f < nf; f++) + { + for (n = i = 0; i < MAXSAT; i++) + { + if (!test_sys(rtk->ssat[i].sys, m) || rtk->ssat[i].fix[f] != 2 || + rtk->ssat[i].azel[1] < rtk->opt.elmaskhold) + { + continue; + } + index[n++] = IB_RTK(i + 1, f, &rtk->opt); + rtk->ssat[i].fix[f] = 3; /* hold */ + } + /* constraint to fixed ambiguity */ + for (i = 1; i < n; i++) + { + v[nv] = (xa[index[0]] - xa[index[i]]) - (rtk->x[index[0]] - rtk->x[index[i]]); - H[index[0] + nv * rtk->nx] = 1.0; - H[index[i] + nv * rtk->nx] = -1.0; - nv++; - } - } + H[index[0] + nv * rtk->nx] = 1.0; + H[index[i] + nv * rtk->nx] = -1.0; + nv++; + } + } + } if (nv > 0) { R = zeros(nv, nv); - for (i = 0; i < nv; i++) R[i + i * nv] = VAR_HOLDAMB; + for (i = 0; i < nv; i++) + { + R[i + i * nv] = VAR_HOLDAMB; + } /* update states with constraints */ if ((info = filter(rtk->x, rtk->P, H, v, R, rtk->nx, nv))) @@ -1772,9 +2049,19 @@ int resamb_LAMBDA(rtk_t *rtk, double *bias, double *xa) /* phase-bias covariance (Qb) and real-parameters to bias covariance (Qab) */ for (i = 0; i < nb; i++) - for (j = 0; j < nb; j++) Qb[i + j * nb] = Qy[na + i + (na + j) * ny]; + { + for (j = 0; j < nb; j++) + { + Qb[i + j * nb] = Qy[na + i + (na + j) * ny]; + } + } for (i = 0; i < na; i++) - for (j = 0; j < nb; j++) Qab[i + j * na] = Qy[i + (na + j) * ny]; + { + for (j = 0; j < nb; j++) + { + Qab[i + j * na] = Qy[i + (na + j) * ny]; + } + } trace(4, "N(0)="); tracemat(4, y + na, 1, nb, 10, 3); @@ -1788,7 +2075,10 @@ int resamb_LAMBDA(rtk_t *rtk, double *bias, double *xa) tracemat(4, b + nb, 1, nb, 10, 3); rtk->sol.ratio = s[0] > 0 ? static_cast(s[1] / s[0]) : 0.0f; - if (rtk->sol.ratio > 999.9) rtk->sol.ratio = 999.9f; + if (rtk->sol.ratio > 999.9) + { + rtk->sol.ratio = 999.9f; + } /* validation by popular ratio-test */ if (s[0] <= 0.0 || s[1] / s[0] >= opt->thresar[0]) @@ -1797,7 +2087,10 @@ int resamb_LAMBDA(rtk_t *rtk, double *bias, double *xa) for (i = 0; i < na; i++) { rtk->xa[i] = rtk->x[i]; - for (j = 0; j < na; j++) rtk->Pa[i + j * na] = rtk->P[i + j * nx]; + for (j = 0; j < na; j++) + { + rtk->Pa[i + j * na] = rtk->P[i + j * nx]; + } } for (i = 0; i < nb; i++) { @@ -1820,7 +2113,9 @@ int resamb_LAMBDA(rtk_t *rtk, double *bias, double *xa) restamb(rtk, bias, nb, xa); } else - nb = 0; + { + nb = 0; + } } else { /* validation failed */ @@ -1864,7 +2159,10 @@ int valpos(rtk_t *rtk, const double *v, const double *R, const int *vflg, /* post-fit residual test */ for (i = 0; i < nv; i++) { - if (v[i] * v[i] <= fact * R[i + i * nv]) continue; + if (v[i] * v[i] <= fact * R[i + i * nv]) + { + continue; + } sat1 = (vflg[i] >> 16) & 0xFF; sat2 = (vflg[i] >> 8) & 0xFF; type = (vflg[i] >> 4) & 0xF; @@ -1922,7 +2220,10 @@ int relpos(rtk_t *rtk, const obsd_t *obs, int nu, int nr, for (i = 0; i < MAXSAT; i++) { rtk->ssat[i].sys = satsys(i + 1, nullptr); - for (j = 0; j < NFREQ; j++) rtk->ssat[i].vsat[j] = rtk->ssat[i].snr[j] = 0; + for (j = 0; j < NFREQ; j++) + { + rtk->ssat[i].vsat[j] = rtk->ssat[i].snr[j] = 0; + } } /* satellite positions/clocks */ satposs(time, obs, n, nav, opt->sateph, rs, dts, var, svh); @@ -2021,18 +2322,31 @@ int relpos(rtk_t *rtk, const obsd_t *obs, int nu, int nr, /* update ambiguity control struct */ rtk->sol.ns = 0; for (i = 0; i < ns; i++) - for (f = 0; f < nf; f++) - { - if (!rtk->ssat[sat[i] - 1].vsat[f]) continue; - rtk->ssat[sat[i] - 1].lock[f]++; - rtk->ssat[sat[i] - 1].outc[f] = 0; - if (f == 0) rtk->sol.ns++; /* valid satellite count by L1 */ - } + { + for (f = 0; f < nf; f++) + { + if (!rtk->ssat[sat[i] - 1].vsat[f]) + { + continue; + } + rtk->ssat[sat[i] - 1].lock[f]++; + rtk->ssat[sat[i] - 1].outc[f] = 0; + if (f == 0) + { + rtk->sol.ns++; /* valid satellite count by L1 */ + } + } + } /* lack of valid satellites */ - if (rtk->sol.ns < 4) stat = SOLQ_NONE; + if (rtk->sol.ns < 4) + { + stat = SOLQ_NONE; + } } else - stat = SOLQ_NONE; + { + stat = SOLQ_NONE; + } } /* resolve integer ambiguity by WL-NL */ if (stat != SOLQ_NONE && rtk->opt.modear == ARMODE_WLNL) @@ -2097,24 +2411,39 @@ int relpos(rtk_t *rtk, const obsd_t *obs, int nu, int nr, rtk->nfix = 0; } for (i = 0; i < n; i++) - for (j = 0; j < nf; j++) - { - if (obs[i].L[j] == 0.0) continue; - rtk->ssat[obs[i].sat - 1].pt[obs[i].rcv - 1][j] = obs[i].time; - rtk->ssat[obs[i].sat - 1].ph[obs[i].rcv - 1][j] = obs[i].L[j]; - } + { + for (j = 0; j < nf; j++) + { + if (obs[i].L[j] == 0.0) + { + continue; + } + rtk->ssat[obs[i].sat - 1].pt[obs[i].rcv - 1][j] = obs[i].time; + rtk->ssat[obs[i].sat - 1].ph[obs[i].rcv - 1][j] = obs[i].L[j]; + } + } for (i = 0; i < ns; i++) - for (j = 0; j < nf; j++) - { - /* output snr of rover receiver */ - rtk->ssat[sat[i] - 1].snr[j] = obs[iu[i]].SNR[j]; - } + { + for (j = 0; j < nf; j++) + { + /* output snr of rover receiver */ + rtk->ssat[sat[i] - 1].snr[j] = obs[iu[i]].SNR[j]; + } + } for (i = 0; i < MAXSAT; i++) - for (j = 0; j < nf; j++) - { - if (rtk->ssat[i].fix[j] == 2 && stat != SOLQ_FIX) rtk->ssat[i].fix[j] = 1; - if (rtk->ssat[i].slip[j] & 1) rtk->ssat[i].slipc[j]++; - } + { + for (j = 0; j < nf; j++) + { + if (rtk->ssat[i].fix[j] == 2 && stat != SOLQ_FIX) + { + rtk->ssat[i].fix[j] = 1; + } + if (rtk->ssat[i].slip[j] & 1) + { + rtk->ssat[i].slipc[j]++; + } + } + } free(rs); free(dts); free(var); @@ -2129,7 +2458,10 @@ int relpos(rtk_t *rtk, const obsd_t *obs, int nu, int nr, free(R); free(bias); - if (stat != SOLQ_NONE) rtk->sol.stat = stat; + if (stat != SOLQ_NONE) + { + rtk->sol.stat = stat; + } return stat != SOLQ_NONE; } @@ -2151,7 +2483,10 @@ void rtkinit(rtk_t *rtk, const prcopt_t *opt) trace(3, "rtkinit :\n"); rtk->sol = sol0; - for (i = 0; i < 6; i++) rtk->rb[i] = 0.0; + for (i = 0; i < 6; i++) + { + rtk->rb[i] = 0.0; + } rtk->nx = opt->mode <= PMODE_FIXED ? NX_RTK(opt) : pppnx(opt); rtk->na = opt->mode <= PMODE_FIXED ? NR_RTK(opt) : pppnx(opt); rtk->tt = 0.0; @@ -2165,7 +2500,10 @@ void rtkinit(rtk_t *rtk, const prcopt_t *opt) rtk->ambc[i] = ambc0; rtk->ssat[i] = ssat0; } - for (i = 0; i < MAXERRMSG; i++) rtk->errbuf[i] = 0; + for (i = 0; i < MAXERRMSG; i++) + { + rtk->errbuf[i] = 0; + } rtk->opt = *opt; } @@ -2266,13 +2604,20 @@ int rtkpos(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) if (opt->refpos <= POSOPT_RINEX && opt->mode != PMODE_SINGLE && opt->mode != PMODE_MOVEB) { - for (i = 0; i < 6; i++) rtk->rb[i] = i < 3 ? opt->rb[i] : 0.0; + for (i = 0; i < 6; i++) + { + rtk->rb[i] = i < 3 ? opt->rb[i] : 0.0; + } } /* count rover/base station observations */ for (nu = 0; nu < n && obs[nu].rcv == 1; nu++) - ; + { + ; + } for (nr = 0; nu + nr < n && obs[nu + nr].rcv == 2; nr++) - ; + { + ; + } time = rtk->sol.time; /* previous epoch */ @@ -2286,7 +2631,10 @@ int rtkpos(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) return 0; } } - if (time.time != 0) rtk->tt = timediff(rtk->sol.time, time); + if (time.time != 0) + { + rtk->tt = timediff(rtk->sol.time, time); + } /* single point positioning */ if (opt->mode == PMODE_SINGLE) @@ -2329,10 +2677,16 @@ int rtkpos(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) errmsg(rtk, "time sync error for moving-base (age=%.1f)\n", rtk->sol.age); return 0; } - for (i = 0; i < 6; i++) rtk->rb[i] = solb.rr[i]; + for (i = 0; i < 6; i++) + { + rtk->rb[i] = solb.rr[i]; + } /* time-synchronized position of base station */ - for (i = 0; i < 3; i++) rtk->rb[i] += rtk->rb[i + 3] * rtk->sol.age; + for (i = 0; i < 3; i++) + { + rtk->rb[i] += rtk->rb[i + 3] * rtk->sol.age; + } } else { diff --git a/src/algorithms/libs/rtklib/rtklib_rtksvr.cc b/src/algorithms/libs/rtklib/rtklib_rtksvr.cc index ba21c3359..a86425dbb 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtksvr.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtksvr.cc @@ -78,10 +78,12 @@ void updatenav(nav_t *nav) { int i, j; for (i = 0; i < MAXSAT; i++) - for (j = 0; j < NFREQ; j++) - { - nav->lam[i][j] = satwavelen(i + 1, j, nav); - } + { + for (j = 0; j < NFREQ; j++) + { + nav->lam[i][j] = satwavelen(i + 1, j, nav); + } + } } @@ -96,14 +98,23 @@ void updatefcn(rtksvr_t *svr) for (j = 0, frq = -999; j < 3; j++) { - if (svr->raw[j].nav.geph[i].sat != sat) continue; + if (svr->raw[j].nav.geph[i].sat != sat) + { + continue; + } frq = svr->raw[j].nav.geph[i].frq; } - if (frq < -7 || frq > 6) continue; + if (frq < -7 || frq > 6) + { + continue; + } for (j = 0; j < 3; j++) { - if (svr->raw[j].nav.geph[i].sat == sat) continue; + if (svr->raw[j].nav.geph[i].sat == sat) + { + continue; + } svr->raw[j].nav.geph[i].sat = sat; svr->raw[j].nav.geph[i].frq = frq; } @@ -130,7 +141,10 @@ void updatesvr(rtksvr_t *svr, int ret, obs_t *obs, nav_t *nav, int sat, for (i = 0; i < obs->n; i++) { if (svr->rtk.opt.exsats[obs->data[i].sat - 1] == 1 || - !(satsys(obs->data[i].sat, nullptr) & svr->rtk.opt.navsys)) continue; + !(satsys(obs->data[i].sat, nullptr) & svr->rtk.opt.navsys)) + { + continue; + } svr->obs[index][iobs].data[n] = obs->data[i]; svr->obs[index][iobs].data[n++].rcv = index + 1; } @@ -189,7 +203,10 @@ void updatesvr(rtksvr_t *svr, int ret, obs_t *obs, nav_t *nav, int sat, } else { - for (i = 0; i < MAXSBSMSG - 1; i++) svr->sbsmsg[i] = svr->sbsmsg[i + 1]; + for (i = 0; i < MAXSBSMSG - 1; i++) + { + svr->sbsmsg[i] = svr->sbsmsg[i + 1]; + } svr->sbsmsg[i] = *sbsmsg; } sbsupdatecorr(sbsmsg, &svr->nav); @@ -200,12 +217,30 @@ void updatesvr(rtksvr_t *svr, int ret, obs_t *obs, nav_t *nav, int sat, { /* ion/utc parameters */ if (svr->navsel == index || svr->navsel >= 3) { - for (i = 0; i < 8; i++) svr->nav.ion_gps[i] = nav->ion_gps[i]; - for (i = 0; i < 4; i++) svr->nav.utc_gps[i] = nav->utc_gps[i]; - for (i = 0; i < 4; i++) svr->nav.ion_gal[i] = nav->ion_gal[i]; - for (i = 0; i < 4; i++) svr->nav.utc_gal[i] = nav->utc_gal[i]; - for (i = 0; i < 8; i++) svr->nav.ion_qzs[i] = nav->ion_qzs[i]; - for (i = 0; i < 4; i++) svr->nav.utc_qzs[i] = nav->utc_qzs[i]; + for (i = 0; i < 8; i++) + { + svr->nav.ion_gps[i] = nav->ion_gps[i]; + } + for (i = 0; i < 4; i++) + { + svr->nav.utc_gps[i] = nav->utc_gps[i]; + } + for (i = 0; i < 4; i++) + { + svr->nav.ion_gal[i] = nav->ion_gal[i]; + } + for (i = 0; i < 4; i++) + { + svr->nav.utc_gal[i] = nav->utc_gal[i]; + } + for (i = 0; i < 8; i++) + { + svr->nav.ion_qzs[i] = nav->ion_qzs[i]; + } + for (i = 0; i < 4; i++) + { + svr->nav.utc_qzs[i] = nav->utc_qzs[i]; + } svr->nav.leaps = nav->leaps; } svr->nmsg[index][2]++; @@ -248,7 +283,10 @@ void updatesvr(rtksvr_t *svr, int ret, obs_t *obs, nav_t *nav, int sat, { /* ssr message */ for (i = 0; i < MAXSAT; i++) { - if (!svr->rtcm[index].ssr[i].update) continue; + if (!svr->rtcm[index].ssr[i].update) + { + continue; + } svr->rtcm[index].ssr[i].update = 0; iode = svr->rtcm[index].ssr[i].iode; @@ -333,15 +371,22 @@ int decoderaw(rtksvr_t *svr, int index) } #endif /* update rtk server */ - if (ret > 0) updatesvr(svr, ret, obs, nav, sat, sbsmsg, index, fobs); + if (ret > 0) + { + updatesvr(svr, ret, obs, nav, sat, sbsmsg, index, fobs); + } /* observation data received */ if (ret == 1) { if (fobs < MAXOBSBUF) - fobs++; + { + fobs++; + } else - svr->prcout++; + { + svr->prcout++; + } } } svr->nb[index] = 0; @@ -360,7 +405,9 @@ void decodefile(rtksvr_t *svr, int index) // Allocate space for GLONASS frequency channels depending on availability for (i = 0; i < MAXPRNGLO + 1; i++) - glo_fcn[i] = '0'; + { + glo_fcn[i] = '0'; + } pcv_t pcvt0[MAXSAT] = {{0, {'0'}, {'0'}, {0, 0.0}, {0, 0.0}, {{0.0}, {0.0}}, {{0.0}, {0.0}}}}; sbsfcorr_t sbsfcorr0 = {{0, 0.0}, 0.0, 0.0, 0.0, 0, 0, 0}; sbslcorr_t sbslcorr0 = {{0, 0.0}, 0, {0.0}, {0.0}, 0.0, 0.0}; @@ -413,7 +460,10 @@ void decodefile(rtksvr_t *svr, int index) /* update precise ephemeris */ rtksvrlock(svr); - if (svr->nav.peph) free(svr->nav.peph); + if (svr->nav.peph) + { + free(svr->nav.peph); + } svr->nav.ne = svr->nav.nemax = nav.ne; svr->nav.peph = nav.peph; svr->ftime[index] = utc2gpst(timeget()); @@ -433,7 +483,10 @@ void decodefile(rtksvr_t *svr, int index) /* update precise clock */ rtksvrlock(svr); - if (svr->nav.pclk) free(svr->nav.pclk); + if (svr->nav.pclk) + { + free(svr->nav.pclk); + } svr->nav.nc = svr->nav.ncmax = nav.nc; svr->nav.pclk = nav.pclk; svr->ftime[index] = utc2gpst(timeget()); @@ -555,12 +608,18 @@ void *rtksvrthread(void *arg) } ticknmea = tick; } - if ((cputime = static_cast(tickget() - tick)) > 0) svr->cputime = cputime; + if ((cputime = static_cast(tickget() - tick)) > 0) + { + svr->cputime = cputime; + } /* sleep until next cycle */ sleepms(svr->cycle - cputime); } - for (i = 0; i < MAXSTRRTK; i++) strclose(svr->stream + i); + for (i = 0; i < MAXSTRRTK; i++) + { + strclose(svr->stream + i); + } for (i = 0; i < 3; i++) { svr->nb[i] = svr->npb[i] = 0; @@ -602,23 +661,64 @@ int rtksvrinit(rtksvr_t *svr) tracet(3, "rtksvrinit:\n"); svr->state = svr->cycle = svr->nmeacycle = svr->nmeareq = 0; - for (i = 0; i < 3; i++) svr->nmeapos[i] = 0.0; + for (i = 0; i < 3; i++) + { + svr->nmeapos[i] = 0.0; + } svr->buffsize = 0; - for (i = 0; i < 3; i++) svr->format[i] = 0; - for (i = 0; i < 2; i++) svr->solopt[i] = solopt_default; + for (i = 0; i < 3; i++) + { + svr->format[i] = 0; + } + for (i = 0; i < 2; i++) + { + svr->solopt[i] = solopt_default; + } svr->navsel = svr->nsbs = svr->nsol = 0; rtkinit(&svr->rtk, &prcopt_default); - for (i = 0; i < 3; i++) svr->nb[i] = 0; - for (i = 0; i < 2; i++) svr->nsb[i] = 0; - for (i = 0; i < 3; i++) svr->npb[i] = 0; - for (i = 0; i < 3; i++) svr->buff[i] = nullptr; - for (i = 0; i < 2; i++) svr->sbuf[i] = nullptr; - for (i = 0; i < 3; i++) svr->pbuf[i] = nullptr; - for (i = 0; i < MAXSOLBUF; i++) svr->solbuf[i] = sol0; for (i = 0; i < 3; i++) - for (j = 0; j < 10; j++) svr->nmsg[i][j] = 0; - for (i = 0; i < 3; i++) svr->ftime[i] = time0; - for (i = 0; i < 3; i++) svr->files[i][0] = '\0'; + { + svr->nb[i] = 0; + } + for (i = 0; i < 2; i++) + { + svr->nsb[i] = 0; + } + for (i = 0; i < 3; i++) + { + svr->npb[i] = 0; + } + for (i = 0; i < 3; i++) + { + svr->buff[i] = nullptr; + } + for (i = 0; i < 2; i++) + { + svr->sbuf[i] = nullptr; + } + for (i = 0; i < 3; i++) + { + svr->pbuf[i] = nullptr; + } + for (i = 0; i < MAXSOLBUF; i++) + { + svr->solbuf[i] = sol0; + } + for (i = 0; i < 3; i++) + { + for (j = 0; j < 10; j++) + { + svr->nmsg[i][j] = 0; + } + } + for (i = 0; i < 3; i++) + { + svr->ftime[i] = time0; + } + for (i = 0; i < 3; i++) + { + svr->files[i][0] = '\0'; + } svr->moni = nullptr; svr->tick = 0; svr->thread = 0; // NOLINT @@ -631,28 +731,42 @@ int rtksvrinit(rtksvr_t *svr) tracet(1, "rtksvrinit: malloc error\n"); return 0; } - for (i = 0; i < MAXSAT * 2; i++) svr->nav.eph[i] = eph0; - for (i = 0; i < NSATGLO * 2; i++) svr->nav.geph[i] = geph0; - for (i = 0; i < NSATSBS * 2; i++) svr->nav.seph[i] = seph0; + for (i = 0; i < MAXSAT * 2; i++) + { + svr->nav.eph[i] = eph0; + } + for (i = 0; i < NSATGLO * 2; i++) + { + svr->nav.geph[i] = geph0; + } + for (i = 0; i < NSATSBS * 2; i++) + { + svr->nav.seph[i] = seph0; + } svr->nav.n = MAXSAT * 2; svr->nav.ng = NSATGLO * 2; svr->nav.ns = NSATSBS * 2; for (i = 0; i < 3; i++) - for (j = 0; j < MAXOBSBUF; j++) - { - if (!(svr->obs[i][j].data = static_cast(malloc(sizeof(obsd_t) * MAXOBS)))) - { - tracet(1, "rtksvrinit: malloc error\n"); - return 0; - } - } + { + for (j = 0; j < MAXOBSBUF; j++) + { + if (!(svr->obs[i][j].data = static_cast(malloc(sizeof(obsd_t) * MAXOBS)))) + { + tracet(1, "rtksvrinit: malloc error\n"); + return 0; + } + } + } for (i = 0; i < 3; i++) { memset(svr->raw + i, 0, sizeof(raw_t)); memset(svr->rtcm + i, 0, sizeof(rtcm_t)); } - for (i = 0; i < MAXSTRRTK; i++) strinit(svr->stream + i); + for (i = 0; i < MAXSTRRTK; i++) + { + strinit(svr->stream + i); + } initlock(&svr->lock); @@ -673,10 +787,12 @@ void rtksvrfree(rtksvr_t *svr) free(svr->nav.geph); free(svr->nav.seph); for (i = 0; i < 3; i++) - for (j = 0; j < MAXOBSBUF; j++) - { - free(svr->obs[i][j].data); - } + { + for (j = 0; j < MAXOBSBUF; j++) + { + free(svr->obs[i][j].data); + } + } } @@ -742,15 +858,24 @@ int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs, tracet(3, "rtksvrstart: cycle=%d buffsize=%d navsel=%d nmeacycle=%d nmeareq=%d\n", cycle, buffsize, navsel, nmeacycle, nmeareq); - if (svr->state) return 0; + if (svr->state) + { + return 0; + } strinitcom(); svr->cycle = cycle > 1 ? cycle : 1; svr->nmeacycle = nmeacycle > 1000 ? nmeacycle : 1000; svr->nmeareq = nmeareq; - for (i = 0; i < 3; i++) svr->nmeapos[i] = nmeapos[i]; + for (i = 0; i < 3; i++) + { + svr->nmeapos[i] = nmeapos[i]; + } svr->buffsize = buffsize > 4096 ? buffsize : 4096; - for (i = 0; i < 3; i++) svr->format[i] = formats[i]; + for (i = 0; i < 3; i++) + { + svr->format[i] = formats[i]; + } svr->navsel = navsel; svr->nsbs = 0; svr->nsol = 0; @@ -767,16 +892,28 @@ int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs, tracet(1, "rtksvrstart: malloc error\n"); return 0; } - for (j = 0; j < 10; j++) svr->nmsg[i][j] = 0; - for (j = 0; j < MAXOBSBUF; j++) svr->obs[i][j].n = 0; + for (j = 0; j < 10; j++) + { + svr->nmsg[i][j] = 0; + } + for (j = 0; j < MAXOBSBUF; j++) + { + svr->obs[i][j].n = 0; + } /* initialize receiver raw and rtcm control */ //init_raw (svr->raw +i); init_rtcm(svr->rtcm + i); /* set receiver and rtcm option */ - if (strlen(rcvopts[i]) < 256) strcpy(svr->raw[i].opt, rcvopts[i]); - if (strlen(rcvopts[i]) < 256) strcpy(svr->rtcm[i].opt, rcvopts[i]); + if (strlen(rcvopts[i]) < 256) + { + strcpy(svr->raw[i].opt, rcvopts[i]); + } + if (strlen(rcvopts[i]) < 256) + { + strcpy(svr->rtcm[i].opt, rcvopts[i]); + } /* connect dgps corrections */ svr->rtcm[i].dgps = svr->nav.dgps; @@ -800,9 +937,18 @@ int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs, svr->rtk.rb[i] = i < 3 ? prcopt->rb[i] : 0.0; } /* update navigation data */ - for (i = 0; i < MAXSAT * 2; i++) svr->nav.eph[i].ttr = time0; - for (i = 0; i < NSATGLO * 2; i++) svr->nav.geph[i].tof = time0; - for (i = 0; i < NSATSBS * 2; i++) svr->nav.seph[i].tof = time0; + for (i = 0; i < MAXSAT * 2; i++) + { + svr->nav.eph[i].ttr = time0; + } + for (i = 0; i < NSATGLO * 2; i++) + { + svr->nav.geph[i].tof = time0; + } + for (i = 0; i < NSATSBS * 2; i++) + { + svr->nav.seph[i].tof = time0; + } updatenav(&svr->nav); /* set monitor stream */ @@ -812,10 +958,16 @@ int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs, for (i = 0; i < 8; i++) { rw = i < 3 ? STR_MODE_R : STR_MODE_W; - if (strs[i] != STR_FILE) rw |= STR_MODE_W; + if (strs[i] != STR_FILE) + { + rw |= STR_MODE_W; + } if (!stropen(svr->stream + i, strs[i], rw, paths[i])) { - for (i--; i >= 0; i--) strclose(svr->stream + i); + for (i--; i >= 0; i--) + { + strclose(svr->stream + i); + } return 0; } /* set initial time for rtcm and raw */ @@ -833,7 +985,10 @@ int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs, /* write start commands to input streams */ for (i = 0; i < 3; i++) { - if (cmds[i]) strsendcmd(svr->stream + i, cmds[i]); + if (cmds[i]) + { + strsendcmd(svr->stream + i, cmds[i]); + } } /* write solution header to solution streams */ for (i = 3; i < 5; i++) @@ -843,7 +998,10 @@ int rtksvrstart(rtksvr_t *svr, int cycle, int buffsize, int *strs, /* create rtk server thread */ if (pthread_create(&svr->thread, nullptr, rtksvrthread, svr)) { - for (i = 0; i < MAXSTRRTK; i++) strclose(svr->stream + i); + for (i = 0; i < MAXSTRRTK; i++) + { + strclose(svr->stream + i); + } return 0; } return 1; @@ -869,7 +1027,10 @@ void rtksvrstop(rtksvr_t *svr, char **cmds) rtksvrlock(svr); for (i = 0; i < 3; i++) { - if (cmds[i]) strsendcmd(svr->stream + i, cmds[i]); + if (cmds[i]) + { + strsendcmd(svr->stream + i, cmds[i]); + } } rtksvrunlock(svr); @@ -897,7 +1058,10 @@ int rtksvropenstr(rtksvr_t *svr, int index, int str, const char *path, { tracet(3, "rtksvropenstr: index=%d str=%d path=%s\n", index, str, path); - if (index < 3 || index > 7 || !svr->state) return 0; + if (index < 3 || index > 7 || !svr->state) + { + return 0; + } rtksvrlock(svr); @@ -936,7 +1100,10 @@ void rtksvrclosestr(rtksvr_t *svr, int index) { tracet(3, "rtksvrclosestr: index=%d\n", index); - if (index < 3 || index > 7 || !svr->state) return; + if (index < 3 || index > 7 || !svr->state) + { + return; + } rtksvrlock(svr); @@ -966,7 +1133,10 @@ int rtksvrostat(rtksvr_t *svr, int rcv, gtime_t *time, int *sat, tracet(4, "rtksvrostat: rcv=%d\n", rcv); - if (!svr->state) return 0; + if (!svr->state) + { + return 0; + } rtksvrlock(svr); ns = svr->obs[rcv][0].n; if (ns > 0) @@ -1014,7 +1184,10 @@ void rtksvrsstat(rtksvr_t *svr, int *sstat, char *msg) for (i = 0; i < MAXSTRRTK; i++) { sstat[i] = strstat(svr->stream + i, s); - if (*s) p += sprintf(p, "(%d) %s ", i + 1, s); + if (*s) + { + p += sprintf(p, "(%d) %s ", i + 1, s); + } } rtksvrunlock(svr); } diff --git a/src/algorithms/libs/rtklib/rtklib_sbas.cc b/src/algorithms/libs/rtklib/rtklib_sbas.cc index 9a780f3ac..4f63cb40a 100644 --- a/src/algorithms/libs/rtklib/rtklib_sbas.cc +++ b/src/algorithms/libs/rtklib/rtklib_sbas.cc @@ -67,7 +67,12 @@ char *getfield(char *p, int pos) { for (pos--; pos > 0; pos--, p++) - if (!(p = strchr(p, ','))) return nullptr; + { + if (!(p = strchr(p, ','))) + { + return nullptr; + } + } return p; } @@ -114,21 +119,37 @@ int decode_sbstype1(const sbsmsg_t *msg, sbssat_t *sbssat) if (getbitu(msg->msg, 13 + i, 1)) { if (i <= 37) - sat = satno(SYS_GPS, i); /* 0- 37: gps */ + { + sat = satno(SYS_GPS, i); /* 0- 37: gps */ + } else if (i <= 61) - sat = satno(SYS_GLO, i - 37); /* 38- 61: glonass */ + { + sat = satno(SYS_GLO, i - 37); /* 38- 61: glonass */ + } else if (i <= 119) - sat = 0; /* 62-119: future gnss */ + { + sat = 0; /* 62-119: future gnss */ + } else if (i <= 138) - sat = satno(SYS_SBS, i); /* 120-138: geo/waas */ + { + sat = satno(SYS_SBS, i); /* 120-138: geo/waas */ + } else if (i <= 182) - sat = 0; /* 139-182: reserved */ + { + sat = 0; /* 139-182: reserved */ + } else if (i <= 192) - sat = satno(SYS_SBS, i + 10); /* 183-192: qzss ref [2] */ + { + sat = satno(SYS_SBS, i + 10); /* 183-192: qzss ref [2] */ + } else if (i <= 202) - sat = satno(SYS_QZS, i); /* 193-202: qzss ref [2] */ + { + sat = satno(SYS_QZS, i); /* 193-202: qzss ref [2] */ + } else - sat = 0; /* 203- : reserved */ + { + sat = 0; /* 203- : reserved */ + } sbssat->sat[n++].sat = sat; } } @@ -149,14 +170,20 @@ int decode_sbstype2(const sbsmsg_t *msg, sbssat_t *sbssat) trace(4, "decode_sbstype2:\n"); - if (sbssat->iodp != static_cast(getbitu(msg->msg, 16, 2))) return 0; + if (sbssat->iodp != static_cast(getbitu(msg->msg, 16, 2))) + { + return 0; + } type = getbitu(msg->msg, 8, 6); iodf = getbitu(msg->msg, 14, 2); for (i = 0; i < 13; i++) { - if ((j = 13 * ((type == 0 ? 2 : type) - 2) + i) >= sbssat->nsat) break; + if ((j = 13 * ((type == 0 ? 2 : type) - 2) + i) >= sbssat->nsat) + { + break; + } udre = getbitu(msg->msg, 174 + 4 * i, 4); t0 = sbssat->sat[j].fcorr.t0; prc = sbssat->sat[j].fcorr.prc; @@ -194,7 +221,10 @@ int decode_sbstype6(const sbsmsg_t *msg, sbssat_t *sbssat) } for (i = 0; i < sbssat->nsat && i < MAXSAT; i++) { - if (sbssat->sat[i].fcorr.iodf != iodf[i / 28]) continue; + if (sbssat->sat[i].fcorr.iodf != iodf[i / 28]) + { + continue; + } udre = getbitu(msg->msg, 22 + i * 4, 4); sbssat->sat[i].fcorr.udre = udre + 1; } @@ -210,7 +240,10 @@ int decode_sbstype7(const sbsmsg_t *msg, sbssat_t *sbssat) trace(4, "decode_sbstype7\n"); - if (sbssat->iodp != static_cast(getbitu(msg->msg, 18, 2))) return 0; + if (sbssat->iodp != static_cast(getbitu(msg->msg, 18, 2))) + { + return 0; + } sbssat->tlat = getbitu(msg->msg, 14, 4); @@ -237,9 +270,13 @@ int decode_sbstype9(const sbsmsg_t *msg, nav_t *nav) } t = static_cast(getbitu(msg->msg, 22, 13)) * 16 - msg->tow % 86400; if (t <= -43200) - t += 86400; + { + t += 86400; + } else if (t > 43200) - t -= 86400; + { + t -= 86400; + } seph.sat = sat; seph.t0 = gpst2time(msg->week, msg->tow + t); seph.tof = gpst2time(msg->week, msg->tow); @@ -291,16 +328,24 @@ int decode_sbstype18(const sbsmsg_t *msg, sbsion_t *sbsion) m = 5; } else - return 0; + { + return 0; + } sbsion[band].iodi = static_cast(getbitu(msg->msg, 22, 2)); for (i = 1, n = 0; i <= 201; i++) { - if (!getbitu(msg->msg, 23 + i, 1)) continue; + if (!getbitu(msg->msg, 23 + i, 1)) + { + continue; + } for (j = 0; j < m; j++) { - if (i < p[j].bits || p[j].bite < i) continue; + if (i < p[j].bits || p[j].bite < i) + { + continue; + } sbsion[band].igp[n].lat = band <= 8 ? p[j].y[i - p[j].bits] : p[j].x; sbsion[band].igp[n++].lon = band <= 8 ? p[j].x : p[j].y[i - p[j].bits]; break; @@ -320,7 +365,10 @@ int decode_longcorr0(const sbsmsg_t *msg, int p, sbssat_t *sbssat) trace(4, "decode_longcorr0:\n"); - if (n == 0 || n > MAXSAT) return 0; + if (n == 0 || n > MAXSAT) + { + return 0; + } sbssat->sat[n - 1].lcorr.iode = getbitu(msg->msg, p + 6, 8); @@ -345,7 +393,10 @@ int decode_longcorr1(const sbsmsg_t *msg, int p, sbssat_t *sbssat) trace(4, "decode_longcorr1:\n"); - if (n == 0 || n > MAXSAT) return 0; + if (n == 0 || n > MAXSAT) + { + return 0; + } sbssat->sat[n - 1].lcorr.iode = getbitu(msg->msg, p + 6, 8); @@ -358,9 +409,13 @@ int decode_longcorr1(const sbsmsg_t *msg, int p, sbssat_t *sbssat) sbssat->sat[n - 1].lcorr.daf1 = getbits(msg->msg, p + 82, 8) * TWO_N39; t = static_cast(getbitu(msg->msg, p + 90, 13)) * 16 - msg->tow % 86400; if (t <= -43200) - t += 86400; + { + t += 86400; + } else if (t > 43200) - t -= 86400; + { + t -= 86400; + } sbssat->sat[n - 1].lcorr.t0 = gpst2time(msg->week, msg->tow + t); trace(5, "decode_longcorr1: sat=%2d\n", sbssat->sat[n - 1].sat); @@ -396,14 +451,20 @@ int decode_sbstype24(const sbsmsg_t *msg, sbssat_t *sbssat) trace(4, "decode_sbstype24:\n"); - if (sbssat->iodp != static_cast(getbitu(msg->msg, 110, 2))) return 0; /* check IODP */ + if (sbssat->iodp != static_cast(getbitu(msg->msg, 110, 2))) + { + return 0; /* check IODP */ + } blk = getbitu(msg->msg, 112, 2); iodf = getbitu(msg->msg, 114, 2); for (i = 0; i < 6; i++) { - if ((j = 13 * blk + i) >= sbssat->nsat) break; + if ((j = 13 * blk + i) >= sbssat->nsat) + { + break; + } udre = getbitu(msg->msg, 86 + 4 * i, 4); sbssat->sat[j].fcorr.t0 = gpst2time(msg->week, msg->tow); @@ -431,13 +492,19 @@ int decode_sbstype26(const sbsmsg_t *msg, sbsion_t *sbsion) trace(4, "decode_sbstype26:\n"); - if (band > MAXBAND || sbsion[band].iodi != static_cast(getbitu(msg->msg, 217, 2))) return 0; + if (band > MAXBAND || sbsion[band].iodi != static_cast(getbitu(msg->msg, 217, 2))) + { + return 0; + } block = getbitu(msg->msg, 18, 4); for (i = 0; i < 15; i++) { - if ((j = block * 15 + i) >= sbsion[band].nigp) continue; + if ((j = block * 15 + i) >= sbsion[band].nigp) + { + continue; + } give = getbitu(msg->msg, 22 + i * 13 + 9, 4); delay = getbitu(msg->msg, 22 + i * 13, 9); @@ -470,7 +537,10 @@ int sbsupdatecorr(const sbsmsg_t *msg, nav_t *nav) trace(3, "sbsupdatecorr: type=%d\n", type); - if (msg->week == 0) return -1; + if (msg->week == 0) + { + return -1; + } switch (type) { @@ -551,27 +621,62 @@ void readmsgs(const char *file, int sel, gtime_t ts, gtime_t te, } else if (!strncmp(buff, "#RAWWAASFRAMEA", 14)) { /* NovAtel OEM4/V */ - if (!(p = getfield(buff, 6))) continue; - if (sscanf(p, "%d,%lf", &week, &tow) < 2) continue; - if (!(p = strchr(++p, ';'))) continue; - if (sscanf(++p, "%d,%d", &ch, &prn) < 2) continue; - if (!(p = getfield(p, 4))) continue; + if (!(p = getfield(buff, 6))) + { + continue; + } + if (sscanf(p, "%d,%lf", &week, &tow) < 2) + { + continue; + } + if (!(p = strchr(++p, ';'))) + { + continue; + } + if (sscanf(++p, "%d,%d", &ch, &prn) < 2) + { + continue; + } + if (!(p = getfield(p, 4))) + { + continue; + } } else if (!strncmp(buff, "$FRMA", 5)) { /* NovAtel OEM3 */ - if (!(p = getfield(buff, 2))) continue; - if (sscanf(p, "%d,%lf,%d", &week, &tow, &prn) < 3) continue; - if (!(p = getfield(p, 6))) continue; - if (week < WEEKOFFSET) week += WEEKOFFSET; + if (!(p = getfield(buff, 2))) + { + continue; + } + if (sscanf(p, "%d,%lf,%d", &week, &tow, &prn) < 3) + { + continue; + } + if (!(p = getfield(p, 6))) + { + continue; + } + if (week < WEEKOFFSET) + { + week += WEEKOFFSET; + } } else - continue; + { + continue; + } - if (sel != 0 && sel != prn) continue; + if (sel != 0 && sel != prn) + { + continue; + } time = gpst2time(week, tow); - if (!screent(time, ts, te, 0.0)) continue; + if (!screent(time, ts, te, 0.0)) + { + continue; + } if (sbs->n >= sbs->nmax) { @@ -590,10 +695,16 @@ void readmsgs(const char *file, int sel, gtime_t ts, gtime_t te, sbs->msgs[sbs->n].week = week; sbs->msgs[sbs->n].tow = static_cast(tow + 0.5); sbs->msgs[sbs->n].prn = prn; - for (i = 0; i < 29; i++) sbs->msgs[sbs->n].msg[i] = 0; + for (i = 0; i < 29; i++) + { + sbs->msgs[sbs->n].msg[i] = 0; + } for (i = 0; *(p - 1) && *p && i < 29; p += 2, i++) { - if (sscanf(p, "%2X", &b) == 1) sbs->msgs[sbs->n].msg[i] = static_cast(b); + if (sscanf(p, "%2X", &b) == 1) + { + sbs->msgs[sbs->n].msg[i] = static_cast(b); + } } sbs->msgs[sbs->n++].msg[28] &= 0xC0; } @@ -636,7 +747,10 @@ int sbsreadmsgt(const char *file, int sel, gtime_t ts, gtime_t te, { if (!(efiles[i] = static_cast(malloc(1024)))) { - for (i--; i >= 0; i--) free(efiles[i]); + for (i--; i >= 0; i--) + { + free(efiles[i]); + } return 0; } } @@ -645,13 +759,22 @@ int sbsreadmsgt(const char *file, int sel, gtime_t ts, gtime_t te, for (i = 0; i < n; i++) { - if (!(ext = strrchr(efiles[i], '.'))) continue; + if (!(ext = strrchr(efiles[i], '.'))) + { + continue; + } if (strcmp(ext, ".sbs") != 0 && strcmp(ext, ".SBS") != 0 && - strcmp(ext, ".ems") != 0 && strcmp(ext, ".EMS") != 0) continue; + strcmp(ext, ".ems") != 0 && strcmp(ext, ".EMS") != 0) + { + continue; + } readmsgs(efiles[i], sel, ts, te, sbs); } - for (i = 0; i < MAXEXFILE; i++) free(efiles[i]); + for (i = 0; i < MAXEXFILE; i++) + { + free(efiles[i]); + } /* sort messages */ if (sbs->n > 0) @@ -685,7 +808,10 @@ void sbsoutmsg(FILE *fp, sbsmsg_t *sbsmsg) trace(4, "sbsoutmsg:\n"); fprintf(fp, "%4d %6d %3d %2d : ", sbsmsg->week, sbsmsg->tow, sbsmsg->prn, type); - for (i = 0; i < 29; i++) fprintf(fp, "%02X", sbsmsg->msg[i]); + for (i = 0; i < 29; i++) + { + fprintf(fp, "%02X", sbsmsg->msg[i]); + } fprintf(fp, "\n"); } @@ -700,7 +826,10 @@ void searchigp(gtime_t time __attribute__((unused)), const double *pos, const sb trace(4, "searchigp: pos=%.3f %.3f\n", pos[0] * R2D, pos[1] * R2D); - if (lon >= 180.0) lon -= 360.0; + if (lon >= 180.0) + { + lon -= 360.0; + } if (-55.0 <= lat && lat < 55.0) { latp[0] = static_cast(floor(lat / 5.0)) * 5; @@ -730,29 +859,54 @@ void searchigp(gtime_t time __attribute__((unused)), const double *pos, const sb } else if (lat >= 85.0) { - for (i = 0; i < 4; i++) lonp[i] = static_cast(floor(lon / 90.0)) * 90; + for (i = 0; i < 4; i++) + { + lonp[i] = static_cast(floor(lon / 90.0)) * 90; + } } else if (lat < -85.0) { - for (i = 0; i < 4; i++) lonp[i] = static_cast(floor((lon - 50.0) / 90.0)) * 90 + 40; + for (i = 0; i < 4; i++) + { + lonp[i] = static_cast(floor((lon - 50.0) / 90.0)) * 90 + 40; + } } } for (i = 0; i < 4; i++) - if (lonp[i] == 180) lonp[i] = -180; + { + if (lonp[i] == 180) + { + lonp[i] = -180; + } + } for (i = 0; i <= MAXBAND; i++) { for (p = ion[i].igp; p < ion[i].igp + ion[i].nigp; p++) { - if (p->t0.time == 0) continue; + if (p->t0.time == 0) + { + continue; + } if (p->lat == latp[0] && p->lon == lonp[0] && p->give > 0) - igp[0] = p; + { + igp[0] = p; + } else if (p->lat == latp[1] && p->lon == lonp[1] && p->give > 0) - igp[1] = p; + { + igp[1] = p; + } else if (p->lat == latp[0] && p->lon == lonp[2] && p->give > 0) - igp[2] = p; + { + igp[2] = p; + } else if (p->lat == latp[1] && p->lon == lonp[3] && p->give > 0) - igp[3] = p; - if (igp[0] && igp[1] && igp[2] && igp[3]) return; + { + igp[3] = p; + } + if (igp[0] && igp[1] && igp[2] && igp[3]) + { + return; + } } } } @@ -783,7 +937,10 @@ int sbsioncorr(gtime_t time, const nav_t *nav, const double *pos, azel[0] * R2D, azel[1] * R2D); *delay = *var = 0.0; - if (pos[2] < -100.0 || azel[1] <= 0) return 1; + if (pos[2] < -100.0 || azel[1] <= 0) + { + return 1; + } /* ipp (ionospheric pierce point) position */ fp = ionppp(pos, azel, re, hion, posp); @@ -803,28 +960,42 @@ int sbsioncorr(gtime_t time, const nav_t *nav, const double *pos, { w[1] = y; w[2] = x; - if ((w[0] = 1.0 - w[1] - w[2]) < 0.0) err = 1; + if ((w[0] = 1.0 - w[1] - w[2]) < 0.0) + { + err = 1; + } } else if (igp[0] && igp[2] && igp[3]) { w[0] = 1.0 - x; w[3] = y; - if ((w[2] = 1.0 - w[0] - w[3]) < 0.0) err = 1; + if ((w[2] = 1.0 - w[0] - w[3]) < 0.0) + { + err = 1; + } } else if (igp[0] && igp[1] && igp[3]) { w[0] = 1.0 - y; w[3] = x; - if ((w[1] = 1.0 - w[0] - w[3]) < 0.0) err = 1; + if ((w[1] = 1.0 - w[0] - w[3]) < 0.0) + { + err = 1; + } } else if (igp[1] && igp[2] && igp[3]) { w[1] = 1.0 - x; w[2] = 1.0 - y; - if ((w[3] = 1.0 - w[1] - w[2]) < 0.0) err = 1; + if ((w[3] = 1.0 - w[1] - w[2]) < 0.0) + { + err = 1; + } } else - err = 1; + { + err = 1; + } if (err) { @@ -834,7 +1005,10 @@ int sbsioncorr(gtime_t time, const nav_t *nav, const double *pos, } for (i = 0; i < 4; i++) { - if (!igp[i]) continue; + if (!igp[i]) + { + continue; + } t = timediff(time, igp[i]->t0); *delay += w[i] * igp[i]->delay; *var += w[i] * varicorr(igp[i]->give) * 9e-8 * fabs(t); @@ -860,14 +1034,27 @@ void getmet(double lat, double *met) double a; lat = fabs(lat); if (lat <= 15.0) - for (i = 0; i < 10; i++) met[i] = metprm[0][i]; + { + for (i = 0; i < 10; i++) + { + met[i] = metprm[0][i]; + } + } else if (lat >= 75.0) - for (i = 0; i < 10; i++) met[i] = metprm[4][i]; + { + for (i = 0; i < 10; i++) + { + met[i] = metprm[4][i]; + } + } else { j = static_cast(lat / 15.0); a = (lat - j * 15.0) / 15.0; - for (i = 0; i < 10; i++) met[i] = (1.0 - a) * metprm[j - 1][i] + a * metprm[j][i]; + for (i = 0; i < 10; i++) + { + met[i] = (1.0 - a) * metprm[j - 1][i] + a * metprm[j][i]; + } } } @@ -901,12 +1088,18 @@ double sbstropcorr(gtime_t time, const double *pos, const double *azel, { getmet(pos[0] * R2D, met); c = cos(2.0 * PI * (time2doy(time) - (pos[0] >= 0.0 ? 28.0 : 211.0)) / 365.25); - for (i = 0; i < 5; i++) met[i] -= met[i + 5] * c; + for (i = 0; i < 5; i++) + { + met[i] -= met[i + 5] * c; + } zh = 1e-6 * k1 * rd * met[0] / gm; zw = 1e-6 * k2 * rd / (gm * (met[4] + 1.0) - met[3] * rd) * met[2] / met[1]; zh *= pow(1.0 - met[3] * h / met[1], g / (rd * met[3])); zw *= pow(1.0 - met[3] * h / met[1], (met[4] + 1.0) * g / (rd * met[3]) - 1.0); - for (i = 0; i < 3; i++) pos_[i] = pos[i]; + for (i = 0; i < 3; i++) + { + pos_[i] = pos[i]; + } } m = 1.001 / sqrt(0.002001 + sinel * sinel); *var = 0.12 * 0.12 * m * m; @@ -926,7 +1119,10 @@ int sbslongcorr(gtime_t time, int sat, const sbssat_t *sbssat, for (p = sbssat->sat; p < sbssat->sat + sbssat->nsat; p++) { - if (p->sat != sat || p->lcorr.t0.time == 0) continue; + if (p->sat != sat || p->lcorr.t0.time == 0) + { + continue; + } t = timediff(time, p->lcorr.t0); if (fabs(t) > MAXSBSAGEL) { @@ -934,7 +1130,10 @@ int sbslongcorr(gtime_t time, int sat, const sbssat_t *sbssat, time_str(time, 0), sat, t); return 0; } - for (i = 0; i < 3; i++) drs[i] = p->lcorr.dpos[i] + p->lcorr.dvel[i] * t; + for (i = 0; i < 3; i++) + { + drs[i] = p->lcorr.dpos[i] + p->lcorr.dvel[i] * t; + } *ddts = p->lcorr.daf0 + p->lcorr.daf1 * t; trace(5, "sbslongcorr: sat=%2d drs=%7.2f%7.2f%7.2f ddts=%7.2f\n", @@ -943,7 +1142,10 @@ int sbslongcorr(gtime_t time, int sat, const sbssat_t *sbssat, return 1; } /* if sbas satellite without correction, no correction applied */ - if (satsys(sat, nullptr) == SYS_SBS) return 1; + if (satsys(sat, nullptr) == SYS_SBS) + { + return 1; + } trace(2, "no sbas long-term correction: %s sat=%2d\n", time_str(time, 0), sat); return 0; @@ -961,12 +1163,21 @@ int sbsfastcorr(gtime_t time, int sat, const sbssat_t *sbssat, for (p = sbssat->sat; p < sbssat->sat + sbssat->nsat; p++) { - if (p->sat != sat) continue; - if (p->fcorr.t0.time == 0) break; + if (p->sat != sat) + { + continue; + } + if (p->fcorr.t0.time == 0) + { + break; + } t = timediff(time, p->fcorr.t0) + sbssat->tlat; /* expire age of correction or UDRE==14 (not monitored) */ - if (fabs(t) > MAXSBSAGEF || p->fcorr.udre >= 15) continue; + if (fabs(t) > MAXSBSAGEF || p->fcorr.udre >= 15) + { + continue; + } *prc = p->fcorr.prc; #ifdef RRCENA if (p->fcorr.ai > 0 && fabs(t) <= 8.0 * p->fcorr.dt) @@ -1020,7 +1231,10 @@ int sbssatcorr(gtime_t time, int sat, const nav_t *nav, double *rs, { return 0; } - for (i = 0; i < 3; i++) rs[i] += drs[i]; + for (i = 0; i < 3; i++) + { + rs[i] += drs[i]; + } dts[0] += dclk + prc / SPEED_OF_LIGHT; @@ -1048,17 +1262,25 @@ int sbsdecodemsg(gtime_t time, int prn, const unsigned int *words, trace(5, "sbsdecodemsg: prn=%d\n", prn); - if (time.time == 0) return 0; + if (time.time == 0) + { + return 0; + } tow = time2gpst(time, &sbsmsg->week); sbsmsg->tow = static_cast(tow + DTTOL); sbsmsg->prn = prn; for (i = 0; i < 7; i++) - for (j = 0; j < 4; j++) - { - sbsmsg->msg[i * 4 + j] = static_cast(words[i] >> ((3 - j) * 8)); - } + { + for (j = 0; j < 4; j++) + { + sbsmsg->msg[i * 4 + j] = static_cast(words[i] >> ((3 - j) * 8)); + } + } sbsmsg->msg[28] = static_cast(words[7] >> 18) & 0xC0; - for (i = 28; i > 0; i--) f[i] = (sbsmsg->msg[i] >> 6) + (sbsmsg->msg[i - 1] << 2); + for (i = 28; i > 0; i--) + { + f[i] = (sbsmsg->msg[i] >> 6) + (sbsmsg->msg[i - 1] << 2); + } f[0] = sbsmsg->msg[0] >> 6; return rtk_crc24q(f, 29) == (words[7] & 0xFFFFFF); /* check crc */ diff --git a/src/algorithms/libs/rtklib/rtklib_solution.cc b/src/algorithms/libs/rtklib/rtklib_solution.cc index 965166b01..96ba51b1e 100644 --- a/src/algorithms/libs/rtklib/rtklib_solution.cc +++ b/src/algorithms/libs/rtklib/rtklib_solution.cc @@ -79,9 +79,13 @@ static const int solq_nmea[] = {/* nmea quality flags to rtklib sol quality */ const char *opt2sep(const solopt_t *opt) { if (!*opt->sep) - return " "; + { + return " "; + } if (!strcmp(opt->sep, "\\t")) - return "\t"; + { + return "\t"; + } return opt->sep; } @@ -94,9 +98,18 @@ int tonum(char *buff, const char *sep, double *v) for (p = buff, n = 0; n < MAXFIELD; p = q + len) { - if ((q = strstr(p, sep))) *q = '\0'; - if (*p) v[n++] = atof(p); - if (!q) break; + if ((q = strstr(p, sep))) + { + *q = '\0'; + } + if (*p) + { + v[n++] = atof(p); + } + if (!q) + { + break; + } } return n; } @@ -301,11 +314,17 @@ int decode_nmeagga(char **val, int n, sol_t *sol) time = utc2gpst(epoch2time(ep)); tt = timediff(time, sol->time); if (tt < -43200.0) - sol->time = timeadd(time, 86400.0); + { + sol->time = timeadd(time, 86400.0); + } else if (tt > 43200.0) - sol->time = timeadd(time, -86400.0); + { + sol->time = timeadd(time, -86400.0); + } else - sol->time = time; + { + sol->time = time; + } pos2ecef(pos, sol->rr); sol->stat = 0 <= solq && solq <= 8 ? solq_nmea[solq] : SOLQ_NONE; sol->ns = nrcv; @@ -337,7 +356,9 @@ int decode_nmea(char *buff, sol_t *sol) *q = '\0'; } else - break; + { + break; + } } /* decode nmea sentence */ if (!strcmp(val[0], "$GPRMC")) @@ -362,9 +383,13 @@ char *decode_soltime(char *buff, const solopt_t *opt, gtime_t *time) trace(4, "decode_soltime:\n"); if (!strcmp(opt->sep, "\\t")) - strcpy(s, "\t"); + { + strcpy(s, "\t"); + } else if (*opt->sep) - strcpy(s, opt->sep); + { + strcpy(s, opt->sep); + } len = static_cast(strlen(s)); /* yyyy/mm/dd hh:mm:ss or yyyy mm dd hh:mm:ss */ @@ -383,8 +408,14 @@ char *decode_soltime(char *buff, const solopt_t *opt, gtime_t *time) { *time = utc2gpst(timeadd(*time, -9 * 3600.0)); } - if (!(p = strchr(buff, ':')) || !(p = strchr(p + 1, ':'))) return nullptr; - for (p++; isdigit(static_cast(*p)) || *p == '.';) p++; + if (!(p = strchr(buff, ':')) || !(p = strchr(p + 1, ':'))) + { + return nullptr; + } + for (p++; isdigit(static_cast(*p)) || *p == '.';) + { + p++; + } return p + len; } if (opt->posf == SOLF_GSIF) @@ -394,16 +425,31 @@ char *decode_soltime(char *buff, const solopt_t *opt, gtime_t *time) return nullptr; } *time = timeadd(epoch2time(v), -12.0 * 3600.0); - if (!(p = strchr(buff, ':')) || !(p = strchr(p + 1, ':'))) return nullptr; - for (p++; isdigit(static_cast(*p)) || *p == '.';) p++; + if (!(p = strchr(buff, ':')) || !(p = strchr(p + 1, ':'))) + { + return nullptr; + } + for (p++; isdigit(static_cast(*p)) || *p == '.';) + { + p++; + } return p + len; } /* wwww ssss */ for (p = buff, n = 0; n < 2; p = q + len) { - if ((q = strstr(p, s))) *q = '\0'; - if (*p) v[n++] = atof(p); - if (!q) break; + if ((q = strstr(p, s))) + { + *q = '\0'; + } + if (*p) + { + v[n++] = atof(p); + } + if (!q) + { + break; + } } if (n >= 2 && 0.0 <= v[0] && v[0] <= 3000.0 && 0.0 <= v[1] && v[1] < 604800.0) { @@ -423,14 +469,23 @@ int decode_solxyz(char *buff, const solopt_t *opt, sol_t *sol) trace(4, "decode_solxyz:\n"); - if ((n = tonum(buff, sep, val)) < 3) return 0; + if ((n = tonum(buff, sep, val)) < 3) + { + return 0; + } for (j = 0; j < 3; j++) { sol->rr[j] = val[i++]; /* xyz */ } - if (i < n) sol->stat = static_cast(val[i++]); - if (i < n) sol->ns = static_cast(val[i++]); + if (i < n) + { + sol->stat = static_cast(val[i++]); + } + if (i < n) + { + sol->ns = static_cast(val[i++]); + } if (i + 3 < n) { P[0] = val[i] * val[i]; @@ -450,12 +505,21 @@ int decode_solxyz(char *buff, const solopt_t *opt, sol_t *sol) } covtosol(P, sol); } - if (i < n) sol->age = static_cast(val[i++]); - if (i < n) sol->ratio = static_cast(val[i]); + if (i < n) + { + sol->age = static_cast(val[i++]); + } + if (i < n) + { + sol->ratio = static_cast(val[i]); + } sol->type = 0; /* position type = xyz */ - if (MAXSOLQ < sol->stat) sol->stat = SOLQ_NONE; + if (MAXSOLQ < sol->stat) + { + sol->stat = SOLQ_NONE; + } return 1; } @@ -473,22 +537,34 @@ int decode_solllh(char *buff, const solopt_t *opt, sol_t *sol) if (!opt->degf) { - if (n < 3) return 0; + if (n < 3) + { + return 0; + } pos[0] = val[i++] * D2R; /* lat/lon/hgt (ddd.ddd) */ pos[1] = val[i++] * D2R; pos[2] = val[i++]; } else { - if (n < 7) return 0; + if (n < 7) + { + return 0; + } pos[0] = dms2deg(val) * D2R; /* lat/lon/hgt (ddd mm ss) */ pos[1] = dms2deg(val + 3) * D2R; pos[2] = val[6]; i += 7; } pos2ecef(pos, sol->rr); - if (i < n) sol->stat = static_cast(val[i++]); - if (i < n) sol->ns = static_cast(val[i++]); + if (i < n) + { + sol->stat = static_cast(val[i++]); + } + if (i < n) + { + sol->ns = static_cast(val[i++]); + } if (i + 3 < n) { Q[4] = val[i] * val[i]; @@ -509,12 +585,21 @@ int decode_solllh(char *buff, const solopt_t *opt, sol_t *sol) covecef(pos, Q, P); covtosol(P, sol); } - if (i < n) sol->age = static_cast(val[i++]); - if (i < n) sol->ratio = static_cast(val[i]); + if (i < n) + { + sol->age = static_cast(val[i++]); + } + if (i < n) + { + sol->ratio = static_cast(val[i]); + } sol->type = 0; /* position type = xyz */ - if (MAXSOLQ < sol->stat) sol->stat = SOLQ_NONE; + if (MAXSOLQ < sol->stat) + { + sol->stat = SOLQ_NONE; + } return 1; } @@ -528,14 +613,23 @@ int decode_solenu(char *buff, const solopt_t *opt, sol_t *sol) trace(4, "decode_solenu:\n"); - if ((n = tonum(buff, sep, val)) < 3) return 0; + if ((n = tonum(buff, sep, val)) < 3) + { + return 0; + } for (j = 0; j < 3; j++) { sol->rr[j] = val[i++]; /* enu */ } - if (i < n) sol->stat = static_cast(val[i++]); - if (i < n) sol->ns = static_cast(val[i++]); + if (i < n) + { + sol->stat = static_cast(val[i++]); + } + if (i < n) + { + sol->ns = static_cast(val[i++]); + } if (i + 3 < n) { Q[0] = val[i] * val[i]; @@ -555,12 +649,21 @@ int decode_solenu(char *buff, const solopt_t *opt, sol_t *sol) } covtosol(Q, sol); } - if (i < n) sol->age = static_cast(val[i++]); - if (i < n) sol->ratio = static_cast(val[i]); + if (i < n) + { + sol->age = static_cast(val[i++]); + } + if (i < n) + { + sol->ratio = static_cast(val[i]); + } sol->type = 1; /* position type = enu */ - if (MAXSOLQ < sol->stat) sol->stat = SOLQ_NONE; + if (MAXSOLQ < sol->stat) + { + sol->stat = SOLQ_NONE; + } return 1; } @@ -573,7 +676,10 @@ int decode_solgsi(char *buff, const solopt_t *opt __attribute((unused)), sol_t * trace(4, "decode_solgsi:\n"); - if (tonum(buff, " ", val) < 3) return 0; + if (tonum(buff, " ", val) < 3) + { + return 0; + } for (j = 0; j < 3; j++) { @@ -624,11 +730,17 @@ void decode_refpos(char *buff, const solopt_t *opt, double *rb) trace(3, "decode_refpos: buff=%s\n", buff); - if ((n = tonum(buff, sep, val)) < 3) return; + if ((n = tonum(buff, sep, val)) < 3) + { + return; + } if (opt->posf == SOLF_XYZ) { /* xyz */ - for (i = 0; i < 3; i++) rb[i] = val[i]; + for (i = 0; i < 3; i++) + { + rb[i] = val[i]; + } } else if (opt->degf == 0) { /* lat/lon/hgt (ddd.ddd) */ @@ -656,21 +768,36 @@ int decode_sol(char *buff, const solopt_t *opt, sol_t *sol, double *rb) if (!strncmp(buff, COMMENTH, 1)) { /* reference position */ - if (!strstr(buff, "ref pos") && !strstr(buff, "slave pos")) return 0; - if (!(p = strchr(buff, ':'))) return 0; + if (!strstr(buff, "ref pos") && !strstr(buff, "slave pos")) + { + return 0; + } + if (!(p = strchr(buff, ':'))) + { + return 0; + } decode_refpos(p + 1, opt, rb); return 0; } if (!strncmp(buff, "$GP", 3)) { /* decode nmea */ - if (!decode_nmea(buff, sol)) return 0; + if (!decode_nmea(buff, sol)) + { + return 0; + } /* for time update only */ - if (opt->posf != SOLF_NMEA && !strncmp(buff, "$GPRMC", 6)) return 2; + if (opt->posf != SOLF_NMEA && !strncmp(buff, "$GPRMC", 6)) + { + return 2; + } } else { /* decode position record */ - if (!decode_solpos(buff, opt, sol)) return 0; + if (!decode_solpos(buff, opt, sol)) + { + return 0; + } } return 1; } @@ -683,14 +810,23 @@ void decode_solopt(char *buff, solopt_t *opt) trace(4, "decode_solhead: buff=%s\n", buff); - if (strncmp(buff, COMMENTH, 1) != 0 && strncmp(buff, "+", 1) != 0) return; + if (strncmp(buff, COMMENTH, 1) != 0 && strncmp(buff, "+", 1) != 0) + { + return; + } if (strstr(buff, "GPST")) - opt->times = TIMES_GPST; + { + opt->times = TIMES_GPST; + } else if (strstr(buff, "UTC")) - opt->times = TIMES_UTC; + { + opt->times = TIMES_UTC; + } else if (strstr(buff, "JST")) - opt->times = TIMES_JST; + { + opt->times = TIMES_JST; + } if ((p = strstr(buff, "x-ecef(m)"))) { @@ -771,7 +907,10 @@ int inputsol(unsigned char data, gtime_t ts, gtime_t te, double tint, solbuf->nb = 0; } solbuf->buff[solbuf->nb++] = data; - if (data != '\n' && solbuf->nb < MAXSOLMSG) return 0; /* sync trailer */ + if (data != '\n' && solbuf->nb < MAXSOLMSG) + { + return 0; /* sync trailer */ + } solbuf->buff[solbuf->nb] = '\0'; solbuf->nb = 0; @@ -829,7 +968,10 @@ int sort_solbuf(solbuf_t *solbuf) trace(4, "sort_solbuf: n=%d\n", solbuf->n); - if (solbuf->n <= 0) return 0; + if (solbuf->n <= 0) + { + return 0; + } if (!(solbuf_data = static_cast(realloc(solbuf->data, sizeof(sol_t) * solbuf->n)))) { @@ -916,15 +1058,26 @@ int addsol(solbuf_t *solbuf, const sol_t *sol) if (solbuf->cyclic) { /* ring buffer */ - if (solbuf->nmax <= 1) return 0; + if (solbuf->nmax <= 1) + { + return 0; + } solbuf->data[solbuf->end] = *sol; - if (++solbuf->end >= solbuf->nmax) solbuf->end = 0; + if (++solbuf->end >= solbuf->nmax) + { + solbuf->end = 0; + } if (solbuf->start == solbuf->end) { - if (++solbuf->start >= solbuf->nmax) solbuf->start = 0; + if (++solbuf->start >= solbuf->nmax) + { + solbuf->start = 0; + } } else - solbuf->n++; + { + solbuf->n++; + } return 1; } @@ -957,7 +1110,10 @@ sol_t *getsol(solbuf_t *solbuf, int index) { trace(4, "getsol: index=%d\n", index); - if (index < 0 || solbuf->n <= index) return nullptr; + if (index < 0 || solbuf->n <= index) + { + return nullptr; + } if ((index = solbuf->start + index) >= solbuf->nmax) { index -= solbuf->nmax; @@ -985,7 +1141,10 @@ void initsolbuf(solbuf_t *solbuf, int cyclic, int nmax) solbuf->data = nullptr; if (cyclic) { - if (nmax <= 2) nmax = 2; + if (nmax <= 2) + { + nmax = 2; + } if (!(solbuf->data = static_cast(malloc(sizeof(sol_t) * nmax)))) { trace(1, "initsolbuf: memory allocation error\n"); @@ -1037,7 +1196,10 @@ int sort_solstat(solstatbuf_t *statbuf) trace(4, "sort_solstat: n=%d\n", statbuf->n); - if (statbuf->n <= 0) return 0; + if (statbuf->n <= 0) + { + return 0; + } if (!(statbuf_data = static_cast(realloc(statbuf->data, sizeof(solstat_t) * statbuf->n)))) { @@ -1064,10 +1226,18 @@ int decode_solstat(char *buff, solstat_t *stat) trace(4, "decode_solstat: buff=%s\n", buff); - if (strstr(buff, "$SAT") != buff) return 0; + if (strstr(buff, "$SAT") != buff) + { + return 0; + } for (p = buff; *p; p++) - if (*p == ',') *p = ' '; + { + if (*p == ',') + { + *p = ' '; + } + } n = sscanf(buff, "$SAT%d%lf%s%d%lf%lf%lf%lf%d%d%d%d%d%d%d%d", &week, &tow, id, &frq, &az, &el, &resp, &resc, &vsat, &snr, &fix, &slip, @@ -1138,7 +1308,10 @@ int readsolstatdata(FILE *fp, gtime_t ts, gtime_t te, double tint, while (fgets(buff, sizeof(buff), fp)) { /* decode solution status */ - if (!decode_solstat(buff, &stat)) continue; + if (!decode_solstat(buff, &stat)) + { + continue; + } /* add solution to solution buffer */ if (screent(stat.time, ts, te, tint)) @@ -1245,7 +1418,9 @@ int outpos(unsigned char *buff, const char *s, const sol_t *sol, dms2[2]); } else - p += sprintf(p, "%s%s%14.9f%s%14.9f", s, sep, pos[0] * R2D, sep, pos[1] * R2D); + { + p += sprintf(p, "%s%s%14.9f%s%14.9f", s, sep, pos[0] * R2D, sep, pos[1] * R2D); + } p += sprintf(p, "%s%10.4f%s%3d%s%3d%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%8.4f%s%6.2f%s%6.1f\n", sep, pos[2], sep, sol->stat, sep, sol->ns, sep, SQRT_SOL(Q[4]), sep, SQRT_SOL(Q[0]), sep, SQRT_SOL(Q[8]), sep, sqvar(Q[1]), sep, sqvar(Q[2]), @@ -1265,7 +1440,10 @@ int outenu(unsigned char *buff, const char *s, const sol_t *sol, trace(3, "outenu :\n"); - for (i = 0; i < 3; i++) rr[i] = sol->rr[i] - rb[i]; + for (i = 0; i < 3; i++) + { + rr[i] = sol->rr[i] - rb[i]; + } ecef2pos(rb, pos); soltocov(sol, P); covenu(pos, P, Q); @@ -1291,7 +1469,10 @@ int outnmea_rmc(unsigned char *buff, const sol_t *sol) if (sol->stat <= SOLQ_NONE) { p += sprintf(p, "$GPRMC,,,,,,,,,,,,"); - for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) sum ^= *q; + for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) + { + sum ^= *q; + } p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); return p - reinterpret_cast(buff); } @@ -1308,11 +1489,16 @@ int outnmea_rmc(unsigned char *buff, const sol_t *sol) if (vel >= 1.0) { dir = atan2(enuv[0], enuv[1]) * R2D; - if (dir < 0.0) dir += 360.0; + if (dir < 0.0) + { + dir += 360.0; + } dirp = dir; } else - dir = dirp; + { + dir = dirp; + } deg2dms(fabs(pos[0]) * R2D, dms1); deg2dms(fabs(pos[1]) * R2D, dms2); p += sprintf(p, "$GPRMC,%02.0f%02.0f%05.2f,A,%02.0f%010.7f,%s,%03.0f%010.7f,%s,%4.2f,%4.2f,%02.0f%02.0f%02d,%.1f,%s,%s", @@ -1320,7 +1506,10 @@ int outnmea_rmc(unsigned char *buff, const sol_t *sol) dms2[0], dms2[1] + dms2[2] / 60.0, pos[1] >= 0 ? "E" : "W", vel / KNOT2M, dir, ep[2], ep[1], static_cast(ep[0]) % 100, amag, emag, sol->stat == SOLQ_DGPS || sol->stat == SOLQ_FLOAT || sol->stat == SOLQ_FIX ? "D" : "A"); - for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */ + for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) + { + sum ^= *q; /* check-sum */ + } p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); return p - reinterpret_cast(buff); } @@ -1339,13 +1528,24 @@ int outnmea_gga(unsigned char *buff, const sol_t *sol) if (sol->stat <= SOLQ_NONE) { p += sprintf(p, "$GPGGA,,,,,,,,,,,,,,"); - for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) sum ^= *q; + for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) + { + sum ^= *q; + } p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); return p - reinterpret_cast(buff); } for (solq = 0; solq < 8; solq++) - if (solq_nmea[solq] == sol->stat) break; - if (solq >= 8) solq = 0; + { + if (solq_nmea[solq] == sol->stat) + { + break; + } + } + if (solq >= 8) + { + solq = 0; + } time = gpst2utc(sol->time); if (time.sec >= 0.995) { @@ -1361,7 +1561,10 @@ int outnmea_gga(unsigned char *buff, const sol_t *sol) ep[3], ep[4], ep[5], dms1[0], dms1[1] + dms1[2] / 60.0, pos[0] >= 0 ? "N" : "S", dms2[0], dms2[1] + dms2[2] / 60.0, pos[1] >= 0 ? "E" : "W", solq, sol->ns, dop, pos[2] - h, h, sol->age); - for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */ + for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) + { + sum ^= *q; /* check-sum */ + } p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); return p - reinterpret_cast(buff); } @@ -1380,7 +1583,10 @@ int outnmea_gsa(unsigned char *buff, const sol_t *sol, if (sol->stat <= SOLQ_NONE) { p += sprintf(p, "$GPGSA,A,1,,,,,,,,,,,,,,,"); - for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) sum ^= *q; + for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) + { + sum ^= *q; + } p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); return p - reinterpret_cast(buff); } @@ -1388,11 +1594,23 @@ int outnmea_gsa(unsigned char *buff, const sol_t *sol, /* GPGSA: gps/sbas */ for (sat = 1, nsat = 0; sat <= MAXSAT && nsat < 12; sat++) { - if (!ssat[sat - 1].vs || ssat[sat - 1].azel[1] <= 0.0) continue; + if (!ssat[sat - 1].vs || ssat[sat - 1].azel[1] <= 0.0) + { + continue; + } sys = satsys(sat, prn + nsat); - if (sys != SYS_GPS && sys != SYS_SBS) continue; - if (sys == SYS_SBS) prn[nsat] += 33 - MINPRNSBS; - for (i = 0; i < 2; i++) azel[i + nsat * 2] = ssat[sat - 1].azel[i]; + if (sys != SYS_GPS && sys != SYS_SBS) + { + continue; + } + if (sys == SYS_SBS) + { + prn[nsat] += 33 - MINPRNSBS; + } + for (i = 0; i < 2; i++) + { + azel[i + nsat * 2] = ssat[sat - 1].azel[i]; + } nsat++; } if (nsat > 0) @@ -1402,21 +1620,37 @@ int outnmea_gsa(unsigned char *buff, const sol_t *sol, for (i = 0; i < 12; i++) { if (i < nsat) - p += sprintf(p, ",%02d", prn[i]); + { + p += sprintf(p, ",%02d", prn[i]); + } else - p += sprintf(p, ","); + { + p += sprintf(p, ","); + } } dops(nsat, azel, 0.0, dop); p += sprintf(p, ",%3.1f,%3.1f,%3.1f,1", dop[1], dop[2], dop[3]); - for (q = s + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */ + for (q = s + 1, sum = 0; *q; q++) + { + sum ^= *q; /* check-sum */ + } p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); } /* GLGSA: glonass */ for (sat = 1, nsat = 0; sat <= MAXSAT && nsat < 12; sat++) { - if (!ssat[sat - 1].vs || ssat[sat - 1].azel[1] <= 0.0) continue; - if (satsys(sat, prn + nsat) != SYS_GLO) continue; - for (i = 0; i < 2; i++) azel[i + nsat * 2] = ssat[sat - 1].azel[i]; + if (!ssat[sat - 1].vs || ssat[sat - 1].azel[1] <= 0.0) + { + continue; + } + if (satsys(sat, prn + nsat) != SYS_GLO) + { + continue; + } + for (i = 0; i < 2; i++) + { + azel[i + nsat * 2] = ssat[sat - 1].azel[i]; + } nsat++; } if (nsat > 0) @@ -1426,21 +1660,37 @@ int outnmea_gsa(unsigned char *buff, const sol_t *sol, for (i = 0; i < 12; i++) { if (i < nsat) - p += sprintf(p, ",%02d", prn[i] + 64); + { + p += sprintf(p, ",%02d", prn[i] + 64); + } else - p += sprintf(p, ","); + { + p += sprintf(p, ","); + } } dops(nsat, azel, 0.0, dop); p += sprintf(p, ",%3.1f,%3.1f,%3.1f,2", dop[1], dop[2], dop[3]); - for (q = s + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */ + for (q = s + 1, sum = 0; *q; q++) + { + sum ^= *q; /* check-sum */ + } p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); } /* GAGSA: galileo */ for (sat = 1, nsat = 0; sat <= MAXSAT && nsat < 12; sat++) { - if (!ssat[sat - 1].vs || ssat[sat - 1].azel[1] <= 0.0) continue; - if (satsys(sat, prn + nsat) != SYS_GAL) continue; - for (i = 0; i < 2; i++) azel[i + nsat * 2] = ssat[sat - 1].azel[i]; + if (!ssat[sat - 1].vs || ssat[sat - 1].azel[1] <= 0.0) + { + continue; + } + if (satsys(sat, prn + nsat) != SYS_GAL) + { + continue; + } + for (i = 0; i < 2; i++) + { + azel[i + nsat * 2] = ssat[sat - 1].azel[i]; + } nsat++; } if (nsat > 0) @@ -1450,13 +1700,20 @@ int outnmea_gsa(unsigned char *buff, const sol_t *sol, for (i = 0; i < 12; i++) { if (i < nsat) - p += sprintf(p, ",%02d", prn[i]); + { + p += sprintf(p, ",%02d", prn[i]); + } else - p += sprintf(p, ","); + { + p += sprintf(p, ","); + } } dops(nsat, azel, 0.0, dop); p += sprintf(p, ",%3.1f,%3.1f,%3.1f,3", dop[1], dop[2], dop[3]); - for (q = s + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */ + for (q = s + 1, sum = 0; *q; q++) + { + sum ^= *q; /* check-sum */ + } p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); } return p - reinterpret_cast(buff); @@ -1476,7 +1733,10 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol, if (sol->stat <= SOLQ_NONE) { p += sprintf(p, "$GPGSV,1,1,0,,,,,,,,,,,,,,,,"); - for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) sum ^= *q; + for (q = reinterpret_cast(buff) + 1, sum = 0; *q; q++) + { + sum ^= *q; + } p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); return p - reinterpret_cast(buff); } @@ -1484,8 +1744,14 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol, for (sat = 1, n = 0; sat < MAXSAT && n < 12; sat++) { sys = satsys(sat, &prn); - if (sys != SYS_GPS && sys != SYS_SBS) continue; - if (ssat[sat - 1].vs && ssat[sat - 1].azel[1] > 0.0) sats[n++] = sat; + if (sys != SYS_GPS && sys != SYS_SBS) + { + continue; + } + if (ssat[sat - 1].vs && ssat[sat - 1].azel[1] > 0.0) + { + sats[n++] = sat; + } } nmsg = n <= 0 ? 0 : (n - 1) / 4 + 1; @@ -1498,25 +1764,42 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol, { if (k < n) { - if (satsys(sats[k], &prn) == SYS_SBS) prn += 33 - MINPRNSBS; + if (satsys(sats[k], &prn) == SYS_SBS) + { + prn += 33 - MINPRNSBS; + } az = ssat[sats[k] - 1].azel[0] * R2D; - if (az < 0.0) az += 360.0; + if (az < 0.0) + { + az += 360.0; + } el = ssat[sats[k] - 1].azel[1] * R2D; snr = ssat[sats[k] - 1].snr[0] * 0.25; p += sprintf(p, ",%02d,%02.0f,%03.0f,%02.0f", prn, el, az, snr); } else - p += sprintf(p, ",,,,"); + { + p += sprintf(p, ",,,,"); + } + } + p += sprintf(p, ",1"); /* L1C/A */ + for (q = s + 1, sum = 0; *q; q++) + { + sum ^= *q; /* check-sum */ } - p += sprintf(p, ",1"); /* L1C/A */ - for (q = s + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */ p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); } /* GLGSV: glonass */ for (sat = 1, n = 0; sat < MAXSAT && n < 12; sat++) { - if (satsys(sat, &prn) != SYS_GLO) continue; - if (ssat[sat - 1].vs && ssat[sat - 1].azel[1] > 0.0) sats[n++] = sat; + if (satsys(sat, &prn) != SYS_GLO) + { + continue; + } + if (ssat[sat - 1].vs && ssat[sat - 1].azel[1] > 0.0) + { + sats[n++] = sat; + } } nmsg = n <= 0 ? 0 : (n - 1) / 4 + 1; @@ -1532,23 +1815,37 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol, satsys(sats[k], &prn); prn += 64; /* 65-99 */ az = ssat[sats[k] - 1].azel[0] * R2D; - if (az < 0.0) az += 360.0; + if (az < 0.0) + { + az += 360.0; + } el = ssat[sats[k] - 1].azel[1] * R2D; snr = ssat[sats[k] - 1].snr[0] * 0.25; p += sprintf(p, ",%02d,%02.0f,%03.0f,%02.0f", prn, el, az, snr); } else - p += sprintf(p, ",,,,"); + { + p += sprintf(p, ",,,,"); + } + } + p += sprintf(p, ",1"); /* L1C/A */ + for (q = s + 1, sum = 0; *q; q++) + { + sum ^= *q; /* check-sum */ } - p += sprintf(p, ",1"); /* L1C/A */ - for (q = s + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */ p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); } /* GAGSV: galileo */ for (sat = 1, n = 0; sat < MAXSAT && n < 12; sat++) { - if (satsys(sat, &prn) != SYS_GAL) continue; - if (ssat[sat - 1].vs && ssat[sat - 1].azel[1] > 0.0) sats[n++] = sat; + if (satsys(sat, &prn) != SYS_GAL) + { + continue; + } + if (ssat[sat - 1].vs && ssat[sat - 1].azel[1] > 0.0) + { + sats[n++] = sat; + } } nmsg = n <= 0 ? 0 : (n - 1) / 4 + 1; @@ -1563,16 +1860,24 @@ int outnmea_gsv(unsigned char *buff, const sol_t *sol, { satsys(sats[k], &prn); /* 1-36 */ az = ssat[sats[k] - 1].azel[0] * R2D; - if (az < 0.0) az += 360.0; + if (az < 0.0) + { + az += 360.0; + } el = ssat[sats[k] - 1].azel[1] * R2D; snr = ssat[sats[k] - 1].snr[0] * 0.25; p += sprintf(p, ",%02d,%02.0f,%03.0f,%02.0f", prn, el, az, snr); } else - p += sprintf(p, ",,,,"); + { + p += sprintf(p, ",,,,"); + } + } + p += sprintf(p, ",7"); /* L1BC */ + for (q = s + 1, sum = 0; *q; q++) + { + sum ^= *q; /* check-sum */ } - p += sprintf(p, ",7"); /* L1BC */ - for (q = s + 1, sum = 0; *q; q++) sum ^= *q; /* check-sum */ p += sprintf(p, "*%02X%c%c", sum, 0x0D, 0x0A); } return p - reinterpret_cast(buff); @@ -1633,7 +1938,10 @@ int outprcopts(unsigned char *buff, const prcopt_t *opt) p += sprintf(p, "%s navi sys :", COMMENTH); for (i = 0; sys[i]; i++) { - if (opt->navsys & sys[i]) p += sprintf(p, " %s", s7[i]); + if (opt->navsys & sys[i]) + { + p += sprintf(p, " %s", s7[i]); + } } p += sprintf(p, "\n"); } @@ -1656,7 +1964,10 @@ int outprcopts(unsigned char *buff, const prcopt_t *opt) } for (i = 0; i < 2; i++) { - if (opt->mode == PMODE_SINGLE || (i >= 1 && opt->mode > PMODE_FIXED)) continue; + if (opt->mode == PMODE_SINGLE || (i >= 1 && opt->mode > PMODE_FIXED)) + { + continue; + } p += sprintf(p, "%s antenna%d : %-21s (%7.4f %7.4f %7.4f)\n", COMMENTH, i + 1, opt->anttype[i], opt->antdel[i][0], opt->antdel[i][1], opt->antdel[i][2]); @@ -1680,17 +1991,26 @@ int outsolheads(unsigned char *buff, const solopt_t *opt) trace(3, "outsolheads:\n"); - if (opt->posf == SOLF_NMEA) return 0; + if (opt->posf == SOLF_NMEA) + { + return 0; + } if (opt->outhead) { p += sprintf(p, "%s (", COMMENTH); if (opt->posf == SOLF_XYZ) - p += sprintf(p, "x/y/z-ecef=WGS84"); + { + p += sprintf(p, "x/y/z-ecef=WGS84"); + } else if (opt->posf == SOLF_ENU) - p += sprintf(p, "e/n/u-baseline=WGS84"); + { + p += sprintf(p, "e/n/u-baseline=WGS84"); + } else - p += sprintf(p, "lat/lon/height=%s/%s", s1[opt->datum], s2[opt->height]); + { + p += sprintf(p, "lat/lon/height=%s/%s", s1[opt->datum], s2[opt->height]); + } p += sprintf(p, ",Q=1:fix,2:float,3:sbas,4:dgps,5:single,6:ppp,ns=# of satellites)\n"); } p += sprintf(p, "%s %-*s%s", COMMENTH, (opt->timef ? 16 : 8) + timeu + 1, s3[opt->times], sep); @@ -1752,8 +2072,14 @@ int outsols(unsigned char *buff, const sol_t *sol, const double *rb, if (opt->posf == SOLF_NMEA) { - if (opt->nmeaintv[0] < 0.0) return 0; - if (!screent(sol->time, ts, ts, opt->nmeaintv[0])) return 0; + if (opt->nmeaintv[0] < 0.0) + { + return 0; + } + if (!screent(sol->time, ts, ts, opt->nmeaintv[0])) + { + return 0; + } } if (sol->stat <= SOLQ_NONE || (opt->posf == SOLF_ENU && norm_rtk(rb, 3) <= 0.0)) { @@ -1762,11 +2088,19 @@ int outsols(unsigned char *buff, const sol_t *sol, const double *rb, timeu = opt->timeu < 0 ? 0 : (opt->timeu > 20 ? 20 : opt->timeu); time = sol->time; - if (opt->times >= TIMES_UTC) time = gpst2utc(time); - if (opt->times == TIMES_JST) time = timeadd(time, 9 * 3600.0); + if (opt->times >= TIMES_UTC) + { + time = gpst2utc(time); + } + if (opt->times == TIMES_JST) + { + time = timeadd(time, 9 * 3600.0); + } if (opt->timef) - time2str(time, s, timeu); + { + time2str(time, s, timeu); + } else { gpst = time2gpst(time, &week); @@ -1816,8 +2150,14 @@ int outsolexs(unsigned char *buff, const sol_t *sol, const ssat_t *ssat, if (opt->posf == SOLF_NMEA) { - if (opt->nmeaintv[1] < 0.0) return 0; - if (!screent(sol->time, ts, ts, opt->nmeaintv[1])) return 0; + if (opt->nmeaintv[1] < 0.0) + { + return 0; + } + if (!screent(sol->time, ts, ts, opt->nmeaintv[1])) + { + return 0; + } } if (opt->posf == SOLF_NMEA) { diff --git a/src/algorithms/libs/rtklib/rtklib_stream.cc b/src/algorithms/libs/rtklib/rtklib_stream.cc index 53635b2ea..48a1564e6 100644 --- a/src/algorithms/libs/rtklib/rtklib_stream.cc +++ b/src/algorithms/libs/rtklib/rtklib_stream.cc @@ -97,7 +97,10 @@ serial_t *openserial(const char *path, int mode, char *msg) int rw = 0; tracet(3, "openserial: path=%s mode=%d\n", path, mode); - if (!(serial = static_cast(malloc(sizeof(serial_t))))) return nullptr; + if (!(serial = static_cast(malloc(sizeof(serial_t))))) + { + return nullptr; + } if ((p = strchr(const_cast(path), ':'))) { @@ -106,10 +109,17 @@ serial_t *openserial(const char *path, int mode, char *msg) sscanf(p, ":%d:%d:%c:%d:%s", &brate, &bsize, &parity, &stopb, fctr); } else if (strlen(path) < 128) - strcpy(port, path); + { + strcpy(port, path); + } for (i = 0; i < 10; i++) - if (br[i] == brate) break; + { + if (br[i] == brate) + { + break; + } + } if (i >= 11) { sprintf(msg, "bitrate error (%d)", brate); @@ -123,15 +133,27 @@ serial_t *openserial(const char *path, int mode, char *msg) std::string s_aux = "/dev/" + std::string(port); s_aux.resize(128, '\0'); int n = s_aux.length(); - for (int i = 0; i < n; i++) dev[i] = s_aux[i]; - if (n == 0) dev[0] = '\0'; + for (int i = 0; i < n; i++) + { + dev[i] = s_aux[i]; + } + if (n == 0) + { + dev[0] = '\0'; + } if ((mode & STR_MODE_R) && (mode & STR_MODE_W)) - rw = O_RDWR; + { + rw = O_RDWR; + } else if (mode & STR_MODE_R) - rw = O_RDONLY; + { + rw = O_RDONLY; + } else if (mode & STR_MODE_W) - rw = O_WRONLY; + { + rw = O_WRONLY; + } if ((serial->dev = open(dev, rw | O_NOCTTY | O_NONBLOCK)) < 0) { @@ -161,7 +183,10 @@ serial_t *openserial(const char *path, int mode, char *msg) /* close serial --------------------------------------------------------------*/ void closeserial(serial_t *serial) { - if (!serial) return; + if (!serial) + { + return; + } tracet(3, "closeserial: dev=%d\n", serial->dev); close(serial->dev); free(serial); @@ -172,9 +197,15 @@ void closeserial(serial_t *serial) int readserial(serial_t *serial, unsigned char *buff, int n, char *msg __attribute__((unused))) { int nr; - if (!serial) return 0; + if (!serial) + { + return 0; + } tracet(4, "readserial: dev=%d n=%d\n", serial->dev, n); - if ((nr = read(serial->dev, buff, n)) < 0) return 0; + if ((nr = read(serial->dev, buff, n)) < 0) + { + return 0; + } tracet(5, "readserial: exit dev=%d nr=%d\n", serial->dev, nr); return nr; } @@ -184,9 +215,15 @@ int readserial(serial_t *serial, unsigned char *buff, int n, char *msg __attribu int writeserial(serial_t *serial, unsigned char *buff, int n, char *msg __attribute__((unused))) { int ns; - if (!serial) return 0; + if (!serial) + { + return 0; + } tracet(3, "writeserial: dev=%d n=%d\n", serial->dev, n); - if ((ns = write(serial->dev, buff, n)) < 0) return 0; + if ((ns = write(serial->dev, buff, n)) < 0) + { + return 0; + } tracet(5, "writeserial: exit dev=%d ns=%d\n", serial->dev, ns); return ns; } @@ -227,9 +264,13 @@ int openfile_(file_t *file, gtime_t time, char *msg) createdir(file->openpath); } if (file->mode & STR_MODE_R) - rw = (char *)"rb"; + { + rw = (char *)"rb"; + } else - rw = (char *)"wb"; + { + rw = (char *)"wb"; + } if (!(file->fp = fopen(file->openpath, rw))) { @@ -283,7 +324,10 @@ int openfile_(file_t *file, gtime_t time, char *msg) if ((fp = fopen(tagpath, "rbe"))) { fclose(fp); - if (remove(tagpath) != 0) trace(1, "Error removing file"); + if (remove(tagpath) != 0) + { + trace(1, "Error removing file"); + } } } return 1; @@ -294,10 +338,22 @@ int openfile_(file_t *file, gtime_t time, char *msg) void closefile_(file_t *file) { tracet(3, "closefile_: path=%s\n", file->path); - if (file->fp) fclose(file->fp); - if (file->fp_tag) fclose(file->fp_tag); - if (file->fp_tmp) fclose(file->fp_tmp); - if (file->fp_tag_tmp) fclose(file->fp_tag_tmp); + if (file->fp) + { + fclose(file->fp); + } + if (file->fp_tag) + { + fclose(file->fp_tag); + } + if (file->fp_tmp) + { + fclose(file->fp_tmp); + } + if (file->fp_tag_tmp) + { + fclose(file->fp_tag_tmp); + } file->fp = file->fp_tag = file->fp_tmp = file->fp_tag_tmp = nullptr; } @@ -313,28 +369,54 @@ file_t *openfile(const char *path, int mode, char *msg) tracet(3, "openfile: path=%s mode=%d\n", path, mode); - if (!(mode & (STR_MODE_R | STR_MODE_W))) return nullptr; + if (!(mode & (STR_MODE_R | STR_MODE_W))) + { + return nullptr; + } /* file options */ for (p = const_cast(path); (p = strstr(p, "::")); p += 2) { /* file options */ if (*(p + 2) == 'T') - timetag = 1; + { + timetag = 1; + } else if (*(p + 2) == '+') - sscanf(p + 2, "+%lf", &start); + { + sscanf(p + 2, "+%lf", &start); + } else if (*(p + 2) == 'x') - sscanf(p + 2, "x%lf", &speed); + { + sscanf(p + 2, "x%lf", &speed); + } else if (*(p + 2) == 'S') - sscanf(p + 2, "S=%lf", &swapintv); + { + sscanf(p + 2, "S=%lf", &swapintv); + } + } + if (start <= 0.0) + { + start = 0.0; + } + if (swapintv <= 0.0) + { + swapintv = 0.0; } - if (start <= 0.0) start = 0.0; - if (swapintv <= 0.0) swapintv = 0.0; - if (!(file = static_cast(malloc(sizeof(file_t))))) return nullptr; + if (!(file = static_cast(malloc(sizeof(file_t))))) + { + return nullptr; + } file->fp = file->fp_tag = file->fp_tmp = file->fp_tag_tmp = nullptr; - if (strlen(path) < MAXSTRPATH) strcpy(file->path, path); - if ((p = strstr(file->path, "::"))) *p = '\0'; + if (strlen(path) < MAXSTRPATH) + { + strcpy(file->path, path); + } + if ((p = strstr(file->path, "::"))) + { + *p = '\0'; + } file->openpath[0] = '\0'; file->mode = mode; file->timetag = timetag; @@ -362,7 +444,10 @@ file_t *openfile(const char *path, int mode, char *msg) /* close file ----------------------------------------------------------------*/ void closefile(file_t *file) { - if (!file) return; + if (!file) + { + return; + } tracet(3, "closefile: fp=%d\n", file->fp); closefile_(file); free(file); @@ -377,7 +462,10 @@ void swapfile(file_t *file, gtime_t time, char *msg) tracet(3, "swapfile: fp=%d time=%s\n", file->fp, time_str(time, 0)); /* return if old swap file open */ - if (file->fp_tmp || file->fp_tag_tmp) return; + if (file->fp_tmp || file->fp_tag_tmp) + { + return; + } /* check path of new swap file */ reppath(file->path, openpath, time, "", ""); @@ -400,8 +488,14 @@ void swapfile(file_t *file, gtime_t time, char *msg) void swapclose(file_t *file) { tracet(3, "swapclose: fp_tmp=%d\n", file->fp_tmp); - if (file->fp_tmp) fclose(file->fp_tmp); - if (file->fp_tag_tmp) fclose(file->fp_tag_tmp); + if (file->fp_tmp) + { + fclose(file->fp_tmp); + } + if (file->fp_tag_tmp) + { + fclose(file->fp_tag_tmp); + } file->fp_tmp = file->fp_tag_tmp = nullptr; } @@ -422,7 +516,10 @@ int readfile(file_t *file, unsigned char *buff, int nmax, char *msg) int nr = 0; size_t fpos; - if (!file) return 0; + if (!file) + { + return 0; + } tracet(4, "readfile: fp=%d nmax=%d\n", file->fp, nmax); if (file->fp == stdin) @@ -430,8 +527,14 @@ int readfile(file_t *file, unsigned char *buff, int nmax, char *msg) /* input from stdin */ FD_ZERO(&rs); FD_SET(0, &rs); - if (!select(1, &rs, nullptr, nullptr, &tv)) return 0; - if ((nr = read(0, buff, nmax)) < 0) return 0; + if (!select(1, &rs, nullptr, nullptr, &tv)) + { + return 0; + } + if ((nr = read(0, buff, nmax)) < 0) + { + return 0; + } return nr; } if (file->fp_tag) @@ -449,21 +552,33 @@ int readfile(file_t *file, unsigned char *buff, int nmax, char *msg) if (fread(&tick, sizeof(tick), 1, file->fp_tag) < 1 || fread(&fpos, sizeof(fpos), 1, file->fp_tag) < 1) { - if (fseek(file->fp, 0, SEEK_END) != 0) trace(1, "fseek error"); + if (fseek(file->fp, 0, SEEK_END) != 0) + { + trace(1, "fseek error"); + } sprintf(msg, "end"); break; } if (file->repmode || file->speed > 0.0) { - if (static_cast(tick - t) < 1) continue; + if (static_cast(tick - t) < 1) + { + continue; + } + } + if (!file->repmode) + { + tick_master = tick; } - if (!file->repmode) tick_master = tick; sprintf(msg, "T%+.1fs", static_cast(tick) < 0 ? 0.0 : static_cast(tick) / 1000.0); if (static_cast(fpos - file->fpos) >= nmax) { - if (fseek(file->fp, fpos, SEEK_SET) != 0) trace(1, "Error fseek"); + if (fseek(file->fp, fpos, SEEK_SET) != 0) + { + trace(1, "Error fseek"); + } file->fpos = fpos; return 0; } @@ -471,7 +586,10 @@ int readfile(file_t *file, unsigned char *buff, int nmax, char *msg) if (file->repmode || file->speed > 0.0) { - if (fseek(file->fp_tag, -static_cast(sizeof(tick) + sizeof(fpos)), SEEK_CUR) != 0) trace(1, "Error fseek"); + if (fseek(file->fp_tag, -static_cast(sizeof(tick) + sizeof(fpos)), SEEK_CUR) != 0) + { + trace(1, "Error fseek"); + } } break; } @@ -480,7 +598,10 @@ int readfile(file_t *file, unsigned char *buff, int nmax, char *msg) { nr = fread(buff, 1, nmax, file->fp); file->fpos += nr; - if (nr <= 0) sprintf(msg, "end"); + if (nr <= 0) + { + sprintf(msg, "end"); + } } tracet(5, "readfile: fp=%d nr=%d fpos=%d\n", file->fp, nr, file->fpos); return nr; @@ -496,7 +617,10 @@ int writefile(file_t *file, unsigned char *buff, int n, char *msg) double tow1, tow2, intv; size_t fpos, fpos_tmp; - if (!file) return 0; + if (!file) + { + return 0; + } tracet(3, "writefile: fp=%d n=%d\n", file->fp, n); wtime = utc2gpst(timeget()); /* write time in gpst */ @@ -520,7 +644,10 @@ int writefile(file_t *file, unsigned char *buff, int n, char *msg) swapclose(file); } } - if (!file->fp) return 0; + if (!file->fp) + { + return 0; + } ns = fwrite(buff, 1, n, file->fp); fpos = ftell(file->fp); @@ -556,7 +683,10 @@ int writefile(file_t *file, unsigned char *buff, int n, char *msg) /* sync files by time-tag ----------------------------------------------------*/ void syncfile(file_t *file1, file_t *file2) { - if (!file1->fp_tag || !file2->fp_tag) return; + if (!file1->fp_tag || !file2->fp_tag) + { + return; + } file1->repmode = 0; file2->repmode = 1; file2->offset = static_cast(file1->tick_f - file2->tick_f); @@ -571,25 +701,52 @@ void decodetcppath(const char *path, char *addr, char *port, char *user, tracet(4, "decodetcpepath: path=%s\n", path); - if (port) *port = '\0'; - if (user) *user = '\0'; - if (passwd) *passwd = '\0'; - if (mntpnt) *mntpnt = '\0'; - if (str) *str = '\0'; + if (port) + { + *port = '\0'; + } + if (user) + { + *user = '\0'; + } + if (passwd) + { + *passwd = '\0'; + } + if (mntpnt) + { + *mntpnt = '\0'; + } + if (str) + { + *str = '\0'; + } - if (strlen(path) < MAXSTRPATH) strcpy(buff, path); + if (strlen(path) < MAXSTRPATH) + { + strcpy(buff, path); + } - if (!(p = strrchr(buff, '@'))) p = buff; + if (!(p = strrchr(buff, '@'))) + { + p = buff; + } if ((p = strchr(p, '/'))) { if ((q = strchr(p + 1, ':'))) { *q = '\0'; - if (str) strcpy(str, q + 1); + if (str) + { + strcpy(str, q + 1); + } } *p = '\0'; - if (mntpnt) strcpy(mntpnt, p + 1); + if (mntpnt) + { + strcpy(mntpnt, p + 1); + } } if ((p = strrchr(buff, '@'))) { @@ -597,19 +754,33 @@ void decodetcppath(const char *path, char *addr, char *port, char *user, if ((q = strchr(buff, ':'))) { *q = '\0'; - if (passwd) strcpy(passwd, q + 1); + if (passwd) + { + strcpy(passwd, q + 1); + } + } + if (user) + { + strcpy(user, buff); } - if (user) strcpy(user, buff); } else - p = buff; + { + p = buff; + } if ((q = strchr(p, ':'))) { *q = '\0'; - if (port) strcpy(port, q + 1); + if (port) + { + strcpy(port, q + 1); + } + } + if (addr) + { + strcpy(addr, p); } - if (addr) strcpy(addr, p); } @@ -655,7 +826,10 @@ socket_t accept_nb(socket_t sock, struct sockaddr *addr, socklen_t *len) fd_set rs; FD_ZERO(&rs); FD_SET(sock, &rs); - if (!select(sock + 1, &rs, nullptr, nullptr, &tv)) return 0; + if (!select(sock + 1, &rs, nullptr, nullptr, &tv)) + { + return 0; + } return accept(sock, addr, len); } @@ -668,15 +842,24 @@ int connect_nb(socket_t sock, struct sockaddr *addr, socklen_t len) int err, flag; flag = fcntl(sock, F_GETFL, 0); - if (fcntl(sock, F_SETFL, flag | O_NONBLOCK) == -1) trace(1, "fcntl error"); + if (fcntl(sock, F_SETFL, flag | O_NONBLOCK) == -1) + { + trace(1, "fcntl error"); + } if (connect(sock, addr, len) == -1) { err = errsock(); - if (err != EISCONN && err != EINPROGRESS && err != EALREADY) return -1; + if (err != EISCONN && err != EINPROGRESS && err != EALREADY) + { + return -1; + } FD_ZERO(&rs); FD_SET(sock, &rs); ws = rs; - if (select(sock + 1, &rs, &ws, nullptr, &tv) == 0) return 0; + if (select(sock + 1, &rs, &ws, nullptr, &tv) == 0) + { + return 0; + } } return 1; } @@ -689,7 +872,10 @@ int recv_nb(socket_t sock, unsigned char *buff, int n) fd_set rs; FD_ZERO(&rs); FD_SET(sock, &rs); - if (!select(sock + 1, &rs, nullptr, nullptr, &tv)) return 0; + if (!select(sock + 1, &rs, nullptr, nullptr, &tv)) + { + return 0; + } return recv(sock, reinterpret_cast(buff), n, 0); } @@ -701,7 +887,10 @@ int send_nb(socket_t sock, unsigned char *buff, int n) fd_set ws; FD_ZERO(&ws); FD_SET(sock, &ws); - if (!select(sock + 1, nullptr, &ws, nullptr, &tv)) return 0; + if (!select(sock + 1, nullptr, &ws, nullptr, &tv)) + { + return 0; + } return send(sock, reinterpret_cast(buff), n, 0); } @@ -791,7 +980,10 @@ tcpsvr_t *opentcpsvr(const char *path, char *msg) tcpsvr0 = {{0, {0}, 0, {0, 0, 0, {0}}, 0, 0, 0, 0}, {{0, {0}, 0, {0, 0, 0, {0}}, 0, 0, 0, 0}}}; tracet(3, "opentcpsvr: path=%s\n", path); - if (!(tcpsvr = static_cast(malloc(sizeof(tcpsvr_t))))) return nullptr; + if (!(tcpsvr = static_cast(malloc(sizeof(tcpsvr_t))))) + { + return nullptr; + } *tcpsvr = tcpsvr0; decodetcppath(path, tcpsvr->svr.saddr, port, nullptr, nullptr, nullptr, nullptr); if (sscanf(port, "%d", &tcpsvr->svr.port) < 1) @@ -818,7 +1010,10 @@ void closetcpsvr(tcpsvr_t *tcpsvr) tracet(3, "closetcpsvr:\n"); for (i = 0; i < MAXCLI; i++) { - if (tcpsvr->cli[i].state) closesocket(tcpsvr->cli[i].sock); + if (tcpsvr->cli[i].state) + { + closesocket(tcpsvr->cli[i].sock); + } } closesocket(tcpsvr->svr.sock); free(tcpsvr); @@ -833,14 +1028,23 @@ void updatetcpsvr(tcpsvr_t *tcpsvr, char *msg) tracet(3, "updatetcpsvr: state=%d\n", tcpsvr->svr.state); - if (tcpsvr->svr.state == 0) return; + if (tcpsvr->svr.state == 0) + { + return; + } for (i = 0; i < MAXCLI; i++) { - if (tcpsvr->cli[i].state) continue; + if (tcpsvr->cli[i].state) + { + continue; + } for (j = i + 1; j < MAXCLI; j++) { - if (!tcpsvr->cli[j].state) continue; + if (!tcpsvr->cli[j].state) + { + continue; + } tcpsvr->cli[i] = tcpsvr->cli[j]; tcpsvr->cli[j].state = 0; break; @@ -848,7 +1052,10 @@ void updatetcpsvr(tcpsvr_t *tcpsvr, char *msg) } for (i = 0; i < MAXCLI; i++) { - if (!tcpsvr->cli[i].state) continue; + if (!tcpsvr->cli[i].state) + { + continue; + } strcpy(saddr, tcpsvr->cli[i].saddr); n++; } @@ -860,9 +1067,13 @@ void updatetcpsvr(tcpsvr_t *tcpsvr, char *msg) } tcpsvr->svr.state = 2; if (n == 1) - sprintf(msg, "%s", saddr); + { + sprintf(msg, "%s", saddr); + } else - sprintf(msg, "%d clients", n); + { + sprintf(msg, "%d clients", n); + } } @@ -879,8 +1090,16 @@ int accsock(tcpsvr_t *tcpsvr, char *msg) tracet(3, "accsock: sock=%d\n", tcpsvr->svr.sock); for (i = 0; i < MAXCLI; i++) - if (tcpsvr->cli[i].state == 0) break; - if (i >= MAXCLI) return 0; /* too many client */ + { + if (tcpsvr->cli[i].state == 0) + { + break; + } + } + if (i >= MAXCLI) + { + return 0; /* too many client */ + } if ((sock = accept_nb(tcpsvr->svr.sock, reinterpret_cast(&addr), &len)) == -1) { @@ -891,12 +1110,21 @@ int accsock(tcpsvr_t *tcpsvr, char *msg) tcpsvr->svr.state = 0; return 0; } - if (sock == 0) return 0; + if (sock == 0) + { + return 0; + } tcpsvr->cli[i].sock = sock; - if (!setsock(tcpsvr->cli[i].sock, msg)) return 0; + if (!setsock(tcpsvr->cli[i].sock, msg)) + { + return 0; + } memcpy(&tcpsvr->cli[i].addr, &addr, sizeof(addr)); - if (strlen(inet_ntoa(addr.sin_addr)) < 256) strcpy(tcpsvr->cli[i].saddr, inet_ntoa(addr.sin_addr)); + if (strlen(inet_ntoa(addr.sin_addr)) < 256) + { + strcpy(tcpsvr->cli[i].saddr, inet_ntoa(addr.sin_addr)); + } sprintf(msg, "%s", tcpsvr->cli[i].saddr); tracet(2, "accsock: connected sock=%d addr=%s\n", tcpsvr->cli[i].sock, tcpsvr->cli[i].saddr); tcpsvr->cli[i].state = 2; @@ -909,9 +1137,14 @@ int accsock(tcpsvr_t *tcpsvr, char *msg) int waittcpsvr(tcpsvr_t *tcpsvr, char *msg) { tracet(4, "waittcpsvr: sock=%d state=%d\n", tcpsvr->svr.sock, tcpsvr->svr.state); - if (tcpsvr->svr.state <= 0) return 0; + if (tcpsvr->svr.state <= 0) + { + return 0; + } while (accsock(tcpsvr, msg)) - ; + { + ; + } updatetcpsvr(tcpsvr, msg); return tcpsvr->svr.state == 2; } @@ -924,7 +1157,10 @@ int readtcpsvr(tcpsvr_t *tcpsvr, unsigned char *buff, int n, char *msg) tracet(4, "readtcpsvr: state=%d n=%d\n", tcpsvr->svr.state, n); - if (!waittcpsvr(tcpsvr, msg) || tcpsvr->cli[0].state != 2) return 0; + if (!waittcpsvr(tcpsvr, msg) || tcpsvr->cli[0].state != 2) + { + return 0; + } if ((nr = recv_nb(tcpsvr->cli[0].sock, buff, n)) == -1) { @@ -935,7 +1171,10 @@ int readtcpsvr(tcpsvr_t *tcpsvr, unsigned char *buff, int n, char *msg) updatetcpsvr(tcpsvr, msg); return 0; } - if (nr > 0) tcpsvr->cli[0].tact = tickget(); + if (nr > 0) + { + tcpsvr->cli[0].tact = tickget(); + } tracet(5, "readtcpsvr: exit sock=%d nr=%d\n", tcpsvr->cli[0].sock, nr); return nr; } @@ -948,11 +1187,17 @@ int writetcpsvr(tcpsvr_t *tcpsvr, unsigned char *buff, int n, char *msg) tracet(3, "writetcpsvr: state=%d n=%d\n", tcpsvr->svr.state, n); - if (!waittcpsvr(tcpsvr, msg)) return 0; + if (!waittcpsvr(tcpsvr, msg)) + { + return 0; + } for (i = 0; i < MAXCLI; i++) { - if (tcpsvr->cli[i].state != 2) continue; + if (tcpsvr->cli[i].state != 2) + { + continue; + } if ((ns = send_nb(tcpsvr->cli[i].sock, buff, n)) == -1) { @@ -963,7 +1208,10 @@ int writetcpsvr(tcpsvr_t *tcpsvr, unsigned char *buff, int n, char *msg) updatetcpsvr(tcpsvr, msg); return 0; } - if (ns > 0) tcpsvr->cli[i].tact = tickget(); + if (ns > 0) + { + tcpsvr->cli[i].tact = tickget(); + } tracet(5, "writetcpsvr: send i=%d ns=%d\n", i, ns); } return ns; @@ -1023,7 +1271,10 @@ tcpcli_t *opentcpcli(const char *path, char *msg) tracet(3, "opentcpcli: path=%s\n", path); - if (!(tcpcli = static_cast(malloc(sizeof(tcpcli_t))))) return nullptr; + if (!(tcpcli = static_cast(malloc(sizeof(tcpcli_t))))) + { + return nullptr; + } *tcpcli = tcpcli0; decodetcppath(path, tcpcli->svr.saddr, port, nullptr, nullptr, nullptr, nullptr); if (sscanf(port, "%d", &tcpcli->svr.port) < 1) @@ -1054,15 +1305,24 @@ int waittcpcli(tcpcli_t *tcpcli, char *msg) { tracet(4, "waittcpcli: sock=%d state=%d\n", tcpcli->svr.sock, tcpcli->svr.state); - if (tcpcli->svr.state < 0) return 0; + if (tcpcli->svr.state < 0) + { + return 0; + } if (tcpcli->svr.state == 0) { /* close */ - if (!gentcp(&tcpcli->svr, 1, msg)) return 0; + if (!gentcp(&tcpcli->svr, 1, msg)) + { + return 0; + } } if (tcpcli->svr.state == 1) { /* wait */ - if (!consock(tcpcli, msg)) return 0; + if (!consock(tcpcli, msg)) + { + return 0; + } } if (tcpcli->svr.state == 2) { /* connect */ @@ -1086,7 +1346,10 @@ int readtcpcli(tcpcli_t *tcpcli, unsigned char *buff, int n, char *msg) tracet(4, "readtcpcli: sock=%d state=%d n=%d\n", tcpcli->svr.sock, tcpcli->svr.state, n); - if (!waittcpcli(tcpcli, msg)) return 0; + if (!waittcpcli(tcpcli, msg)) + { + return 0; + } if ((nr = recv_nb(tcpcli->svr.sock, buff, n)) == -1) { @@ -1096,7 +1359,10 @@ int readtcpcli(tcpcli_t *tcpcli, unsigned char *buff, int n, char *msg) discontcp(&tcpcli->svr, tcpcli->tirecon); return 0; } - if (nr > 0) tcpcli->svr.tact = tickget(); + if (nr > 0) + { + tcpcli->svr.tact = tickget(); + } tracet(5, "readtcpcli: exit sock=%d nr=%d\n", tcpcli->svr.sock, nr); return nr; } @@ -1109,7 +1375,10 @@ int writetcpcli(tcpcli_t *tcpcli, unsigned char *buff, int n, char *msg) tracet(3, "writetcpcli: sock=%d state=%d n=%d\n", tcpcli->svr.sock, tcpcli->svr.state, n); - if (!waittcpcli(tcpcli, msg)) return 0; + if (!waittcpcli(tcpcli, msg)) + { + return 0; + } if ((ns = send_nb(tcpcli->svr.sock, buff, n)) == -1) { @@ -1119,7 +1388,10 @@ int writetcpcli(tcpcli_t *tcpcli, unsigned char *buff, int n, char *msg) discontcp(&tcpcli->svr, tcpcli->tirecon); return 0; } - if (ns > 0) tcpcli->svr.tact = tickget(); + if (ns > 0) + { + tcpcli->svr.tact = tickget(); + } tracet(5, "writetcpcli: exit sock=%d ns=%d\n", tcpcli->svr.sock, ns); return ns; } @@ -1146,11 +1418,17 @@ int encbase64(char *str, const unsigned char *byte, int n) for (k = b = 0; k < 6; k++, i++) { b <<= 1; - if (i / 8 < n) b |= (byte[i / 8] >> (7 - i % 8)) & 0x1; + if (i / 8 < n) + { + b |= (byte[i / 8] >> (7 - i % 8)) & 0x1; + } } str[j++] = table[b]; } - while (j & 0x3) str[j++] = '='; + while (j & 0x3) + { + str[j++] = '='; + } str[j] = '\0'; tracet(5, "encbase64: str=%s\n", str); return j; @@ -1169,7 +1447,10 @@ int reqntrip_s(ntrip_t *ntrip, char *msg) p += sprintf(p, "STR: %s\r\n", ntrip->str); p += sprintf(p, "\r\n"); - if (writetcpcli(ntrip->tcp, reinterpret_cast(buff), p - buff, msg) != p - buff) return 0; + if (writetcpcli(ntrip->tcp, reinterpret_cast(buff), p - buff, msg) != p - buff) + { + return 0; + } tracet(2, "reqntrip_s: send request state=%d ns=%d\n", ntrip->state, p - buff); tracet(5, "reqntrip_s: n=%d buff=\n%s\n", p - buff, buff); @@ -1202,7 +1483,10 @@ int reqntrip_c(ntrip_t *ntrip, char *msg) } p += sprintf(p, "\r\n"); - if (writetcpcli(ntrip->tcp, reinterpret_cast(buff), p - buff, msg) != p - buff) return 0; + if (writetcpcli(ntrip->tcp, reinterpret_cast(buff), p - buff, msg) != p - buff) + { + return 0; + } tracet(2, "reqntrip_c: send request state=%d ns=%d\n", ntrip->state, p - buff); tracet(5, "reqntrip_c: n=%d buff=\n%s\n", p - buff, buff); @@ -1226,7 +1510,10 @@ int rspntrip_s(ntrip_t *ntrip, char *msg) q = reinterpret_cast(ntrip->buff); p += strlen(NTRIP_RSP_OK_SVR); ntrip->nb -= p - q; - for (i = 0; i < ntrip->nb; i++) *q++ = *p++; + for (i = 0; i < ntrip->nb; i++) + { + *q++ = *p++; + } ntrip->state = 2; sprintf(msg, "%s/%s", ntrip->tcp->svr.saddr, ntrip->mntpnt); tracet(2, "rspntrip_s: response ok nb=%d\n", ntrip->nb); @@ -1238,7 +1525,10 @@ int rspntrip_s(ntrip_t *ntrip, char *msg) // strncpy(msg, (char *)ntrip->buff, nb); This line triggers a warning. Replaced by; std::string s_aux(reinterpret_cast(ntrip->buff)); s_aux.resize(nb, '\0'); - for (int i = 0; i < nb; i++) msg[i] = s_aux[i]; + for (int i = 0; i < nb; i++) + { + msg[i] = s_aux[i]; + } msg[nb] = 0; tracet(1, "rspntrip_s: %s nb=%d\n", msg, ntrip->nb); @@ -1276,7 +1566,10 @@ int rspntrip_c(ntrip_t *ntrip, char *msg) q = reinterpret_cast(ntrip->buff); p += strlen(NTRIP_RSP_OK_CLI); ntrip->nb -= p - q; - for (i = 0; i < ntrip->nb; i++) *q++ = *p++; + for (i = 0; i < ntrip->nb; i++) + { + *q++ = *p++; + } ntrip->state = 2; sprintf(msg, "%s/%s", ntrip->tcp->svr.saddr, ntrip->mntpnt); tracet(2, "rspntrip_c: response ok nb=%d\n", ntrip->nb); @@ -1301,9 +1594,13 @@ int rspntrip_c(ntrip_t *ntrip, char *msg) else if ((p = strstr(reinterpret_cast(ntrip->buff), NTRIP_RSP_HTTP))) { /* http response */ if ((q = strchr(p, '\r'))) - *q = '\0'; + { + *q = '\0'; + } else - ntrip->buff[128] = '\0'; + { + ntrip->buff[128] = '\0'; + } strcpy(msg, p); tracet(1, "rspntrip_s: %s nb=%d\n", msg, ntrip->nb); ntrip->nb = 0; @@ -1333,9 +1630,15 @@ int waitntrip(ntrip_t *ntrip, char *msg) tracet(4, "waitntrip: state=%d nb=%d\n", ntrip->state, ntrip->nb); - if (ntrip->state < 0) return 0; /* error */ + if (ntrip->state < 0) + { + return 0; /* error */ + } - if (ntrip->tcp->svr.state < 2) ntrip->state = 0; /* tcp disconnected */ + if (ntrip->tcp->svr.state < 2) + { + ntrip->state = 0; /* tcp disconnected */ + } if (ntrip->state == 0) { /* send request */ @@ -1372,14 +1675,20 @@ ntrip_t *openntrip(const char *path, int type, char *msg) tracet(3, "openntrip: path=%s type=%d\n", path, type); - if (!(ntrip = static_cast(malloc(sizeof(ntrip_t))))) return nullptr; + if (!(ntrip = static_cast(malloc(sizeof(ntrip_t))))) + { + return nullptr; + } ntrip->state = 0; ntrip->type = type; /* 0:server, 1:client */ ntrip->nb = 0; ntrip->url[0] = '\0'; ntrip->mntpnt[0] = ntrip->user[0] = ntrip->passwd[0] = ntrip->str[0] = '\0'; - for (i = 0; i < NTRIP_MAXRSP; i++) ntrip->buff[i] = 0; + for (i = 0; i < NTRIP_MAXRSP; i++) + { + ntrip->buff[i] = 0; + } /* decode tcp/ntrip path */ decodetcppath(path, addr, port, ntrip->user, ntrip->passwd, ntrip->mntpnt, @@ -1399,7 +1708,12 @@ ntrip_t *openntrip(const char *path, int type, char *msg) std::string s_aux = "http://" + std::string(tpath); int n = s_aux.length(); if (n < 256) - for (int k = 0; k < n; k++) ntrip->url[k] = s_aux[k]; + { + for (int k = 0; k < n; k++) + { + ntrip->url[k] = s_aux[k]; + } + } strcpy(tpath, proxyaddr); } /* open tcp client stream */ @@ -1429,7 +1743,10 @@ int readntrip(ntrip_t *ntrip, unsigned char *buff, int n, char *msg) tracet(4, "readntrip: n=%d\n", n); - if (!waitntrip(ntrip, msg)) return 0; + if (!waitntrip(ntrip, msg)) + { + return 0; + } if (ntrip->nb > 0) { /* read response buffer first */ nb = ntrip->nb <= n ? ntrip->nb : n; @@ -1446,7 +1763,10 @@ int writentrip(ntrip_t *ntrip, unsigned char *buff, int n, char *msg) { tracet(3, "writentrip: n=%d\n", n); - if (!waitntrip(ntrip, msg)) return 0; + if (!waitntrip(ntrip, msg)) + { + return 0; + } return writetcpcli(ntrip->tcp, buff, n, msg); } @@ -1466,8 +1786,14 @@ void decodeftppath(const char *path, char *addr, char *file, char *user, tracet(4, "decodeftpath: path=%s\n", path); - if (user) *user = '\0'; - if (passwd) *passwd = '\0'; + if (user) + { + *user = '\0'; + } + if (passwd) + { + *passwd = '\0'; + } if (topts) { topts[0] = 0; /* time offset in path (s) */ @@ -1475,20 +1801,28 @@ void decodeftppath(const char *path, char *addr, char *file, char *user, topts[2] = 0; /* download time offset (s) */ topts[3] = 0; /* retry interval (s) (0: no retry) */ } - if (strlen(path) < MAXSTRPATH) strcpy(buff, path); + if (strlen(path) < MAXSTRPATH) + { + strcpy(buff, path); + } if ((p = strchr(buff, '/'))) { if ((q = strstr(p + 1, "::"))) { *q = '\0'; - if (topts) sscanf(q + 2, "T=%d, %d, %d, %d", topts, topts + 1, topts + 2, topts + 3); + if (topts) + { + sscanf(q + 2, "T=%d, %d, %d, %d", topts, topts + 1, topts + 2, topts + 3); + } } strcpy(file, p + 1); *p = '\0'; } else - file[0] = '\0'; + { + file[0] = '\0'; + } if ((p = strrchr(buff, '@'))) { @@ -1496,12 +1830,20 @@ void decodeftppath(const char *path, char *addr, char *file, char *user, if ((q = strchr(buff, ':'))) { *q = '\0'; - if (passwd) strcpy(passwd, q + 1); + if (passwd) + { + strcpy(passwd, q + 1); + } + } + if (user) + { + strcpy(user, buff); } - if (user) strcpy(user, buff); } else - p = buff; + { + p = buff; + } strcpy(addr, p); } @@ -1560,20 +1902,34 @@ void *ftpthread(void *arg) reppath(ftp->file, remote, time, "", ""); if ((p = strrchr(remote, '/'))) - p++; + { + p++; + } else - p = remote; + { + p = remote; + } // sprintf(local, "%s%c%s", localdir, FILEPATHSEP, p); This line triggers a warning. Replaced by: std::string s_aux = std::string(localdir) + std::to_string(FILEPATHSEP) + std::string(p); int n = s_aux.length(); if (n < 1024) - for (int i = 0; i < n; i++) local[i] = s_aux[i]; + { + for (int i = 0; i < n; i++) + { + local[i] = s_aux[i]; + } + } // sprintf(errfile, "%s.err", local); This line triggers a warning. Replaced by: std::string s_aux2 = std::string(local) + ".err"; n = s_aux2.length(); if (n < 1024) - for (int i = 0; i < n; i++) errfile[i] = s_aux2[i]; + { + for (int i = 0; i < n; i++) + { + errfile[i] = s_aux2[i]; + } + } /* if local file exist, skip download */ strcpy(tmpfile, local); @@ -1608,39 +1964,59 @@ void *ftpthread(void *arg) " -O \"" + std::string(local) + "\""; int k = s_aux.length(); if (k < 1024) - for (int i = 0; i < k; i++) opt[i] = s_aux[i]; + { + for (int i = 0; i < k; i++) + { + opt[i] = s_aux[i]; + } + } // sprintf(cmd, "%s%s %s \"ftp://%s/%s\" 2> \"%s\"\n", env, FTP_CMD, opt, ftp->addr, // remote, errfile); This line triggers a warning. Replaced by: std::string s_aux2 = std::string(env) + std::string(FTP_CMD) + " " + std::string(opt) + " " + "\"ftp://" + std::string(ftp->addr) + "/" + std::string(remote) + "\" 2> \"" + std::string(errfile) + "\"\n"; k = s_aux2.length(); - for (int i = 0; (i < k) && (i < 1024); i++) cmd[i] = s_aux2[i]; + for (int i = 0; (i < k) && (i < 1024); i++) + { + cmd[i] = s_aux2[i]; + } } else { /* http */ // sprintf(opt, "%s-t 1 -T %d -O \"%s\"", proxyopt, FTP_TIMEOUT, local); This line triggers a warning. Replaced by: std::string s_aux = std::string(proxyopt) + " -t 1 -T " + std::to_string(FTP_TIMEOUT) + " -O \"" + std::string(local) + "\""; int l = s_aux.length(); - for (int i = 0; (i < l) && (i < 1024); i++) opt[i] = s_aux[i]; + for (int i = 0; (i < l) && (i < 1024); i++) + { + opt[i] = s_aux[i]; + } // sprintf(cmd, "%s%s %s \"http://%s/%s\" 2> \"%s\"\n", env, FTP_CMD, opt, ftp->addr, // remote, errfile); This line triggers a warning. Replaced by: std::string s_aux2 = std::string(env) + std::string(FTP_CMD) + " " + std::string(opt) + " " + "\"http://" + std::string(ftp->addr) + "/" + std::string(remote) + "\" 2> \"" + std::string(errfile) + "\"\n"; l = s_aux2.length(); - for (int i = 0; (i < l) && (i < 1024); i++) cmd[i] = s_aux2[i]; + for (int i = 0; (i < l) && (i < 1024); i++) + { + cmd[i] = s_aux2[i]; + } } /* execute download command */ if ((ret = execcmd(cmd))) { - if (remove(local) != 0) trace(1, "Error removing file"); + if (remove(local) != 0) + { + trace(1, "Error removing file"); + } tracet(1, "execcmd error: cmd=%s ret=%d\n", cmd, ret); ftp->error = ret; ftp->state = 3; return nullptr; } - if (remove(errfile) != 0) trace(1, "Error removing file"); + if (remove(errfile) != 0) + { + trace(1, "Error removing file"); + } /* uncompress downloaded file */ if ((p = strrchr(local, '.')) && @@ -1649,8 +2025,14 @@ void *ftpthread(void *arg) { if (rtk_uncompress(local, tmpfile)) { - if (remove(local) != 0) trace(1, "Error removing file"); - if (strlen(tmpfile) < 1024) strcpy(local, tmpfile); + if (remove(local) != 0) + { + trace(1, "Error removing file"); + } + if (strlen(tmpfile) < 1024) + { + strcpy(local, tmpfile); + } } else { @@ -1660,7 +2042,10 @@ void *ftpthread(void *arg) return nullptr; } } - if (strlen(local) < 1024) strcpy(ftp->local, local); + if (strlen(local) < 1024) + { + strcpy(ftp->local, local); + } ftp->state = 2; /* ftp completed */ tracet(3, "ftpthread: complete cmd=%s\n", cmd); @@ -1677,7 +2062,10 @@ ftp_t *openftp(const char *path, int type, char *msg) msg[0] = '\0'; - if (!(ftp = static_cast(malloc(sizeof(ftp_t))))) return nullptr; + if (!(ftp = static_cast(malloc(sizeof(ftp_t))))) + { + return nullptr; + } ftp->state = 0; ftp->proto = type; @@ -1700,7 +2088,10 @@ void closeftp(ftp_t *ftp) { tracet(3, "closeftp: state=%d\n", ftp->state); - if (ftp->state != 1) free(ftp); + if (ftp->state != 1) + { + free(ftp); + } } @@ -1731,7 +2122,10 @@ int readftp(ftp_t *ftp, unsigned char *buff, int n, char *msg) return 0; } } - if (ftp->state <= 1) return 0; /* ftp/http on going? */ + if (ftp->state <= 1) + { + return 0; /* ftp/http on going? */ + } if (ftp->state == 3) { /* ftp error */ @@ -1745,7 +2139,10 @@ int readftp(ftp_t *ftp, unsigned char *buff, int n, char *msg) /* return local file path if ftp completed */ p = buff; q = reinterpret_cast(ftp->local); - while (*q && static_cast(p - buff) < n) *p++ = *q++; + while (*q && static_cast(p - buff) < n) + { + *p++ = *q++; + } p += sprintf(reinterpret_cast(p), "\r\n"); /* set next download time */ @@ -1838,7 +2235,10 @@ int stropen(stream_t *stream, int type, int mode, const char *path) stream->type = type; stream->mode = mode; - if (strlen(path) < MAXSTRPATH) strcpy(stream->path, path); + if (strlen(path) < MAXSTRPATH) + { + strcpy(stream->path, path); + } stream->inb = stream->inr = stream->outb = stream->outr = 0; stream->tick = tickget(); stream->inbt = stream->outbt = 0; @@ -1942,10 +2342,16 @@ void strclose(stream_t *stream) void strsync(stream_t *stream1, stream_t *stream2) { file_t *file1, *file2; - if (stream1->type != STR_FILE || stream2->type != STR_FILE) return; + if (stream1->type != STR_FILE || stream2->type != STR_FILE) + { + return; + } file1 = static_cast(stream1->port); file2 = static_cast(stream2->port); - if (file1 && file2) syncfile(file1, file2); + if (file1 && file2) + { + syncfile(file1, file2); + } } @@ -1975,7 +2381,10 @@ int strread(stream_t *stream, unsigned char *buff, int n) tracet(4, "strread: n=%d\n", n); - if (!(stream->mode & STR_MODE_R) || !stream->port) return 0; + if (!(stream->mode & STR_MODE_R) || !stream->port) + { + return 0; + } strlock(stream); @@ -2008,7 +2417,10 @@ int strread(stream_t *stream, unsigned char *buff, int n) } stream->inb += nr; tick = tickget(); - if (nr > 0) stream->tact = tick; + if (nr > 0) + { + stream->tact = tick; + } if (static_cast(tick - stream->tick) >= tirate) { @@ -2037,7 +2449,10 @@ int strwrite(stream_t *stream, unsigned char *buff, int n) tracet(3, "strwrite: n=%d\n", n); - if (!(stream->mode & STR_MODE_W) || !stream->port) return 0; + if (!(stream->mode & STR_MODE_W) || !stream->port) + { + return 0; + } strlock(stream); @@ -2067,7 +2482,10 @@ int strwrite(stream_t *stream, unsigned char *buff, int n) } stream->outb += ns; tick = tickget(); - if (ns > 0) stream->tact = tick; + if (ns > 0) + { + stream->tact = tick; + } if (static_cast(tick - stream->tick) > tirate) { @@ -2098,7 +2516,10 @@ int strstat(stream_t *stream, char *msg) // strncpy(msg, stream->msg, MAXSTRMSG - 1); This line triggers a warning. Replaced by: std::string aux_s(stream->msg); aux_s.resize(MAXSTRMSG - 1, '0'); - for (int i = 0; i < MAXSTRMSG - 1; i++) msg[i] = aux_s[i]; + for (int i = 0; i < MAXSTRMSG - 1; i++) + { + msg[i] = aux_s[i]; + } msg[MAXSTRMSG - 1] = '\0'; } if (!stream->port) @@ -2134,7 +2555,10 @@ int strstat(stream_t *stream, char *msg) strunlock(stream); return 0; } - if (state == 2 && static_cast(tickget() - stream->tact) <= TINTACT) state = 3; + if (state == 2 && static_cast(tickget() - stream->tact) <= TINTACT) + { + state = 3; + } strunlock(stream); return state; } @@ -2154,10 +2578,22 @@ void strsum(stream_t *stream, int *inb, int *inr, int *outb, int *outr) tracet(4, "strsum:\n"); strlock(stream); - if (inb) *inb = stream->inb; - if (inr) *inr = stream->inr; - if (outb) *outb = stream->outb; - if (outr) *outr = stream->outr; + if (inb) + { + *inb = stream->inb; + } + if (inr) + { + *inr = stream->inr; + } + if (outb) + { + *outb = stream->outb; + } + if (outr) + { + *outr = stream->outr; + } strunlock(stream); } @@ -2210,7 +2646,9 @@ void strsettimeout(stream_t *stream, int toinact, int tirecon) tcpcli = (static_cast(stream->port))->tcp; } else - return; + { + return; + } tcpcli->toinact = toinact; tcpcli->tirecon = tirecon; @@ -2225,7 +2663,10 @@ void strsettimeout(stream_t *stream, int toinact, int tirecon) void strsetdir(const char *dir) { tracet(3, "strsetdir: dir=%s\n", dir); - if (strlen(dir) < 1024) strcpy(localdir, dir); + if (strlen(dir) < 1024) + { + strcpy(localdir, dir); + } } @@ -2237,7 +2678,10 @@ void strsetdir(const char *dir) void strsetproxy(const char *addr) { tracet(3, "strsetproxy: addr=%s\n", addr); - if (strlen(addr) < 256) strcpy(proxyaddr, addr); + if (strlen(addr) < 256) + { + strcpy(proxyaddr, addr); + } } @@ -2274,7 +2718,10 @@ void strsendnmea(stream_t *stream, const double *pos) sol.stat = SOLQ_SINGLE; sol.time = utc2gpst(timeget()); - for (i = 0; i < 3; i++) sol.rr[i] = pos[i]; + for (i = 0; i < 3; i++) + { + sol.rr[i] = pos[i]; + } n = outnmea_gga(buff, &sol); strwrite(stream, buff, n); } @@ -2297,7 +2744,10 @@ int gen_hex(const char *msg, unsigned char *buff) } for (i = 0; i < narg; i++) { - if (sscanf(args[i], "%x", &byte)) *q++ = static_cast(byte); + if (sscanf(args[i], "%x", &byte)) + { + *q++ = static_cast(byte); + } } return static_cast(q - buff); } @@ -2321,7 +2771,12 @@ void strsendcmd(stream_t *str, const char *cmd) for (;;) { for (q = p;; q++) - if (*q == '\r' || *q == '\n' || *q == '\0') break; + { + if (*q == '\r' || *q == '\n' || *q == '\0') + { + break; + } + } n = static_cast(q - p); strncpy(msg, p, n); msg[n] = '\0'; @@ -2334,8 +2789,14 @@ void strsendcmd(stream_t *str, const char *cmd) { /* binary escape */ if (!strncmp(msg + 1, "WAIT", 4)) { /* wait */ - if (sscanf(msg + 5, "%d", &ms) < 1) ms = 100; - if (ms > 3000) ms = 3000; /* max 3 s */ + if (sscanf(msg + 5, "%d", &ms) < 1) + { + ms = 100; + } + if (ms > 3000) + { + ms = 3000; /* max 3 s */ + } sleepms(ms); } @@ -2357,7 +2818,10 @@ void strsendcmd(stream_t *str, const char *cmd) //} else if (!strncmp(msg + 1, "HEX", 3)) { /* general hex message */ - if ((m = gen_hex(msg + 4, buff)) > 0) strwrite(str, buff, m); + if ((m = gen_hex(msg + 4, buff)) > 0) + { + strwrite(str, buff, m); + } } } else @@ -2366,7 +2830,9 @@ void strsendcmd(stream_t *str, const char *cmd) strwrite(str, reinterpret_cast(cmdend), 2); } if (*q == '\0') - break; + { + break; + } p = q + 1; } diff --git a/src/algorithms/libs/rtklib/rtklib_tides.cc b/src/algorithms/libs/rtklib/rtklib_tides.cc index c53d5cd98..eb5355a61 100644 --- a/src/algorithms/libs/rtklib/rtklib_tides.cc +++ b/src/algorithms/libs/rtklib/rtklib_tides.cc @@ -65,9 +65,15 @@ void tide_pl(const double *eu, const double *rp, double GMp, trace(4, "tide_pl : pos=%.3f %.3f\n", pos[0] * R2D, pos[1] * R2D); - if ((r = norm_rtk(rp, 3)) <= 0.0) return; + if ((r = norm_rtk(rp, 3)) <= 0.0) + { + return; + } - for (i = 0; i < 3; i++) ep[i] = rp[i] / r; + for (i = 0; i < 3; i++) + { + ep[i] = rp[i] / r; + } K2 = GMp / GME * std::pow(RE_WGS84, 2.04) * std::pow(RE_WGS84, 2.0) / (r * r * r); K3 = K2 * RE_WGS84 / r; @@ -181,8 +187,14 @@ void tide_oload(gtime_t tut, const double *odisp, double *denu) for (i = 0; i < 11; i++) { ang = 0.0; - for (j = 0; j < 5; j++) ang += a[j] * args[i][j]; - for (j = 0; j < 3; j++) dp[j] += odisp[j + i * 6] * cos(ang - odisp[j + 3 + i * 6] * D2R); + for (j = 0; j < 5; j++) + { + ang += a[j] * args[i][j]; + } + for (j = 0; j < 3; j++) + { + dp[j] += odisp[j + i * 6] * cos(ang - odisp[j + 3 + i * 6] * D2R); + } } denu[0] = -dp[1]; denu[1] = -dp[2]; @@ -279,13 +291,19 @@ void tidedisp(gtime_t tutc, const double *rr, int opt, const erp_t *erp, trace(3, "tidedisp: tutc=%s\n", time_str(tutc, 0)); - if (erp) geterp(erp, tutc, erpv); + if (erp) + { + geterp(erp, tutc, erpv); + } tut = timeadd(tutc, erpv[2]); dr[0] = dr[1] = dr[2] = 0.0; - if (norm_rtk(rr, 3) <= 0.0) return; + if (norm_rtk(rr, 3) <= 0.0) + { + return; + } pos[0] = asin(rr[2] / norm_rtk(rr, 3)); pos[1] = atan2(rr[1], rr[0]); @@ -309,19 +327,28 @@ void tidedisp(gtime_t tutc, const double *rr, int opt, const erp_t *erp, #else tide_solid(rs, rm, pos, E, gmst, opt, drt); #endif - for (i = 0; i < 3; i++) dr[i] += drt[i]; + for (i = 0; i < 3; i++) + { + dr[i] += drt[i]; + } } if ((opt & 2) && odisp) { /* ocean tide loading */ tide_oload(tut, odisp, denu); matmul("TN", 3, 1, 3, 1.0, E, denu, 0.0, drt); - for (i = 0; i < 3; i++) dr[i] += drt[i]; + for (i = 0; i < 3; i++) + { + dr[i] += drt[i]; + } } if ((opt & 4) && erp) { /* pole tide */ tide_pole(tut, pos, erpv, denu); matmul("TN", 3, 1, 3, 1.0, E, denu, 0.0, drt); - for (i = 0; i < 3; i++) dr[i] += drt[i]; + for (i = 0; i < 3; i++) + { + dr[i] += drt[i]; + } } trace(5, "tidedisp: dr=%.3f %.3f %.3f\n", dr[0], dr[1], dr[2]); } diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc index d542235a9..f90982965 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_cc.cc @@ -576,7 +576,10 @@ int hybrid_observables_cc::general_work(int noutput_items __attribute__((unused) } } - if (n_valid > 0) compute_pranges(epoch_data); + if (n_valid > 0) + { + compute_pranges(epoch_data); + } for (uint32_t n = 0; n < d_nchannels_out; n++) { diff --git a/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.cc b/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.cc index 84a90d555..6029af1ac 100644 --- a/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.cc +++ b/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.cc @@ -53,7 +53,7 @@ signal_make_generator_c(std::vector signal1, std::vector &delay_chips, const std::vector &delay_sec, bool data_flag, bool noise_flag, unsigned int fs_in, unsigned int vector_length, float BW_BB) { - return gnuradio::get_initial_sptr(new signal_generator_c(std::move(signal1), std::move(system), PRN, CN0_dB, doppler_Hz, delay_chips, delay_sec, + return gnuradio::get_initial_sptr(new signal_generator_c(signal1, system, PRN, CN0_dB, doppler_Hz, delay_chips, delay_sec, data_flag, noise_flag, fs_in, vector_length, BW_BB)); } diff --git a/src/algorithms/signal_source/adapters/file_signal_source.cc b/src/algorithms/signal_source/adapters/file_signal_source.cc index c6627d001..d7856ee57 100644 --- a/src/algorithms/signal_source/adapters/file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/file_signal_source.cc @@ -56,12 +56,18 @@ FileSignalSource::FileSignalSource(ConfigurationInterface* configuration, double default_seconds_to_skip = 0.0; size_t header_size = 0; samples_ = configuration->property(role + ".samples", 0); - sampling_frequency_ = configuration->property(role + ".sampling_frequency", 0LL); + sampling_frequency_ = configuration->property(role + ".sampling_frequency", 0); filename_ = configuration->property(role + ".filename", default_filename); // override value with commandline flag, if present - if (FLAGS_signal_source != "-") filename_ = FLAGS_signal_source; - if (FLAGS_s != "-") filename_ = FLAGS_s; + if (FLAGS_signal_source != "-") + { + filename_ = FLAGS_signal_source; + } + if (FLAGS_s != "-") + { + filename_ = FLAGS_s; + } item_type_ = configuration->property(role + ".item_type", default_item_type); repeat_ = configuration->property(role + ".repeat", false); diff --git a/src/algorithms/signal_source/adapters/nsr_file_signal_source.cc b/src/algorithms/signal_source/adapters/nsr_file_signal_source.cc index 60566ed5e..2ceeca528 100644 --- a/src/algorithms/signal_source/adapters/nsr_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/nsr_file_signal_source.cc @@ -58,8 +58,14 @@ NsrFileSignalSource::NsrFileSignalSource(ConfigurationInterface* configuration, filename_ = configuration->property(role + ".filename", default_filename); // override value with commandline flag, if present - if (FLAGS_signal_source != "-") filename_ = FLAGS_signal_source; - if (FLAGS_s != "-") filename_ = FLAGS_s; + if (FLAGS_signal_source != "-") + { + filename_ = FLAGS_signal_source; + } + if (FLAGS_s != "-") + { + filename_ = FLAGS_s; + } item_type_ = configuration->property(role + ".item_type", default_item_type); repeat_ = configuration->property(role + ".repeat", false); diff --git a/src/algorithms/signal_source/adapters/spir_file_signal_source.cc b/src/algorithms/signal_source/adapters/spir_file_signal_source.cc index d5692e434..58675e527 100644 --- a/src/algorithms/signal_source/adapters/spir_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/spir_file_signal_source.cc @@ -57,8 +57,14 @@ SpirFileSignalSource::SpirFileSignalSource(ConfigurationInterface* configuration filename_ = configuration->property(role + ".filename", default_filename); // override value with commandline flag, if present - if (FLAGS_signal_source != "-") filename_ = FLAGS_signal_source; - if (FLAGS_s != "-") filename_ = FLAGS_s; + if (FLAGS_signal_source != "-") + { + filename_ = FLAGS_signal_source; + } + if (FLAGS_s != "-") + { + filename_ = FLAGS_s; + } item_type_ = configuration->property(role + ".item_type", default_item_type); repeat_ = configuration->property(role + ".repeat", false); diff --git a/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.cc b/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.cc index 7115771e9..b1e578b1b 100644 --- a/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/two_bit_cpx_file_signal_source.cc @@ -62,8 +62,14 @@ TwoBitCpxFileSignalSource::TwoBitCpxFileSignalSource(ConfigurationInterface* con filename_ = configuration->property(role + ".filename", default_filename); // override value with commandline flag, if present - if (FLAGS_signal_source != "-") filename_ = FLAGS_signal_source; - if (FLAGS_s != "-") filename_ = FLAGS_s; + if (FLAGS_signal_source != "-") + { + filename_ = FLAGS_signal_source; + } + if (FLAGS_s != "-") + { + filename_ = FLAGS_s; + } item_type_ = configuration->property(role + ".item_type", default_item_type); repeat_ = configuration->property(role + ".repeat", false); diff --git a/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc b/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc index 9355537ce..00a50257e 100644 --- a/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc +++ b/src/algorithms/signal_source/adapters/two_bit_packed_file_signal_source.cc @@ -66,8 +66,14 @@ TwoBitPackedFileSignalSource::TwoBitPackedFileSignalSource(ConfigurationInterfac filename_ = configuration->property(role + ".filename", default_filename); // override value with commandline flag, if present - if (FLAGS_signal_source != "-") filename_ = FLAGS_signal_source; - if (FLAGS_s != "-") filename_ = FLAGS_s; + if (FLAGS_signal_source != "-") + { + filename_ = FLAGS_signal_source; + } + if (FLAGS_s != "-") + { + filename_ = FLAGS_s; + } item_type_ = configuration->property(role + ".item_type", default_item_type); big_endian_items_ = configuration->property(role + ".big_endian_items", true); diff --git a/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc b/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc index efc866de8..bc636f23c 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc +++ b/src/algorithms/signal_source/gnuradio_blocks/labsat23_source.cc @@ -198,7 +198,10 @@ int labsat23_source::general_work(int noutput_items, bool preamble_ok = true; for (int i = 0; i < 8; i++) { - if (memblock[byte_counter] != 0x00) preamble_ok = false; + if (memblock[byte_counter] != 0x00) + { + preamble_ok = false; + } //std::cout << "H[" << i << "]:" << (int)memblock[byte_counter] << std::endl; byte_counter++; } diff --git a/src/algorithms/signal_source/gnuradio_blocks/unpack_2bit_samples.cc b/src/algorithms/signal_source/gnuradio_blocks/unpack_2bit_samples.cc index 1fd5c2032..db56ff0b2 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/unpack_2bit_samples.cc +++ b/src/algorithms/signal_source/gnuradio_blocks/unpack_2bit_samples.cc @@ -65,7 +65,9 @@ bool systemBytesAreBigEndian() byte_and_samples b{}; b.byte = static_cast(0x01); if (*reinterpret_cast(&b.byte) == 1) - return false; + { + return false; + } return true; } diff --git a/src/algorithms/signal_source/libs/gnss_sdr_valve.cc b/src/algorithms/signal_source/libs/gnss_sdr_valve.cc index b613f3e2b..992507cd7 100644 --- a/src/algorithms/signal_source/libs/gnss_sdr_valve.cc +++ b/src/algorithms/signal_source/libs/gnss_sdr_valve.cc @@ -94,7 +94,10 @@ int gnss_sdr_valve::work(int noutput_items, return 0; // do not produce or consume } uint64_t n = std::min(d_nitems - d_ncopied_items, static_cast(noutput_items)); - if (n == 0) return 0; + if (n == 0) + { + return 0; + } memcpy(output_items[0], input_items[0], n * input_signature()->sizeof_stream_item(0)); d_ncopied_items += n; return n; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc index 8dec53b5a..658397b46 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.cc @@ -203,7 +203,10 @@ bool gps_l1_ca_telemetry_decoder_cc::decode_subframe() if (symbol_accumulator_counter == 20) { // symbol to bit - if (symbol_accumulator > 0) GPS_frame_4bytes += 1; // insert the telemetry bit in LSB + if (symbol_accumulator > 0) + { + GPS_frame_4bytes += 1; // insert the telemetry bit in LSB + } symbol_accumulator = 0; symbol_accumulator_counter = 0; diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.cc index 75b18caef..552a0f398 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/sbas_l1_telemetry_decoder_cc.cc @@ -299,13 +299,17 @@ void sbas_l1_telemetry_decoder_cc::frame_detector::get_frame_candidates(const st { // invert bits for (int &candidate_bit_it : candidate) - candidate_bit_it = candidate_bit_it == 0 ? 1 : 0; + { + candidate_bit_it = candidate_bit_it == 0 ? 1 : 0; + } } msg_candidates.emplace_back(relative_preamble_start, candidate); ss.str(""); ss << "preamble " << preample_it - preambles.begin() << (inv_preamble_detected ? " inverted" : " normal") << " detected! candidate="; for (auto bit_it = candidate.begin(); bit_it < candidate.end(); ++bit_it) - ss << *bit_it; + { + ss << *bit_it; + } VLOG(EVENT) << ss.str(); } } diff --git a/src/algorithms/telemetry_decoder/libs/convolutional.h b/src/algorithms/telemetry_decoder/libs/convolutional.h index 23b9976b9..cc775110b 100644 --- a/src/algorithms/telemetry_decoder/libs/convolutional.h +++ b/src/algorithms/telemetry_decoder/libs/convolutional.h @@ -155,7 +155,9 @@ inline static float Gamma(const float rec_array[], for (i = 0; i < nn; i++) { if (symbol & mask) - rm += rec_array[nn - i - 1]; + { + rm += rec_array[nn - i - 1]; + } mask = mask << 1; } return (rm); @@ -219,11 +221,15 @@ inline static void Viterbi(int output_u_int[], for (t = 0; t < LL + mm; t++) { for (i = 0; i < nn; i++) - rec_array[i] = static_cast(input_c[nn * t + i]); + { + rec_array[i] = static_cast(input_c[nn * t + i]); + } /* precompute all possible branch metrics */ for (i = 0; i < number_symbols; i++) - metric_c[i] = Gamma(rec_array, i, nn); + { + metric_c[i] = Gamma(rec_array, i, nn); + } /* step through all states */ for (state = 0; state < states; state++) diff --git a/src/algorithms/telemetry_decoder/libs/libswiftcnav/bits.c b/src/algorithms/telemetry_decoder/libs/libswiftcnav/bits.c index 866b822fb..207c7fb94 100644 --- a/src/algorithms/telemetry_decoder/libs/libswiftcnav/bits.c +++ b/src/algorithms/telemetry_decoder/libs/libswiftcnav/bits.c @@ -30,7 +30,6 @@ */ #include "bits.h" - #include #include @@ -72,11 +71,11 @@ u8 parity(u32 x) u32 getbitu(const u8 *buff, u32 pos, u8 len) { u32 bits = 0; - u32 i=0; + u32 i = 0; for (i = pos; i < pos + len; i++) { bits = (bits << 1) + - ((buff[i/8] >> (7 - i%8)) & 1u); + ((buff[i / 8] >> (7 - i % 8)) & 1u); } return bits; @@ -118,14 +117,20 @@ void setbitu(u8 *buff, u32 pos, u32 len, u32 data) u32 mask = 1u << (len - 1); if (len <= 0 || 32 < len) - return; + { + return; + } u32 i = 0; for (i = pos; i < pos + len; i++, mask >>= 1) { if (data & mask) - buff[i/8] |= 1u << (7 - i % 8); + { + buff[i / 8] |= 1u << (7 - i % 8); + } else - buff[i/8] &= ~(1u << (7 - i % 8)); + { + buff[i / 8] &= ~(1u << (7 - i % 8)); + } } } @@ -162,12 +167,12 @@ void bitshl(void *buf, u32 size, u32 shift) return; } - unsigned char *dst = buf; /* Destination byte. */ + unsigned char *dst = buf; /* Destination byte. */ const unsigned char *src = dst + shift / CHAR_BIT; /* First source byte, possibly incomplete. */ - u32 copy_bits = size * CHAR_BIT - shift; /* Number of bits to move */ - u32 byte_shift = copy_bits % CHAR_BIT; /* Shift of data */ - u32 full_bytes = copy_bits / CHAR_BIT; /* Number of bytes to move */ + u32 copy_bits = size * CHAR_BIT - shift; /* Number of bits to move */ + u32 byte_shift = copy_bits % CHAR_BIT; /* Shift of data */ + u32 full_bytes = copy_bits / CHAR_BIT; /* Number of bytes to move */ if (0 == byte_shift) { @@ -211,7 +216,7 @@ void bitshl(void *buf, u32 size, u32 shift) * proper native type like long. */ void bitcopy(void *dst, u32 dst_index, const void *src, u32 src_index, - u32 count) + u32 count) { u32 limit1 = count / 32; u32 limit2 = count % 32; @@ -243,7 +248,9 @@ u8 count_bits_u64(u64 v, u8 bv) u8 r = 0; int i = 0; for (i = 0; i < 16; i++) - r += bitn[(v >> (i*4)) & 0xf]; + { + r += bitn[(v >> (i * 4)) & 0xf]; + } return bv == 1 ? r : 64 - r; } @@ -260,7 +267,9 @@ u8 count_bits_u32(u32 v, u8 bv) u8 r = 0; int i = 0; for (i = 0; i < 8; i++) - r += bitn[(v >> (i*4)) & 0xf]; + { + r += bitn[(v >> (i * 4)) & 0xf]; + } return bv == 1 ? r : 32 - r; } @@ -276,8 +285,10 @@ u8 count_bits_u16(u16 v, u8 bv) { u8 r = 0; int i = 0; - for (i= 0; i < 4; i++) - r += bitn[(v >> (i*4)) & 0xf]; + for (i = 0; i < 4; i++) + { + r += bitn[(v >> (i * 4)) & 0xf]; + } return bv == 1 ? r : 16 - r; } @@ -294,7 +305,9 @@ u8 count_bits_u8(u8 v, u8 bv) u8 r = 0; int i = 0; for (i = 0; i < 2; i++) - r += bitn[(v >> (i*4)) & 0xf]; + { + r += bitn[(v >> (i * 4)) & 0xf]; + } return bv == 1 ? r : 8 - r; } diff --git a/src/algorithms/telemetry_decoder/libs/libswiftcnav/edc.c b/src/algorithms/telemetry_decoder/libs/libswiftcnav/edc.c index c89bae64d..b5f3623a2 100644 --- a/src/algorithms/telemetry_decoder/libs/libswiftcnav/edc.c +++ b/src/algorithms/telemetry_decoder/libs/libswiftcnav/edc.c @@ -40,39 +40,38 @@ * \{ */ static const u32 crc24qtab[256] = { - 0x000000, 0x864CFB, 0x8AD50D, 0x0C99F6, 0x93E6E1, 0x15AA1A, 0x1933EC, 0x9F7F17, - 0xA18139, 0x27CDC2, 0x2B5434, 0xAD18CF, 0x3267D8, 0xB42B23, 0xB8B2D5, 0x3EFE2E, - 0xC54E89, 0x430272, 0x4F9B84, 0xC9D77F, 0x56A868, 0xD0E493, 0xDC7D65, 0x5A319E, - 0x64CFB0, 0xE2834B, 0xEE1ABD, 0x685646, 0xF72951, 0x7165AA, 0x7DFC5C, 0xFBB0A7, - 0x0CD1E9, 0x8A9D12, 0x8604E4, 0x00481F, 0x9F3708, 0x197BF3, 0x15E205, 0x93AEFE, - 0xAD50D0, 0x2B1C2B, 0x2785DD, 0xA1C926, 0x3EB631, 0xB8FACA, 0xB4633C, 0x322FC7, - 0xC99F60, 0x4FD39B, 0x434A6D, 0xC50696, 0x5A7981, 0xDC357A, 0xD0AC8C, 0x56E077, - 0x681E59, 0xEE52A2, 0xE2CB54, 0x6487AF, 0xFBF8B8, 0x7DB443, 0x712DB5, 0xF7614E, - 0x19A3D2, 0x9FEF29, 0x9376DF, 0x153A24, 0x8A4533, 0x0C09C8, 0x00903E, 0x86DCC5, - 0xB822EB, 0x3E6E10, 0x32F7E6, 0xB4BB1D, 0x2BC40A, 0xAD88F1, 0xA11107, 0x275DFC, - 0xDCED5B, 0x5AA1A0, 0x563856, 0xD074AD, 0x4F0BBA, 0xC94741, 0xC5DEB7, 0x43924C, - 0x7D6C62, 0xFB2099, 0xF7B96F, 0x71F594, 0xEE8A83, 0x68C678, 0x645F8E, 0xE21375, - 0x15723B, 0x933EC0, 0x9FA736, 0x19EBCD, 0x8694DA, 0x00D821, 0x0C41D7, 0x8A0D2C, - 0xB4F302, 0x32BFF9, 0x3E260F, 0xB86AF4, 0x2715E3, 0xA15918, 0xADC0EE, 0x2B8C15, - 0xD03CB2, 0x567049, 0x5AE9BF, 0xDCA544, 0x43DA53, 0xC596A8, 0xC90F5E, 0x4F43A5, - 0x71BD8B, 0xF7F170, 0xFB6886, 0x7D247D, 0xE25B6A, 0x641791, 0x688E67, 0xEEC29C, - 0x3347A4, 0xB50B5F, 0xB992A9, 0x3FDE52, 0xA0A145, 0x26EDBE, 0x2A7448, 0xAC38B3, - 0x92C69D, 0x148A66, 0x181390, 0x9E5F6B, 0x01207C, 0x876C87, 0x8BF571, 0x0DB98A, - 0xF6092D, 0x7045D6, 0x7CDC20, 0xFA90DB, 0x65EFCC, 0xE3A337, 0xEF3AC1, 0x69763A, - 0x578814, 0xD1C4EF, 0xDD5D19, 0x5B11E2, 0xC46EF5, 0x42220E, 0x4EBBF8, 0xC8F703, - 0x3F964D, 0xB9DAB6, 0xB54340, 0x330FBB, 0xAC70AC, 0x2A3C57, 0x26A5A1, 0xA0E95A, - 0x9E1774, 0x185B8F, 0x14C279, 0x928E82, 0x0DF195, 0x8BBD6E, 0x872498, 0x016863, - 0xFAD8C4, 0x7C943F, 0x700DC9, 0xF64132, 0x693E25, 0xEF72DE, 0xE3EB28, 0x65A7D3, - 0x5B59FD, 0xDD1506, 0xD18CF0, 0x57C00B, 0xC8BF1C, 0x4EF3E7, 0x426A11, 0xC426EA, - 0x2AE476, 0xACA88D, 0xA0317B, 0x267D80, 0xB90297, 0x3F4E6C, 0x33D79A, 0xB59B61, - 0x8B654F, 0x0D29B4, 0x01B042, 0x87FCB9, 0x1883AE, 0x9ECF55, 0x9256A3, 0x141A58, - 0xEFAAFF, 0x69E604, 0x657FF2, 0xE33309, 0x7C4C1E, 0xFA00E5, 0xF69913, 0x70D5E8, - 0x4E2BC6, 0xC8673D, 0xC4FECB, 0x42B230, 0xDDCD27, 0x5B81DC, 0x57182A, 0xD154D1, - 0x26359F, 0xA07964, 0xACE092, 0x2AAC69, 0xB5D37E, 0x339F85, 0x3F0673, 0xB94A88, - 0x87B4A6, 0x01F85D, 0x0D61AB, 0x8B2D50, 0x145247, 0x921EBC, 0x9E874A, 0x18CBB1, - 0xE37B16, 0x6537ED, 0x69AE1B, 0xEFE2E0, 0x709DF7, 0xF6D10C, 0xFA48FA, 0x7C0401, - 0x42FA2F, 0xC4B6D4, 0xC82F22, 0x4E63D9, 0xD11CCE, 0x575035, 0x5BC9C3, 0xDD8538 -}; + 0x000000, 0x864CFB, 0x8AD50D, 0x0C99F6, 0x93E6E1, 0x15AA1A, 0x1933EC, 0x9F7F17, + 0xA18139, 0x27CDC2, 0x2B5434, 0xAD18CF, 0x3267D8, 0xB42B23, 0xB8B2D5, 0x3EFE2E, + 0xC54E89, 0x430272, 0x4F9B84, 0xC9D77F, 0x56A868, 0xD0E493, 0xDC7D65, 0x5A319E, + 0x64CFB0, 0xE2834B, 0xEE1ABD, 0x685646, 0xF72951, 0x7165AA, 0x7DFC5C, 0xFBB0A7, + 0x0CD1E9, 0x8A9D12, 0x8604E4, 0x00481F, 0x9F3708, 0x197BF3, 0x15E205, 0x93AEFE, + 0xAD50D0, 0x2B1C2B, 0x2785DD, 0xA1C926, 0x3EB631, 0xB8FACA, 0xB4633C, 0x322FC7, + 0xC99F60, 0x4FD39B, 0x434A6D, 0xC50696, 0x5A7981, 0xDC357A, 0xD0AC8C, 0x56E077, + 0x681E59, 0xEE52A2, 0xE2CB54, 0x6487AF, 0xFBF8B8, 0x7DB443, 0x712DB5, 0xF7614E, + 0x19A3D2, 0x9FEF29, 0x9376DF, 0x153A24, 0x8A4533, 0x0C09C8, 0x00903E, 0x86DCC5, + 0xB822EB, 0x3E6E10, 0x32F7E6, 0xB4BB1D, 0x2BC40A, 0xAD88F1, 0xA11107, 0x275DFC, + 0xDCED5B, 0x5AA1A0, 0x563856, 0xD074AD, 0x4F0BBA, 0xC94741, 0xC5DEB7, 0x43924C, + 0x7D6C62, 0xFB2099, 0xF7B96F, 0x71F594, 0xEE8A83, 0x68C678, 0x645F8E, 0xE21375, + 0x15723B, 0x933EC0, 0x9FA736, 0x19EBCD, 0x8694DA, 0x00D821, 0x0C41D7, 0x8A0D2C, + 0xB4F302, 0x32BFF9, 0x3E260F, 0xB86AF4, 0x2715E3, 0xA15918, 0xADC0EE, 0x2B8C15, + 0xD03CB2, 0x567049, 0x5AE9BF, 0xDCA544, 0x43DA53, 0xC596A8, 0xC90F5E, 0x4F43A5, + 0x71BD8B, 0xF7F170, 0xFB6886, 0x7D247D, 0xE25B6A, 0x641791, 0x688E67, 0xEEC29C, + 0x3347A4, 0xB50B5F, 0xB992A9, 0x3FDE52, 0xA0A145, 0x26EDBE, 0x2A7448, 0xAC38B3, + 0x92C69D, 0x148A66, 0x181390, 0x9E5F6B, 0x01207C, 0x876C87, 0x8BF571, 0x0DB98A, + 0xF6092D, 0x7045D6, 0x7CDC20, 0xFA90DB, 0x65EFCC, 0xE3A337, 0xEF3AC1, 0x69763A, + 0x578814, 0xD1C4EF, 0xDD5D19, 0x5B11E2, 0xC46EF5, 0x42220E, 0x4EBBF8, 0xC8F703, + 0x3F964D, 0xB9DAB6, 0xB54340, 0x330FBB, 0xAC70AC, 0x2A3C57, 0x26A5A1, 0xA0E95A, + 0x9E1774, 0x185B8F, 0x14C279, 0x928E82, 0x0DF195, 0x8BBD6E, 0x872498, 0x016863, + 0xFAD8C4, 0x7C943F, 0x700DC9, 0xF64132, 0x693E25, 0xEF72DE, 0xE3EB28, 0x65A7D3, + 0x5B59FD, 0xDD1506, 0xD18CF0, 0x57C00B, 0xC8BF1C, 0x4EF3E7, 0x426A11, 0xC426EA, + 0x2AE476, 0xACA88D, 0xA0317B, 0x267D80, 0xB90297, 0x3F4E6C, 0x33D79A, 0xB59B61, + 0x8B654F, 0x0D29B4, 0x01B042, 0x87FCB9, 0x1883AE, 0x9ECF55, 0x9256A3, 0x141A58, + 0xEFAAFF, 0x69E604, 0x657FF2, 0xE33309, 0x7C4C1E, 0xFA00E5, 0xF69913, 0x70D5E8, + 0x4E2BC6, 0xC8673D, 0xC4FECB, 0x42B230, 0xDDCD27, 0x5B81DC, 0x57182A, 0xD154D1, + 0x26359F, 0xA07964, 0xACE092, 0x2AAC69, 0xB5D37E, 0x339F85, 0x3F0673, 0xB94A88, + 0x87B4A6, 0x01F85D, 0x0D61AB, 0x8B2D50, 0x145247, 0x921EBC, 0x9E874A, 0x18CBB1, + 0xE37B16, 0x6537ED, 0x69AE1B, 0xEFE2E0, 0x709DF7, 0xF6D10C, 0xFA48FA, 0x7C0401, + 0x42FA2F, 0xC4B6D4, 0xC82F22, 0x4E63D9, 0xD11CCE, 0x575035, 0x5BC9C3, 0xDD8538}; /** Calculate Qualcomm 24-bit Cyclical Redundancy Check (CRC-24Q). * @@ -93,7 +92,9 @@ u32 crc24q(const u8 *buf, u32 len, u32 crc) { u32 i = 0; for (i = 0; i < len; i++) - crc = ((crc << 8) & 0xFFFFFF) ^ crc24qtab[((crc >> 16) ^ buf[i]) & 0xff]; + { + crc = ((crc << 8) & 0xFFFFFF) ^ crc24qtab[((crc >> 16) ^ buf[i]) & 0xff]; + } return crc; } @@ -114,28 +115,28 @@ u32 crc24q(const u8 *buf, u32 len, u32 crc) */ u32 crc24q_bits(u32 crc, const u8 *buf, u32 n_bits, bool invert) { - u16 acc = 0; - u8 b = 0; + u16 acc = 0; + u8 b = 0; u32 shift = 8 - n_bits % 8; u32 i = 0; for (i = 0; i < n_bits / 8; ++i) { - acc = (acc << 8) | *buf++; + acc = (acc << 8) | *buf++; if (invert) { acc ^= 0xFFu; } - b = (acc >> shift) & 0xFFu; - crc = ((crc << 8) & 0xFFFFFFu) ^ crc24qtab[((crc >> 16) ^ b) & 0xFFu]; + b = (acc >> shift) & 0xFFu; + crc = ((crc << 8) & 0xFFFFFFu) ^ crc24qtab[((crc >> 16) ^ b) & 0xFFu]; } - acc = (acc << 8) | *buf; + acc = (acc << 8) | *buf; if (invert) { acc ^= 0xFFu; } - b = (acc >> shift) & 0xFFu; - crc = ((crc << 8) & 0xFFFFFFu) ^ crc24qtab[((crc >> 16) ^ b) & 0xFFu]; + b = (acc >> shift) & 0xFFu; + crc = ((crc << 8) & 0xFFFFFFu) ^ crc24qtab[((crc >> 16) ^ b) & 0xFFu]; return crc; } diff --git a/src/algorithms/telemetry_decoder/libs/libswiftcnav/viterbi27.c b/src/algorithms/telemetry_decoder/libs/libswiftcnav/viterbi27.c index 9739c2ab3..c6486412a 100644 --- a/src/algorithms/telemetry_decoder/libs/libswiftcnav/viterbi27.c +++ b/src/algorithms/telemetry_decoder/libs/libswiftcnav/viterbi27.c @@ -30,8 +30,8 @@ */ -#include #include "fec.h" +#include static inline int parity(int x) { @@ -52,10 +52,10 @@ void v27_poly_init(v27_poly_t *poly, const signed char polynomial[2]) { int state; - for(state = 0; state < 32; state++) + for (state = 0; state < 32; state++) { - poly->c0[state] = (polynomial[0] < 0) ^ parity((2*state) & abs(polynomial[0])) ? 255 : 0; - poly->c1[state] = (polynomial[1] < 0) ^ parity((2*state) & abs(polynomial[1])) ? 255 : 0; + poly->c0[state] = (polynomial[0] < 0) ^ parity((2 * state) & abs(polynomial[0])) ? 255 : 0; + poly->c1[state] = (polynomial[1] < 0) ^ parity((2 * state) & abs(polynomial[1])) ? 255 : 0; } } @@ -72,7 +72,7 @@ void v27_poly_init(v27_poly_t *poly, const signed char polynomial[2]) * \param initial_state Initial state of the decoder shift register. Usually zero. */ void v27_init(v27_t *v, v27_decision_t *decisions, unsigned int decisions_count, - const v27_poly_t *poly, unsigned char initial_state) + const v27_poly_t *poly, unsigned char initial_state) { int i; @@ -83,28 +83,31 @@ void v27_init(v27_t *v, v27_decision_t *decisions, unsigned int decisions_count, v->decisions_index = 0; v->decisions_count = decisions_count; - for(i = 0; i < 64; i++) - v->old_metrics[i] = 63; + for (i = 0; i < 64; i++) + { + v->old_metrics[i] = 63; + } v->old_metrics[initial_state & 63] = 0; /* Bias known start state */ } /* C-language butterfly */ -#define BFLY(i) {\ - unsigned int metric,m0,m1,decision;\ - metric = (v->poly->c0[i] ^ sym0) + (v->poly->c1[i] ^ sym1);\ - m0 = v->old_metrics[i] + metric;\ - m1 = v->old_metrics[(i)+32] + (510 - metric);\ - decision = (signed int)(m0-m1) > 0;\ - v->new_metrics[2*(i)] = decision ? m1 : m0;\ - d->w[(i)/16] |= decision << ((2*(i))&31);\ - m0 -= (metric+metric-510);\ - m1 += (metric+metric-510);\ - decision = (signed int)(m0-m1) > 0;\ - v->new_metrics[2*(i)+1] = decision ? m1 : m0;\ - d->w[(i)/16] |= decision << ((2*(i)+1)&31);\ -} +#define BFLY(i) \ + { \ + unsigned int metric, m0, m1, decision; \ + metric = (v->poly->c0[i] ^ sym0) + (v->poly->c1[i] ^ sym1); \ + m0 = v->old_metrics[i] + metric; \ + m1 = v->old_metrics[(i) + 32] + (510 - metric); \ + decision = (signed int)(m0 - m1) > 0; \ + v->new_metrics[2 * (i)] = decision ? m1 : m0; \ + d->w[(i) / 16] |= decision << ((2 * (i)) & 31); \ + m0 -= (metric + metric - 510); \ + m1 += (metric + metric - 510); \ + decision = (signed int)(m0 - m1) > 0; \ + v->new_metrics[2 * (i) + 1] = decision ? m1 : m0; \ + d->w[(i) / 16] |= decision << ((2 * (i) + 1) & 31); \ + } /** Update a v27_t decoder with a block of symbols. * @@ -119,7 +122,7 @@ void v27_update(v27_t *v, const unsigned char *syms, int nbits) unsigned int *tmp; int normalize = 0; - while(nbits--) + while (nbits--) { v27_decision_t *d = &v->decisions[v->decisions_index]; @@ -161,26 +164,32 @@ void v27_update(v27_t *v, const unsigned char *syms, int nbits) BFLY(31); /* Normalize metrics if they are nearing overflow */ - if(v->new_metrics[0] > (1 << 30)) + if (v->new_metrics[0] > (1 << 30)) { int i; unsigned int minmetric = 1 << 31; - for(i = 0; i < 64; i++) + for (i = 0; i < 64; i++) { - if(v->new_metrics[i] < minmetric) - minmetric = v->new_metrics[i]; + if (v->new_metrics[i] < minmetric) + { + minmetric = v->new_metrics[i]; + } } - for(i = 0; i < 64; i++) - v->new_metrics[i] -= minmetric; + for (i = 0; i < 64; i++) + { + v->new_metrics[i] -= minmetric; + } normalize += minmetric; } /* Advance decision index */ - if(++v->decisions_index >= v->decisions_count) - v->decisions_index = 0; + if (++v->decisions_index >= v->decisions_count) + { + v->decisions_index = 0; + } /* Swap pointers to old and new metrics */ tmp = v->old_metrics; @@ -199,7 +208,7 @@ void v27_update(v27_t *v, const unsigned char *syms, int nbits) * \param final_state Known final state of the decoder shift register. */ void v27_chainback_fixed(v27_t *v, unsigned char *data, unsigned int nbits, - unsigned char final_state) + unsigned char final_state) { int k; unsigned int decisions_index = v->decisions_index; @@ -207,12 +216,10 @@ void v27_chainback_fixed(v27_t *v, unsigned char *data, unsigned int nbits, final_state %= 64; final_state <<= 2; - while(nbits-- != 0) + while (nbits-- != 0) { - /* Decrement decision index */ - decisions_index = (decisions_index == 0) ? - v->decisions_count-1 : decisions_index-1; + decisions_index = (decisions_index == 0) ? v->decisions_count - 1 : decisions_index - 1; v27_decision_t *d = &v->decisions[decisions_index]; k = (d->w[(final_state >> 2) / 32] >> ((final_state >> 2) % 32)) & 1; @@ -239,9 +246,9 @@ void v27_chainback_likely(v27_t *v, unsigned char *data, unsigned int nbits) int i; unsigned int best_metric = 0xffffffff; unsigned char best_state = 0; - for(i = 0; i < 64; i++) + for (i = 0; i < 64; i++) { - if(v->new_metrics[i] < best_metric) + if (v->new_metrics[i] < best_metric) { best_metric = v->new_metrics[i]; best_state = i; diff --git a/src/algorithms/telemetry_decoder/libs/viterbi_decoder.cc b/src/algorithms/telemetry_decoder/libs/viterbi_decoder.cc index 957efa9a6..febb18294 100644 --- a/src/algorithms/telemetry_decoder/libs/viterbi_decoder.cc +++ b/src/algorithms/telemetry_decoder/libs/viterbi_decoder.cc @@ -199,7 +199,9 @@ int Viterbi_Decoder::do_acs(const double sym[], int nbits) { /* Temporarily store the received symbols current decoding step */ for (i = 0; i < d_nn; i++) - d_rec_array[i] = static_cast(sym[d_nn * t + i]); + { + d_rec_array[i] = static_cast(sym[d_nn * t + i]); + } /* precompute all possible branch metrics */ for (i = 0; i < d_number_symbols; i++) diff --git a/src/algorithms/tracking/adapters/beidou_b1i_dll_pll_tracking.cc b/src/algorithms/tracking/adapters/beidou_b1i_dll_pll_tracking.cc index e860da87b..d74732151 100644 --- a/src/algorithms/tracking/adapters/beidou_b1i_dll_pll_tracking.cc +++ b/src/algorithms/tracking/adapters/beidou_b1i_dll_pll_tracking.cc @@ -59,14 +59,20 @@ BeidouB1iDllPllTracking::BeidouB1iDllPllTracking( bool dump = configuration->property(role + ".dump", false); trk_param.dump = dump; float pll_bw_hz = configuration->property(role + ".pll_bw_hz", 50.0); - if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + if (FLAGS_pll_bw_hz != 0.0) + { + pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + } trk_param.pll_bw_hz = pll_bw_hz; float pll_bw_narrow_hz = configuration->property(role + ".pll_bw_narrow_hz", 20.0); trk_param.pll_bw_narrow_hz = pll_bw_narrow_hz; float dll_bw_narrow_hz = configuration->property(role + ".dll_bw_narrow_hz", 2.0); trk_param.dll_bw_narrow_hz = dll_bw_narrow_hz; float dll_bw_hz = configuration->property(role + ".dll_bw_hz", 2.0); - if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } trk_param.dll_bw_hz = dll_bw_hz; float early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5); trk_param.early_late_space_chips = early_late_space_chips; @@ -105,16 +111,28 @@ BeidouB1iDllPllTracking::BeidouB1iDllPllTracking( char sig_[3] = "B1"; std::memcpy(trk_param.signal, sig_, 3); int cn0_samples = configuration->property(role + ".cn0_samples", 20); - if (FLAGS_cn0_samples != 20) cn0_samples = FLAGS_cn0_samples; + if (FLAGS_cn0_samples != 20) + { + cn0_samples = FLAGS_cn0_samples; + } trk_param.cn0_samples = cn0_samples; int cn0_min = configuration->property(role + ".cn0_min", 25); - if (FLAGS_cn0_min != 25) cn0_min = FLAGS_cn0_min; + if (FLAGS_cn0_min != 25) + { + cn0_min = FLAGS_cn0_min; + } trk_param.cn0_min = cn0_min; int max_lock_fail = configuration->property(role + ".max_lock_fail", 50); - if (FLAGS_max_lock_fail != 50) max_lock_fail = FLAGS_max_lock_fail; + if (FLAGS_max_lock_fail != 50) + { + max_lock_fail = FLAGS_max_lock_fail; + } trk_param.max_lock_fail = max_lock_fail; double carrier_lock_th = configuration->property(role + ".carrier_lock_th", 0.85); - if (FLAGS_carrier_lock_th != 0.85) carrier_lock_th = FLAGS_carrier_lock_th; + if (FLAGS_carrier_lock_th != 0.85) + { + carrier_lock_th = FLAGS_carrier_lock_th; + } trk_param.carrier_lock_th = carrier_lock_th; //################# MAKE TRACKING GNURadio object ################### diff --git a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking.cc b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking.cc index 3bb059dc2..4912bd093 100644 --- a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking.cc +++ b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking.cc @@ -76,10 +76,16 @@ GalileoE1DllPllVemlTracking::GalileoE1DllPllVemlTracking( trk_param.smoother_length = configuration->property(role + ".smoother_length", 10); } float pll_bw_hz = configuration->property(role + ".pll_bw_hz", 5.0); - if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + if (FLAGS_pll_bw_hz != 0.0) + { + pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + } trk_param.pll_bw_hz = pll_bw_hz; float dll_bw_hz = configuration->property(role + ".dll_bw_hz", 0.5); - if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } trk_param.dll_bw_hz = dll_bw_hz; float pll_bw_narrow_hz = configuration->property(role + ".pll_bw_narrow_hz", 2.0); trk_param.pll_bw_narrow_hz = pll_bw_narrow_hz; @@ -117,16 +123,28 @@ GalileoE1DllPllVemlTracking::GalileoE1DllPllVemlTracking( char sig_[3] = "1B"; std::memcpy(trk_param.signal, sig_, 3); int cn0_samples = configuration->property(role + ".cn0_samples", 20); - if (FLAGS_cn0_samples != 20) cn0_samples = FLAGS_cn0_samples; + if (FLAGS_cn0_samples != 20) + { + cn0_samples = FLAGS_cn0_samples; + } trk_param.cn0_samples = cn0_samples; int cn0_min = configuration->property(role + ".cn0_min", 25); - if (FLAGS_cn0_min != 25) cn0_min = FLAGS_cn0_min; + if (FLAGS_cn0_min != 25) + { + cn0_min = FLAGS_cn0_min; + } trk_param.cn0_min = cn0_min; int max_lock_fail = configuration->property(role + ".max_lock_fail", 50); - if (FLAGS_max_lock_fail != 50) max_lock_fail = FLAGS_max_lock_fail; + if (FLAGS_max_lock_fail != 50) + { + max_lock_fail = FLAGS_max_lock_fail; + } trk_param.max_lock_fail = max_lock_fail; double carrier_lock_th = configuration->property(role + ".carrier_lock_th", 0.85); - if (FLAGS_carrier_lock_th != 0.85) carrier_lock_th = FLAGS_carrier_lock_th; + if (FLAGS_carrier_lock_th != 0.85) + { + carrier_lock_th = FLAGS_carrier_lock_th; + } trk_param.carrier_lock_th = carrier_lock_th; //################# MAKE TRACKING GNURadio object ################### diff --git a/src/algorithms/tracking/adapters/galileo_e1_tcp_connector_tracking.cc b/src/algorithms/tracking/adapters/galileo_e1_tcp_connector_tracking.cc index f95f76200..358e952c9 100644 --- a/src/algorithms/tracking/adapters/galileo_e1_tcp_connector_tracking.cc +++ b/src/algorithms/tracking/adapters/galileo_e1_tcp_connector_tracking.cc @@ -68,9 +68,15 @@ GalileoE1TcpConnectorTracking::GalileoE1TcpConnectorTracking( fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); dump = configuration->property(role + ".dump", false); pll_bw_hz = configuration->property(role + ".pll_bw_hz", 50.0); - if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + if (FLAGS_pll_bw_hz != 0.0) + { + pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + } dll_bw_hz = configuration->property(role + ".dll_bw_hz", 2.0); - if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.15); very_early_late_space_chips = configuration->property(role + ".very_early_late_space_chips", 0.6); port_ch0 = configuration->property(role + ".port_ch0", 2060); diff --git a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking.cc b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking.cc index b0e0a0730..78a497755 100644 --- a/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking.cc +++ b/src/algorithms/tracking/adapters/galileo_e5a_dll_pll_tracking.cc @@ -76,10 +76,16 @@ GalileoE5aDllPllTracking::GalileoE5aDllPllTracking( trk_param.smoother_length = configuration->property(role + ".smoother_length", 10); } float pll_bw_hz = configuration->property(role + ".pll_bw_hz", 20.0); - if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + if (FLAGS_pll_bw_hz != 0.0) + { + pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + } trk_param.pll_bw_hz = pll_bw_hz; float dll_bw_hz = configuration->property(role + ".dll_bw_hz", 20.0); - if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } trk_param.dll_bw_hz = dll_bw_hz; float pll_bw_narrow_hz = configuration->property(role + ".pll_bw_narrow_hz", 5.0); trk_param.pll_bw_narrow_hz = pll_bw_narrow_hz; @@ -115,16 +121,28 @@ GalileoE5aDllPllTracking::GalileoE5aDllPllTracking( char sig_[3] = "5X"; std::memcpy(trk_param.signal, sig_, 3); int cn0_samples = configuration->property(role + ".cn0_samples", 20); - if (FLAGS_cn0_samples != 20) cn0_samples = FLAGS_cn0_samples; + if (FLAGS_cn0_samples != 20) + { + cn0_samples = FLAGS_cn0_samples; + } trk_param.cn0_samples = cn0_samples; int cn0_min = configuration->property(role + ".cn0_min", 25); - if (FLAGS_cn0_min != 25) cn0_min = FLAGS_cn0_min; + if (FLAGS_cn0_min != 25) + { + cn0_min = FLAGS_cn0_min; + } trk_param.cn0_min = cn0_min; int max_lock_fail = configuration->property(role + ".max_lock_fail", 50); - if (FLAGS_max_lock_fail != 50) max_lock_fail = FLAGS_max_lock_fail; + if (FLAGS_max_lock_fail != 50) + { + max_lock_fail = FLAGS_max_lock_fail; + } trk_param.max_lock_fail = max_lock_fail; double carrier_lock_th = configuration->property(role + ".carrier_lock_th", 0.85); - if (FLAGS_carrier_lock_th != 0.85) carrier_lock_th = FLAGS_carrier_lock_th; + if (FLAGS_carrier_lock_th != 0.85) + { + carrier_lock_th = FLAGS_carrier_lock_th; + } trk_param.carrier_lock_th = carrier_lock_th; //################# MAKE TRACKING GNURadio object ################### diff --git a/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_c_aid_tracking.cc b/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_c_aid_tracking.cc index 30101a0ff..e3ca80dbe 100644 --- a/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_c_aid_tracking.cc +++ b/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_c_aid_tracking.cc @@ -69,9 +69,15 @@ GlonassL1CaDllPllCAidTracking::GlonassL1CaDllPllCAidTracking( fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); dump = configuration->property(role + ".dump", false); pll_bw_hz = configuration->property(role + ".pll_bw_hz", 50.0); - if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + if (FLAGS_pll_bw_hz != 0.0) + { + pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + } dll_bw_hz = configuration->property(role + ".dll_bw_hz", 2.0); - if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } pll_bw_narrow_hz = configuration->property(role + ".pll_bw_narrow_hz", 20.0); dll_bw_narrow_hz = configuration->property(role + ".dll_bw_narrow_hz", 2.0); int extend_correlation_ms; diff --git a/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_tracking.cc b/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_tracking.cc index a96165d47..406271643 100644 --- a/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_tracking.cc +++ b/src/algorithms/tracking/adapters/glonass_l1_ca_dll_pll_tracking.cc @@ -66,9 +66,15 @@ GlonassL1CaDllPllTracking::GlonassL1CaDllPllTracking( fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); dump = configuration->property(role + ".dump", false); pll_bw_hz = configuration->property(role + ".pll_bw_hz", 50.0); - if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + if (FLAGS_pll_bw_hz != 0.0) + { + pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + } dll_bw_hz = configuration->property(role + ".dll_bw_hz", 2.0); - if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5); std::string default_dump_filename = "./track_ch"; dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); diff --git a/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_c_aid_tracking.cc b/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_c_aid_tracking.cc index 4ddff7163..419ccc462 100644 --- a/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_c_aid_tracking.cc +++ b/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_c_aid_tracking.cc @@ -67,9 +67,15 @@ GlonassL2CaDllPllCAidTracking::GlonassL2CaDllPllCAidTracking( fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); dump = configuration->property(role + ".dump", false); pll_bw_hz = configuration->property(role + ".pll_bw_hz", 50.0); - if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + if (FLAGS_pll_bw_hz != 0.0) + { + pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + } dll_bw_hz = configuration->property(role + ".dll_bw_hz", 2.0); - if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } pll_bw_narrow_hz = configuration->property(role + ".pll_bw_narrow_hz", 20.0); dll_bw_narrow_hz = configuration->property(role + ".dll_bw_narrow_hz", 2.0); int extend_correlation_ms; diff --git a/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_tracking.cc b/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_tracking.cc index 3c39300af..1e7ded9da 100644 --- a/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_tracking.cc +++ b/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_tracking.cc @@ -64,9 +64,15 @@ GlonassL2CaDllPllTracking::GlonassL2CaDllPllTracking( fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); dump = configuration->property(role + ".dump", false); pll_bw_hz = configuration->property(role + ".pll_bw_hz", 50.0); - if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + if (FLAGS_pll_bw_hz != 0.0) + { + pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + } dll_bw_hz = configuration->property(role + ".dll_bw_hz", 2.0); - if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5); std::string default_dump_filename = "./track_ch"; dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_c_aid_tracking.cc b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_c_aid_tracking.cc index 899e878e2..5531be4e0 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_c_aid_tracking.cc +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_c_aid_tracking.cc @@ -68,9 +68,15 @@ GpsL1CaDllPllCAidTracking::GpsL1CaDllPllCAidTracking( fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); dump = configuration->property(role + ".dump", false); pll_bw_hz = configuration->property(role + ".pll_bw_hz", 50.0); - if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + if (FLAGS_pll_bw_hz != 0.0) + { + pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + } dll_bw_hz = configuration->property(role + ".dll_bw_hz", 2.0); - if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } pll_bw_narrow_hz = configuration->property(role + ".pll_bw_narrow_hz", 20.0); dll_bw_narrow_hz = configuration->property(role + ".dll_bw_narrow_hz", 2.0); int extend_correlation_ms; diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking.cc b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking.cc index 394574667..83a60b49a 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking.cc +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking.cc @@ -76,14 +76,20 @@ GpsL1CaDllPllTracking::GpsL1CaDllPllTracking( bool dump_mat = configuration->property(role + ".dump_mat", true); trk_param.dump_mat = dump_mat; float pll_bw_hz = configuration->property(role + ".pll_bw_hz", 50.0); - if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + if (FLAGS_pll_bw_hz != 0.0) + { + pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + } trk_param.pll_bw_hz = pll_bw_hz; float pll_bw_narrow_hz = configuration->property(role + ".pll_bw_narrow_hz", 20.0); trk_param.pll_bw_narrow_hz = pll_bw_narrow_hz; float dll_bw_narrow_hz = configuration->property(role + ".dll_bw_narrow_hz", 2.0); trk_param.dll_bw_narrow_hz = dll_bw_narrow_hz; float dll_bw_hz = configuration->property(role + ".dll_bw_hz", 2.0); - if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } trk_param.dll_bw_hz = dll_bw_hz; float early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5); trk_param.early_late_space_chips = early_late_space_chips; @@ -119,16 +125,28 @@ GpsL1CaDllPllTracking::GpsL1CaDllPllTracking( char sig_[3] = "1C"; std::memcpy(trk_param.signal, sig_, 3); int cn0_samples = configuration->property(role + ".cn0_samples", 20); - if (FLAGS_cn0_samples != 20) cn0_samples = FLAGS_cn0_samples; + if (FLAGS_cn0_samples != 20) + { + cn0_samples = FLAGS_cn0_samples; + } trk_param.cn0_samples = cn0_samples; int cn0_min = configuration->property(role + ".cn0_min", 30); - if (FLAGS_cn0_min != 25) cn0_min = FLAGS_cn0_min; + if (FLAGS_cn0_min != 25) + { + cn0_min = FLAGS_cn0_min; + } trk_param.cn0_min = cn0_min; int max_lock_fail = configuration->property(role + ".max_lock_fail", 50); - if (FLAGS_max_lock_fail != 50) max_lock_fail = FLAGS_max_lock_fail; + if (FLAGS_max_lock_fail != 50) + { + max_lock_fail = FLAGS_max_lock_fail; + } trk_param.max_lock_fail = max_lock_fail; double carrier_lock_th = configuration->property(role + ".carrier_lock_th", 0.80); - if (FLAGS_carrier_lock_th != 0.85) carrier_lock_th = FLAGS_carrier_lock_th; + if (FLAGS_carrier_lock_th != 0.85) + { + carrier_lock_th = FLAGS_carrier_lock_th; + } trk_param.carrier_lock_th = carrier_lock_th; //################# MAKE TRACKING GNURadio object ################### diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_kf_tracking.cc b/src/algorithms/tracking/adapters/gps_l1_ca_kf_tracking.cc index e0960758f..b10cecafd 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_kf_tracking.cc +++ b/src/algorithms/tracking/adapters/gps_l1_ca_kf_tracking.cc @@ -77,7 +77,10 @@ GpsL1CaKfTracking::GpsL1CaKfTracking( f_if = configuration->property(role + ".if", 0); dump = configuration->property(role + ".dump", false); dll_bw_hz = configuration->property(role + ".dll_bw_hz", 2.0); - if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5); std::string default_dump_filename = "./track_ch"; dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); diff --git a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking.cc b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking.cc index 332b7b9c2..c55191bd2 100644 --- a/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking.cc +++ b/src/algorithms/tracking/adapters/gps_l2_m_dll_pll_tracking.cc @@ -66,10 +66,16 @@ GpsL2MDllPllTracking::GpsL2MDllPllTracking( bool dump_mat = configuration->property(role + ".dump_mat", true); trk_param.dump_mat = dump_mat; float pll_bw_hz = configuration->property(role + ".pll_bw_hz", 2.0); - if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + if (FLAGS_pll_bw_hz != 0.0) + { + pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + } trk_param.pll_bw_hz = pll_bw_hz; float dll_bw_hz = configuration->property(role + ".dll_bw_hz", 0.75); - if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } trk_param.dll_bw_hz = dll_bw_hz; float early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5); trk_param.early_late_space_chips = early_late_space_chips; @@ -96,16 +102,28 @@ GpsL2MDllPllTracking::GpsL2MDllPllTracking( char sig_[3] = "2S"; std::memcpy(trk_param.signal, sig_, 3); int cn0_samples = configuration->property(role + ".cn0_samples", 20); - if (FLAGS_cn0_samples != 20) cn0_samples = FLAGS_cn0_samples; + if (FLAGS_cn0_samples != 20) + { + cn0_samples = FLAGS_cn0_samples; + } trk_param.cn0_samples = cn0_samples; int cn0_min = configuration->property(role + ".cn0_min", 25); - if (FLAGS_cn0_min != 25) cn0_min = FLAGS_cn0_min; + if (FLAGS_cn0_min != 25) + { + cn0_min = FLAGS_cn0_min; + } trk_param.cn0_min = cn0_min; int max_lock_fail = configuration->property(role + ".max_lock_fail", 50); - if (FLAGS_max_lock_fail != 50) max_lock_fail = FLAGS_max_lock_fail; + if (FLAGS_max_lock_fail != 50) + { + max_lock_fail = FLAGS_max_lock_fail; + } trk_param.max_lock_fail = max_lock_fail; double carrier_lock_th = configuration->property(role + ".carrier_lock_th", 0.85); - if (FLAGS_carrier_lock_th != 0.85) carrier_lock_th = FLAGS_carrier_lock_th; + if (FLAGS_carrier_lock_th != 0.85) + { + carrier_lock_th = FLAGS_carrier_lock_th; + } trk_param.carrier_lock_th = carrier_lock_th; //################# MAKE TRACKING GNURadio object ################### diff --git a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking.cc b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking.cc index c471f98b8..f0fbcd37a 100644 --- a/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking.cc +++ b/src/algorithms/tracking/adapters/gps_l5_dll_pll_tracking.cc @@ -76,10 +76,16 @@ GpsL5DllPllTracking::GpsL5DllPllTracking( trk_param.smoother_length = configuration->property(role + ".smoother_length", 10); } float pll_bw_hz = configuration->property(role + ".pll_bw_hz", 50.0); - if (FLAGS_pll_bw_hz != 0.0) pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + if (FLAGS_pll_bw_hz != 0.0) + { + pll_bw_hz = static_cast(FLAGS_pll_bw_hz); + } trk_param.pll_bw_hz = pll_bw_hz; float dll_bw_hz = configuration->property(role + ".dll_bw_hz", 2.0); - if (FLAGS_dll_bw_hz != 0.0) dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + if (FLAGS_dll_bw_hz != 0.0) + { + dll_bw_hz = static_cast(FLAGS_dll_bw_hz); + } trk_param.dll_bw_hz = dll_bw_hz; float pll_bw_narrow_hz = configuration->property(role + ".pll_bw_narrow_hz", 2.0); trk_param.pll_bw_narrow_hz = pll_bw_narrow_hz; @@ -115,16 +121,28 @@ GpsL5DllPllTracking::GpsL5DllPllTracking( char sig_[3] = "L5"; std::memcpy(trk_param.signal, sig_, 3); int cn0_samples = configuration->property(role + ".cn0_samples", 20); - if (FLAGS_cn0_samples != 20) cn0_samples = FLAGS_cn0_samples; + if (FLAGS_cn0_samples != 20) + { + cn0_samples = FLAGS_cn0_samples; + } trk_param.cn0_samples = cn0_samples; int cn0_min = configuration->property(role + ".cn0_min", 25); - if (FLAGS_cn0_min != 25) cn0_min = FLAGS_cn0_min; + if (FLAGS_cn0_min != 25) + { + cn0_min = FLAGS_cn0_min; + } trk_param.cn0_min = cn0_min; int max_lock_fail = configuration->property(role + ".max_lock_fail", 50); - if (FLAGS_max_lock_fail != 50) max_lock_fail = FLAGS_max_lock_fail; + if (FLAGS_max_lock_fail != 50) + { + max_lock_fail = FLAGS_max_lock_fail; + } trk_param.max_lock_fail = max_lock_fail; double carrier_lock_th = configuration->property(role + ".carrier_lock_th", 0.75); - if (FLAGS_carrier_lock_th != 0.85) carrier_lock_th = FLAGS_carrier_lock_th; + if (FLAGS_carrier_lock_th != 0.85) + { + carrier_lock_th = FLAGS_carrier_lock_th; + } trk_param.carrier_lock_th = carrier_lock_th; //################# MAKE TRACKING GNURadio object ################### diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc index a42e85d15..518e5dfda 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc @@ -764,7 +764,10 @@ bool dll_pll_veml_tracking::cn0_and_tracking_lock_status(double coh_integration_ } else { - if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; + if (d_carrier_lock_fail_counter > 0) + { + d_carrier_lock_fail_counter--; + } } if (d_carrier_lock_fail_counter > trk_parameters.max_lock_fail) { @@ -853,7 +856,10 @@ void dll_pll_veml_tracking::run_dll_pll() void dll_pll_veml_tracking::clear_tracking_vars() { std::fill_n(d_correlator_outs, d_n_correlator_taps, gr_complex(0.0, 0.0)); - if (trk_parameters.track_pilot) d_Prompt_Data[0] = gr_complex(0.0, 0.0); + if (trk_parameters.track_pilot) + { + d_Prompt_Data[0] = gr_complex(0.0, 0.0); + } d_carr_error_hz = 0.0; d_carr_error_filt_hz = 0.0; d_code_error_chips = 0.0; @@ -989,9 +995,13 @@ void dll_pll_veml_tracking::save_correlation_results() } // If tracking pilot, disable Costas loop if (trk_parameters.track_pilot) - d_cloop = false; + { + d_cloop = false; + } else - d_cloop = true; + { + d_cloop = true; + } } diff --git a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc index 6d410efe1..641dcf248 100644 --- a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_tcp_connector_tracking_cc.cc @@ -425,7 +425,10 @@ int Galileo_E1_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attri } else { - if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; + if (d_carrier_lock_fail_counter > 0) + { + d_carrier_lock_fail_counter--; + } } if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) { diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc index 73a5f8604..b422fa6ec 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc @@ -74,7 +74,7 @@ glonass_l1_ca_dll_pll_c_aid_make_tracking_cc( float early_late_space_chips) { return glonass_l1_ca_dll_pll_c_aid_tracking_cc_sptr(new glonass_l1_ca_dll_pll_c_aid_tracking_cc( - fs_in, vector_length, dump, std::move(dump_filename), pll_bw_hz, dll_bw_hz, pll_bw_narrow_hz, dll_bw_narrow_hz, extend_correlation_ms, early_late_space_chips)); + fs_in, vector_length, dump, dump_filename, pll_bw_hz, dll_bw_hz, pll_bw_narrow_hz, dll_bw_narrow_hz, extend_correlation_ms, early_late_space_chips)); } @@ -94,7 +94,7 @@ void glonass_l1_ca_dll_pll_c_aid_tracking_cc::msg_handler_preamble_index(pmt::pm DLOG(INFO) << "Extended correlation enabled for Tracking CH " << d_channel << ": Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN); if (d_enable_extended_integration == false) //avoid re-setting preamble indicator { - d_preamble_timestamp_s = pmt::to_double(std::move(msg)); + d_preamble_timestamp_s = pmt::to_double(msg); d_enable_extended_integration = true; d_preamble_synchronized = false; } @@ -125,7 +125,7 @@ glonass_l1_ca_dll_pll_c_aid_tracking_cc::glonass_l1_ca_dll_pll_c_aid_tracking_cc d_dump = dump; d_fs_in = fs_in; d_vector_length = vector_length; - d_dump_filename = std::move(dump_filename); + d_dump_filename = dump_filename; d_correlation_length_samples = static_cast(d_vector_length); // Initialize tracking ========================================== @@ -808,7 +808,10 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at } else { - if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; + if (d_carrier_lock_fail_counter > 0) + { + d_carrier_lock_fail_counter--; + } } if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) { diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc index a9f9402b8..3e0338be2 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc @@ -798,7 +798,10 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at } else { - if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; + if (d_carrier_lock_fail_counter > 0) + { + d_carrier_lock_fail_counter--; + } } if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) { diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.cc index 0bd9553c6..3df2c07f6 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_tracking_cc.cc @@ -68,7 +68,7 @@ glonass_l1_ca_dll_pll_make_tracking_cc( float early_late_space_chips) { return glonass_l1_ca_dll_pll_tracking_cc_sptr(new Glonass_L1_Ca_Dll_Pll_Tracking_cc( - fs_in, vector_length, dump, std::move(dump_filename), pll_bw_hz, dll_bw_hz, early_late_space_chips)); + fs_in, vector_length, dump, dump_filename, pll_bw_hz, dll_bw_hz, early_late_space_chips)); } @@ -98,7 +98,7 @@ Glonass_L1_Ca_Dll_Pll_Tracking_cc::Glonass_L1_Ca_Dll_Pll_Tracking_cc( d_dump = dump; d_fs_in = fs_in; d_vector_length = vector_length; - d_dump_filename = std::move(dump_filename); + d_dump_filename = dump_filename; d_current_prn_length_samples = static_cast(d_vector_length); @@ -667,7 +667,10 @@ int Glonass_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut } else { - if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; + if (d_carrier_lock_fail_counter > 0) + { + d_carrier_lock_fail_counter--; + } } if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) { diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc index ac85df763..b31f4167b 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc @@ -71,7 +71,7 @@ glonass_l2_ca_dll_pll_c_aid_make_tracking_cc( float early_late_space_chips) { return glonass_l2_ca_dll_pll_c_aid_tracking_cc_sptr(new glonass_l2_ca_dll_pll_c_aid_tracking_cc( - fs_in, vector_length, dump, std::move(dump_filename), pll_bw_hz, dll_bw_hz, pll_bw_narrow_hz, dll_bw_narrow_hz, extend_correlation_ms, early_late_space_chips)); + fs_in, vector_length, dump, dump_filename, pll_bw_hz, dll_bw_hz, pll_bw_narrow_hz, dll_bw_narrow_hz, extend_correlation_ms, early_late_space_chips)); } @@ -91,7 +91,7 @@ void glonass_l2_ca_dll_pll_c_aid_tracking_cc::msg_handler_preamble_index(pmt::pm DLOG(INFO) << "Extended correlation enabled for Tracking CH " << d_channel << ": Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN); if (d_enable_extended_integration == false) //avoid re-setting preamble indicator { - d_preamble_timestamp_s = pmt::to_double(std::move(msg)); + d_preamble_timestamp_s = pmt::to_double(msg); d_enable_extended_integration = true; d_preamble_synchronized = false; } @@ -122,7 +122,7 @@ glonass_l2_ca_dll_pll_c_aid_tracking_cc::glonass_l2_ca_dll_pll_c_aid_tracking_cc d_dump = dump; d_fs_in = fs_in; d_vector_length = vector_length; - d_dump_filename = std::move(dump_filename); + d_dump_filename = dump_filename; d_correlation_length_samples = static_cast(d_vector_length); // Initialize tracking ========================================== @@ -806,7 +806,10 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at } else { - if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; + if (d_carrier_lock_fail_counter > 0) + { + d_carrier_lock_fail_counter--; + } } if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) { diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc index b60aabb3a..aebdf3db7 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc @@ -797,7 +797,10 @@ int glonass_l2_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at } else { - if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; + if (d_carrier_lock_fail_counter > 0) + { + d_carrier_lock_fail_counter--; + } } if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) { diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc index 8b3492978..b5b4dcd3e 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc @@ -68,7 +68,7 @@ glonass_l2_ca_dll_pll_make_tracking_cc( float early_late_space_chips) { return glonass_l2_ca_dll_pll_tracking_cc_sptr(new Glonass_L2_Ca_Dll_Pll_Tracking_cc( - fs_in, vector_length, dump, std::move(dump_filename), pll_bw_hz, dll_bw_hz, early_late_space_chips)); + fs_in, vector_length, dump, dump_filename, pll_bw_hz, dll_bw_hz, early_late_space_chips)); } @@ -98,7 +98,7 @@ Glonass_L2_Ca_Dll_Pll_Tracking_cc::Glonass_L2_Ca_Dll_Pll_Tracking_cc( d_dump = dump; d_fs_in = fs_in; d_vector_length = vector_length; - d_dump_filename = std::move(dump_filename); + d_dump_filename = dump_filename; d_current_prn_length_samples = static_cast(d_vector_length); @@ -667,7 +667,10 @@ int Glonass_L2_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut } else { - if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; + if (d_carrier_lock_fail_counter > 0) + { + d_carrier_lock_fail_counter--; + } } if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) { diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc index eea588de4..aed6b2abc 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_cc.cc @@ -63,7 +63,7 @@ gps_l1_ca_dll_pll_c_aid_make_tracking_cc( float early_late_space_chips) { return gps_l1_ca_dll_pll_c_aid_tracking_cc_sptr(new gps_l1_ca_dll_pll_c_aid_tracking_cc( - fs_in, vector_length, dump, std::move(dump_filename), pll_bw_hz, dll_bw_hz, pll_bw_narrow_hz, dll_bw_narrow_hz, extend_correlation_ms, early_late_space_chips)); + fs_in, vector_length, dump, dump_filename, pll_bw_hz, dll_bw_hz, pll_bw_narrow_hz, dll_bw_narrow_hz, extend_correlation_ms, early_late_space_chips)); } @@ -83,7 +83,7 @@ void gps_l1_ca_dll_pll_c_aid_tracking_cc::msg_handler_preamble_index(pmt::pmt_t DLOG(INFO) << "Extended correlation enabled for Tracking CH " << d_channel << ": Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN); if (d_enable_extended_integration == false) //avoid re-setting preamble indicator { - d_preamble_timestamp_s = pmt::to_double(std::move(msg)); + d_preamble_timestamp_s = pmt::to_double(msg); d_enable_extended_integration = true; d_preamble_synchronized = false; } @@ -114,7 +114,7 @@ gps_l1_ca_dll_pll_c_aid_tracking_cc::gps_l1_ca_dll_pll_c_aid_tracking_cc( d_dump = dump; d_fs_in = fs_in; d_vector_length = vector_length; - d_dump_filename = std::move(dump_filename); + d_dump_filename = dump_filename; d_correlation_length_samples = static_cast(d_vector_length); // Initialize tracking ========================================== @@ -787,7 +787,10 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __attrib } else { - if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; + if (d_carrier_lock_fail_counter > 0) + { + d_carrier_lock_fail_counter--; + } } if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) { diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.cc index 6ba84d855..8a3dd9a7d 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_sc.cc @@ -788,7 +788,10 @@ int gps_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __attrib } else { - if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; + if (d_carrier_lock_fail_counter > 0) + { + d_carrier_lock_fail_counter--; + } } if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) { diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.cc index d5a6cb62f..8ddf18102 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_kf_tracking_cc.cc @@ -74,7 +74,7 @@ gps_l1_ca_kf_make_tracking_cc( int32_t bce_kappa) { return gps_l1_ca_kf_tracking_cc_sptr(new Gps_L1_Ca_Kf_Tracking_cc(order, if_freq, - fs_in, vector_length, dump, std::move(dump_filename), dll_bw_hz, early_late_space_chips, + fs_in, vector_length, dump, dump_filename, dll_bw_hz, early_late_space_chips, bce_run, bce_ptrans, bce_strans, bce_nu, bce_kappa)); } @@ -115,7 +115,7 @@ Gps_L1_Ca_Kf_Tracking_cc::Gps_L1_Ca_Kf_Tracking_cc( d_if_freq = if_freq; d_fs_in = fs_in; d_vector_length = vector_length; - d_dump_filename = std::move(dump_filename); + d_dump_filename = dump_filename; d_current_prn_length_samples = static_cast(d_vector_length); @@ -850,7 +850,10 @@ int Gps_L1_Ca_Kf_Tracking_cc::general_work(int noutput_items __attribute__((unus } else { - if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; + if (d_carrier_lock_fail_counter > 0) + { + d_carrier_lock_fail_counter--; + } } if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) { diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc index cf5cb96a2..2912e8e2c 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_tcp_connector_tracking_cc.cc @@ -461,7 +461,10 @@ int Gps_L1_Ca_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attrib } else { - if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; + if (d_carrier_lock_fail_counter > 0) + { + d_carrier_lock_fail_counter--; + } } if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) { diff --git a/src/core/libs/INIReader.cc b/src/core/libs/INIReader.cc index 9ca9dd039..63c076b82 100644 --- a/src/core/libs/INIReader.cc +++ b/src/core/libs/INIReader.cc @@ -87,7 +87,9 @@ std::string INIReader::MakeKey(const std::string& section, const std::string& na std::string key = section + "." + name; // Convert to lower case to make lookups case-insensitive for (char& i : key) - i = tolower(i); + { + i = tolower(i); + } return key; } diff --git a/src/core/libs/ini.cc b/src/core/libs/ini.cc index 49991e57f..17506e56e 100644 --- a/src/core/libs/ini.cc +++ b/src/core/libs/ini.cc @@ -68,7 +68,9 @@ static char* rstrip(char* s) { char* p = s + std::char_traits::length(s); while (p > s && isspace(*--p)) - *p = '\0'; + { + *p = '\0'; + } return s; } @@ -76,7 +78,9 @@ static char* rstrip(char* s) static char* lskip(char* s) { while (*s && isspace(*s)) - s++; + { + s++; + } return static_cast(s); } @@ -85,7 +89,9 @@ static char* lskip(char* s) static char* find_char_or_comment(char* s, char c) { while (*s && *s != c && *s != ';') - s++; + { + s++; + } return static_cast(s); } @@ -121,7 +127,9 @@ int ini_parse(const char* filename, file.open(filename, std::fstream::in); if (!file.is_open()) - return -1; + { + return -1; + } /* Scan through file line by line */ while (std::getline(file, line_str)) @@ -129,7 +137,10 @@ int ini_parse(const char* filename, lineno++; int len_str = line_str.length(); const char* read_line = line_str.data(); - if (len_str > (MAX_LINE - 1)) len_str = MAX_LINE - 1; + if (len_str > (MAX_LINE - 1)) + { + len_str = MAX_LINE - 1; + } int i; for (i = 0; i < len_str; i++) { @@ -144,7 +155,9 @@ int ini_parse(const char* filename, /* Non-black line with leading whitespace, treat as continuation of previous name's value (as per Python ConfigParser). */ if (!handler(user, section, prev_name, start) && !error) - error = lineno; + { + error = lineno; + } } else #endif @@ -175,13 +188,17 @@ int ini_parse(const char* filename, value = lskip(end + 1); end = find_char_or_comment(value, ';'); if (*end == ';') - *end = '\0'; + { + *end = '\0'; + } rstrip(value); /* Valid name=value pair found, call handler */ strncpy0(prev_name, name, sizeof(prev_name)); if (!handler(user, section, name, value) && !error) - error = lineno; + { + error = lineno; + } } else if (!error) { diff --git a/src/core/libs/supl/supl.c b/src/core/libs/supl/supl.c index 3722d1af0..0184f35ac 100644 --- a/src/core/libs/supl/supl.c +++ b/src/core/libs/supl/supl.c @@ -9,29 +9,29 @@ */ #include "supl.h" -#include +#include #include #include -#include +#include +#include +#include +#include #include #include -#include -#include -#include - #define PARAM_GSM_CELL_CURRENT 1 #define PARAM_GSM_CELL_KNOWN 2 #define PARAM_WCDMA_CELL_CURRENT 4 -#define OPTIONAL_MISSING ((void*)0) +#define OPTIONAL_MISSING ((void *)0) #ifdef SUPL_DEBUG -static struct supl_debug_s { - FILE *log; - int verbose_rrlp, verbose_supl, debug; - int sent,recv, out_msg, in_msg; +static struct supl_debug_s +{ + FILE *log; + int verbose_rrlp, verbose_supl, debug; + int sent, recv, out_msg, in_msg; } debug; #endif @@ -42,201 +42,242 @@ static int pdu_make_ulp_rrlp_ack(supl_ctx_t *ctx, supl_ulp_t *pdu, PDU_t *rrlp); static int supl_more_rrlp(PDU_t *rrlp); static int supl_response_harvest(supl_ctx_t *ctx, supl_ulp_t *pdu); -int EXPORT supl_ulp_decode(supl_ulp_t *pdu) { - ULP_PDU_t *ulp; - asn_codec_ctx_t ctx; - asn_dec_rval_t rval; +int EXPORT supl_ulp_decode(supl_ulp_t *pdu) +{ + ULP_PDU_t *ulp; + asn_codec_ctx_t ctx; + asn_dec_rval_t rval; - ulp = calloc(1, sizeof(ULP_PDU_t)); - pdu->pdu = ulp; + ulp = calloc(1, sizeof(ULP_PDU_t)); + pdu->pdu = ulp; - ctx.max_stack_size = 0; - rval = uper_decode_complete(&ctx, &asn_DEF_ULP_PDU, (void **)&ulp, pdu->buffer, pdu->size); - if (rval.code == RC_OK) { - return 0; - } + ctx.max_stack_size = 0; + rval = uper_decode_complete(&ctx, &asn_DEF_ULP_PDU, (void **)&ulp, pdu->buffer, pdu->size); + if (rval.code == RC_OK) + { + return 0; + } - free(ulp); - pdu->pdu = 0; + free(ulp); + pdu->pdu = 0; - return E_SUPL_DECODE; + return E_SUPL_DECODE; } -int EXPORT supl_ulp_encode(supl_ulp_t *pdu) { - asn_enc_rval_t ret; - int pdu_len; - ret = uper_encode_to_buffer(&asn_DEF_ULP_PDU, pdu->pdu, pdu->buffer, sizeof(pdu->buffer)); - if (ret.encoded != -1) { - memset(pdu->buffer, 0, sizeof(pdu->buffer)); - - pdu_len = (ret.encoded + 7) >> 3; - ((ULP_PDU_t *)pdu->pdu)->length = pdu_len; +int EXPORT supl_ulp_encode(supl_ulp_t *pdu) +{ + asn_enc_rval_t ret; + int pdu_len; ret = uper_encode_to_buffer(&asn_DEF_ULP_PDU, pdu->pdu, pdu->buffer, sizeof(pdu->buffer)); - if (ret.encoded > 0) { - int len = (ret.encoded + 7) >> 3; + if (ret.encoded != -1) + { + memset(pdu->buffer, 0, sizeof(pdu->buffer)); - if (len == pdu_len) { - pdu->size = pdu_len; - return 0; - } - } - } + pdu_len = (ret.encoded + 7) >> 3; + ((ULP_PDU_t *)pdu->pdu)->length = pdu_len; - return E_SUPL_ENCODE; + ret = uper_encode_to_buffer(&asn_DEF_ULP_PDU, pdu->pdu, pdu->buffer, sizeof(pdu->buffer)); + if (ret.encoded > 0) + { + int len = (ret.encoded + 7) >> 3; + + if (len == pdu_len) + { + pdu->size = pdu_len; + return 0; + } + } + } + + return E_SUPL_ENCODE; } -void EXPORT supl_ulp_free(supl_ulp_t *pdu) { - asn_DEF_ULP_PDU.free_struct(&asn_DEF_ULP_PDU, pdu->pdu, 0); + +void EXPORT supl_ulp_free(supl_ulp_t *pdu) +{ + asn_DEF_ULP_PDU.free_struct(&asn_DEF_ULP_PDU, pdu->pdu, 0); } -int EXPORT supl_ulp_send(supl_ctx_t *ctx, supl_ulp_t *pdu) { - int err; + +int EXPORT supl_ulp_send(supl_ctx_t *ctx, supl_ulp_t *pdu) +{ + int err; #if SUPL_DEBUG - if (debug.verbose_supl) { - fprintf(debug.log, "Send %lu bytes\n", pdu->size); - xer_fprint(debug.log, &asn_DEF_ULP_PDU, pdu->pdu); - } + if (debug.verbose_supl) + { + fprintf(debug.log, "Send %lu bytes\n", pdu->size); + xer_fprint(debug.log, &asn_DEF_ULP_PDU, pdu->pdu); + } #endif - err = SSL_write(ctx->ssl, pdu->buffer, pdu->size); - if (err <= 0) { + err = SSL_write(ctx->ssl, pdu->buffer, pdu->size); + if (err <= 0) + { #if SUPL_DEBUG - if (debug.debug) fprintf(debug.log, "Error: SSL_write error: %s\n", strerror(errno)); + if (debug.debug) fprintf(debug.log, "Error: SSL_write error: %s\n", strerror(errno)); #endif - return E_SUPL_WRITE; - } + return E_SUPL_WRITE; + } #ifdef SUPL_DEBUG - debug.sent += pdu->size; - debug.out_msg++; + debug.sent += pdu->size; + debug.out_msg++; #endif - return 0; -} - -int EXPORT supl_ulp_recv(supl_ctx_t *ctx, supl_ulp_t *pdu) { - int err; - int n; - asn_dec_rval_t rval; - ULP_PDU_t *length; - - err = SSL_read(ctx->ssl, pdu->buffer, sizeof(pdu->buffer)); - if (err <= 0) { -#ifdef SUPL_DEBUG - if (debug.debug) fprintf(debug.log, "Error: SSL_read error: %s\n", strerror(errno)); -#endif - return E_SUPL_READ; - } - n = err; - - length = calloc(1, sizeof(ULP_PDU_t)); - // decode the very first bytes of the ULP_PDU message, just enough to the get message length - rval = uper_decode_complete(0, &asn_DEF_ULP_PDU, (void **)&length, pdu->buffer, n < 6 ? n : 6); - if (rval.code == RC_WMORE) { - // read the missing data - for (n = err; n < length->length; n += err) { -#ifdef SUPL_DEBUG - if (debug.debug) fprintf(debug.log, "SSL_read got %u bytes (total %lu)\n", n, length->length); -#endif - err = SSL_read(ctx->ssl, &pdu->buffer[n], sizeof(pdu->buffer)-n); - if (err <= 0) { -#ifdef SUPL_DEBUG - if (debug.debug) fprintf(debug.log, "Error: SSL_read (again) error: %s\n", strerror(errno)); -#endif - return E_SUPL_READ; - } - } - } - - asn_DEF_ULP_PDU.free_struct(&asn_DEF_ULP_PDU, length, 0); - - pdu->size = n; - - if (supl_ulp_decode(pdu)) { - return E_SUPL_DECODE; - } - -#ifdef SUPL_DEBUG - if (debug.verbose_supl) { - fprintf(debug.log, "Recv %lu bytes\n", pdu->size); - xer_fprint(debug.log, &asn_DEF_ULP_PDU, pdu->pdu); - } -#endif - -#ifdef SUPL_DEBUG - debug.recv += err; - debug.in_msg++; -#endif - - return 0; -} - -int EXPORT supl_decode_rrlp(supl_ulp_t *ulp_pdu, PDU_t **ret_rrlp) { - asn_dec_rval_t rval; - OCTET_STRING_t *rrlp_pdu; - PDU_t *rrlp; - ULP_PDU_t *ulp; - - ulp = ulp_pdu->pdu; - - if (!(ulp->message.present == UlpMessage_PR_msSUPLPOS && - ulp->message.choice.msSUPLPOS.posPayLoad.present == PosPayLoad_PR_rrlpPayload)) { return 0; - } - rrlp_pdu = &ulp->message.choice.msSUPLPOS.posPayLoad.choice.rrlpPayload; - - rrlp = calloc(1, sizeof(PDU_t)); - rval = uper_decode_complete(0, &asn_DEF_PDU, (void **)&rrlp, rrlp_pdu->buf, rrlp_pdu->size); - switch (rval.code) { - case RC_OK: -#ifdef SUPL_DEBUG - if (rval.consumed != rrlp_pdu->size) { - if (debug.debug) fprintf(debug.log, "Warning: %lu bytes left over in RRLP decoding\n", rval.consumed); - } -#endif - - *ret_rrlp = rrlp; - return 0; - - case RC_WMORE: - asn_DEF_PDU.free_struct(&asn_DEF_PDU, rrlp, 0); - ret_rrlp = 0; - return E_SUPL_DECODE_RRLP; - - default: - asn_DEF_PDU.free_struct(&asn_DEF_PDU, rrlp, 0); - ret_rrlp = 0; - return E_SUPL_DECODE_RRLP; - } - - return E_SUPL_INTERNAL; } -int EXPORT supl_server_connect(supl_ctx_t *ctx, char *server) { - int err; - SSL_METHOD *meth; - SSLeay_add_ssl_algorithms(); - // meth = TLSv1_client_method(); - meth = (SSL_METHOD*)SSLv23_client_method(); - SSL_load_error_strings(); - ctx->ssl_ctx = SSL_CTX_new(meth); - if (!ctx->ssl_ctx) return E_SUPL_CONNECT; +int EXPORT supl_ulp_recv(supl_ctx_t *ctx, supl_ulp_t *pdu) +{ + int err; + int n; + asn_dec_rval_t rval; + ULP_PDU_t *length; - ctx->ssl = SSL_new(ctx->ssl_ctx); - if (!ctx->ssl) return E_SUPL_CONNECT; + err = SSL_read(ctx->ssl, pdu->buffer, sizeof(pdu->buffer)); + if (err <= 0) + { +#ifdef SUPL_DEBUG + if (debug.debug) fprintf(debug.log, "Error: SSL_read error: %s\n", strerror(errno)); +#endif + return E_SUPL_READ; + } + n = err; - if (server) { - ctx->fd = server_connect(server); - if (ctx->fd == -1) return E_SUPL_CONNECT; - } + length = calloc(1, sizeof(ULP_PDU_t)); + // decode the very first bytes of the ULP_PDU message, just enough to the get message length + rval = uper_decode_complete(0, &asn_DEF_ULP_PDU, (void **)&length, pdu->buffer, n < 6 ? n : 6); + if (rval.code == RC_WMORE) + { + // read the missing data + for (n = err; n < length->length; n += err) + { +#ifdef SUPL_DEBUG + if (debug.debug) fprintf(debug.log, "SSL_read got %u bytes (total %lu)\n", n, length->length); +#endif + err = SSL_read(ctx->ssl, &pdu->buffer[n], sizeof(pdu->buffer) - n); + if (err <= 0) + { +#ifdef SUPL_DEBUG + if (debug.debug) fprintf(debug.log, "Error: SSL_read (again) error: %s\n", strerror(errno)); +#endif + return E_SUPL_READ; + } + } + } - SSL_set_fd(ctx->ssl, ctx->fd); - err = SSL_connect(ctx->ssl); - if (err == -1) return E_SUPL_CONNECT; + asn_DEF_ULP_PDU.free_struct(&asn_DEF_ULP_PDU, length, 0); + + pdu->size = n; + + if (supl_ulp_decode(pdu)) + { + return E_SUPL_DECODE; + } + +#ifdef SUPL_DEBUG + if (debug.verbose_supl) + { + fprintf(debug.log, "Recv %lu bytes\n", pdu->size); + xer_fprint(debug.log, &asn_DEF_ULP_PDU, pdu->pdu); + } +#endif + +#ifdef SUPL_DEBUG + debug.recv += err; + debug.in_msg++; +#endif + + return 0; +} + + +int EXPORT supl_decode_rrlp(supl_ulp_t *ulp_pdu, PDU_t **ret_rrlp) +{ + asn_dec_rval_t rval; + OCTET_STRING_t *rrlp_pdu; + PDU_t *rrlp; + ULP_PDU_t *ulp; + + ulp = ulp_pdu->pdu; + + if (!(ulp->message.present == UlpMessage_PR_msSUPLPOS && + ulp->message.choice.msSUPLPOS.posPayLoad.present == PosPayLoad_PR_rrlpPayload)) + { + return 0; + } + rrlp_pdu = &ulp->message.choice.msSUPLPOS.posPayLoad.choice.rrlpPayload; + + rrlp = calloc(1, sizeof(PDU_t)); + rval = uper_decode_complete(0, &asn_DEF_PDU, (void **)&rrlp, rrlp_pdu->buf, rrlp_pdu->size); + switch (rval.code) + { + case RC_OK: +#ifdef SUPL_DEBUG + if (rval.consumed != rrlp_pdu->size) + { + if (debug.debug) fprintf(debug.log, "Warning: %lu bytes left over in RRLP decoding\n", rval.consumed); + } +#endif + + *ret_rrlp = rrlp; + return 0; + + case RC_WMORE: + asn_DEF_PDU.free_struct(&asn_DEF_PDU, rrlp, 0); + ret_rrlp = 0; + return E_SUPL_DECODE_RRLP; + + default: + asn_DEF_PDU.free_struct(&asn_DEF_PDU, rrlp, 0); + ret_rrlp = 0; + return E_SUPL_DECODE_RRLP; + } + + return E_SUPL_INTERNAL; +} + + +int EXPORT supl_server_connect(supl_ctx_t *ctx, char *server) +{ + int err; + SSL_METHOD *meth; + + SSLeay_add_ssl_algorithms(); + // meth = TLSv1_client_method(); + meth = (SSL_METHOD *)SSLv23_client_method(); + SSL_load_error_strings(); + ctx->ssl_ctx = SSL_CTX_new(meth); + if (!ctx->ssl_ctx) + { + return E_SUPL_CONNECT; + } + + ctx->ssl = SSL_new(ctx->ssl_ctx); + if (!ctx->ssl) + { + return E_SUPL_CONNECT; + } + + if (server) + { + ctx->fd = server_connect(server); + if (ctx->fd == -1) + { + return E_SUPL_CONNECT; + } + } + + SSL_set_fd(ctx->ssl, ctx->fd); + err = SSL_connect(ctx->ssl); + if (err == -1) + { + return E_SUPL_CONNECT; + } #if 0 { @@ -249,314 +290,351 @@ int EXPORT supl_server_connect(supl_ctx_t *ctx, char *server) { } #endif - return 0; -} - -void EXPORT supl_close(supl_ctx_t *ctx) { - SSL_shutdown(ctx->ssl); - SSL_free(ctx->ssl); - SSL_CTX_free(ctx->ssl_ctx); - close(ctx->fd); + return 0; } -static int server_connect(char *server) { - int fd = -1; - struct addrinfo *ailist, *aip; - struct addrinfo hint; - int err; - - memset(&hint, 0, sizeof(struct addrinfo)); - hint.ai_socktype = SOCK_STREAM; - err = getaddrinfo(server, SUPL_PORT, &hint, &ailist); - if (err != 0) { - return -1; - } - - for (aip = ailist; aip; aip = aip->ai_next) { - if ((fd = socket(aip->ai_family, SOCK_STREAM, 0)) < 0) { - err = errno; - } - if (connect(fd, aip->ai_addr, aip->ai_addrlen) != 0) { - return -1; - } - break; - } - - return fd; +void EXPORT supl_close(supl_ctx_t *ctx) +{ + SSL_shutdown(ctx->ssl); + SSL_free(ctx->ssl); + SSL_CTX_free(ctx->ssl_ctx); + close(ctx->fd); } -static int pdu_make_ulp_start(supl_ctx_t *ctx, supl_ulp_t *pdu) { - ULP_PDU_t *ulp; - SetSessionID_t *session_id; - int err; - ulp = calloc(1, sizeof(ULP_PDU_t)); - session_id = calloc(1, sizeof(SetSessionID_t)); +static int server_connect(char *server) +{ + int fd = -1; + struct addrinfo *ailist, *aip; + struct addrinfo hint; + int err; - ulp->length = 0; - ulp->version.maj = 1; - ulp->version.min = 0; - ulp->version.servind = 0; + memset(&hint, 0, sizeof(struct addrinfo)); + hint.ai_socktype = SOCK_STREAM; + err = getaddrinfo(server, SUPL_PORT, &hint, &ailist); + if (err != 0) + { + return -1; + } - session_id->sessionId = 1; - // session_id->setId.present = SETId_PR_msisdn; - // (void)OCTET_STRING_fromBuf(&session_id->setId.choice.msisdn, ctx->p.msisdn, 8); - session_id->setId.present = SETId_PR_imsi; - (void)OCTET_STRING_fromBuf(&session_id->setId.choice.imsi, ctx->p.msisdn, 8); + for (aip = ailist; aip; aip = aip->ai_next) + { + if ((fd = socket(aip->ai_family, SOCK_STREAM, 0)) < 0) + { + err = errno; + } + if (connect(fd, aip->ai_addr, aip->ai_addrlen) != 0) + { + return -1; + } + break; + } - ulp->sessionID.setSessionID = session_id; - ulp->sessionID.slpSessionID = OPTIONAL_MISSING; - - ulp->message.present = UlpMessage_PR_msSUPLSTART; - ulp->message.choice.msSUPLSTART.sETCapabilities.posTechnology.agpsSETBased = 1; - // (void)asn_long2INTEGER(&ulp->message.choice.msSUPLSTART.sETCapabilities.prefMethod, PrefMethod_noPreference); - (void)asn_long2INTEGER(&ulp->message.choice.msSUPLSTART.sETCapabilities.prefMethod, PrefMethod_agpsSETBasedPreferred); - ulp->message.choice.msSUPLSTART.sETCapabilities.posProtocol.rrlp = 1; - - if (ctx->p.set & PARAM_GSM_CELL_CURRENT) { - ulp->message.choice.msSUPLSTART.locationId.cellInfo.present = CellInfo_PR_gsmCell; - ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.refMCC = ctx->p.gsm.mcc; - ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.refMNC = ctx->p.gsm.mnc; - ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.refLAC = ctx->p.gsm.lac; - ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.refCI = ctx->p.gsm.ci; - ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.nMR = OPTIONAL_MISSING; - ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.tA = OPTIONAL_MISSING; - } else if (ctx->p.set & PARAM_WCDMA_CELL_CURRENT) { - ulp->message.choice.msSUPLSTART.locationId.cellInfo.present = CellInfo_PR_wcdmaCell; - ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.wcdmaCell.refMCC = ctx->p.wcdma.mcc; - ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.wcdmaCell.refMNC = ctx->p.wcdma.mnc; - ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.wcdmaCell.refUC = ctx->p.wcdma.uc; - } - - (void)asn_long2INTEGER(&ulp->message.choice.msSUPLSTART.locationId.status, Status_current); - - ulp->message.choice.msSUPLSTART.qoP = OPTIONAL_MISSING; - - pdu->pdu = ulp; - - err = supl_ulp_encode(pdu); - if (err < 0) { - asn_DEF_ULP_PDU.free_struct(&asn_DEF_ULP_PDU, ulp, 0); - return err; - } - - return 0; + return fd; } + +static int pdu_make_ulp_start(supl_ctx_t *ctx, supl_ulp_t *pdu) +{ + ULP_PDU_t *ulp; + SetSessionID_t *session_id; + int err; + + ulp = calloc(1, sizeof(ULP_PDU_t)); + session_id = calloc(1, sizeof(SetSessionID_t)); + + ulp->length = 0; + ulp->version.maj = 1; + ulp->version.min = 0; + ulp->version.servind = 0; + + session_id->sessionId = 1; + // session_id->setId.present = SETId_PR_msisdn; + // (void)OCTET_STRING_fromBuf(&session_id->setId.choice.msisdn, ctx->p.msisdn, 8); + session_id->setId.present = SETId_PR_imsi; + (void)OCTET_STRING_fromBuf(&session_id->setId.choice.imsi, ctx->p.msisdn, 8); + + ulp->sessionID.setSessionID = session_id; + ulp->sessionID.slpSessionID = OPTIONAL_MISSING; + + ulp->message.present = UlpMessage_PR_msSUPLSTART; + ulp->message.choice.msSUPLSTART.sETCapabilities.posTechnology.agpsSETBased = 1; + // (void)asn_long2INTEGER(&ulp->message.choice.msSUPLSTART.sETCapabilities.prefMethod, PrefMethod_noPreference); + (void)asn_long2INTEGER(&ulp->message.choice.msSUPLSTART.sETCapabilities.prefMethod, PrefMethod_agpsSETBasedPreferred); + ulp->message.choice.msSUPLSTART.sETCapabilities.posProtocol.rrlp = 1; + + if (ctx->p.set & PARAM_GSM_CELL_CURRENT) + { + ulp->message.choice.msSUPLSTART.locationId.cellInfo.present = CellInfo_PR_gsmCell; + ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.refMCC = ctx->p.gsm.mcc; + ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.refMNC = ctx->p.gsm.mnc; + ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.refLAC = ctx->p.gsm.lac; + ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.refCI = ctx->p.gsm.ci; + ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.nMR = OPTIONAL_MISSING; + ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.gsmCell.tA = OPTIONAL_MISSING; + } + else if (ctx->p.set & PARAM_WCDMA_CELL_CURRENT) + { + ulp->message.choice.msSUPLSTART.locationId.cellInfo.present = CellInfo_PR_wcdmaCell; + ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.wcdmaCell.refMCC = ctx->p.wcdma.mcc; + ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.wcdmaCell.refMNC = ctx->p.wcdma.mnc; + ulp->message.choice.msSUPLSTART.locationId.cellInfo.choice.wcdmaCell.refUC = ctx->p.wcdma.uc; + } + + (void)asn_long2INTEGER(&ulp->message.choice.msSUPLSTART.locationId.status, Status_current); + + ulp->message.choice.msSUPLSTART.qoP = OPTIONAL_MISSING; + + pdu->pdu = ulp; + + err = supl_ulp_encode(pdu); + if (err < 0) + { + asn_DEF_ULP_PDU.free_struct(&asn_DEF_ULP_PDU, ulp, 0); + return err; + } + + return 0; +} + + // get slpSessionID from SUPLRESPONSE pdu if preset -static int supl_response_harvest(supl_ctx_t *ctx, supl_ulp_t *pdu) { - int ret; - ULP_PDU_t *ulp = pdu->pdu; - void *buf; +static int supl_response_harvest(supl_ctx_t *ctx, supl_ulp_t *pdu) +{ + int ret; + ULP_PDU_t *ulp = pdu->pdu; + void *buf; - ctx->slp_session_id.buf = 0; + ctx->slp_session_id.buf = 0; - ret = uper_encode_to_new_buffer(&asn_DEF_SlpSessionID, 0, (void *)ulp->sessionID.slpSessionID, &buf); - if (ret == -1) return -1; + ret = uper_encode_to_new_buffer(&asn_DEF_SlpSessionID, 0, (void *)ulp->sessionID.slpSessionID, &buf); + if (ret == -1) + { + return -1; + } - ctx->slp_session_id.buf = buf; - ctx->slp_session_id.size = ret; + ctx->slp_session_id.buf = buf; + ctx->slp_session_id.size = ret; - return 0; + return 0; } -static int pdu_make_ulp_pos_init(supl_ctx_t *ctx, supl_ulp_t *pdu) { - int err; - ULP_PDU_t *ulp; - SetSessionID_t *session_id; - RequestedAssistData_t *req_adata; - ulp = calloc(1, sizeof(ULP_PDU_t)); - session_id = calloc(1, sizeof(SetSessionID_t)); - req_adata = calloc(1, sizeof(RequestedAssistData_t)); +static int pdu_make_ulp_pos_init(supl_ctx_t *ctx, supl_ulp_t *pdu) +{ + int err; + ULP_PDU_t *ulp; + SetSessionID_t *session_id; + RequestedAssistData_t *req_adata; - ulp->length = 0; - ulp->version.maj = 1; - ulp->version.min = 0; - ulp->version.servind = 0; + ulp = calloc(1, sizeof(ULP_PDU_t)); + session_id = calloc(1, sizeof(SetSessionID_t)); + req_adata = calloc(1, sizeof(RequestedAssistData_t)); - session_id->sessionId = 1; - // session_id->setId.present = SETId_PR_msisdn; - // (void)OCTET_STRING_fromBuf(&session_id->setId.choice.msisdn, ctx->p.msisdn, 8); - session_id->setId.present = SETId_PR_imsi; - (void)OCTET_STRING_fromBuf(&session_id->setId.choice.imsi, ctx->p.msisdn, 8); + ulp->length = 0; + ulp->version.maj = 1; + ulp->version.min = 0; + ulp->version.servind = 0; - ulp->sessionID.setSessionID = session_id; - // ulp->sessionID.slpSessionID = OPTIONAL_MISSING; - if (ctx->slp_session_id.buf) { - (void)uper_decode_complete(0, &asn_DEF_SlpSessionID, (void **)&ulp->sessionID.slpSessionID, ctx->slp_session_id.buf, ctx->slp_session_id.size); - } else { - ulp->sessionID.slpSessionID = OPTIONAL_MISSING; - } + session_id->sessionId = 1; + // session_id->setId.present = SETId_PR_msisdn; + // (void)OCTET_STRING_fromBuf(&session_id->setId.choice.msisdn, ctx->p.msisdn, 8); + session_id->setId.present = SETId_PR_imsi; + (void)OCTET_STRING_fromBuf(&session_id->setId.choice.imsi, ctx->p.msisdn, 8); - ulp->message.present = UlpMessage_PR_msSUPLPOSINIT; - ulp->message.choice.msSUPLPOSINIT.sETCapabilities.posTechnology.agpsSETBased = 1; - // (void)asn_long2INTEGER(&ulp->message.choice.msSUPLPOSINIT.sETCapabilities.prefMethod, PrefMethod_noPreference); - (void)asn_long2INTEGER(&ulp->message.choice.msSUPLPOSINIT.sETCapabilities.prefMethod, PrefMethod_agpsSETBasedPreferred); - ulp->message.choice.msSUPLPOSINIT.sETCapabilities.posProtocol.rrlp = 1; + ulp->sessionID.setSessionID = session_id; + // ulp->sessionID.slpSessionID = OPTIONAL_MISSING; + if (ctx->slp_session_id.buf) + { + (void)uper_decode_complete(0, &asn_DEF_SlpSessionID, (void **)&ulp->sessionID.slpSessionID, ctx->slp_session_id.buf, ctx->slp_session_id.size); + } + else + { + ulp->sessionID.slpSessionID = OPTIONAL_MISSING; + } - //GNSS-SDR mod - // Use ctx->p.request to swith between a pre-defined set of assistence data request - // reason: Some SUPL servers do not respond to Acquisition assistance depending on the status of other assistance flags + ulp->message.present = UlpMessage_PR_msSUPLPOSINIT; + ulp->message.choice.msSUPLPOSINIT.sETCapabilities.posTechnology.agpsSETBased = 1; + // (void)asn_long2INTEGER(&ulp->message.choice.msSUPLPOSINIT.sETCapabilities.prefMethod, PrefMethod_noPreference); + (void)asn_long2INTEGER(&ulp->message.choice.msSUPLPOSINIT.sETCapabilities.prefMethod, PrefMethod_agpsSETBasedPreferred); + ulp->message.choice.msSUPLPOSINIT.sETCapabilities.posProtocol.rrlp = 1; - switch (ctx->p.request) - { - case 0: //request almanac, time, and cell positions - req_adata->acquisitionAssistanceRequested = 0; // 1 - req_adata->navigationModelRequested = 0; // 1 - req_adata->referenceTimeRequested = 1; - req_adata->utcModelRequested = 1; //1 - req_adata->ionosphericModelRequested = 1; // 1 - req_adata->referenceLocationRequested = 1; - req_adata->almanacRequested = 1; - req_adata->realTimeIntegrityRequested = 1; // 1 - break; - case 1: // request Navigation Model (Ephemeris) - req_adata->acquisitionAssistanceRequested = 0; // 1 - req_adata->navigationModelRequested = 1; // 1 - req_adata->referenceTimeRequested = 1; - req_adata->utcModelRequested = 0; //1 - req_adata->ionosphericModelRequested = 0; // 1 - req_adata->referenceLocationRequested = 0; - req_adata->almanacRequested = 0; - req_adata->realTimeIntegrityRequested = 0; // 1 - break; - case 2: //request Acquisition assistance (Doppler assistance) - req_adata->acquisitionAssistanceRequested = 1; // 1 - req_adata->navigationModelRequested = 0; // 1 - req_adata->referenceTimeRequested = 1; - req_adata->utcModelRequested = 1; //1 - req_adata->ionosphericModelRequested = 1; // 1 - req_adata->referenceLocationRequested = 1; - req_adata->almanacRequested = 1; - req_adata->realTimeIntegrityRequested = 1; // 1 - break; - default: - req_adata->acquisitionAssistanceRequested = 0; // 1 - req_adata->navigationModelRequested = 0; // 1 - req_adata->referenceTimeRequested = 1; - req_adata->utcModelRequested = 1; //1 - req_adata->ionosphericModelRequested = 1; // 1 - req_adata->referenceLocationRequested = 1; - req_adata->almanacRequested = 1; - req_adata->realTimeIntegrityRequested = 1; // 1 - break; - } + //GNSS-SDR mod + // Use ctx->p.request to swith between a pre-defined set of assistence data request + // reason: Some SUPL servers do not respond to Acquisition assistance depending on the status of other assistance flags - ulp->message.choice.msSUPLPOSINIT.requestedAssistData = req_adata; + switch (ctx->p.request) + { + case 0: //request almanac, time, and cell positions + req_adata->acquisitionAssistanceRequested = 0; // 1 + req_adata->navigationModelRequested = 0; // 1 + req_adata->referenceTimeRequested = 1; + req_adata->utcModelRequested = 1; //1 + req_adata->ionosphericModelRequested = 1; // 1 + req_adata->referenceLocationRequested = 1; + req_adata->almanacRequested = 1; + req_adata->realTimeIntegrityRequested = 1; // 1 + break; + case 1: // request Navigation Model (Ephemeris) + req_adata->acquisitionAssistanceRequested = 0; // 1 + req_adata->navigationModelRequested = 1; // 1 + req_adata->referenceTimeRequested = 1; + req_adata->utcModelRequested = 0; //1 + req_adata->ionosphericModelRequested = 0; // 1 + req_adata->referenceLocationRequested = 0; + req_adata->almanacRequested = 0; + req_adata->realTimeIntegrityRequested = 0; // 1 + break; + case 2: //request Acquisition assistance (Doppler assistance) + req_adata->acquisitionAssistanceRequested = 1; // 1 + req_adata->navigationModelRequested = 0; // 1 + req_adata->referenceTimeRequested = 1; + req_adata->utcModelRequested = 1; //1 + req_adata->ionosphericModelRequested = 1; // 1 + req_adata->referenceLocationRequested = 1; + req_adata->almanacRequested = 1; + req_adata->realTimeIntegrityRequested = 1; // 1 + break; + default: + req_adata->acquisitionAssistanceRequested = 0; // 1 + req_adata->navigationModelRequested = 0; // 1 + req_adata->referenceTimeRequested = 1; + req_adata->utcModelRequested = 1; //1 + req_adata->ionosphericModelRequested = 1; // 1 + req_adata->referenceLocationRequested = 1; + req_adata->almanacRequested = 1; + req_adata->realTimeIntegrityRequested = 1; // 1 + break; + } - if (ctx->p.set & PARAM_GSM_CELL_CURRENT) { - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.present = CellInfo_PR_gsmCell; - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.refMCC = ctx->p.gsm.mcc; - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.refMNC = ctx->p.gsm.mnc; - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.refLAC = ctx->p.gsm.lac; - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.refCI = ctx->p.gsm.ci; - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.nMR = OPTIONAL_MISSING; - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.tA = OPTIONAL_MISSING; - } else if (ctx->p.set & PARAM_WCDMA_CELL_CURRENT) { - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.present = CellInfo_PR_wcdmaCell; - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.wcdmaCell.refMCC = ctx->p.wcdma.mcc; - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.wcdmaCell.refMNC = ctx->p.wcdma.mnc; - ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.wcdmaCell.refUC = ctx->p.wcdma.uc; - } + ulp->message.choice.msSUPLPOSINIT.requestedAssistData = req_adata; - if (ctx->p.set & PARAM_GSM_CELL_KNOWN) { - Position_t *pos = calloc(1, sizeof(Position_t)); - struct tm *tm; - time_t t; + if (ctx->p.set & PARAM_GSM_CELL_CURRENT) + { + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.present = CellInfo_PR_gsmCell; + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.refMCC = ctx->p.gsm.mcc; + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.refMNC = ctx->p.gsm.mnc; + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.refLAC = ctx->p.gsm.lac; + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.refCI = ctx->p.gsm.ci; + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.nMR = OPTIONAL_MISSING; + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.gsmCell.tA = OPTIONAL_MISSING; + } + else if (ctx->p.set & PARAM_WCDMA_CELL_CURRENT) + { + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.present = CellInfo_PR_wcdmaCell; + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.wcdmaCell.refMCC = ctx->p.wcdma.mcc; + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.wcdmaCell.refMNC = ctx->p.wcdma.mnc; + ulp->message.choice.msSUPLPOSINIT.locationId.cellInfo.choice.wcdmaCell.refUC = ctx->p.wcdma.uc; + } - (void)asn_long2INTEGER(&ulp->message.choice.msSUPLPOSINIT.locationId.status, Status_stale); + if (ctx->p.set & PARAM_GSM_CELL_KNOWN) + { + Position_t *pos = calloc(1, sizeof(Position_t)); + struct tm *tm; + time_t t; - t = time(0); - tm = gmtime(&t); - asn_UT2time(&pos->timestamp, tm ,1); - (void)asn_long2INTEGER(&pos->positionEstimate.latitudeSign, latitudeSign_north); - pos->positionEstimate.latitude = (1 << 23) / 90.0 * ctx->p.known.lat; - pos->positionEstimate.longitude = (1 << 24) / 360.0 * ctx->p.known.lon; - // TODO: set position estimate + (void)asn_long2INTEGER(&ulp->message.choice.msSUPLPOSINIT.locationId.status, Status_stale); - ulp->message.choice.msSUPLPOSINIT.position = pos; - } else { - (void)asn_long2INTEGER(&ulp->message.choice.msSUPLPOSINIT.locationId.status, Status_current); - ulp->message.choice.msSUPLPOSINIT.position = OPTIONAL_MISSING; - } + t = time(0); + tm = gmtime(&t); + asn_UT2time(&pos->timestamp, tm, 1); + (void)asn_long2INTEGER(&pos->positionEstimate.latitudeSign, latitudeSign_north); + pos->positionEstimate.latitude = (1 << 23) / 90.0 * ctx->p.known.lat; + pos->positionEstimate.longitude = (1 << 24) / 360.0 * ctx->p.known.lon; + // TODO: set position estimate - ulp->message.choice.msSUPLPOSINIT.sUPLPOS = OPTIONAL_MISSING; + ulp->message.choice.msSUPLPOSINIT.position = pos; + } + else + { + (void)asn_long2INTEGER(&ulp->message.choice.msSUPLPOSINIT.locationId.status, Status_current); + ulp->message.choice.msSUPLPOSINIT.position = OPTIONAL_MISSING; + } - ulp->message.choice.msSUPLPOSINIT.ver = OPTIONAL_MISSING; + ulp->message.choice.msSUPLPOSINIT.sUPLPOS = OPTIONAL_MISSING; - pdu->pdu = ulp; + ulp->message.choice.msSUPLPOSINIT.ver = OPTIONAL_MISSING; - err = supl_ulp_encode(pdu); - if (err < 0) { - asn_DEF_ULP_PDU.free_struct(&asn_DEF_ULP_PDU, ulp, 0); - return err; - } + pdu->pdu = ulp; - return 0; + err = supl_ulp_encode(pdu); + if (err < 0) + { + asn_DEF_ULP_PDU.free_struct(&asn_DEF_ULP_PDU, ulp, 0); + return err; + } + + return 0; } -static int pdu_make_ulp_rrlp_ack(supl_ctx_t *ctx, supl_ulp_t *pdu, PDU_t *rrlp) { - int err; - PDU_t *rrlp_ack; - ULP_PDU_t *ulp; - SetSessionID_t *session_id; - asn_enc_rval_t ret; - int pdu_len; - char buffer[1024]; - rrlp_ack = calloc(1, sizeof(PDU_t)); +static int pdu_make_ulp_rrlp_ack(supl_ctx_t *ctx, supl_ulp_t *pdu, PDU_t *rrlp) +{ + int err; + PDU_t *rrlp_ack; + ULP_PDU_t *ulp; + SetSessionID_t *session_id; + asn_enc_rval_t ret; + int pdu_len; + char buffer[1024]; - /* create RRLP assistanceDataAck */ + rrlp_ack = calloc(1, sizeof(PDU_t)); - rrlp_ack->referenceNumber = rrlp->referenceNumber; - rrlp_ack->component.present = RRLP_Component_PR_assistanceDataAck; + /* create RRLP assistanceDataAck */ - ret = uper_encode_to_buffer(&asn_DEF_PDU, rrlp_ack, buffer, sizeof(buffer)); - asn_DEF_ULP_PDU.free_struct(&asn_DEF_PDU, rrlp_ack, 0); - if (ret.encoded == -1) { - return E_SUPL_ENCODE_RRLP; - } - pdu_len = (ret.encoded + 7) >> 3; + rrlp_ack->referenceNumber = rrlp->referenceNumber; + rrlp_ack->component.present = RRLP_Component_PR_assistanceDataAck; - /* embedded it in SUPLPOS */ + ret = uper_encode_to_buffer(&asn_DEF_PDU, rrlp_ack, buffer, sizeof(buffer)); + asn_DEF_ULP_PDU.free_struct(&asn_DEF_PDU, rrlp_ack, 0); + if (ret.encoded == -1) + { + return E_SUPL_ENCODE_RRLP; + } + pdu_len = (ret.encoded + 7) >> 3; - ulp = calloc(1, sizeof(ULP_PDU_t)); - session_id = calloc(1, sizeof(SetSessionID_t)); + /* embedded it in SUPLPOS */ - ulp->length = 0; - ulp->version.maj = 1; - ulp->version.min = 0; - ulp->version.servind = 0; + ulp = calloc(1, sizeof(ULP_PDU_t)); + session_id = calloc(1, sizeof(SetSessionID_t)); - session_id->sessionId = 1; - // session_id->setId.present = SETId_PR_msisdn; - // (void)OCTET_STRING_fromBuf(&session_id->setId.choice.msisdn, ctx->p.msisdn, 8); - session_id->setId.present = SETId_PR_imsi; - (void)OCTET_STRING_fromBuf(&session_id->setId.choice.imsi, ctx->p.msisdn, 8); + ulp->length = 0; + ulp->version.maj = 1; + ulp->version.min = 0; + ulp->version.servind = 0; - ulp->sessionID.setSessionID = session_id; - // ulp->sessionID.slpSessionID = OPTIONAL_MISSING; - if (ctx->slp_session_id.buf) { - (void)uper_decode_complete(0, &asn_DEF_SlpSessionID, (void **)&ulp->sessionID.slpSessionID, ctx->slp_session_id.buf, ctx->slp_session_id.size); - } else { - ulp->sessionID.slpSessionID = OPTIONAL_MISSING; - } + session_id->sessionId = 1; + // session_id->setId.present = SETId_PR_msisdn; + // (void)OCTET_STRING_fromBuf(&session_id->setId.choice.msisdn, ctx->p.msisdn, 8); + session_id->setId.present = SETId_PR_imsi; + (void)OCTET_STRING_fromBuf(&session_id->setId.choice.imsi, ctx->p.msisdn, 8); - ulp->message.present = UlpMessage_PR_msSUPLPOS; - ulp->message.choice.msSUPLPOS.posPayLoad.present = PosPayLoad_PR_rrlpPayload; - (void)OCTET_STRING_fromBuf(&ulp->message.choice.msSUPLPOS.posPayLoad.choice.rrlpPayload, buffer, pdu_len); + ulp->sessionID.setSessionID = session_id; + // ulp->sessionID.slpSessionID = OPTIONAL_MISSING; + if (ctx->slp_session_id.buf) + { + (void)uper_decode_complete(0, &asn_DEF_SlpSessionID, (void **)&ulp->sessionID.slpSessionID, ctx->slp_session_id.buf, ctx->slp_session_id.size); + } + else + { + ulp->sessionID.slpSessionID = OPTIONAL_MISSING; + } - pdu->pdu = ulp; + ulp->message.present = UlpMessage_PR_msSUPLPOS; + ulp->message.choice.msSUPLPOS.posPayLoad.present = PosPayLoad_PR_rrlpPayload; + (void)OCTET_STRING_fromBuf(&ulp->message.choice.msSUPLPOS.posPayLoad.choice.rrlpPayload, buffer, pdu_len); - err = supl_ulp_encode(pdu); - if (err < 0) { - supl_ulp_free(pdu); - return err; - } + pdu->pdu = ulp; - return 0; + err = supl_ulp_encode(pdu); + if (err < 0) + { + supl_ulp_free(pdu); + return err; + } + + return 0; } /* @@ -564,132 +642,161 @@ static int pdu_make_ulp_rrlp_ack(supl_ctx_t *ctx, supl_ulp_t *pdu, PDU_t *rrlp) ** */ -int EXPORT supl_collect_rrlp(supl_assist_t *assist, PDU_t *rrlp, struct timeval *t) { - ControlHeader_t *hdr; +int EXPORT supl_collect_rrlp(supl_assist_t *assist, PDU_t *rrlp, struct timeval *t) +{ + ControlHeader_t *hdr; - if (rrlp->component.present != RRLP_Component_PR_assistanceData) return 0; - if (!rrlp->component.choice.assistanceData.gps_AssistData) return 0; + if (rrlp->component.present != RRLP_Component_PR_assistanceData) + { + return 0; + } + if (!rrlp->component.choice.assistanceData.gps_AssistData) + { + return 0; + } - hdr = &rrlp->component.choice.assistanceData.gps_AssistData->controlHeader; + hdr = &rrlp->component.choice.assistanceData.gps_AssistData->controlHeader; - if (hdr->referenceTime) { - assist->set |= SUPL_RRLP_ASSIST_REFTIME; - assist->time.gps_tow = hdr->referenceTime->gpsTime.gpsTOW23b; - assist->time.gps_week = hdr->referenceTime->gpsTime.gpsWeek; - memcpy(&assist->time.stamp, t, sizeof(struct timeval)); - } + if (hdr->referenceTime) + { + assist->set |= SUPL_RRLP_ASSIST_REFTIME; + assist->time.gps_tow = hdr->referenceTime->gpsTime.gpsTOW23b; + assist->time.gps_week = hdr->referenceTime->gpsTime.gpsWeek; + memcpy(&assist->time.stamp, t, sizeof(struct timeval)); + } - if (hdr->refLocation) { - OCTET_STRING_t *loc; + if (hdr->refLocation) + { + OCTET_STRING_t *loc; - loc = &hdr->refLocation->threeDLocation; - if (loc->size == 14 && loc->buf[0] == 0x90) { - double lat, lon; - long l; + loc = &hdr->refLocation->threeDLocation; + if (loc->size == 14 && loc->buf[0] == 0x90) + { + double lat, lon; + long l; - /* from 3GPP TS 23.032 V4.0.0 (2001-04) */ + /* from 3GPP TS 23.032 V4.0.0 (2001-04) */ - l = (loc->buf[1] & 0x7f) << 16 | - (loc->buf[2] << 8) | - loc->buf[3]; - if (loc->buf[1] & 0x80) l *= -1; - lat = 90.0 / (1 << 23) * l; + l = (loc->buf[1] & 0x7f) << 16 | + (loc->buf[2] << 8) | + loc->buf[3]; + if (loc->buf[1] & 0x80) + { + l *= -1; + } + lat = 90.0 / (1 << 23) * l; - l = (loc->buf[4] << 16) | - (loc->buf[5] << 8) | - loc->buf[6]; - lon = 360.0 / (1 << 24) * l; + l = (loc->buf[4] << 16) | + (loc->buf[5] << 8) | + loc->buf[6]; + lon = 360.0 / (1 << 24) * l; - /* max of uncertainty ellipsoid axis */ - /* uncert in meters = 10 * (1.1 ^ l - 1) */ - /* l == 96 => 100 km uncertainty => not usable */ - l = loc->buf[9]; - if (loc->buf[10] > l) l = loc->buf[10]; + /* max of uncertainty ellipsoid axis */ + /* uncert in meters = 10 * (1.1 ^ l - 1) */ + /* l == 96 => 100 km uncertainty => not usable */ + l = loc->buf[9]; + if (loc->buf[10] > l) + { + l = loc->buf[10]; + } - assist->set |= SUPL_RRLP_ASSIST_REFLOC; - assist->pos.lat = lat; - assist->pos.lon = lon; - assist->pos.uncertainty = l; - } - } + assist->set |= SUPL_RRLP_ASSIST_REFLOC; + assist->pos.lat = lat; + assist->pos.lon = lon; + assist->pos.uncertainty = l; + } + } - if (hdr->acquisAssist) { - int n; + if (hdr->acquisAssist) + { + int n; - assist->acq_time = hdr->acquisAssist->timeRelation.gpsTOW; + assist->acq_time = hdr->acquisAssist->timeRelation.gpsTOW; - for (n = 0; n < hdr->acquisAssist->acquisList.list.count; n++) { - struct AcquisElement *e = hdr->acquisAssist->acquisList.list.array[n]; - int i = assist->cnt_acq++; + for (n = 0; n < hdr->acquisAssist->acquisList.list.count; n++) + { + struct AcquisElement *e = hdr->acquisAssist->acquisList.list.array[n]; + int i = assist->cnt_acq++; - assist->acq[i].prn = e->svid + 1; - assist->acq[i].parts = 0; - assist->acq[i].doppler0 = e->doppler0; + assist->acq[i].prn = e->svid + 1; + assist->acq[i].parts = 0; + assist->acq[i].doppler0 = e->doppler0; - if (e->addionalDoppler) { - assist->acq[i].parts |= SUPL_ACQUIS_DOPPLER; - assist->acq[i].doppler1 = e->addionalDoppler->doppler1; - assist->acq[i].d_win = e->addionalDoppler->dopplerUncertainty; - } + if (e->addionalDoppler) + { + assist->acq[i].parts |= SUPL_ACQUIS_DOPPLER; + assist->acq[i].doppler1 = e->addionalDoppler->doppler1; + assist->acq[i].d_win = e->addionalDoppler->dopplerUncertainty; + } - assist->acq[i].code_ph = e->codePhase; - assist->acq[i].code_ph_int = e->intCodePhase; - assist->acq[i].bit_num = e->gpsBitNumber; - assist->acq[i].code_ph_win = e->codePhaseSearchWindow; + assist->acq[i].code_ph = e->codePhase; + assist->acq[i].code_ph_int = e->intCodePhase; + assist->acq[i].bit_num = e->gpsBitNumber; + assist->acq[i].code_ph_win = e->codePhaseSearchWindow; - if (e->addionalAngle) { - assist->acq[i].parts |= SUPL_ACQUIS_ANGLE; - assist->acq[i].az = e->addionalAngle->azimuth; - assist->acq[i].el = e->addionalAngle->elevation; - } - } - } + if (e->addionalAngle) + { + assist->acq[i].parts |= SUPL_ACQUIS_ANGLE; + assist->acq[i].az = e->addionalAngle->azimuth; + assist->acq[i].el = e->addionalAngle->elevation; + } + } + } - if (hdr->almanac) { - int n; + if (hdr->almanac) + { + int n; - for (n = 0; n < hdr->almanac->almanacList.list.count; n++) { - struct AlmanacElement *e = hdr->almanac->almanacList.list.array[n]; - int i = assist->cnt_alm++; + for (n = 0; n < hdr->almanac->almanacList.list.count; n++) + { + struct AlmanacElement *e = hdr->almanac->almanacList.list.array[n]; + int i = assist->cnt_alm++; - assist->alm[i].prn = e->satelliteID + 1; - assist->alm[i].e = e->almanacE; - assist->alm[i].toa = e->alamanacToa; // nice touch 3gpp - assist->alm[i].Ksii = e->almanacKsii; - assist->alm[i].OMEGA_dot = e->almanacOmegaDot; - assist->alm[i].A_sqrt = e->almanacAPowerHalf; - assist->alm[i].OMEGA_0 = e->almanacOmega0; - assist->alm[i].w = e->almanacW; - assist->alm[i].M0 = e->almanacM0; - assist->alm[i].AF0 = e->almanacAF0; - assist->alm[i].AF1 = e->almanacAF1; - } - } + assist->alm[i].prn = e->satelliteID + 1; + assist->alm[i].e = e->almanacE; + assist->alm[i].toa = e->alamanacToa; // nice touch 3gpp + assist->alm[i].Ksii = e->almanacKsii; + assist->alm[i].OMEGA_dot = e->almanacOmegaDot; + assist->alm[i].A_sqrt = e->almanacAPowerHalf; + assist->alm[i].OMEGA_0 = e->almanacOmega0; + assist->alm[i].w = e->almanacW; + assist->alm[i].M0 = e->almanacM0; + assist->alm[i].AF0 = e->almanacAF0; + assist->alm[i].AF1 = e->almanacAF1; + } + } - if (hdr->navigationModel) { - UncompressedEphemeris_t *ue; - int n; + if (hdr->navigationModel) + { + UncompressedEphemeris_t *ue; + int n; - for (n = 0; n < hdr->navigationModel->navModelList.list.count; n++) { - struct NavModelElement *e = hdr->navigationModel->navModelList.list.array[n]; - int i = assist->cnt_eph++; + for (n = 0; n < hdr->navigationModel->navModelList.list.count; n++) + { + struct NavModelElement *e = hdr->navigationModel->navModelList.list.array[n]; + int i = assist->cnt_eph++; - assist->eph[i].prn = e->satelliteID + 1; + assist->eph[i].prn = e->satelliteID + 1; - /* what is the difference between these two */ - ue = 0; - if (e->satStatus.present == SatStatus_PR_newNaviModelUC) - ue = &e->satStatus.choice.newNaviModelUC; - if (e->satStatus.present == SatStatus_PR_newSatelliteAndModelUC) - ue = &e->satStatus.choice.newSatelliteAndModelUC; + /* what is the difference between these two */ + ue = 0; + if (e->satStatus.present == SatStatus_PR_newNaviModelUC) + { + ue = &e->satStatus.choice.newNaviModelUC; + } + if (e->satStatus.present == SatStatus_PR_newSatelliteAndModelUC) + { + ue = &e->satStatus.choice.newSatelliteAndModelUC; + } - if (ue) { + if (ue) + { #if 0 assist->eph_x[i].L2P = ue->ephemL2Pflag; assist->eph_x[i].fit = ue->ephemFitFlag; #endif - assist->eph[i].delta_n = ue->ephemDeltaN; - assist->eph[i].M0 = ue->ephemM0; + assist->eph[i].delta_n = ue->ephemDeltaN; + assist->eph[i].M0 = ue->ephemM0; #if 0 // this is needed for asn1c version 0.9.22 { @@ -700,252 +807,288 @@ int EXPORT supl_collect_rrlp(supl_assist_t *assist, PDU_t *rrlp, struct timeval assist->eph[i].e = v; } #else - assist->eph[i].e = ue->ephemE; - assist->eph[i].A_sqrt = ue->ephemAPowerHalf; + assist->eph[i].e = ue->ephemE; + assist->eph[i].A_sqrt = ue->ephemAPowerHalf; #endif - assist->eph[i].OMEGA_0 = ue->ephemOmegaA0; - assist->eph[i].i0 = ue->ephemI0; - assist->eph[i].w = ue->ephemW; - assist->eph[i].OMEGA_dot = ue->ephemOmegaADot; - assist->eph[i].i_dot = ue->ephemIDot; - assist->eph[i].Cuc = ue->ephemCuc; - assist->eph[i].Cus = ue->ephemCus; - assist->eph[i].Crc = ue->ephemCrc; - assist->eph[i].Crs = ue->ephemCrs; - assist->eph[i].Cic = ue->ephemCic; - assist->eph[i].Cis = ue->ephemCis; - assist->eph[i].toe = ue->ephemToe; - assist->eph[i].IODC = ue->ephemIODC; - assist->eph[i].toc = ue->ephemToc; - assist->eph[i].AF0 = ue->ephemAF0; - assist->eph[i].AF1 = ue->ephemAF1; - assist->eph[i].AF2 = ue->ephemAF2; + assist->eph[i].OMEGA_0 = ue->ephemOmegaA0; + assist->eph[i].i0 = ue->ephemI0; + assist->eph[i].w = ue->ephemW; + assist->eph[i].OMEGA_dot = ue->ephemOmegaADot; + assist->eph[i].i_dot = ue->ephemIDot; + assist->eph[i].Cuc = ue->ephemCuc; + assist->eph[i].Cus = ue->ephemCus; + assist->eph[i].Crc = ue->ephemCrc; + assist->eph[i].Crs = ue->ephemCrs; + assist->eph[i].Cic = ue->ephemCic; + assist->eph[i].Cis = ue->ephemCis; + assist->eph[i].toe = ue->ephemToe; + assist->eph[i].IODC = ue->ephemIODC; + assist->eph[i].toc = ue->ephemToc; + assist->eph[i].AF0 = ue->ephemAF0; + assist->eph[i].AF1 = ue->ephemAF1; + assist->eph[i].AF2 = ue->ephemAF2; - assist->eph[i].nav_model = 1; - assist->eph[i].bits = ue->ephemCodeOnL2; - assist->eph[i].ura = ue->ephemURA; - assist->eph[i].health = ue->ephemSVhealth; - assist->eph[i].AODA = ue->ephemAODA; - assist->eph[i].tgd = ue->ephemTgd; - } - } - } + assist->eph[i].nav_model = 1; + assist->eph[i].bits = ue->ephemCodeOnL2; + assist->eph[i].ura = ue->ephemURA; + assist->eph[i].health = ue->ephemSVhealth; + assist->eph[i].AODA = ue->ephemAODA; + assist->eph[i].tgd = ue->ephemTgd; + } + } + } - if (hdr->ionosphericModel) { - assist->set |= SUPL_RRLP_ASSIST_IONO; - assist->iono.a0 = hdr->ionosphericModel->alfa0; - assist->iono.a1 = hdr->ionosphericModel->alfa1; - assist->iono.a2 = hdr->ionosphericModel->alfa2; - assist->iono.a3 = hdr->ionosphericModel->alfa3; //missed in original supl client - assist->iono.b0 = hdr->ionosphericModel->beta0; - assist->iono.b1 = hdr->ionosphericModel->beta1; - assist->iono.b2 = hdr->ionosphericModel->beta2; - assist->iono.b3 = hdr->ionosphericModel->beta3; - } + if (hdr->ionosphericModel) + { + assist->set |= SUPL_RRLP_ASSIST_IONO; + assist->iono.a0 = hdr->ionosphericModel->alfa0; + assist->iono.a1 = hdr->ionosphericModel->alfa1; + assist->iono.a2 = hdr->ionosphericModel->alfa2; + assist->iono.a3 = hdr->ionosphericModel->alfa3; //missed in original supl client + assist->iono.b0 = hdr->ionosphericModel->beta0; + assist->iono.b1 = hdr->ionosphericModel->beta1; + assist->iono.b2 = hdr->ionosphericModel->beta2; + assist->iono.b3 = hdr->ionosphericModel->beta3; + } - if (hdr->utcModel) { - assist->set |= SUPL_RRLP_ASSIST_UTC; - assist->utc.a0 = hdr->utcModel->utcA0; - assist->utc.a1 = hdr->utcModel->utcA1; - assist->utc.tot = hdr->utcModel->utcTot; - assist->utc.wnt = hdr->utcModel->utcWNt; - assist->utc.delta_tls = hdr->utcModel->utcDeltaTls; - assist->utc.wnlsf = hdr->utcModel->utcWNlsf; - assist->utc.dn = hdr->utcModel->utcDN; - assist->utc.delta_tlsf = hdr->utcModel->utcDeltaTlsf; - } + if (hdr->utcModel) + { + assist->set |= SUPL_RRLP_ASSIST_UTC; + assist->utc.a0 = hdr->utcModel->utcA0; + assist->utc.a1 = hdr->utcModel->utcA1; + assist->utc.tot = hdr->utcModel->utcTot; + assist->utc.wnt = hdr->utcModel->utcWNt; + assist->utc.delta_tls = hdr->utcModel->utcDeltaTls; + assist->utc.wnlsf = hdr->utcModel->utcWNlsf; + assist->utc.dn = hdr->utcModel->utcDN; + assist->utc.delta_tlsf = hdr->utcModel->utcDeltaTlsf; + } - return 1; + return 1; } -int EXPORT supl_ctx_new(supl_ctx_t *ctx) { - memset(ctx, 0, sizeof(supl_ctx_t)); + +int EXPORT supl_ctx_new(supl_ctx_t *ctx) +{ + memset(ctx, 0, sizeof(supl_ctx_t)); #ifdef SUPL_DEBUG - memset(&debug, 0, sizeof(struct supl_debug_s)); + memset(&debug, 0, sizeof(struct supl_debug_s)); #endif - return 0; + return 0; } -int EXPORT supl_ctx_free(supl_ctx_t *ctx) { - if (ctx->slp_session_id.buf) { - free(ctx->slp_session_id.buf); - ctx->slp_session_id.buf = 0; - } - return 0; +int EXPORT supl_ctx_free(supl_ctx_t *ctx) +{ + if (ctx->slp_session_id.buf) + { + free(ctx->slp_session_id.buf); + ctx->slp_session_id.buf = 0; + } + + return 0; } -static int supl_more_rrlp(PDU_t *rrlp) { - long value; - return (rrlp->component.present == RRLP_Component_PR_assistanceData && - rrlp->component.choice.assistanceData.moreAssDataToBeSent && - asn_INTEGER2long((INTEGER_t *)rrlp->component.choice.assistanceData.moreAssDataToBeSent, &value) == 0 && - value == MoreAssDataToBeSent_moreMessagesOnTheWay); +static int supl_more_rrlp(PDU_t *rrlp) +{ + long value; + + return (rrlp->component.present == RRLP_Component_PR_assistanceData && + rrlp->component.choice.assistanceData.moreAssDataToBeSent && + asn_INTEGER2long((INTEGER_t *)rrlp->component.choice.assistanceData.moreAssDataToBeSent, &value) == 0 && + value == MoreAssDataToBeSent_moreMessagesOnTheWay); } -int EXPORT supl_get_assist(supl_ctx_t *ctx, char *server, supl_assist_t *assist) { - supl_ulp_t ulp; - // memcpy(ctx->p.msisdn, "\xde\xad\xbe\xef\xf0\x0b\xaa\x42", 8); - memcpy(ctx->p.msisdn, "\xFF\xFF\x91\x94\x48\x45\x83\x98", 8); +int EXPORT supl_get_assist(supl_ctx_t *ctx, char *server, supl_assist_t *assist) +{ + supl_ulp_t ulp; - /* + // memcpy(ctx->p.msisdn, "\xde\xad\xbe\xef\xf0\x0b\xaa\x42", 8); + memcpy(ctx->p.msisdn, "\xFF\xFF\x91\x94\x48\x45\x83\x98", 8); + + /* ** connect to server */ - if (supl_server_connect(ctx, server) < 0) return E_SUPL_CONNECT; + if (supl_server_connect(ctx, server) < 0) + { + return E_SUPL_CONNECT; + } - /* + /* ** send SUPL_START */ - if (pdu_make_ulp_start(ctx, &ulp) < 0) { - return E_SUPL_ENCODE_START; - } + if (pdu_make_ulp_start(ctx, &ulp) < 0) + { + return E_SUPL_ENCODE_START; + } - (void)supl_ulp_send(ctx, &ulp); - supl_ulp_free(&ulp); + (void)supl_ulp_send(ctx, &ulp); + supl_ulp_free(&ulp); - /* + /* ** should receive SUPL_RESPONSE back */ - if (supl_ulp_recv(ctx, &ulp) < 0) { - return E_SUPL_RECV_RESPONSE; - } + if (supl_ulp_recv(ctx, &ulp) < 0) + { + return E_SUPL_RECV_RESPONSE; + } + + if (ulp.pdu->message.present != UlpMessage_PR_msSUPLRESPONSE) + { + supl_ulp_free(&ulp); + return E_SUPL_SUPLRESPONSE; + } + + // get and copy slpSessionID if present + supl_response_harvest(ctx, &ulp); - if (ulp.pdu->message.present != UlpMessage_PR_msSUPLRESPONSE) { supl_ulp_free(&ulp); - return E_SUPL_SUPLRESPONSE; - } - // get and copy slpSessionID if present - supl_response_harvest(ctx, &ulp); - - supl_ulp_free(&ulp); - - /* + /* ** send SUPL_POS_INIT */ - if (pdu_make_ulp_pos_init(ctx, &ulp) < 0) { - return E_SUPL_ENCODE_POSINIT; - } + if (pdu_make_ulp_pos_init(ctx, &ulp) < 0) + { + return E_SUPL_ENCODE_POSINIT; + } - (void)supl_ulp_send(ctx, &ulp); + (void)supl_ulp_send(ctx, &ulp); - /* + /* ** should get SUPLPOS back - bounce back and forth until all messages have arrived */ - memset(assist, 0, sizeof(supl_assist_t)); + memset(assist, 0, sizeof(supl_assist_t)); - while (1) { - struct timeval t; - PDU_t *rrlp; + while (1) + { + struct timeval t; + PDU_t *rrlp; + + supl_ulp_free(&ulp); + + /* record packet recv time */ + gettimeofday(&t, 0); + + if (supl_ulp_recv(ctx, &ulp) < 0) + { + return E_SUPL_RECV_SUPLPOS; + } + + if (ulp.pdu->message.present == UlpMessage_PR_msSUPLEND) + { + break; + } + + if (ulp.pdu->message.present != UlpMessage_PR_msSUPLPOS) + { + supl_ulp_free(&ulp); + return E_SUPL_SUPLPOS; + } + + /* get the beef, the RRLP payload */ + + if (supl_decode_rrlp(&ulp, &rrlp) < 0) + { + supl_ulp_free(&ulp); + return E_SUPL_DECODE_RRLP; + } + +#ifdef SUPL_DEBUG + if (debug.verbose_rrlp) + { + fprintf(debug.log, "Embedded RRLP message\n"); + xer_fprint(debug.log, &asn_DEF_PDU, rrlp); + } +#endif + + /* remember important stuff from it */ + + supl_collect_rrlp(assist, rrlp, &t); + + if (!supl_more_rrlp(rrlp)) + { + asn_DEF_ULP_PDU.free_struct(&asn_DEF_PDU, rrlp, 0); + break; + } + + /* More data coming in, send SUPLPOS + RRLP ACK */ + + if (pdu_make_ulp_rrlp_ack(ctx, &ulp, rrlp) < 0) + { + return E_SUPL_RRLP_ACK; + } + + supl_ulp_send(ctx, &ulp); + asn_DEF_ULP_PDU.free_struct(&asn_DEF_PDU, rrlp, 0); + } supl_ulp_free(&ulp); - /* record packet recv time */ - gettimeofday(&t, 0); - - if (supl_ulp_recv(ctx, &ulp) < 0) { - return E_SUPL_RECV_SUPLPOS; - } - - if (ulp.pdu->message.present == UlpMessage_PR_msSUPLEND) { - break; - } - - if (ulp.pdu->message.present != UlpMessage_PR_msSUPLPOS) { - supl_ulp_free(&ulp); - return E_SUPL_SUPLPOS; - } - - /* get the beef, the RRLP payload */ - - if (supl_decode_rrlp(&ulp, &rrlp) < 0) { - supl_ulp_free(&ulp); - return E_SUPL_DECODE_RRLP; - } - -#ifdef SUPL_DEBUG - if (debug.verbose_rrlp) { - fprintf(debug.log, "Embedded RRLP message\n"); - xer_fprint(debug.log, &asn_DEF_PDU, rrlp); - } -#endif - - /* remember important stuff from it */ - - supl_collect_rrlp(assist, rrlp, &t); - - if (!supl_more_rrlp(rrlp)) { - asn_DEF_ULP_PDU.free_struct(&asn_DEF_PDU, rrlp, 0); - break; - } - - /* More data coming in, send SUPLPOS + RRLP ACK */ - - if (pdu_make_ulp_rrlp_ack(ctx, &ulp, rrlp) < 0) { - return E_SUPL_RRLP_ACK; - } - - supl_ulp_send(ctx, &ulp); - asn_DEF_ULP_PDU.free_struct(&asn_DEF_PDU, rrlp, 0); - } - - supl_ulp_free(&ulp); - - /* + /* ** send SUPL_END (but who really cares) */ - supl_close(ctx); + supl_close(ctx); - return 0; + return 0; } -void EXPORT supl_set_gsm_cell(supl_ctx_t *ctx, int mcc, int mns, int lac, int ci) { - ctx->p.set |= PARAM_GSM_CELL_CURRENT; - ctx->p.gsm.mcc = mcc; - ctx->p.gsm.mnc = mns; - ctx->p.gsm.lac = lac; - ctx->p.gsm.ci = ci; +void EXPORT supl_set_gsm_cell(supl_ctx_t *ctx, int mcc, int mns, int lac, int ci) +{ + ctx->p.set |= PARAM_GSM_CELL_CURRENT; + + ctx->p.gsm.mcc = mcc; + ctx->p.gsm.mnc = mns; + ctx->p.gsm.lac = lac; + ctx->p.gsm.ci = ci; } -void EXPORT supl_set_gsm_cell_known(supl_ctx_t *ctx, int mcc, int mns, int lac, int ci, double lat, double lon, int uncert) { - ctx->p.set |= PARAM_GSM_CELL_KNOWN; - ctx->p.known.mcc = mcc; - ctx->p.known.mnc = mns; - ctx->p.known.lac = lac; - ctx->p.known.ci = ci; - ctx->p.known.lat = lat; - ctx->p.known.lon = lon; - ctx->p.known.uncert = uncert; +void EXPORT supl_set_gsm_cell_known(supl_ctx_t *ctx, int mcc, int mns, int lac, int ci, double lat, double lon, int uncert) +{ + ctx->p.set |= PARAM_GSM_CELL_KNOWN; + + ctx->p.known.mcc = mcc; + ctx->p.known.mnc = mns; + ctx->p.known.lac = lac; + ctx->p.known.ci = ci; + ctx->p.known.lat = lat; + ctx->p.known.lon = lon; + ctx->p.known.uncert = uncert; } -void EXPORT supl_set_wcdma_cell(supl_ctx_t *ctx, int mcc, int mns, int uc) { - ctx->p.set |= PARAM_WCDMA_CELL_CURRENT; - ctx->p.wcdma.mcc = mcc; - ctx->p.wcdma.mnc = mns; - ctx->p.wcdma.uc = uc; +void EXPORT supl_set_wcdma_cell(supl_ctx_t *ctx, int mcc, int mns, int uc) +{ + ctx->p.set |= PARAM_WCDMA_CELL_CURRENT; + + ctx->p.wcdma.mcc = mcc; + ctx->p.wcdma.mnc = mns; + ctx->p.wcdma.uc = uc; } -void EXPORT supl_request(supl_ctx_t *ctx, int request) { - ctx->p.request = request; + +void EXPORT supl_request(supl_ctx_t *ctx, int request) +{ + ctx->p.request = request; } -void EXPORT supl_set_debug(FILE *log, int flags) { + +void EXPORT supl_set_debug(FILE *log, int flags) +{ #ifdef SUPL_DEBUG - debug.log = log; - if (flags & SUPL_DEBUG_RRLP) debug.verbose_rrlp = 1; - if (flags & SUPL_DEBUG_SUPL) debug.verbose_supl = 1; - if (flags & SUPL_DEBUG_DEBUG) debug.debug = 1; + debug.log = log; + if (flags & SUPL_DEBUG_RRLP) debug.verbose_rrlp = 1; + if (flags & SUPL_DEBUG_SUPL) debug.verbose_supl = 1; + if (flags & SUPL_DEBUG_DEBUG) debug.debug = 1; #endif } diff --git a/src/core/monitor/gnss_synchro_monitor.cc b/src/core/monitor/gnss_synchro_monitor.cc index ad9f40e37..f8997d6a3 100644 --- a/src/core/monitor/gnss_synchro_monitor.cc +++ b/src/core/monitor/gnss_synchro_monitor.cc @@ -45,26 +45,26 @@ using google::LogMessage; gnss_synchro_monitor_sptr gnss_synchro_make_monitor(unsigned int n_channels, int output_rate_ms, int udp_port, - std::vector udp_addresses) + const std::vector& udp_addresses) { return gnss_synchro_monitor_sptr(new gnss_synchro_monitor(n_channels, output_rate_ms, udp_port, - std::move(udp_addresses))); + udp_addresses)); } gnss_synchro_monitor::gnss_synchro_monitor(unsigned int n_channels, int output_rate_ms, int udp_port, - std::vector udp_addresses) : gr::sync_block("gnss_synchro_monitor", + const std::vector& udp_addresses) : gr::sync_block("gnss_synchro_monitor", gr::io_signature::make(n_channels, n_channels, sizeof(Gnss_Synchro)), gr::io_signature::make(0, 0, 0)) { d_output_rate_ms = output_rate_ms; d_nchannels = n_channels; - udp_sink_ptr = std::unique_ptr(new Gnss_Synchro_Udp_Sink(std::move(udp_addresses), udp_port)); + udp_sink_ptr = std::unique_ptr(new Gnss_Synchro_Udp_Sink(udp_addresses, udp_port)); count = 0; } diff --git a/src/core/monitor/gnss_synchro_monitor.h b/src/core/monitor/gnss_synchro_monitor.h index 7c22a1290..a0a8e470a 100644 --- a/src/core/monitor/gnss_synchro_monitor.h +++ b/src/core/monitor/gnss_synchro_monitor.h @@ -48,7 +48,7 @@ using gnss_synchro_monitor_sptr = boost::shared_ptr; gnss_synchro_monitor_sptr gnss_synchro_make_monitor(unsigned int n_channels, int output_rate_ms, int udp_port, - std::vector udp_addresses); + const std::vector& udp_addresses); /*! * \brief This class implements a block that computes the PVT solution with Galileo E1 signals @@ -59,7 +59,7 @@ private: friend gnss_synchro_monitor_sptr gnss_synchro_make_monitor(unsigned int nchannels, int output_rate_ms, int udp_port, - std::vector udp_addresses); + const std::vector& udp_addresses); unsigned int d_nchannels; @@ -74,7 +74,7 @@ public: gnss_synchro_monitor(unsigned int nchannels, int output_rate_ms, int udp_port, - std::vector udp_addresses); + const std::vector& udp_addresses); ~gnss_synchro_monitor(); //!< Default destructor diff --git a/src/core/monitor/gnss_synchro_udp_sink.cc b/src/core/monitor/gnss_synchro_udp_sink.cc index 54f489433..2978537ea 100644 --- a/src/core/monitor/gnss_synchro_udp_sink.cc +++ b/src/core/monitor/gnss_synchro_udp_sink.cc @@ -37,7 +37,7 @@ Gnss_Synchro_Udp_Sink::Gnss_Synchro_Udp_Sink(std::vector addresses, const uint16_t& port) : socket{io_service} { - for (auto address : addresses) + for (const auto& address : addresses) { boost::asio::ip::udp::endpoint endpoint(boost::asio::ip::address::from_string(address, error), port); endpoints.push_back(endpoint); @@ -51,7 +51,7 @@ bool Gnss_Synchro_Udp_Sink::write_gnss_synchro(const std::vector& oa << stocks; std::string outbound_data = archive_stream.str(); - for (auto endpoint : endpoints) + for (const auto& endpoint : endpoints) { socket.open(endpoint.protocol(), error); socket.connect(endpoint, error); diff --git a/src/core/receiver/control_thread.cc b/src/core/receiver/control_thread.cc index 57907e079..71e789778 100644 --- a/src/core/receiver/control_thread.cc +++ b/src/core/receiver/control_thread.cc @@ -138,7 +138,9 @@ void ControlThread::init() { vect.push_back(d); if ((ss.peek() == ',') or (ss.peek() == ' ')) - ss.ignore(); + { + ss.ignore(); + } } // fill agnss_ref_location_ if (vect.size() >= 2) @@ -191,7 +193,10 @@ void ControlThread::init() ControlThread::~ControlThread() // NOLINT(modernize-use-equals-default) { - if (msqid != -1) msgctl(msqid, IPC_RMID, nullptr); + if (msqid != -1) + { + msgctl(msqid, IPC_RMID, nullptr); + } } @@ -269,7 +274,10 @@ int ControlThread::run() { //TODO re-enable the blocking read messages functions and fork the process read_control_messages(); - if (control_messages_ != nullptr) process_control_messages(); + if (control_messages_ != nullptr) + { + process_control_messages(); + } } std::cout << "Stopping GNSS-SDR, please wait!" << std::endl; flowgraph_->stop(); @@ -778,7 +786,10 @@ void ControlThread::process_control_messages() { for (auto &i : *control_messages_) { - if (stop_) break; + if (stop_) + { + break; + } if (i->who == 200) { apply_action(i->what); @@ -998,7 +1009,10 @@ void ControlThread::gps_acq_assist_data_collector() while (stop_ == false) { global_gps_acq_assist_queue.wait_and_pop(gps_acq); - if (gps_acq.i_satellite_PRN == 0) break; + if (gps_acq.i_satellite_PRN == 0) + { + break; + } // DEBUG MESSAGE std::cout << "Acquisition assistance record has arrived from SAT ID " diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index d4c1acd56..82cc49e09 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -1344,7 +1344,7 @@ void GNSSFlowgraph::priorize_satellites(std::vectorget_signal().get_satellite() == result.get_satellite()) and (channels_[ch]->get_signal().get_signal_str() != "1C")) untracked_satellite = false; + if ((channels_[ch]->get_signal().get_satellite() == result.get_satellite()) and (channels_[ch]->get_signal().get_signal_str() != "1C")) + { + untracked_satellite = false; + } } if (untracked_satellite and configuration_->property("Channels_2S.count", 0) > 0) { @@ -1843,7 +1846,10 @@ Gnss_Signal GNSSFlowgraph::search_next_signal(const std::string& searched_signal { for (unsigned int ch = 0; ch < channels_count_; ch++) { - if ((channels_[ch]->get_signal().get_satellite() == result.get_satellite()) and (channels_[ch]->get_signal().get_signal_str() != "2S")) untracked_satellite = false; + if ((channels_[ch]->get_signal().get_satellite() == result.get_satellite()) and (channels_[ch]->get_signal().get_signal_str() != "2S")) + { + untracked_satellite = false; + } } if (untracked_satellite and configuration_->property("Channels_1C.count", 0) > 0) { @@ -1874,7 +1880,10 @@ Gnss_Signal GNSSFlowgraph::search_next_signal(const std::string& searched_signal { for (unsigned int ch = 0; ch < channels_count_; ch++) { - if ((channels_[ch]->get_signal().get_satellite() == result.get_satellite()) and (channels_[ch]->get_signal().get_signal_str() != "L5")) untracked_satellite = false; + if ((channels_[ch]->get_signal().get_satellite() == result.get_satellite()) and (channels_[ch]->get_signal().get_signal_str() != "L5")) + { + untracked_satellite = false; + } } if (untracked_satellite and configuration_->property("Channels_1C.count", 0) > 0) { @@ -1905,7 +1914,10 @@ Gnss_Signal GNSSFlowgraph::search_next_signal(const std::string& searched_signal { for (unsigned int ch = 0; ch < channels_count_; ch++) { - if ((channels_[ch]->get_signal().get_satellite() == result.get_satellite()) and (channels_[ch]->get_signal().get_signal_str() != "1B")) untracked_satellite = false; + if ((channels_[ch]->get_signal().get_satellite() == result.get_satellite()) and (channels_[ch]->get_signal().get_signal_str() != "1B")) + { + untracked_satellite = false; + } } if (untracked_satellite) { @@ -1930,7 +1942,10 @@ Gnss_Signal GNSSFlowgraph::search_next_signal(const std::string& searched_signal { for (unsigned int ch = 0; ch < channels_count_; ch++) { - if ((channels_[ch]->get_signal().get_satellite() == result.get_satellite()) and (channels_[ch]->get_signal().get_signal_str() != "5X")) untracked_satellite = false; + if ((channels_[ch]->get_signal().get_satellite() == result.get_satellite()) and (channels_[ch]->get_signal().get_signal_str() != "5X")) + { + untracked_satellite = false; + } } if (untracked_satellite) { @@ -1955,7 +1970,10 @@ Gnss_Signal GNSSFlowgraph::search_next_signal(const std::string& searched_signal { for (unsigned int ch = 0; ch < channels_count_; ch++) { - if ((channels_[ch]->get_signal().get_satellite() == result.get_satellite()) and (channels_[ch]->get_signal().get_signal_str() != "1G")) untracked_satellite = false; + if ((channels_[ch]->get_signal().get_satellite() == result.get_satellite()) and (channels_[ch]->get_signal().get_signal_str() != "1G")) + { + untracked_satellite = false; + } } if (untracked_satellite) { @@ -1980,7 +1998,10 @@ Gnss_Signal GNSSFlowgraph::search_next_signal(const std::string& searched_signal { for (unsigned int ch = 0; ch < channels_count_; ch++) { - if ((channels_[ch]->get_signal().get_satellite() == result.get_satellite()) and (channels_[ch]->get_signal().get_signal_str() != "2G")) untracked_satellite = false; + if ((channels_[ch]->get_signal().get_satellite() == result.get_satellite()) and (channels_[ch]->get_signal().get_signal_str() != "2G")) + { + untracked_satellite = false; + } } if (untracked_satellite) { diff --git a/src/core/system_parameters/beidou_dnav_navigation_message.h b/src/core/system_parameters/beidou_dnav_navigation_message.h index 7212447cd..44d83ca39 100644 --- a/src/core/system_parameters/beidou_dnav_navigation_message.h +++ b/src/core/system_parameters/beidou_dnav_navigation_message.h @@ -129,7 +129,7 @@ public: double d_OMEGA; //!< Argument of Perigee [semi-cicles] double d_OMEGA_DOT; //!< Rate of Right Ascension [semi-circles/s] //broadcast orbit 5 - double d_IDOT; //!< Rate of Inclination Angle [semi-circles/s] + double d_IDOT; //!< Rate of Inclination Angle [semi-circles/s] int32_t i_BEIDOU_week; //!< BeiDou week number, aka WN [week] //broadcast orbit 6 int32_t i_SV_accuracy; //!< User Range Accuracy (URA) index of the SV @@ -167,8 +167,8 @@ public: uint64_t d_OMEGA_DOT_lsb_bits; //!< Rate of Right Ascension [semi-circles/s] // Almanac - double d_Toa; //!< Almanac reference time [s] - int32_t i_WN_A; //!< Modulo 256 of the GPS week number to which the almanac reference time (d_Toa) is referenced + double d_Toa; //!< Almanac reference time [s] + int32_t i_WN_A; //!< Modulo 256 of the GPS week number to which the almanac reference time (d_Toa) is referenced std::map almanacHealth; //!< Map that stores the health information stored in the almanac std::map satelliteBlock; //!< Map that stores to which block the PRN belongs http://www.navcen.uscg.gov/?Do=constellationStatus @@ -221,8 +221,8 @@ public: double d_A1UTC; //!< 1st order term of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200E) [s/s] double d_A0UTC; //!< Constant of a model that relates GPS and UTC time (ref. 20.3.3.5.2.4 IS-GPS-200E) [s] double d_DeltaT_LS; //!< delta time due to leap seconds [s]. Number of leap seconds since 6-Jan-1980 as transmitted by the GPS almanac. - int32_t i_WN_LSF; //!< Week number at the end of which the leap second becomes effective [weeks] - int32_t i_DN; //!< Day number (DN) at the end of which the leap second becomes effective [days] + int32_t i_WN_LSF; //!< Week number at the end of which the leap second becomes effective [weeks] + int32_t i_DN; //!< Day number (DN) at the end of which the leap second becomes effective [days] double d_DeltaT_LSF; //!< Scheduled future or recent past (relative to NAV message upload) value of the delta time due to leap seconds [s] double d_A1GPS; double d_A0GPS; diff --git a/src/core/system_parameters/glonass_gnav_navigation_message.cc b/src/core/system_parameters/glonass_gnav_navigation_message.cc index b2a825894..5685b34a4 100644 --- a/src/core/system_parameters/glonass_gnav_navigation_message.cc +++ b/src/core/system_parameters/glonass_gnav_navigation_message.cc @@ -84,7 +84,9 @@ void Glonass_Gnav_Navigation_Message::reset() // Data update information d_previous_tb = 0.0; for (double& i : d_previous_Na) - i = 0.0; + { + i = 0.0; + } std::map satelliteBlock; // Map that stores to which block the PRN belongs http://www.navcen.uscg.gov/?Do=constellationStatus @@ -320,7 +322,9 @@ int32_t Glonass_Gnav_Navigation_Message::string_decoder(const std::string& frame // Perform data verification and exit code if error in bit sequence flag_CRC_test = CRC_test(string_bits); if (flag_CRC_test == false) - return 0; + { + return 0; + } // Decode all 15 string messages d_string_ID = static_cast(read_navigation_unsigned(string_bits, STRING_ID)); @@ -451,7 +455,9 @@ int32_t Glonass_Gnav_Navigation_Message::string_decoder(const std::string& frame d_frame_ID = get_frame_number(i_alm_satellite_slot_number); // Make sure a valid frame_ID or satellite slot number is returned if (d_frame_ID == 0) - return 0; + { + return 0; + } gnav_almanac[i_alm_satellite_slot_number - 1].d_C_n = static_cast(read_navigation_bool(string_bits, C_N)); gnav_almanac[i_alm_satellite_slot_number - 1].d_M_n_A = static_cast(read_navigation_unsigned(string_bits, M_N_A)); @@ -499,7 +505,9 @@ int32_t Glonass_Gnav_Navigation_Message::string_decoder(const std::string& frame d_frame_ID = get_frame_number(i_alm_satellite_slot_number); // Make sure a valid frame_ID or satellite slot number is returned if (d_frame_ID == 0) - return 0; + { + return 0; + } gnav_almanac[i_alm_satellite_slot_number - 1].d_C_n = static_cast(read_navigation_bool(string_bits, C_N)); gnav_almanac[i_alm_satellite_slot_number - 1].d_M_n_A = static_cast(read_navigation_unsigned(string_bits, M_N_A)); @@ -542,7 +550,9 @@ int32_t Glonass_Gnav_Navigation_Message::string_decoder(const std::string& frame d_frame_ID = get_frame_number(i_alm_satellite_slot_number); // Make sure a valid frame_ID or satellite slot number is returned if (d_frame_ID == 0) - return 0; + { + return 0; + } gnav_almanac[i_alm_satellite_slot_number - 1].d_C_n = static_cast(read_navigation_bool(string_bits, C_N)); gnav_almanac[i_alm_satellite_slot_number - 1].d_M_n_A = static_cast(read_navigation_unsigned(string_bits, M_N_A)); @@ -585,7 +595,9 @@ int32_t Glonass_Gnav_Navigation_Message::string_decoder(const std::string& frame d_frame_ID = get_frame_number(i_alm_satellite_slot_number); // Make sure a valid frame_ID or satellite slot number is returned if (d_frame_ID == 0) - return 0; + { + return 0; + } gnav_almanac[i_alm_satellite_slot_number - 1].d_C_n = static_cast(read_navigation_bool(string_bits, C_N)); gnav_almanac[i_alm_satellite_slot_number - 1].d_M_n_A = static_cast(read_navigation_unsigned(string_bits, M_N_A)); gnav_almanac[i_alm_satellite_slot_number - 1].d_n_A = static_cast(read_navigation_unsigned(string_bits, n_A)); @@ -634,7 +646,9 @@ int32_t Glonass_Gnav_Navigation_Message::string_decoder(const std::string& frame d_frame_ID = get_frame_number(i_alm_satellite_slot_number); // Make sure a valid frame_ID or satellite slot number is returned if (d_frame_ID == 0) - return 0; + { + return 0; + } gnav_almanac[i_alm_satellite_slot_number - 1].d_C_n = static_cast(read_navigation_bool(string_bits, C_N)); gnav_almanac[i_alm_satellite_slot_number - 1].d_M_n_A = static_cast(read_navigation_unsigned(string_bits, M_N_A)); gnav_almanac[i_alm_satellite_slot_number - 1].d_n_A = static_cast(read_navigation_unsigned(string_bits, n_A)); diff --git a/src/core/system_parameters/gnss_satellite.cc b/src/core/system_parameters/gnss_satellite.cc index 6ff824868..0252ef8f8 100644 --- a/src/core/system_parameters/gnss_satellite.cc +++ b/src/core/system_parameters/gnss_satellite.cc @@ -69,8 +69,14 @@ std::ostream& operator<<(std::ostream& out, const Gnss_Satellite& sat) // outpu { std::string tag; std::string tag2; - if (sat.get_system() == "Galileo") tag = "E"; - if (sat.get_PRN() < 10) tag2 = "0"; + if (sat.get_system() == "Galileo") + { + tag = "E"; + } + if (sat.get_PRN() < 10) + { + tag2 = "0"; + } out << sat.get_system() << " PRN " << tag << tag2 << sat.get_PRN() << " (Block " << sat.get_block() << ")"; return out; } diff --git a/src/tests/common-files/gnuplot_i.h b/src/tests/common-files/gnuplot_i.h index 5944d01c3..983ca0870 100644 --- a/src/tests/common-files/gnuplot_i.h +++ b/src/tests/common-files/gnuplot_i.h @@ -651,7 +651,10 @@ public: //---------------------------------------------------------------------------------- inline Gnuplot &replot(void) { - if (nplots > 0) cmd("replot"); + if (nplots > 0) + { + cmd("replot"); + } return *this; }; @@ -795,13 +798,17 @@ Gnuplot &Gnuplot::plot_x(const X &x, const std::string &title) std::ofstream tmp; std::string name = create_tmpfile(tmp); if (name.empty()) - return *this; + { + return *this; + } // // write the data to file // for (unsigned int i = 0; i < x.size(); i++) - tmp << x[i] << std::endl; + { + tmp << x[i] << std::endl; + } tmp.flush(); tmp.close(); @@ -834,13 +841,17 @@ Gnuplot &Gnuplot::plot_xy(const X &x, const Y &y, const std::string &title, cons std::ofstream tmp; std::string name = create_tmpfile(tmp); if (name.empty()) - return *this; + { + return *this; + } // // write the data to file // for (unsigned int i = 0; i < x.size(); i++) - tmp << x[i] << " " << y[i] << std::endl; + { + tmp << x[i] << " " << y[i] << std::endl; + } tmp.flush(); tmp.close(); @@ -876,13 +887,17 @@ Gnuplot &Gnuplot::plot_xy_err(const X &x, std::ofstream tmp; std::string name = create_tmpfile(tmp); if (name.empty()) - return *this; + { + return *this; + } // // write the data to file // for (unsigned int i = 0; i < x.size(); i++) - tmp << x[i] << " " << y[i] << " " << dy[i] << std::endl; + { + tmp << x[i] << " " << y[i] << " " << dy[i] << std::endl; + } tmp.flush(); tmp.close(); @@ -912,7 +927,9 @@ Gnuplot &Gnuplot::plot_grid3d(const X &x, std::ofstream tmp; std::string name = create_tmpfile(tmp); if (name.empty()) - return *this; + { + return *this; + } // // write the data to file @@ -938,9 +955,13 @@ Gnuplot &Gnuplot::plot_grid3d(const X &x, cmdstr << " splot \"" << name << "\" u 1:2:3"; if (title.empty()) - cmdstr << " notitle with " << pstyle << " palette"; + { + cmdstr << " notitle with " << pstyle << " palette"; + } else - cmdstr << " title \"" << title << "\" with " << pstyle << " palette"; + { + cmdstr << " title \"" << title << "\" with " << pstyle << " palette"; + } cmdstr << "\n"; // @@ -976,13 +997,17 @@ Gnuplot &Gnuplot::plot_xyz(const X &x, std::ofstream tmp; std::string name = create_tmpfile(tmp); if (name.empty()) - return *this; + { + return *this; + } // // write the data to file // for (unsigned int i = 0; i < x.size(); i++) - tmp << x[i] << " " << y[i] << " " << z[i] << std::endl; + { + tmp << x[i] << " " << y[i] << " " << z[i] << std::endl; + } tmp.flush(); tmp.close(); @@ -1055,7 +1080,9 @@ void stringtok(Container &container, i = in.find_first_not_of(delimiters, i); if (i == std::string::npos) - return; // nothing left but white space + { + return; // nothing left but white space + } // find the end of the token std::string::size_type j = in.find_first_of(delimiters, i); @@ -1084,18 +1111,19 @@ void stringtok(Container &container, Gnuplot::~Gnuplot() { // remove_tmpfiles(); - // A stream opened by popen() should be closed by pclose() #if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__) if (_pclose(gnucmd) == -1) + { #elif defined(unix) || defined(__unix) || defined(__unix__) || defined(__APPLE__) if (pclose(gnucmd) == -1) + { #endif - // throw GnuplotException("Problem closing communication to gnuplot"); - std::cout << "Gnuplot window left open." << std::endl; + // throw GnuplotException("Problem closing communication to gnuplot"); + std::cout << "Gnuplot window left open." << std::endl; + } } - //------------------------------------------------------------------------------ // // Resets a gnuplot session (next plot will erase previous ones) @@ -1108,7 +1136,6 @@ Gnuplot &Gnuplot::reset_plot() return *this; } - //------------------------------------------------------------------------------ // // resets a gnuplot session and sets all variables to default @@ -1126,7 +1153,6 @@ Gnuplot &Gnuplot::reset_all() return *this; } - //------------------------------------------------------------------------------ // // Change the plotting style of a gnuplot session @@ -1172,7 +1198,6 @@ Gnuplot &Gnuplot::set_style(const std::string &stylestr) return *this; } - //------------------------------------------------------------------------------ // // smooth: interpolation and approximation of data @@ -1501,16 +1526,24 @@ Gnuplot &Gnuplot::plot_slope(const double a, // command to be sent to gnuplot // if (nplots > 0 && two_dim == true) - cmdstr << "replot "; + { + cmdstr << "replot "; + } else - cmdstr << "plot "; + { + cmdstr << "plot "; + } cmdstr << a << " * x + " << b << " title \""; if (title.empty()) - cmdstr << "f(x) = " << a << " * x + " << b; + { + cmdstr << "f(x) = " << a << " * x + " << b; + } else - cmdstr << title; + { + cmdstr << title; + } cmdstr << "\" with " << pstyle; @@ -1535,16 +1568,24 @@ Gnuplot &Gnuplot::plot_equation(const std::string &equation, // command to be sent to gnuplot // if (nplots > 0 && two_dim == true) - cmdstr << "replot "; + { + cmdstr << "replot "; + } else - cmdstr << "plot "; + { + cmdstr << "plot "; + } cmdstr << equation << " title \""; if (title.empty()) - cmdstr << "f(x) = " << equation; + { + cmdstr << "f(x) = " << equation; + } else - cmdstr << title; + { + cmdstr << title; + } cmdstr << "\" with " << pstyle; @@ -1569,16 +1610,24 @@ Gnuplot &Gnuplot::plot_equation3d(const std::string &equation, // command to be sent to gnuplot // if (nplots > 0 && two_dim == false) - cmdstr << "replot "; + { + cmdstr << "replot "; + } else - cmdstr << "splot "; + { + cmdstr << "splot "; + } cmdstr << equation << " title \""; if (title.empty()) - cmdstr << "f(x,y) = " << equation; + { + cmdstr << "f(x,y) = " << equation; + } else - cmdstr << title; + { + cmdstr << title; + } cmdstr << "\" with " << pstyle; @@ -1609,21 +1658,33 @@ Gnuplot &Gnuplot::plotfile_x(const std::string &filename, // command to be sent to gnuplot // if (nplots > 0 && two_dim == true) - cmdstr << "replot "; + { + cmdstr << "replot "; + } else - cmdstr << "plot "; + { + cmdstr << "plot "; + } cmdstr << "\"" << filename << "\" using " << column; if (title.empty()) - cmdstr << " notitle "; + { + cmdstr << " notitle "; + } else - cmdstr << " title \"" << title << "\" "; + { + cmdstr << " title \"" << title << "\" "; + } if (smooth.empty()) - cmdstr << "with " << pstyle; + { + cmdstr << "with " << pstyle; + } else - cmdstr << "smooth " << smooth; + { + cmdstr << "smooth " << smooth; + } // // Do the actual plot @@ -1654,21 +1715,33 @@ Gnuplot &Gnuplot::plotfile_xy(const std::string &filename, // command to be sent to gnuplot // if (nplots > 0 && two_dim == true) - cmdstr << "replot "; + { + cmdstr << "replot "; + } else - cmdstr << "plot "; + { + cmdstr << "plot "; + } cmdstr << "\"" << filename << "\" using " << column_x << ":" << column_y << " every " << std::to_string(decimate); if (title.empty()) - cmdstr << " notitle "; + { + cmdstr << " notitle "; + } else - cmdstr << " title \"" << title << "\" "; + { + cmdstr << " title \"" << title << "\" "; + } if (smooth.empty()) - cmdstr << "with " << pstyle; + { + cmdstr << "with " << pstyle; + } else - cmdstr << "smooth " << smooth; + { + cmdstr << "smooth " << smooth; + } // // Do the actual plot @@ -1699,18 +1772,26 @@ Gnuplot &Gnuplot::plotfile_xy_err(const std::string &filename, // command to be sent to gnuplot // if (nplots > 0 && two_dim == true) - cmdstr << "replot "; + { + cmdstr << "replot "; + } else - cmdstr << "plot "; + { + cmdstr << "plot "; + } cmdstr << "\"" << filename << "\" using " << column_x << ":" << column_y << ":" << column_dy << " with errorbars "; if (title.empty()) - cmdstr << " notitle "; + { + cmdstr << " notitle "; + } else - cmdstr << " title \"" << title << "\" "; + { + cmdstr << " title \"" << title << "\" "; + } // // Do the actual plot @@ -1741,17 +1822,25 @@ Gnuplot &Gnuplot::plotfile_xyz(const std::string &filename, // command to be sent to gnuplot // if (nplots > 0 && two_dim == false) - cmdstr << "replot "; + { + cmdstr << "replot "; + } else - cmdstr << "splot "; + { + cmdstr << "splot "; + } cmdstr << "\"" << filename << "\" using " << column_x << ":" << column_y << ":" << column_z; if (title.empty()) - cmdstr << " notitle with " << pstyle; + { + cmdstr << " notitle with " << pstyle; + } else - cmdstr << " title \"" << title << "\" with " << pstyle; + { + cmdstr << " title \"" << title << "\" with " << pstyle; + } // // Do the actual plot @@ -1774,7 +1863,9 @@ Gnuplot &Gnuplot::plot_image(const unsigned char *ucPicBuf, std::ofstream tmp; std::string name = create_tmpfile(tmp); if (name.empty()) - return *this; + { + return *this; + } // // write the data to file @@ -1797,14 +1888,22 @@ Gnuplot &Gnuplot::plot_image(const unsigned char *ucPicBuf, // command to be sent to gnuplot // if (nplots > 0 && two_dim == true) - cmdstr << "replot "; + { + cmdstr << "replot "; + } else - cmdstr << "plot "; + { + cmdstr << "plot "; + } if (title.empty()) - cmdstr << "\"" << name << "\" with image"; + { + cmdstr << "\"" << name << "\" with image"; + } else - cmdstr << "\"" << name << "\" title \"" << title << "\" with image"; + { + cmdstr << "\"" << name << "\" title \"" << title << "\" with image"; + } // // Do the actual plot @@ -1832,9 +1931,13 @@ Gnuplot &Gnuplot::plot_circle(double east, double north, double radius, const st ", " + std::to_string(north_label) + " norotate back nopoint offset 0,0\n"; } if (nplots > 0) - cmdstr << "replot "; + { + cmdstr << "replot "; + } else - cmdstr << "plot "; + { + cmdstr << "plot "; + } // // Do the actual plot @@ -2154,8 +2257,12 @@ void Gnuplot::remove_tmpfiles() if (!(tmpfile_list).empty()) { for (auto &i : tmpfile_list) - if (remove(i.c_str()) != 0) - std::cout << "Problem closing files" << std::endl; + { + if (remove(i.c_str()) != 0) + { + std::cout << "Problem closing files" << std::endl; + } + } Gnuplot::tmpfile_num -= tmpfile_list.size(); } diff --git a/src/tests/system-tests/position_test.cc b/src/tests/system-tests/position_test.cc index e1ac453be..cb8f8975b 100644 --- a/src/tests/system-tests/position_test.cc +++ b/src/tests/system-tests/position_test.cc @@ -104,7 +104,10 @@ int PositionSystemTest::configure_generator() if (FLAGS_dynamic_position.empty()) { p2 = std::string("-static_position=") + FLAGS_static_position + std::string(",") + std::to_string(std::min(FLAGS_duration * 10, 3000)); - if (FLAGS_duration > 300) std::cout << "WARNING: Duration has been set to its maximum value of 300 s" << std::endl; + if (FLAGS_duration > 300) + { + std::cout << "WARNING: Duration has been set to its maximum value of 300 s" << std::endl; + } } else { @@ -126,7 +129,9 @@ int PositionSystemTest::generate_signal() int pid; if ((pid = fork()) == -1) - perror("fork error"); + { + perror("fork error"); + } else if (pid == 0) { execv(&generator_binary[0], parmList); @@ -135,7 +140,10 @@ int PositionSystemTest::generate_signal() } wait_result = waitpid(pid, &child_status, 0); - if (wait_result == -1) perror("waitpid error"); + if (wait_result == -1) + { + perror("waitpid error"); + } return 0; } diff --git a/src/tests/system-tests/ttff.cc b/src/tests/system-tests/ttff.cc index c5a7ca707..c9186a05f 100644 --- a/src/tests/system-tests/ttff.cc +++ b/src/tests/system-tests/ttff.cc @@ -79,7 +79,7 @@ class TtffTest : public ::testing::Test public: void config_1(); void config_2(); - void print_TTFF_report(const std::vector &ttff_v, const std::shared_ptr& config_); + void print_TTFF_report(const std::vector &ttff_v, const std::shared_ptr &config_); std::shared_ptr config; std::shared_ptr config2; @@ -297,7 +297,7 @@ void receive_msg() } -void TtffTest::print_TTFF_report(const std::vector &ttff_v, const std::shared_ptr& config_) +void TtffTest::print_TTFF_report(const std::vector &ttff_v, const std::shared_ptr &config_) { std::ofstream ttff_report_file; std::string filename = "ttff_report"; @@ -385,7 +385,10 @@ void TtffTest::print_TTFF_report(const std::vector &ttff_v, const std::s stm << "Disabled." << std::endl; } stm << "Valid measurements (" << ttff.size() << "/" << FLAGS_num_measurements << "): "; - for (double ttff_ : ttff) stm << ttff_ << " "; + for (double ttff_ : ttff) + { + stm << ttff_ << " "; + } stm << std::endl; stm << "TTFF mean: " << mean << " [s]" << std::endl; if (!ttff.empty()) diff --git a/src/tests/unit-tests/arithmetic/fft_length_test.cc b/src/tests/unit-tests/arithmetic/fft_length_test.cc index ff5d2fdb6..c8eb8354d 100644 --- a/src/tests/unit-tests/arithmetic/fft_length_test.cc +++ b/src/tests/unit-tests/arithmetic/fft_length_test.cc @@ -151,7 +151,10 @@ TEST(FFTLengthTest, MeasureExecutionTime) g2.set_style("points").plot_xy(powers_of_two, execution_times_powers_of_two, "Power of 2"); g2.savetops("FFT_execution_times"); g2.savetopdf("FFT_execution_times", 18); - if (FLAGS_show_plots) g2.showonscreen(); // window output + if (FLAGS_show_plots) + { + g2.showonscreen(); // window output + } } catch (const GnuplotException& ge) { diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/acq_performance_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/acq_performance_test.cc index 63368b59d..74508dc3c 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/acq_performance_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/acq_performance_test.cc @@ -141,8 +141,7 @@ AcqPerfTest_msg_rx::AcqPerfTest_msg_rx(concurrent_queue& queue) : gr::block } -AcqPerfTest_msg_rx::~AcqPerfTest_msg_rx() -= default; +AcqPerfTest_msg_rx::~AcqPerfTest_msg_rx() = default; // ----------------------------------------- @@ -288,15 +287,23 @@ protected: } Pd.resize(cn0_vector.size()); - for (int i = 0; i < static_cast(cn0_vector.size()); i++) Pd[i].reserve(num_thresholds); + for (int i = 0; i < static_cast(cn0_vector.size()); i++) + { + Pd[i].reserve(num_thresholds); + } Pfa.resize(cn0_vector.size()); - for (int i = 0; i < static_cast(cn0_vector.size()); i++) Pfa[i].reserve(num_thresholds); + for (int i = 0; i < static_cast(cn0_vector.size()); i++) + { + Pfa[i].reserve(num_thresholds); + } Pd_correct.resize(cn0_vector.size()); - for (int i = 0; i < static_cast(cn0_vector.size()); i++) Pd_correct[i].reserve(num_thresholds); + for (int i = 0; i < static_cast(cn0_vector.size()); i++) + { + Pd_correct[i].reserve(num_thresholds); + } } - ~AcquisitionPerformanceTest() - = default; + ~AcquisitionPerformanceTest() = default; std::vector cn0_vector; std::vector pfa_vector; @@ -453,7 +460,9 @@ int AcquisitionPerformanceTest::generate_signal() int pid; if ((pid = fork()) == -1) - perror("fork error"); + { + perror("fork error"); + } else if (pid == 0) { execv(&generator_binary[0], parmList); @@ -462,7 +471,10 @@ int AcquisitionPerformanceTest::generate_signal() } wait_result = waitpid(pid, &child_status, 0); - if (wait_result == -1) perror("waitpid error"); + if (wait_result == -1) + { + perror("waitpid error"); + } return 0; } @@ -783,7 +795,10 @@ TEST_F(AcquisitionPerformanceTest, ROC) std::vector meas_Pd_correct_; std::vector meas_Pfa_; - if (FLAGS_acq_test_input_file.empty()) std::cout << "Execution for CN0 = " << it << " dB-Hz" << std::endl; + if (FLAGS_acq_test_input_file.empty()) + { + std::cout << "Execution for CN0 = " << it << " dB-Hz" << std::endl; + } // Do N_iterations of the experiment for (int pfa_iter = 0; pfa_iter < static_cast(pfa_vector.size()); pfa_iter++) @@ -798,12 +813,18 @@ TEST_F(AcquisitionPerformanceTest, ROC) } // Configure the signal generator - if (FLAGS_acq_test_input_file.empty()) configure_generator(it); + if (FLAGS_acq_test_input_file.empty()) + { + configure_generator(it); + } for (int iter = 0; iter < N_iterations; iter++) { // Generate signal raw signal samples and observations RINEX file - if (FLAGS_acq_test_input_file.empty()) generate_signal(); + if (FLAGS_acq_test_input_file.empty()) + { + generate_signal(); + } for (unsigned k = 0; k < 2; k++) { diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc index 8c1b365e9..a62f21079 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_8ms_ambiguous_acquisition_gsoc2013_test.cc @@ -104,8 +104,7 @@ GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx::GalileoE1Pcps8msAmbiguo rx_message = 0; } -GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx::~GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx() -= default; +GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx::~GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test_msg_rx() = default; // ########################################################### @@ -123,8 +122,7 @@ protected: init(); } - ~GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test() - = default; + ~GalileoE1Pcps8msAmbiguousAcquisitionGSoC2013Test() = default; void init(); void config_1(); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc index 493e8f56f..54910c30f 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc2013_test.cc @@ -105,8 +105,7 @@ GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx::GalileoE1PcpsAmbiguousAcqu rx_message = 0; } -GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx::~GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx() -= default; +GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx::~GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test_msg_rx() = default; // ########################################################### @@ -124,8 +123,7 @@ protected: gnss_synchro = Gnss_Synchro(); } - ~GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test() - = default; + ~GalileoE1PcpsAmbiguousAcquisitionGSoC2013Test() = default; void init(); void config_1(); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc_test.cc index ad9332cc3..6e83b6df6 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_gsoc_test.cc @@ -113,8 +113,7 @@ GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx::GalileoE1PcpsAmbiguousAcquisit rx_message = 0; } -GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx::~GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx() -= default; +GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx::~GalileoE1PcpsAmbiguousAcquisitionGSoCTest_msg_rx() = default; // ########################################################### @@ -133,8 +132,7 @@ protected: gnss_synchro = Gnss_Synchro(); } - ~GalileoE1PcpsAmbiguousAcquisitionGSoCTest() - = default; + ~GalileoE1PcpsAmbiguousAcquisitionGSoCTest() = default; void init(); void start_queue(); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_test.cc index ac68a9229..5e369c576 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_test.cc @@ -107,8 +107,7 @@ GalileoE1PcpsAmbiguousAcquisitionTest_msg_rx::GalileoE1PcpsAmbiguousAcquisitionT } -GalileoE1PcpsAmbiguousAcquisitionTest_msg_rx::~GalileoE1PcpsAmbiguousAcquisitionTest_msg_rx() -= default; +GalileoE1PcpsAmbiguousAcquisitionTest_msg_rx::~GalileoE1PcpsAmbiguousAcquisitionTest_msg_rx() = default; // ########################################################### @@ -126,8 +125,7 @@ protected: doppler_step = 250; } - ~GalileoE1PcpsAmbiguousAcquisitionTest() - = default; + ~GalileoE1PcpsAmbiguousAcquisitionTest() = default; void init(); void plot_grid(); @@ -180,7 +178,10 @@ void GalileoE1PcpsAmbiguousAcquisitionTest::plot_grid() auto samples_per_code = static_cast(round(4000000 / (Galileo_E1_CODE_CHIP_RATE_HZ / Galileo_E1_B_CODE_LENGTH_CHIPS))); // !! acquisition_dump_reader acq_dump(basename, sat, doppler_max, doppler_step, samples_per_code); - if (!acq_dump.read_binary_acq()) std::cout << "Error reading files" << std::endl; + if (!acq_dump.read_binary_acq()) + { + std::cout << "Error reading files" << std::endl; + } std::vector* doppler = &acq_dump.doppler; std::vector* samples = &acq_dump.samples; diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc index c87ebc536..40dbccb66 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_cccwsr_ambiguous_acquisition_gsoc2013_test.cc @@ -105,8 +105,7 @@ GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx::GalileoE1PcpsCccwsrAmbiguous rx_message = 0; } -GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx::~GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx() -= default; +GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx::~GalileoE1PcpsCccwsrAmbiguousAcquisitionTest_msg_rx() = default; // ########################################################### @@ -124,8 +123,7 @@ protected: init(); } - ~GalileoE1PcpsCccwsrAmbiguousAcquisitionTest() - = default; + ~GalileoE1PcpsCccwsrAmbiguousAcquisitionTest() = default; void init(); void config_1(); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc index bc94b1f04..1b3a50e84 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc @@ -114,8 +114,7 @@ GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx::GalileoE1PcpsQuic } -GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx::~GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx() -= default; +GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx::~GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test_msg_rx() = default; // ########################################################### @@ -132,8 +131,7 @@ protected: gnss_synchro = Gnss_Synchro(); init(); } - ~GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test() - = default; + ~GalileoE1PcpsQuickSyncAmbiguousAcquisitionGSoC2014Test() = default; void init(); void config_1(); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc index 578cccf6a..100bae463 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_tong_ambiguous_acquisition_gsoc2013_test.cc @@ -108,8 +108,7 @@ GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx::GalileoE1PcpsTongAmbig } -GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx::~GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx() -= default; +GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx::~GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test_msg_rx() = default; class GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test : public ::testing::Test @@ -125,8 +124,7 @@ protected: init(); } - ~GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test() - = default; + ~GalileoE1PcpsTongAmbiguousAcquisitionGSoC2013Test() = default; void init(); void config_1(); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc index 76f5b5d29..2c2eed08e 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc @@ -105,8 +105,7 @@ GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx::GalileoE5aPcpsAcquisition } -GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx::~GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx() -= default; +GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx::~GalileoE5aPcpsAcquisitionGSoC2014GensourceTest_msg_rx() = default; class GalileoE5aPcpsAcquisitionGSoC2014GensourceTest : public ::testing::Test @@ -121,8 +120,7 @@ protected: init(); } - ~GalileoE5aPcpsAcquisitionGSoC2014GensourceTest() - = default; + ~GalileoE5aPcpsAcquisitionGSoC2014GensourceTest() = default; void init(); void config_1(); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_gsoc2017_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_gsoc2017_test.cc index 29cfd0068..88ef46af5 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_gsoc2017_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_gsoc2017_test.cc @@ -110,8 +110,7 @@ GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx::GlonassL1CaPcpsAcquisitionGSoC201 } -GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx::~GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx() -= default; +GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx::~GlonassL1CaPcpsAcquisitionGSoC2017Test_msg_rx() = default; // ########################################################### @@ -129,8 +128,7 @@ protected: init(); } - ~GlonassL1CaPcpsAcquisitionGSoC2017Test() - = default; + ~GlonassL1CaPcpsAcquisitionGSoC2017Test() = default; void init(); void config_1(); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_test.cc index c1d5bd419..3ed69a462 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_test.cc @@ -104,8 +104,7 @@ GlonassL1CaPcpsAcquisitionTest_msg_rx::GlonassL1CaPcpsAcquisitionTest_msg_rx() : } -GlonassL1CaPcpsAcquisitionTest_msg_rx::~GlonassL1CaPcpsAcquisitionTest_msg_rx() -= default; +GlonassL1CaPcpsAcquisitionTest_msg_rx::~GlonassL1CaPcpsAcquisitionTest_msg_rx() = default; // ########################################################### @@ -121,8 +120,7 @@ protected: gnss_synchro = Gnss_Synchro(); } - ~GlonassL1CaPcpsAcquisitionTest() - = default; + ~GlonassL1CaPcpsAcquisitionTest() = default; void init(); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc index 0e82f6f03..9a6ee1c8e 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_gsoc2013_test.cc @@ -109,8 +109,7 @@ GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx::GpsL1CaPcpsAcquisitionGSoC2013Test_ms rx_message = 0; } -GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx::~GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx() -= default; +GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx::~GpsL1CaPcpsAcquisitionGSoC2013Test_msg_rx() = default; // ########################################################### @@ -128,8 +127,7 @@ protected: init(); } - ~GpsL1CaPcpsAcquisitionGSoC2013Test() - = default; + ~GpsL1CaPcpsAcquisitionGSoC2013Test() = default; void init(); void config_1(); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc index d93f11918..8dd6ef17f 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc @@ -89,7 +89,7 @@ void GpsL1CaPcpsAcquisitionTest_msg_rx::msg_handler_events(pmt::pmt_t msg) { try { - int64_t message = pmt::to_long(std::move(msg)); + int64_t message = pmt::to_long(msg); rx_message = message; } catch (boost::bad_any_cast &e) @@ -179,7 +179,10 @@ void GpsL1CaPcpsAcquisitionTest::plot_grid() auto samples_per_code = static_cast(round(4000000 / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS))); // !! acquisition_dump_reader acq_dump(basename, sat, doppler_max, doppler_step, samples_per_code, 1); - if (!acq_dump.read_binary_acq()) std::cout << "Error reading files" << std::endl; + if (!acq_dump.read_binary_acq()) + { + std::cout << "Error reading files" << std::endl; + } std::vector *doppler = &acq_dump.doppler; std::vector *samples = &acq_dump.samples; diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc index 79515988e..a64b752e8 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test_fpga.cc @@ -36,6 +36,7 @@ #include #include #include +#include #ifdef GR_GREATER_38 #include #else @@ -203,7 +204,7 @@ void GpsL1CaPcpsAcquisitionTestFpga_msg_rx::msg_handler_events(pmt::pmt_t msg) { try { - int64_t message = pmt::to_long(msg); + int64_t message = pmt::to_long(std::move(msg)); rx_message = message; } catch (boost::bad_any_cast &e) @@ -225,9 +226,7 @@ GpsL1CaPcpsAcquisitionTestFpga_msg_rx::GpsL1CaPcpsAcquisitionTestFpga_msg_rx() : } -GpsL1CaPcpsAcquisitionTestFpga_msg_rx::~GpsL1CaPcpsAcquisitionTestFpga_msg_rx() -{ -} +GpsL1CaPcpsAcquisitionTestFpga_msg_rx::~GpsL1CaPcpsAcquisitionTestFpga_msg_rx() = default; class GpsL1CaPcpsAcquisitionTestFpga : public ::testing::Test @@ -241,9 +240,7 @@ protected: gnss_synchro = Gnss_Synchro(); } - ~GpsL1CaPcpsAcquisitionTestFpga() - { - } + ~GpsL1CaPcpsAcquisitionTestFpga() = default; void init(); @@ -385,7 +382,7 @@ TEST_F(GpsL1CaPcpsAcquisitionTestFpga, ValidationOfResults) ASSERT_EQ(1, msg_rx->rx_message) << "Acquisition failure. Expected message: 1=ACQ SUCCESS."; double delay_error_samples = std::abs(expected_delay_samples - gnss_synchro.Acq_delay_samples); - float delay_error_chips = static_cast(delay_error_samples * 1023 / 4000); + auto delay_error_chips = static_cast(delay_error_samples * 1023 / 4000); double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); EXPECT_LE(doppler_error_hz, 666) << "Doppler error exceeds the expected value: 666 Hz = 2/(3*integration period)"; diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc index 48e1bda56..82b06b177 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_quicksync_acquisition_gsoc2014_test.cc @@ -112,8 +112,7 @@ GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx::GpsL1CaPcpsQuickSyncAcquisit } -GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx::~GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx() -= default; +GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx::~GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test_msg_rx() = default; // ########################################################### @@ -130,8 +129,7 @@ protected: gnss_synchro = Gnss_Synchro(); } - ~GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test() - = default; + ~GpsL1CaPcpsQuickSyncAcquisitionGSoC2014Test() = default; void init(); void config_1(); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc index 526bd3476..e9acd6ac9 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_tong_acquisition_gsoc2013_test.cc @@ -107,8 +107,7 @@ GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx::GpsL1CaPcpsTongAcquisitionGSoC201 rx_message = 0; } -GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx::~GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx() -= default; +GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx::~GpsL1CaPcpsTongAcquisitionGSoC2013Test_msg_rx() = default; // ########################################################### @@ -124,8 +123,7 @@ protected: gnss_synchro = Gnss_Synchro(); } - ~GpsL1CaPcpsTongAcquisitionGSoC2013Test() - = default; + ~GpsL1CaPcpsTongAcquisitionGSoC2013Test() = default; void init(); void config_1(); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l2_m_pcps_acquisition_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l2_m_pcps_acquisition_test.cc index 0305870db..8176537e2 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l2_m_pcps_acquisition_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l2_m_pcps_acquisition_test.cc @@ -105,8 +105,7 @@ GpsL2MPcpsAcquisitionTest_msg_rx::GpsL2MPcpsAcquisitionTest_msg_rx() : gr::block rx_message = 0; } -GpsL2MPcpsAcquisitionTest_msg_rx::~GpsL2MPcpsAcquisitionTest_msg_rx() -= default; +GpsL2MPcpsAcquisitionTest_msg_rx::~GpsL2MPcpsAcquisitionTest_msg_rx() = default; // ########################################################### @@ -126,8 +125,7 @@ protected: gnss_synchro = Gnss_Synchro(); } - ~GpsL2MPcpsAcquisitionTest() - = default; + ~GpsL2MPcpsAcquisitionTest() = default; void init(); void plot_grid(); @@ -184,7 +182,10 @@ void GpsL2MPcpsAcquisitionTest::plot_grid() auto samples_per_code = static_cast(floor(static_cast(sampling_frequency_hz) / (GPS_L2_M_CODE_RATE_HZ / static_cast(GPS_L2_M_CODE_LENGTH_CHIPS)))); acquisition_dump_reader acq_dump(basename, sat, doppler_max, doppler_step, samples_per_code, 1); - if (!acq_dump.read_binary_acq()) std::cout << "Error reading files" << std::endl; + if (!acq_dump.read_binary_acq()) + { + std::cout << "Error reading files" << std::endl; + } std::vector *doppler = &acq_dump.doppler; std::vector *samples = &acq_dump.samples; @@ -204,7 +205,7 @@ void GpsL2MPcpsAcquisitionTest::plot_grid() { boost::filesystem::path p(gnuplot_executable); boost::filesystem::path dir = p.parent_path(); - const std::string& gnuplot_path = dir.native(); + const std::string &gnuplot_path = dir.native(); Gnuplot::set_GNUPlotPath(gnuplot_path); Gnuplot g1("impulses"); diff --git a/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc b/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc index 9c411c862..42fb1496a 100644 --- a/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/filter/fir_filter_test.cc @@ -137,7 +137,10 @@ TEST_F(FirFilterTest, InstantiateGrComplexGrComplex) configure_gr_complex_gr_complex(); std::unique_ptr filter(new FirFilter(config.get(), "InputFilter", 1, 1)); int res = 0; - if (filter) res = 1; + if (filter) + { + res = 1; + } ASSERT_EQ(1, res); } @@ -147,7 +150,10 @@ TEST_F(FirFilterTest, InstantiateCshortCshort) configure_cshort_cshort(); std::unique_ptr filter(new FirFilter(config.get(), "InputFilter", 1, 1)); int res = 0; - if (filter) res = 1; + if (filter) + { + res = 1; + } ASSERT_EQ(1, res); } @@ -158,7 +164,10 @@ TEST_F(FirFilterTest, InstantiateCbyteCbyte) configure_cbyte_cbyte(); std::unique_ptr filter(new FirFilter(config.get(), "InputFilter", 1, 1)); int res = 0; - if (filter) res = 1; + if (filter) + { + res = 1; + } ASSERT_EQ(1, res); } @@ -169,7 +178,10 @@ TEST_F(FirFilterTest, InstantiateCbyteGrComplex) configure_cbyte_gr_complex(); std::unique_ptr filter(new FirFilter(config.get(), "InputFilter", 1, 1)); int res = 0; - if (filter) res = 1; + if (filter) + { + res = 1; + } ASSERT_EQ(1, res); } diff --git a/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc b/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc index f23a84558..a77e9d853 100644 --- a/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_lite_test.cc @@ -95,7 +95,10 @@ TEST_F(NotchFilterLiteTest, InstantiateGrComplexGrComplex) configure_gr_complex_gr_complex(); std::unique_ptr filter(new NotchFilterLite(config.get(), "InputFilter", 1, 1)); int res = 0; - if (filter) res = 1; + if (filter) + { + res = 1; + } ASSERT_EQ(1, res); } diff --git a/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_test.cc b/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_test.cc index b3c9fbece..943ac2fe2 100644 --- a/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/filter/notch_filter_test.cc @@ -95,7 +95,10 @@ TEST_F(NotchFilterTest, InstantiateGrComplexGrComplex) configure_gr_complex_gr_complex(); std::unique_ptr filter(new NotchFilter(config.get(), "InputFilter", 1, 1)); int res = 0; - if (filter) res = 1; + if (filter) + { + res = 1; + } ASSERT_EQ(1, res); } diff --git a/src/tests/unit-tests/signal-processing-blocks/filter/pulse_blanking_filter_test.cc b/src/tests/unit-tests/signal-processing-blocks/filter/pulse_blanking_filter_test.cc index 729ff78dd..83a63d551 100644 --- a/src/tests/unit-tests/signal-processing-blocks/filter/pulse_blanking_filter_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/filter/pulse_blanking_filter_test.cc @@ -94,7 +94,10 @@ TEST_F(PulseBlankingFilterTest, InstantiateGrComplexGrComplex) configure_gr_complex_gr_complex(); std::unique_ptr filter(new PulseBlankingFilter(config.get(), "InputFilter", 1, 1)); int res = 0; - if (filter) res = 1; + if (filter) + { + res = 1; + } ASSERT_EQ(1, res); } diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc index f401b1bc9..f671a9b34 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc +++ b/src/tests/unit-tests/signal-processing-blocks/libs/acquisition_dump_reader.cc @@ -60,8 +60,14 @@ bool acquisition_dump_reader::read_binary_acq() if ((var_->dims[0] != d_samples_per_code) or (var_->dims[1] != d_num_doppler_bins)) { std::cout << "Invalid Acquisition dump file: dimension matrix error" << std::endl; - if (var_->dims[0] != d_samples_per_code) std::cout << "Expected " << d_samples_per_code << " samples per code. Obtained " << var_->dims[0] << std::endl; - if (var_->dims[1] != d_num_doppler_bins) std::cout << "Expected " << d_num_doppler_bins << " Doppler bins. Obtained " << var_->dims[1] << std::endl; + if (var_->dims[0] != d_samples_per_code) + { + std::cout << "Expected " << d_samples_per_code << " samples per code. Obtained " << var_->dims[0] << std::endl; + } + if (var_->dims[1] != d_num_doppler_bins) + { + std::cout << "Expected " << d_num_doppler_bins << " Doppler bins. Obtained " << var_->dims[1] << std::endl; + } Mat_VarFree(var_); Mat_Close(matfile); return false; @@ -218,7 +224,10 @@ acquisition_dump_reader::acquisition_dump_reader(const std::string& basename, sample_counter = 0; num_dwells = 0; PRN = 0; - if (d_doppler_step == 0) d_doppler_step = 1; + if (d_doppler_step == 0) + { + d_doppler_step = 1; + } d_num_doppler_bins = static_cast(ceil(static_cast(static_cast(d_doppler_max) - static_cast(-d_doppler_max)) / static_cast(d_doppler_step))); std::vector > mag_aux(d_num_doppler_bins, std::vector(d_samples_per_code)); mag = mag_aux; diff --git a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test.cc b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test.cc index 10012705b..946e43b80 100644 --- a/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/observables/hybrid_observables_test.cc @@ -133,8 +133,7 @@ HybridObservablesTest_msg_rx::HybridObservablesTest_msg_rx() : gr::block("Hybrid rx_message = 0; } -HybridObservablesTest_msg_rx::~HybridObservablesTest_msg_rx() -= default; +HybridObservablesTest_msg_rx::~HybridObservablesTest_msg_rx() = default; // ########################################################### @@ -185,8 +184,7 @@ HybridObservablesTest_tlm_msg_rx::HybridObservablesTest_tlm_msg_rx() : gr::block rx_message = 0; } -HybridObservablesTest_tlm_msg_rx::~HybridObservablesTest_tlm_msg_rx() -= default; +HybridObservablesTest_tlm_msg_rx::~HybridObservablesTest_tlm_msg_rx() = default; // ########################################################### @@ -278,8 +276,7 @@ public: mapStringValues_["2G"] = evGLO_2G; } - ~HybridObservablesTest() - = default; + ~HybridObservablesTest() = default; bool ReadRinexObs(std::vector* obs_vec, Gnss_Synchro gnss); @@ -330,7 +327,9 @@ int HybridObservablesTest::generate_signal() int pid; if ((pid = fork()) == -1) - perror("fork err"); + { + perror("fork err"); + } else if (pid == 0) { execv(&generator_binary[0], parmList); @@ -662,9 +661,13 @@ void HybridObservablesTest::configure_receiver( config = std::make_shared(); config->set_property("Tracking.dump", "true"); if (high_dyn) - config->set_property("Tracking.high_dyn", "true"); + { + config->set_property("Tracking.high_dyn", "true"); + } else - config->set_property("Tracking.high_dyn", "false"); + { + config->set_property("Tracking.high_dyn", "false"); + } config->set_property("Tracking.smoother_length", std::to_string(smoother_length)); config->set_property("Tracking.dump_filename", "./tracking_ch_"); config->set_property("Tracking.implementation", implementation); @@ -1677,7 +1680,7 @@ TEST_F(HybridObservablesTest, ValidationOfResults) FLAGS_high_dyn); - for (auto & n : gnss_synchro_vec) + for (auto& n : gnss_synchro_vec) { //setup the signal synchronization, simulating an acquisition if (!FLAGS_enable_external_signal_file) @@ -1775,7 +1778,7 @@ TEST_F(HybridObservablesTest, ValidationOfResults) //Observables std::shared_ptr observables(new HybridObservables(config.get(), "Observables", tracking_ch_vec.size() + 1, tracking_ch_vec.size())); - for (auto & n : tracking_ch_vec) + for (auto& n : tracking_ch_vec) { ASSERT_NO_THROW({ n->connect(top_block); @@ -1815,7 +1818,7 @@ TEST_F(HybridObservablesTest, ValidationOfResults) file_source->seek(2 * FLAGS_skip_samples, 0); //skip head. ibyte, two bytes per complex sample }) << "Failure connecting the blocks."; - for (auto & n : tracking_ch_vec) + for (auto& n : tracking_ch_vec) { n->start_tracking(); } @@ -1921,7 +1924,7 @@ TEST_F(HybridObservablesTest, ValidationOfResults) //Cut measurement tail zeros arma::uvec index; - for (auto & n : measured_obs_vec) + for (auto& n : measured_obs_vec) { index = arma::find(n.col(0) > 0.0, 1, "last"); if ((!index.empty()) and index(0) < (nepoch - 1)) @@ -1961,7 +1964,9 @@ TEST_F(HybridObservablesTest, ValidationOfResults) { prn_pairs.push_back(i); if (ss.peek() == ',') - ss.ignore(); + { + ss.ignore(); + } } if (prn_pairs.size() % 2 != 0) diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc index 72522a769..60e496ede 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/nmea_printer_test.cc @@ -42,8 +42,7 @@ protected: { this->conf(); } - ~NmeaPrinterTest() - = default; + ~NmeaPrinterTest() = default; void conf(); rtk_t rtk; }; diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc index c4a559448..2f5e819f0 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/rinex_printer_test.cc @@ -58,7 +58,10 @@ TEST(RinexPrinterTest, GalileoObsHeader) } std::string expected_str("E 4 C1B L1B D1B S1B SYS / # / OBS TYPES "); EXPECT_EQ(0, expected_str.compare(line_aux)); - if (remove(rp1->obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(rp1->obsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } line_aux.clear(); std::shared_ptr rp2; @@ -82,7 +85,10 @@ TEST(RinexPrinterTest, GalileoObsHeader) std::string expected_str2("E 12 C1B L1B D1B S1B C5X L5X D5X S5X C7X L7X D7X S7X SYS / # / OBS TYPES "); EXPECT_EQ(0, expected_str2.compare(line_aux)); - if (remove(rp2->obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(rp2->obsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } @@ -113,7 +119,10 @@ TEST(RinexPrinterTest, GlonassObsHeader) } std::string expected_str("R 4 C1C L1C D1C S1C SYS / # / OBS TYPES "); EXPECT_EQ(0, expected_str.compare(line_aux)); - if (remove(rp1->obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(rp1->obsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } line_aux.clear(); } @@ -158,7 +167,10 @@ TEST(RinexPrinterTest, MixedObsHeader) std::string expected_str2("E 8 C1B L1B D1B S1B C5X L5X D5X S5X SYS / # / OBS TYPES "); EXPECT_EQ(0, expected_str.compare(line_aux)); EXPECT_EQ(0, expected_str2.compare(line_aux2)); - if (remove(rp1->obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(rp1->obsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } @@ -202,7 +214,10 @@ TEST(RinexPrinterTest, MixedObsHeaderGpsGlo) std::string expected_str2("R 4 C1C L1C D1C S1C SYS / # / OBS TYPES "); EXPECT_EQ(0, expected_str.compare(line_aux)); EXPECT_EQ(0, expected_str2.compare(line_aux2)); - if (remove(rp1->obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(rp1->obsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } @@ -270,7 +285,10 @@ TEST(RinexPrinterTest, GalileoObsLog) std::string expected_str("E22 22000000.000 7 3.724 7 1534.000 7 42.000 "); EXPECT_EQ(0, expected_str.compare(line_aux)); - if (remove(rp->obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(rp->obsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } @@ -338,7 +356,10 @@ TEST(RinexPrinterTest, GlonassObsLog) std::string expected_str("R22 22000000.000 7 3.724 7 1534.000 7 42.000 "); EXPECT_EQ(0, expected_str.compare(line_aux)); - if (remove(rp->obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(rp->obsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } @@ -419,7 +440,10 @@ TEST(RinexPrinterTest, GpsObsLogDualBand) std::string expected_str("G08 22000002.100 6 7.226 6 321.000 6 39.000 22000000.000 7 3.724 7 1534.000 7 42.000"); EXPECT_EQ(0, expected_str.compare(line_aux)); - if (remove(rp->obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(rp->obsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } @@ -500,7 +524,10 @@ TEST(RinexPrinterTest, GalileoObsLogDualBand) std::string expected_str("E08 22000002.100 6 7.226 6 321.000 6 39.000 22000000.000 7 3.724 7 1534.000 7 42.000"); EXPECT_EQ(0, expected_str.compare(line_aux)); - if (remove(rp->obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(rp->obsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } @@ -610,7 +637,10 @@ TEST(RinexPrinterTest, MixedObsLog) std::string expected_str("E16 22000000.000 7 0.127 7 -20.000 7 42.000 22000000.000 6 8.292 6 1534.000 6 41.000"); EXPECT_EQ(0, expected_str.compare(line_aux)); - if (remove(rp->obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(rp->obsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } @@ -719,5 +749,8 @@ TEST(RinexPrinterTest, MixedObsLogGpsGlo) std::string expected_str("R16 22000000.000 6 8.292 6 1534.000 6 41.000 22000000.000 7 0.127 7 -20.000 7 42.000"); EXPECT_EQ(0, expected_str.compare(line_aux)); - if (remove(rp->obsfilename.c_str()) != 0) LOG(INFO) << "Error deleting temporary file"; + if (remove(rp->obsfilename.c_str()) != 0) + { + LOG(INFO) << "Error deleting temporary file"; + } } diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/rtklib_solver_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/rtklib_solver_test.cc index 2bf2b0a12..28b69ce0d 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/rtklib_solver_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/rtklib_solver_test.cc @@ -58,11 +58,26 @@ rtk_t configure_rtklib_options() int positioning_mode = -1; std::string default_pos_mode("Single"); std::string positioning_mode_str = configuration->property(role + ".positioning_mode", default_pos_mode); /* (PMODE_XXX) see src/algorithms/libs/rtklib/rtklib.h */ - if (positioning_mode_str == "Single") positioning_mode = PMODE_SINGLE; - if (positioning_mode_str == "Static") positioning_mode = PMODE_STATIC; - if (positioning_mode_str == "Kinematic") positioning_mode = PMODE_KINEMA; - if (positioning_mode_str == "PPP_Static") positioning_mode = PMODE_PPP_STATIC; - if (positioning_mode_str == "PPP_Kinematic") positioning_mode = PMODE_PPP_KINEMA; + if (positioning_mode_str == "Single") + { + positioning_mode = PMODE_SINGLE; + } + if (positioning_mode_str == "Static") + { + positioning_mode = PMODE_STATIC; + } + if (positioning_mode_str == "Kinematic") + { + positioning_mode = PMODE_KINEMA; + } + if (positioning_mode_str == "PPP_Static") + { + positioning_mode = PMODE_PPP_STATIC; + } + if (positioning_mode_str == "PPP_Kinematic") + { + positioning_mode = PMODE_PPP_KINEMA; + } if (positioning_mode == -1) { @@ -107,12 +122,30 @@ rtk_t configure_rtklib_options() std::string default_iono_model("OFF"); std::string iono_model_str = configuration->property(role + ".iono_model", default_iono_model); /* (IONOOPT_XXX) see src/algorithms/libs/rtklib/rtklib.h */ int iono_model = -1; - if (iono_model_str == "OFF") iono_model = IONOOPT_OFF; - if (iono_model_str == "Broadcast") iono_model = IONOOPT_BRDC; - if (iono_model_str == "SBAS") iono_model = IONOOPT_SBAS; - if (iono_model_str == "Iono-Free-LC") iono_model = IONOOPT_IFLC; - if (iono_model_str == "Estimate_STEC") iono_model = IONOOPT_EST; - if (iono_model_str == "IONEX") iono_model = IONOOPT_TEC; + if (iono_model_str == "OFF") + { + iono_model = IONOOPT_OFF; + } + if (iono_model_str == "Broadcast") + { + iono_model = IONOOPT_BRDC; + } + if (iono_model_str == "SBAS") + { + iono_model = IONOOPT_SBAS; + } + if (iono_model_str == "Iono-Free-LC") + { + iono_model = IONOOPT_IFLC; + } + if (iono_model_str == "Estimate_STEC") + { + iono_model = IONOOPT_EST; + } + if (iono_model_str == "IONEX") + { + iono_model = IONOOPT_TEC; + } if (iono_model == -1) { //warn user and set the default @@ -126,11 +159,26 @@ rtk_t configure_rtklib_options() std::string default_trop_model("OFF"); int trop_model = -1; std::string trop_model_str = configuration->property(role + ".trop_model", default_trop_model); /* (TROPOPT_XXX) see src/algorithms/libs/rtklib/rtklib.h */ - if (trop_model_str == "OFF") trop_model = TROPOPT_OFF; - if (trop_model_str == "Saastamoinen") trop_model = TROPOPT_SAAS; - if (trop_model_str == "SBAS") trop_model = TROPOPT_SBAS; - if (trop_model_str == "Estimate_ZTD") trop_model = TROPOPT_EST; - if (trop_model_str == "Estimate_ZTD_Grad") trop_model = TROPOPT_ESTG; + if (trop_model_str == "OFF") + { + trop_model = TROPOPT_OFF; + } + if (trop_model_str == "Saastamoinen") + { + trop_model = TROPOPT_SAAS; + } + if (trop_model_str == "SBAS") + { + trop_model = TROPOPT_SBAS; + } + if (trop_model_str == "Estimate_ZTD") + { + trop_model = TROPOPT_EST; + } + if (trop_model_str == "Estimate_ZTD_Grad") + { + trop_model = TROPOPT_ESTG; + } if (trop_model == -1) { //warn user and set the default @@ -175,11 +223,26 @@ rtk_t configure_rtklib_options() std::string default_gps_ar("Continuous"); std::string integer_ambiguity_resolution_gps_str = configuration->property(role + ".AR_GPS", default_gps_ar); /* Integer Ambiguity Resolution mode for GPS (0:off,1:continuous,2:instantaneous,3:fix and hold,4:ppp-ar) */ int integer_ambiguity_resolution_gps = -1; - if (integer_ambiguity_resolution_gps_str == "OFF") integer_ambiguity_resolution_gps = ARMODE_OFF; - if (integer_ambiguity_resolution_gps_str == "Continuous") integer_ambiguity_resolution_gps = ARMODE_CONT; - if (integer_ambiguity_resolution_gps_str == "Instantaneous") integer_ambiguity_resolution_gps = ARMODE_INST; - if (integer_ambiguity_resolution_gps_str == "Fix-and-Hold") integer_ambiguity_resolution_gps = ARMODE_FIXHOLD; - if (integer_ambiguity_resolution_gps_str == "PPP-AR") integer_ambiguity_resolution_gps = ARMODE_PPPAR; + if (integer_ambiguity_resolution_gps_str == "OFF") + { + integer_ambiguity_resolution_gps = ARMODE_OFF; + } + if (integer_ambiguity_resolution_gps_str == "Continuous") + { + integer_ambiguity_resolution_gps = ARMODE_CONT; + } + if (integer_ambiguity_resolution_gps_str == "Instantaneous") + { + integer_ambiguity_resolution_gps = ARMODE_INST; + } + if (integer_ambiguity_resolution_gps_str == "Fix-and-Hold") + { + integer_ambiguity_resolution_gps = ARMODE_FIXHOLD; + } + if (integer_ambiguity_resolution_gps_str == "PPP-AR") + { + integer_ambiguity_resolution_gps = ARMODE_PPPAR; + } if (integer_ambiguity_resolution_gps == -1) { //warn user and set the default diff --git a/src/tests/unit-tests/signal-processing-blocks/telemetry_decoder/gps_l1_ca_telemetry_decoder_test.cc b/src/tests/unit-tests/signal-processing-blocks/telemetry_decoder/gps_l1_ca_telemetry_decoder_test.cc index 518472edd..28da8661d 100644 --- a/src/tests/unit-tests/signal-processing-blocks/telemetry_decoder/gps_l1_ca_telemetry_decoder_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/telemetry_decoder/gps_l1_ca_telemetry_decoder_test.cc @@ -109,8 +109,7 @@ GpsL1CADllPllTelemetryDecoderTest_msg_rx::GpsL1CADllPllTelemetryDecoderTest_msg_ rx_message = 0; } -GpsL1CADllPllTelemetryDecoderTest_msg_rx::~GpsL1CADllPllTelemetryDecoderTest_msg_rx() -= default; +GpsL1CADllPllTelemetryDecoderTest_msg_rx::~GpsL1CADllPllTelemetryDecoderTest_msg_rx() = default; // ########################################################### @@ -161,8 +160,7 @@ GpsL1CADllPllTelemetryDecoderTest_tlm_msg_rx::GpsL1CADllPllTelemetryDecoderTest_ rx_message = 0; } -GpsL1CADllPllTelemetryDecoderTest_tlm_msg_rx::~GpsL1CADllPllTelemetryDecoderTest_tlm_msg_rx() -= default; +GpsL1CADllPllTelemetryDecoderTest_tlm_msg_rx::~GpsL1CADllPllTelemetryDecoderTest_tlm_msg_rx() = default; // ########################################################### @@ -198,8 +196,7 @@ public: gnss_synchro = Gnss_Synchro(); } - ~GpsL1CATelemetryDecoderTest() - = default; + ~GpsL1CATelemetryDecoderTest() = default; void configure_receiver(); @@ -240,7 +237,9 @@ int GpsL1CATelemetryDecoderTest::generate_signal() int pid; if ((pid = fork()) == -1) - perror("fork err"); + { + perror("fork err"); + } else if (pid == 0) { execv(&generator_binary[0], parmList); diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/galileo_e5a_tracking_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/galileo_e5a_tracking_test.cc index 1094fbd7f..122184eb7 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/galileo_e5a_tracking_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/galileo_e5a_tracking_test.cc @@ -65,8 +65,7 @@ protected: gnss_synchro = Gnss_Synchro(); } - ~GalileoE5aTrackingTest() - = default; + ~GalileoE5aTrackingTest() = default; void init(); diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/glonass_l1_ca_dll_pll_c_aid_tracking_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/glonass_l1_ca_dll_pll_c_aid_tracking_test.cc index c8a6f94d0..003c63a9d 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/glonass_l1_ca_dll_pll_c_aid_tracking_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/glonass_l1_ca_dll_pll_c_aid_tracking_test.cc @@ -98,8 +98,7 @@ GlonassL1CaDllPllCAidTrackingTest_msg_rx::GlonassL1CaDllPllCAidTrackingTest_msg_ rx_message = 0; } -GlonassL1CaDllPllCAidTrackingTest_msg_rx::~GlonassL1CaDllPllCAidTrackingTest_msg_rx() -= default; +GlonassL1CaDllPllCAidTrackingTest_msg_rx::~GlonassL1CaDllPllCAidTrackingTest_msg_rx() = default; // ########################################################### @@ -116,8 +115,7 @@ protected: gnss_synchro = Gnss_Synchro(); } - ~GlonassL1CaDllPllCAidTrackingTest() - = default; + ~GlonassL1CaDllPllCAidTrackingTest() = default; void init(); diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/glonass_l1_ca_dll_pll_tracking_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/glonass_l1_ca_dll_pll_tracking_test.cc index d83116a49..20a910ce4 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/glonass_l1_ca_dll_pll_tracking_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/glonass_l1_ca_dll_pll_tracking_test.cc @@ -99,8 +99,7 @@ GlonassL1CaDllPllTrackingTest_msg_rx::GlonassL1CaDllPllTrackingTest_msg_rx() : g rx_message = 0; } -GlonassL1CaDllPllTrackingTest_msg_rx::~GlonassL1CaDllPllTrackingTest_msg_rx() -= default; +GlonassL1CaDllPllTrackingTest_msg_rx::~GlonassL1CaDllPllTrackingTest_msg_rx() = default; // ########################################################### @@ -117,8 +116,7 @@ protected: gnss_synchro = Gnss_Synchro(); } - ~GlonassL1CaDllPllTrackingTest() - = default; + ~GlonassL1CaDllPllTrackingTest() = default; void init(); diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc index b9750b5e3..8fcd3a726 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc @@ -110,8 +110,7 @@ GpsL1CADllPllTrackingTest_msg_rx::GpsL1CADllPllTrackingTest_msg_rx() : gr::block } -GpsL1CADllPllTrackingTest_msg_rx::~GpsL1CADllPllTrackingTest_msg_rx() -= default; +GpsL1CADllPllTrackingTest_msg_rx::~GpsL1CADllPllTrackingTest_msg_rx() = default; // ########################################################### @@ -166,8 +165,7 @@ public: gnss_synchro = Gnss_Synchro(); } - ~GpsL1CADllPllTrackingTest() - = default; + ~GpsL1CADllPllTrackingTest() = default; void configure_receiver(double PLL_wide_bw_hz, double DLL_wide_bw_hz, @@ -213,7 +211,9 @@ int GpsL1CADllPllTrackingTest::generate_signal() int pid; if ((pid = fork()) == -1) - perror("fork err"); + { + perror("fork err"); + } else if (pid == 0) { execv(&generator_binary[0], parmList); diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc index fc7b028fe..0f93e68d7 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc @@ -143,7 +143,7 @@ void sending_thread(gr::top_block_sptr top_block, const char *file_name) usleep(FIVE_SECONDS); // wait for some time to give time to the other thread to program the device //send_tracking_gps_input_samples(dma_descr, rx_signal_file, file_length); - send_tracking_gps_input_samples(rx_signal_file, file_length, std::move(top_block)); + send_tracking_gps_input_samples(rx_signal_file, file_length, top_block); fclose(rx_signal_file); } diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_kf_tracking_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_kf_tracking_test.cc index 341185dad..f987d1973 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_kf_tracking_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_kf_tracking_test.cc @@ -111,8 +111,7 @@ GpsL1CAKfTrackingTest_msg_rx::GpsL1CAKfTrackingTest_msg_rx() : gr::block("GpsL1C } -GpsL1CAKfTrackingTest_msg_rx::~GpsL1CAKfTrackingTest_msg_rx() -= default; +GpsL1CAKfTrackingTest_msg_rx::~GpsL1CAKfTrackingTest_msg_rx() = default; // ########################################################### @@ -157,8 +156,7 @@ public: gnss_synchro = Gnss_Synchro(); } - ~GpsL1CAKfTrackingTest() - = default; + ~GpsL1CAKfTrackingTest() = default; void configure_receiver(); @@ -199,7 +197,9 @@ int GpsL1CAKfTrackingTest::generate_signal() int pid; if ((pid = fork()) == -1) - perror("fork err"); + { + perror("fork err"); + } else if (pid == 0) { execv(&generator_binary[0], parmList); diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l2_m_dll_pll_tracking_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l2_m_dll_pll_tracking_test.cc index fe9cd4c85..3b6b325a4 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l2_m_dll_pll_tracking_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l2_m_dll_pll_tracking_test.cc @@ -103,8 +103,7 @@ GpsL2MDllPllTrackingTest_msg_rx::GpsL2MDllPllTrackingTest_msg_rx() : gr::block(" } -GpsL2MDllPllTrackingTest_msg_rx::~GpsL2MDllPllTrackingTest_msg_rx() -= default; +GpsL2MDllPllTrackingTest_msg_rx::~GpsL2MDllPllTrackingTest_msg_rx() = default; // ########################################################### @@ -120,8 +119,7 @@ protected: gnss_synchro = Gnss_Synchro(); } - ~GpsL2MDllPllTrackingTest() - = default; + ~GpsL2MDllPllTrackingTest() = default; void init(); diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test.cc index e64973c8f..15756f3bc 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test.cc @@ -126,8 +126,7 @@ TrackingPullInTest_msg_rx::TrackingPullInTest_msg_rx() : gr::block("TrackingPull } -TrackingPullInTest_msg_rx::~TrackingPullInTest_msg_rx() -= default; +TrackingPullInTest_msg_rx::~TrackingPullInTest_msg_rx() = default; // ########################################################### @@ -202,8 +201,7 @@ public: mapStringValues_["2G"] = evGLO_2G; } - ~TrackingPullInTest() - = default; + ~TrackingPullInTest() = default; void configure_receiver(double PLL_wide_bw_hz, double DLL_wide_bw_hz, @@ -252,7 +250,9 @@ int TrackingPullInTest::generate_signal() int pid; if ((pid = fork()) == -1) - perror("fork err"); + { + perror("fork err"); + } else if (pid == 0) { execv(&generator_binary[0], parmList); @@ -716,7 +716,10 @@ TEST_F(TrackingPullInTest, ValidationOfResults) ASSERT_EQ(acquire_signal(FLAGS_test_satellite_PRN), true); bool found_satellite = doppler_measurements_map.find(FLAGS_test_satellite_PRN) != doppler_measurements_map.end(); EXPECT_TRUE(found_satellite) << "Error: satellite SV: " << FLAGS_test_satellite_PRN << " is not acquired"; - if (!found_satellite) return; + if (!found_satellite) + { + return; + } } else {