diff --git a/CMakeLists.txt b/CMakeLists.txt index 2e90646f5..d5f1f79a9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,9 +41,10 @@ endif(NOT CMAKE_PREFIX_PATH) ######################################################################## # Determine optional blocks/libraries to be built (default: not built) -# Enable them here or at the command line by doing 'cmake -DENABLE_XXX=ON ../' +# Enable them at the command line by doing 'cmake -DENABLE_XXX=ON ../' ######################################################################## # Support of optional RF front-ends +option(ENABLE_UHD "Enable the use of UHD (driver for all USRP devices)" ON) option(ENABLE_OSMOSDR "Enable the use of OsmoSDR and other front-ends (RTL-based dongles, HackRF, bladeRF, etc.) as signal source (experimental)" OFF) option(ENABLE_FLEXIBAND "Enable the use of the signal source adater for the Teleorbit Flexiband GNURadio driver" OFF) option(ENABLE_ARRAY "Enable the use of CTTC's antenna array front-end as signal source (experimental)" OFF) @@ -1195,18 +1196,18 @@ endif(NOT MATIO_FOUND OR MATIO_VERSION_STRING VERSION_LESS ${GNSSSDR_MATIO_MIN_V ################################################################################ # USRP Hardware Driver (UHD) - OPTIONAL ################################################################################ -find_package(UHD) -if(NOT UHD_FOUND) - set(ENABLE_UHD OFF) - message(STATUS " The USRP Hardware Driver (UHD) signal source will not be built,") - message(STATUS " so all USRP-based front-ends will not be usable.") - message(STATUS " Please check http://files.ettus.com/manual/") -else(NOT UHD_FOUND) - set(GR_REQUIRED_COMPONENTS UHD) - find_package(Gnuradio) - set(ENABLE_UHD ON) -endif(NOT UHD_FOUND) - +if(ENABLE_UHD) + find_package(UHD) + if(NOT UHD_FOUND) + set(ENABLE_UHD OFF) + message(STATUS " The USRP Hardware Driver (UHD) signal source will not be built,") + message(STATUS " so all USRP-based front-ends will not be usable.") + message(STATUS " Please check http://files.ettus.com/manual/") + else(NOT UHD_FOUND) + set(GR_REQUIRED_COMPONENTS UHD) + find_package(Gnuradio) + endif(NOT UHD_FOUND) +endif(ENABLE_UHD) ################################################################################ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8af901f52..7a87240cb 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -67,7 +67,7 @@ GitHub](https://github.com/join). GitHub](https://github.com/gnss-sdr/gnss-sdr/fork). This will copy the whole gnss-sdr repository to your personal account. - 3. Then, go to your favourite working folder in your computer and + 3. Then, go to your favorite working folder in your computer and clone your forked repository by typing (replacing ```YOUR_USERNAME``` by the actual username of your GitHub account): @@ -128,7 +128,7 @@ $ git pull --rebase upstream next ### How to submit a pull request -Before submitting you code, please be sure to [apply clang-format](http://gnss-sdr.org/coding-style/#use-tools-for-automated-code-formatting). +Before submitting your code, please be sure to [apply clang-format](http://gnss-sdr.org/coding-style/#use-tools-for-automated-code-formatting). When the contribution is ready, you can [submit a pull request](https://github.com/gnss-sdr/gnss-sdr/compare/). Head to your diff --git a/README.md b/README.md index 2a7b6d821..270eaf8d5 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,7 @@ In the L1 band (centered at 1575.42 MHz): In the L2 band (centered at 1227.60 MHz): - 🛰 GPS L2C :white_check_mark: + - 🛰 GLONASS L2 C/A :white_check_mark: In the L5 band (centered at 1176.45 MHz): - 🛰 GPS L5 :white_check_mark: @@ -52,7 +53,7 @@ Before building GNSS-SDR, you need to install all the required dependencies. The ### Alternative 1: Install dependencies using software packages -If you want to start building and running GNSS-SDR as quick and easy as possible, the best option is to install all the required dependencies as binary packages. +If you want to start building and running GNSS-SDR as quick and easy as possible, the best option is to install all the required dependencies as binary packages. #### Debian / Ubuntu @@ -84,7 +85,7 @@ $ sudo yum install make automake gcc gcc-c++ kernel-devel cmake git boost-devel boost-date-time boost-system boost-filesystem boost-thread boost-chrono \ boost-serialization log4cpp-devel gnuradio-devel gr-osmosdr-devel \ blas-devel lapack-devel matio-devel armadillo-devel gflags-devel \ - glog-devel openssl-devel python-mako python-six + glog-devel openssl-devel python-mako python-six ~~~~~~ Once you have installed these packages, you can jump directly to [download the source code and build GNSS-SDR](#download-and-build-linux). @@ -303,7 +304,7 @@ $ cmake ../ $ make ~~~~~~ -By default, CMake will build the Release version, meaning that the compiler will generate a fast, optimized executable. This is the recommended build type when using a RF front-end and you need to attain real time. If working with a file (and thus without real-time constraints), you may want to obtain more information about the internals of the receiver, as well as more fine-grained logging. This can be done by building the Debug version, by doing: +By default, CMake will build the Release version, meaning that the compiler will generate a fast, optimized executable. This is the recommended build type when using an RF front-end and you need to attain real time. If working with a file (and thus without real-time constraints), you may want to obtain more information about the internals of the receiver, as well as more fine-grained logging. This can be done by building the Debug version, by doing: ~~~~~~ $ cmake -DCMAKE_BUILD_TYPE=Debug ../ @@ -696,8 +697,8 @@ Getting started 2. You will need a GPS active antenna, a [USRP](http://www.ettus.com/product) and a suitable USRP daughter board to receive GPS L1 C/A signals. GNSS-SDR require to have at least 2 MHz of bandwidth in 1.57542 GHz. (remember to enable the DC bias with the daughter board jumper). We use a [DBSRX2](https://www.ettus.com/product/details/DBSRX2) to do the task, but you can try the newer Ettus' daughter boards as well. 3. The easiest way to capture a signal file is to use the GNU Radio Companion GUI. Only two blocks are needed: a USRP signal source connected to complex float file sink. You need to tune the USRP central frequency and decimation factor using USRP signal source properties box. We suggest using a decimation factor of 20 if you use the USRP2. This will give you 100/20 = 5 MSPS which will be enough to receive GPS L1 C/A signals. The front-end gain should also be configured. In our test with the DBSRX2 we obtained good results with ```G=50```. - 4. Capture at least 80 seconds of signal in open sky conditions. During the process, be aware of USRP driver buffer underuns messages. If your hard disk is not fast enough to write data at this speed you can capture to a virtual RAM drive. 80 seconds of signal at 5 MSPS occupies less than 3 Gbytes using ```gr_complex```. - 5. If you have no access to a RF front-end, you can download a sample raw data file (that contains GPS and Galileo signals) from [here](http://sourceforge.net/projects/gnss-sdr/files/data/). + 4. Capture at least 80 seconds of signal in open sky conditions. During the process, be aware of USRP driver buffer underruns messages. If your hard disk is not fast enough to write data at this speed you can capture to a virtual RAM drive. 80 seconds of signal at 5 MSPS occupies less than 3 Gbytes using ```gr_complex```. + 5. If you have no access to an RF front-end, you can download a sample raw data file (that contains GPS and Galileo signals) from [here](http://sourceforge.net/projects/gnss-sdr/files/data/). 3. You are ready to configure the receiver to use your captured file among other parameters: 1. The default configuration file resides at [/usr/local/share/gnss-sdr/conf/default.conf](./conf/gnss-sdr.conf). 2. You need to review/modify at least the following settings: @@ -717,7 +718,7 @@ For more information, check out our [quick start guide](http://gnss-sdr.org/quic Using GNSS-SDR ============== -With GNSS-SDR, you can define you own receiver, work with captured raw data or from a RF front-end, dump into files intermediate signals, or tune every single algorithm used in the signal processing. All the configuration is done in a single file. Those configuration files reside at the [gnss-sdr/conf/](./conf/) folder (or at /usr/local/share/gnss-sdr/conf if you installed the program). By default, the executable ```gnss-sdr``` will read the configuration available at ```gnss-sdr/conf/gnss-sdr.conf``` (or at (usr/local/share/gnss-sdr/conf/default.conf if you installed the program). You can edit that file to fit your needs, or even better, define a new ```my_receiver.conf``` file with your own configuration. This new receiver can be generated by invoking gnss-sdr with the ```--config_file``` flag pointing to your configuration file: +With GNSS-SDR, you can define your own receiver, work with captured raw data or from an RF front-end, dump into files intermediate signals, or tune every single algorithm used in the signal processing. All the configuration is done in a single file. Those configuration files reside at the [gnss-sdr/conf/](./conf/) folder (or at /usr/local/share/gnss-sdr/conf if you installed the program). By default, the executable ```gnss-sdr``` will read the configuration available at ```gnss-sdr/conf/gnss-sdr.conf``` (or at (usr/local/share/gnss-sdr/conf/default.conf if you installed the program). You can edit that file to fit your needs, or even better, define a new ```my_receiver.conf``` file with your own configuration. This new receiver can be generated by invoking gnss-sdr with the ```--config_file``` flag pointing to your configuration file: ~~~~~~ $ gnss-sdr --config_file=/path/to/my_receiver.conf @@ -769,7 +770,7 @@ Since the configuration is just a set of property names and values without any m ### GNSS block factory -Hence, the application defines a simple accessor class to fetch the configuration pairs of values and passes them to a factory class called [GNSSBlockFactory](./src/core/receiver/gnss_block_factory.h). This factory decides, according to the configuration, which class needs to be instantiated and which parameters should be passed to the constructor. Hence, the factory encapsulates the complexity of blocks' instantiation. With that approach, adding a new block that requires new parameters will be as simple as adding the block class and modifying the factory to be able to instantiate it. This loose coupling between the blocks' implementations and the syntax of the configuration enables extending the application capacities in a high degree. It also allows to produce fully customized receivers, for instance a testbed for acquisition algorithms, and to place observers at any point of the receiver chain. +Hence, the application defines a simple accessor class to fetch the configuration pairs of values and passes them to a factory class called [GNSSBlockFactory](./src/core/receiver/gnss_block_factory.h). This factory decides, according to the configuration, which class needs to be instantiated and which parameters should be passed to the constructor. Hence, the factory encapsulates the complexity of blocks' instantiation. With that approach, adding a new block that requires new parameters will be as simple as adding the block class and modifying the factory to be able to instantiate it. This loose coupling between the blocks' implementations and the syntax of the configuration enables extending the application capacities in a high degree. It also allows producing fully customized receivers, for instance a testbed for acquisition algorithms, and to place observers at any point of the receiver chain. More information can be found at the [Control Plane page](http://gnss-sdr.org/docs/control-plane/). @@ -783,9 +784,9 @@ GNU Radio's class ```gr::basic_block``` is the abstract base class for all signa A signal processing flow is constructed by creating a tree of hierarchical blocks, which at any level may also contain terminal nodes that actually implement signal processing functions. -Class ```gr::top_block``` is the top-level hierarchical block representing a flowgraph. It defines GNU Radio runtime functions used during the execution of the program: run(), start(), stop(), wait(), etc. A a subclass called [GNSSBlockInterface](./src/core/interfaces/gnss_block_interface.h) is the common interface for all the GNSS-SDR modules. It defines pure virtual methods, that are required to be implemented by a derived class. +Class ```gr::top_block``` is the top-level hierarchical block representing a flowgraph. It defines GNU Radio runtime functions used during the execution of the program: run(), start(), stop(), wait(), etc. A subclass called [GNSSBlockInterface](./src/core/interfaces/gnss_block_interface.h) is the common interface for all the GNSS-SDR modules. It defines pure virtual methods, that are required to be implemented by a derived class. -Subclassing GNSSBlockInterface, we defined interfaces for the GNSS receiver blocks depicted in the figure above. This hierarchy provides the definition of different algorithms and different implementations, which will be instantiated according to the configuration. This strategy allows multiple implementations sharing a common interface, achieving the objective of decoupling interfaces from implementations: it defines a family of algorithms, encapsulates each one, and makes them interchangeable. Hence, we let the algorithm vary independently from the program that uses it. +Subclassing GNSSBlockInterface, we defined interfaces for the GNSS receiver blocks depicted in the figure above. This hierarchy provides the definition of different algorithms and different implementations, which will be instantiated according to the configuration. This strategy allows multiple implementations sharing a common interface, achieving the objective of decoupling interfaces from implementations: it defines a family of algorithms, encapsulates each one, and makes them interchangeable. Hence, we let the algorithm vary independently of the program that uses it. Internally, GNSS-SDR makes use of the complex data types defined by [VOLK](http://libvolk.org/ "Vector-Optimized Library of Kernels home"). They are fundamental for handling sample streams in which samples are complex numbers with real and imaginary components of 8, 16 or 32 bits, common formats delivered by GNSS (and generic SDR) radio frequency front-ends. The following list shows the data type names that GNSS-SDR exposes through the configuration file: @@ -805,7 +806,7 @@ More information about the available processing blocks and their configuration p The input of a software receiver are the raw bits that come out from the front-end's analog-to-digital converter (ADC). Those bits can be read from a file stored in the hard disk or directly in real-time from a hardware device through USB or Ethernet buses. -The Signal Source module is in charge of implementing the hardware driver, that is, the portion of the code that communicates with the RF front-end and receives the samples coming from the ADC. This communication is usually performed through USB or Ethernet buses. Since real-time processing requires a highly optimized implementation of the whole receiver, this module also allows to read samples from a file stored in a hard disk, and thus processing without time constraints. Relevant parameters of those samples are the intermediate frequency (or baseband I&Q components), the sampling rate and number of bits per sample, that must be specified by the user in the configuration file. +The Signal Source module is in charge of implementing the hardware driver, that is, the portion of the code that communicates with the RF front-end and receives the samples coming from the ADC. This communication is usually performed through USB or Ethernet buses. Since real-time processing requires a highly optimized implementation of the whole receiver, this module also allows reading samples from a file stored in a hard disk, and thus processing without time constraints. Relevant parameters of those samples are the intermediate frequency (or baseband I&Q components), the sampling rate and number of bits per sample, that must be specified by the user in the configuration file. This module also performs bit-depth adaptation, since most of the existing RF front-ends provide samples quantized with 2 or 3 bits, while operations inside the processor are performed on 32- or 64-bit words, depending on its architecture. Although there are implementations of the most intensive computational processes (mainly correlation) that take advantage of specific data types and architectures for the sake of efficiency, the approach is processor-specific and hardly portable. We suggest to keep signal samples in standard data types and letting the compiler select the best library version (implemented using SIMD or any other processor-specific technology) of the required routines for a given processor. @@ -821,7 +822,7 @@ SignalSource.item_type=gr_complex SignalSource.sampling_frequency=4000000 ; Sampling frequency in samples per second (Sps) ~~~~~~ -Type ```gr_complex``` refers to a GNU Radio typedef equivalent to ```std::complex```. In order to save some storage space, you might wanted to store your signal in a more efficient format such as an I/Q interleaved ```short`` integer sample stream. In that case, change the corresponding line to: +Type ```gr_complex``` refers to a GNU Radio typedef equivalent to ```std::complex```. In order to save some storage space, you might want to store your signal in a more efficient format such as an I/Q interleaved ```short`` integer sample stream. In that case, change the corresponding line to: ~~~~~~ SignalSource.item_type=ishort @@ -845,7 +846,7 @@ Sometimes, samples are stored in files with a format which is not in the list of Within a byte the samples may be packed in big endian ```big_endian_bytes=true``` (if the most significant byte value is stored at the memory location with the lowest address, the next byte value in significance is stored at the following memory location, and so on) or little endian ```big_endian_bytes=false``` (if the least significant byte value is at the lowest address, and the other bytes follow in increasing order of significance). If the order is big endian then the most significant two bits will form the first sample output, otherwise the least significant two bits will be used. -Additionally the samples may be either real ```sample_type=real```, or complex. If the sample type is complex, then the samples are either stored in the order: real, imag, real, imag, ... ```sample_type=iq``` or in the order: imag, real, imag, real, ... ```sample_type=qi```. +Additionally, the samples may be either real ```sample_type=real```, or complex. If the sample type is complex, then the samples are either stored in the order: real, imag, real, imag, ... ```sample_type=iq``` or in the order: imag, real, imag, real, ... ```sample_type=qi```. Finally, if the data is stored as shorts ```item_type=short```, then it may be stored in either big endian ```big_endian_items=true``` or little endian ```big_endian_items=false```. If the shorts are big endian then the 2nd byte in each short is output first. @@ -1007,7 +1008,7 @@ If your signal source is providing baseband signal samples of type ```gr_complex SignalConditioner.implementation=Pass_Through ~~~~~~ -If you need to adapt some aspect of you signal, you can enable the Signal Conditioner and configure three internal blocks: a data type adpater, an input signal and a resampler. +If you need to adapt some aspect of your signal, you can enable the Signal Conditioner and configure three internal blocks: a data type adapter, an input signal and a resampler. ~~~~~~ ;#[Signal_Conditioner] enables this block. Then you have to configure [DataTypeAdapter], [InputFilter] and [Resampler] blocks @@ -1030,7 +1031,7 @@ More documentation at the [Data Type Adapter Blocks page](http://gnss-sdr.org/do #### Input filter -This block filters the input data. It can be combined with frequency translation for IF signals. The computation of the filter taps is based on parameters of GNU Radio's function [pm_remez](http://gnuradio.org/doc/doxygen/pm__remez_8h.html), that calculates the optimal (in the Chebyshev/minimax sense) FIR filter impulse response given a set of band edges, the desired reponse on those bands, and the weight given to the error in those bands. +This block filters the input data. It can be combined with frequency translation for IF signals. The computation of the filter taps is based on parameters of GNU Radio's function [pm_remez](http://gnuradio.org/doc/doxygen/pm__remez_8h.html), that calculates the optimal (in the Chebyshev/minimax sense) FIR filter impulse response given a set of band edges, the desired response on those bands, and the weight given to the error in those bands. The block can be configured like this: @@ -1085,7 +1086,7 @@ More documentation at the [Input Filter Blocks page](http://gnss-sdr.org/docs/sp #### Resampler -This block resamples the input data stream. The ```Direct_Resampler``` block implements a nearest neigbourhood interpolation: +This block resamples the input data stream. The ```Direct_Resampler``` block implements a nearest neighbourhood interpolation: ~~~~~~ ;######### RESAMPLER CONFIG ############ @@ -1103,7 +1104,7 @@ More documentation at the [Resampler Blocks page](http://gnss-sdr.org/docs/sp-bl ### Channel -A channel encapsulates all signal processing devoted to a single satellite. Thus, it is a large composite object which encapsulates the acquisition, tracking and navigation data decoding modules. As a composite object, it can be treated as a single entity, meaning that it can be easily replicated. Since the number of channels is selectable by the user in the configuration file, this approach helps improving the scalability and maintainability of the receiver. +A channel encapsulates all signal processing devoted to a single satellite. Thus, it is a large composite object which encapsulates the acquisition, tracking and navigation data decoding modules. As a composite object, it can be treated as a single entity, meaning that it can be easily replicated. Since the number of channels is selectable by the user in the configuration file, this approach helps to improve the scalability and maintainability of the receiver. Each channel must be assigned to a GNSS signal, according to the following identifiers: @@ -1113,6 +1114,7 @@ Each channel must be assigned to a GNSS signal, according to the following ident | Galileo E1b/c | 1B | | Glonass L1 C/A | 1G | | GPS L2 L2C(M) | 2S | +| Glonass L2 C/A | 2G | | GPS L5 | L5 | | Galileo E5a | 5X | @@ -1144,7 +1146,7 @@ Channel6.signal=1B ; Channel7.signal=1B ; ~~~~~~ -This module is also in charge of managing the interplay between acquisition and tracking. Acquisition can be initialized in several ways, depending on the prior information available (called cold start when the receiver has no information about its position nor the satellites almanac; warm start when a rough location and the approximate time of day are available, and the receiver has a recently recorded almanac broadcast; or hot start when the receiver was tracking a satellite and the signal line of sight broke for a short period of time, but the ephemeris and almanac data is still valid, or this information is provided by other means), and an acquisition process can finish deciding that the satellite is not present, that longer integration is needed in order to confirm the presence of the satellite, or declaring the satellite present. In the latter case, acquisition process should stop and trigger the tracking module with coarse estimations of the synchronization parameters. The mathematical abstraction used to design this logic is known as finite state machine (FSM), that is a behavior model composed of a finite number of states, transitions between those states, and actions. For the implementation, we use the [Boost.Statechart library](http://www.boost.org/libs/statechart/doc/tutorial.html), which provides desirable features such as support for asynchronous state machines, multi-threading, type-safety, error handling and compile-time validation. +This module is also in charge of managing the interplay between acquisition and tracking. Acquisition can be initialized in several ways, depending on the prior information available (called cold start when the receiver has no information about its position nor the satellites' almanac; warm start when a rough location and the approximate time of day are available, and the receiver has a recently recorded almanac broadcast; or hot start when the receiver was tracking a satellite and the signal line of sight broke for a short period of time, but the ephemeris and almanac data is still valid, or this information is provided by other means), and an acquisition process can finish deciding that the satellite is not present, that longer integration is needed in order to confirm the presence of the satellite, or declaring the satellite present. In the latter case, acquisition process should stop and trigger the tracking module with coarse estimations of the synchronization parameters. The mathematical abstraction used to design this logic is known as finite state machine (FSM), that is a behavior model composed of a finite number of states, transitions between those states, and actions. The abstract class [ChannelInterface](./src/core/interfaces/channel_interface.h) represents an interface to a channel GNSS block. Check [Channel](./src/algorithms/channel/adapters/channel.h) for an actual implementation. @@ -1254,7 +1256,7 @@ More documentation at the [Tracking Blocks page](http://gnss-sdr.org/docs/sp-blo #### Decoding of the navigation message -Most of GNSS signal links are modulated by a navigation message containing the time the message was transmitted, orbital parameters of satellites (also known as ephemeris) and an almanac (information about the general system health, rough orbits of all satellites in the network as well as data related to error correction). Navigation data bits are structured in words, pages, subframes, frames and superframes. Sometimes, bits corresponding to a single parameter are spread over different words, and values extracted from different frames are required for proper decoding. Some words are for synchronization purposes, others for error control an others contain actual information. There are also error control mechanisms, from parity checks to forward error correction (FEC) encoding and interleaving, depending on the system. All this decoding complexity is managed by a finite state machine implemented with the [Boost.Statechart library](http://www.boost.org/libs/statechart/doc/tutorial.html). +Most of GNSS signal links are modulated by a navigation message containing the time the message was transmitted, orbital parameters of satellites (also known as ephemeris) and an almanac (information about the general system health, rough orbits of all satellites in the network as well as data related to error correction). Navigation data bits are structured in words, pages, subframes, frames and superframes. Sometimes, bits corresponding to a single parameter are spread over different words, and values extracted from different frames are required for proper decoding. Some words are for synchronization purposes, others for error control and others contain actual information. There are also error control mechanisms, from parity checks to forward error correction (FEC) encoding and interleaving, depending on the system. All this decoding complexity is managed by a finite state machine. The common interface is [TelemetryDecoderInterface](./src/core/interfaces/telemetry_decoder_interface.h). Check [GpsL1CaTelemetryDecoder](./src/algorithms/telemetry_decoder/adapters/gps_l1_ca_telemetry_decoder.h) for an example of the GPS L1 NAV message decoding adapter, and [gps_l1_ca_telemetry_decoder_cc](./src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l1_ca_telemetry_decoder_cc.h) for an actual implementation of a signal processing block. Configuration example: @@ -1341,7 +1343,7 @@ PVT.rtcm_MT1077_rate_ms=1000 PVT.rinex_version=2 ~~~~~~ -* **RTCM SC-104** provides standards that define the data structure for differential GNSS correction information for a variety of differential correction applications. Developed by the Radio Technical Commission for Maritime Services ([RTCM](http://www.rtcm.org/overview.php#Standards "Radio Technical Commission for Maritime Services")), they have become an industry standard for communication of correction information. GNSS-SDR implements RTCM version 3.2, defined in the document *RTCM 10403.2, Differential GNSS (Global Navigation Satellite Systems) Services - Version 3* (February 1, 2013), which can be [purchased online](https://ssl29.pair.com/dmarkle/puborder.php?show=3 "RTCM Online Publication Order Form"). By default, the generated RTCM binary messages are dumped into a text file in hexadecimal format. However, GNSS-SDR is equipped with a TCP/IP server, acting as an NTRIP source that can feed an NTRIP server. NTRIP (Networked Transport of RTCM via Internet Protocol) is an open standard protocol that can be freely download from [BKG](http://igs.bkg.bund.de/root_ftp/NTRIP/documentation/NtripDocumentation.pdf "Networked Transport of RTCM via Internet Protocol (Ntrip) Version 1.0"), and it is designed for disseminating differential correction data (*e.g.* in the RTCM-104 format) or other kinds of GNSS streaming data to stationary or mobile users over the Internet. The TCP/IP server can be enabled by setting ```PVT.flag_rtcm_server=true``` in the configuration file, and will be active during the execution of the software receiver. By default, the server will operate on port 2101 (which is the recommended port for RTCM services according to the Internet Assigned Numbers Authority, [IANA](http://www.iana.org/assignments/service-names-port-numbers "Service Name and Transport Protocol Port Number Registry")), and will identify the Reference Station with ID=1234. This behaviour can be changed in the configuration file: +* **RTCM SC-104** provides standards that define the data structure for differential GNSS correction information for a variety of differential correction applications. Developed by the Radio Technical Commission for Maritime Services ([RTCM](http://www.rtcm.org/overview.php#Standards "Radio Technical Commission for Maritime Services")), they have become an industry standard for communication of correction information. GNSS-SDR implements RTCM version 3.2, defined in the document *RTCM 10403.2, Differential GNSS (Global Navigation Satellite Systems) Services - Version 3* (February 1, 2013), which can be [purchased online](https://ssl29.pair.com/dmarkle/puborder.php?show=3 "RTCM Online Publication Order Form"). By default, the generated RTCM binary messages are dumped into a text file in hexadecimal format. However, GNSS-SDR is equipped with a TCP/IP server, acting as an NTRIP source that can feed an NTRIP server. NTRIP (Networked Transport of RTCM via Internet Protocol) is an open standard protocol that can be freely downloaded from [BKG](http://igs.bkg.bund.de/root_ftp/NTRIP/documentation/NtripDocumentation.pdf "Networked Transport of RTCM via Internet Protocol (Ntrip) Version 1.0"), and it is designed for disseminating differential correction data (*e.g.* in the RTCM-104 format) or other kinds of GNSS streaming data to stationary or mobile users over the Internet. The TCP/IP server can be enabled by setting ```PVT.flag_rtcm_server=true``` in the configuration file, and will be active during the execution of the software receiver. By default, the server will operate on port 2101 (which is the recommended port for RTCM services according to the Internet Assigned Numbers Authority, [IANA](http://www.iana.org/assignments/service-names-port-numbers "Service Name and Transport Protocol Port Number Registry")), and will identify the Reference Station with ID=1234. This behaviour can be changed in the configuration file: ~~~~~~ PVT.flag_rtcm_server=true PVT.rtcm_tcp_port=2102 @@ -1398,9 +1400,9 @@ There is a list of papers related to GNSS-SDR in our [publications page](http:// Ok, now what? ============= -In order to start using GNSS-SDR, you may want to populate ```gnss-sdr/data``` folder (or anywhere else on your system) with raw data files. By "raw data" we mean the output of a Radio Frequency front-end's Analog-to-Digital converter. GNSS-SDR needs signal samples already in baseband or in passband, at a suitable intemediate frequency (on the order of MHz). Prepare your configuration file, and then you are ready for running ```gnss-sdr --config_file=your_configuration.conf```, and seeing how the file is processed. +In order to start using GNSS-SDR, you may want to populate ```gnss-sdr/data``` folder (or anywhere else on your system) with raw data files. By "raw data" we mean the output of a Radio Frequency front-end's Analog-to-Digital converter. GNSS-SDR needs signal samples already in baseband or in passband, at a suitable intermediate frequency (on the order of MHz). Prepare your configuration file, and then you are ready for running ```gnss-sdr --config_file=your_configuration.conf```, and seeing how the file is processed. -Another interesting option is working in real-time with a RF front-end. We provide drivers for UHD-compatible hardware such as the [USRP family](http://www.ettus.com/product), for OsmoSDR and other front-ends (HackRF, bladeRF, LimeSDR), for the GN3S v2 USB dongle and for some DVB-T USB dongles. Start with a low number of channels and then increase it in order to test how many channels your processor can handle in real-time. +Another interesting option is working in real-time with an RF front-end. We provide drivers for UHD-compatible hardware such as the [USRP family](http://www.ettus.com/product), for OsmoSDR and other front-ends (HackRF, bladeRF, LimeSDR), for the GN3S v2 USB dongle and for some DVB-T USB dongles. Start with a low number of channels and then increase it in order to test how many channels your processor can handle in real-time. You can find more information at the [GNSS-SDR Documentation page](http://gnss-sdr.org/docs/) or directly asking to the [GNSS-SDR Developers mailing list](http://lists.sourceforge.net/lists/listinfo/gnss-sdr-developers). diff --git a/cmake/Modules/Findlibiio.cmake b/cmake/Modules/Findlibiio.cmake new file mode 100644 index 000000000..4ce6ca9c5 --- /dev/null +++ b/cmake/Modules/Findlibiio.cmake @@ -0,0 +1,53 @@ +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PC_LIBIIO libiio) + +FIND_PATH( + LIBIIO_INCLUDE_DIRS + NAMES gnuradio/iio/api.h + HINTS $ENV{LIBIIO_DIR}/include + ${PC_LIBIIO_INCLUDEDIR} + PATHS ${CMAKE_INSTALL_PREFIX}/include + /usr/local/include + /usr/include + /opt/local/include +) + +FIND_LIBRARY( + LIBIIO_LIBRARIES + NAMES libiio.so iio + HINTS $ENV{LIBIIO_DIR}/lib + ${PC_LIBIIO_LIBDIR} + PATHS ${CMAKE_INSTALL_PREFIX}/lib + ${CMAKE_INSTALL_PREFIX}/lib64 + /usr/local/lib + /usr/local/lib64 + /usr/lib + /usr/lib64 + /usr/lib/x86_64-linux-gnu + /usr/lib/gcc/alpha-linux-gnu + /usr/lib/gcc/aarch64-linux-gnu + /usr/lib/gcc/arm-linux-gnueabi + /usr/lib/gcc/arm-linux-gnueabihf + /usr/lib/gcc/hppa-linux-gnu + /usr/lib/gcc/i686-gnu + /usr/lib/gcc/i686-linux-gnu + /usr/lib/gcc/x86_64-kfreebsd-gnu + /usr/lib/gcc/i686-kfreebsd-gnu + /usr/lib/gcc/m68k-linux-gnu + /usr/lib/gcc/mips-linux-gnu + /usr/lib/gcc/mips64el-linux-gnuabi64 + /usr/lib/gcc/mipsel-linux-gnu + /usr/lib/gcc/powerpc-linux-gnu + /usr/lib/gcc/powerpc-linux-gnuspe + /usr/lib/gcc/powerpc64-linux-gnu + /usr/lib/gcc/powerpc64le-linux-gnu + /usr/lib/gcc/s390x-linux-gnu + /usr/lib/gcc/sparc64-linux-gnu + /usr/lib/gcc/x86_64-linux-gnux32 + /usr/lib/gcc/sh4-linux-gnu + /Library/Frameworks/iio.framework/ +) + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBIIO DEFAULT_MSG LIBIIO_LIBRARIES LIBIIO_INCLUDE_DIRS) +MARK_AS_ADVANCED(LIBIIO_LIBRARIES LIBIIO_INCLUDE_DIRS) diff --git a/conf/gnss-sdr_GLONASS_L1_CA_ibyte.conf b/conf/gnss-sdr_GLONASS_L1_CA_ibyte.conf index fe8f57080..b95b93551 100644 --- a/conf/gnss-sdr_GLONASS_L1_CA_ibyte.conf +++ b/conf/gnss-sdr_GLONASS_L1_CA_ibyte.conf @@ -5,7 +5,7 @@ GNSS-SDR.internal_fs_sps=6625000 ;######### SIGNAL_SOURCE CONFIG ############ SignalSource.implementation=File_Signal_Source -SignalSource.filename=/archive/NT1065_GLONASS_L1_20160924_fs6625e6_if0e3_schar.bin ; <- PUT YOUR FILE HERE +SignalSource.filename=/media/dmiralles/Seagate Backup Plus Drive/GNSS Data/NT1065_GLONASS_L1_20160923_fs6625e6_if0e3_schar.bin ; <- PUT YOUR FILE HERE ; <- PUT YOUR FILE HERE SignalSource.item_type=ibyte SignalSource.sampling_frequency=6625000 SignalSource.samples=0 @@ -25,11 +25,11 @@ Channel.signal=1G Channels.in_acquisition=1 Channels_1G.count=5 -;Channel0.satellite=24 ; k= -;Channel1.satellite=1 ; k=1 -;Channel2.satellite=2 ; k=-4 -;Channel3.satellite=20 ; k=-5 -;Channel4.satellite=21 ; k=4 +Channel0.satellite=24 ; k= +Channel1.satellite=1 ; k=1 +Channel2.satellite=2 ; k=-4 +Channel3.satellite=20 ; k=-5 +Channel4.satellite=21 ; k=4 ;######### ACQUISITION GLOBAL CONFIG ############ Acquisition_1G.implementation=GLONASS_L1_CA_PCPS_Acquisition diff --git a/conf/gnss-sdr_GLONASS_L2_CA_GPS_L1_CA_ibyte.conf b/conf/gnss-sdr_GLONASS_L2_CA_GPS_L1_CA_ibyte.conf new file mode 100644 index 000000000..04b8dd746 --- /dev/null +++ b/conf/gnss-sdr_GLONASS_L2_CA_GPS_L1_CA_ibyte.conf @@ -0,0 +1,141 @@ +[GNSS-SDR] + +;######### GLOBAL OPTIONS ################## +GNSS-SDR.internal_fs_sps=6625000 +Receiver.sources_count=2 + +;######### SIGNAL_SOURCE CONFIG ############ +SignalSource0.implementation=File_Signal_Source +SignalSource0.filename=/media/dmiralles/Seagate Backup Plus Drive/GNSS Data/NT1065_L1_20160923_fs6625e6_if60e3_schar.bin ; <- PUT YOUR FILE HERE +SignalSource0.item_type=ibyte +SignalSource0.sampling_frequency=6625000 +SignalSource0.samples=0 +SignalSource0.dump=false; +SignalSource0.dump_filename=/archive/signal_glonass.bin + +SignalSource1.implementation=File_Signal_Source +SignalSource1.filename=/media/dmiralles/Seagate Backup Plus Drive/GNSS Data/NT1065_GLONASS_L2_20160923_fs6625e6_if0e3_schar.bin ; <- PUT YOUR FILE HERE +SignalSource1.item_type=ibyte +SignalSource1.sampling_frequency=6625000 +SignalSource1.samples=0 +SignalSource1.dump=false; +SignalSource1.dump_filename=/archive/signal_glonass.bin + +;######### SIGNAL_CONDITIONER CONFIG ############ +SignalConditioner0.implementation=Signal_Conditioner +DataTypeAdapter0.implementation=Ibyte_To_Complex +InputFilter0.implementation=Freq_Xlating_Fir_Filter +InputFilter0.item_type=gr_complex +InputFilter0.output_item_type=gr_complex +InputFilter0.taps_item_type=float +InputFilter0.number_of_taps=5 +InputFilter0.number_of_bands=2 +InputFilter0.band1_begin=0.0 +InputFilter0.band1_end=0.70 +InputFilter0.band2_begin=0.80 +InputFilter0.band2_end=1.0 +InputFilter0.ampl1_begin=1.0 +InputFilter0.ampl1_end=1.0 +InputFilter0.ampl2_begin=0.0 +InputFilter0.ampl2_end=0.0 +InputFilter0.band1_error=1.0 +InputFilter0.band2_error=1.0 +InputFilter0.filter_type=bandpass +InputFilter0.grid_density=16 +InputFilter0.sampling_frequency=6625000 +InputFilter0.IF=60000 +Resampler0.implementation=Direct_Resampler +Resampler0.sample_freq_in=6625000 +Resampler0.sample_freq_out=6625000 +Resampler0.item_type=gr_complex + +SignalConditioner1.implementation=Signal_Conditioner +DataTypeAdapter1.implementation=Ibyte_To_Complex +InputFilter1.implementation=Pass_Through +InputFilter1.item_type=gr_complex +Resampler1.implementation=Pass_Through +Resampler1.item_type=gr_complex + +;######### CHANNELS GLOBAL CONFIG ############ +Channels.in_acquisition=1 +Channels_2G.count=5 +Channels_1C.count=5 + +;# Defining GLONASS satellites +Channel0.RF_channel_ID=0 +Channel1.RF_channel_ID=0 +Channel2.RF_channel_ID=0 +Channel3.RF_channel_ID=0 +Channel4.RF_channel_ID=0 +Channel5.RF_channel_ID=1 +Channel6.RF_channel_ID=1 +Channel7.RF_channel_ID=1 +Channel8.RF_channel_ID=1 +Channel9.RF_channel_ID=1 + + +;######### ACQUISITION GLOBAL CONFIG ############ +Acquisition_1C.implementation=GPS_L1_CA_PCPS_Acquisition +Acquisition_1C.item_type=gr_complex +Acquisition_1C.threshold=0.0 +Acquisition_1C.pfa=0.00001 +Acquisition_1C.if=0 +Acquisition_1C.doppler_max=10000 +Acquisition_1C.doppler_step=250 +Acquisition_1C.dump=false; +Acquisition_1C.dump_filename=/archive/gps_acquisition.dat +;Acquisition_1C.coherent_integration_time_ms=10 + +Acquisition_2G.implementation=GLONASS_L2_CA_PCPS_Acquisition +Acquisition_2G.item_type=gr_complex +Acquisition_2G.threshold=0.0 +Acquisition_2G.pfa=0.00001 +Acquisition_2G.if=0 +Acquisition_2G.doppler_max=10000 +Acquisition_2G.doppler_step=250 +Acquisition_2G.dump=false; +Acquisition_2G.dump_filename=/archive/glo_acquisition.dat +;Acquisition_2G.coherent_integration_time_ms=10 + +;######### TRACKING GLOBAL CONFIG ############ +Tracking_1C.implementation=GPS_L1_CA_DLL_PLL_Tracking +Tracking_1C.item_type=gr_complex +Tracking_1C.if=0 +Tracking_1C.early_late_space_chips=0.5 +Tracking_1C.pll_bw_hz=20.0; +Tracking_1C.dll_bw_hz=2.0; +Tracking_1C.dump=false; +Tracking_1C.dump_filename=/archive/gps_tracking_ch_ + +Tracking_2G.implementation=GLONASS_L2_CA_DLL_PLL_Tracking +Tracking_2G.item_type=gr_complex +Tracking_2G.if=0 +Tracking_2G.early_late_space_chips=0.5 +Tracking_2G.pll_bw_hz=25.0; +Tracking_2G.dll_bw_hz=2.0; +Tracking_2G.dump=false; +Tracking_2G.dump_filename=/archive/glo_tracking_ch_ + +;######### TELEMETRY DECODER GPS CONFIG ############ +TelemetryDecoder_1C.implementation=GPS_L1_CA_Telemetry_Decoder +TelemetryDecoder_2G.implementation=GLONASS_L2_CA_Telemetry_Decoder + +;######### OBSERVABLES CONFIG ############ +Observables.implementation=Hybrid_Observables +Observables.dump=false; +Observables.dump_filename=/archive/gnss_observables.dat + +;######### PVT CONFIG ############ +PVT.implementation=RTKLIB_PVT +PVT.output_rate_ms=100 +PVT.display_rate_ms=500 +PVT.trop_model=Saastamoinen +PVT.flag_rtcm_server=false +PVT.flag_rtcm_tty_port=false +PVT.rtcm_dump_devname=/dev/pts/1 +PVT.rtcm_tcp_port=2101 +PVT.rtcm_MT1019_rate_ms=5000 +PVT.rtcm_MT1045_rate_ms=5000 +PVT.rtcm_MT1097_rate_ms=1000 +PVT.rtcm_MT1077_rate_ms=1000 +PVT.rinex_version=2 diff --git a/conf/gnss-sdr_GLONASS_L2_CA_GPS_L2C_ibyte.conf b/conf/gnss-sdr_GLONASS_L2_CA_GPS_L2C_ibyte.conf new file mode 100644 index 000000000..32faba32a --- /dev/null +++ b/conf/gnss-sdr_GLONASS_L2_CA_GPS_L2C_ibyte.conf @@ -0,0 +1,142 @@ +[GNSS-SDR] + +;######### GLOBAL OPTIONS ################## +GNSS-SDR.internal_fs_sps=6625000 +Receiver.sources_count=2 + +;######### SIGNAL_SOURCE CONFIG ############ +SignalSource0.implementation=File_Signal_Source +SignalSource0.filename=/archive/NT1065_L2_20160923_fs6625e6_if60e3_schar.bin ; <- PUT YOUR FILE HERE +SignalSource0.item_type=ibyte +SignalSource0.sampling_frequency=6625000 +SignalSource0.samples=0 +SignalSource0.dump=false; +SignalSource0.dump_filename=/archive/signal_glonass.bin + +SignalSource1.implementation=File_Signal_Source +SignalSource1.filename=/archive/NT1065_GLONASS_L2_20160923_fs6625e6_if0e3_schar.bin ; <- PUT YOUR FILE HERE +SignalSource1.item_type=ibyte +SignalSource1.sampling_frequency=6625000 +SignalSource1.samples=0 +SignalSource1.dump=false; +SignalSource1.dump_filename=/archive/signal_glonass.bin + +;######### SIGNAL_CONDITIONER CONFIG ############ +SignalConditioner0.implementation=Signal_Conditioner +DataTypeAdapter0.implementation=Ibyte_To_Complex +InputFilter0.implementation=Freq_Xlating_Fir_Filter +InputFilter0.item_type=gr_complex +InputFilter0.output_item_type=gr_complex +InputFilter0.taps_item_type=float +InputFilter0.number_of_taps=5 +InputFilter0.number_of_bands=2 +InputFilter0.band1_begin=0.0 +InputFilter0.band1_end=0.70 +InputFilter0.band2_begin=0.80 +InputFilter0.band2_end=1.0 +InputFilter0.ampl1_begin=1.0 +InputFilter0.ampl1_end=1.0 +InputFilter0.ampl2_begin=0.0 +InputFilter0.ampl2_end=0.0 +InputFilter0.band1_error=1.0 +InputFilter0.band2_error=1.0 +InputFilter0.filter_type=bandpass +InputFilter0.grid_density=16 +InputFilter0.sampling_frequency=6625000 +InputFilter0.IF=60000 +Resampler0.implementation=Pass_Through +Resampler0.item_type=gr_complex + +SignalConditioner1.implementation=Signal_Conditioner +DataTypeAdapter1.implementation=Ibyte_To_Complex +InputFilter1.implementation=Pass_Through +InputFilter1.item_type=gr_complex +Resampler1.implementation=Pass_Through +Resampler1.item_type=gr_complex + +;######### CHANNELS GLOBAL CONFIG ############ +Channels.in_acquisition=5 +Channels_2S.count=5 +Channels_2G.count=5 + +;# Defining GLONASS satellites +Channel0.RF_channel_ID=0 +Channel0.signal=2S +Channel1.RF_channel_ID=0 +Channel1.signal=2S +Channel2.RF_channel_ID=0 +Channel2.signal=2S +Channel3.RF_channel_ID=0 +Channel3.signal=2S +Channel4.RF_channel_ID=0 +Channel4.signal=2S +Channel5.RF_channel_ID=1 +Channel6.RF_channel_ID=1 +Channel7.RF_channel_ID=1 +Channel8.RF_channel_ID=1 +Channel9.RF_channel_ID=1 + + +;######### ACQUISITION GLOBAL CONFIG ############ +Acquisition_2S.implementation=GPS_L2_M_PCPS_Acquisition +Acquisition_2S.item_type=gr_complex +Acquisition_2S.threshold=0.0 +Acquisition_2S.pfa=0.00001 +Acquisition_2S.if=0 +Acquisition_2S.doppler_max=10000 +Acquisition_2S.doppler_step=60 +Acquisition_2S.max_dwells=1 + +Acquisition_2G.implementation=GLONASS_L2_CA_PCPS_Acquisition +Acquisition_2G.item_type=gr_complex +Acquisition_2G.threshold=0.0 +Acquisition_2G.pfa=0.00001 +Acquisition_2G.if=0 +Acquisition_2G.doppler_max=10000 +Acquisition_2G.doppler_step=250 +Acquisition_2G.dump=false; +Acquisition_2G.dump_filename=/archive/glo_acquisition.dat + +;######### TRACKING GLOBAL CONFIG ############ +Tracking_2S.implementation=GPS_L2_M_DLL_PLL_Tracking +Tracking_2S.item_type=gr_complex +Tracking_2S.if=0 +Tracking_2S.early_late_space_chips=0.5 +Tracking_2S.pll_bw_hz=2.0; +Tracking_2S.dll_bw_hz=0.250; +Tracking_2S.order=2; +Tracking_2S.dump=false; +Tracking_2S.dump_filename=/archive/gps_tracking_ch_ + +Tracking_2G.implementation=GLONASS_L2_CA_DLL_PLL_Tracking +Tracking_2G.item_type=gr_complex +Tracking_2G.if=0 +Tracking_2G.early_late_space_chips=0.5 +Tracking_2G.pll_bw_hz=25.0; +Tracking_2G.dll_bw_hz=3.0; +Tracking_2G.dump=false; +Tracking_2G.dump_filename=/archive/glo_tracking_ch_ + +;######### TELEMETRY DECODER GPS CONFIG ############ +TelemetryDecoder_2S.implementation=GPS_L2C_Telemetry_Decoder +TelemetryDecoder_2G.implementation=GLONASS_L2_CA_Telemetry_Decoder + +;######### OBSERVABLES CONFIG ############ +Observables.implementation=Hybrid_Observables +Observables.dump=false; +Observables.dump_filename=/archive/gnss_observables.dat + +;######### PVT CONFIG ############ +PVT.implementation=RTKLIB_PVT +PVT.output_rate_ms=100 +PVT.display_rate_ms=500 +PVT.trop_model=Saastamoinen +PVT.flag_rtcm_server=true +PVT.flag_rtcm_tty_port=false +PVT.rtcm_dump_devname=/dev/pts/1 +PVT.rtcm_tcp_port=2101 +PVT.rtcm_MT1019_rate_ms=5000 +PVT.rtcm_MT1045_rate_ms=5000 +PVT.rtcm_MT1097_rate_ms=1000 +PVT.rtcm_MT1077_rate_ms=1000 +PVT.rinex_version=3 diff --git a/conf/gnss-sdr_GLONASS_L2_CA_ibyte.conf b/conf/gnss-sdr_GLONASS_L2_CA_ibyte.conf new file mode 100644 index 000000000..e8d1342a8 --- /dev/null +++ b/conf/gnss-sdr_GLONASS_L2_CA_ibyte.conf @@ -0,0 +1,73 @@ +[GNSS-SDR] + +;######### GLOBAL OPTIONS ################## +GNSS-SDR.internal_fs_sps=6625000 + +;######### SIGNAL_SOURCE CONFIG ############ +SignalSource.implementation=File_Signal_Source +SignalSource.filename=/media/dmiralles/Seagate Backup Plus Drive/GNSS Data/NT1065_GLONASS_L2_20160831_fs6625e6_60e3_schar_1m.bin ; <- PUT YOUR FILE HERE +SignalSource.item_type=ibyte +SignalSource.sampling_frequency=6625000 +SignalSource.samples=0 +SignalSource.dump=false; +SignalSource.dump_filename=/archive/signal_glonass.bin + +;######### SIGNAL_CONDITIONER CONFIG ############ +SignalConditioner.implementation=Signal_Conditioner +DataTypeAdapter.implementation=Ibyte_To_Complex +InputFilter.implementation=Pass_Through +InputFilter.item_type=gr_complex +Resampler.implementation=Pass_Through +Resampler.item_type=gr_complex + +;######### CHANNELS GLOBAL CONFIG ############ +Channel.signal=2G +Channels.in_acquisition=1 +Channels_2G.count=5 + +;######### ACQUISITION GLOBAL CONFIG ############ +Acquisition_2G.implementation=GLONASS_L2_CA_PCPS_Acquisition +Acquisition_2G.item_type=gr_complex +Acquisition_2G.threshold=0.0 +Acquisition_2G.pfa=0.0001 +Acquisition_2G.if=0 +Acquisition_2G.doppler_max=10000 +Acquisition_2G.doppler_step=250 +Acquisition_2G.dump=true; +Acquisition_2G.dump_filename=/archive/glo_acquisition.dat +;Acquisition_2G.coherent_integration_time_ms=1 +;Acquisition_2G.max_dwells = 5 + +;######### TRACKING GLOBAL CONFIG ############ +Tracking_2G.implementation=GLONASS_L2_CA_DLL_PLL_Tracking +Tracking_2G.item_type=gr_complex +Tracking_2G.if=0 +Tracking_2G.early_late_space_chips=0.5 +Tracking_2G.pll_bw_hz=20.0; +Tracking_2G.dll_bw_hz=2.0; +Tracking_2G.dump=true; +Tracking_2G.dump_filename=/archive/glo_tracking_ch_ + +;######### TELEMETRY DECODER GPS CONFIG ############ +TelemetryDecoder_2G.implementation=GLONASS_L2_CA_Telemetry_Decoder + +;######### OBSERVABLES CONFIG ############ +Observables.implementation=Hybrid_Observables +Observables.dump=true; +Observables.dump_filename=/archive/glo_observables.dat + +;######### PVT CONFIG ############ +PVT.implementation=RTKLIB_PVT +PVT.positioning_mode=Single +PVT.output_rate_ms=100 +PVT.display_rate_ms=500 +PVT.trop_model=Saastamoinen +PVT.flag_rtcm_server=false +PVT.flag_rtcm_tty_port=false +PVT.rtcm_dump_devname=/dev/pts/1 +PVT.rtcm_tcp_port=2101 +PVT.rtcm_MT1019_rate_ms=5000 +PVT.rtcm_MT1045_rate_ms=5000 +PVT.rtcm_MT1097_rate_ms=1000 +PVT.rtcm_MT1077_rate_ms=1000 +PVT.rinex_version=2 diff --git a/conf/gnss-sdr_GLONASS_L2_CA_ibyte_coh_trk.conf b/conf/gnss-sdr_GLONASS_L2_CA_ibyte_coh_trk.conf new file mode 100644 index 000000000..0bdbe7739 --- /dev/null +++ b/conf/gnss-sdr_GLONASS_L2_CA_ibyte_coh_trk.conf @@ -0,0 +1,83 @@ +[GNSS-SDR] + +;######### GLOBAL OPTIONS ################## +GNSS-SDR.internal_fs_sps=6625000 + +;######### SIGNAL_SOURCE CONFIG ############ +SignalSource.implementation=File_Signal_Source +SignalSource.filename=/archive/NT1065_GLONASS_L1_20160923_fs6625e6_if0e3_schar.bin ; <- PUT YOUR FILE HERE +SignalSource.item_type=ibyte +SignalSource.sampling_frequency=6625000 +SignalSource.samples=0 +SignalSource.dump=false; +SignalSource.dump_filename=/archive/signal_glonass.bin + +;######### SIGNAL_CONDITIONER CONFIG ############ +SignalConditioner.implementation=Signal_Conditioner +DataTypeAdapter.implementation=Ibyte_To_Complex +InputFilter.implementation=Pass_Through +InputFilter.item_type=gr_complex +Resampler.implementation=Pass_Through +Resampler.item_type=gr_complex + +;######### CHANNELS GLOBAL CONFIG ############ +Channel.signal=1G +Channels.in_acquisition=2 +Channels_1G.count=8 + +;Channel0.satellite=24 ; k=2 +;Channel1.satellite=1 ; k=1 +;Channel2.satellite=2 ; k=-4 +;Channel3.satellite=20 ; k=-5 +;Channel4.satellite=21 ; k=4 + +;######### ACQUISITION GLOBAL CONFIG ############ +Acquisition_1G.implementation=GLONASS_L1_CA_PCPS_Acquisition +Acquisition_1G.item_type=gr_complex +Acquisition_1G.threshold=0.0 +Acquisition_1G.pfa=0.0001 +Acquisition_1G.if=0 +Acquisition_1G.doppler_max=10000 +Acquisition_1G.doppler_step=250 +Acquisition_1G.dump=false; +Acquisition_1G.dump_filename=/archive/glo_acquisition.dat +;Acquisition_1G.coherent_integration_time_ms=1 +;Acquisition_1G.max_dwells = 5 + +;######### TRACKING GLOBAL CONFIG ############ +Tracking_1G.implementation=GLONASS_L1_CA_DLL_PLL_C_Aid_Tracking +Tracking_1G.item_type=gr_complex +Tracking_1G.if=0 +Tracking_1G.early_late_space_chips=0.5 +Tracking_1G.pll_bw_hz=40.0; +Tracking_1G.dll_bw_hz=3.0; +Tracking_1G.pll_bw_narrow_hz = 25.0; +Tracking_1G.dll_bw_narrow_hz = 2.0; +Tracking_1G.extend_correlation_ms = 1; +Tracking_1G.dump=false; +Tracking_1G.dump_filename=/archive/glo_tracking_ch_ + + +;######### TELEMETRY DECODER GPS CONFIG ############ +TelemetryDecoder_1G.implementation=GLONASS_L1_CA_Telemetry_Decoder + +;######### OBSERVABLES CONFIG ############ +Observables.implementation=Hybrid_Observables +Observables.dump=false +Observables.dump_filename=/archive/glo_observables.dat + +;######### PVT CONFIG ############ +PVT.implementation=RTKLIB_PVT +PVT.positioning_mode=Single +PVT.output_rate_ms=100 +PVT.display_rate_ms=500 +PVT.trop_model=Saastamoinen +PVT.flag_rtcm_server=true +PVT.flag_rtcm_tty_port=false +PVT.rtcm_dump_devname=/dev/pts/1 +PVT.rtcm_tcp_port=2101 +PVT.rtcm_MT1019_rate_ms=5000 +PVT.rtcm_MT1045_rate_ms=5000 +PVT.rtcm_MT1097_rate_ms=1000 +PVT.rtcm_MT1077_rate_ms=1000 +PVT.rinex_version=2 diff --git a/conf/gnss-sdr_GPS_L1_2ch_fmcomms2_realtime.conf b/conf/gnss-sdr_GPS_L1_2ch_fmcomms2_realtime.conf new file mode 100644 index 000000000..79a57f712 --- /dev/null +++ b/conf/gnss-sdr_GPS_L1_2ch_fmcomms2_realtime.conf @@ -0,0 +1,112 @@ +; You can define your own receiver and invoke it by doing +; gnss-sdr --config_file=my_GNSS_SDR_configuration.conf +; + +[GNSS-SDR] + +;######### GLOBAL OPTIONS ################## +;internal_fs_sps: Internal signal sampling frequency after the signal conditioning stage [Sps]. +GNSS-SDR.internal_fs_sps=7000000 + +;######### SIGNAL_SOURCE CONFIG ############ +SignalSource.implementation=Fmcomms2_Signal_Source +SignalSource.item_type=gr_complex +SignalSource.device_address=192.168.0.4 +SignalSource.sampling_frequency=7000000 +SignalSource.freq=1575420000 +SignalSource.bandwidth=4000000 +SignalSource.RF_channels=2 +SignalSource.rx1_enable=true +SignalSource.rx2_enable=true +SignalSource.gain_mode_rx1=slow_attack +SignalSource.gain_mode_rx2=slow_attack +SignalSource.rf_port_select=A_BALANCED +SignalSource.gain_rx1=64 +SignalSource.gain_rx2=64 +SignalSource.samples=0 +SignalSource.repeat=false +SignalSource.dump=false +SignalSource.dump_filename=../data/signal_source.dat +SignalSource.enable_throttle_control=false +SignalSource.enable_dds_lo=false +SignalSource.freq_rf_tx_hz=1260000000 +SignalSource.freq_dds_tx_hz=1000 +SignalSource.scale_dds_dbfs=0.0 +SignalSource.phase_dds_deg=0.0 +SignalSource.tx_attenuation_db=0.0 + + +;######### SIGNAL_CONDITIONER CONFIG ############ +SignalConditioner0.implementation=Pass_Through +SignalConditioner1.implementation=Pass_Through + +;######### CHANNELS GLOBAL CONFIG ############ +Channels_1C.count=8 +Channels.in_acquisition=1 + +;# CHANNEL CONNECTION +Channel0.RF_channel_ID=0 +Channel0.signal=1C +Channel1.RF_channel_ID=0 +Channel1.signal=1C +Channel2.RF_channel_ID=0 +Channel2.signal=1C +Channel3.RF_channel_ID=0 +Channel3.signal=1C +Channel4.RF_channel_ID=1 +Channel4.signal=1C +Channel5.RF_channel_ID=1 +Channel5.signal=1C +Channel6.RF_channel_ID=1 +Channel6.signal=1C +Channel7.RF_channel_ID=1 +Channel7.signal=1C + +;######### ACQUISITION GLOBAL CONFIG ############ +Acquisition_1C.implementation=GPS_L1_CA_PCPS_Acquisition +Acquisition_1C.item_type=gr_complex +Acquisition_1C.threshold=20 +Acquisition_1C.use_CFAR_algorithm=false +Acquisition_1C.blocking=true +Acquisition_1C.doppler_max=10000 +Acquisition_1C.doppler_step=250 +Acquisition_1C.dump=false +Acquisition_1C.dump_filename=./acq_dump.dat + + +;######### TRACKING GLOBAL CONFIG ############ +Tracking_1C.implementation=GPS_L1_CA_DLL_PLL_Tracking +Tracking_1C.item_type=gr_complex +Tracking_1C.dump=false +Tracking_1C.dump_filename=./tracking_ch_ +Tracking_1C.pll_bw_hz=35.0; +Tracking_1C.dll_bw_hz=2.0; +Tracking_1C.early_late_space_chips=0.5; + + +;######### TELEMETRY DECODER GPS CONFIG ############ +TelemetryDecoder_1C.implementation=GPS_L1_CA_Telemetry_Decoder +TelemetryDecoder_1C.dump=false + + +;######### OBSERVABLES CONFIG ############ +Observables.implementation=Hybrid_Observables +Observables.dump=false +Observables.dump_filename=./observables.dat + + +;######### PVT CONFIG ############ +PVT.implementation=RTKLIB_PVT +PVT.positioning_mode=Single ; options: Single, Static, Kinematic, PPP_Static, PPP_Kinematic +PVT.iono_model=Broadcast ; options: OFF, Broadcast, SBAS, Iono-Free-LC, Estimate_STEC, IONEX +PVT.trop_model=Saastamoinen ; options: OFF, Saastamoinen, SBAS, Estimate_ZTD, Estimate_ZTD_Grad +PVT.output_rate_ms=100 +PVT.display_rate_ms=500 +PVT.dump_filename=./PVT +PVT.nmea_dump_filename=./gnss_sdr_pvt.nmea; +PVT.flag_nmea_tty_port=false; +PVT.nmea_dump_devname=/dev/pts/4 +PVT.flag_rtcm_server=false +PVT.flag_rtcm_tty_port=false +PVT.rtcm_dump_devname=/dev/pts/1 +PVT.dump=false diff --git a/docs/doxygen/Doxyfile.in b/docs/doxygen/Doxyfile.in index ab11a667f..9d0978e3f 100644 --- a/docs/doxygen/Doxyfile.in +++ b/docs/doxygen/Doxyfile.in @@ -129,7 +129,7 @@ INLINE_INHERITED_MEMB = NO # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. -FULL_PATH_NAMES = YES +FULL_PATH_NAMES = NO # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is @@ -703,7 +703,7 @@ EXAMPLE_RECURSIVE = NO # directories that contain image that are included in the documentation (see # the \image command). -IMAGE_PATH = @top_srcdir@/docs/doxygen/images/ +IMAGE_PATH = @top_srcdir@/docs/doxygen/images/ # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program @@ -791,7 +791,7 @@ REFERENCES_LINK_SOURCE = YES # The default value is: YES. # This tag requires that the tag SOURCE_BROWSER is set to YES. -SOURCE_TOOLTIPS = YES +SOURCE_TOOLTIPS = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen @@ -901,7 +901,7 @@ HTML_COLORSTYLE_GAMMA = 80 # page will contain the date and time when the page was generated. Setting # this to NO can help when comparing the output of multiple runs. -HTML_TIMESTAMP = YES +HTML_TIMESTAMP = NO # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to @@ -1164,7 +1164,7 @@ MATHJAX_EXTENSIONS = # example see the documentation. # This tag requires that the tag USE_MATHJAX is set to YES. -MATHJAX_CODEFILE = +MATHJAX_CODEFILE = # When the SEARCHENGINE tag is enabled doxygen will generate a search box # for the HTML output. The underlying search engine uses javascript @@ -1677,7 +1677,7 @@ DOT_FONTSIZE = 10 # different font using DOT_FONTNAME you can set the path where dot # can find it using this tag. -DOT_FONTPATH = +DOT_FONTPATH = # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and diff --git a/src/algorithms/PVT/adapters/rtklib_pvt.cc b/src/algorithms/PVT/adapters/rtklib_pvt.cc index f9bcc37d9..6a0b4299e 100644 --- a/src/algorithms/PVT/adapters/rtklib_pvt.cc +++ b/src/algorithms/PVT/adapters/rtklib_pvt.cc @@ -178,40 +178,44 @@ RtklibPvt::RtklibPvt(ConfigurationInterface* configuration, int gal_E5a_count = configuration->property("Channels_5X.count", 0); int gal_E5b_count = configuration->property("Channels_7X.count", 0); int glo_1G_count = configuration->property("Channels_1G.count", 0); + int glo_2G_count = configuration->property("Channels_2G.count", 0); unsigned int type_of_receiver = 0; // *******************WARNING!!!!!!!*********** // GPS L5 only configurable for single frequency, single system at the moment!!!!!! - 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)) type_of_receiver = 1; - 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)) 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)) type_of_receiver = 3; - 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)) type_of_receiver = 4; - 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)) type_of_receiver = 5; - 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)) 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)) type_of_receiver = 1; + 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)) 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)) type_of_receiver = 3; + 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)) type_of_receiver = 4; + 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)) type_of_receiver = 5; + 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)) 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)) 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)) 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)) type_of_receiver = 8; - 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)) type_of_receiver = 9; - 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)) 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)) 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)) 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)) type_of_receiver = 9; + 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)) 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)) 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)) type_of_receiver = 12; //if( (gps_1C_count == 0) && (gps_2S_count == 0) && (gal_1B_count != 0) && (gal_E5a_count == 0) && (gal_E5b_count == 0)) type_of_receiver = 13; - 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)) 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)) 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)) 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)) 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)) 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)) 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)) 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)) 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)) 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)) 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)) 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)) 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)) 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)) 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)) 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_2R_count != 0)) 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_1G_count != 0)) 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)) 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)) 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)) 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)) 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)) 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)) 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)) 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)) 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)) 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)) 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)) type_of_receiver = 31; //RTKLIB PVT solver options // Settings 1 int positioning_mode = -1; @@ -236,9 +240,9 @@ RtklibPvt::RtklibPvt(ConfigurationInterface* configuration, int num_bands = 0; if ((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0)) num_bands = 1; - if (((gps_1C_count > 0) || (gal_1B_count > 0) || (glo_1G_count > 0)) && (gps_2S_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))) 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) && ((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)) && ((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)) @@ -321,7 +325,7 @@ RtklibPvt::RtklibPvt(ConfigurationInterface* configuration, 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)) nsys += SYS_GLO; + if ((glo_1G_count > 0) || (glo_2G_count > 0)) nsys += SYS_GLO; 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 */ { diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc index dc3afaf72..a839fcc63 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_cc.cc @@ -34,12 +34,14 @@ #include #include #include +#include #include #include #include #include #include #include +#include using google::LogMessage; @@ -544,34 +546,46 @@ int rtklib_pvt_cc::work(int noutput_items, gr_vector_const_void_star& input_item // store valid observables in a map. gnss_observables_map.insert(std::pair(i, in[i][epoch])); } - - if (d_ls_pvt->gps_ephemeris_map.size() > 0) + try { - if (tmp_eph_iter_gps != d_ls_pvt->gps_ephemeris_map.end()) + if (d_ls_pvt->gps_ephemeris_map.size() > 0) { - d_rtcm_printer->lock_time(d_ls_pvt->gps_ephemeris_map.find(in[i][epoch].PRN)->second, in[i][epoch].RX_time, in[i][epoch]); // keep track of locking time + if (tmp_eph_iter_gps != d_ls_pvt->gps_ephemeris_map.end()) + { + d_rtcm_printer->lock_time(d_ls_pvt->gps_ephemeris_map.find(in[i][epoch].PRN)->second, in[i][epoch].RX_time, in[i][epoch]); // keep track of locking time + } + } + if (d_ls_pvt->galileo_ephemeris_map.size() > 0) + { + if (tmp_eph_iter_gal != d_ls_pvt->galileo_ephemeris_map.end()) + { + d_rtcm_printer->lock_time(d_ls_pvt->galileo_ephemeris_map.find(in[i][epoch].PRN)->second, in[i][epoch].RX_time, in[i][epoch]); // keep track of locking time + } + } + if (d_ls_pvt->gps_cnav_ephemeris_map.size() > 0) + { + if (tmp_eph_iter_cnav != d_ls_pvt->gps_cnav_ephemeris_map.end()) + { + d_rtcm_printer->lock_time(d_ls_pvt->gps_cnav_ephemeris_map.find(in[i][epoch].PRN)->second, in[i][epoch].RX_time, in[i][epoch]); // keep track of locking time + } + } + if (d_ls_pvt->glonass_gnav_ephemeris_map.size() > 0) + { + if (tmp_eph_iter_glo_gnav != d_ls_pvt->glonass_gnav_ephemeris_map.end()) + { + d_rtcm_printer->lock_time(d_ls_pvt->glonass_gnav_ephemeris_map.find(in[i][epoch].PRN)->second, in[i][epoch].RX_time, in[i][epoch]); // keep track of locking time + } } } - if (d_ls_pvt->galileo_ephemeris_map.size() > 0) + catch (const boost::exception& ex) { - if (tmp_eph_iter_gal != d_ls_pvt->galileo_ephemeris_map.end()) - { - d_rtcm_printer->lock_time(d_ls_pvt->galileo_ephemeris_map.find(in[i][epoch].PRN)->second, in[i][epoch].RX_time, in[i][epoch]); // keep track of locking time - } + std::cout << "RTCM boost exception: " << boost::diagnostic_information(ex) << std::endl; + LOG(ERROR) << "RTCM boost exception: " << boost::diagnostic_information(ex); } - if (d_ls_pvt->gps_cnav_ephemeris_map.size() > 0) + catch (const std::exception& ex) { - if (tmp_eph_iter_cnav != d_ls_pvt->gps_cnav_ephemeris_map.end()) - { - d_rtcm_printer->lock_time(d_ls_pvt->gps_cnav_ephemeris_map.find(in[i][epoch].PRN)->second, in[i][epoch].RX_time, in[i][epoch]); // keep track of locking time - } - } - if (d_ls_pvt->glonass_gnav_ephemeris_map.size() > 0) - { - if (tmp_eph_iter_glo_gnav != d_ls_pvt->glonass_gnav_ephemeris_map.end()) - { - d_rtcm_printer->lock_time(d_ls_pvt->glonass_gnav_ephemeris_map.find(in[i][epoch].PRN)->second, in[i][epoch].RX_time, in[i][epoch]); // keep track of locking time - } + std::cout << "RTCM std exception: " << ex.what() << std::endl; + LOG(ERROR) << "RTCM std exception: " << ex.what(); } } } @@ -590,10 +604,7 @@ int rtklib_pvt_cc::work(int noutput_items, gr_vector_const_void_star& input_item // compute on the fly PVT solution if (flag_compute_pvt_output == true) { - bool pvt_result; - pvt_result = d_ls_pvt->get_PVT(gnss_observables_map, d_rx_time, false); - - if (pvt_result == true) + if (d_ls_pvt->get_PVT(gnss_observables_map, d_rx_time, false)) { if (std::fabs(current_RX_time - last_pvt_display_T_rx_s) * 1000.0 >= static_cast(d_display_rate_ms)) { @@ -700,6 +711,9 @@ int rtklib_pvt_cc::work(int noutput_items, gr_vector_const_void_star& input_item * 26 | GPS L1 C/A + GLONASS L1 C/A * 27 | Galileo E1B + GLONASS L1 C/A * 28 | GPS L2C + GLONASS L1 C/A + * 29 | GPS L1 C/A + GLONASS L2 C/A + * 30 | Galileo E1B + GLONASS L2 C/A + * 31 | GPS L2C + GLONASS L2 C/A */ // ####################### RINEX FILES ################# @@ -901,6 +915,43 @@ int rtklib_pvt_cc::work(int noutput_items, gr_vector_const_void_star& input_item b_rinex_header_written = true; // do not write header anymore } } + if (type_of_rx == 29) // GPS L1 C/A + GLONASS L2 C/A + { + if ((glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) && (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend())) + { + 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_ls_pvt->gps_iono, d_ls_pvt->gps_utc_model, d_ls_pvt->glonass_gnav_utc_model, d_ls_pvt->glonass_gnav_almanac); + if (d_rinex_version == 2) + { + rp->rinex_nav_header(rp->navFile, d_ls_pvt->gps_iono, d_ls_pvt->gps_utc_model); + rp->rinex_nav_header(rp->navGloFile, d_ls_pvt->glonass_gnav_utc_model, glonass_gnav_ephemeris_iter->second); + } + b_rinex_header_written = true; // do not write header anymore + } + } + if (type_of_rx == 30) // Galileo E1B + GLONASS L2 C/A + { + if ((glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) && (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend())) + { + std::string glo_signal("2G"); + std::string gal_signal("1B"); + rp->rinex_obs_header(rp->obsFile, galileo_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal, gal_signal); + rp->rinex_nav_header(rp->navMixFile, d_ls_pvt->galileo_iono, d_ls_pvt->galileo_utc_model, d_ls_pvt->galileo_almanac, d_ls_pvt->glonass_gnav_utc_model, d_ls_pvt->glonass_gnav_almanac); + b_rinex_header_written = true; // do not write header anymore + } + } + if (type_of_rx == 31) // GPS L2C + GLONASS L2 C/A + { + if ((glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) && (gps_cnav_ephemeris_iter != d_ls_pvt->gps_cnav_ephemeris_map.cend())) + { + std::string glo_signal("2G"); + rp->rinex_obs_header(rp->obsFile, gps_cnav_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, glo_signal); + rp->rinex_nav_header(rp->navMixFile, d_ls_pvt->gps_cnav_iono, d_ls_pvt->gps_cnav_utc_model, d_ls_pvt->glonass_gnav_utc_model, d_ls_pvt->glonass_gnav_almanac); + b_rinex_header_written = true; // do not write header anymore + } + } } if (b_rinex_header_written) // The header is already written, we can now log the navigation message data { @@ -956,6 +1007,24 @@ int rtklib_pvt_cc::work(int noutput_items, gr_vector_const_void_star& input_item { rp->log_rinex_nav(rp->navMixFile, d_ls_pvt->gps_cnav_ephemeris_map, d_ls_pvt->glonass_gnav_ephemeris_map); } + if (type_of_rx == 29) // GPS L1 C/A + GLONASS L2 C/A + { + if (d_rinex_version == 3) + rp->log_rinex_nav(rp->navMixFile, d_ls_pvt->gps_ephemeris_map, d_ls_pvt->glonass_gnav_ephemeris_map); + if (d_rinex_version == 2) + { + rp->log_rinex_nav(rp->navFile, d_ls_pvt->gps_ephemeris_map); + rp->log_rinex_nav(rp->navGloFile, d_ls_pvt->glonass_gnav_ephemeris_map); + } + } + if (type_of_rx == 30) // Galileo E1B + GLONASS L2 C/A + { + rp->log_rinex_nav(rp->navMixFile, d_ls_pvt->galileo_ephemeris_map, d_ls_pvt->glonass_gnav_ephemeris_map); + } + if (type_of_rx == 31) // GPS L2C + GLONASS L2 C/A + { + rp->log_rinex_nav(rp->navMixFile, d_ls_pvt->gps_cnav_ephemeris_map, d_ls_pvt->glonass_gnav_ephemeris_map); + } } galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.cbegin(); gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); @@ -1173,92 +1242,523 @@ int rtklib_pvt_cc::work(int noutput_items, gr_vector_const_void_star& input_item b_rinex_header_updated = true; // do not write header anymore } } + if (type_of_rx == 29) // GPS L1 C/A + GLONASS L2 C/A + { + if ((glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) && (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.end())) + { + rp->log_rinex_obs(rp->obsFile, gps_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated && (d_ls_pvt->gps_utc_model.d_A0 != 0)) + { + rp->update_obs_header(rp->obsFile, d_ls_pvt->gps_utc_model); + rp->update_nav_header(rp->navMixFile, d_ls_pvt->gps_iono, d_ls_pvt->gps_utc_model, d_ls_pvt->glonass_gnav_utc_model, d_ls_pvt->glonass_gnav_almanac); + b_rinex_header_updated = true; // do not write header anymore + } + } + if (type_of_rx == 30) // Galileo E1B + GLONASS L2 C/A + { + if ((glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) && (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end())) + { + rp->log_rinex_obs(rp->obsFile, galileo_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated && (d_ls_pvt->galileo_utc_model.A0_6 != 0)) + { + rp->update_obs_header(rp->obsFile, d_ls_pvt->galileo_utc_model); + rp->update_nav_header(rp->navMixFile, d_ls_pvt->galileo_iono, d_ls_pvt->galileo_utc_model, d_ls_pvt->galileo_almanac, d_ls_pvt->glonass_gnav_utc_model, d_ls_pvt->glonass_gnav_almanac); + b_rinex_header_updated = true; // do not write header anymore + } + } + if (type_of_rx == 31) // GPS L2C + GLONASS L2 C/A + { + if ((glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) && (gps_cnav_ephemeris_iter != d_ls_pvt->gps_cnav_ephemeris_map.end())) + { + rp->log_rinex_obs(rp->obsFile, gps_cnav_ephemeris_iter->second, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map); + } + if (!b_rinex_header_updated && (d_ls_pvt->gps_cnav_utc_model.d_A0 != 0)) + { + rp->update_obs_header(rp->obsFile, d_ls_pvt->gps_cnav_utc_model); + rp->update_nav_header(rp->navMixFile, d_ls_pvt->gps_cnav_iono, d_ls_pvt->gps_cnav_utc_model, d_ls_pvt->glonass_gnav_utc_model, d_ls_pvt->glonass_gnav_almanac); + b_rinex_header_updated = true; // do not write header anymore + } + } } } // ####################### RTCM MESSAGES ################# - if (b_rtcm_writing_started) + try { - if (type_of_rx == 1) // GPS L1 C/A + if (b_rtcm_writing_started) { - if (flag_write_RTCM_1019_output == true) + if (type_of_rx == 1) // GPS L1 C/A + { + if (flag_write_RTCM_1019_output == true) + { + for (std::map::const_iterator gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend(); gps_ephemeris_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1019(gps_ephemeris_iter->second); + } + } + if (flag_write_RTCM_MSM_output == true) + { + std::map::const_iterator gps_ephemeris_iter; + gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); + + if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_ephemeris_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + } + } + } + if ((type_of_rx == 4) || (type_of_rx == 5) || (type_of_rx == 6) || (type_of_rx == 14) || (type_of_rx == 15)) // Galileo + { + if (flag_write_RTCM_1045_output == true) + { + for (std::map::const_iterator gal_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.cbegin(); gal_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend(); gal_ephemeris_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1045(gal_ephemeris_iter->second); + } + } + if (flag_write_RTCM_MSM_output == true) + { + std::map::const_iterator gal_ephemeris_iter; + gal_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.cbegin(); + if (gal_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_ephemeris_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + } + } + } + if (type_of_rx == 7) // GPS L1 C/A + GPS L2C + { + if (flag_write_RTCM_1019_output == true) + { + for (std::map::const_iterator gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend(); gps_ephemeris_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1019(gps_ephemeris_iter->second); + } + } + if (flag_write_RTCM_MSM_output == true) + { + std::map::const_iterator gps_ephemeris_iter; + gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); + std::map::const_iterator gps_cnav_ephemeris_iter; + gps_cnav_ephemeris_iter = d_ls_pvt->gps_cnav_ephemeris_map.cbegin(); + if ((gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) && (gps_cnav_ephemeris_iter != d_ls_pvt->gps_cnav_ephemeris_map.cend())) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + } + } + } + if (type_of_rx == 9) // GPS L1 C/A + Galileo E1B + { + if (flag_write_RTCM_1019_output == true) + { + for (gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.begin(); gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.end(); gps_ephemeris_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1019(gps_ephemeris_iter->second); + } + } + if (flag_write_RTCM_1045_output == true) + { + for (galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.begin(); galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end(); galileo_ephemeris_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1045(galileo_ephemeris_iter->second); + } + } + if (flag_write_RTCM_MSM_output == true) + { + //gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.end(); + //galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.end(); + unsigned int i = 0; + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + { + std::string system(&gnss_observables_iter->second.System, 1); + if (gps_channel == 0) + { + if (system.compare("G") == 0) + { + // This is a channel with valid GPS signal + gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) + { + gps_channel = i; + } + } + } + if (gal_channel == 0) + { + if (system.compare("E") == 0) + { + galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend()) + { + gal_channel = i; + } + } + } + i++; + } + if (flag_write_RTCM_MSM_output == true) + { + if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, galileo_ephemeris_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + } + } + if (flag_write_RTCM_MSM_output == true) + { + if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_ephemeris_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + } + } + } + } + if ((type_of_rx == 23) || (type_of_rx == 24) || (type_of_rx == 25)) // GLONASS + { + if (flag_write_RTCM_1020_output == true) + { + for (std::map::const_iterator glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_ls_pvt->glonass_gnav_utc_model); + } + } + + std::map::const_iterator glo_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); + + if (glo_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glo_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + } + b_rtcm_writing_started = true; + } + if (type_of_rx == 26) // GPS L1 C/A + GLONASS L1 C/A + { + if (flag_write_RTCM_1019_output == true) + { + for (gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend(); gps_ephemeris_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1019(gps_ephemeris_iter->second); + } + } + if (flag_write_RTCM_1020_output == true) + { + for (std::map::const_iterator glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_ls_pvt->glonass_gnav_utc_model); + } + } + if (flag_write_RTCM_MSM_output == true) + { + //gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.end(); + //galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.end(); + unsigned int i = 0; + for (gnss_observables_iter = gnss_observables_map.begin(); gnss_observables_iter != gnss_observables_map.end(); gnss_observables_iter++) + { + std::string system(&gnss_observables_iter->second.System, 1); + if (gps_channel == 0) + { + if (system.compare("G") == 0) + { + // This is a channel with valid GPS signal + gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) + { + gps_channel = i; + } + } + } + if (glo_channel == 0) + { + if (system.compare("R") == 0) + { + glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) + { + glo_channel = i; + } + } + } + i++; + } + if (flag_write_RTCM_MSM_output == true) + { + if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + } + } + if (flag_write_RTCM_MSM_output == true) + { + if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_ephemeris_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + } + } + } + } + if (type_of_rx == 27) // GLONASS L1 C/A + Galileo E1B + { + if (flag_write_RTCM_1020_output == true) + { + for (std::map::const_iterator glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_ls_pvt->glonass_gnav_utc_model); + } + } + if (flag_write_RTCM_1045_output == true) + { + for (galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.cbegin(); galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend(); galileo_ephemeris_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1045(galileo_ephemeris_iter->second); + } + } + if (flag_write_RTCM_MSM_output == true) + { + //gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.end(); + //galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.end(); + unsigned int i = 0; + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + { + std::string system(&gnss_observables_iter->second.System, 1); + if (gal_channel == 0) + { + if (system.compare("E") == 0) + { + // This is a channel with valid GPS signal + galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend()) + { + gal_channel = i; + } + } + } + if (glo_channel == 0) + { + if (system.compare("R") == 0) + { + glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) + { + glo_channel = i; + } + } + } + i++; + } + if (flag_write_RTCM_MSM_output == true) + { + if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, galileo_ephemeris_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + } + } + if (flag_write_RTCM_MSM_output == true) + { + if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + } + } + } + } + if (type_of_rx == 29) // GPS L1 C/A + GLONASS L2 C/A + { + if (flag_write_RTCM_1019_output == true) + { + for (gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend(); gps_ephemeris_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1019(gps_ephemeris_iter->second); + } + } + if (flag_write_RTCM_1020_output == true) + { + for (std::map::const_iterator glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_ls_pvt->glonass_gnav_utc_model); + } + } + if (flag_write_RTCM_MSM_output == true) + { + //gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.end(); + //galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.end(); + unsigned int i = 0; + for (gnss_observables_iter = gnss_observables_map.begin(); gnss_observables_iter != gnss_observables_map.end(); gnss_observables_iter++) + { + std::string system(&gnss_observables_iter->second.System, 1); + if (gps_channel == 0) + { + if (system.compare("G") == 0) + { + // This is a channel with valid GPS signal + gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) + { + gps_channel = i; + } + } + } + if (glo_channel == 0) + { + if (system.compare("R") == 0) + { + glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) + { + glo_channel = i; + } + } + } + i++; + } + if (flag_write_RTCM_MSM_output == true) + { + if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + } + } + if (flag_write_RTCM_MSM_output == true) + { + if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_ephemeris_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + } + } + } + } + if (type_of_rx == 30) // GLONASS L2 C/A + Galileo E1B + { + if (flag_write_RTCM_1020_output == true) + { + for (std::map::const_iterator glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_ls_pvt->glonass_gnav_utc_model); + } + } + if (flag_write_RTCM_1045_output == true) + { + for (galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.cbegin(); galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend(); galileo_ephemeris_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1045(galileo_ephemeris_iter->second); + } + } + if (flag_write_RTCM_MSM_output == true) + { + //gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.end(); + //galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.end(); + unsigned int i = 0; + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + { + std::string system(&gnss_observables_iter->second.System, 1); + if (gal_channel == 0) + { + if (system.compare("E") == 0) + { + // This is a channel with valid GPS signal + galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend()) + { + gal_channel = i; + } + } + } + if (glo_channel == 0) + { + if (system.compare("R") == 0) + { + glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) + { + glo_channel = i; + } + } + } + i++; + } + if (flag_write_RTCM_MSM_output == true) + { + if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, galileo_ephemeris_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + } + } + if (flag_write_RTCM_MSM_output == true) + { + if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + } + } + } + } + } + + if (!b_rtcm_writing_started) // the first time + { + if (type_of_rx == 1) // GPS L1 C/A { for (std::map::const_iterator gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend(); gps_ephemeris_iter++) { d_rtcm_printer->Print_Rtcm_MT1019(gps_ephemeris_iter->second); } - } - if (flag_write_RTCM_MSM_output == true) - { - std::map::const_iterator gps_ephemeris_iter; - gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); + + std::map::const_iterator gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) { d_rtcm_printer->Print_Rtcm_MSM(7, gps_ephemeris_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); } + b_rtcm_writing_started = true; } - } - if ((type_of_rx == 4) || (type_of_rx == 5) || (type_of_rx == 6) || (type_of_rx == 14) || (type_of_rx == 15)) // Galileo - { - if (flag_write_RTCM_1045_output == true) + if ((type_of_rx == 4) || (type_of_rx == 5) || (type_of_rx == 6) || (type_of_rx == 14) || (type_of_rx == 15)) // Galileo { for (std::map::const_iterator gal_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.cbegin(); gal_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend(); gal_ephemeris_iter++) { d_rtcm_printer->Print_Rtcm_MT1045(gal_ephemeris_iter->second); } - } - if (flag_write_RTCM_MSM_output == true) - { - std::map::const_iterator gal_ephemeris_iter; - gal_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.cbegin(); + + std::map::const_iterator gal_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.cbegin(); + if (gal_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend()) { d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_ephemeris_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); } + b_rtcm_writing_started = true; } - } - if (type_of_rx == 7) // GPS L1 C/A + GPS L2C - { - if (flag_write_RTCM_1019_output == true) + if (type_of_rx == 7) // GPS L1 C/A + GPS L2C { for (std::map::const_iterator gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend(); gps_ephemeris_iter++) { d_rtcm_printer->Print_Rtcm_MT1019(gps_ephemeris_iter->second); } - } - if (flag_write_RTCM_MSM_output == true) - { - std::map::const_iterator gps_ephemeris_iter; - gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); - std::map::const_iterator gps_cnav_ephemeris_iter; - gps_cnav_ephemeris_iter = d_ls_pvt->gps_cnav_ephemeris_map.cbegin(); + + std::map::const_iterator gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); + std::map::const_iterator gps_cnav_ephemeris_iter = d_ls_pvt->gps_cnav_ephemeris_map.cbegin(); + if ((gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) && (gps_cnav_ephemeris_iter != d_ls_pvt->gps_cnav_ephemeris_map.cend())) { d_rtcm_printer->Print_Rtcm_MSM(7, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); } + b_rtcm_writing_started = true; } - } - if (type_of_rx == 9) // GPS L1 C/A + Galileo E1B - { - if (flag_write_RTCM_1019_output == true) + if (type_of_rx == 9) // GPS L1 C/A + Galileo E1B { - for (gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.begin(); gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.end(); gps_ephemeris_iter++) + if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 { - d_rtcm_printer->Print_Rtcm_MT1019(gps_ephemeris_iter->second); + for (std::map::const_iterator gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend(); gps_ephemeris_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1019(gps_ephemeris_iter->second); + } } - } - if (flag_write_RTCM_1045_output == true) - { - for (galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.begin(); galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end(); galileo_ephemeris_iter++) + if (d_rtcm_MT1045_rate_ms != 0) { - d_rtcm_printer->Print_Rtcm_MT1045(galileo_ephemeris_iter->second); + for (galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.begin(); galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end(); galileo_ephemeris_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1045(galileo_ephemeris_iter->second); + } } - } - if (flag_write_RTCM_MSM_output == true) - { - //gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.end(); - //galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.end(); + unsigned int i = 0; for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) { @@ -1269,7 +1769,7 @@ int rtklib_pvt_cc::work(int noutput_items, gr_vector_const_void_star& input_item { // This is a channel with valid GPS signal gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) + if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.end()) { gps_channel = i; } @@ -1280,7 +1780,7 @@ int rtklib_pvt_cc::work(int noutput_items, gr_vector_const_void_star& input_item if (system.compare("E") == 0) { galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend()) + if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end()) { gal_channel = i; } @@ -1288,62 +1788,54 @@ int rtklib_pvt_cc::work(int noutput_items, gr_vector_const_void_star& input_item } i++; } - if (flag_write_RTCM_MSM_output == true) + + if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.end() && (d_rtcm_MT1077_rate_ms != 0)) { - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, galileo_ephemeris_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } + d_rtcm_printer->Print_Rtcm_MSM(7, gps_ephemeris_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); } - if (flag_write_RTCM_MSM_output == true) + + if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end() && (d_rtcm_MT1097_rate_ms != 0)) { - if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_ephemeris_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, galileo_ephemeris_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); } + b_rtcm_writing_started = true; } - } - if ((type_of_rx == 23) || (type_of_rx == 24) || (type_of_rx == 25)) // GLONASS - { - if (flag_write_RTCM_1020_output == true) + if ((type_of_rx == 23) || (type_of_rx == 24) || (type_of_rx == 25)) // GLONASS { for (std::map::const_iterator glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) { d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_ls_pvt->glonass_gnav_utc_model); } - } - std::map::const_iterator glo_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); + std::map::const_iterator glo_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); - if (glo_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glo_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } - b_rtcm_writing_started = true; - } - if (type_of_rx == 26) // GPS L1 C/A + GLONASS L1 C/A - { - if (flag_write_RTCM_1019_output == true) - { - for (gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend(); gps_ephemeris_iter++) + if (glo_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) { - d_rtcm_printer->Print_Rtcm_MT1019(gps_ephemeris_iter->second); + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glo_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); } + b_rtcm_writing_started = true; } - if (flag_write_RTCM_1020_output == true) + if (type_of_rx == 26) // GPS L1 C/A + GLONASS L1 C/A { - for (std::map::const_iterator glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) + if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 { - d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_ls_pvt->glonass_gnav_utc_model); + for (gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend(); gps_ephemeris_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1019(gps_ephemeris_iter->second); + } } - } - if (flag_write_RTCM_MSM_output == true) - { + if (d_rtcm_MT1020_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (std::map::const_iterator glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_ls_pvt->glonass_gnav_utc_model); + } + } + //gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.end(); //galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.end(); unsigned int i = 0; - for (gnss_observables_iter = gnss_observables_map.begin(); gnss_observables_iter != gnss_observables_map.end(); gnss_observables_iter++) + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) { std::string system(&gnss_observables_iter->second.System, 1); if (gps_channel == 0) @@ -1371,42 +1863,35 @@ int rtklib_pvt_cc::work(int noutput_items, gr_vector_const_void_star& input_item } i++; } - if (flag_write_RTCM_MSM_output == true) + if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) { - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + } + + if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_ephemeris_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + } + + b_rtcm_writing_started = true; + } + if (type_of_rx == 27) // GLONASS L1 C/A + Galileo E1B + { + if (d_rtcm_MT1020_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (std::map::const_iterator glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_ls_pvt->glonass_gnav_utc_model); } } - if (flag_write_RTCM_MSM_output == true) + if (d_rtcm_MT1045_rate_ms != 0) // allows deactivating messages by setting rate = 0 { - if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) + for (galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.cbegin(); galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend(); galileo_ephemeris_iter++) { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_ephemeris_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + d_rtcm_printer->Print_Rtcm_MT1045(galileo_ephemeris_iter->second); } } - } - } - if (type_of_rx == 27) // GLONASS L1 C/A + Galileo E1B - { - if (flag_write_RTCM_1020_output == true) - { - for (std::map::const_iterator glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) - { - d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_ls_pvt->glonass_gnav_utc_model); - } - } - if (flag_write_RTCM_1045_output == true) - { - for (galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.cbegin(); galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend(); galileo_ephemeris_iter++) - { - d_rtcm_printer->Print_Rtcm_MT1045(galileo_ephemeris_iter->second); - } - } - if (flag_write_RTCM_MSM_output == true) - { - //gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.end(); - //galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.end(); + unsigned int i = 0; for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) { @@ -1436,266 +1921,148 @@ int rtklib_pvt_cc::work(int noutput_items, gr_vector_const_void_star& input_item } i++; } - if (flag_write_RTCM_MSM_output == true) + if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end()) { - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end()) + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, galileo_ephemeris_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + } + if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + } + } + if (type_of_rx == 29) // GPS L1 C/A + GLONASS L2 C/A + { + if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend(); gps_ephemeris_iter++) { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, galileo_ephemeris_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + d_rtcm_printer->Print_Rtcm_MT1019(gps_ephemeris_iter->second); } } - if (flag_write_RTCM_MSM_output == true) + if (d_rtcm_MT1020_rate_ms != 0) // allows deactivating messages by setting rate = 0 { - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) + for (std::map::const_iterator glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_ls_pvt->glonass_gnav_utc_model); } } + + //gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.end(); + //galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.end(); + unsigned int i = 0; + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + { + std::string system(&gnss_observables_iter->second.System, 1); + if (gps_channel == 0) + { + if (system.compare("G") == 0) + { + // This is a channel with valid GPS signal + gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) + { + gps_channel = i; + } + } + } + if (glo_channel == 0) + { + if (system.compare("R") == 0) + { + glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) + { + glo_channel = i; + } + } + } + i++; + } + if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + } + + if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, gps_ephemeris_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + } + + b_rtcm_writing_started = true; + } + if (type_of_rx == 30) // GLONASS L2 C/A + Galileo E1B + { + if (d_rtcm_MT1020_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (std::map::const_iterator glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_ls_pvt->glonass_gnav_utc_model); + } + } + if (d_rtcm_MT1045_rate_ms != 0) // allows deactivating messages by setting rate = 0 + { + for (galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.cbegin(); galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend(); galileo_ephemeris_iter++) + { + d_rtcm_printer->Print_Rtcm_MT1045(galileo_ephemeris_iter->second); + } + } + + unsigned int i = 0; + for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) + { + std::string system(&gnss_observables_iter->second.System, 1); + if (gal_channel == 0) + { + if (system.compare("E") == 0) + { + // This is a channel with valid GPS signal + galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend()) + { + gal_channel = i; + } + } + } + if (glo_channel == 0) + { + if (system.compare("R") == 0) + { + glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); + if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) + { + glo_channel = i; + } + } + } + i++; + } + if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, galileo_ephemeris_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + } + if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) + { + d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); + } } } } - if (!b_rtcm_writing_started) // the first time + catch (const boost::exception& ex) { - if (type_of_rx == 1) // GPS L1 C/A - { - for (std::map::const_iterator gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend(); gps_ephemeris_iter++) - { - d_rtcm_printer->Print_Rtcm_MT1019(gps_ephemeris_iter->second); - } - - std::map::const_iterator gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); - - if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_ephemeris_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } - b_rtcm_writing_started = true; - } - if ((type_of_rx == 4) || (type_of_rx == 5) || (type_of_rx == 6) || (type_of_rx == 14) || (type_of_rx == 15)) // Galileo - { - for (std::map::const_iterator gal_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.cbegin(); gal_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend(); gal_ephemeris_iter++) - { - d_rtcm_printer->Print_Rtcm_MT1045(gal_ephemeris_iter->second); - } - - std::map::const_iterator gal_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.cbegin(); - - if (gal_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, gal_ephemeris_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } - b_rtcm_writing_started = true; - } - if (type_of_rx == 7) // GPS L1 C/A + GPS L2C - { - for (std::map::const_iterator gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend(); gps_ephemeris_iter++) - { - d_rtcm_printer->Print_Rtcm_MT1019(gps_ephemeris_iter->second); - } - - std::map::const_iterator gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); - std::map::const_iterator gps_cnav_ephemeris_iter = d_ls_pvt->gps_cnav_ephemeris_map.cbegin(); - - if ((gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) && (gps_cnav_ephemeris_iter != d_ls_pvt->gps_cnav_ephemeris_map.cend())) - { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_ephemeris_iter->second, gps_cnav_ephemeris_iter->second, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } - b_rtcm_writing_started = true; - } - if (type_of_rx == 9) // GPS L1 C/A + Galileo E1B - { - if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 - { - for (std::map::const_iterator gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend(); gps_ephemeris_iter++) - { - d_rtcm_printer->Print_Rtcm_MT1019(gps_ephemeris_iter->second); - } - } - if (d_rtcm_MT1045_rate_ms != 0) - { - for (galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.begin(); galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end(); galileo_ephemeris_iter++) - { - d_rtcm_printer->Print_Rtcm_MT1045(galileo_ephemeris_iter->second); - } - } - - unsigned int i = 0; - for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) - { - std::string system(&gnss_observables_iter->second.System, 1); - if (gps_channel == 0) - { - if (system.compare("G") == 0) - { - // This is a channel with valid GPS signal - gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.end()) - { - gps_channel = i; - } - } - } - if (gal_channel == 0) - { - if (system.compare("E") == 0) - { - galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end()) - { - gal_channel = i; - } - } - } - i++; - } - - if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.end() && (d_rtcm_MT1077_rate_ms != 0)) - { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_ephemeris_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } - - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end() && (d_rtcm_MT1097_rate_ms != 0)) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, galileo_ephemeris_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } - b_rtcm_writing_started = true; - } - if ((type_of_rx == 23) || (type_of_rx == 24) || (type_of_rx == 25)) // GLONASS - { - for (std::map::const_iterator glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) - { - d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_ls_pvt->glonass_gnav_utc_model); - } - - std::map::const_iterator glo_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); - - if (glo_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glo_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } - b_rtcm_writing_started = true; - } - if (type_of_rx == 26) // GPS L1 C/A + GLONASS L1 C/A - { - if (d_rtcm_MT1019_rate_ms != 0) // allows deactivating messages by setting rate = 0 - { - for (gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.cbegin(); gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend(); gps_ephemeris_iter++) - { - d_rtcm_printer->Print_Rtcm_MT1019(gps_ephemeris_iter->second); - } - } - if (d_rtcm_MT1020_rate_ms != 0) // allows deactivating messages by setting rate = 0 - { - for (std::map::const_iterator glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) - { - d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_ls_pvt->glonass_gnav_utc_model); - } - } - - //gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.end(); - //galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.end(); - unsigned int i = 0; - for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) - { - std::string system(&gnss_observables_iter->second.System, 1); - if (gps_channel == 0) - { - if (system.compare("G") == 0) - { - // This is a channel with valid GPS signal - gps_ephemeris_iter = d_ls_pvt->gps_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) - { - gps_channel = i; - } - } - } - if (glo_channel == 0) - { - if (system.compare("R") == 0) - { - glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) - { - glo_channel = i; - } - } - } - i++; - } - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } - - if (gps_ephemeris_iter != d_ls_pvt->gps_ephemeris_map.cend()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, gps_ephemeris_iter->second, {}, {}, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } - - b_rtcm_writing_started = true; - } - if (type_of_rx == 27) // GLONASS L1 C/A + Galileo E1B - { - if (d_rtcm_MT1020_rate_ms != 0) // allows deactivating messages by setting rate = 0 - { - for (std::map::const_iterator glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.cbegin(); glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.cend(); glonass_gnav_ephemeris_iter++) - { - d_rtcm_printer->Print_Rtcm_MT1020(glonass_gnav_ephemeris_iter->second, d_ls_pvt->glonass_gnav_utc_model); - } - } - if (d_rtcm_MT1045_rate_ms != 0) // allows deactivating messages by setting rate = 0 - { - for (galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.cbegin(); galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend(); galileo_ephemeris_iter++) - { - d_rtcm_printer->Print_Rtcm_MT1045(galileo_ephemeris_iter->second); - } - } - - unsigned int i = 0; - for (gnss_observables_iter = gnss_observables_map.cbegin(); gnss_observables_iter != gnss_observables_map.cend(); gnss_observables_iter++) - { - std::string system(&gnss_observables_iter->second.System, 1); - if (gal_channel == 0) - { - if (system.compare("E") == 0) - { - // This is a channel with valid GPS signal - galileo_ephemeris_iter = d_ls_pvt->galileo_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.cend()) - { - gal_channel = i; - } - } - } - if (glo_channel == 0) - { - if (system.compare("R") == 0) - { - glonass_gnav_ephemeris_iter = d_ls_pvt->glonass_gnav_ephemeris_map.find(gnss_observables_iter->second.PRN); - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) - { - glo_channel = i; - } - } - } - i++; - } - if (galileo_ephemeris_iter != d_ls_pvt->galileo_ephemeris_map.end()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, galileo_ephemeris_iter->second, {}, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } - if (glonass_gnav_ephemeris_iter != d_ls_pvt->glonass_gnav_ephemeris_map.end()) - { - d_rtcm_printer->Print_Rtcm_MSM(7, {}, {}, {}, glonass_gnav_ephemeris_iter->second, d_rx_time, gnss_observables_map, 0, 0, 0, 0, 0); - } - } + std::cout << "RTCM boost exception: " << boost::diagnostic_information(ex) << std::endl; + LOG(ERROR) << "RTCM boost exception: " << boost::diagnostic_information(ex); + } + catch (const std::exception& ex) + { + std::cout << "RTCM std exception: " << ex.what() << std::endl; + LOG(ERROR) << "RTCM std exception: " << ex.what(); } } } // DEBUG MESSAGE: Display position in console output - if ((d_ls_pvt->is_valid_position() == true) && (flag_display_pvt == true)) + if (d_ls_pvt->is_valid_position() and flag_display_pvt) { std::cout << "Position at " << boost::posix_time::to_simple_string(d_ls_pvt->get_position_UTC_time()) << " UTC using " << d_ls_pvt->get_num_valid_observations() << " observations is Lat = " << d_ls_pvt->get_latitude() << " [deg], Long = " << d_ls_pvt->get_longitude() diff --git a/src/algorithms/PVT/libs/rinex_printer.h b/src/algorithms/PVT/libs/rinex_printer.h index d5b8f5835..794c98a3f 100644 --- a/src/algorithms/PVT/libs/rinex_printer.h +++ b/src/algorithms/PVT/libs/rinex_printer.h @@ -57,7 +57,7 @@ #include "glonass_gnav_navigation_message.h" #include "GPS_L1_CA.h" #include "Galileo_E1.h" -#include "GLONASS_L1_CA.h" +#include "GLONASS_L1_L2_CA.h" #include "gnss_synchro.h" #include #include diff --git a/src/algorithms/PVT/libs/rtklib_solver.cc b/src/algorithms/PVT/libs/rtklib_solver.cc index 158e92b59..a501b66ad 100644 --- a/src/algorithms/PVT/libs/rtklib_solver.cc +++ b/src/algorithms/PVT/libs/rtklib_solver.cc @@ -55,7 +55,7 @@ #include "rtklib_conversions.h" #include "GPS_L1_CA.h" #include "Galileo_E1.h" -#include "GLONASS_L1_CA.h" +#include "GLONASS_L1_L2_CA.h" #include diff --git a/src/algorithms/acquisition/adapters/CMakeLists.txt b/src/algorithms/acquisition/adapters/CMakeLists.txt index bf0c1428d..ff708f433 100644 --- a/src/algorithms/acquisition/adapters/CMakeLists.txt +++ b/src/algorithms/acquisition/adapters/CMakeLists.txt @@ -33,6 +33,7 @@ set(ACQ_ADAPTER_SOURCES galileo_e5a_noncoherent_iq_acquisition_caf.cc galileo_e5a_pcps_acquisition.cc glonass_l1_ca_pcps_acquisition.cc + glonass_l2_ca_pcps_acquisition.cc ) if(ENABLE_FPGA) 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 4c96e0f81..685c93425 100644 --- a/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.cc +++ b/src/algorithms/acquisition/adapters/glonass_l1_ca_pcps_acquisition.cc @@ -34,8 +34,8 @@ #include "glonass_l1_ca_pcps_acquisition.h" #include "configuration_interface.h" #include "glonass_l1_signal_processing.h" -#include "GLONASS_L1_CA.h" #include "gnss_sdr_flags.h" +#include "GLONASS_L1_L2_CA.h" #include #include diff --git a/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.cc b/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.cc new file mode 100644 index 000000000..a7584cb15 --- /dev/null +++ b/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.cc @@ -0,0 +1,312 @@ +/*! + * \file glonass_l2_ca_pcps_acquisition.cc + * \brief Adapts a PCPS acquisition block to an AcquisitionInterface for + * Glonass L2 C/A signals + * \author Damian Miralles, 2018, dmiralles2009@gmail.com + * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "glonass_l2_ca_pcps_acquisition.h" +#include "configuration_interface.h" +#include "glonass_l2_signal_processing.h" +#include "GLONASS_L1_L2_CA.h" +#include "gnss_sdr_flags.h" +#include +#include + + +using google::LogMessage; + +GlonassL2CaPcpsAcquisition::GlonassL2CaPcpsAcquisition( + ConfigurationInterface* configuration, std::string role, + unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) +{ + configuration_ = configuration; + std::string default_item_type = "gr_complex"; + std::string default_dump_filename = "./data/acquisition.dat"; + + DLOG(INFO) << "role " << role; + + item_type_ = configuration_->property(role + ".item_type", default_item_type); + + long fs_in_deprecated = configuration_->property("GNSS-SDR.internal_fs_hz", 2048000); + fs_in_ = configuration_->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + if_ = configuration_->property(role + ".if", 0); + dump_ = configuration_->property(role + ".dump", false); + blocking_ = configuration_->property(role + ".blocking", true); + doppler_max_ = configuration_->property(role + ".doppler_max", 5000); + if (FLAGS_doppler_max != 0) doppler_max_ = FLAGS_doppler_max; + sampled_ms_ = configuration_->property(role + ".coherent_integration_time_ms", 1); + + bit_transition_flag_ = configuration_->property(role + ".bit_transition_flag", false); + use_CFAR_algorithm_flag_ = configuration_->property(role + ".use_CFAR_algorithm", true); //will be false in future versions + + max_dwells_ = configuration_->property(role + ".max_dwells", 1); + + dump_filename_ = configuration_->property(role + ".dump_filename", default_dump_filename); + + //--- Find number of samples per spreading code ------------------------- + code_length_ = round(fs_in_ / (GLONASS_L2_CA_CODE_RATE_HZ / GLONASS_L2_CA_CODE_LENGTH_CHIPS)); + + vector_length_ = code_length_ * sampled_ms_; + + if (bit_transition_flag_) + { + vector_length_ *= 2; + } + + code_ = new gr_complex[vector_length_]; + + if (item_type_.compare("cshort") == 0) + { + item_size_ = sizeof(lv_16sc_t); + } + else + { + item_size_ = sizeof(gr_complex); + } + acquisition_ = pcps_make_acquisition(sampled_ms_, max_dwells_, + doppler_max_, if_, fs_in_, code_length_, code_length_, + bit_transition_flag_, use_CFAR_algorithm_flag_, dump_, blocking_, dump_filename_, item_size_); + DLOG(INFO) << "acquisition(" << acquisition_->unique_id() << ")"; + + stream_to_vector_ = gr::blocks::stream_to_vector::make(item_size_, vector_length_); + DLOG(INFO) << "stream_to_vector(" << stream_to_vector_->unique_id() << ")"; + + if (item_type_.compare("cbyte") == 0) + { + cbyte_to_float_x2_ = make_complex_byte_to_float_x2(); + float_to_complex_ = gr::blocks::float_to_complex::make(); + } + + channel_ = 0; + threshold_ = 0.0; + doppler_step_ = 0; + gnss_synchro_ = 0; +} + + +GlonassL2CaPcpsAcquisition::~GlonassL2CaPcpsAcquisition() +{ + delete[] code_; +} + + +void GlonassL2CaPcpsAcquisition::set_channel(unsigned int channel) +{ + channel_ = channel; + acquisition_->set_channel(channel_); +} + + +void GlonassL2CaPcpsAcquisition::set_threshold(float threshold) +{ + float pfa = configuration_->property(role_ + ".pfa", 0.0); + + if (pfa == 0.0) + { + threshold_ = threshold; + } + else + { + threshold_ = calculate_threshold(pfa); + } + + DLOG(INFO) << "Channel " << channel_ << " Threshold = " << threshold_; + + acquisition_->set_threshold(threshold_); +} + + +void GlonassL2CaPcpsAcquisition::set_doppler_max(unsigned int doppler_max) +{ + doppler_max_ = doppler_max; + + acquisition_->set_doppler_max(doppler_max_); +} + + +void GlonassL2CaPcpsAcquisition::set_doppler_step(unsigned int doppler_step) +{ + doppler_step_ = doppler_step; + + acquisition_->set_doppler_step(doppler_step_); +} + + +void GlonassL2CaPcpsAcquisition::set_gnss_synchro(Gnss_Synchro* gnss_synchro) +{ + gnss_synchro_ = gnss_synchro; + + acquisition_->set_gnss_synchro(gnss_synchro_); +} + + +signed int GlonassL2CaPcpsAcquisition::mag() +{ + return acquisition_->mag(); +} + + +void GlonassL2CaPcpsAcquisition::init() +{ + acquisition_->init(); + + set_local_code(); +} + + +void GlonassL2CaPcpsAcquisition::set_local_code() +{ + std::complex* code = new std::complex[code_length_]; + + glonass_l2_ca_code_gen_complex_sampled(code, /* gnss_synchro_->PRN,*/ fs_in_, 0); + + for (unsigned int i = 0; i < sampled_ms_; i++) + { + memcpy(&(code_[i * code_length_]), code, + sizeof(gr_complex) * code_length_); + } + + acquisition_->set_local_code(code_); + delete[] code; +} + + +void GlonassL2CaPcpsAcquisition::reset() +{ + acquisition_->set_active(true); +} + + +void GlonassL2CaPcpsAcquisition::set_state(int state) +{ + acquisition_->set_state(state); +} + + +float GlonassL2CaPcpsAcquisition::calculate_threshold(float pfa) +{ + //Calculate the threshold + unsigned int frequency_bins = 0; + /* + for (int doppler = (int)(-doppler_max_); doppler <= (int)doppler_max_; doppler += doppler_step_) + { + frequency_bins++; + } + */ + + frequency_bins = (2 * doppler_max_ + doppler_step_) / doppler_step_; + + DLOG(INFO) << "Channel " << channel_ << " Pfa = " << pfa; + unsigned int ncells = vector_length_ * frequency_bins; + double exponent = 1 / static_cast(ncells); + double val = pow(1.0 - pfa, exponent); + double lambda = static_cast(vector_length_); + boost::math::exponential_distribution mydist(lambda); + float threshold = static_cast(quantile(mydist, val)); + + return threshold; +} + + +void GlonassL2CaPcpsAcquisition::connect(gr::top_block_sptr top_block) +{ + if (item_type_.compare("gr_complex") == 0) + { + top_block->connect(stream_to_vector_, 0, acquisition_, 0); + } + else if (item_type_.compare("cshort") == 0) + { + top_block->connect(stream_to_vector_, 0, acquisition_, 0); + } + else if (item_type_.compare("cbyte") == 0) + { + top_block->connect(cbyte_to_float_x2_, 0, float_to_complex_, 0); + top_block->connect(cbyte_to_float_x2_, 1, float_to_complex_, 1); + top_block->connect(float_to_complex_, 0, stream_to_vector_, 0); + top_block->connect(stream_to_vector_, 0, acquisition_, 0); + } + else + { + LOG(WARNING) << item_type_ << " unknown acquisition item type"; + } +} + + +void GlonassL2CaPcpsAcquisition::disconnect(gr::top_block_sptr top_block) +{ + if (item_type_.compare("gr_complex") == 0) + { + top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); + } + else if (item_type_.compare("cshort") == 0) + { + top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); + } + else if (item_type_.compare("cbyte") == 0) + { + // Since a byte-based acq implementation is not available, + // we just convert cshorts to gr_complex + top_block->disconnect(cbyte_to_float_x2_, 0, float_to_complex_, 0); + top_block->disconnect(cbyte_to_float_x2_, 1, float_to_complex_, 1); + top_block->disconnect(float_to_complex_, 0, stream_to_vector_, 0); + top_block->disconnect(stream_to_vector_, 0, acquisition_, 0); + } + else + { + LOG(WARNING) << item_type_ << " unknown acquisition item type"; + } +} + + +gr::basic_block_sptr GlonassL2CaPcpsAcquisition::get_left_block() +{ + if (item_type_.compare("gr_complex") == 0) + { + return stream_to_vector_; + } + else if (item_type_.compare("cshort") == 0) + { + return stream_to_vector_; + } + else if (item_type_.compare("cbyte") == 0) + { + return cbyte_to_float_x2_; + } + else + { + LOG(WARNING) << item_type_ << " unknown acquisition item type"; + return nullptr; + } +} + + +gr::basic_block_sptr GlonassL2CaPcpsAcquisition::get_right_block() +{ + return acquisition_; +} diff --git a/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.h b/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.h new file mode 100644 index 000000000..f86acdaff --- /dev/null +++ b/src/algorithms/acquisition/adapters/glonass_l2_ca_pcps_acquisition.h @@ -0,0 +1,166 @@ +/*! + * \file glonass_l2_ca_pcps_acquisition.h + * \brief Adapts a PCPS acquisition block to an AcquisitionInterface for + * Glonass L2 C/A signals + * \author Damian Miralles, 2018, dmiralles2009@gmail.com + * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_GLONASS_L2_CA_PCPS_ACQUISITION_H_ +#define GNSS_SDR_GLONASS_L2_CA_PCPS_ACQUISITION_H_ + +#include "acquisition_interface.h" +#include "gnss_synchro.h" +#include "pcps_acquisition.h" +#include "complex_byte_to_float_x2.h" +#include +#include +#include + +class ConfigurationInterface; + +/*! + * \brief This class adapts a PCPS acquisition block to an AcquisitionInterface + * for GLONASS L2 C/A signals + */ +class GlonassL2CaPcpsAcquisition : public AcquisitionInterface +{ +public: + GlonassL2CaPcpsAcquisition(ConfigurationInterface* configuration, + std::string role, unsigned int in_streams, + unsigned int out_streams); + + virtual ~GlonassL2CaPcpsAcquisition(); + + inline std::string role() override + { + return role_; + } + + /*! + * \brief Returns "GLONASS_L2_CA_PCPS_Acquisition" + */ + inline std::string implementation() override + { + return "GLONASS_L2_CA_PCPS_Acquisition"; + } + + inline size_t item_size() override + { + return item_size_; + } + + void connect(gr::top_block_sptr top_block) override; + void disconnect(gr::top_block_sptr top_block) override; + gr::basic_block_sptr get_left_block() override; + gr::basic_block_sptr get_right_block() override; + + /*! + * \brief Set acquisition/tracking common Gnss_Synchro object pointer + * to efficiently exchange synchronization data between acquisition and + * tracking blocks + */ + void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; + + /*! + * \brief Set acquisition channel unique ID + */ + void set_channel(unsigned int channel) override; + + /*! + * \brief Set statistics threshold of PCPS algorithm + */ + void set_threshold(float threshold) override; + + /*! + * \brief Set maximum Doppler off grid search + */ + void set_doppler_max(unsigned int doppler_max) override; + + /*! + * \brief Set Doppler steps for the grid search + */ + void set_doppler_step(unsigned int doppler_step) override; + + /*! + * \brief Initializes acquisition algorithm. + */ + void init() override; + + /*! + * \brief Sets local code for GLONASS L2/CA PCPS acquisition algorithm. + */ + void set_local_code() override; + + /*! + * \brief Returns the maximum peak of grid search + */ + signed int mag() override; + + /*! + * \brief Restart acquisition algorithm + */ + void reset() override; + + /*! + * \brief If state = 1, it forces the block to start acquiring from the first sample + */ + void set_state(int state); + +private: + ConfigurationInterface* configuration_; + pcps_acquisition_sptr acquisition_; + gr::blocks::stream_to_vector::sptr stream_to_vector_; + gr::blocks::float_to_complex::sptr float_to_complex_; + complex_byte_to_float_x2_sptr cbyte_to_float_x2_; + size_t item_size_; + std::string item_type_; + unsigned int vector_length_; + unsigned int code_length_; + bool bit_transition_flag_; + bool use_CFAR_algorithm_flag_; + unsigned int channel_; + float threshold_; + unsigned int doppler_max_; + unsigned int doppler_step_; + unsigned int sampled_ms_; + unsigned int max_dwells_; + long fs_in_; + long if_; + bool dump_; + bool blocking_; + std::string dump_filename_; + std::complex* code_; + Gnss_Synchro* gnss_synchro_; + std::string role_; + unsigned int in_streams_; + unsigned int out_streams_; + + float calculate_threshold(float pfa); +}; + +#endif /* GNSS_SDR_GLONASS_L2_CA_PCPS_ACQUISITION_H_ */ diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc index 11c0754cd..19faf843e 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc @@ -34,8 +34,8 @@ */ #include "pcps_acquisition.h" -#include "GPS_L1_CA.h" // for GPS_TWO_PI -#include "GLONASS_L1_CA.h" // for GLONASS_TWO_PI +#include "GPS_L1_CA.h" // for GPS_TWO_PI +#include "GLONASS_L1_L2_CA.h" // for GLONASS_TWO_PI" #include #include #include @@ -210,6 +210,12 @@ bool pcps_acquisition::is_fdma() LOG(INFO) << "Trying to acquire SV PRN " << d_gnss_synchro->PRN << " with freq " << d_freq << " in Glonass Channel " << GLONASS_PRN.at(d_gnss_synchro->PRN) << std::endl; return true; } + else if (strcmp(d_gnss_synchro->Signal, "2G") == 0) + { + d_freq += DFRQ2_GLO * GLONASS_PRN.at(d_gnss_synchro->PRN); + LOG(INFO) << "Trying to acquire SV PRN " << d_gnss_synchro->PRN << " with freq " << d_freq << " in Glonass Channel " << GLONASS_PRN.at(d_gnss_synchro->PRN) << std::endl; + return true; + } else { return false; 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 80e823156..d97385f49 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_quicksync_acquisition_cc.cc @@ -316,7 +316,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, gr_complex* corr_output = static_cast(volk_gnsssdr_malloc(d_samples_per_code * sizeof(gr_complex), volk_gnsssdr_get_alignment())); /*Stores a copy of the folded version of the signal.This is used for - the FFT operations in future steps of excecution*/ + the FFT operations in future steps of execution*/ // gr_complex in_folded[d_fft_size]; float fft_normalization_factor = static_cast(d_fft_size) * static_cast(d_fft_size); @@ -468,7 +468,7 @@ int pcps_quicksync_acquisition_cc::general_work(int noutput_items, if (d_dump) { /*Since QuickSYnc performs a folded correlation in frequency by means - of the FFT, it is esential to also keep the values obtained from the + of the FFT, it is essential to also keep the values obtained from the possible delay to show how it is maximize*/ std::stringstream filename; std::streamsize n = sizeof(float) * (d_fft_size); // complex file write diff --git a/src/algorithms/acquisition/libs/CMakeLists.txt b/src/algorithms/acquisition/libs/CMakeLists.txt index 702ee57b8..53feb9366 100644 --- a/src/algorithms/acquisition/libs/CMakeLists.txt +++ b/src/algorithms/acquisition/libs/CMakeLists.txt @@ -16,40 +16,11 @@ # along with GNSS-SDR. If not, see . # - -#if(ENABLE_CUDA) -# # Append current NVCC flags by something, eg comput capability -# # set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} --gpu-architecture sm_30) -# list(APPEND CUDA_NVCC_FLAGS "-gencode arch=compute_30,code=sm_30; -std=c++11;-O3; -use_fast_math -default-stream per-thread") -# set(CUDA_PROPAGATE_HOST_FLAGS OFF) -# CUDA_INCLUDE_DIRECTORIES( ${CMAKE_CURRENT_SOURCE_DIR}) -# set(LIB_TYPE STATIC) #set the lib type -# CUDA_ADD_LIBRARY(CUDA_CORRELATOR_LIB ${LIB_TYPE} cuda_multicorrelator.h cuda_multicorrelator.cu) -# set(OPT_TRACKING_LIBRARIES ${OPT_TRACKING_LIBRARIES} CUDA_CORRELATOR_LIB) -# set(OPT_TRACKING_INCLUDES ${OPT_TRACKING_INCLUDES} ${CUDA_INCLUDE_DIRS} ) -#endif(ENABLE_CUDA) - - - -#set(TRACKING_LIB_SOURCES + set(ACQUISITION_LIB_SOURCES gps_fpga_acquisition_8sc.cc -# cpu_multicorrelator.cc -# cpu_multicorrelator_16sc.cc -# lock_detectors.cc -# tcp_communication.cc -# tcp_packet_data.cc -# tracking_2nd_DLL_filter.cc -# tracking_2nd_PLL_filter.cc -# tracking_discriminators.cc -# tracking_FLL_PLL_filter.cc -# tracking_loop_filter.cc ) -#if(ENABLE_FPGA) -# SET(ACQUISITION_LIB_SOURCES ${ACQUISITION_LIB_SOURCES} fpga_acquisition_8sc.cc) -#endif(ENABLE_FPGA) - include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src/core/system_parameters @@ -59,34 +30,17 @@ include_directories( ${VOLK_INCLUDE_DIRS} ${GLOG_INCLUDE_DIRS} ${GFlags_INCLUDE_DIRS} - ${OPT_TRACKING_INCLUDES} ${VOLK_GNSSSDR_INCLUDE_DIRS} ) -if(ENABLE_GENERIC_ARCH) - add_definitions( -DGENERIC_ARCH=1 ) -endif(ENABLE_GENERIC_ARCH) - -if (SSE3_AVAILABLE) - add_definitions( -DHAVE_SSE3=1 ) -endif(SSE3_AVAILABLE) - - -#file(GLOB TRACKING_LIB_HEADERS "*.h") file(GLOB ACQUISITION_LIB_HEADERS "*.h") -#list(SORT TRACKING_LIB_HEADERS) list(SORT ACQUISITION_LIB_HEADERS) -#add_library(tracking_lib ${TRACKING_LIB_SOURCES} ${TRACKING_LIB_HEADERS}) add_library(acquisition_lib ${ACQUISITION_LIB_SOURCES} ${ACQUISITION_LIB_HEADERS}) -#source_group(Headers FILES ${TRACKING_LIB_HEADERS}) source_group(Headers FILES ${ACQUISITION_LIB_HEADERS}) -#target_link_libraries(tracking_lib ${OPT_TRACKING_LIBRARIES} ${VOLK_LIBRARIES} ${VOLK_GNSSSDR_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES}) -target_link_libraries(acquisition_lib ${OPT_ACQUISITION_LIBRARIES} ${VOLK_LIBRARIES} ${VOLK_GNSSSDR_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES}) +target_link_libraries(acquisition_lib ${VOLK_LIBRARIES} ${VOLK_GNSSSDR_LIBRARIES} ${GNURADIO_RUNTIME_LIBRARIES}) if(VOLK_GNSSSDR_FOUND) -# add_dependencies(tracking_lib glog-${glog_RELEASE}) add_dependencies(acquisition_lib glog-${glog_RELEASE}) else(VOLK_GNSSSDR_FOUND) -# add_dependencies(tracking_lib glog-${glog_RELEASE} volk_gnsssdr_module) add_dependencies(acquisition_lib glog-${glog_RELEASE} volk_gnsssdr_module) endif() diff --git a/src/algorithms/acquisition/libs/gps_fpga_acquisition_8sc.cc b/src/algorithms/acquisition/libs/gps_fpga_acquisition_8sc.cc index 1cfc34c50..b1a855a11 100644 --- a/src/algorithms/acquisition/libs/gps_fpga_acquisition_8sc.cc +++ b/src/algorithms/acquisition/libs/gps_fpga_acquisition_8sc.cc @@ -35,34 +35,32 @@ #include "gps_fpga_acquisition_8sc.h" #include "gps_sdr_signal_processing.h" +#include "GPS_L1_CA.h" #include +#include // allocate memory dynamically #include // libraries used by DMA test code and GIPO test code -#include +#include #include #include -#include +#include // libraries used by DMA test code #include -#include -#include -#include +#include +#include // libraries used by GPIO test code -#include -#include +#include +#include #include // logging #include -#include - -#include "GPS_L1_CA.h" #define PAGE_SIZE 0x10000 #define MAX_PHASE_STEP_RAD 0.999999999534339 // 1 - pow(2,-31); @@ -110,7 +108,7 @@ gps_fpga_acquisition_8sc::gps_fpga_acquisition_8sc(std::string device_name, // allocate memory to compute all the PRNs // and compute all the possible codes std::complex* code = new std::complex[nsamples_total]; // buffer for the local code - std::complex* code_total = new gr_complex[vector_length]; // buffer for the local code repeate every number of ms + std::complex* code_total = new gr_complex[vector_length]; // buffer for the local code repeat every number of ms gr_complex* d_fft_codes_padded = static_cast(volk_gnsssdr_malloc(vector_length * sizeof(gr_complex), volk_gnsssdr_get_alignment())); @@ -252,8 +250,8 @@ void gps_fpga_acquisition_8sc::set_phase_step(unsigned int doppler_index) { phase_step_rad_real = MAX_PHASE_STEP_RAD; } - phase_step_rad_int_temp = phase_step_rad_real * 4; // * 2^2 - phase_step_rad_int = (int32_t)(phase_step_rad_int_temp * (536870912)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings + phase_step_rad_int_temp = phase_step_rad_real * 4; // * 2^2 + phase_step_rad_int = static_cast(phase_step_rad_int_temp * (536870912)); // * 2^29 (in total it makes x2^31 in two steps to avoid the warnings d_map_base[3] = phase_step_rad_int; } diff --git a/src/algorithms/acquisition/libs/gps_fpga_acquisition_8sc.h b/src/algorithms/acquisition/libs/gps_fpga_acquisition_8sc.h index 71f5e250b..40f8f37f2 100644 --- a/src/algorithms/acquisition/libs/gps_fpga_acquisition_8sc.h +++ b/src/algorithms/acquisition/libs/gps_fpga_acquisition_8sc.h @@ -92,7 +92,7 @@ private: int d_fd; // driver descriptor volatile unsigned *d_map_base; // driver memory map lv_16sc_t *d_all_fft_codes; // memory that contains all the code ffts - unsigned int d_vector_length; // number of samples incluing padding and number of ms + unsigned int d_vector_length; // number of samples including padding and number of ms unsigned int d_nsamples; // number of samples not including padding unsigned int d_select_queue; // queue selection std::string d_device_name; // HW device name diff --git a/src/algorithms/input_filter/adapters/notch_filter_lite.h b/src/algorithms/input_filter/adapters/notch_filter_lite.h index ea091dc58..9442b66cd 100644 --- a/src/algorithms/input_filter/adapters/notch_filter_lite.h +++ b/src/algorithms/input_filter/adapters/notch_filter_lite.h @@ -1,6 +1,6 @@ /*! * \file notch_filter_lite.h - * \brief Adapts a ligth version of a multistate notch filter + * \brief Adapts a light version of a multistate notch filter * \author Antonio Ramos, 2017. antonio.ramosdet(at)gmail.com * * Detailed description of the file here if needed. diff --git a/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.h b/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.h index 288dbbf7a..c2720180e 100644 --- a/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.h +++ b/src/algorithms/input_filter/gnuradio_blocks/notch_lite_cc.h @@ -1,6 +1,6 @@ /*! * \file notch_lite_cc.h - * \brief Implements a notch filter ligth algorithm + * \brief Implements a notch filter light algorithm * \author Antonio Ramos (antonio.ramosdet(at)gmail.com) * * ------------------------------------------------------------------------- @@ -43,7 +43,7 @@ typedef boost::shared_ptr notch_lite_sptr; notch_lite_sptr make_notch_filter_lite(float p_c_factor, float pfa, int length_, int n_segments_est, int n_segments_reset, int n_segments_coeff); /*! - * \brief This class implements a real-time software-defined multi state notch filter ligth version + * \brief This class implements a real-time software-defined multi state notch filter light version */ class NotchLite : public gr::block diff --git a/src/algorithms/libs/CMakeLists.txt b/src/algorithms/libs/CMakeLists.txt index 65e2c96b2..ac182801e 100644 --- a/src/algorithms/libs/CMakeLists.txt +++ b/src/algorithms/libs/CMakeLists.txt @@ -27,6 +27,7 @@ set(GNSS_SPLIBS_SOURCES gnss_signal_processing.cc gps_sdr_signal_processing.cc glonass_l1_signal_processing.cc + glonass_l2_signal_processing.cc pass_through.cc galileo_e5_signal_processing.cc complex_byte_to_float_x2.cc diff --git a/src/algorithms/libs/galileo_e1_signal_processing.cc b/src/algorithms/libs/galileo_e1_signal_processing.cc index ebeefcccf..beea0297c 100644 --- a/src/algorithms/libs/galileo_e1_signal_processing.cc +++ b/src/algorithms/libs/galileo_e1_signal_processing.cc @@ -53,7 +53,7 @@ void galileo_e1_code_gen_int(int* _dest, char _Signal[3], signed int _prn) for (size_t i = 0; i < Galileo_E1_B_PRIMARY_CODE[prn].length(); i++) { hex_to_binary_converter(&_dest[index], Galileo_E1_B_PRIMARY_CODE[prn].at(i)); - index = index + 4; + index += 4; } } else if (_galileo_signal.rfind("1C") != std::string::npos && _galileo_signal.length() >= 2) @@ -61,13 +61,9 @@ void galileo_e1_code_gen_int(int* _dest, char _Signal[3], signed int _prn) for (size_t i = 0; i < Galileo_E1_C_PRIMARY_CODE[prn].length(); i++) { hex_to_binary_converter(&_dest[index], Galileo_E1_C_PRIMARY_CODE[prn].at(i)); - index = index + 4; + index += 4; } } - else - { - return; - } } @@ -107,6 +103,18 @@ void galileo_e1_sinboc_61_gen_int(int* _dest, int* _prn, unsigned int _length_ou } } +void galileo_e1_code_gen_sinboc11_float(float* _dest, char _Signal[3], unsigned int _prn) +{ + std::string _galileo_signal = _Signal; + unsigned int _codeLength = static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS); + int primary_code_E1_chips[4092]; // _codeLength not accepted by Clang + galileo_e1_code_gen_int(primary_code_E1_chips, _Signal, _prn); //generate Galileo E1 code, 1 sample per chip + for (unsigned int i = 0; i < _codeLength; i++) + { + _dest[2 * i] = static_cast(primary_code_E1_chips[i]); + _dest[2 * i + 1] = -_dest[2 * i]; + } +} void galileo_e1_gen_float(float* _dest, int* _prn, char _Signal[3]) { @@ -137,8 +145,6 @@ void galileo_e1_gen_float(float* _dest, int* _prn, char _Signal[3]) beta * static_cast(sinboc_61[i]); } } - else - return; } diff --git a/src/algorithms/libs/galileo_e1_signal_processing.h b/src/algorithms/libs/galileo_e1_signal_processing.h index 96f0fd175..5ce893638 100644 --- a/src/algorithms/libs/galileo_e1_signal_processing.h +++ b/src/algorithms/libs/galileo_e1_signal_processing.h @@ -34,6 +34,11 @@ #include +/*! + * \brief This function generates Galileo E1 code (can select E1B or E1C sinboc). + * + */ +void galileo_e1_code_gen_sinboc11_float(float* _dest, char _Signal[3], unsigned int _prn); /*! * \brief This function generates Galileo E1 code (can select E1B or E1C, cboc or sinboc diff --git a/src/algorithms/libs/glonass_l2_signal_processing.cc b/src/algorithms/libs/glonass_l2_signal_processing.cc new file mode 100644 index 000000000..87e8cc4a1 --- /dev/null +++ b/src/algorithms/libs/glonass_l2_signal_processing.cc @@ -0,0 +1,152 @@ +/*! + * \file glonass_l2_signal_processing.cc + * \brief This class implements various functions for GLONASS L2 CA signals + * \author Damian Miralles, 2018, dmiralles2009(at)gmail.com + * + * Detailed description of the file here if needed. + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "glonass_l2_signal_processing.h" + +auto auxCeil = [](float x) { return static_cast(static_cast((x) + 1)); }; + +void glonass_l2_ca_code_gen_complex(std::complex* _dest, /* signed int _prn,*/ unsigned int _chip_shift) +{ + const unsigned int _code_length = 511; + bool G1[_code_length]; + bool G1_register[9]; + bool feedback1; + bool aux; + unsigned int delay; + unsigned int lcv, lcv2; + + for (lcv = 0; lcv < 9; lcv++) + { + G1_register[lcv] = 1; + } + + /* Generate G1 Register */ + for (lcv = 0; lcv < _code_length; lcv++) + { + G1[lcv] = G1_register[2]; + + feedback1 = G1_register[4] ^ G1_register[0]; + + for (lcv2 = 0; lcv2 < 8; lcv2++) + { + G1_register[lcv2] = G1_register[lcv2 + 1]; + } + + G1_register[8] = feedback1; + } + + /* Generate PRN from G1 Register */ + for (lcv = 0; lcv < _code_length; lcv++) + { + aux = G1[lcv]; + if (aux == true) + { + _dest[lcv] = std::complex(1, 0); + } + else + { + _dest[lcv] = std::complex(-1, 0); + } + } + + /* Set the delay */ + delay = _code_length; + delay += _chip_shift; + delay %= _code_length; + + /* Generate PRN from G1 and G2 Registers */ + for (lcv = 0; lcv < _code_length; lcv++) + { + aux = G1[(lcv + _chip_shift) % _code_length]; + if (aux == true) + { + _dest[lcv] = std::complex(1, 0); + } + else + { + _dest[lcv] = std::complex(-1, 0); + } + delay++; + delay %= _code_length; + } +} + + +/* + * Generates complex GLONASS L2 C/A code for the desired SV ID and sampled to specific sampling frequency + */ +void glonass_l2_ca_code_gen_complex_sampled(std::complex* _dest, /* unsigned int _prn,*/ signed int _fs, unsigned int _chip_shift) +{ + // This function is based on the GNU software GPS for MATLAB in the Kay Borre book + std::complex _code[511]; + signed int _samplesPerCode, _codeValueIndex; + float _ts; + float _tc; + float aux; + const signed int _codeFreqBasis = 511000; //Hz + const signed int _codeLength = 511; + + //--- Find number of samples per spreading code ---------------------------- + _samplesPerCode = static_cast(static_cast(_fs) / static_cast(_codeFreqBasis / _codeLength)); + + //--- Find time constants -------------------------------------------------- + _ts = 1.0 / static_cast(_fs); // Sampling period in sec + _tc = 1.0 / static_cast(_codeFreqBasis); // C/A chip period in sec + glonass_l2_ca_code_gen_complex(_code, _chip_shift); //generate C/A code 1 sample per chip + + for (signed int i = 0; i < _samplesPerCode; i++) + { + //=== Digitizing ======================================================= + + //--- Make index array to read C/A code values ------------------------- + // The length of the index array depends on the sampling frequency - + // number of samples per millisecond (because one C/A code period is one + // millisecond). + + // _codeValueIndex = ceil((_ts * ((float)i + 1)) / _tc) - 1; + aux = (_ts * (i + 1)) / _tc; + _codeValueIndex = auxCeil(aux) - 1; + + //--- Make the digitized version of the C/A code ----------------------- + // The "upsampled" code is made by selecting values form the CA code + // chip array (caCode) for the time instances of each sample. + if (i == _samplesPerCode - 1) + { + //--- Correct the last index (due to number rounding issues) ----------- + _dest[i] = _code[_codeLength - 1]; + } + else + { + _dest[i] = _code[_codeValueIndex]; //repeat the chip -> upsample + } + } +} diff --git a/src/algorithms/libs/glonass_l2_signal_processing.h b/src/algorithms/libs/glonass_l2_signal_processing.h new file mode 100644 index 000000000..ae52e0680 --- /dev/null +++ b/src/algorithms/libs/glonass_l2_signal_processing.h @@ -0,0 +1,47 @@ +/*! + * \file glonass_l2_signal_processing.h + * \brief This class implements various functions for GLONASS L2 CA signals + * \author Damian Miralles, 2018, dmiralles2009(at)gmail.com + * + * Detailed description of the file here if needed. + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_GLONASS_L2_SIGNAL_PROCESSING_H_ +#define GNSS_SDR_GLONASS_L2_SIGNAL_PROCESSING_H_ + +#include + +//!Generates complex GLONASS L2 C/A code for the desired SV ID and code shift, and sampled to specific sampling frequency +void glonass_l2_ca_code_gen_complex(std::complex* _dest, /*signed int _prn,*/ unsigned int _chip_shift); + +//! Generates N complex GLONASS L2 C/A codes for the desired SV ID and code shift +void glonass_l2_ca_code_gen_complex_sampled(std::complex* _dest, /* unsigned int _prn,*/ signed int _fs, unsigned int _chip_shift, unsigned int _ncodes); + +//! Generates complex GLONASS L2 C/A code for the desired SV ID and code shift +void glonass_l2_ca_code_gen_complex_sampled(std::complex* _dest, /* unsigned int _prn,*/ signed int _fs, unsigned int _chip_shift); + +#endif /* GNSS_SDR_GLONASS_L2_SIGNAL_PROCESSING_H_ */ diff --git a/src/algorithms/libs/gps_l2c_signal.cc b/src/algorithms/libs/gps_l2c_signal.cc index 68fb7c024..a0d266ab7 100644 --- a/src/algorithms/libs/gps_l2c_signal.cc +++ b/src/algorithms/libs/gps_l2c_signal.cc @@ -71,6 +71,23 @@ void gps_l2c_m_code_gen_complex(std::complex* _dest, unsigned int _prn) delete[] _code; } +void gps_l2c_m_code_gen_float(float* _dest, unsigned int _prn) +{ + int32_t* _code = new int32_t[GPS_L2_M_CODE_LENGTH_CHIPS]; + + if (_prn > 0 and _prn < 51) + { + gps_l2c_m_code(_code, _prn); + } + + for (signed int i = 0; i < GPS_L2_M_CODE_LENGTH_CHIPS; i++) + { + _dest[i] = 1.0 - 2.0 * static_cast(_code[i]); + } + + delete[] _code; +} + /* * Generates complex GPS L2C M code for the desired SV ID and sampled to specific sampling frequency diff --git a/src/algorithms/libs/gps_l2c_signal.h b/src/algorithms/libs/gps_l2c_signal.h index a5f48a230..627588355 100644 --- a/src/algorithms/libs/gps_l2c_signal.h +++ b/src/algorithms/libs/gps_l2c_signal.h @@ -38,7 +38,7 @@ //!Generates complex GPS L2C M code for the desired SV ID void gps_l2c_m_code_gen_complex(std::complex* _dest, unsigned int _prn); - +void gps_l2c_m_code_gen_float(float* _dest, unsigned int _prn); //! Generates complex GPS L2C M code for the desired SV ID, and sampled to specific sampling frequency void gps_l2c_m_code_gen_complex_sampled(std::complex* _dest, unsigned int _prn, signed int _fs); diff --git a/src/algorithms/libs/gps_l5_signal.cc b/src/algorithms/libs/gps_l5_signal.cc index 7a443d20f..0bacbea7b 100644 --- a/src/algorithms/libs/gps_l5_signal.cc +++ b/src/algorithms/libs/gps_l5_signal.cc @@ -197,6 +197,22 @@ void gps_l5i_code_gen_complex(std::complex* _dest, unsigned int _prn) delete[] _code; } +void gps_l5i_code_gen_float(float* _dest, unsigned int _prn) +{ + int32_t* _code = new int32_t[GPS_L5i_CODE_LENGTH_CHIPS]; + + if (_prn > 0 and _prn < 51) + { + make_l5i(_code, _prn - 1); + } + + for (signed int i = 0; i < GPS_L5i_CODE_LENGTH_CHIPS; i++) + { + _dest[i] = 1.0 - 2.0 * static_cast(_code[i]); + } + + delete[] _code; +} /* * Generates complex GPS L5i code for the desired SV ID and sampled to specific sampling frequency @@ -264,7 +280,22 @@ void gps_l5q_code_gen_complex(std::complex* _dest, unsigned int _prn) delete[] _code; } +void gps_l5q_code_gen_float(float* _dest, unsigned int _prn) +{ + int32_t* _code = new int32_t[GPS_L5q_CODE_LENGTH_CHIPS]; + if (_prn > 0 and _prn < 51) + { + make_l5q(_code, _prn - 1); + } + + for (signed int i = 0; i < GPS_L5q_CODE_LENGTH_CHIPS; i++) + { + _dest[i] = 1.0 - 2.0 * static_cast(_code[i]); + } + + delete[] _code; +} /* * Generates complex GPS L5i code for the desired SV ID and sampled to specific sampling frequency */ diff --git a/src/algorithms/libs/gps_l5_signal.h b/src/algorithms/libs/gps_l5_signal.h index e9fee4e4b..928180e9a 100644 --- a/src/algorithms/libs/gps_l5_signal.h +++ b/src/algorithms/libs/gps_l5_signal.h @@ -38,9 +38,11 @@ //!Generates complex GPS L5i M code for the desired SV ID void gps_l5i_code_gen_complex(std::complex* _dest, unsigned int _prn); +void gps_l5i_code_gen_float(float* _dest, unsigned int _prn); //!Generates complex GPS L5q M code for the desired SV ID void gps_l5q_code_gen_complex(std::complex* _dest, unsigned int _prn); +void gps_l5q_code_gen_float(float* _dest, unsigned int _prn); //! Generates complex GPS L5i M code for the desired SV ID, and sampled to specific sampling frequency void gps_l5i_code_gen_complex_sampled(std::complex* _dest, unsigned int _prn, signed int _fs); diff --git a/src/algorithms/libs/opencl/cl.hpp b/src/algorithms/libs/opencl/cl.hpp index 0480e3116..62ba50cfc 100644 --- a/src/algorithms/libs/opencl/cl.hpp +++ b/src/algorithms/libs/opencl/cl.hpp @@ -67,7 +67,7 @@ * The following example shows a general use case for the C++ * bindings, including support for the optional exception feature and * also the supplied vector and string classes, see following sections for - * decriptions of these features. + * descriptions of these features. * * \code * #define __CL_ENABLE_EXCEPTIONS @@ -153,7 +153,7 @@ #if defined(__CL_ENABLE_EXCEPTIONS) #include -#endif // #if defined(__CL_ENABLE_EXCEPTIONS) +#endif // #if defined(__CL_ENABLE_EXCEPTIONS) #pragma push_macro("max") #undef max @@ -161,9 +161,9 @@ #include #include #endif -#endif // _WIN32 +#endif // _WIN32 -// +// #if defined(USE_CL_DEVICE_FISSION) #include #endif @@ -175,29 +175,29 @@ #else #include #include -#endif // !__APPLE__ +#endif // !__APPLE__ // To avoid accidentally taking ownership of core OpenCL types // such as cl_kernel constructors are made explicit // under OpenCL 1.2 #if defined(CL_VERSION_1_2) && !defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) #define __CL_EXPLICIT_CONSTRUCTORS explicit -#else // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) -#define __CL_EXPLICIT_CONSTRUCTORS -#endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) +#else // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) +#define __CL_EXPLICIT_CONSTRUCTORS +#endif // #if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) // Define deprecated prefixes and suffixes to ensure compilation // in case they are not pre-defined #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED) -#define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED -#endif // #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED) +#define CL_EXT_PREFIX__VERSION_1_1_DEPRECATED +#endif // #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED) #if !defined(CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED) #define CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED -#endif // #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED) +#endif // #if !defined(CL_EXT_PREFIX__VERSION_1_1_DEPRECATED) #if !defined(CL_CALLBACK) #define CL_CALLBACK -#endif //CL_CALLBACK +#endif //CL_CALLBACK #include #include @@ -208,14 +208,14 @@ #if !defined(__NO_STD_STRING) #include -#endif +#endif #if defined(linux) || defined(__APPLE__) || defined(__MACOSX) #include #include #include -#endif // linux +#endif // linux #include @@ -225,32 +225,36 @@ * \brief The OpenCL C++ bindings are defined within this namespace. * */ -namespace cl { - +namespace cl +{ class Memory; /** * Deprecated APIs for 1.2 */ -#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) || (defined(CL_VERSION_1_1) && !defined(CL_VERSION_1_2)) -#define __INIT_CL_EXT_FCN_PTR(name) \ - if(!pfn_##name) { \ - pfn_##name = (PFN_##name) \ - clGetExtensionFunctionAddress(#name); \ - if(!pfn_##name) { \ - } \ - } -#endif // #if defined(CL_VERSION_1_1) +#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) || (defined(CL_VERSION_1_1) && !defined(CL_VERSION_1_2)) +#define __INIT_CL_EXT_FCN_PTR(name) \ + if (!pfn_##name) \ + { \ + pfn_##name = (PFN_##name) \ + clGetExtensionFunctionAddress(#name); \ + if (!pfn_##name) \ + { \ + } \ + } +#endif // #if defined(CL_VERSION_1_1) #if defined(CL_VERSION_1_2) -#define __INIT_CL_EXT_FCN_PTR_PLATFORM(platform, name) \ - if(!pfn_##name) { \ - pfn_##name = (PFN_##name) \ - clGetExtensionFunctionAddressForPlatform(platform, #name); \ - if(!pfn_##name) { \ - } \ - } -#endif // #if defined(CL_VERSION_1_1) +#define __INIT_CL_EXT_FCN_PTR_PLATFORM(platform, name) \ + if (!pfn_##name) \ + { \ + pfn_##name = (PFN_##name) \ + clGetExtensionFunctionAddressForPlatform(platform, #name); \ + if (!pfn_##name) \ + { \ + } \ + } +#endif // #if defined(CL_VERSION_1_1) class Program; class Device; @@ -268,7 +272,8 @@ class Error : public std::exception { private: cl_int err_; - const char * errStr_; + const char* errStr_; + public: /*! \brief Create a new CL error exception for a given error code * and corresponding message. @@ -279,8 +284,9 @@ public: * handling of the exception has concluded. If set, it * will be returned by what(). */ - Error(cl_int err, const char * errStr = NULL) : err_(err), errStr_(errStr) - {} + Error(cl_int err, const char* errStr = NULL) : err_(err), errStr_(errStr) + { + } ~Error() throw() {} @@ -288,14 +294,16 @@ public: * * \return A memory pointer to the error message string. */ - virtual const char * what() const throw () + virtual const char* what() const throw() { - if (errStr_ == NULL) { - return "empty"; - } - else { - return errStr_; - } + if (errStr_ == NULL) + { + return "empty"; + } + else + { + return errStr_; + } } /*! \brief Get error code associated with exception @@ -308,162 +316,162 @@ public: #define __ERR_STR(x) #x #else #define __ERR_STR(x) NULL -#endif // __CL_ENABLE_EXCEPTIONS +#endif // __CL_ENABLE_EXCEPTIONS namespace detail { #if defined(__CL_ENABLE_EXCEPTIONS) -static inline cl_int errHandler ( +static inline cl_int errHandler( cl_int err, - const char * errStr = NULL) + const char* errStr = NULL) { - if (err != CL_SUCCESS) { - throw Error(err, errStr); - } + if (err != CL_SUCCESS) + { + throw Error(err, errStr); + } return err; } #else -static inline cl_int errHandler (cl_int err, const char * errStr = NULL) +static inline cl_int errHandler(cl_int err, const char* errStr = NULL) { - (void) errStr; // suppress unused variable warning + (void)errStr; // suppress unused variable warning return err; } -#endif // __CL_ENABLE_EXCEPTIONS -} - +#endif // __CL_ENABLE_EXCEPTIONS +} // namespace detail //! \cond DOXYGEN_DETAIL #if !defined(__CL_USER_OVERRIDE_ERROR_STRINGS) -#define __GET_DEVICE_INFO_ERR __ERR_STR(clGetDeviceInfo) -#define __GET_PLATFORM_INFO_ERR __ERR_STR(clGetPlatformInfo) -#define __GET_DEVICE_IDS_ERR __ERR_STR(clGetDeviceIDs) -#define __GET_PLATFORM_IDS_ERR __ERR_STR(clGetPlatformIDs) -#define __GET_CONTEXT_INFO_ERR __ERR_STR(clGetContextInfo) -#define __GET_EVENT_INFO_ERR __ERR_STR(clGetEventInfo) -#define __GET_EVENT_PROFILE_INFO_ERR __ERR_STR(clGetEventProfileInfo) -#define __GET_MEM_OBJECT_INFO_ERR __ERR_STR(clGetMemObjectInfo) -#define __GET_IMAGE_INFO_ERR __ERR_STR(clGetImageInfo) -#define __GET_SAMPLER_INFO_ERR __ERR_STR(clGetSamplerInfo) -#define __GET_KERNEL_INFO_ERR __ERR_STR(clGetKernelInfo) +#define __GET_DEVICE_INFO_ERR __ERR_STR(clGetDeviceInfo) +#define __GET_PLATFORM_INFO_ERR __ERR_STR(clGetPlatformInfo) +#define __GET_DEVICE_IDS_ERR __ERR_STR(clGetDeviceIDs) +#define __GET_PLATFORM_IDS_ERR __ERR_STR(clGetPlatformIDs) +#define __GET_CONTEXT_INFO_ERR __ERR_STR(clGetContextInfo) +#define __GET_EVENT_INFO_ERR __ERR_STR(clGetEventInfo) +#define __GET_EVENT_PROFILE_INFO_ERR __ERR_STR(clGetEventProfileInfo) +#define __GET_MEM_OBJECT_INFO_ERR __ERR_STR(clGetMemObjectInfo) +#define __GET_IMAGE_INFO_ERR __ERR_STR(clGetImageInfo) +#define __GET_SAMPLER_INFO_ERR __ERR_STR(clGetSamplerInfo) +#define __GET_KERNEL_INFO_ERR __ERR_STR(clGetKernelInfo) #if defined(CL_VERSION_1_2) -#define __GET_KERNEL_ARG_INFO_ERR __ERR_STR(clGetKernelArgInfo) -#endif // #if defined(CL_VERSION_1_2) -#define __GET_KERNEL_WORK_GROUP_INFO_ERR __ERR_STR(clGetKernelWorkGroupInfo) -#define __GET_PROGRAM_INFO_ERR __ERR_STR(clGetProgramInfo) -#define __GET_PROGRAM_BUILD_INFO_ERR __ERR_STR(clGetProgramBuildInfo) -#define __GET_COMMAND_QUEUE_INFO_ERR __ERR_STR(clGetCommandQueueInfo) +#define __GET_KERNEL_ARG_INFO_ERR __ERR_STR(clGetKernelArgInfo) +#endif // #if defined(CL_VERSION_1_2) +#define __GET_KERNEL_WORK_GROUP_INFO_ERR __ERR_STR(clGetKernelWorkGroupInfo) +#define __GET_PROGRAM_INFO_ERR __ERR_STR(clGetProgramInfo) +#define __GET_PROGRAM_BUILD_INFO_ERR __ERR_STR(clGetProgramBuildInfo) +#define __GET_COMMAND_QUEUE_INFO_ERR __ERR_STR(clGetCommandQueueInfo) -#define __CREATE_CONTEXT_ERR __ERR_STR(clCreateContext) -#define __CREATE_CONTEXT_FROM_TYPE_ERR __ERR_STR(clCreateContextFromType) -#define __GET_SUPPORTED_IMAGE_FORMATS_ERR __ERR_STR(clGetSupportedImageFormats) +#define __CREATE_CONTEXT_ERR __ERR_STR(clCreateContext) +#define __CREATE_CONTEXT_FROM_TYPE_ERR __ERR_STR(clCreateContextFromType) +#define __GET_SUPPORTED_IMAGE_FORMATS_ERR __ERR_STR(clGetSupportedImageFormats) -#define __CREATE_BUFFER_ERR __ERR_STR(clCreateBuffer) -#define __COPY_ERR __ERR_STR(cl::copy) -#define __CREATE_SUBBUFFER_ERR __ERR_STR(clCreateSubBuffer) -#define __CREATE_GL_BUFFER_ERR __ERR_STR(clCreateFromGLBuffer) -#define __CREATE_GL_RENDER_BUFFER_ERR __ERR_STR(clCreateFromGLBuffer) -#define __GET_GL_OBJECT_INFO_ERR __ERR_STR(clGetGLObjectInfo) +#define __CREATE_BUFFER_ERR __ERR_STR(clCreateBuffer) +#define __COPY_ERR __ERR_STR(cl::copy) +#define __CREATE_SUBBUFFER_ERR __ERR_STR(clCreateSubBuffer) +#define __CREATE_GL_BUFFER_ERR __ERR_STR(clCreateFromGLBuffer) +#define __CREATE_GL_RENDER_BUFFER_ERR __ERR_STR(clCreateFromGLBuffer) +#define __GET_GL_OBJECT_INFO_ERR __ERR_STR(clGetGLObjectInfo) #if defined(CL_VERSION_1_2) -#define __CREATE_IMAGE_ERR __ERR_STR(clCreateImage) -#define __CREATE_GL_TEXTURE_ERR __ERR_STR(clCreateFromGLTexture) -#define __IMAGE_DIMENSION_ERR __ERR_STR(Incorrect image dimensions) -#endif // #if defined(CL_VERSION_1_2) -#define __CREATE_SAMPLER_ERR __ERR_STR(clCreateSampler) +#define __CREATE_IMAGE_ERR __ERR_STR(clCreateImage) +#define __CREATE_GL_TEXTURE_ERR __ERR_STR(clCreateFromGLTexture) +#define __IMAGE_DIMENSION_ERR __ERR_STR(Incorrect image dimensions) +#endif // #if defined(CL_VERSION_1_2) +#define __CREATE_SAMPLER_ERR __ERR_STR(clCreateSampler) #define __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR __ERR_STR(clSetMemObjectDestructorCallback) -#define __CREATE_USER_EVENT_ERR __ERR_STR(clCreateUserEvent) -#define __SET_USER_EVENT_STATUS_ERR __ERR_STR(clSetUserEventStatus) -#define __SET_EVENT_CALLBACK_ERR __ERR_STR(clSetEventCallback) -#define __WAIT_FOR_EVENTS_ERR __ERR_STR(clWaitForEvents) +#define __CREATE_USER_EVENT_ERR __ERR_STR(clCreateUserEvent) +#define __SET_USER_EVENT_STATUS_ERR __ERR_STR(clSetUserEventStatus) +#define __SET_EVENT_CALLBACK_ERR __ERR_STR(clSetEventCallback) +#define __WAIT_FOR_EVENTS_ERR __ERR_STR(clWaitForEvents) -#define __CREATE_KERNEL_ERR __ERR_STR(clCreateKernel) -#define __SET_KERNEL_ARGS_ERR __ERR_STR(clSetKernelArg) -#define __CREATE_PROGRAM_WITH_SOURCE_ERR __ERR_STR(clCreateProgramWithSource) -#define __CREATE_PROGRAM_WITH_BINARY_ERR __ERR_STR(clCreateProgramWithBinary) +#define __CREATE_KERNEL_ERR __ERR_STR(clCreateKernel) +#define __SET_KERNEL_ARGS_ERR __ERR_STR(clSetKernelArg) +#define __CREATE_PROGRAM_WITH_SOURCE_ERR __ERR_STR(clCreateProgramWithSource) +#define __CREATE_PROGRAM_WITH_BINARY_ERR __ERR_STR(clCreateProgramWithBinary) #if defined(CL_VERSION_1_2) -#define __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR __ERR_STR(clCreateProgramWithBuiltInKernels) -#endif // #if defined(CL_VERSION_1_2) -#define __BUILD_PROGRAM_ERR __ERR_STR(clBuildProgram) +#define __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR __ERR_STR(clCreateProgramWithBuiltInKernels) +#endif // #if defined(CL_VERSION_1_2) +#define __BUILD_PROGRAM_ERR __ERR_STR(clBuildProgram) #if defined(CL_VERSION_1_2) -#define __COMPILE_PROGRAM_ERR __ERR_STR(clCompileProgram) +#define __COMPILE_PROGRAM_ERR __ERR_STR(clCompileProgram) -#endif // #if defined(CL_VERSION_1_2) -#define __CREATE_KERNELS_IN_PROGRAM_ERR __ERR_STR(clCreateKernelsInProgram) +#endif // #if defined(CL_VERSION_1_2) +#define __CREATE_KERNELS_IN_PROGRAM_ERR __ERR_STR(clCreateKernelsInProgram) -#define __CREATE_COMMAND_QUEUE_ERR __ERR_STR(clCreateCommandQueue) -#define __SET_COMMAND_QUEUE_PROPERTY_ERR __ERR_STR(clSetCommandQueueProperty) -#define __ENQUEUE_READ_BUFFER_ERR __ERR_STR(clEnqueueReadBuffer) -#define __ENQUEUE_READ_BUFFER_RECT_ERR __ERR_STR(clEnqueueReadBufferRect) -#define __ENQUEUE_WRITE_BUFFER_ERR __ERR_STR(clEnqueueWriteBuffer) -#define __ENQUEUE_WRITE_BUFFER_RECT_ERR __ERR_STR(clEnqueueWriteBufferRect) -#define __ENQEUE_COPY_BUFFER_ERR __ERR_STR(clEnqueueCopyBuffer) -#define __ENQEUE_COPY_BUFFER_RECT_ERR __ERR_STR(clEnqueueCopyBufferRect) -#define __ENQUEUE_FILL_BUFFER_ERR __ERR_STR(clEnqueueFillBuffer) -#define __ENQUEUE_READ_IMAGE_ERR __ERR_STR(clEnqueueReadImage) -#define __ENQUEUE_WRITE_IMAGE_ERR __ERR_STR(clEnqueueWriteImage) -#define __ENQUEUE_COPY_IMAGE_ERR __ERR_STR(clEnqueueCopyImage) -#define __ENQUEUE_FILL_IMAGE_ERR __ERR_STR(clEnqueueFillImage) -#define __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR __ERR_STR(clEnqueueCopyImageToBuffer) -#define __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR __ERR_STR(clEnqueueCopyBufferToImage) -#define __ENQUEUE_MAP_BUFFER_ERR __ERR_STR(clEnqueueMapBuffer) -#define __ENQUEUE_MAP_IMAGE_ERR __ERR_STR(clEnqueueMapImage) -#define __ENQUEUE_UNMAP_MEM_OBJECT_ERR __ERR_STR(clEnqueueUnMapMemObject) -#define __ENQUEUE_NDRANGE_KERNEL_ERR __ERR_STR(clEnqueueNDRangeKernel) -#define __ENQUEUE_TASK_ERR __ERR_STR(clEnqueueTask) -#define __ENQUEUE_NATIVE_KERNEL __ERR_STR(clEnqueueNativeKernel) +#define __CREATE_COMMAND_QUEUE_ERR __ERR_STR(clCreateCommandQueue) +#define __SET_COMMAND_QUEUE_PROPERTY_ERR __ERR_STR(clSetCommandQueueProperty) +#define __ENQUEUE_READ_BUFFER_ERR __ERR_STR(clEnqueueReadBuffer) +#define __ENQUEUE_READ_BUFFER_RECT_ERR __ERR_STR(clEnqueueReadBufferRect) +#define __ENQUEUE_WRITE_BUFFER_ERR __ERR_STR(clEnqueueWriteBuffer) +#define __ENQUEUE_WRITE_BUFFER_RECT_ERR __ERR_STR(clEnqueueWriteBufferRect) +#define __ENQEUE_COPY_BUFFER_ERR __ERR_STR(clEnqueueCopyBuffer) +#define __ENQEUE_COPY_BUFFER_RECT_ERR __ERR_STR(clEnqueueCopyBufferRect) +#define __ENQUEUE_FILL_BUFFER_ERR __ERR_STR(clEnqueueFillBuffer) +#define __ENQUEUE_READ_IMAGE_ERR __ERR_STR(clEnqueueReadImage) +#define __ENQUEUE_WRITE_IMAGE_ERR __ERR_STR(clEnqueueWriteImage) +#define __ENQUEUE_COPY_IMAGE_ERR __ERR_STR(clEnqueueCopyImage) +#define __ENQUEUE_FILL_IMAGE_ERR __ERR_STR(clEnqueueFillImage) +#define __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR __ERR_STR(clEnqueueCopyImageToBuffer) +#define __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR __ERR_STR(clEnqueueCopyBufferToImage) +#define __ENQUEUE_MAP_BUFFER_ERR __ERR_STR(clEnqueueMapBuffer) +#define __ENQUEUE_MAP_IMAGE_ERR __ERR_STR(clEnqueueMapImage) +#define __ENQUEUE_UNMAP_MEM_OBJECT_ERR __ERR_STR(clEnqueueUnMapMemObject) +#define __ENQUEUE_NDRANGE_KERNEL_ERR __ERR_STR(clEnqueueNDRangeKernel) +#define __ENQUEUE_TASK_ERR __ERR_STR(clEnqueueTask) +#define __ENQUEUE_NATIVE_KERNEL __ERR_STR(clEnqueueNativeKernel) #if defined(CL_VERSION_1_2) -#define __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR __ERR_STR(clEnqueueMigrateMemObjects) -#endif // #if defined(CL_VERSION_1_2) +#define __ENQUEUE_MIGRATE_MEM_OBJECTS_ERR __ERR_STR(clEnqueueMigrateMemObjects) +#endif // #if defined(CL_VERSION_1_2) -#define __ENQUEUE_ACQUIRE_GL_ERR __ERR_STR(clEnqueueAcquireGLObjects) -#define __ENQUEUE_RELEASE_GL_ERR __ERR_STR(clEnqueueReleaseGLObjects) +#define __ENQUEUE_ACQUIRE_GL_ERR __ERR_STR(clEnqueueAcquireGLObjects) +#define __ENQUEUE_RELEASE_GL_ERR __ERR_STR(clEnqueueReleaseGLObjects) -#define __RETAIN_ERR __ERR_STR(Retain Object) -#define __RELEASE_ERR __ERR_STR(Release Object) -#define __FLUSH_ERR __ERR_STR(clFlush) -#define __FINISH_ERR __ERR_STR(clFinish) -#define __VECTOR_CAPACITY_ERR __ERR_STR(Vector capacity error) +#define __RETAIN_ERR __ERR_STR(Retain Object) +#define __RELEASE_ERR __ERR_STR(Release Object) +#define __FLUSH_ERR __ERR_STR(clFlush) +#define __FINISH_ERR __ERR_STR(clFinish) +#define __VECTOR_CAPACITY_ERR __ERR_STR(Vector capacity error) /** * CL 1.2 version that uses device fission. */ #if defined(CL_VERSION_1_2) -#define __CREATE_SUB_DEVICES __ERR_STR(clCreateSubDevices) +#define __CREATE_SUB_DEVICES __ERR_STR(clCreateSubDevices) #else -#define __CREATE_SUB_DEVICES __ERR_STR(clCreateSubDevicesEXT) -#endif // #if defined(CL_VERSION_1_2) +#define __CREATE_SUB_DEVICES __ERR_STR(clCreateSubDevicesEXT) +#endif // #if defined(CL_VERSION_1_2) /** * Deprecated APIs for 1.2 */ -#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) || (defined(CL_VERSION_1_1) && !defined(CL_VERSION_1_2)) -#define __ENQUEUE_MARKER_ERR __ERR_STR(clEnqueueMarker) -#define __ENQUEUE_WAIT_FOR_EVENTS_ERR __ERR_STR(clEnqueueWaitForEvents) -#define __ENQUEUE_BARRIER_ERR __ERR_STR(clEnqueueBarrier) -#define __UNLOAD_COMPILER_ERR __ERR_STR(clUnloadCompiler) -#define __CREATE_GL_TEXTURE_2D_ERR __ERR_STR(clCreateFromGLTexture2D) -#define __CREATE_GL_TEXTURE_3D_ERR __ERR_STR(clCreateFromGLTexture3D) -#define __CREATE_IMAGE2D_ERR __ERR_STR(clCreateImage2D) -#define __CREATE_IMAGE3D_ERR __ERR_STR(clCreateImage3D) -#endif // #if defined(CL_VERSION_1_1) +#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) || (defined(CL_VERSION_1_1) && !defined(CL_VERSION_1_2)) +#define __ENQUEUE_MARKER_ERR __ERR_STR(clEnqueueMarker) +#define __ENQUEUE_WAIT_FOR_EVENTS_ERR __ERR_STR(clEnqueueWaitForEvents) +#define __ENQUEUE_BARRIER_ERR __ERR_STR(clEnqueueBarrier) +#define __UNLOAD_COMPILER_ERR __ERR_STR(clUnloadCompiler) +#define __CREATE_GL_TEXTURE_2D_ERR __ERR_STR(clCreateFromGLTexture2D) +#define __CREATE_GL_TEXTURE_3D_ERR __ERR_STR(clCreateFromGLTexture3D) +#define __CREATE_IMAGE2D_ERR __ERR_STR(clCreateImage2D) +#define __CREATE_IMAGE3D_ERR __ERR_STR(clCreateImage3D) +#endif // #if defined(CL_VERSION_1_1) -#endif // __CL_USER_OVERRIDE_ERROR_STRINGS +#endif // __CL_USER_OVERRIDE_ERROR_STRINGS //! \endcond /** * CL 1.2 marker and barrier commands */ #if defined(CL_VERSION_1_2) -#define __ENQUEUE_MARKER_WAIT_LIST_ERR __ERR_STR(clEnqueueMarkerWithWaitList) -#define __ENQUEUE_BARRIER_WAIT_LIST_ERR __ERR_STR(clEnqueueBarrierWithWaitList) -#endif // #if defined(CL_VERSION_1_2) +#define __ENQUEUE_MARKER_WAIT_LIST_ERR __ERR_STR(clEnqueueMarkerWithWaitList) +#define __ENQUEUE_BARRIER_WAIT_LIST_ERR __ERR_STR(clEnqueueBarrierWithWaitList) +#endif // #if defined(CL_VERSION_1_2) #if !defined(__USE_DEV_STRING) && !defined(__NO_STD_STRING) typedef std::string STRING_CLASS; -#elif !defined(__USE_DEV_STRING) +#elif !defined(__USE_DEV_STRING) /*! \class string * \brief Simple string class, that provides a limited subset of std::string @@ -477,7 +485,8 @@ class CL_EXT_PREFIX__VERSION_1_1_DEPRECATED string CL_EXT_SUFFIX__VERSION_1_1_DE { private: ::size_t size_; - char * str_; + char* str_; + public: //! \brief Constructs an empty string, allocating no memory. string(void) : size_(0), str_(NULL) @@ -495,20 +504,22 @@ public: * * \param size the number of characters to copy from str. */ - string(const char * str, ::size_t size) : - size_(size), - str_(NULL) + string(const char* str, ::size_t size) : size_(size), + str_(NULL) { - if( size > 0 ) { - str_ = new char[size_+1]; - if (str_ != NULL) { - memcpy(str_, str, size_ * sizeof(char)); - str_[size_] = '\0'; + if (size > 0) + { + str_ = new char[size_ + 1]; + if (str_ != NULL) + { + memcpy(str_, str, size_ * sizeof(char)); + str_[size_] = '\0'; + } + else + { + size_ = 0; + } } - else { - size_ = 0; - } - } } /*! \brief Constructs a string populated from a null-terminated value. @@ -516,60 +527,69 @@ public: * \param str the null-terminated initial value of the string instance. * If NULL, the string is left empty, with a size of 0. */ - string(const char * str) : - size_(0), - str_(NULL) + string(const char* str) : size_(0), + str_(NULL) { - if( str ) { - size_= ::strlen(str); - } - if( size_ > 0 ) { - str_ = new char[size_ + 1]; - if (str_ != NULL) { - memcpy(str_, str, (size_ + 1) * sizeof(char)); + if (str) + { + size_ = ::strlen(str); + } + if (size_ > 0) + { + str_ = new char[size_ + 1]; + if (str_ != NULL) + { + memcpy(str_, str, (size_ + 1) * sizeof(char)); + } } - } } - void resize( ::size_t n ) + void resize(::size_t n) { - if( size_ == n ) { - return; - } - if (n == 0) { - if( str_ ) { - delete [] str_; + if (size_ == n) + { + return; } - str_ = NULL; - size_ = 0; - } - else { - char *newString = new char[n + 1]; - int copySize = n; - if( size_ < n ) { - copySize = size_; + if (n == 0) + { + if (str_) + { + delete[] str_; + } + str_ = NULL; + size_ = 0; } - size_ = n; - - if(str_) { - memcpy(newString, str_, (copySize + 1) * sizeof(char)); - } - if( copySize < size_ ) { - memset(newString + copySize, 0, size_ - copySize); - } - newString[size_] = '\0'; + else + { + char* newString = new char[n + 1]; + int copySize = n; + if (size_ < n) + { + copySize = size_; + } + size_ = n; - delete [] str_; - str_ = newString; - } + if (str_) + { + memcpy(newString, str_, (copySize + 1) * sizeof(char)); + } + if (copySize < size_) + { + memset(newString + copySize, 0, size_ - copySize); + } + newString[size_] = '\0'; + + delete[] str_; + str_ = newString; + } } - const char& operator[] ( ::size_t pos ) const + const char& operator[](::size_t pos) const { return str_[pos]; } - char& operator[] ( ::size_t pos ) + char& operator[](::size_t pos) { return str_[pos]; } @@ -582,31 +602,37 @@ public: */ string& operator=(const string& rhs) { - if (this == &rhs) { - return *this; - } - - if( str_ != NULL ) { - delete [] str_; - str_ = NULL; - size_ = 0; - } - - if (rhs.size_ == 0 || rhs.str_ == NULL) { - str_ = NULL; - size_ = 0; - } - else { - str_ = new char[rhs.size_ + 1]; - size_ = rhs.size_; - - if (str_ != NULL) { - memcpy(str_, rhs.str_, (size_ + 1) * sizeof(char)); + if (this == &rhs) + { + return *this; } - else { + + if (str_ != NULL) + { + delete[] str_; + str_ = NULL; size_ = 0; } - } + + if (rhs.size_ == 0 || rhs.str_ == NULL) + { + str_ = NULL; + size_ = 0; + } + else + { + str_ = new char[rhs.size_ + 1]; + size_ = rhs.size_; + + if (str_ != NULL) + { + memcpy(str_, rhs.str_, (size_ + 1) * sizeof(char)); + } + else + { + size_ = 0; + } + } return *this; } @@ -615,9 +641,8 @@ public: * * \param rhs the string to copy. */ - string(const string& rhs) : - size_(0), - str_(NULL) + string(const string& rhs) : size_(0), + str_(NULL) { *this = rhs; } @@ -628,9 +653,9 @@ public: delete[] str_; str_ = NULL; } - + //! \brief Queries the length of the string, excluding any added '\0's. - ::size_t size(void) const { return size_; } + ::size_t size(void) const { return size_; } //! \brief Queries the length of the string, excluding any added '\0's. ::size_t length(void) const { return size(); } @@ -638,15 +663,15 @@ public: /*! \brief Returns a pointer to the private copy held by this instance, * or "" if empty/unset. */ - const char * c_str(void) const { return (str_) ? str_ : "";} + const char* c_str(void) const { return (str_) ? str_ : ""; } }; typedef cl::string STRING_CLASS; -#endif // #elif !defined(__USE_DEV_STRING) +#endif // #elif !defined(__USE_DEV_STRING) #if !defined(__USE_DEV_VECTOR) && !defined(__NO_STD_VECTOR) #define VECTOR_CLASS std::vector -#elif !defined(__USE_DEV_VECTOR) -#define VECTOR_CLASS cl::vector +#elif !defined(__USE_DEV_VECTOR) +#define VECTOR_CLASS cl::vector #if !defined(__MAX_DEFAULT_VECTOR_SIZE) #define __MAX_DEFAULT_VECTOR_SIZE 10 @@ -683,12 +708,12 @@ private: public: //! \brief Constructs an empty vector with no memory allocated. - vector() : - size_(static_cast(0)) - {} + vector() : size_(static_cast(0)) + { + } //! \brief Deallocates the vector's memory and destroys all of its elements. - ~vector() + ~vector() { clear(); } @@ -698,7 +723,7 @@ public: { return size_; } - + /*! \brief Empties the vector of all elements. * \note * This does not deallocate memory but will invoke destructors @@ -706,23 +731,27 @@ public: */ void clear() { - while(!empty()) { - pop_back(); - } + while (!empty()) + { + pop_back(); + } } /*! \brief Appends an element after the last valid element. * Calling this on a vector that has reached capacity will throw an * exception if exceptions are enabled. */ - void push_back (const T& x) - { - if (size() < N) { - new (&data_[size_]) T(x); - size_++; - } else { - detail::errHandler(CL_MEM_OBJECT_ALLOCATION_FAILURE, __VECTOR_CAPACITY_ERR); - } + void push_back(const T& x) + { + if (size() < N) + { + new (&data_[size_]) T(x); + size_++; + } + else + { + detail::errHandler(CL_MEM_OBJECT_ALLOCATION_FAILURE, __VECTOR_CAPACITY_ERR); + } } /*! \brief Removes the last valid element from the vector. @@ -731,25 +760,28 @@ public: */ void pop_back(void) { - if (size_ != 0) { - --size_; - data_[size_].~T(); - } else { - detail::errHandler(CL_MEM_OBJECT_ALLOCATION_FAILURE, __VECTOR_CAPACITY_ERR); - } + if (size_ != 0) + { + --size_; + data_[size_].~T(); + } + else + { + detail::errHandler(CL_MEM_OBJECT_ALLOCATION_FAILURE, __VECTOR_CAPACITY_ERR); + } } - + /*! \brief Constructs with a value copied from another. * * \param vec the vector to copy. */ - vector(const vector& vec) : - size_(vec.size_) + vector(const vector& vec) : size_(vec.size_) { - if (size_ != 0) { - assign(vec.begin(), vec.end()); - } - } + if (size_ != 0) + { + assign(vec.begin(), vec.end()); + } + } /*! \brief Constructs with a specified number of initial elements. * @@ -757,12 +789,12 @@ public: * * \param val value of initial elements. */ - vector(unsigned int size, const T& val = T()) : - size_(0) + vector(unsigned int size, const T& val = T()) : size_(0) { - for (unsigned int i = 0; i < size; i++) { - push_back(val); - } + for (unsigned int i = 0; i < size; i++) + { + push_back(val); + } } /*! \brief Overwrites the current content with that copied from another @@ -774,16 +806,20 @@ public: */ vector& operator=(const vector& rhs) { - if (this == &rhs) { - return *this; - } + if (this == &rhs) + { + return *this; + } + + if (rhs.size_ != 0) + { + assign(rhs.begin(), rhs.end()); + } + else + { + clear(); + } - if (rhs.size_ != 0) { - assign(rhs.begin(), rhs.end()); - } else { - clear(); - } - return *this; } @@ -791,40 +827,43 @@ public: * * \param vec the vector against which to compare. */ - bool operator==(vector &vec) + bool operator==(vector& vec) { - if (size() != vec.size()) { - return false; - } - - for( unsigned int i = 0; i < size(); ++i ) { - if( operator[](i) != vec[i] ) { + if (size() != vec.size()) + { return false; } - } + + for (unsigned int i = 0; i < size(); ++i) + { + if (operator[](i) != vec[i]) + { + return false; + } + } return true; } - + //! \brief Conversion operator to T*. - operator T* () { return data_; } + operator T*() { return data_; } //! \brief Conversion operator to const T*. - operator const T* () const { return data_; } - + operator const T*() const { return data_; } + //! \brief Tests whether this instance has any elements. - bool empty (void) const + bool empty(void) const { - return size_==0; + return size_ == 0; } - + //! \brief Returns the maximum number of elements this instance can hold. - unsigned int max_size (void) const + unsigned int max_size(void) const { return N; } //! \brief Returns the maximum number of elements this instance can hold. - unsigned int capacity () const + unsigned int capacity() const { return N; } @@ -839,7 +878,7 @@ public: { return data_[index]; } - + /*! \brief Returns a const reference to a given element. * * \param index which element to access. @@ -851,7 +890,7 @@ public: { return data_[index]; } - + /*! \brief Assigns elements of the vector based on a source iterator range. * * \param start Beginning iterator of source range @@ -860,14 +899,15 @@ public: * \note * Will throw an exception if exceptions are enabled and size exceeded. */ - template + template void assign(I start, I end) { - clear(); - while(start != end) { - push_back(*start); - start++; - } + clear(); + while (start != end) + { + push_back(*start); + start++; + } } /*! \class iterator @@ -876,7 +916,7 @@ public: class iterator { private: - const vector *vec_; + const vector* vec_; int index_; /** @@ -884,54 +924,54 @@ public: * to the vector it iterates over rather than taking * the vector by copy. */ - iterator (const vector &vec, int index) : - vec_(&vec) - { - if( !vec.empty() ) { - index_ = index; - } else { - index_ = -1; - } + iterator(const vector& vec, int index) : vec_(&vec) + { + if (!vec.empty()) + { + index_ = index; + } + else + { + index_ = -1; + } } public: - iterator(void) : - index_(-1), - vec_(NULL) + iterator(void) : index_(-1), + vec_(NULL) { } - iterator(const iterator& rhs) : - vec_(rhs.vec_), - index_(rhs.index_) + iterator(const iterator& rhs) : vec_(rhs.vec_), + index_(rhs.index_) { } ~iterator(void) {} - static iterator begin(const cl::vector &vec) + static iterator begin(const cl::vector& vec) { iterator i(vec, 0); return i; } - static iterator end(const cl::vector &vec) + static iterator end(const cl::vector& vec) { iterator i(vec, vec.size()); return i; } - + bool operator==(iterator i) { - return ((vec_ == i.vec_) && + return ((vec_ == i.vec_) && (index_ == i.index_)); } bool operator!=(iterator i) { - return (!(*this==i)); + return (!(*this == i)); } iterator& operator++() @@ -960,7 +1000,7 @@ public: return retVal; } - const T& operator *() const + const T& operator*() const { return (*vec_)[index_]; } @@ -1003,51 +1043,49 @@ public: const T& back(void) const { - return data_[size_-1]; + return data_[size_ - 1]; } -}; -#endif // #if !defined(__USE_DEV_VECTOR) && !defined(__NO_STD_VECTOR) +}; +#endif // #if !defined(__USE_DEV_VECTOR) && !defined(__NO_STD_VECTOR) - - - -namespace detail { -#define __DEFAULT_NOT_INITIALIZED 1 +namespace detail +{ +#define __DEFAULT_NOT_INITIALIZED 1 #define __DEFAULT_BEING_INITIALIZED 2 #define __DEFAULT_INITIALIZED 4 - /* +/* * Compare and exchange primitives are needed for handling of defaults */ - inline int compare_exchange(volatile int * dest, int exchange, int comparand) - { +inline int compare_exchange(volatile int* dest, int exchange, int comparand) +{ #ifdef _WIN32 - return (int)(InterlockedCompareExchange( - (volatile long*)dest, - (long)exchange, - (long)comparand)); + return (int)(InterlockedCompareExchange( + (volatile long*)dest, + (long)exchange, + (long)comparand)); #elif defined(__APPLE__) || defined(__MACOSX) - return OSAtomicOr32Orig((uint32_t)exchange, (volatile uint32_t*)dest); -#else // !_WIN32 || defined(__APPLE__) || defined(__MACOSX) - return (__sync_val_compare_and_swap( - dest, - comparand, - exchange)); -#endif // !_WIN32 - } + return OSAtomicOr32Orig((uint32_t)exchange, (volatile uint32_t*)dest); +#else // !_WIN32 || defined(__APPLE__) || defined(__MACOSX) + return (__sync_val_compare_and_swap( + dest, + comparand, + exchange)); +#endif // !_WIN32 +} + +inline void fence() { _mm_mfence(); } +}; // namespace detail - inline void fence() { _mm_mfence(); } -}; // namespace detail - /*! \brief class used to interface between C++ and * OpenCL C calls that require arrays of size_t values, whose * size is known statically. */ template class size_t -{ +{ private: ::size_t data_[N]; @@ -1055,9 +1093,10 @@ public: //! \brief Initialize size_t to all 0s size_t() { - for( int i = 0; i < N; ++i ) { - data_[i] = 0; - } + for (int i = 0; i < N; ++i) + { + data_[i] = 0; + } } ::size_t& operator[](int index) @@ -1071,19 +1110,19 @@ public: } //! \brief Conversion operator to T*. - operator ::size_t* () { return data_; } + operator ::size_t*() { return data_; } //! \brief Conversion operator to const T*. - operator const ::size_t* () const { return data_; } + operator const ::size_t*() const { return data_; } }; -namespace detail { - +namespace detail +{ // Generic getInfoHelper. The final parameter is used to guide overload // resolution: the actual parameter passed is an int, which makes this // a worse conversion sequence than a specialization that declares the // parameter as an int. -template +template inline cl_int getInfoHelper(Functor f, cl_uint name, T* param, long) { return f(name, sizeof(T), param, NULL); @@ -1095,17 +1134,19 @@ inline cl_int getInfoHelper(Func f, cl_uint name, VECTOR_CLASS* param, long) { ::size_t required; cl_int err = f(name, 0, NULL, &required); - if (err != CL_SUCCESS) { - return err; - } + if (err != CL_SUCCESS) + { + return err; + } - T* value = (T*) alloca(required); + T* value = (T*)alloca(required); err = f(name, required, value, NULL); - if (err != CL_SUCCESS) { - return err; - } + if (err != CL_SUCCESS) + { + return err; + } - param->assign(&value[0], &value[required/sizeof(T)]); + param->assign(&value[0], &value[required / sizeof(T)]); return CL_SUCCESS; } @@ -1120,40 +1161,44 @@ inline cl_int getInfoHelper(Func f, cl_uint name, VECTOR_CLASS* param, int, t { ::size_t required; cl_int err = f(name, 0, NULL, &required); - if (err != CL_SUCCESS) { - return err; - } + if (err != CL_SUCCESS) + { + return err; + } - typename T::cl_type * value = (typename T::cl_type *) alloca(required); + typename T::cl_type* value = (typename T::cl_type*)alloca(required); err = f(name, required, value, NULL); - if (err != CL_SUCCESS) { - return err; - } + if (err != CL_SUCCESS) + { + return err; + } ::size_t elements = required / sizeof(typename T::cl_type); param->assign(&value[0], &value[elements]); for (::size_t i = 0; i < elements; i++) - { - if (value[i] != NULL) { - err = (*param)[i].retain(); - if (err != CL_SUCCESS) { - return err; - } + if (value[i] != NULL) + { + err = (*param)[i].retain(); + if (err != CL_SUCCESS) + { + return err; + } + } } - } return CL_SUCCESS; } // Specialized for getInfo template -inline cl_int getInfoHelper(Func f, cl_uint name, VECTOR_CLASS* param, int) +inline cl_int getInfoHelper(Func f, cl_uint name, VECTOR_CLASS* param, int) { - cl_int err = f(name, param->size() * sizeof(char *), &(*param)[0], NULL); + cl_int err = f(name, param->size() * sizeof(char*), &(*param)[0], NULL); - if (err != CL_SUCCESS) { - return err; - } + if (err != CL_SUCCESS) + { + return err; + } return CL_SUCCESS; } @@ -1164,15 +1209,17 @@ inline cl_int getInfoHelper(Func f, cl_uint name, STRING_CLASS* param, long) { ::size_t required; cl_int err = f(name, 0, NULL, &required); - if (err != CL_SUCCESS) { - return err; - } + if (err != CL_SUCCESS) + { + return err; + } - char* value = (char*) alloca(required); + char* value = (char*)alloca(required); err = f(name, required, value, NULL); - if (err != CL_SUCCESS) { - return err; - } + if (err != CL_SUCCESS) + { + return err; + } *param = value; return CL_SUCCESS; @@ -1184,24 +1231,28 @@ inline cl_int getInfoHelper(Func f, cl_uint name, size_t* param, long) { ::size_t required; cl_int err = f(name, 0, NULL, &required); - if (err != CL_SUCCESS) { - return err; - } + if (err != CL_SUCCESS) + { + return err; + } - ::size_t* value = (::size_t*) alloca(required); + ::size_t* value = (::size_t*)alloca(required); err = f(name, required, value, NULL); - if (err != CL_SUCCESS) { - return err; - } + if (err != CL_SUCCESS) + { + return err; + } - for(int i = 0; i < N; ++i) { - (*param)[i] = value[i]; - } + for (int i = 0; i < N; ++i) + { + (*param)[i] = value[i]; + } return CL_SUCCESS; } -template struct ReferenceHandler; +template +struct ReferenceHandler; /* Specialization for reference-counted types. This depends on the * existence of Wrapper::cl_type, and none of the other types having the @@ -1209,229 +1260,236 @@ template struct ReferenceHandler; * does not work, because when using a derived type (e.g. Context) the generic * template will provide a better match. */ -template +template inline cl_int getInfoHelper(Func f, cl_uint name, T* param, int, typename T::cl_type = 0) { typename T::cl_type value; cl_int err = f(name, sizeof(value), &value, NULL); - if (err != CL_SUCCESS) { - return err; - } - *param = value; - if (value != NULL) - { - err = param->retain(); - if (err != CL_SUCCESS) { + if (err != CL_SUCCESS) + { return err; } - } + *param = value; + if (value != NULL) + { + err = param->retain(); + if (err != CL_SUCCESS) + { + return err; + } + } return CL_SUCCESS; } -#define __PARAM_NAME_INFO_1_0(F) \ - F(cl_platform_info, CL_PLATFORM_PROFILE, STRING_CLASS) \ - F(cl_platform_info, CL_PLATFORM_VERSION, STRING_CLASS) \ - F(cl_platform_info, CL_PLATFORM_NAME, STRING_CLASS) \ - F(cl_platform_info, CL_PLATFORM_VENDOR, STRING_CLASS) \ - F(cl_platform_info, CL_PLATFORM_EXTENSIONS, STRING_CLASS) \ - \ - F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \ - F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \ - F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \ - F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \ - F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, ::size_t) \ - F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, VECTOR_CLASS< ::size_t>) \ - F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, cl_uint) \ - F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, cl_uint) \ - F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, cl_uint) \ - F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, cl_uint) \ - F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, cl_uint) \ - F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, cl_uint) \ - F(cl_device_info, CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint) \ - F(cl_device_info, CL_DEVICE_ADDRESS_BITS, cl_uint) \ - F(cl_device_info, CL_DEVICE_MAX_READ_IMAGE_ARGS, cl_uint) \ - F(cl_device_info, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, cl_uint) \ - F(cl_device_info, CL_DEVICE_MAX_MEM_ALLOC_SIZE, cl_ulong) \ - F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_WIDTH, ::size_t) \ - F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_HEIGHT, ::size_t) \ - F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, ::size_t) \ - F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, ::size_t) \ - F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, ::size_t) \ - F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_bool) \ - F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, ::size_t) \ - F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \ - F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \ - F(cl_device_info, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, cl_uint) \ - F(cl_device_info, CL_DEVICE_SINGLE_FP_CONFIG, cl_device_fp_config) \ - F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, cl_device_mem_cache_type) \ - F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cl_uint)\ - F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cl_ulong) \ - F(cl_device_info, CL_DEVICE_GLOBAL_MEM_SIZE, cl_ulong) \ - F(cl_device_info, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, cl_ulong) \ - F(cl_device_info, CL_DEVICE_MAX_CONSTANT_ARGS, cl_uint) \ - F(cl_device_info, CL_DEVICE_LOCAL_MEM_TYPE, cl_device_local_mem_type) \ - F(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE, cl_ulong) \ - F(cl_device_info, CL_DEVICE_ERROR_CORRECTION_SUPPORT, cl_bool) \ - F(cl_device_info, CL_DEVICE_PROFILING_TIMER_RESOLUTION, ::size_t) \ - F(cl_device_info, CL_DEVICE_ENDIAN_LITTLE, cl_bool) \ - F(cl_device_info, CL_DEVICE_AVAILABLE, cl_bool) \ - F(cl_device_info, CL_DEVICE_COMPILER_AVAILABLE, cl_bool) \ +#define __PARAM_NAME_INFO_1_0(F) \ + F(cl_platform_info, CL_PLATFORM_PROFILE, STRING_CLASS) \ + F(cl_platform_info, CL_PLATFORM_VERSION, STRING_CLASS) \ + F(cl_platform_info, CL_PLATFORM_NAME, STRING_CLASS) \ + F(cl_platform_info, CL_PLATFORM_VENDOR, STRING_CLASS) \ + F(cl_platform_info, CL_PLATFORM_EXTENSIONS, STRING_CLASS) \ + \ + F(cl_device_info, CL_DEVICE_TYPE, cl_device_type) \ + F(cl_device_info, CL_DEVICE_VENDOR_ID, cl_uint) \ + F(cl_device_info, CL_DEVICE_MAX_COMPUTE_UNITS, cl_uint) \ + F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS, cl_uint) \ + F(cl_device_info, CL_DEVICE_MAX_WORK_GROUP_SIZE, ::size_t) \ + F(cl_device_info, CL_DEVICE_MAX_WORK_ITEM_SIZES, VECTOR_CLASS< ::size_t>) \ + F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_CHAR, cl_uint) \ + F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_SHORT, cl_uint) \ + F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_INT, cl_uint) \ + F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_LONG, cl_uint) \ + F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_FLOAT, cl_uint) \ + F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_DOUBLE, cl_uint) \ + F(cl_device_info, CL_DEVICE_MAX_CLOCK_FREQUENCY, cl_uint) \ + F(cl_device_info, CL_DEVICE_ADDRESS_BITS, cl_uint) \ + F(cl_device_info, CL_DEVICE_MAX_READ_IMAGE_ARGS, cl_uint) \ + F(cl_device_info, CL_DEVICE_MAX_WRITE_IMAGE_ARGS, cl_uint) \ + F(cl_device_info, CL_DEVICE_MAX_MEM_ALLOC_SIZE, cl_ulong) \ + F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_WIDTH, ::size_t) \ + F(cl_device_info, CL_DEVICE_IMAGE2D_MAX_HEIGHT, ::size_t) \ + F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_WIDTH, ::size_t) \ + F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_HEIGHT, ::size_t) \ + F(cl_device_info, CL_DEVICE_IMAGE3D_MAX_DEPTH, ::size_t) \ + F(cl_device_info, CL_DEVICE_IMAGE_SUPPORT, cl_bool) \ + F(cl_device_info, CL_DEVICE_MAX_PARAMETER_SIZE, ::size_t) \ + F(cl_device_info, CL_DEVICE_MAX_SAMPLERS, cl_uint) \ + F(cl_device_info, CL_DEVICE_MEM_BASE_ADDR_ALIGN, cl_uint) \ + F(cl_device_info, CL_DEVICE_MIN_DATA_TYPE_ALIGN_SIZE, cl_uint) \ + F(cl_device_info, CL_DEVICE_SINGLE_FP_CONFIG, cl_device_fp_config) \ + F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE, cl_device_mem_cache_type) \ + F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE, cl_uint) \ + F(cl_device_info, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE, cl_ulong) \ + F(cl_device_info, CL_DEVICE_GLOBAL_MEM_SIZE, cl_ulong) \ + F(cl_device_info, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE, cl_ulong) \ + F(cl_device_info, CL_DEVICE_MAX_CONSTANT_ARGS, cl_uint) \ + F(cl_device_info, CL_DEVICE_LOCAL_MEM_TYPE, cl_device_local_mem_type) \ + F(cl_device_info, CL_DEVICE_LOCAL_MEM_SIZE, cl_ulong) \ + F(cl_device_info, CL_DEVICE_ERROR_CORRECTION_SUPPORT, cl_bool) \ + F(cl_device_info, CL_DEVICE_PROFILING_TIMER_RESOLUTION, ::size_t) \ + F(cl_device_info, CL_DEVICE_ENDIAN_LITTLE, cl_bool) \ + F(cl_device_info, CL_DEVICE_AVAILABLE, cl_bool) \ + F(cl_device_info, CL_DEVICE_COMPILER_AVAILABLE, cl_bool) \ F(cl_device_info, CL_DEVICE_EXECUTION_CAPABILITIES, cl_device_exec_capabilities) \ - F(cl_device_info, CL_DEVICE_QUEUE_PROPERTIES, cl_command_queue_properties) \ - F(cl_device_info, CL_DEVICE_PLATFORM, cl_platform_id) \ - F(cl_device_info, CL_DEVICE_NAME, STRING_CLASS) \ - F(cl_device_info, CL_DEVICE_VENDOR, STRING_CLASS) \ - F(cl_device_info, CL_DRIVER_VERSION, STRING_CLASS) \ - F(cl_device_info, CL_DEVICE_PROFILE, STRING_CLASS) \ - F(cl_device_info, CL_DEVICE_VERSION, STRING_CLASS) \ - F(cl_device_info, CL_DEVICE_EXTENSIONS, STRING_CLASS) \ - \ - F(cl_context_info, CL_CONTEXT_REFERENCE_COUNT, cl_uint) \ - F(cl_context_info, CL_CONTEXT_DEVICES, VECTOR_CLASS) \ - F(cl_context_info, CL_CONTEXT_PROPERTIES, VECTOR_CLASS) \ - \ - F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \ - F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \ - F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \ - F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_uint) \ - \ - F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \ - F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \ - F(cl_profiling_info, CL_PROFILING_COMMAND_START, cl_ulong) \ - F(cl_profiling_info, CL_PROFILING_COMMAND_END, cl_ulong) \ - \ - F(cl_mem_info, CL_MEM_TYPE, cl_mem_object_type) \ - F(cl_mem_info, CL_MEM_FLAGS, cl_mem_flags) \ - F(cl_mem_info, CL_MEM_SIZE, ::size_t) \ - F(cl_mem_info, CL_MEM_HOST_PTR, void*) \ - F(cl_mem_info, CL_MEM_MAP_COUNT, cl_uint) \ - F(cl_mem_info, CL_MEM_REFERENCE_COUNT, cl_uint) \ - F(cl_mem_info, CL_MEM_CONTEXT, cl::Context) \ - \ - F(cl_image_info, CL_IMAGE_FORMAT, cl_image_format) \ - F(cl_image_info, CL_IMAGE_ELEMENT_SIZE, ::size_t) \ - F(cl_image_info, CL_IMAGE_ROW_PITCH, ::size_t) \ - F(cl_image_info, CL_IMAGE_SLICE_PITCH, ::size_t) \ - F(cl_image_info, CL_IMAGE_WIDTH, ::size_t) \ - F(cl_image_info, CL_IMAGE_HEIGHT, ::size_t) \ - F(cl_image_info, CL_IMAGE_DEPTH, ::size_t) \ - \ - F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \ - F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \ - F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_addressing_mode) \ - F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_filter_mode) \ - F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_bool) \ - \ - F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \ - F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \ - F(cl_program_info, CL_PROGRAM_NUM_DEVICES, cl_uint) \ - F(cl_program_info, CL_PROGRAM_DEVICES, VECTOR_CLASS) \ - F(cl_program_info, CL_PROGRAM_SOURCE, STRING_CLASS) \ - F(cl_program_info, CL_PROGRAM_BINARY_SIZES, VECTOR_CLASS< ::size_t>) \ - F(cl_program_info, CL_PROGRAM_BINARIES, VECTOR_CLASS) \ - \ - F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \ - F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, STRING_CLASS) \ - F(cl_program_build_info, CL_PROGRAM_BUILD_LOG, STRING_CLASS) \ - \ - F(cl_kernel_info, CL_KERNEL_FUNCTION_NAME, STRING_CLASS) \ - F(cl_kernel_info, CL_KERNEL_NUM_ARGS, cl_uint) \ - F(cl_kernel_info, CL_KERNEL_REFERENCE_COUNT, cl_uint) \ - F(cl_kernel_info, CL_KERNEL_CONTEXT, cl::Context) \ - F(cl_kernel_info, CL_KERNEL_PROGRAM, cl::Program) \ - \ - F(cl_kernel_work_group_info, CL_KERNEL_WORK_GROUP_SIZE, ::size_t) \ - F(cl_kernel_work_group_info, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, cl::size_t<3>) \ - F(cl_kernel_work_group_info, CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong) \ - \ - F(cl_command_queue_info, CL_QUEUE_CONTEXT, cl::Context) \ - F(cl_command_queue_info, CL_QUEUE_DEVICE, cl::Device) \ - F(cl_command_queue_info, CL_QUEUE_REFERENCE_COUNT, cl_uint) \ + F(cl_device_info, CL_DEVICE_QUEUE_PROPERTIES, cl_command_queue_properties) \ + F(cl_device_info, CL_DEVICE_PLATFORM, cl_platform_id) \ + F(cl_device_info, CL_DEVICE_NAME, STRING_CLASS) \ + F(cl_device_info, CL_DEVICE_VENDOR, STRING_CLASS) \ + F(cl_device_info, CL_DRIVER_VERSION, STRING_CLASS) \ + F(cl_device_info, CL_DEVICE_PROFILE, STRING_CLASS) \ + F(cl_device_info, CL_DEVICE_VERSION, STRING_CLASS) \ + F(cl_device_info, CL_DEVICE_EXTENSIONS, STRING_CLASS) \ + \ + F(cl_context_info, CL_CONTEXT_REFERENCE_COUNT, cl_uint) \ + F(cl_context_info, CL_CONTEXT_DEVICES, VECTOR_CLASS) \ + F(cl_context_info, CL_CONTEXT_PROPERTIES, VECTOR_CLASS) \ + \ + F(cl_event_info, CL_EVENT_COMMAND_QUEUE, cl::CommandQueue) \ + F(cl_event_info, CL_EVENT_COMMAND_TYPE, cl_command_type) \ + F(cl_event_info, CL_EVENT_REFERENCE_COUNT, cl_uint) \ + F(cl_event_info, CL_EVENT_COMMAND_EXECUTION_STATUS, cl_uint) \ + \ + F(cl_profiling_info, CL_PROFILING_COMMAND_QUEUED, cl_ulong) \ + F(cl_profiling_info, CL_PROFILING_COMMAND_SUBMIT, cl_ulong) \ + F(cl_profiling_info, CL_PROFILING_COMMAND_START, cl_ulong) \ + F(cl_profiling_info, CL_PROFILING_COMMAND_END, cl_ulong) \ + \ + F(cl_mem_info, CL_MEM_TYPE, cl_mem_object_type) \ + F(cl_mem_info, CL_MEM_FLAGS, cl_mem_flags) \ + F(cl_mem_info, CL_MEM_SIZE, ::size_t) \ + F(cl_mem_info, CL_MEM_HOST_PTR, void*) \ + F(cl_mem_info, CL_MEM_MAP_COUNT, cl_uint) \ + F(cl_mem_info, CL_MEM_REFERENCE_COUNT, cl_uint) \ + F(cl_mem_info, CL_MEM_CONTEXT, cl::Context) \ + \ + F(cl_image_info, CL_IMAGE_FORMAT, cl_image_format) \ + F(cl_image_info, CL_IMAGE_ELEMENT_SIZE, ::size_t) \ + F(cl_image_info, CL_IMAGE_ROW_PITCH, ::size_t) \ + F(cl_image_info, CL_IMAGE_SLICE_PITCH, ::size_t) \ + F(cl_image_info, CL_IMAGE_WIDTH, ::size_t) \ + F(cl_image_info, CL_IMAGE_HEIGHT, ::size_t) \ + F(cl_image_info, CL_IMAGE_DEPTH, ::size_t) \ + \ + F(cl_sampler_info, CL_SAMPLER_REFERENCE_COUNT, cl_uint) \ + F(cl_sampler_info, CL_SAMPLER_CONTEXT, cl::Context) \ + F(cl_sampler_info, CL_SAMPLER_NORMALIZED_COORDS, cl_addressing_mode) \ + F(cl_sampler_info, CL_SAMPLER_ADDRESSING_MODE, cl_filter_mode) \ + F(cl_sampler_info, CL_SAMPLER_FILTER_MODE, cl_bool) \ + \ + F(cl_program_info, CL_PROGRAM_REFERENCE_COUNT, cl_uint) \ + F(cl_program_info, CL_PROGRAM_CONTEXT, cl::Context) \ + F(cl_program_info, CL_PROGRAM_NUM_DEVICES, cl_uint) \ + F(cl_program_info, CL_PROGRAM_DEVICES, VECTOR_CLASS) \ + F(cl_program_info, CL_PROGRAM_SOURCE, STRING_CLASS) \ + F(cl_program_info, CL_PROGRAM_BINARY_SIZES, VECTOR_CLASS< ::size_t>) \ + F(cl_program_info, CL_PROGRAM_BINARIES, VECTOR_CLASS) \ + \ + F(cl_program_build_info, CL_PROGRAM_BUILD_STATUS, cl_build_status) \ + F(cl_program_build_info, CL_PROGRAM_BUILD_OPTIONS, STRING_CLASS) \ + F(cl_program_build_info, CL_PROGRAM_BUILD_LOG, STRING_CLASS) \ + \ + F(cl_kernel_info, CL_KERNEL_FUNCTION_NAME, STRING_CLASS) \ + F(cl_kernel_info, CL_KERNEL_NUM_ARGS, cl_uint) \ + F(cl_kernel_info, CL_KERNEL_REFERENCE_COUNT, cl_uint) \ + F(cl_kernel_info, CL_KERNEL_CONTEXT, cl::Context) \ + F(cl_kernel_info, CL_KERNEL_PROGRAM, cl::Program) \ + \ + F(cl_kernel_work_group_info, CL_KERNEL_WORK_GROUP_SIZE, ::size_t) \ + F(cl_kernel_work_group_info, CL_KERNEL_COMPILE_WORK_GROUP_SIZE, cl::size_t<3>) \ + F(cl_kernel_work_group_info, CL_KERNEL_LOCAL_MEM_SIZE, cl_ulong) \ + \ + F(cl_command_queue_info, CL_QUEUE_CONTEXT, cl::Context) \ + F(cl_command_queue_info, CL_QUEUE_DEVICE, cl::Device) \ + F(cl_command_queue_info, CL_QUEUE_REFERENCE_COUNT, cl_uint) \ F(cl_command_queue_info, CL_QUEUE_PROPERTIES, cl_command_queue_properties) #if defined(CL_VERSION_1_1) -#define __PARAM_NAME_INFO_1_1(F) \ - F(cl_context_info, CL_CONTEXT_NUM_DEVICES, cl_uint)\ - F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, cl_uint) \ - F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, cl_uint) \ - F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, cl_uint) \ - F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, cl_uint) \ - F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, cl_uint) \ - F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, cl_uint) \ - F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, cl_uint) \ - F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, cl_uint) \ - F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \ - F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \ - F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool) \ - F(cl_device_info, CL_DEVICE_OPENCL_C_VERSION, STRING_CLASS) \ - \ - F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \ - F(cl_mem_info, CL_MEM_OFFSET, ::size_t) \ - \ +#define __PARAM_NAME_INFO_1_1(F) \ + F(cl_context_info, CL_CONTEXT_NUM_DEVICES, cl_uint) \ + F(cl_device_info, CL_DEVICE_PREFERRED_VECTOR_WIDTH_HALF, cl_uint) \ + F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_CHAR, cl_uint) \ + F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_SHORT, cl_uint) \ + F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_INT, cl_uint) \ + F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_LONG, cl_uint) \ + F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_FLOAT, cl_uint) \ + F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_DOUBLE, cl_uint) \ + F(cl_device_info, CL_DEVICE_NATIVE_VECTOR_WIDTH_HALF, cl_uint) \ + F(cl_device_info, CL_DEVICE_DOUBLE_FP_CONFIG, cl_device_fp_config) \ + F(cl_device_info, CL_DEVICE_HALF_FP_CONFIG, cl_device_fp_config) \ + F(cl_device_info, CL_DEVICE_HOST_UNIFIED_MEMORY, cl_bool) \ + F(cl_device_info, CL_DEVICE_OPENCL_C_VERSION, STRING_CLASS) \ + \ + F(cl_mem_info, CL_MEM_ASSOCIATED_MEMOBJECT, cl::Memory) \ + F(cl_mem_info, CL_MEM_OFFSET, ::size_t) \ + \ F(cl_kernel_work_group_info, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE, ::size_t) \ - F(cl_kernel_work_group_info, CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong) \ - \ + F(cl_kernel_work_group_info, CL_KERNEL_PRIVATE_MEM_SIZE, cl_ulong) \ + \ F(cl_event_info, CL_EVENT_CONTEXT, cl::Context) -#endif // CL_VERSION_1_1 +#endif // CL_VERSION_1_1 + - #if defined(CL_VERSION_1_2) -#define __PARAM_NAME_INFO_1_2(F) \ - F(cl_image_info, CL_IMAGE_BUFFER, cl::Buffer) \ - \ - F(cl_program_info, CL_PROGRAM_NUM_KERNELS, ::size_t) \ - F(cl_program_info, CL_PROGRAM_KERNEL_NAMES, STRING_CLASS) \ - \ - F(cl_program_build_info, CL_PROGRAM_BINARY_TYPE, cl_program_binary_type) \ - \ - F(cl_kernel_info, CL_KERNEL_ATTRIBUTES, STRING_CLASS) \ - \ - F(cl_kernel_arg_info, CL_KERNEL_ARG_ADDRESS_QUALIFIER, cl_kernel_arg_address_qualifier) \ - F(cl_kernel_arg_info, CL_KERNEL_ARG_ACCESS_QUALIFIER, cl_kernel_arg_access_qualifier) \ - F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_NAME, STRING_CLASS) \ - F(cl_kernel_arg_info, CL_KERNEL_ARG_NAME, STRING_CLASS) \ - \ - F(cl_device_info, CL_DEVICE_PARENT_DEVICE, cl_device_id) \ +#define __PARAM_NAME_INFO_1_2(F) \ + F(cl_image_info, CL_IMAGE_BUFFER, cl::Buffer) \ + \ + F(cl_program_info, CL_PROGRAM_NUM_KERNELS, ::size_t) \ + F(cl_program_info, CL_PROGRAM_KERNEL_NAMES, STRING_CLASS) \ + \ + F(cl_program_build_info, CL_PROGRAM_BINARY_TYPE, cl_program_binary_type) \ + \ + F(cl_kernel_info, CL_KERNEL_ATTRIBUTES, STRING_CLASS) \ + \ + F(cl_kernel_arg_info, CL_KERNEL_ARG_ADDRESS_QUALIFIER, cl_kernel_arg_address_qualifier) \ + F(cl_kernel_arg_info, CL_KERNEL_ARG_ACCESS_QUALIFIER, cl_kernel_arg_access_qualifier) \ + F(cl_kernel_arg_info, CL_KERNEL_ARG_TYPE_NAME, STRING_CLASS) \ + F(cl_kernel_arg_info, CL_KERNEL_ARG_NAME, STRING_CLASS) \ + \ + F(cl_device_info, CL_DEVICE_PARENT_DEVICE, cl_device_id) \ F(cl_device_info, CL_DEVICE_PARTITION_PROPERTIES, VECTOR_CLASS) \ - F(cl_device_info, CL_DEVICE_PARTITION_TYPE, VECTOR_CLASS) \ - F(cl_device_info, CL_DEVICE_REFERENCE_COUNT, cl_uint) \ - F(cl_device_info, CL_DEVICE_PREFERRED_INTEROP_USER_SYNC, ::size_t) \ - F(cl_device_info, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, cl_device_affinity_domain) \ + F(cl_device_info, CL_DEVICE_PARTITION_TYPE, VECTOR_CLASS) \ + F(cl_device_info, CL_DEVICE_REFERENCE_COUNT, cl_uint) \ + F(cl_device_info, CL_DEVICE_PREFERRED_INTEROP_USER_SYNC, ::size_t) \ + F(cl_device_info, CL_DEVICE_PARTITION_AFFINITY_DOMAIN, cl_device_affinity_domain) \ F(cl_device_info, CL_DEVICE_BUILT_IN_KERNELS, STRING_CLASS) -#endif // #if defined(CL_VERSION_1_2) +#endif // #if defined(CL_VERSION_1_2) #if defined(USE_CL_DEVICE_FISSION) -#define __PARAM_NAME_DEVICE_FISSION(F) \ - F(cl_device_info, CL_DEVICE_PARENT_DEVICE_EXT, cl_device_id) \ - F(cl_device_info, CL_DEVICE_PARTITION_TYPES_EXT, VECTOR_CLASS) \ +#define __PARAM_NAME_DEVICE_FISSION(F) \ + F(cl_device_info, CL_DEVICE_PARENT_DEVICE_EXT, cl_device_id) \ + F(cl_device_info, CL_DEVICE_PARTITION_TYPES_EXT, VECTOR_CLASS) \ F(cl_device_info, CL_DEVICE_AFFINITY_DOMAINS_EXT, VECTOR_CLASS) \ - F(cl_device_info, CL_DEVICE_REFERENCE_COUNT_EXT , cl_uint) \ + F(cl_device_info, CL_DEVICE_REFERENCE_COUNT_EXT, cl_uint) \ F(cl_device_info, CL_DEVICE_PARTITION_STYLE_EXT, VECTOR_CLASS) -#endif // USE_CL_DEVICE_FISSION +#endif // USE_CL_DEVICE_FISSION template -struct param_traits {}; +struct param_traits +{ +}; #define __CL_DECLARE_PARAM_TRAITS(token, param_name, T) \ -struct token; \ -template<> \ -struct param_traits \ -{ \ - enum { value = param_name }; \ - typedef T param_type; \ -}; + struct token; \ + template <> \ + struct param_traits \ + { \ + enum \ + { \ + value = param_name \ + }; \ + typedef T param_type; \ + }; __PARAM_NAME_INFO_1_0(__CL_DECLARE_PARAM_TRAITS) #if defined(CL_VERSION_1_1) __PARAM_NAME_INFO_1_1(__CL_DECLARE_PARAM_TRAITS) -#endif // CL_VERSION_1_1 +#endif // CL_VERSION_1_1 #if defined(CL_VERSION_1_2) __PARAM_NAME_INFO_1_2(__CL_DECLARE_PARAM_TRAITS) -#endif // CL_VERSION_1_1 +#endif // CL_VERSION_1_1 #if defined(USE_CL_DEVICE_FISSION) __PARAM_NAME_DEVICE_FISSION(__CL_DECLARE_PARAM_TRAITS); -#endif // USE_CL_DEVICE_FISSION +#endif // USE_CL_DEVICE_FISSION #ifdef CL_PLATFORM_ICD_SUFFIX_KHR __CL_DECLARE_PARAM_TRAITS(cl_platform_info, CL_PLATFORM_ICD_SUFFIX_KHR, STRING_CLASS) @@ -1506,26 +1564,33 @@ getInfo(Func f, cl_uint name, T* param) template struct GetInfoFunctor0 { - Func f_; const Arg0& arg0_; - cl_int operator ()( + Func f_; + const Arg0& arg0_; + cl_int operator()( cl_uint param, ::size_t size, void* value, ::size_t* size_ret) - { return f_(arg0_, param, size, value, size_ret); } + { + return f_(arg0_, param, size, value, size_ret); + } }; template struct GetInfoFunctor1 { - Func f_; const Arg0& arg0_; const Arg1& arg1_; - cl_int operator ()( + Func f_; + const Arg0& arg0_; + const Arg1& arg1_; + cl_int operator()( cl_uint param, ::size_t size, void* value, ::size_t* size_ret) - { return f_(arg0_, arg1_, param, size, value, size_ret); } + { + return f_(arg0_, arg1_, param, size, value, size_ret); + } }; template inline cl_int getInfo(Func f, const Arg0& arg0, cl_uint name, T* param) { - GetInfoFunctor0 f0 = { f, arg0 }; + GetInfoFunctor0 f0 = {f, arg0}; return getInfoHelper(f0, name, param, 0); } @@ -1533,13 +1598,14 @@ template inline cl_int getInfo(Func f, const Arg0& arg0, const Arg1& arg1, cl_uint name, T* param) { - GetInfoFunctor1 f0 = { f, arg0, arg1 }; + GetInfoFunctor1 f0 = {f, arg0, arg1}; return getInfoHelper(f0, name, param, 0); } -template +template struct ReferenceHandler -{ }; +{ +}; #if defined(CL_VERSION_1_2) /** @@ -1558,7 +1624,9 @@ struct ReferenceHandler * CL_OUT_OF_HOST_MEMORY */ static cl_int retain(cl_device_id device) - { return ::clRetainDevice(device); } + { + return ::clRetainDevice(device); + } /** * Retain the device. * \param device A valid device created using createSubDevices @@ -1569,9 +1637,11 @@ struct ReferenceHandler * CL_OUT_OF_HOST_MEMORY */ static cl_int release(cl_device_id device) - { return ::clReleaseDevice(device); } + { + return ::clReleaseDevice(device); + } }; -#else // #if defined(CL_VERSION_1_2) +#else // #if defined(CL_VERSION_1_2) /** * OpenCL 1.1 devices do not have retain/release. */ @@ -1580,105 +1650,143 @@ struct ReferenceHandler { // cl_device_id does not have retain(). static cl_int retain(cl_device_id) - { return CL_SUCCESS; } + { + return CL_SUCCESS; + } // cl_device_id does not have release(). static cl_int release(cl_device_id) - { return CL_SUCCESS; } + { + return CL_SUCCESS; + } }; -#endif // #if defined(CL_VERSION_1_2) +#endif // #if defined(CL_VERSION_1_2) template <> struct ReferenceHandler { // cl_platform_id does not have retain(). static cl_int retain(cl_platform_id) - { return CL_SUCCESS; } + { + return CL_SUCCESS; + } // cl_platform_id does not have release(). static cl_int release(cl_platform_id) - { return CL_SUCCESS; } + { + return CL_SUCCESS; + } }; template <> struct ReferenceHandler { static cl_int retain(cl_context context) - { return ::clRetainContext(context); } + { + return ::clRetainContext(context); + } static cl_int release(cl_context context) - { return ::clReleaseContext(context); } + { + return ::clReleaseContext(context); + } }; template <> struct ReferenceHandler { static cl_int retain(cl_command_queue queue) - { return ::clRetainCommandQueue(queue); } + { + return ::clRetainCommandQueue(queue); + } static cl_int release(cl_command_queue queue) - { return ::clReleaseCommandQueue(queue); } + { + return ::clReleaseCommandQueue(queue); + } }; template <> struct ReferenceHandler { static cl_int retain(cl_mem memory) - { return ::clRetainMemObject(memory); } + { + return ::clRetainMemObject(memory); + } static cl_int release(cl_mem memory) - { return ::clReleaseMemObject(memory); } + { + return ::clReleaseMemObject(memory); + } }; template <> struct ReferenceHandler { static cl_int retain(cl_sampler sampler) - { return ::clRetainSampler(sampler); } + { + return ::clRetainSampler(sampler); + } static cl_int release(cl_sampler sampler) - { return ::clReleaseSampler(sampler); } + { + return ::clReleaseSampler(sampler); + } }; template <> struct ReferenceHandler { static cl_int retain(cl_program program) - { return ::clRetainProgram(program); } + { + return ::clRetainProgram(program); + } static cl_int release(cl_program program) - { return ::clReleaseProgram(program); } + { + return ::clReleaseProgram(program); + } }; template <> struct ReferenceHandler { static cl_int retain(cl_kernel kernel) - { return ::clRetainKernel(kernel); } + { + return ::clRetainKernel(kernel); + } static cl_int release(cl_kernel kernel) - { return ::clReleaseKernel(kernel); } + { + return ::clReleaseKernel(kernel); + } }; template <> struct ReferenceHandler { static cl_int retain(cl_event event) - { return ::clRetainEvent(event); } + { + return ::clRetainEvent(event); + } static cl_int release(cl_event event) - { return ::clReleaseEvent(event); } + { + return ::clReleaseEvent(event); + } }; // Extracts version number with major in the upper 16 bits, minor in the lower 16 -static cl_uint getVersion(const char *versionInfo) +static cl_uint getVersion(const char* versionInfo) { int highVersion = 0; int lowVersion = 0; int index = 7; - while(versionInfo[index] != '.' ) { - highVersion *= 10; - highVersion += versionInfo[index]-'0'; - ++index; - } + while (versionInfo[index] != '.') + { + highVersion *= 10; + highVersion += versionInfo[index] - '0'; + ++index; + } ++index; - while(versionInfo[index] != ' ' ) { - lowVersion *= 10; - lowVersion += versionInfo[index]-'0'; - ++index; - } + while (versionInfo[index] != ' ') + { + lowVersion *= 10; + lowVersion += versionInfo[index] - '0'; + ++index; + } return (highVersion << 16) | lowVersion; } @@ -1686,7 +1794,7 @@ static cl_uint getPlatformVersion(cl_platform_id platform) { ::size_t size = 0; clGetPlatformInfo(platform, CL_PLATFORM_VERSION, 0, NULL, &size); - char *versionInfo = (char *) alloca(size); + char* versionInfo = (char*)alloca(size); clGetPlatformInfo(platform, CL_PLATFORM_VERSION, size, &versionInfo[0], &size); return getVersion(versionInfo); } @@ -1707,11 +1815,11 @@ static cl_uint getContextPlatformVersion(cl_context context) clGetContextInfo(context, CL_CONTEXT_DEVICES, 0, NULL, &size); if (size == 0) return 0; - cl_device_id *devices = (cl_device_id *) alloca(size); + cl_device_id* devices = (cl_device_id*)alloca(size); clGetContextInfo(context, CL_CONTEXT_DEVICES, size, devices, NULL); return getDevicePlatformVersion(devices[0]); } -#endif // #if defined(CL_VERSION_1_2) && defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) +#endif // #if defined(CL_VERSION_1_2) && defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) template class Wrapper @@ -1723,42 +1831,57 @@ protected: cl_type object_; public: - Wrapper() : object_(NULL) { } + Wrapper() : object_(NULL) {} - Wrapper(const cl_type &obj) : object_(obj) { } + Wrapper(const cl_type& obj) : object_(obj) {} ~Wrapper() { - if (object_ != NULL) { release(); } + if (object_ != NULL) + { + release(); + } } Wrapper(const Wrapper& rhs) { object_ = rhs.object_; - if (object_ != NULL) { detail::errHandler(retain(), __RETAIN_ERR); } + if (object_ != NULL) + { + detail::errHandler(retain(), __RETAIN_ERR); + } } - Wrapper& operator = (const Wrapper& rhs) + Wrapper& operator=(const Wrapper& rhs) { - if (object_ != NULL) { detail::errHandler(release(), __RELEASE_ERR); } + if (object_ != NULL) + { + detail::errHandler(release(), __RELEASE_ERR); + } object_ = rhs.object_; - if (object_ != NULL) { detail::errHandler(retain(), __RETAIN_ERR); } + if (object_ != NULL) + { + detail::errHandler(retain(), __RETAIN_ERR); + } return *this; } - Wrapper& operator = (const cl_type &rhs) + Wrapper& operator=(const cl_type& rhs) { - if (object_ != NULL) { detail::errHandler(release(), __RELEASE_ERR); } + if (object_ != NULL) + { + detail::errHandler(release(), __RELEASE_ERR); + } object_ = rhs; return *this; } - cl_type operator ()() const { return object_; } + cl_type operator()() const { return object_; } - cl_type& operator ()() { return object_; } + cl_type& operator()() { return object_; } protected: - template + template friend inline cl_int getInfoHelper(Func, cl_uint, U*, int, typename U::cl_type); cl_int retain() const @@ -1785,90 +1908,111 @@ protected: static bool isReferenceCountable(cl_device_id device) { bool retVal = false; - if (device != NULL) { - int version = getDevicePlatformVersion(device); - if(version > ((1 << 16) + 1)) { - retVal = true; + if (device != NULL) + { + int version = getDevicePlatformVersion(device); + if (version > ((1 << 16) + 1)) + { + retVal = true; + } } - } return retVal; } public: - Wrapper() : object_(NULL), referenceCountable_(false) - { - } - - Wrapper(const cl_type &obj) : object_(obj), referenceCountable_(false) + Wrapper() : object_(NULL), referenceCountable_(false) { - referenceCountable_ = isReferenceCountable(obj); + } + + Wrapper(const cl_type& obj) : object_(obj), referenceCountable_(false) + { + referenceCountable_ = isReferenceCountable(obj); } ~Wrapper() { - if (object_ != NULL) { release(); } + if (object_ != NULL) + { + release(); + } } - + Wrapper(const Wrapper& rhs) { object_ = rhs.object_; - referenceCountable_ = isReferenceCountable(object_); - if (object_ != NULL) { detail::errHandler(retain(), __RETAIN_ERR); } + referenceCountable_ = isReferenceCountable(object_); + if (object_ != NULL) + { + detail::errHandler(retain(), __RETAIN_ERR); + } } - Wrapper& operator = (const Wrapper& rhs) + Wrapper& operator=(const Wrapper& rhs) { - if (object_ != NULL) { detail::errHandler(release(), __RELEASE_ERR); } + if (object_ != NULL) + { + detail::errHandler(release(), __RELEASE_ERR); + } object_ = rhs.object_; referenceCountable_ = rhs.referenceCountable_; - if (object_ != NULL) { detail::errHandler(retain(), __RETAIN_ERR); } + if (object_ != NULL) + { + detail::errHandler(retain(), __RETAIN_ERR); + } return *this; } - Wrapper& operator = (const cl_type &rhs) + Wrapper& operator=(const cl_type& rhs) { - if (object_ != NULL) { detail::errHandler(release(), __RELEASE_ERR); } + if (object_ != NULL) + { + detail::errHandler(release(), __RELEASE_ERR); + } object_ = rhs; - referenceCountable_ = isReferenceCountable(object_); + referenceCountable_ = isReferenceCountable(object_); return *this; } - cl_type operator ()() const { return object_; } + cl_type operator()() const { return object_; } - cl_type& operator ()() { return object_; } + cl_type& operator()() { return object_; } protected: - template + template friend inline cl_int getInfoHelper(Func, cl_uint, U*, int, typename U::cl_type); - template + template friend inline cl_int getInfoHelper(Func, cl_uint, VECTOR_CLASS*, int, typename U::cl_type); cl_int retain() const { - if( referenceCountable_ ) { - return ReferenceHandler::retain(object_); - } - else { - return CL_SUCCESS; - } + if (referenceCountable_) + { + return ReferenceHandler::retain(object_); + } + else + { + return CL_SUCCESS; + } } cl_int release() const { - if( referenceCountable_ ) { - return ReferenceHandler::release(object_); - } - else { - return CL_SUCCESS; - } + if (referenceCountable_) + { + return ReferenceHandler::release(object_); + } + else + { + return CL_SUCCESS; + } } }; -} // namespace detail +} // namespace detail //! \endcond -/*! \stuct ImageFormat +/*! \struct ImageFormat * \brief Adds constructors and member functions for cl_image_format. * * \see cl_image_format @@ -1876,7 +2020,7 @@ protected: struct ImageFormat : public cl_image_format { //! \brief Default constructor - performs no initialization. - ImageFormat(){} + ImageFormat() {} //! \brief Initializing constructor. ImageFormat(cl_channel_order order, cl_channel_type type) @@ -1886,12 +2030,13 @@ struct ImageFormat : public cl_image_format } //! \brief Assignment operator. - ImageFormat& operator = (const ImageFormat& rhs) + ImageFormat& operator=(const ImageFormat& rhs) { - if (this != &rhs) { - this->image_channel_data_type = rhs.image_channel_data_type; - this->image_channel_order = rhs.image_channel_order; - } + if (this != &rhs) + { + this->image_channel_data_type = rhs.image_channel_data_type; + this->image_channel_order = rhs.image_channel_order; + } return *this; } }; @@ -1907,35 +2052,36 @@ class Device : public detail::Wrapper { public: //! \brief Default constructor - initializes to NULL. - Device() : detail::Wrapper() { } + Device() : detail::Wrapper() {} /*! \brief Copy constructor. * * This simply copies the device ID value, which is an inexpensive operation. */ - Device(const Device& device) : detail::Wrapper(device) { } + Device(const Device& device) : detail::Wrapper(device) {} /*! \brief Constructor from cl_device_id. * * This simply copies the device ID value, which is an inexpensive operation. */ - Device(const cl_device_id &device) : detail::Wrapper(device) { } + Device(const cl_device_id& device) : detail::Wrapper(device) {} /*! \brief Returns the first device on the default context. * * \see Context::getDefault() */ - static Device getDefault(cl_int * err = NULL); + static Device getDefault(cl_int* err = NULL); /*! \brief Assignment operator from Device. * * This simply copies the device ID value, which is an inexpensive operation. */ - Device& operator = (const Device& rhs) + Device& operator=(const Device& rhs) { - if (this != &rhs) { - detail::Wrapper::operator=(rhs); - } + if (this != &rhs) + { + detail::Wrapper::operator=(rhs); + } return *this; } @@ -1943,7 +2089,7 @@ public: * * This simply copies the device ID value, which is an inexpensive operation. */ - Device& operator = (const cl_device_id& rhs) + Device& operator=(const cl_device_id& rhs) { detail::Wrapper::operator=(rhs); return *this; @@ -1959,16 +2105,17 @@ public: } //! \brief Wrapper for clGetDeviceInfo() that returns by value. - template typename - detail::param_traits::param_type + template + typename detail::param_traits::param_type getInfo(cl_int* err = NULL) const { typename detail::param_traits< detail::cl_device_info, name>::param_type param; cl_int result = getInfo(name, ¶m); - if (err != NULL) { - *err = result; - } + if (err != NULL) + { + *err = result; + } return param; } @@ -1978,25 +2125,27 @@ public: #if defined(CL_VERSION_1_2) //! \brief Wrapper for clCreateSubDevicesEXT(). cl_int createSubDevices( - const cl_device_partition_property * properties, + const cl_device_partition_property* properties, VECTOR_CLASS* devices) { cl_uint n = 0; cl_int err = clCreateSubDevices(object_, properties, 0, NULL, &n); - if (err != CL_SUCCESS) { - return detail::errHandler(err, __CREATE_SUB_DEVICES); - } + if (err != CL_SUCCESS) + { + return detail::errHandler(err, __CREATE_SUB_DEVICES); + } - cl_device_id* ids = (cl_device_id*) alloca(n * sizeof(cl_device_id)); + cl_device_id* ids = (cl_device_id*)alloca(n * sizeof(cl_device_id)); err = clCreateSubDevices(object_, properties, n, ids, NULL); - if (err != CL_SUCCESS) { - return detail::errHandler(err, __CREATE_SUB_DEVICES); - } + if (err != CL_SUCCESS) + { + return detail::errHandler(err, __CREATE_SUB_DEVICES); + } devices->assign(&ids[0], &ids[n]); return CL_SUCCESS; } -#endif // #if defined(CL_VERSION_1_2) +#endif // #if defined(CL_VERSION_1_2) /** * CL 1.1 version that uses device fission. @@ -2004,37 +2153,38 @@ public: #if defined(CL_VERSION_1_1) #if defined(USE_CL_DEVICE_FISSION) cl_int createSubDevices( - const cl_device_partition_property_ext * properties, + const cl_device_partition_property_ext* properties, VECTOR_CLASS* devices) { - typedef CL_API_ENTRY cl_int - ( CL_API_CALL * PFN_clCreateSubDevicesEXT)( - cl_device_id /*in_device*/, - const cl_device_partition_property_ext * /* properties */, - cl_uint /*num_entries*/, - cl_device_id * /*out_devices*/, - cl_uint * /*num_devices*/ ) CL_EXT_SUFFIX__VERSION_1_1; + typedef CL_API_ENTRY cl_int(CL_API_CALL * PFN_clCreateSubDevicesEXT)( + cl_device_id /*in_device*/, + const cl_device_partition_property_ext* /* properties */, + cl_uint /*num_entries*/, + cl_device_id* /*out_devices*/, + cl_uint* /*num_devices*/) CL_EXT_SUFFIX__VERSION_1_1; static PFN_clCreateSubDevicesEXT pfn_clCreateSubDevicesEXT = NULL; __INIT_CL_EXT_FCN_PTR(clCreateSubDevicesEXT); cl_uint n = 0; cl_int err = pfn_clCreateSubDevicesEXT(object_, properties, 0, NULL, &n); - if (err != CL_SUCCESS) { - return detail::errHandler(err, __CREATE_SUB_DEVICES); - } + if (err != CL_SUCCESS) + { + return detail::errHandler(err, __CREATE_SUB_DEVICES); + } - cl_device_id* ids = (cl_device_id*) alloca(n * sizeof(cl_device_id)); + cl_device_id* ids = (cl_device_id*)alloca(n * sizeof(cl_device_id)); err = pfn_clCreateSubDevicesEXT(object_, properties, n, ids, NULL); - if (err != CL_SUCCESS) { - return detail::errHandler(err, __CREATE_SUB_DEVICES); - } + if (err != CL_SUCCESS) + { + return detail::errHandler(err, __CREATE_SUB_DEVICES); + } devices->assign(&ids[0], &ids[n]); return CL_SUCCESS; } -#endif // #if defined(USE_CL_DEVICE_FISSION) -#endif // #if defined(CL_VERSION_1_1) +#endif // #if defined(USE_CL_DEVICE_FISSION) +#endif // #if defined(CL_VERSION_1_1) }; /*! \brief Class interface for cl_platform_id. @@ -2048,29 +2198,30 @@ class Platform : public detail::Wrapper { public: //! \brief Default constructor - initializes to NULL. - Platform() : detail::Wrapper() { } + Platform() : detail::Wrapper() {} /*! \brief Copy constructor. * * This simply copies the platform ID value, which is an inexpensive operation. */ - Platform(const Platform& platform) : detail::Wrapper(platform) { } + Platform(const Platform& platform) : detail::Wrapper(platform) {} /*! \brief Constructor from cl_platform_id. * * This simply copies the platform ID value, which is an inexpensive operation. */ - Platform(const cl_platform_id &platform) : detail::Wrapper(platform) { } + Platform(const cl_platform_id& platform) : detail::Wrapper(platform) {} /*! \brief Assignment operator from Platform. * * This simply copies the platform ID value, which is an inexpensive operation. */ - Platform& operator = (const Platform& rhs) + Platform& operator=(const Platform& rhs) { - if (this != &rhs) { - detail::Wrapper::operator=(rhs); - } + if (this != &rhs) + { + detail::Wrapper::operator=(rhs); + } return *this; } @@ -2078,7 +2229,7 @@ public: * * This simply copies the platform ID value, which is an inexpensive operation. */ - Platform& operator = (const cl_platform_id& rhs) + Platform& operator=(const cl_platform_id& rhs) { detail::Wrapper::operator=(rhs); return *this; @@ -2093,16 +2244,17 @@ public: } //! \brief Wrapper for clGetPlatformInfo() that returns by value. - template typename - detail::param_traits::param_type + template + typename detail::param_traits::param_type getInfo(cl_int* err = NULL) const { typename detail::param_traits< detail::cl_platform_info, name>::param_type param; cl_int result = getInfo(name, ¶m); - if (err != NULL) { - *err = result; - } + if (err != NULL) + { + *err = result; + } return param; } @@ -2115,26 +2267,29 @@ public: VECTOR_CLASS* devices) const { cl_uint n = 0; - if( devices == NULL ) { - return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR); - } + if (devices == NULL) + { + return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR); + } cl_int err = ::clGetDeviceIDs(object_, type, 0, NULL, &n); - if (err != CL_SUCCESS) { - return detail::errHandler(err, __GET_DEVICE_IDS_ERR); - } + if (err != CL_SUCCESS) + { + return detail::errHandler(err, __GET_DEVICE_IDS_ERR); + } - cl_device_id* ids = (cl_device_id*) alloca(n * sizeof(cl_device_id)); + cl_device_id* ids = (cl_device_id*)alloca(n * sizeof(cl_device_id)); err = ::clGetDeviceIDs(object_, type, n, ids, NULL); - if (err != CL_SUCCESS) { - return detail::errHandler(err, __GET_DEVICE_IDS_ERR); - } + if (err != CL_SUCCESS) + { + return detail::errHandler(err, __GET_DEVICE_IDS_ERR); + } devices->assign(&ids[0], &ids[n]); return CL_SUCCESS; } #if defined(USE_DX_INTEROP) - /*! \brief Get the list of available D3D10 devices. + /*! \brief Get the list of available D3D10 devices. * * \param d3d_device_source. * @@ -2159,51 +2314,54 @@ public: */ cl_int getDevices( cl_d3d10_device_source_khr d3d_device_source, - void * d3d_object, - cl_d3d10_device_set_khr d3d_device_set, + void* d3d_object, + cl_d3d10_device_set_khr d3d_device_set, VECTOR_CLASS* devices) const { - typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clGetDeviceIDsFromD3D10KHR)( - cl_platform_id platform, - cl_d3d10_device_source_khr d3d_device_source, - void * d3d_object, + typedef CL_API_ENTRY cl_int(CL_API_CALL * PFN_clGetDeviceIDsFromD3D10KHR)( + cl_platform_id platform, + cl_d3d10_device_source_khr d3d_device_source, + void* d3d_object, cl_d3d10_device_set_khr d3d_device_set, cl_uint num_entries, - cl_device_id * devices, + cl_device_id* devices, cl_uint* num_devices); - if( devices == NULL ) { - return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR); - } + if (devices == NULL) + { + return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_DEVICE_IDS_ERR); + } static PFN_clGetDeviceIDsFromD3D10KHR pfn_clGetDeviceIDsFromD3D10KHR = NULL; __INIT_CL_EXT_FCN_PTR_PLATFORM(object_, clGetDeviceIDsFromD3D10KHR); cl_uint n = 0; cl_int err = pfn_clGetDeviceIDsFromD3D10KHR( - object_, - d3d_device_source, - d3d_object, - d3d_device_set, - 0, - NULL, - &n); - if (err != CL_SUCCESS) { - return detail::errHandler(err, __GET_DEVICE_IDS_ERR); - } - - cl_device_id* ids = (cl_device_id*) alloca(n * sizeof(cl_device_id)); - err = pfn_clGetDeviceIDsFromD3D10KHR( - object_, - d3d_device_source, + object_, + d3d_device_source, d3d_object, d3d_device_set, - n, - ids, + 0, + NULL, + &n); + if (err != CL_SUCCESS) + { + return detail::errHandler(err, __GET_DEVICE_IDS_ERR); + } + + cl_device_id* ids = (cl_device_id*)alloca(n * sizeof(cl_device_id)); + err = pfn_clGetDeviceIDsFromD3D10KHR( + object_, + d3d_device_source, + d3d_object, + d3d_device_set, + n, + ids, NULL); - if (err != CL_SUCCESS) { - return detail::errHandler(err, __GET_DEVICE_IDS_ERR); - } + if (err != CL_SUCCESS) + { + return detail::errHandler(err, __GET_DEVICE_IDS_ERR); + } devices->assign(&ids[0], &ids[n]); return CL_SUCCESS; @@ -2219,21 +2377,24 @@ public: { cl_uint n = 0; - if( platforms == NULL ) { - return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR); - } + if (platforms == NULL) + { + return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR); + } cl_int err = ::clGetPlatformIDs(0, NULL, &n); - if (err != CL_SUCCESS) { - return detail::errHandler(err, __GET_PLATFORM_IDS_ERR); - } + if (err != CL_SUCCESS) + { + return detail::errHandler(err, __GET_PLATFORM_IDS_ERR); + } - cl_platform_id* ids = (cl_platform_id*) alloca( + cl_platform_id* ids = (cl_platform_id*)alloca( n * sizeof(cl_platform_id)); err = ::clGetPlatformIDs(n, ids, NULL); - if (err != CL_SUCCESS) { - return detail::errHandler(err, __GET_PLATFORM_IDS_ERR); - } + if (err != CL_SUCCESS) + { + return detail::errHandler(err, __GET_PLATFORM_IDS_ERR); + } platforms->assign(&ids[0], &ids[n]); return CL_SUCCESS; @@ -2244,25 +2405,28 @@ public: * Wraps clGetPlatformIDs(), returning the first result. */ static cl_int get( - Platform * platform) + Platform* platform) { cl_uint n = 0; - if( platform == NULL ) { - return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR); - } + if (platform == NULL) + { + return detail::errHandler(CL_INVALID_ARG_VALUE, __GET_PLATFORM_IDS_ERR); + } cl_int err = ::clGetPlatformIDs(0, NULL, &n); - if (err != CL_SUCCESS) { - return detail::errHandler(err, __GET_PLATFORM_IDS_ERR); - } + if (err != CL_SUCCESS) + { + return detail::errHandler(err, __GET_PLATFORM_IDS_ERR); + } - cl_platform_id* ids = (cl_platform_id*) alloca( + cl_platform_id* ids = (cl_platform_id*)alloca( n * sizeof(cl_platform_id)); err = ::clGetPlatformIDs(n, ids, NULL); - if (err != CL_SUCCESS) { - return detail::errHandler(err, __GET_PLATFORM_IDS_ERR); - } + if (err != CL_SUCCESS) + { + return detail::errHandler(err, __GET_PLATFORM_IDS_ERR); + } *platform = ids[0]; return CL_SUCCESS; @@ -2273,40 +2437,44 @@ public: * Wraps clGetPlatformIDs(), returning the first result. */ static Platform get( - cl_int * errResult = NULL) + cl_int* errResult = NULL) { Platform platform; cl_uint n = 0; cl_int err = ::clGetPlatformIDs(0, NULL, &n); - if (err != CL_SUCCESS) { - detail::errHandler(err, __GET_PLATFORM_IDS_ERR); - if (errResult != NULL) { - *errResult = err; + if (err != CL_SUCCESS) + { + detail::errHandler(err, __GET_PLATFORM_IDS_ERR); + if (errResult != NULL) + { + *errResult = err; + } } - } - cl_platform_id* ids = (cl_platform_id*) alloca( + cl_platform_id* ids = (cl_platform_id*)alloca( n * sizeof(cl_platform_id)); err = ::clGetPlatformIDs(n, ids, NULL); - if (err != CL_SUCCESS) { - detail::errHandler(err, __GET_PLATFORM_IDS_ERR); - } + if (err != CL_SUCCESS) + { + detail::errHandler(err, __GET_PLATFORM_IDS_ERR); + } + + if (errResult != NULL) + { + *errResult = err; + } - if (errResult != NULL) { - *errResult = err; - } - return ids[0]; } - static Platform getDefault( - cl_int *errResult = NULL ) + static Platform getDefault( + cl_int* errResult = NULL) { return get(errResult); } - + #if defined(CL_VERSION_1_2) //! \brief Wrapper for clUnloadCompiler(). cl_int @@ -2314,8 +2482,8 @@ public: { return ::clUnloadPlatformCompiler(object_); } -#endif // #if defined(CL_VERSION_1_2) -}; // class Platform +#endif // #if defined(CL_VERSION_1_2) +}; // class Platform /** * Deprecated APIs for 1.2 @@ -2332,7 +2500,7 @@ UnloadCompiler() { return ::clUnloadCompiler(); } -#endif // #if defined(CL_VERSION_1_1) +#endif // #if defined(CL_VERSION_1_1) /*! \brief Class interface for cl_context. * @@ -2342,19 +2510,20 @@ UnloadCompiler() * * \see cl_context */ -class Context +class Context : public detail::Wrapper { private: static volatile int default_initialized_; static Context default_; static volatile cl_int default_error_; + public: /*! \brief Destructor. * * This calls clReleaseContext() on the value held by this instance. */ - ~Context() { } + ~Context() {} /*! \brief Constructs a context including a list of specified devices. * @@ -2363,41 +2532,43 @@ public: Context( const VECTOR_CLASS& devices, cl_context_properties* properties = NULL, - void (CL_CALLBACK * notifyFptr)( - const char *, - const void *, + void(CL_CALLBACK* notifyFptr)( + const char*, + const void*, ::size_t, - void *) = NULL, + void*) = NULL, void* data = NULL, cl_int* err = NULL) { cl_int error; ::size_t numDevices = devices.size(); - cl_device_id* deviceIDs = (cl_device_id*) alloca(numDevices * sizeof(cl_device_id)); - for( ::size_t deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) { - deviceIDs[deviceIndex] = (devices[deviceIndex])(); - } + cl_device_id* deviceIDs = (cl_device_id*)alloca(numDevices * sizeof(cl_device_id)); + for (::size_t deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex) + { + deviceIDs[deviceIndex] = (devices[deviceIndex])(); + } object_ = ::clCreateContext( - properties, (cl_uint) numDevices, + properties, (cl_uint)numDevices, deviceIDs, notifyFptr, data, &error); detail::errHandler(error, __CREATE_CONTEXT_ERR); - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } } Context( const Device& device, cl_context_properties* properties = NULL, - void (CL_CALLBACK * notifyFptr)( - const char *, - const void *, + void(CL_CALLBACK* notifyFptr)( + const char*, + const void*, ::size_t, - void *) = NULL, + void*) = NULL, void* data = NULL, cl_int* err = NULL) { @@ -2411,9 +2582,10 @@ public: notifyFptr, data, &error); detail::errHandler(error, __CREATE_CONTEXT_ERR); - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } } /*! \brief Constructs a context including all devices of a specified type. @@ -2423,68 +2595,77 @@ public: Context( cl_device_type type, cl_context_properties* properties = NULL, - void (CL_CALLBACK * notifyFptr)( - const char *, - const void *, + void(CL_CALLBACK* notifyFptr)( + const char*, + const void*, ::size_t, - void *) = NULL, + void*) = NULL, void* data = NULL, cl_int* err = NULL) { cl_int error; #if !defined(__APPLE__) || !defined(__MACOS) - cl_context_properties prop[4] = {CL_CONTEXT_PLATFORM, 0, 0, 0 }; - if (properties == NULL) { - prop[1] = (cl_context_properties)Platform::get(&error)(); - if (error != CL_SUCCESS) { - detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR); - if (err != NULL) { - *err = error; - return; - } - } + cl_context_properties prop[4] = {CL_CONTEXT_PLATFORM, 0, 0, 0}; + if (properties == NULL) + { + prop[1] = (cl_context_properties)Platform::get(&error)(); + if (error != CL_SUCCESS) + { + detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR); + if (err != NULL) + { + *err = error; + return; + } + } - properties = &prop[0]; - } + properties = &prop[0]; + } #endif object_ = ::clCreateContextFromType( properties, type, notifyFptr, data, &error); detail::errHandler(error, __CREATE_CONTEXT_FROM_TYPE_ERR); - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } } /*! \brief Returns a singleton context including all devices of CL_DEVICE_TYPE_DEFAULT. * * \note All calls to this function return the same cl_context as the first. */ - static Context getDefault(cl_int * err = NULL) + static Context getDefault(cl_int* err = NULL) { int state = detail::compare_exchange( - &default_initialized_, + &default_initialized_, __DEFAULT_BEING_INITIALIZED, __DEFAULT_NOT_INITIALIZED); - - if (state & __DEFAULT_INITIALIZED) { - if (err != NULL) { - *err = default_error_; - } - return default_; - } - if (state & __DEFAULT_BEING_INITIALIZED) { - // Assume writes will propagate eventually... - while(default_initialized_ != __DEFAULT_INITIALIZED) { - detail::fence(); - } - - if (err != NULL) { - *err = default_error_; + if (state & __DEFAULT_INITIALIZED) + { + if (err != NULL) + { + *err = default_error_; + } + return default_; + } + + if (state & __DEFAULT_BEING_INITIALIZED) + { + // Assume writes will propagate eventually... + while (default_initialized_ != __DEFAULT_INITIALIZED) + { + detail::fence(); + } + + if (err != NULL) + { + *err = default_error_; + } + return default_; } - return default_; - } cl_int error; default_ = Context( @@ -2502,39 +2683,40 @@ public: detail::fence(); - if (err != NULL) { - *err = default_error_; - } + if (err != NULL) + { + *err = default_error_; + } return default_; - } //! \brief Default constructor - initializes to NULL. - Context() : detail::Wrapper() { } + Context() : detail::Wrapper() {} /*! \brief Copy constructor. * * This calls clRetainContext() on the parameter's cl_context. */ - Context(const Context& context) : detail::Wrapper(context) { } + Context(const Context& context) : detail::Wrapper(context) {} /*! \brief Constructor from cl_context - takes ownership. * * This effectively transfers ownership of a refcount on the cl_context * into the new Context object. */ - __CL_EXPLICIT_CONSTRUCTORS Context(const cl_context& context) : detail::Wrapper(context) { } + __CL_EXPLICIT_CONSTRUCTORS Context(const cl_context& context) : detail::Wrapper(context) {} /*! \brief Assignment operator from Context. * * This calls clRetainContext() on the parameter and clReleaseContext() on * the previous value held by this instance. */ - Context& operator = (const Context& rhs) + Context& operator=(const Context& rhs) { - if (this != &rhs) { - detail::Wrapper::operator=(rhs); - } + if (this != &rhs) + { + detail::Wrapper::operator=(rhs); + } return *this; } @@ -2543,7 +2725,7 @@ public: * This effectively transfers ownership of a refcount on the rhs and calls * clReleaseContext() on the value previously held by this instance. */ - Context& operator = (const cl_context& rhs) + Context& operator=(const cl_context& rhs) { detail::Wrapper::operator=(rhs); return *this; @@ -2559,16 +2741,17 @@ public: } //! \brief Wrapper for clGetContextInfo() that returns by value. - template typename - detail::param_traits::param_type + template + typename detail::param_traits::param_type getInfo(cl_int* err = NULL) const { typename detail::param_traits< detail::cl_context_info, name>::param_type param; cl_int result = getInfo(name, ¶m); - if (err != NULL) { - *err = result; - } + if (err != NULL) + { + *err = result; + } return param; } @@ -2583,35 +2766,37 @@ public: { cl_uint numEntries; cl_int err = ::clGetSupportedImageFormats( - object_, - flags, - type, - 0, - NULL, - &numEntries); - if (err != CL_SUCCESS) { - return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR); - } + object_, + flags, + type, + 0, + NULL, + &numEntries); + if (err != CL_SUCCESS) + { + return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR); + } ImageFormat* value = (ImageFormat*) alloca(numEntries * sizeof(ImageFormat)); err = ::clGetSupportedImageFormats( - object_, - flags, - type, + object_, + flags, + type, numEntries, - (cl_image_format*) value, + (cl_image_format*)value, NULL); - if (err != CL_SUCCESS) { - return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR); - } + if (err != CL_SUCCESS) + { + return detail::errHandler(err, __GET_SUPPORTED_IMAGE_FORMATS_ERR); + } formats->assign(&value[0], &value[numEntries]); return CL_SUCCESS; } }; -inline Device Device::getDefault(cl_int * err) +inline Device Device::getDefault(cl_int* err) { cl_int error; Device device; @@ -2619,17 +2804,21 @@ inline Device Device::getDefault(cl_int * err) Context context = Context::getDefault(&error); detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR); - if (error != CL_SUCCESS) { - if (err != NULL) { - *err = error; + if (error != CL_SUCCESS) + { + if (err != NULL) + { + *err = error; + } } - } - else { - device = context.getInfo()[0]; - if (err != NULL) { - *err = CL_SUCCESS; + else + { + device = context.getInfo()[0]; + if (err != NULL) + { + *err = CL_SUCCESS; + } } - } return device; } @@ -2660,34 +2849,35 @@ public: * * This calls clReleaseEvent() on the value held by this instance. */ - ~Event() { } - + ~Event() {} + //! \brief Default constructor - initializes to NULL. - Event() : detail::Wrapper() { } + Event() : detail::Wrapper() {} /*! \brief Copy constructor. * * This calls clRetainEvent() on the parameter's cl_event. */ - Event(const Event& event) : detail::Wrapper(event) { } + Event(const Event& event) : detail::Wrapper(event) {} /*! \brief Constructor from cl_event - takes ownership. * * This effectively transfers ownership of a refcount on the cl_event * into the new Event object. */ - Event(const cl_event& event) : detail::Wrapper(event) { } + Event(const cl_event& event) : detail::Wrapper(event) {} /*! \brief Assignment operator from cl_event - takes ownership. * * This effectively transfers ownership of a refcount on the rhs and calls * clReleaseEvent() on the value previously held by this instance. */ - Event& operator = (const Event& rhs) + Event& operator=(const Event& rhs) { - if (this != &rhs) { - detail::Wrapper::operator=(rhs); - } + if (this != &rhs) + { + detail::Wrapper::operator=(rhs); + } return *this; } @@ -2696,7 +2886,7 @@ public: * This calls clRetainEvent() on the parameter and clReleaseEvent() on * the previous value held by this instance. */ - Event& operator = (const cl_event& rhs) + Event& operator=(const cl_event& rhs) { detail::Wrapper::operator=(rhs); return *this; @@ -2712,16 +2902,17 @@ public: } //! \brief Wrapper for clGetEventInfo() that returns by value. - template typename - detail::param_traits::param_type + template + typename detail::param_traits::param_type getInfo(cl_int* err = NULL) const { typename detail::param_traits< detail::cl_event_info, name>::param_type param; cl_int result = getInfo(name, ¶m); - if (err != NULL) { - *err = result; - } + if (err != NULL) + { + *err = result; + } return param; } @@ -2730,21 +2921,22 @@ public: cl_int getProfilingInfo(cl_profiling_info name, T* param) const { return detail::errHandler(detail::getInfo( - &::clGetEventProfilingInfo, object_, name, param), + &::clGetEventProfilingInfo, object_, name, param), __GET_EVENT_PROFILE_INFO_ERR); } //! \brief Wrapper for clGetEventProfilingInfo() that returns by value. - template typename - detail::param_traits::param_type + template + typename detail::param_traits::param_type getProfilingInfo(cl_int* err = NULL) const { typename detail::param_traits< detail::cl_profiling_info, name>::param_type param; cl_int result = getProfilingInfo(name, ¶m); - if (err != NULL) { - *err = result; - } + if (err != NULL) + { + *err = result; + } return param; } @@ -2766,15 +2958,15 @@ public: */ cl_int setCallback( cl_int type, - void (CL_CALLBACK * pfn_notify)(cl_event, cl_int, void *), - void * user_data = NULL) + void(CL_CALLBACK* pfn_notify)(cl_event, cl_int, void*), + void* user_data = NULL) { return detail::errHandler( ::clSetEventCallback( object_, type, pfn_notify, - user_data), + user_data), __SET_EVENT_CALLBACK_ERR); } #endif @@ -2788,7 +2980,7 @@ public: { return detail::errHandler( ::clWaitForEvents( - (cl_uint) events.size(), (cl_event*)&events.front()), + (cl_uint)events.size(), (cl_event*)&events.front()), __WAIT_FOR_EVENTS_ERR); } }; @@ -2807,7 +2999,7 @@ public: */ UserEvent( const Context& context, - cl_int * err = NULL) + cl_int* err = NULL) { cl_int error; object_ = ::clCreateUserEvent( @@ -2815,23 +3007,25 @@ public: &error); detail::errHandler(error, __CREATE_USER_EVENT_ERR); - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } } //! \brief Default constructor - initializes to NULL. - UserEvent() : Event() { } + UserEvent() : Event() {} //! \brief Copy constructor - performs shallow copy. - UserEvent(const UserEvent& event) : Event(event) { } + UserEvent(const UserEvent& event) : Event(event) {} //! \brief Assignment Operator - performs shallow copy. - UserEvent& operator = (const UserEvent& rhs) + UserEvent& operator=(const UserEvent& rhs) { - if (this != &rhs) { - Event::operator=(rhs); - } + if (this != &rhs) + { + Event::operator=(rhs); + } return *this; } @@ -2842,7 +3036,7 @@ public: cl_int setStatus(cl_int status) { return detail::errHandler( - ::clSetUserEventStatus(object_,status), + ::clSetUserEventStatus(object_, status), __SET_USER_EVENT_STATUS_ERR); } }; @@ -2857,7 +3051,7 @@ WaitForEvents(const VECTOR_CLASS& events) { return detail::errHandler( ::clWaitForEvents( - (cl_uint) events.size(), (cl_event*)&events.front()), + (cl_uint)events.size(), (cl_event*)&events.front()), __WAIT_FOR_EVENTS_ERR); } @@ -2872,7 +3066,6 @@ WaitForEvents(const VECTOR_CLASS& events) class Memory : public detail::Wrapper { public: - /*! \brief Destructor. * * This calls clReleaseMemObject() on the value held by this instance. @@ -2880,31 +3073,32 @@ public: ~Memory() {} //! \brief Default constructor - initializes to NULL. - Memory() : detail::Wrapper() { } + Memory() : detail::Wrapper() {} /*! \brief Copy constructor - performs shallow copy. * * This calls clRetainMemObject() on the parameter's cl_mem. */ - Memory(const Memory& memory) : detail::Wrapper(memory) { } + Memory(const Memory& memory) : detail::Wrapper(memory) {} /*! \brief Constructor from cl_mem - takes ownership. * * This effectively transfers ownership of a refcount on the cl_mem * into the new Memory object. */ - __CL_EXPLICIT_CONSTRUCTORS Memory(const cl_mem& memory) : detail::Wrapper(memory) { } + __CL_EXPLICIT_CONSTRUCTORS Memory(const cl_mem& memory) : detail::Wrapper(memory) {} /*! \brief Assignment operator from Memory. * * This calls clRetainMemObject() on the parameter and clReleaseMemObject() * on the previous value held by this instance. */ - Memory& operator = (const Memory& rhs) + Memory& operator=(const Memory& rhs) { - if (this != &rhs) { - detail::Wrapper::operator=(rhs); - } + if (this != &rhs) + { + detail::Wrapper::operator=(rhs); + } return *this; } @@ -2913,7 +3107,7 @@ public: * This effectively transfers ownership of a refcount on the rhs and calls * clReleaseMemObject() on the value previously held by this instance. */ - Memory& operator = (const cl_mem& rhs) + Memory& operator=(const cl_mem& rhs) { detail::Wrapper::operator=(rhs); return *this; @@ -2929,16 +3123,17 @@ public: } //! \brief Wrapper for clGetMemObjectInfo() that returns by value. - template typename - detail::param_traits::param_type + template + typename detail::param_traits::param_type getInfo(cl_int* err = NULL) const { typename detail::param_traits< detail::cl_mem_info, name>::param_type param; cl_int result = getInfo(name, ¶m); - if (err != NULL) { - *err = result; - } + if (err != NULL) + { + *err = result; + } return param; } @@ -2957,26 +3152,25 @@ public: * value - not the Memory class instance. */ cl_int setDestructorCallback( - void (CL_CALLBACK * pfn_notify)(cl_mem, void *), - void * user_data = NULL) + void(CL_CALLBACK* pfn_notify)(cl_mem, void*), + void* user_data = NULL) { return detail::errHandler( ::clSetMemObjectDestructorCallback( object_, pfn_notify, - user_data), + user_data), __SET_MEM_OBJECT_DESTRUCTOR_CALLBACK_ERR); } #endif - }; // Pre-declare copy functions class Buffer; -template< typename IteratorType > -cl_int copy( IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer ); -template< typename IteratorType > -cl_int copy( const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator ); +template +cl_int copy(IteratorType startIterator, IteratorType endIterator, cl::Buffer& buffer); +template +cl_int copy(const cl::Buffer& buffer, IteratorType startIterator, IteratorType endIterator); /*! \brief Class interface for Buffer Memory Objects. * @@ -2987,7 +3181,6 @@ cl_int copy( const cl::Buffer &buffer, IteratorType startIterator, IteratorType class Buffer : public Memory { public: - /*! \brief Constructs a Buffer in a specified context. * * Wraps clCreateBuffer(). @@ -3006,9 +3199,10 @@ public: object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error); detail::errHandler(error, __CREATE_BUFFER_ERR); - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } } /*! \brief Constructs a Buffer in the default context. @@ -3021,7 +3215,7 @@ public: * \see Context::getDefault() */ Buffer( - cl_mem_flags flags, + cl_mem_flags flags, ::size_t size, void* host_ptr = NULL, cl_int* err = NULL) @@ -3033,16 +3227,17 @@ public: object_ = ::clCreateBuffer(context(), flags, size, host_ptr, &error); detail::errHandler(error, __CREATE_BUFFER_ERR); - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } } /*! * \brief Construct a Buffer from a host container via iterators. * If useHostPtr is specified iterators must be random access. */ - template< typename IteratorType > + template Buffer( IteratorType startIterator, IteratorType endIterator, @@ -3054,64 +3249,74 @@ public: cl_int error; cl_mem_flags flags = 0; - if( readOnly ) { - flags |= CL_MEM_READ_ONLY; - } - else { - flags |= CL_MEM_READ_WRITE; - } - if( useHostPtr ) { - flags |= CL_MEM_USE_HOST_PTR; - } - - ::size_t size = sizeof(DataType)*(endIterator - startIterator); + if (readOnly) + { + flags |= CL_MEM_READ_ONLY; + } + else + { + flags |= CL_MEM_READ_WRITE; + } + if (useHostPtr) + { + flags |= CL_MEM_USE_HOST_PTR; + } + + ::size_t size = sizeof(DataType) * (endIterator - startIterator); Context context = Context::getDefault(err); - if( useHostPtr ) { - object_ = ::clCreateBuffer(context(), flags, size, static_cast(&*startIterator), &error); - } else { - object_ = ::clCreateBuffer(context(), flags, size, 0, &error); - } + if (useHostPtr) + { + object_ = ::clCreateBuffer(context(), flags, size, static_cast(&*startIterator), &error); + } + else + { + object_ = ::clCreateBuffer(context(), flags, size, 0, &error); + } detail::errHandler(error, __CREATE_BUFFER_ERR); - if (err != NULL) { - *err = error; - } - - if( !useHostPtr ) { - error = cl::copy(startIterator, endIterator, *this); - detail::errHandler(error, __CREATE_BUFFER_ERR); - if (err != NULL) { + if (err != NULL) + { *err = error; } - } + + if (!useHostPtr) + { + error = cl::copy(startIterator, endIterator, *this); + detail::errHandler(error, __CREATE_BUFFER_ERR); + if (err != NULL) + { + *err = error; + } + } } //! \brief Default constructor - initializes to NULL. - Buffer() : Memory() { } + Buffer() : Memory() {} /*! \brief Copy constructor - performs shallow copy. * * See Memory for further details. */ - Buffer(const Buffer& buffer) : Memory(buffer) { } + Buffer(const Buffer& buffer) : Memory(buffer) {} /*! \brief Constructor from cl_mem - takes ownership. * * See Memory for further details. */ - __CL_EXPLICIT_CONSTRUCTORS Buffer(const cl_mem& buffer) : Memory(buffer) { } + __CL_EXPLICIT_CONSTRUCTORS Buffer(const cl_mem& buffer) : Memory(buffer) {} /*! \brief Assignment from Buffer - performs shallow copy. * * See Memory for further details. */ - Buffer& operator = (const Buffer& rhs) + Buffer& operator=(const Buffer& rhs) { - if (this != &rhs) { - Memory::operator=(rhs); - } + if (this != &rhs) + { + Memory::operator=(rhs); + } return *this; } @@ -3119,7 +3324,7 @@ public: * * See Memory for further details. */ - Buffer& operator = (const cl_mem& rhs) + Buffer& operator=(const cl_mem& rhs) { Memory::operator=(rhs); return *this; @@ -3133,29 +3338,30 @@ public: Buffer createSubBuffer( cl_mem_flags flags, cl_buffer_create_type buffer_create_type, - const void * buffer_create_info, - cl_int * err = NULL) + const void* buffer_create_info, + cl_int* err = NULL) { Buffer result; cl_int error; result.object_ = ::clCreateSubBuffer( - object_, - flags, - buffer_create_type, - buffer_create_info, + object_, + flags, + buffer_create_type, + buffer_create_info, &error); detail::errHandler(error, __CREATE_SUBBUFFER_ERR); - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } return result; - } + } #endif }; -#if defined (USE_DX_INTEROP) +#if defined(USE_DX_INTEROP) /*! \brief Class interface for creating OpenCL buffers from ID3D10Buffer's. * * This is provided to facilitate interoperability with Direct3D. @@ -3167,9 +3373,9 @@ public: class BufferD3D10 : public Buffer { public: - typedef CL_API_ENTRY cl_mem (CL_API_CALL *PFN_clCreateFromD3D10BufferKHR)( - cl_context context, cl_mem_flags flags, ID3D10Buffer* buffer, - cl_int* errcode_ret); + typedef CL_API_ENTRY cl_mem(CL_API_CALL* PFN_clCreateFromD3D10BufferKHR)( + cl_context context, cl_mem_flags flags, ID3D10Buffer* buffer, + cl_int* errcode_ret); /*! \brief Constructs a BufferD3D10, in a specified context, from a * given ID3D10Buffer. @@ -3180,18 +3386,20 @@ public: const Context& context, cl_mem_flags flags, ID3D10Buffer* bufobj, - cl_int * err = NULL) + cl_int* err = NULL) { static PFN_clCreateFromD3D10BufferKHR pfn_clCreateFromD3D10BufferKHR = NULL; #if defined(CL_VERSION_1_2) vector props = context.getInfo(); cl_platform platform = -1; - for( int i = 0; i < props.size(); ++i ) { - if( props[i] == CL_CONTEXT_PLATFORM ) { - platform = props[i+1]; + for (int i = 0; i < props.size(); ++i) + { + if (props[i] == CL_CONTEXT_PLATFORM) + { + platform = props[i + 1]; + } } - } __INIT_CL_EXT_FCN_PTR_PLATFORM(platform, clCreateFromD3D10BufferKHR); #endif #if defined(CL_VERSION_1_1) @@ -3206,35 +3414,37 @@ public: &error); detail::errHandler(error, __CREATE_GL_BUFFER_ERR); - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } } //! \brief Default constructor - initializes to NULL. - BufferD3D10() : Buffer() { } + BufferD3D10() : Buffer() {} /*! \brief Copy constructor - performs shallow copy. * * See Memory for further details. */ - BufferD3D10(const BufferD3D10& buffer) : Buffer(buffer) { } + BufferD3D10(const BufferD3D10& buffer) : Buffer(buffer) {} /*! \brief Constructor from cl_mem - takes ownership. * * See Memory for further details. */ - __CL_EXPLICIT_CONSTRUCTORS BufferD3D10(const cl_mem& buffer) : Buffer(buffer) { } + __CL_EXPLICIT_CONSTRUCTORS BufferD3D10(const cl_mem& buffer) : Buffer(buffer) {} /*! \brief Assignment from BufferD3D10 - performs shallow copy. * * See Memory for further details. */ - BufferD3D10& operator = (const BufferD3D10& rhs) + BufferD3D10& operator=(const BufferD3D10& rhs) { - if (this != &rhs) { - Buffer::operator=(rhs); - } + if (this != &rhs) + { + Buffer::operator=(rhs); + } return *this; } @@ -3242,7 +3452,7 @@ public: * * See Memory for further details. */ - BufferD3D10& operator = (const cl_mem& rhs) + BufferD3D10& operator=(const cl_mem& rhs) { Buffer::operator=(rhs); return *this; @@ -3270,7 +3480,7 @@ public: const Context& context, cl_mem_flags flags, GLuint bufobj, - cl_int * err = NULL) + cl_int* err = NULL) { cl_int error; object_ = ::clCreateFromGLBuffer( @@ -3280,35 +3490,37 @@ public: &error); detail::errHandler(error, __CREATE_GL_BUFFER_ERR); - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } } //! \brief Default constructor - initializes to NULL. - BufferGL() : Buffer() { } + BufferGL() : Buffer() {} /*! \brief Copy constructor - performs shallow copy. * * See Memory for further details. */ - BufferGL(const BufferGL& buffer) : Buffer(buffer) { } + BufferGL(const BufferGL& buffer) : Buffer(buffer) {} /*! \brief Constructor from cl_mem - takes ownership. * * See Memory for further details. */ - __CL_EXPLICIT_CONSTRUCTORS BufferGL(const cl_mem& buffer) : Buffer(buffer) { } + __CL_EXPLICIT_CONSTRUCTORS BufferGL(const cl_mem& buffer) : Buffer(buffer) {} /*! \brief Assignment from BufferGL - performs shallow copy. * * See Memory for further details. */ - BufferGL& operator = (const BufferGL& rhs) + BufferGL& operator=(const BufferGL& rhs) { - if (this != &rhs) { - Buffer::operator=(rhs); - } + if (this != &rhs) + { + Buffer::operator=(rhs); + } return *this; } @@ -3316,7 +3528,7 @@ public: * * See Memory for further details. */ - BufferGL& operator = (const cl_mem& rhs) + BufferGL& operator=(const cl_mem& rhs) { Buffer::operator=(rhs); return *this; @@ -3324,11 +3536,11 @@ public: //! \brief Wrapper for clGetGLObjectInfo(). cl_int getObjectInfo( - cl_gl_object_type *type, - GLuint * gl_object_name) + cl_gl_object_type* type, + GLuint* gl_object_name) { return detail::errHandler( - ::clGetGLObjectInfo(object_,type,gl_object_name), + ::clGetGLObjectInfo(object_, type, gl_object_name), __GET_GL_OBJECT_INFO_ERR); } }; @@ -3353,7 +3565,7 @@ public: const Context& context, cl_mem_flags flags, GLuint bufobj, - cl_int * err = NULL) + cl_int* err = NULL) { cl_int error; object_ = ::clCreateFromGLRenderbuffer( @@ -3363,35 +3575,37 @@ public: &error); detail::errHandler(error, __CREATE_GL_RENDER_BUFFER_ERR); - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } } //! \brief Default constructor - initializes to NULL. - BufferRenderGL() : Buffer() { } + BufferRenderGL() : Buffer() {} /*! \brief Copy constructor - performs shallow copy. * * See Memory for further details. */ - BufferRenderGL(const BufferGL& buffer) : Buffer(buffer) { } + BufferRenderGL(const BufferGL& buffer) : Buffer(buffer) {} /*! \brief Constructor from cl_mem - takes ownership. * * See Memory for further details. */ - __CL_EXPLICIT_CONSTRUCTORS BufferRenderGL(const cl_mem& buffer) : Buffer(buffer) { } + __CL_EXPLICIT_CONSTRUCTORS BufferRenderGL(const cl_mem& buffer) : Buffer(buffer) {} /*! \brief Assignment from BufferGL - performs shallow copy. * * See Memory for further details. */ - BufferRenderGL& operator = (const BufferRenderGL& rhs) + BufferRenderGL& operator=(const BufferRenderGL& rhs) { - if (this != &rhs) { - Buffer::operator=(rhs); - } + if (this != &rhs) + { + Buffer::operator=(rhs); + } return *this; } @@ -3399,7 +3613,7 @@ public: * * See Memory for further details. */ - BufferRenderGL& operator = (const cl_mem& rhs) + BufferRenderGL& operator=(const cl_mem& rhs) { Buffer::operator=(rhs); return *this; @@ -3407,11 +3621,11 @@ public: //! \brief Wrapper for clGetGLObjectInfo(). cl_int getObjectInfo( - cl_gl_object_type *type, - GLuint * gl_object_name) + cl_gl_object_type* type, + GLuint* gl_object_name) { return detail::errHandler( - ::clGetGLObjectInfo(object_,type,gl_object_name), + ::clGetGLObjectInfo(object_, type, gl_object_name), __GET_GL_OBJECT_INFO_ERR); } }; @@ -3426,29 +3640,30 @@ class Image : public Memory { protected: //! \brief Default constructor - initializes to NULL. - Image() : Memory() { } + Image() : Memory() {} /*! \brief Copy constructor - performs shallow copy. * * See Memory for further details. */ - Image(const Image& image) : Memory(image) { } + Image(const Image& image) : Memory(image) {} /*! \brief Constructor from cl_mem - takes ownership. * * See Memory for further details. */ - __CL_EXPLICIT_CONSTRUCTORS Image(const cl_mem& image) : Memory(image) { } + __CL_EXPLICIT_CONSTRUCTORS Image(const cl_mem& image) : Memory(image) {} /*! \brief Assignment from Image - performs shallow copy. * * See Memory for further details. */ - Image& operator = (const Image& rhs) + Image& operator=(const Image& rhs) { - if (this != &rhs) { - Memory::operator=(rhs); - } + if (this != &rhs) + { + Memory::operator=(rhs); + } return *this; } @@ -3456,7 +3671,7 @@ protected: * * See Memory for further details. */ - Image& operator = (const cl_mem& rhs) + Image& operator=(const cl_mem& rhs) { Memory::operator=(rhs); return *this; @@ -3471,18 +3686,19 @@ public: detail::getInfo(&::clGetImageInfo, object_, name, param), __GET_IMAGE_INFO_ERR); } - + //! \brief Wrapper for clGetImageInfo() that returns by value. - template typename - detail::param_traits::param_type + template + typename detail::param_traits::param_type getImageInfo(cl_int* err = NULL) const { typename detail::param_traits< detail::cl_image_info, name>::param_type param; cl_int result = getImageInfo(name, ¶m); - if (err != NULL) { - *err = result; - } + if (err != NULL) + { + *err = result; + } return param; } }; @@ -3518,43 +3734,45 @@ public: desc.num_samples = 0; desc.buffer = 0; object_ = ::clCreateImage( - context(), - flags, - &format, - &desc, - host_ptr, + context(), + flags, + &format, + &desc, + host_ptr, &error); detail::errHandler(error, __CREATE_IMAGE_ERR); - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } } //! \brief Default constructor - initializes to NULL. - Image1D() { } + Image1D() {} /*! \brief Copy constructor - performs shallow copy. * * See Memory for further details. */ - Image1D(const Image1D& image1D) : Image(image1D) { } + Image1D(const Image1D& image1D) : Image(image1D) {} /*! \brief Constructor from cl_mem - takes ownership. * * See Memory for further details. */ - __CL_EXPLICIT_CONSTRUCTORS Image1D(const cl_mem& image1D) : Image(image1D) { } + __CL_EXPLICIT_CONSTRUCTORS Image1D(const cl_mem& image1D) : Image(image1D) {} /*! \brief Assignment from Image1D - performs shallow copy. * * See Memory for further details. */ - Image1D& operator = (const Image1D& rhs) + Image1D& operator=(const Image1D& rhs) { - if (this != &rhs) { - Image::operator=(rhs); - } + if (this != &rhs) + { + Image::operator=(rhs); + } return *this; } @@ -3562,7 +3780,7 @@ public: * * See Memory for further details. */ - Image1D& operator = (const cl_mem& rhs) + Image1D& operator=(const cl_mem& rhs) { Image::operator=(rhs); return *this; @@ -3580,7 +3798,7 @@ public: cl_mem_flags flags, ImageFormat format, ::size_t width, - const Buffer &buffer, + const Buffer& buffer, cl_int* err = NULL) { cl_int error; @@ -3592,34 +3810,36 @@ public: desc.num_samples = 0; desc.buffer = buffer(); object_ = ::clCreateImage( - context(), - flags, - &format, - &desc, - NULL, + context(), + flags, + &format, + &desc, + NULL, &error); detail::errHandler(error, __CREATE_IMAGE_ERR); - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } } - Image1DBuffer() { } + Image1DBuffer() {} - Image1DBuffer(const Image1DBuffer& image1D) : Image(image1D) { } + Image1DBuffer(const Image1DBuffer& image1D) : Image(image1D) {} - __CL_EXPLICIT_CONSTRUCTORS Image1DBuffer(const cl_mem& image1D) : Image(image1D) { } + __CL_EXPLICIT_CONSTRUCTORS Image1DBuffer(const cl_mem& image1D) : Image(image1D) {} - Image1DBuffer& operator = (const Image1DBuffer& rhs) + Image1DBuffer& operator=(const Image1DBuffer& rhs) { - if (this != &rhs) { - Image::operator=(rhs); - } + if (this != &rhs) + { + Image::operator=(rhs); + } return *this; } - Image1DBuffer& operator = (const cl_mem& rhs) + Image1DBuffer& operator=(const cl_mem& rhs) { Image::operator=(rhs); return *this; @@ -3652,40 +3872,42 @@ public: desc.num_samples = 0; desc.buffer = 0; object_ = ::clCreateImage( - context(), - flags, - &format, - &desc, - host_ptr, + context(), + flags, + &format, + &desc, + host_ptr, &error); detail::errHandler(error, __CREATE_IMAGE_ERR); - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } } - Image1DArray() { } + Image1DArray() {} - Image1DArray(const Image1DArray& imageArray) : Image(imageArray) { } + Image1DArray(const Image1DArray& imageArray) : Image(imageArray) {} - __CL_EXPLICIT_CONSTRUCTORS Image1DArray(const cl_mem& imageArray) : Image(imageArray) { } + __CL_EXPLICIT_CONSTRUCTORS Image1DArray(const cl_mem& imageArray) : Image(imageArray) {} - Image1DArray& operator = (const Image1DArray& rhs) + Image1DArray& operator=(const Image1DArray& rhs) { - if (this != &rhs) { - Image::operator=(rhs); - } + if (this != &rhs) + { + Image::operator=(rhs); + } return *this; } - Image1DArray& operator = (const cl_mem& rhs) + Image1DArray& operator=(const cl_mem& rhs) { Image::operator=(rhs); return *this; } }; -#endif // #if defined(CL_VERSION_1_2) +#endif // #if defined(CL_VERSION_1_2) /*! \brief Class interface for 2D Image Memory objects. @@ -3718,7 +3940,7 @@ public: // Run-time decision based on the actual platform { cl_uint version = detail::getContextPlatformVersion(context()); - useCreateImage = (version >= 0x10002); // OpenCL 1.2 or above + useCreateImage = (version >= 0x10002); // OpenCL 1.2 or above } #elif defined(CL_VERSION_1_2) useCreateImage = true; @@ -3728,67 +3950,70 @@ public: #if defined(CL_VERSION_1_2) if (useCreateImage) - { - cl_image_desc desc; - desc.image_type = CL_MEM_OBJECT_IMAGE2D; - desc.image_width = width; - desc.image_height = height; - desc.image_row_pitch = row_pitch; - desc.num_mip_levels = 0; - desc.num_samples = 0; - desc.buffer = 0; - object_ = ::clCreateImage( - context(), - flags, - &format, - &desc, - host_ptr, - &error); + { + cl_image_desc desc; + desc.image_type = CL_MEM_OBJECT_IMAGE2D; + desc.image_width = width; + desc.image_height = height; + desc.image_row_pitch = row_pitch; + desc.num_mip_levels = 0; + desc.num_samples = 0; + desc.buffer = 0; + object_ = ::clCreateImage( + context(), + flags, + &format, + &desc, + host_ptr, + &error); - detail::errHandler(error, __CREATE_IMAGE_ERR); - if (err != NULL) { - *err = error; + detail::errHandler(error, __CREATE_IMAGE_ERR); + if (err != NULL) + { + *err = error; + } } - } -#endif // #if defined(CL_VERSION_1_2) +#endif // #if defined(CL_VERSION_1_2) #if !defined(CL_VERSION_1_2) || defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) if (!useCreateImage) - { - object_ = ::clCreateImage2D( - context(), flags,&format, width, height, row_pitch, host_ptr, &error); + { + object_ = ::clCreateImage2D( + context(), flags, &format, width, height, row_pitch, host_ptr, &error); - detail::errHandler(error, __CREATE_IMAGE2D_ERR); - if (err != NULL) { - *err = error; + detail::errHandler(error, __CREATE_IMAGE2D_ERR); + if (err != NULL) + { + *err = error; + } } - } -#endif // #if !defined(CL_VERSION_1_2) || defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) +#endif // #if !defined(CL_VERSION_1_2) || defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) } //! \brief Default constructor - initializes to NULL. - Image2D() { } + Image2D() {} /*! \brief Copy constructor - performs shallow copy. * * See Memory for further details. */ - Image2D(const Image2D& image2D) : Image(image2D) { } + Image2D(const Image2D& image2D) : Image(image2D) {} /*! \brief Constructor from cl_mem - takes ownership. * * See Memory for further details. */ - __CL_EXPLICIT_CONSTRUCTORS Image2D(const cl_mem& image2D) : Image(image2D) { } + __CL_EXPLICIT_CONSTRUCTORS Image2D(const cl_mem& image2D) : Image(image2D) {} /*! \brief Assignment from Image2D - performs shallow copy. * * See Memory for further details. */ - Image2D& operator = (const Image2D& rhs) + Image2D& operator=(const Image2D& rhs) { - if (this != &rhs) { - Image::operator=(rhs); - } + if (this != &rhs) + { + Image::operator=(rhs); + } return *this; } @@ -3796,7 +4021,7 @@ public: * * See Memory for further details. */ - Image2D& operator = (const cl_mem& rhs) + Image2D& operator=(const cl_mem& rhs) { Image::operator=(rhs); return *this; @@ -3826,9 +4051,9 @@ public: const Context& context, cl_mem_flags flags, GLenum target, - GLint miplevel, + GLint miplevel, GLuint texobj, - cl_int * err = NULL) + cl_int* err = NULL) { cl_int error; object_ = ::clCreateFromGLTexture2D( @@ -3840,36 +4065,37 @@ public: &error); detail::errHandler(error, __CREATE_GL_TEXTURE_2D_ERR); - if (err != NULL) { - *err = error; - } - + if (err != NULL) + { + *err = error; + } } - + //! \brief Default constructor - initializes to NULL. - Image2DGL() : Image2D() { } + Image2DGL() : Image2D() {} /*! \brief Copy constructor - performs shallow copy. * * See Memory for further details. */ - Image2DGL(const Image2DGL& image) : Image2D(image) { } + Image2DGL(const Image2DGL& image) : Image2D(image) {} /*! \brief Constructor from cl_mem - takes ownership. * * See Memory for further details. */ - __CL_EXPLICIT_CONSTRUCTORS Image2DGL(const cl_mem& image) : Image2D(image) { } + __CL_EXPLICIT_CONSTRUCTORS Image2DGL(const cl_mem& image) : Image2D(image) {} /*! \brief Assignment from Image2DGL - performs shallow copy. * * See Memory for further details. */ - Image2DGL& operator = (const Image2DGL& rhs) + Image2DGL& operator=(const Image2DGL& rhs) { - if (this != &rhs) { - Image2D::operator=(rhs); - } + if (this != &rhs) + { + Image2D::operator=(rhs); + } return *this; } @@ -3877,13 +4103,13 @@ public: * * See Memory for further details. */ - Image2DGL& operator = (const cl_mem& rhs) + Image2DGL& operator=(const cl_mem& rhs) { Image2D::operator=(rhs); return *this; } }; -#endif // #if !defined(CL_VERSION_1_2) +#endif // #if !defined(CL_VERSION_1_2) #if defined(CL_VERSION_1_2) /*! \class Image2DArray @@ -3916,40 +4142,42 @@ public: desc.num_samples = 0; desc.buffer = 0; object_ = ::clCreateImage( - context(), - flags, - &format, - &desc, - host_ptr, + context(), + flags, + &format, + &desc, + host_ptr, &error); detail::errHandler(error, __CREATE_IMAGE_ERR); - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } } - Image2DArray() { } + Image2DArray() {} - Image2DArray(const Image2DArray& imageArray) : Image(imageArray) { } + Image2DArray(const Image2DArray& imageArray) : Image(imageArray) {} - __CL_EXPLICIT_CONSTRUCTORS Image2DArray(const cl_mem& imageArray) : Image(imageArray) { } + __CL_EXPLICIT_CONSTRUCTORS Image2DArray(const cl_mem& imageArray) : Image(imageArray) {} - Image2DArray& operator = (const Image2DArray& rhs) + Image2DArray& operator=(const Image2DArray& rhs) { - if (this != &rhs) { - Image::operator=(rhs); - } + if (this != &rhs) + { + Image::operator=(rhs); + } return *this; } - Image2DArray& operator = (const cl_mem& rhs) + Image2DArray& operator=(const cl_mem& rhs) { Image::operator=(rhs); return *this; } }; -#endif // #if defined(CL_VERSION_1_2) +#endif // #if defined(CL_VERSION_1_2) /*! \brief Class interface for 3D Image Memory objects. * @@ -3983,7 +4211,7 @@ public: // Run-time decision based on the actual platform { cl_uint version = detail::getContextPlatformVersion(context()); - useCreateImage = (version >= 0x10002); // OpenCL 1.2 or above + useCreateImage = (version >= 0x10002); // OpenCL 1.2 or above } #elif defined(CL_VERSION_1_2) useCreateImage = true; @@ -3993,70 +4221,73 @@ public: #if defined(CL_VERSION_1_2) if (useCreateImage) - { - cl_image_desc desc; - desc.image_type = CL_MEM_OBJECT_IMAGE3D; - desc.image_width = width; - desc.image_height = height; - desc.image_depth = depth; - desc.image_row_pitch = row_pitch; - desc.image_slice_pitch = slice_pitch; - desc.num_mip_levels = 0; - desc.num_samples = 0; - desc.buffer = 0; - object_ = ::clCreateImage( - context(), - flags, - &format, - &desc, - host_ptr, - &error); + { + cl_image_desc desc; + desc.image_type = CL_MEM_OBJECT_IMAGE3D; + desc.image_width = width; + desc.image_height = height; + desc.image_depth = depth; + desc.image_row_pitch = row_pitch; + desc.image_slice_pitch = slice_pitch; + desc.num_mip_levels = 0; + desc.num_samples = 0; + desc.buffer = 0; + object_ = ::clCreateImage( + context(), + flags, + &format, + &desc, + host_ptr, + &error); - detail::errHandler(error, __CREATE_IMAGE_ERR); - if (err != NULL) { - *err = error; + detail::errHandler(error, __CREATE_IMAGE_ERR); + if (err != NULL) + { + *err = error; + } } - } #endif // #if defined(CL_VERSION_1_2) #if !defined(CL_VERSION_1_2) || defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) if (!useCreateImage) - { - object_ = ::clCreateImage3D( - context(), flags, &format, width, height, depth, row_pitch, - slice_pitch, host_ptr, &error); + { + object_ = ::clCreateImage3D( + context(), flags, &format, width, height, depth, row_pitch, + slice_pitch, host_ptr, &error); - detail::errHandler(error, __CREATE_IMAGE3D_ERR); - if (err != NULL) { - *err = error; + detail::errHandler(error, __CREATE_IMAGE3D_ERR); + if (err != NULL) + { + *err = error; + } } - } -#endif // #if !defined(CL_VERSION_1_2) || defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) +#endif // #if !defined(CL_VERSION_1_2) || defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) } //! \brief Default constructor - initializes to NULL. - Image3D() { } + Image3D() {} /*! \brief Copy constructor - performs shallow copy. * * See Memory for further details. */ - Image3D(const Image3D& image3D) : Image(image3D) { } + Image3D(const Image3D& image3D) : Image(image3D) {} /*! \brief Constructor from cl_mem - takes ownership. * * See Memory for further details. */ - __CL_EXPLICIT_CONSTRUCTORS Image3D(const cl_mem& image3D) : Image(image3D) { } + __CL_EXPLICIT_CONSTRUCTORS Image3D(const cl_mem& image3D) : Image(image3D) {} /*! \brief Assignment from Image3D - performs shallow copy. * * See Memory for further details. */ - Image3D& operator = (const Image3D& rhs) + Image3D& operator=(const Image3D& rhs) { - if (this != &rhs) { - Image::operator=(rhs); - } + if (this != &rhs) + { + Image::operator=(rhs); + } return *this; } @@ -4064,7 +4295,7 @@ public: * * See Memory for further details. */ - Image3D& operator = (const cl_mem& rhs) + Image3D& operator=(const cl_mem& rhs) { Image::operator=(rhs); return *this; @@ -4092,9 +4323,9 @@ public: const Context& context, cl_mem_flags flags, GLenum target, - GLint miplevel, + GLint miplevel, GLuint texobj, - cl_int * err = NULL) + cl_int* err = NULL) { cl_int error; object_ = ::clCreateFromGLTexture3D( @@ -4106,35 +4337,37 @@ public: &error); detail::errHandler(error, __CREATE_GL_TEXTURE_3D_ERR); - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } } //! \brief Default constructor - initializes to NULL. - Image3DGL() : Image3D() { } + Image3DGL() : Image3D() {} /*! \brief Copy constructor - performs shallow copy. * * See Memory for further details. */ - Image3DGL(const Image3DGL& image) : Image3D(image) { } + Image3DGL(const Image3DGL& image) : Image3D(image) {} /*! \brief Constructor from cl_mem - takes ownership. * * See Memory for further details. */ - __CL_EXPLICIT_CONSTRUCTORS Image3DGL(const cl_mem& image) : Image3D(image) { } + __CL_EXPLICIT_CONSTRUCTORS Image3DGL(const cl_mem& image) : Image3D(image) {} /*! \brief Assignment from Image3DGL - performs shallow copy. * * See Memory for further details. */ - Image3DGL& operator = (const Image3DGL& rhs) + Image3DGL& operator=(const Image3DGL& rhs) { - if (this != &rhs) { - Image3D::operator=(rhs); - } + if (this != &rhs) + { + Image3D::operator=(rhs); + } return *this; } @@ -4142,13 +4375,13 @@ public: * * See Memory for further details. */ - Image3DGL& operator = (const cl_mem& rhs) + Image3DGL& operator=(const cl_mem& rhs) { Image3D::operator=(rhs); return *this; } }; -#endif // #if !defined(CL_VERSION_1_2) +#endif // #if !defined(CL_VERSION_1_2) #if defined(CL_VERSION_1_2) /*! \class ImageGL @@ -4164,46 +4397,48 @@ public: const Context& context, cl_mem_flags flags, GLenum target, - GLint miplevel, + GLint miplevel, GLuint texobj, - cl_int * err = NULL) + cl_int* err = NULL) { cl_int error; object_ = ::clCreateFromGLTexture( - context(), - flags, + context(), + flags, target, miplevel, texobj, &error); detail::errHandler(error, __CREATE_GL_TEXTURE_ERR); - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } } - ImageGL() : Image() { } + ImageGL() : Image() {} - ImageGL(const ImageGL& image) : Image(image) { } + ImageGL(const ImageGL& image) : Image(image) {} - __CL_EXPLICIT_CONSTRUCTORS ImageGL(const cl_mem& image) : Image(image) { } + __CL_EXPLICIT_CONSTRUCTORS ImageGL(const cl_mem& image) : Image(image) {} - ImageGL& operator = (const ImageGL& rhs) + ImageGL& operator=(const ImageGL& rhs) { - if (this != &rhs) { - Image::operator=(rhs); - } + if (this != &rhs) + { + Image::operator=(rhs); + } return *this; } - ImageGL& operator = (const cl_mem& rhs) + ImageGL& operator=(const cl_mem& rhs) { Image::operator=(rhs); return *this; } }; -#endif // #if defined(CL_VERSION_1_2) +#endif // #if defined(CL_VERSION_1_2) /*! \brief Class interface for cl_sampler. * @@ -4220,10 +4455,10 @@ public: * * This calls clReleaseSampler() on the value held by this instance. */ - ~Sampler() { } + ~Sampler() {} //! \brief Default constructor - initializes to NULL. - Sampler() { } + Sampler() {} /*! \brief Constructs a Sampler in a specified context. * @@ -4238,41 +4473,43 @@ public: { cl_int error; object_ = ::clCreateSampler( - context(), + context(), normalized_coords, addressing_mode, filter_mode, &error); detail::errHandler(error, __CREATE_SAMPLER_ERR); - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } } /*! \brief Copy constructor - performs shallow copy. * * This calls clRetainSampler() on the parameter's cl_sampler. */ - Sampler(const Sampler& sampler) : detail::Wrapper(sampler) { } + Sampler(const Sampler& sampler) : detail::Wrapper(sampler) {} /*! \brief Constructor from cl_sampler - takes ownership. * * This effectively transfers ownership of a refcount on the cl_sampler * into the new Sampler object. */ - Sampler(const cl_sampler& sampler) : detail::Wrapper(sampler) { } + Sampler(const cl_sampler& sampler) : detail::Wrapper(sampler) {} /*! \brief Assignment operator from Sampler. * * This calls clRetainSampler() on the parameter and clReleaseSampler() * on the previous value held by this instance. */ - Sampler& operator = (const Sampler& rhs) + Sampler& operator=(const Sampler& rhs) { - if (this != &rhs) { - detail::Wrapper::operator=(rhs); - } + if (this != &rhs) + { + detail::Wrapper::operator=(rhs); + } return *this; } @@ -4281,7 +4518,7 @@ public: * This effectively transfers ownership of a refcount on the rhs and calls * clReleaseSampler() on the value previously held by this instance. */ - Sampler& operator = (const cl_sampler& rhs) + Sampler& operator=(const cl_sampler& rhs) { detail::Wrapper::operator=(rhs); return *this; @@ -4297,16 +4534,17 @@ public: } //! \brief Wrapper for clGetSamplerInfo() that returns by value. - template typename - detail::param_traits::param_type + template + typename detail::param_traits::param_type getInfo(cl_int* err = NULL) const { typename detail::param_traits< detail::cl_sampler_info, name>::param_type param; cl_int result = getInfo(name, ¶m); - if (err != NULL) { - *err = result; - } + if (err != NULL) + { + *err = result; + } return param; } }; @@ -4326,7 +4564,8 @@ public: //! \brief Default constructor - resulting range has zero dimensions. NDRange() : dimensions_(0) - { } + { + } //! \brief Constructs one-dimensional range. NDRange(::size_t size0) @@ -4356,8 +4595,9 @@ public: * * \returns a pointer to the size of the first dimension. */ - operator const ::size_t*() const { - return (const ::size_t*) sizes_; + operator const ::size_t*() const + { + return (const ::size_t*)sizes_; } //! \brief Queries the number of dimensions in the range. @@ -4373,8 +4613,8 @@ struct LocalSpaceArg ::size_t size_; }; -namespace detail { - +namespace detail +{ template struct KernelArgumentHandler { @@ -4389,7 +4629,7 @@ struct KernelArgumentHandler static void* ptr(LocalSpaceArg&) { return NULL; } }; -} +} // namespace detail //! \endcond /*! __local @@ -4401,7 +4641,7 @@ __local(::size_t size) CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED; inline LocalSpaceArg __local(::size_t size) { - LocalSpaceArg ret = { size }; + LocalSpaceArg ret = {size}; return ret; } @@ -4411,7 +4651,7 @@ __local(::size_t size) inline LocalSpaceArg Local(::size_t size) { - LocalSpaceArg ret = { size }; + LocalSpaceArg ret = {size}; return ret; } @@ -4434,34 +4674,35 @@ public: * * This calls clReleaseKernel() on the value held by this instance. */ - ~Kernel() { } + ~Kernel() {} //! \brief Default constructor - initializes to NULL. - Kernel() { } + Kernel() {} /*! \brief Copy constructor - performs shallow copy. * * This calls clRetainKernel() on the parameter's cl_kernel. */ - Kernel(const Kernel& kernel) : detail::Wrapper(kernel) { } + Kernel(const Kernel& kernel) : detail::Wrapper(kernel) {} /*! \brief Constructor from cl_kernel - takes ownership. * * This effectively transfers ownership of a refcount on the cl_kernel * into the new Kernel object. */ - __CL_EXPLICIT_CONSTRUCTORS Kernel(const cl_kernel& kernel) : detail::Wrapper(kernel) { } + __CL_EXPLICIT_CONSTRUCTORS Kernel(const cl_kernel& kernel) : detail::Wrapper(kernel) {} /*! \brief Assignment operator from Kernel. * * This calls clRetainKernel() on the parameter and clReleaseKernel() * on the previous value held by this instance. */ - Kernel& operator = (const Kernel& rhs) + Kernel& operator=(const Kernel& rhs) { - if (this != &rhs) { - detail::Wrapper::operator=(rhs); - } + if (this != &rhs) + { + detail::Wrapper::operator=(rhs); + } return *this; } @@ -4470,7 +4711,7 @@ public: * This effectively transfers ownership of a refcount on the rhs and calls * clReleaseKernel() on the value previously held by this instance. */ - Kernel& operator = (const cl_kernel& rhs) + Kernel& operator=(const cl_kernel& rhs) { detail::Wrapper::operator=(rhs); return *this; @@ -4484,16 +4725,17 @@ public: __GET_KERNEL_INFO_ERR); } - template typename - detail::param_traits::param_type + template + typename detail::param_traits::param_type getInfo(cl_int* err = NULL) const { typename detail::param_traits< detail::cl_kernel_info, name>::param_type param; cl_int result = getInfo(name, ¶m); - if (err != NULL) { - *err = result; - } + if (err != NULL) + { + *err = result; + } return param; } @@ -4506,19 +4748,20 @@ public: __GET_KERNEL_ARG_INFO_ERR); } - template typename - detail::param_traits::param_type + template + typename detail::param_traits::param_type getArgInfo(cl_uint argIndex, cl_int* err = NULL) const { typename detail::param_traits< detail::cl_kernel_arg_info, name>::param_type param; cl_int result = getArgInfo(argIndex, name, ¶m); - if (err != NULL) { - *err = result; - } + if (err != NULL) + { + *err = result; + } return param; } -#endif // #if defined(CL_VERSION_1_2) +#endif // #if defined(CL_VERSION_1_2) template cl_int getWorkGroupInfo( @@ -4527,19 +4770,20 @@ public: return detail::errHandler( detail::getInfo( &::clGetKernelWorkGroupInfo, object_, device(), name, param), - __GET_KERNEL_WORK_GROUP_INFO_ERR); + __GET_KERNEL_WORK_GROUP_INFO_ERR); } - template typename - detail::param_traits::param_type - getWorkGroupInfo(const Device& device, cl_int* err = NULL) const + template + typename detail::param_traits::param_type + getWorkGroupInfo(const Device& device, cl_int* err = NULL) const { typename detail::param_traits< - detail::cl_kernel_work_group_info, name>::param_type param; + detail::cl_kernel_work_group_info, name>::param_type param; cl_int result = getWorkGroupInfo(device, name, ¶m); - if (err != NULL) { - *err = result; - } + if (err != NULL) + { + *err = result; + } return param; } @@ -4578,8 +4822,8 @@ public: { cl_int error; - const char * strings = source.c_str(); - const ::size_t length = source.size(); + const char* strings = source.c_str(); + const ::size_t length = source.size(); Context context = Context::getDefault(err); @@ -4588,33 +4832,34 @@ public: detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR); - if (error == CL_SUCCESS) { + if (error == CL_SUCCESS) + { + error = ::clBuildProgram( + object_, + 0, + NULL, + "", + NULL, + NULL); - error = ::clBuildProgram( - object_, - 0, - NULL, - "", - NULL, - NULL); + detail::errHandler(error, __BUILD_PROGRAM_ERR); + } - detail::errHandler(error, __BUILD_PROGRAM_ERR); - } - - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } } Program( const STRING_CLASS& source, - bool build, + bool build, cl_int* err = NULL) { cl_int error; - const char * strings = source.c_str(); - const ::size_t length = source.size(); + const char* strings = source.c_str(); + const ::size_t length = source.size(); Context context = Context::getDefault(err); @@ -4623,22 +4868,23 @@ public: detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR); - if (error == CL_SUCCESS && build) { + if (error == CL_SUCCESS && build) + { + error = ::clBuildProgram( + object_, + 0, + NULL, + "", + NULL, + NULL); - error = ::clBuildProgram( - object_, - 0, - NULL, - "", - NULL, - NULL); + detail::errHandler(error, __BUILD_PROGRAM_ERR); + } - detail::errHandler(error, __BUILD_PROGRAM_ERR); - } - - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } } Program( @@ -4649,30 +4895,31 @@ public: { cl_int error; - const char * strings = source.c_str(); - const ::size_t length = source.size(); + const char* strings = source.c_str(); + const ::size_t length = source.size(); object_ = ::clCreateProgramWithSource( context(), (cl_uint)1, &strings, &length, &error); detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR); - if (error == CL_SUCCESS && build) { + if (error == CL_SUCCESS && build) + { + error = ::clBuildProgram( + object_, + 0, + NULL, + "", + NULL, + NULL); - error = ::clBuildProgram( - object_, - 0, - NULL, - "", - NULL, - NULL); + detail::errHandler(error, __BUILD_PROGRAM_ERR); + } - detail::errHandler(error, __BUILD_PROGRAM_ERR); - } - - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } } Program( @@ -4683,21 +4930,23 @@ public: cl_int error; const ::size_t n = (::size_t)sources.size(); - ::size_t* lengths = (::size_t*) alloca(n * sizeof(::size_t)); - const char** strings = (const char**) alloca(n * sizeof(const char*)); + ::size_t* lengths = (::size_t*)alloca(n * sizeof(::size_t)); + const char** strings = (const char**)alloca(n * sizeof(const char*)); - for (::size_t i = 0; i < n; ++i) { - strings[i] = sources[(int)i].first; - lengths[i] = sources[(int)i].second; - } + for (::size_t i = 0; i < n; ++i) + { + strings[i] = sources[(int)i].first; + lengths[i] = sources[(int)i].second; + } object_ = ::clCreateProgramWithSource( context(), (cl_uint)n, strings, lengths, &error); detail::errHandler(error, __CREATE_PROGRAM_WITH_SOURCE_ERR); - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } } /** @@ -4727,50 +4976,54 @@ public: cl_int* err = NULL) { cl_int error; - + const ::size_t numDevices = devices.size(); - + // Catch size mismatch early and return - if(binaries.size() != numDevices) { - error = CL_INVALID_VALUE; - detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR); - if (err != NULL) { - *err = error; + if (binaries.size() != numDevices) + { + error = CL_INVALID_VALUE; + detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR); + if (err != NULL) + { + *err = error; + } + return; } - return; - } - ::size_t* lengths = (::size_t*) alloca(numDevices * sizeof(::size_t)); - const unsigned char** images = (const unsigned char**) alloca(numDevices * sizeof(const unsigned char**)); + ::size_t* lengths = (::size_t*)alloca(numDevices * sizeof(::size_t)); + const unsigned char** images = (const unsigned char**)alloca(numDevices * sizeof(const unsigned char**)); - for (::size_t i = 0; i < numDevices; ++i) { - images[i] = (const unsigned char*)binaries[i].first; - lengths[i] = binaries[(int)i].second; - } + for (::size_t i = 0; i < numDevices; ++i) + { + images[i] = (const unsigned char*)binaries[i].first; + lengths[i] = binaries[(int)i].second; + } - cl_device_id* deviceIDs = (cl_device_id*) alloca(numDevices * sizeof(cl_device_id)); - for( ::size_t deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) { - deviceIDs[deviceIndex] = (devices[deviceIndex])(); - } + cl_device_id* deviceIDs = (cl_device_id*)alloca(numDevices * sizeof(cl_device_id)); + for (::size_t deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex) + { + deviceIDs[deviceIndex] = (devices[deviceIndex])(); + } + + if (binaryStatus) + { + binaryStatus->resize(numDevices); + } - if(binaryStatus) { - binaryStatus->resize(numDevices); - } - object_ = ::clCreateProgramWithBinary( - context(), (cl_uint) devices.size(), + context(), (cl_uint)devices.size(), deviceIDs, - lengths, images, binaryStatus != NULL - ? &binaryStatus->front() - : NULL, &error); + lengths, images, binaryStatus != NULL ? &binaryStatus->front() : NULL, &error); detail::errHandler(error, __CREATE_PROGRAM_WITH_BINARY_ERR); - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } } - + #if defined(CL_VERSION_1_2) /** * Create program using builtin kernels. @@ -4786,40 +5039,45 @@ public: ::size_t numDevices = devices.size(); - cl_device_id* deviceIDs = (cl_device_id*) alloca(numDevices * sizeof(cl_device_id)); - for( ::size_t deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) { - deviceIDs[deviceIndex] = (devices[deviceIndex])(); - } - + cl_device_id* deviceIDs = (cl_device_id*)alloca(numDevices * sizeof(cl_device_id)); + for (::size_t deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex) + { + deviceIDs[deviceIndex] = (devices[deviceIndex])(); + } + object_ = ::clCreateProgramWithBuiltInKernels( - context(), - (cl_uint) devices.size(), + context(), + (cl_uint)devices.size(), deviceIDs, - kernelNames.c_str(), + kernelNames.c_str(), &error); detail::errHandler(error, __CREATE_PROGRAM_WITH_BUILT_IN_KERNELS_ERR); - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } } -#endif // #if defined(CL_VERSION_1_2) +#endif // #if defined(CL_VERSION_1_2) - Program() { } - - Program(const Program& program) : detail::Wrapper(program) { } - - __CL_EXPLICIT_CONSTRUCTORS Program(const cl_program& program) : detail::Wrapper(program) { } - - Program& operator = (const Program& rhs) + Program() { - if (this != &rhs) { - detail::Wrapper::operator=(rhs); - } + } + + Program(const Program& program) : detail::Wrapper(program) {} + + __CL_EXPLICIT_CONSTRUCTORS Program(const cl_program& program) : detail::Wrapper(program) {} + + Program& operator=(const Program& rhs) + { + if (this != &rhs) + { + detail::Wrapper::operator=(rhs); + } return *this; } - Program& operator = (const cl_program& rhs) + Program& operator=(const cl_program& rhs) { detail::Wrapper::operator=(rhs); return *this; @@ -4828,30 +5086,31 @@ public: cl_int build( const VECTOR_CLASS& devices, const char* options = NULL, - void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL, + void(CL_CALLBACK* notifyFptr)(cl_program, void*) = NULL, void* data = NULL) const { ::size_t numDevices = devices.size(); - cl_device_id* deviceIDs = (cl_device_id*) alloca(numDevices * sizeof(cl_device_id)); - for( ::size_t deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex ) { - deviceIDs[deviceIndex] = (devices[deviceIndex])(); - } + cl_device_id* deviceIDs = (cl_device_id*)alloca(numDevices * sizeof(cl_device_id)); + for (::size_t deviceIndex = 0; deviceIndex < numDevices; ++deviceIndex) + { + deviceIDs[deviceIndex] = (devices[deviceIndex])(); + } return detail::errHandler( ::clBuildProgram( object_, (cl_uint) - devices.size(), + devices.size(), deviceIDs, options, notifyFptr, data), - __BUILD_PROGRAM_ERR); + __BUILD_PROGRAM_ERR); } cl_int build( const char* options = NULL, - void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL, + void(CL_CALLBACK* notifyFptr)(cl_program, void*) = NULL, void* data = NULL) const { return detail::errHandler( @@ -4862,13 +5121,13 @@ public: options, notifyFptr, data), - __BUILD_PROGRAM_ERR); + __BUILD_PROGRAM_ERR); } #if defined(CL_VERSION_1_2) - cl_int compile( + cl_int compile( const char* options = NULL, - void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL, + void(CL_CALLBACK* notifyFptr)(cl_program, void*) = NULL, void* data = NULL) const { return detail::errHandler( @@ -4877,12 +5136,12 @@ public: 0, NULL, options, - 0, - NULL, - NULL, + 0, + NULL, + NULL, notifyFptr, data), - __COMPILE_PROGRAM_ERR); + __COMPILE_PROGRAM_ERR); } #endif @@ -4894,16 +5153,17 @@ public: __GET_PROGRAM_INFO_ERR); } - template typename - detail::param_traits::param_type + template + typename detail::param_traits::param_type getInfo(cl_int* err = NULL) const { typename detail::param_traits< detail::cl_program_info, name>::param_type param; cl_int result = getInfo(name, ¶m); - if (err != NULL) { - *err = result; - } + if (err != NULL) + { + *err = result; + } return param; } @@ -4914,19 +5174,20 @@ public: return detail::errHandler( detail::getInfo( &::clGetProgramBuildInfo, object_, device(), name, param), - __GET_PROGRAM_BUILD_INFO_ERR); + __GET_PROGRAM_BUILD_INFO_ERR); } - template typename - detail::param_traits::param_type + template + typename detail::param_traits::param_type getBuildInfo(const Device& device, cl_int* err = NULL) const { typename detail::param_traits< detail::cl_program_build_info, name>::param_type param; cl_int result = getBuildInfo(device, name, ¶m); - if (err != NULL) { - *err = result; - } + if (err != NULL) + { + *err = result; + } return param; } @@ -4934,16 +5195,18 @@ public: { cl_uint numKernels; cl_int err = ::clCreateKernelsInProgram(object_, 0, NULL, &numKernels); - if (err != CL_SUCCESS) { - return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR); - } + if (err != CL_SUCCESS) + { + return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR); + } - Kernel* value = (Kernel*) alloca(numKernels * sizeof(Kernel)); + Kernel* value = (Kernel*)alloca(numKernels * sizeof(Kernel)); err = ::clCreateKernelsInProgram( - object_, numKernels, (cl_kernel*) value, NULL); - if (err != CL_SUCCESS) { - return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR); - } + object_, numKernels, (cl_kernel*)value, NULL); + if (err != CL_SUCCESS) + { + return detail::errHandler(err, __CREATE_KERNELS_IN_PROGRAM_ERR); + } kernels->assign(&value[0], &value[numKernels]); return CL_SUCCESS; @@ -4955,13 +5218,13 @@ inline Program linkProgram( Program input1, Program input2, const char* options = NULL, - void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL, + void(CL_CALLBACK* notifyFptr)(cl_program, void*) = NULL, void* data = NULL, - cl_int* err = NULL) + cl_int* err = NULL) { cl_int err_local = CL_SUCCESS; - cl_program programs[2] = { input1(), input2() }; + cl_program programs[2] = {input1(), input2()}; Context ctx = input1.getInfo(); @@ -4976,10 +5239,11 @@ inline Program linkProgram( data, &err_local); - detail::errHandler(err_local,__COMPILE_PROGRAM_ERR); - if (err != NULL) { - *err = err_local; - } + detail::errHandler(err_local, __COMPILE_PROGRAM_ERR); + if (err != NULL) + { + *err = err_local; + } return Program(prog); } @@ -4987,19 +5251,21 @@ inline Program linkProgram( inline Program linkProgram( VECTOR_CLASS inputPrograms, const char* options = NULL, - void (CL_CALLBACK * notifyFptr)(cl_program, void *) = NULL, + void(CL_CALLBACK* notifyFptr)(cl_program, void*) = NULL, void* data = NULL, - cl_int* err = NULL) + cl_int* err = NULL) { cl_int err_local = CL_SUCCESS; - cl_program * programs = (cl_program*) alloca(inputPrograms.size() * sizeof(cl_program)); + cl_program* programs = (cl_program*)alloca(inputPrograms.size() * sizeof(cl_program)); - if (programs != NULL) { - for (unsigned int i = 0; i < inputPrograms.size(); i++) { - programs[i] = inputPrograms[i](); + if (programs != NULL) + { + for (unsigned int i = 0; i < inputPrograms.size(); i++) + { + programs[i] = inputPrograms[i](); + } } - } cl_program prog = ::clLinkProgram( Context::getDefault()(), @@ -5012,32 +5278,34 @@ inline Program linkProgram( data, &err_local); - detail::errHandler(err_local,__COMPILE_PROGRAM_ERR); - if (err != NULL) { - *err = err_local; - } + detail::errHandler(err_local, __COMPILE_PROGRAM_ERR); + if (err != NULL) + { + *err = err_local; + } return Program(prog); } #endif -template<> -inline VECTOR_CLASS cl::Program::getInfo(cl_int* err) const +template <> +inline VECTOR_CLASS cl::Program::getInfo(cl_int* err) const { VECTOR_CLASS< ::size_t> sizes = getInfo(); - VECTOR_CLASS binaries; - for (VECTOR_CLASS< ::size_t>::iterator s = sizes.begin(); s != sizes.end(); ++s) - { - char *ptr = NULL; - if (*s != 0) - ptr = new char[*s]; - binaries.push_back(ptr); - } - + VECTOR_CLASS binaries; + for (VECTOR_CLASS< ::size_t>::iterator s = sizes.begin(); s != sizes.end(); ++s) + { + char* ptr = NULL; + if (*s != 0) + ptr = new char[*s]; + binaries.push_back(ptr); + } + cl_int result = getInfo(CL_PROGRAM_BINARIES, &binaries); - if (err != NULL) { - *err = result; - } + if (err != NULL) + { + *err = result; + } return binaries; } @@ -5048,10 +5316,10 @@ inline Kernel::Kernel(const Program& program, const char* name, cl_int* err) object_ = ::clCreateKernel(program(), name, &error); detail::errHandler(error, __CREATE_KERNEL_ERR); - if (err != NULL) { - *err = error; - } - + if (err != NULL) + { + *err = error; + } } /*! \class CommandQueue @@ -5063,8 +5331,9 @@ private: static volatile int default_initialized_; static CommandQueue default_; static volatile cl_int default_error_; + public: - CommandQueue( + CommandQueue( cl_command_queue_properties properties, cl_int* err = NULL) { @@ -5073,22 +5342,26 @@ public: Context context = Context::getDefault(&error); detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR); - if (error != CL_SUCCESS) { - if (err != NULL) { - *err = error; + if (error != CL_SUCCESS) + { + if (err != NULL) + { + *err = error; + } } - } - else { - Device device = context.getInfo()[0]; + else + { + Device device = context.getInfo()[0]; - object_ = ::clCreateCommandQueue( - context(), device(), properties, &error); + object_ = ::clCreateCommandQueue( + context(), device(), properties, &error); - detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR); - if (err != NULL) { - *err = error; + detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR); + if (err != NULL) + { + *err = error; + } } - } } CommandQueue( @@ -5102,56 +5375,66 @@ public: context(), device(), properties, &error); detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR); - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } } - static CommandQueue getDefault(cl_int * err = NULL) + static CommandQueue getDefault(cl_int* err = NULL) { int state = detail::compare_exchange( - &default_initialized_, + &default_initialized_, __DEFAULT_BEING_INITIALIZED, __DEFAULT_NOT_INITIALIZED); - - if (state & __DEFAULT_INITIALIZED) { - if (err != NULL) { - *err = default_error_; - } - return default_; - } - if (state & __DEFAULT_BEING_INITIALIZED) { - // Assume writes will propagate eventually... - while(default_initialized_ != __DEFAULT_INITIALIZED) { - detail::fence(); - } - - if (err != NULL) { - *err = default_error_; + if (state & __DEFAULT_INITIALIZED) + { + if (err != NULL) + { + *err = default_error_; + } + return default_; + } + + if (state & __DEFAULT_BEING_INITIALIZED) + { + // Assume writes will propagate eventually... + while (default_initialized_ != __DEFAULT_INITIALIZED) + { + detail::fence(); + } + + if (err != NULL) + { + *err = default_error_; + } + return default_; } - return default_; - } cl_int error; Context context = Context::getDefault(&error); detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR); - if (error != CL_SUCCESS) { - if (err != NULL) { - *err = error; + if (error != CL_SUCCESS) + { + if (err != NULL) + { + *err = error; + } } - } - else { - Device device = context.getInfo()[0]; + else + { + Device device = context.getInfo()[0]; - default_ = CommandQueue(context, device, 0, &error); + default_ = CommandQueue(context, device, 0, &error); - detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR); - if (err != NULL) { - *err = error; + detail::errHandler(error, __CREATE_COMMAND_QUEUE_ERR); + if (err != NULL) + { + *err = error; + } } - } detail::fence(); @@ -5161,28 +5444,29 @@ public: detail::fence(); - if (err != NULL) { - *err = default_error_; - } + if (err != NULL) + { + *err = default_error_; + } return default_; - } - CommandQueue() { } + CommandQueue() {} - CommandQueue(const CommandQueue& commandQueue) : detail::Wrapper(commandQueue) { } + CommandQueue(const CommandQueue& commandQueue) : detail::Wrapper(commandQueue) {} - CommandQueue(const cl_command_queue& commandQueue) : detail::Wrapper(commandQueue) { } + CommandQueue(const cl_command_queue& commandQueue) : detail::Wrapper(commandQueue) {} - CommandQueue& operator = (const CommandQueue& rhs) + CommandQueue& operator=(const CommandQueue& rhs) { - if (this != &rhs) { - detail::Wrapper::operator=(rhs); - } + if (this != &rhs) + { + detail::Wrapper::operator=(rhs); + } return *this; } - CommandQueue& operator = (const cl_command_queue& rhs) + CommandQueue& operator=(const cl_command_queue& rhs) { detail::Wrapper::operator=(rhs); return *this; @@ -5194,19 +5478,20 @@ public: return detail::errHandler( detail::getInfo( &::clGetCommandQueueInfo, object_, name, param), - __GET_COMMAND_QUEUE_INFO_ERR); + __GET_COMMAND_QUEUE_INFO_ERR); } - template typename - detail::param_traits::param_type + template + typename detail::param_traits::param_type getInfo(cl_int* err = NULL) const { typename detail::param_traits< detail::cl_command_queue_info, name>::param_type param; cl_int result = getInfo(name, ¶m); - if (err != NULL) { - *err = result; - } + if (err != NULL) + { + *err = result; + } return param; } @@ -5224,8 +5509,8 @@ public: ::clEnqueueReadBuffer( object_, buffer(), blocking, offset, size, ptr, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, (event != NULL) ? &tmp : NULL), __ENQUEUE_READ_BUFFER_ERR); @@ -5249,10 +5534,10 @@ public: ::clEnqueueWriteBuffer( object_, buffer(), blocking, offset, size, ptr, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, (event != NULL) ? &tmp : NULL), - __ENQUEUE_WRITE_BUFFER_ERR); + __ENQUEUE_WRITE_BUFFER_ERR); if (event != NULL && err == CL_SUCCESS) *event = tmp; @@ -5273,8 +5558,8 @@ public: cl_int err = detail::errHandler( ::clEnqueueCopyBuffer( object_, src(), dst(), src_offset, dst_offset, size, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, (event != NULL) ? &tmp : NULL), __ENQEUE_COPY_BUFFER_ERR); @@ -5294,28 +5579,28 @@ public: ::size_t buffer_slice_pitch, ::size_t host_row_pitch, ::size_t host_slice_pitch, - void *ptr, + void* ptr, const VECTOR_CLASS* events = NULL, Event* event = NULL) const { cl_event tmp; cl_int err = detail::errHandler( ::clEnqueueReadBufferRect( - object_, - buffer(), - blocking, - (const ::size_t *)buffer_offset, - (const ::size_t *)host_offset, - (const ::size_t *)region, + object_, + buffer(), + blocking, + (const ::size_t*)buffer_offset, + (const ::size_t*)host_offset, + (const ::size_t*)region, buffer_row_pitch, buffer_slice_pitch, host_row_pitch, host_slice_pitch, ptr, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, (event != NULL) ? &tmp : NULL), - __ENQUEUE_READ_BUFFER_RECT_ERR); + __ENQUEUE_READ_BUFFER_RECT_ERR); if (event != NULL && err == CL_SUCCESS) *event = tmp; @@ -5333,28 +5618,28 @@ public: ::size_t buffer_slice_pitch, ::size_t host_row_pitch, ::size_t host_slice_pitch, - void *ptr, + void* ptr, const VECTOR_CLASS* events = NULL, Event* event = NULL) const { cl_event tmp; cl_int err = detail::errHandler( ::clEnqueueWriteBufferRect( - object_, - buffer(), - blocking, - (const ::size_t *)buffer_offset, - (const ::size_t *)host_offset, - (const ::size_t *)region, + object_, + buffer(), + blocking, + (const ::size_t*)buffer_offset, + (const ::size_t*)host_offset, + (const ::size_t*)region, buffer_row_pitch, buffer_slice_pitch, host_row_pitch, host_slice_pitch, ptr, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, (event != NULL) ? &tmp : NULL), - __ENQUEUE_WRITE_BUFFER_RECT_ERR); + __ENQUEUE_WRITE_BUFFER_RECT_ERR); if (event != NULL && err == CL_SUCCESS) *event = tmp; @@ -5378,18 +5663,18 @@ public: cl_event tmp; cl_int err = detail::errHandler( ::clEnqueueCopyBufferRect( - object_, - src(), - dst(), - (const ::size_t *)src_origin, - (const ::size_t *)dst_origin, - (const ::size_t *)region, + object_, + src(), + dst(), + (const ::size_t*)src_origin, + (const ::size_t*)dst_origin, + (const ::size_t*)region, src_row_pitch, src_slice_pitch, dst_row_pitch, dst_slice_pitch, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, (event != NULL) ? &tmp : NULL), __ENQEUE_COPY_BUFFER_RECT_ERR); @@ -5406,7 +5691,7 @@ public: * \tparam PatternType The datatype of the pattern field. * The pattern type must be an accepted OpenCL data type. */ - template + template cl_int enqueueFillBuffer( const Buffer& buffer, PatternType pattern, @@ -5418,23 +5703,23 @@ public: cl_event tmp; cl_int err = detail::errHandler( ::clEnqueueFillBuffer( - object_, + object_, buffer(), static_cast(&pattern), - sizeof(PatternType), - offset, + sizeof(PatternType), + offset, size, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, (event != NULL) ? &tmp : NULL), - __ENQUEUE_FILL_BUFFER_ERR); + __ENQUEUE_FILL_BUFFER_ERR); if (event != NULL && err == CL_SUCCESS) *event = tmp; return err; } -#endif // #if defined(CL_VERSION_1_2) +#endif // #if defined(CL_VERSION_1_2) cl_int enqueueReadImage( const Image& image, @@ -5450,10 +5735,10 @@ public: cl_event tmp; cl_int err = detail::errHandler( ::clEnqueueReadImage( - object_, image(), blocking, (const ::size_t *) origin, - (const ::size_t *) region, row_pitch, slice_pitch, ptr, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + object_, image(), blocking, (const ::size_t*)origin, + (const ::size_t*)region, row_pitch, slice_pitch, ptr, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, (event != NULL) ? &tmp : NULL), __ENQUEUE_READ_IMAGE_ERR); @@ -5477,10 +5762,10 @@ public: cl_event tmp; cl_int err = detail::errHandler( ::clEnqueueWriteImage( - object_, image(), blocking, (const ::size_t *) origin, - (const ::size_t *) region, row_pitch, slice_pitch, ptr, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + object_, image(), blocking, (const ::size_t*)origin, + (const ::size_t*)region, row_pitch, slice_pitch, ptr, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, (event != NULL) ? &tmp : NULL), __ENQUEUE_WRITE_IMAGE_ERR); @@ -5502,10 +5787,10 @@ public: cl_event tmp; cl_int err = detail::errHandler( ::clEnqueueCopyImage( - object_, src(), dst(), (const ::size_t *) src_origin, - (const ::size_t *)dst_origin, (const ::size_t *) region, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + object_, src(), dst(), (const ::size_t*)src_origin, + (const ::size_t*)dst_origin, (const ::size_t*)region, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, (event != NULL) ? &tmp : NULL), __ENQUEUE_COPY_IMAGE_ERR); @@ -5534,15 +5819,15 @@ public: cl_event tmp; cl_int err = detail::errHandler( ::clEnqueueFillImage( - object_, + object_, image(), - static_cast(&fillColor), - (const ::size_t *) origin, - (const ::size_t *) region, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + static_cast(&fillColor), + (const ::size_t*)origin, + (const ::size_t*)region, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, (event != NULL) ? &tmp : NULL), - __ENQUEUE_FILL_IMAGE_ERR); + __ENQUEUE_FILL_IMAGE_ERR); if (event != NULL && err == CL_SUCCESS) *event = tmp; @@ -5568,15 +5853,15 @@ public: cl_event tmp; cl_int err = detail::errHandler( ::clEnqueueFillImage( - object_, + object_, image(), - static_cast(&fillColor), - (const ::size_t *) origin, - (const ::size_t *) region, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + static_cast(&fillColor), + (const ::size_t*)origin, + (const ::size_t*)region, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, (event != NULL) ? &tmp : NULL), - __ENQUEUE_FILL_IMAGE_ERR); + __ENQUEUE_FILL_IMAGE_ERR); if (event != NULL && err == CL_SUCCESS) *event = tmp; @@ -5602,22 +5887,22 @@ public: cl_event tmp; cl_int err = detail::errHandler( ::clEnqueueFillImage( - object_, + object_, image(), - static_cast(&fillColor), - (const ::size_t *) origin, - (const ::size_t *) region, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + static_cast(&fillColor), + (const ::size_t*)origin, + (const ::size_t*)region, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, (event != NULL) ? &tmp : NULL), - __ENQUEUE_FILL_IMAGE_ERR); + __ENQUEUE_FILL_IMAGE_ERR); if (event != NULL && err == CL_SUCCESS) *event = tmp; return err; } -#endif // #if defined(CL_VERSION_1_2) +#endif // #if defined(CL_VERSION_1_2) cl_int enqueueCopyImageToBuffer( const Image& src, @@ -5631,10 +5916,10 @@ public: cl_event tmp; cl_int err = detail::errHandler( ::clEnqueueCopyImageToBuffer( - object_, src(), dst(), (const ::size_t *) src_origin, - (const ::size_t *) region, dst_offset, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + object_, src(), dst(), (const ::size_t*)src_origin, + (const ::size_t*)region, dst_offset, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, (event != NULL) ? &tmp : NULL), __ENQUEUE_COPY_IMAGE_TO_BUFFER_ERR); @@ -5657,9 +5942,9 @@ public: cl_int err = detail::errHandler( ::clEnqueueCopyBufferToImage( object_, src(), dst(), src_offset, - (const ::size_t *) dst_origin, (const ::size_t *) region, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (const ::size_t*)dst_origin, (const ::size_t*)region, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, (event != NULL) ? &tmp : NULL), __ENQUEUE_COPY_BUFFER_TO_IMAGE_ERR); @@ -5680,17 +5965,18 @@ public: cl_int* err = NULL) const { cl_int error; - void * result = ::clEnqueueMapBuffer( + void* result = ::clEnqueueMapBuffer( object_, buffer(), blocking, flags, offset, size, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, - (cl_event*) event, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, + (cl_event*)event, &error); detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR); - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } return result; } @@ -5700,26 +5986,27 @@ public: cl_map_flags flags, const size_t<3>& origin, const size_t<3>& region, - ::size_t * row_pitch, - ::size_t * slice_pitch, + ::size_t* row_pitch, + ::size_t* slice_pitch, const VECTOR_CLASS* events = NULL, Event* event = NULL, cl_int* err = NULL) const { cl_int error; - void * result = ::clEnqueueMapImage( + void* result = ::clEnqueueMapImage( object_, buffer(), blocking, flags, - (const ::size_t *) origin, (const ::size_t *) region, + (const ::size_t*)origin, (const ::size_t*)region, row_pitch, slice_pitch, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, - (cl_event*) event, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, + (cl_event*)event, &error); detail::errHandler(error, __ENQUEUE_MAP_IMAGE_ERR); - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } return result; } @@ -5733,8 +6020,8 @@ public: cl_int err = detail::errHandler( ::clEnqueueUnmapMemObject( object_, memory(), mapped_ptr, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, (event != NULL) ? &tmp : NULL), __ENQUEUE_UNMAP_MEM_OBJECT_ERR); @@ -5757,15 +6044,15 @@ public: * have completed. */ cl_int enqueueMarkerWithWaitList( - const VECTOR_CLASS *events = 0, - Event *event = 0) + const VECTOR_CLASS* events = 0, + Event* event = 0) { cl_event tmp; cl_int err = detail::errHandler( ::clEnqueueMarkerWithWaitList( object_, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, (event != NULL) ? &tmp : NULL), __ENQUEUE_MARKER_WAIT_LIST_ERR); @@ -5787,15 +6074,15 @@ public: * before this command to command_queue, have completed. */ cl_int enqueueBarrierWithWaitList( - const VECTOR_CLASS *events = 0, - Event *event = 0) + const VECTOR_CLASS* events = 0, + Event* event = 0) { cl_event tmp; cl_int err = detail::errHandler( ::clEnqueueBarrierWithWaitList( object_, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, (event != NULL) ? &tmp : NULL), __ENQUEUE_BARRIER_WAIT_LIST_ERR); @@ -5804,34 +6091,34 @@ public: return err; } - + /** * Enqueues a command to indicate with which device a set of memory objects * should be associated. */ cl_int enqueueMigrateMemObjects( - const VECTOR_CLASS &memObjects, + const VECTOR_CLASS& memObjects, cl_mem_migration_flags flags, const VECTOR_CLASS* events = NULL, - Event* event = NULL - ) + Event* event = NULL) { cl_event tmp; - + cl_mem* localMemObjects = static_cast(alloca(memObjects.size() * sizeof(cl_mem))); - for( int i = 0; i < (int)memObjects.size(); ++i ) { - localMemObjects[i] = memObjects[i](); - } + for (int i = 0; i < (int)memObjects.size(); ++i) + { + localMemObjects[i] = memObjects[i](); + } cl_int err = detail::errHandler( ::clEnqueueMigrateMemObjects( - object_, - (cl_uint)memObjects.size(), + object_, + (cl_uint)memObjects.size(), static_cast(localMemObjects), flags, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, (event != NULL) ? &tmp : NULL), __ENQUEUE_UNMAP_MEM_OBJECT_ERR); @@ -5840,7 +6127,7 @@ public: return err; } -#endif // #if defined(CL_VERSION_1_2) +#endif // #if defined(CL_VERSION_1_2) cl_int enqueueNDRangeKernel( const Kernel& kernel, @@ -5853,12 +6140,12 @@ public: cl_event tmp; cl_int err = detail::errHandler( ::clEnqueueNDRangeKernel( - object_, kernel(), (cl_uint) global.dimensions(), - offset.dimensions() != 0 ? (const ::size_t*) offset : NULL, - (const ::size_t*) global, - local.dimensions() != 0 ? (const ::size_t*) local : NULL, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + object_, kernel(), (cl_uint)global.dimensions(), + offset.dimensions() != 0 ? (const ::size_t*)offset : NULL, + (const ::size_t*)global, + local.dimensions() != 0 ? (const ::size_t*)local : NULL, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, (event != NULL) ? &tmp : NULL), __ENQUEUE_NDRANGE_KERNEL_ERR); @@ -5877,8 +6164,8 @@ public: cl_int err = detail::errHandler( ::clEnqueueTask( object_, kernel(), - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, (event != NULL) ? &tmp : NULL), __ENQUEUE_TASK_ERR); @@ -5889,32 +6176,34 @@ public: } cl_int enqueueNativeKernel( - void (CL_CALLBACK *userFptr)(void *), + void(CL_CALLBACK* userFptr)(void*), std::pair args, const VECTOR_CLASS* mem_objects = NULL, const VECTOR_CLASS* mem_locs = NULL, const VECTOR_CLASS* events = NULL, Event* event = NULL) const { - cl_mem * mems = (mem_objects != NULL && mem_objects->size() > 0) - ? (cl_mem*) alloca(mem_objects->size() * sizeof(cl_mem)) - : NULL; + cl_mem* mems = (mem_objects != NULL && mem_objects->size() > 0) + ? (cl_mem*)alloca(mem_objects->size() * sizeof(cl_mem)) + : NULL; - if (mems != NULL) { - for (unsigned int i = 0; i < mem_objects->size(); i++) { - mems[i] = ((*mem_objects)[i])(); + if (mems != NULL) + { + for (unsigned int i = 0; i < mem_objects->size(); i++) + { + mems[i] = ((*mem_objects)[i])(); + } } - } cl_event tmp; cl_int err = detail::errHandler( ::clEnqueueNativeKernel( object_, userFptr, args.first, args.second, - (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0, + (mem_objects != NULL) ? (cl_uint)mem_objects->size() : 0, mems, - (mem_locs != NULL) ? (const void **) &mem_locs->front() : NULL, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (mem_locs != NULL) ? (const void**)&mem_locs->front() : NULL, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, (event != NULL) ? &tmp : NULL), __ENQUEUE_NATIVE_KERNEL); @@ -5927,12 +6216,12 @@ public: /** * Deprecated APIs for 1.2 */ -#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) || (defined(CL_VERSION_1_1) && !defined(CL_VERSION_1_2)) - CL_EXT_PREFIX__VERSION_1_1_DEPRECATED +#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) || (defined(CL_VERSION_1_1) && !defined(CL_VERSION_1_2)) + CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int enqueueMarker(Event* event = NULL) const CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED { return detail::errHandler( - ::clEnqueueMarker(object_, (cl_event*) event), + ::clEnqueueMarker(object_, (cl_event*)event), __ENQUEUE_MARKER_ERR); } @@ -5942,70 +6231,70 @@ public: return detail::errHandler( ::clEnqueueWaitForEvents( object_, - (cl_uint) events.size(), - (const cl_event*) &events.front()), + (cl_uint)events.size(), + (const cl_event*)&events.front()), __ENQUEUE_WAIT_FOR_EVENTS_ERR); } -#endif // #if defined(CL_VERSION_1_1) +#endif // #if defined(CL_VERSION_1_1) cl_int enqueueAcquireGLObjects( - const VECTOR_CLASS* mem_objects = NULL, - const VECTOR_CLASS* events = NULL, - Event* event = NULL) const - { + const VECTOR_CLASS* mem_objects = NULL, + const VECTOR_CLASS* events = NULL, + Event* event = NULL) const + { cl_event tmp; cl_int err = detail::errHandler( - ::clEnqueueAcquireGLObjects( - object_, - (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0, - (mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, - (event != NULL) ? &tmp : NULL), - __ENQUEUE_ACQUIRE_GL_ERR); + ::clEnqueueAcquireGLObjects( + object_, + (mem_objects != NULL) ? (cl_uint)mem_objects->size() : 0, + (mem_objects != NULL) ? (const cl_mem*)&mem_objects->front() : NULL, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_ACQUIRE_GL_ERR); if (event != NULL && err == CL_SUCCESS) *event = tmp; return err; - } + } cl_int enqueueReleaseGLObjects( - const VECTOR_CLASS* mem_objects = NULL, - const VECTOR_CLASS* events = NULL, - Event* event = NULL) const - { + const VECTOR_CLASS* mem_objects = NULL, + const VECTOR_CLASS* events = NULL, + Event* event = NULL) const + { cl_event tmp; cl_int err = detail::errHandler( - ::clEnqueueReleaseGLObjects( - object_, - (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0, - (mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, - (event != NULL) ? &tmp : NULL), - __ENQUEUE_RELEASE_GL_ERR); + ::clEnqueueReleaseGLObjects( + object_, + (mem_objects != NULL) ? (cl_uint)mem_objects->size() : 0, + (mem_objects != NULL) ? (const cl_mem*)&mem_objects->front() : NULL, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_RELEASE_GL_ERR); if (event != NULL && err == CL_SUCCESS) *event = tmp; return err; - } + } -#if defined (USE_DX_INTEROP) -typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueAcquireD3D10ObjectsKHR)( - cl_command_queue command_queue, cl_uint num_objects, - const cl_mem* mem_objects, cl_uint num_events_in_wait_list, - const cl_event* event_wait_list, cl_event* event); -typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)( - cl_command_queue command_queue, cl_uint num_objects, - const cl_mem* mem_objects, cl_uint num_events_in_wait_list, - const cl_event* event_wait_list, cl_event* event); +#if defined(USE_DX_INTEROP) + typedef CL_API_ENTRY cl_int(CL_API_CALL* PFN_clEnqueueAcquireD3D10ObjectsKHR)( + cl_command_queue command_queue, cl_uint num_objects, + const cl_mem* mem_objects, cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, cl_event* event); + typedef CL_API_ENTRY cl_int(CL_API_CALL* PFN_clEnqueueReleaseD3D10ObjectsKHR)( + cl_command_queue command_queue, cl_uint num_objects, + const cl_mem* mem_objects, cl_uint num_events_in_wait_list, + const cl_event* event_wait_list, cl_event* event); cl_int enqueueAcquireD3D10Objects( - const VECTOR_CLASS* mem_objects = NULL, - const VECTOR_CLASS* events = NULL, - Event* event = NULL) const + const VECTOR_CLASS* mem_objects = NULL, + const VECTOR_CLASS* events = NULL, + Event* event = NULL) const { static PFN_clEnqueueAcquireD3D10ObjectsKHR pfn_clEnqueueAcquireD3D10ObjectsKHR = NULL; #if defined(CL_VERSION_1_2) @@ -6017,28 +6306,28 @@ typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)( #if defined(CL_VERSION_1_1) __INIT_CL_EXT_FCN_PTR(clEnqueueAcquireD3D10ObjectsKHR); #endif - + cl_event tmp; cl_int err = detail::errHandler( - pfn_clEnqueueAcquireD3D10ObjectsKHR( - object_, - (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0, - (mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL) ? (cl_event*) &events->front() : NULL, - (event != NULL) ? &tmp : NULL), - __ENQUEUE_ACQUIRE_GL_ERR); + pfn_clEnqueueAcquireD3D10ObjectsKHR( + object_, + (mem_objects != NULL) ? (cl_uint)mem_objects->size() : 0, + (mem_objects != NULL) ? (const cl_mem*)&mem_objects->front() : NULL, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL) ? (cl_event*)&events->front() : NULL, + (event != NULL) ? &tmp : NULL), + __ENQUEUE_ACQUIRE_GL_ERR); if (event != NULL && err == CL_SUCCESS) *event = tmp; return err; - } + } cl_int enqueueReleaseD3D10Objects( - const VECTOR_CLASS* mem_objects = NULL, - const VECTOR_CLASS* events = NULL, - Event* event = NULL) const + const VECTOR_CLASS* mem_objects = NULL, + const VECTOR_CLASS* events = NULL, + Event* event = NULL) const { static PFN_clEnqueueReleaseD3D10ObjectsKHR pfn_clEnqueueReleaseD3D10ObjectsKHR = NULL; #if defined(CL_VERSION_1_2) @@ -6046,19 +6335,19 @@ typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)( cl::Device device(getInfo()); cl_platform_id platform = device.getInfo(); __INIT_CL_EXT_FCN_PTR_PLATFORM(platform, clEnqueueReleaseD3D10ObjectsKHR); -#endif // #if defined(CL_VERSION_1_2) +#endif // #if defined(CL_VERSION_1_2) #if defined(CL_VERSION_1_1) __INIT_CL_EXT_FCN_PTR(clEnqueueReleaseD3D10ObjectsKHR); -#endif // #if defined(CL_VERSION_1_1) +#endif // #if defined(CL_VERSION_1_1) cl_event tmp; cl_int err = detail::errHandler( pfn_clEnqueueReleaseD3D10ObjectsKHR( object_, - (mem_objects != NULL) ? (cl_uint) mem_objects->size() : 0, - (mem_objects != NULL) ? (const cl_mem *) &mem_objects->front(): NULL, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL) ? (cl_event*) &events->front() : NULL, + (mem_objects != NULL) ? (cl_uint)mem_objects->size() : 0, + (mem_objects != NULL) ? (const cl_mem*)&mem_objects->front() : NULL, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL) ? (cl_event*)&events->front() : NULL, (event != NULL) ? &tmp : NULL), __ENQUEUE_RELEASE_GL_ERR); @@ -6072,7 +6361,7 @@ typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)( /** * Deprecated APIs for 1.2 */ -#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) || (defined(CL_VERSION_1_1) && !defined(CL_VERSION_1_2)) +#if defined(CL_USE_DEPRECATED_OPENCL_1_1_APIS) || (defined(CL_VERSION_1_1) && !defined(CL_VERSION_1_2)) CL_EXT_PREFIX__VERSION_1_1_DEPRECATED cl_int enqueueBarrier() const CL_EXT_SUFFIX__VERSION_1_1_DEPRECATED { @@ -6080,7 +6369,7 @@ typedef CL_API_ENTRY cl_int (CL_API_CALL *PFN_clEnqueueReleaseD3D10ObjectsKHR)( ::clEnqueueBarrier(object_), __ENQUEUE_BARRIER_ERR); } -#endif // #if defined(CL_VERSION_1_1) +#endif // #if defined(CL_VERSION_1_1) cl_int flush() const { @@ -6115,60 +6404,64 @@ inline cl_int enqueueReadBuffer( cl_int error; CommandQueue queue = CommandQueue::getDefault(&error); - if (error != CL_SUCCESS) { - return error; - } + if (error != CL_SUCCESS) + { + return error; + } return queue.enqueueReadBuffer(buffer, blocking, offset, size, ptr, events, event); } inline cl_int enqueueWriteBuffer( - const Buffer& buffer, - cl_bool blocking, - ::size_t offset, - ::size_t size, - const void* ptr, - const VECTOR_CLASS* events = NULL, - Event* event = NULL) + const Buffer& buffer, + cl_bool blocking, + ::size_t offset, + ::size_t size, + const void* ptr, + const VECTOR_CLASS* events = NULL, + Event* event = NULL) { cl_int error; CommandQueue queue = CommandQueue::getDefault(&error); - if (error != CL_SUCCESS) { - return error; - } + if (error != CL_SUCCESS) + { + return error; + } return queue.enqueueWriteBuffer(buffer, blocking, offset, size, ptr, events, event); } inline void* enqueueMapBuffer( - const Buffer& buffer, - cl_bool blocking, - cl_map_flags flags, - ::size_t offset, - ::size_t size, - const VECTOR_CLASS* events = NULL, - Event* event = NULL, - cl_int* err = NULL) + const Buffer& buffer, + cl_bool blocking, + cl_map_flags flags, + ::size_t offset, + ::size_t size, + const VECTOR_CLASS* events = NULL, + Event* event = NULL, + cl_int* err = NULL) { cl_int error; CommandQueue queue = CommandQueue::getDefault(&error); detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR); - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } - void * result = ::clEnqueueMapBuffer( - queue(), buffer(), blocking, flags, offset, size, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, - (cl_event*) event, - &error); + void* result = ::clEnqueueMapBuffer( + queue(), buffer(), blocking, flags, offset, size, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, + (cl_event*)event, + &error); detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR); - if (err != NULL) { - *err = error; - } + if (err != NULL) + { + *err = error; + } return result; } @@ -6181,16 +6474,17 @@ inline cl_int enqueueUnmapMemObject( cl_int error; CommandQueue queue = CommandQueue::getDefault(&error); detail::errHandler(error, __ENQUEUE_MAP_BUFFER_ERR); - if (error != CL_SUCCESS) { - return error; - } + if (error != CL_SUCCESS) + { + return error; + } cl_event tmp; cl_int err = detail::errHandler( ::clEnqueueUnmapMemObject( queue(), memory(), mapped_ptr, - (events != NULL) ? (cl_uint) events->size() : 0, - (events != NULL && events->size() > 0) ? (cl_event*) &events->front() : NULL, + (events != NULL) ? (cl_uint)events->size() : 0, + (events != NULL && events->size() > 0) ? (cl_event*)&events->front() : NULL, (event != NULL) ? &tmp : NULL), __ENQUEUE_UNMAP_MEM_OBJECT_ERR); @@ -6201,20 +6495,21 @@ inline cl_int enqueueUnmapMemObject( } inline cl_int enqueueCopyBuffer( - const Buffer& src, - const Buffer& dst, - ::size_t src_offset, - ::size_t dst_offset, - ::size_t size, - const VECTOR_CLASS* events = NULL, - Event* event = NULL) + const Buffer& src, + const Buffer& dst, + ::size_t src_offset, + ::size_t dst_offset, + ::size_t size, + const VECTOR_CLASS* events = NULL, + Event* event = NULL) { cl_int error; CommandQueue queue = CommandQueue::getDefault(&error); - if (error != CL_SUCCESS) { - return error; - } + if (error != CL_SUCCESS) + { + return error; + } return queue.enqueueCopyBuffer(src, dst, src_offset, dst_offset, size, events, event); } @@ -6222,25 +6517,26 @@ inline cl_int enqueueCopyBuffer( /** * Blocking copy operation between iterators and a buffer. */ -template< typename IteratorType > -inline cl_int copy( IteratorType startIterator, IteratorType endIterator, cl::Buffer &buffer ) +template +inline cl_int copy(IteratorType startIterator, IteratorType endIterator, cl::Buffer& buffer) { typedef typename std::iterator_traits::value_type DataType; cl_int error; - - ::size_t length = endIterator-startIterator; - ::size_t byteLength = length*sizeof(DataType); - DataType *pointer = + ::size_t length = endIterator - startIterator; + ::size_t byteLength = length * sizeof(DataType); + + DataType* pointer = static_cast(enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_WRITE, 0, byteLength, 0, 0, &error)); // if exceptions enabled, enqueueMapBuffer will throw - if( error != CL_SUCCESS ) { - return error; - } + if (error != CL_SUCCESS) + { + return error; + } #if defined(_MSC_VER) std::copy( - startIterator, - endIterator, + startIterator, + endIterator, stdext::checked_array_iterator( pointer, length)); #else @@ -6249,9 +6545,10 @@ inline cl_int copy( IteratorType startIterator, IteratorType endIterator, cl::Bu Event endEvent; error = enqueueUnmapMemObject(buffer, pointer, 0, &endEvent); // if exceptions enabled, enqueueUnmapMemObject will throw - if( error != CL_SUCCESS ) { - return error; - } + if (error != CL_SUCCESS) + { + return error; + } endEvent.wait(); return CL_SUCCESS; } @@ -6259,28 +6556,30 @@ inline cl_int copy( IteratorType startIterator, IteratorType endIterator, cl::Bu /** * Blocking copy operation between iterators and a buffer. */ -template< typename IteratorType > -inline cl_int copy( const cl::Buffer &buffer, IteratorType startIterator, IteratorType endIterator ) +template +inline cl_int copy(const cl::Buffer& buffer, IteratorType startIterator, IteratorType endIterator) { typedef typename std::iterator_traits::value_type DataType; cl_int error; - - ::size_t length = endIterator-startIterator; - ::size_t byteLength = length*sizeof(DataType); - DataType *pointer = + ::size_t length = endIterator - startIterator; + ::size_t byteLength = length * sizeof(DataType); + + DataType* pointer = static_cast(enqueueMapBuffer(buffer, CL_TRUE, CL_MAP_READ, 0, byteLength, 0, 0, &error)); // if exceptions enabled, enqueueMapBuffer will throw - if( error != CL_SUCCESS ) { - return error; - } + if (error != CL_SUCCESS) + { + return error; + } std::copy(pointer, pointer + length, startIterator); Event endEvent; error = enqueueUnmapMemObject(buffer, pointer, 0, &endEvent); // if exceptions enabled, enqueueUnmapMemObject will throw - if( error != CL_SUCCESS ) { - return error; - } + if (error != CL_SUCCESS) + { + return error; + } endEvent.wait(); return CL_SUCCESS; } @@ -6296,29 +6595,30 @@ inline cl_int enqueueReadBufferRect( ::size_t buffer_slice_pitch, ::size_t host_row_pitch, ::size_t host_slice_pitch, - void *ptr, + void* ptr, const VECTOR_CLASS* events = NULL, Event* event = NULL) { cl_int error; CommandQueue queue = CommandQueue::getDefault(&error); - if (error != CL_SUCCESS) { - return error; - } + if (error != CL_SUCCESS) + { + return error; + } return queue.enqueueReadBufferRect( - buffer, - blocking, - buffer_offset, + buffer, + blocking, + buffer_offset, host_offset, region, buffer_row_pitch, buffer_slice_pitch, host_row_pitch, host_slice_pitch, - ptr, - events, + ptr, + events, event); } @@ -6332,29 +6632,30 @@ inline cl_int enqueueWriteBufferRect( ::size_t buffer_slice_pitch, ::size_t host_row_pitch, ::size_t host_slice_pitch, - void *ptr, + void* ptr, const VECTOR_CLASS* events = NULL, Event* event = NULL) { cl_int error; CommandQueue queue = CommandQueue::getDefault(&error); - if (error != CL_SUCCESS) { - return error; - } + if (error != CL_SUCCESS) + { + return error; + } return queue.enqueueWriteBufferRect( - buffer, - blocking, - buffer_offset, + buffer, + blocking, + buffer_offset, host_offset, region, buffer_row_pitch, buffer_slice_pitch, host_row_pitch, host_slice_pitch, - ptr, - events, + ptr, + events, event); } @@ -6374,9 +6675,10 @@ inline cl_int enqueueCopyBufferRect( cl_int error; CommandQueue queue = CommandQueue::getDefault(&error); - if (error != CL_SUCCESS) { - return error; - } + if (error != CL_SUCCESS) + { + return error; + } return queue.enqueueCopyBufferRect( src, @@ -6388,7 +6690,7 @@ inline cl_int enqueueCopyBufferRect( src_slice_pitch, dst_row_pitch, dst_slice_pitch, - events, + events, event); } #endif @@ -6402,14 +6704,15 @@ inline cl_int enqueueReadImage( ::size_t slice_pitch, void* ptr, const VECTOR_CLASS* events = NULL, - Event* event = NULL) + Event* event = NULL) { cl_int error; CommandQueue queue = CommandQueue::getDefault(&error); - if (error != CL_SUCCESS) { - return error; - } + if (error != CL_SUCCESS) + { + return error; + } return queue.enqueueReadImage( image, @@ -6419,7 +6722,7 @@ inline cl_int enqueueReadImage( row_pitch, slice_pitch, ptr, - events, + events, event); } @@ -6437,9 +6740,10 @@ inline cl_int enqueueWriteImage( cl_int error; CommandQueue queue = CommandQueue::getDefault(&error); - if (error != CL_SUCCESS) { - return error; - } + if (error != CL_SUCCESS) + { + return error; + } return queue.enqueueWriteImage( image, @@ -6449,7 +6753,7 @@ inline cl_int enqueueWriteImage( row_pitch, slice_pitch, ptr, - events, + events, event); } @@ -6465,9 +6769,10 @@ inline cl_int enqueueCopyImage( cl_int error; CommandQueue queue = CommandQueue::getDefault(&error); - if (error != CL_SUCCESS) { - return error; - } + if (error != CL_SUCCESS) + { + return error; + } return queue.enqueueCopyImage( src, @@ -6491,9 +6796,10 @@ inline cl_int enqueueCopyImageToBuffer( cl_int error; CommandQueue queue = CommandQueue::getDefault(&error); - if (error != CL_SUCCESS) { - return error; - } + if (error != CL_SUCCESS) + { + return error; + } return queue.enqueueCopyImageToBuffer( src, @@ -6517,9 +6823,10 @@ inline cl_int enqueueCopyBufferToImage( cl_int error; CommandQueue queue = CommandQueue::getDefault(&error); - if (error != CL_SUCCESS) { - return error; - } + if (error != CL_SUCCESS) + { + return error; + } return queue.enqueueCopyBufferToImage( src, @@ -6537,9 +6844,10 @@ inline cl_int flush(void) cl_int error; CommandQueue queue = CommandQueue::getDefault(&error); - if (error != CL_SUCCESS) { - return error; - } + if (error != CL_SUCCESS) + { + return error; + } return queue.flush(); } @@ -6549,9 +6857,10 @@ inline cl_int finish(void) cl_int error; CommandQueue queue = CommandQueue::getDefault(&error); - if (error != CL_SUCCESS) { - return error; - } + if (error != CL_SUCCESS) + { + return error; + } return queue.finish(); @@ -6570,225 +6879,196 @@ struct EnqueueArgs const NDRange local_; VECTOR_CLASS events_; - EnqueueArgs(NDRange global) : - queue_(CommandQueue::getDefault()), - offset_(NullRange), - global_(global), - local_(NullRange) + EnqueueArgs(NDRange global) : queue_(CommandQueue::getDefault()), + offset_(NullRange), + global_(global), + local_(NullRange) { - } - EnqueueArgs(NDRange global, NDRange local) : - queue_(CommandQueue::getDefault()), - offset_(NullRange), - global_(global), - local_(local) + EnqueueArgs(NDRange global, NDRange local) : queue_(CommandQueue::getDefault()), + offset_(NullRange), + global_(global), + local_(local) { - } - EnqueueArgs(NDRange offset, NDRange global, NDRange local) : - queue_(CommandQueue::getDefault()), - offset_(offset), - global_(global), - local_(local) + EnqueueArgs(NDRange offset, NDRange global, NDRange local) : queue_(CommandQueue::getDefault()), + offset_(offset), + global_(global), + local_(local) { - } - EnqueueArgs(Event e, NDRange global) : - queue_(CommandQueue::getDefault()), - offset_(NullRange), - global_(global), - local_(NullRange) + EnqueueArgs(Event e, NDRange global) : queue_(CommandQueue::getDefault()), + offset_(NullRange), + global_(global), + local_(NullRange) { events_.push_back(e); } - EnqueueArgs(Event e, NDRange global, NDRange local) : - queue_(CommandQueue::getDefault()), - offset_(NullRange), - global_(global), - local_(local) + EnqueueArgs(Event e, NDRange global, NDRange local) : queue_(CommandQueue::getDefault()), + offset_(NullRange), + global_(global), + local_(local) { events_.push_back(e); } - EnqueueArgs(Event e, NDRange offset, NDRange global, NDRange local) : - queue_(CommandQueue::getDefault()), - offset_(offset), - global_(global), - local_(local) + EnqueueArgs(Event e, NDRange offset, NDRange global, NDRange local) : queue_(CommandQueue::getDefault()), + offset_(offset), + global_(global), + local_(local) { events_.push_back(e); } - EnqueueArgs(const VECTOR_CLASS &events, NDRange global) : - queue_(CommandQueue::getDefault()), - offset_(NullRange), - global_(global), - local_(NullRange), - events_(events) + EnqueueArgs(const VECTOR_CLASS& events, NDRange global) : queue_(CommandQueue::getDefault()), + offset_(NullRange), + global_(global), + local_(NullRange), + events_(events) { - } - EnqueueArgs(const VECTOR_CLASS &events, NDRange global, NDRange local) : - queue_(CommandQueue::getDefault()), - offset_(NullRange), - global_(global), - local_(local), - events_(events) + EnqueueArgs(const VECTOR_CLASS& events, NDRange global, NDRange local) : queue_(CommandQueue::getDefault()), + offset_(NullRange), + global_(global), + local_(local), + events_(events) { - } - EnqueueArgs(const VECTOR_CLASS &events, NDRange offset, NDRange global, NDRange local) : - queue_(CommandQueue::getDefault()), - offset_(offset), - global_(global), - local_(local), - events_(events) + EnqueueArgs(const VECTOR_CLASS& events, NDRange offset, NDRange global, NDRange local) : queue_(CommandQueue::getDefault()), + offset_(offset), + global_(global), + local_(local), + events_(events) { - } - EnqueueArgs(CommandQueue &queue, NDRange global) : - queue_(queue), - offset_(NullRange), - global_(global), - local_(NullRange) + EnqueueArgs(CommandQueue& queue, NDRange global) : queue_(queue), + offset_(NullRange), + global_(global), + local_(NullRange) { - } - EnqueueArgs(CommandQueue &queue, NDRange global, NDRange local) : - queue_(queue), - offset_(NullRange), - global_(global), - local_(local) + EnqueueArgs(CommandQueue& queue, NDRange global, NDRange local) : queue_(queue), + offset_(NullRange), + global_(global), + local_(local) { - } - EnqueueArgs(CommandQueue &queue, NDRange offset, NDRange global, NDRange local) : - queue_(queue), - offset_(offset), - global_(global), - local_(local) + EnqueueArgs(CommandQueue& queue, NDRange offset, NDRange global, NDRange local) : queue_(queue), + offset_(offset), + global_(global), + local_(local) { - } - EnqueueArgs(CommandQueue &queue, Event e, NDRange global) : - queue_(queue), - offset_(NullRange), - global_(global), - local_(NullRange) + EnqueueArgs(CommandQueue& queue, Event e, NDRange global) : queue_(queue), + offset_(NullRange), + global_(global), + local_(NullRange) { events_.push_back(e); } - EnqueueArgs(CommandQueue &queue, Event e, NDRange global, NDRange local) : - queue_(queue), - offset_(NullRange), - global_(global), - local_(local) + EnqueueArgs(CommandQueue& queue, Event e, NDRange global, NDRange local) : queue_(queue), + offset_(NullRange), + global_(global), + local_(local) { events_.push_back(e); } - EnqueueArgs(CommandQueue &queue, Event e, NDRange offset, NDRange global, NDRange local) : - queue_(queue), - offset_(offset), - global_(global), - local_(local) + EnqueueArgs(CommandQueue& queue, Event e, NDRange offset, NDRange global, NDRange local) : queue_(queue), + offset_(offset), + global_(global), + local_(local) { events_.push_back(e); } - EnqueueArgs(CommandQueue &queue, const VECTOR_CLASS &events, NDRange global) : - queue_(queue), - offset_(NullRange), - global_(global), - local_(NullRange), - events_(events) + EnqueueArgs(CommandQueue& queue, const VECTOR_CLASS& events, NDRange global) : queue_(queue), + offset_(NullRange), + global_(global), + local_(NullRange), + events_(events) { - } - EnqueueArgs(CommandQueue &queue, const VECTOR_CLASS &events, NDRange global, NDRange local) : - queue_(queue), - offset_(NullRange), - global_(global), - local_(local), - events_(events) + EnqueueArgs(CommandQueue& queue, const VECTOR_CLASS& events, NDRange global, NDRange local) : queue_(queue), + offset_(NullRange), + global_(global), + local_(local), + events_(events) { - } - EnqueueArgs(CommandQueue &queue, const VECTOR_CLASS &events, NDRange offset, NDRange global, NDRange local) : - queue_(queue), - offset_(offset), - global_(global), - local_(local), - events_(events) + EnqueueArgs(CommandQueue& queue, const VECTOR_CLASS& events, NDRange offset, NDRange global, NDRange local) : queue_(queue), + offset_(offset), + global_(global), + local_(local), + events_(events) { - } }; -namespace detail { +namespace detail +{ +class NullType +{ +}; -class NullType {}; - -template +template struct SetArg { - static void set (Kernel kernel, T0 arg) + static void set(Kernel kernel, T0 arg) { kernel.setArg(index, arg); } -}; +}; -template +template struct SetArg { - static void set (Kernel, NullType) - { + static void set(Kernel, NullType) + { } }; template < - typename T0, typename T1, typename T2, typename T3, - typename T4, typename T5, typename T6, typename T7, - typename T8, typename T9, typename T10, typename T11, - typename T12, typename T13, typename T14, typename T15, - typename T16, typename T17, typename T18, typename T19, - typename T20, typename T21, typename T22, typename T23, - typename T24, typename T25, typename T26, typename T27, - typename T28, typename T29, typename T30, typename T31 -> + typename T0, typename T1, typename T2, typename T3, + typename T4, typename T5, typename T6, typename T7, + typename T8, typename T9, typename T10, typename T11, + typename T12, typename T13, typename T14, typename T15, + typename T16, typename T17, typename T18, typename T19, + typename T20, typename T21, typename T22, typename T23, + typename T24, typename T25, typename T26, typename T27, + typename T28, typename T29, typename T30, typename T31> class KernelFunctorGlobal { private: Kernel kernel_; public: - KernelFunctorGlobal( - Kernel kernel) : - kernel_(kernel) - {} + KernelFunctorGlobal( + Kernel kernel) : kernel_(kernel) + { + } - KernelFunctorGlobal( + KernelFunctorGlobal( const Program& program, const STRING_CLASS name, - cl_int * err = NULL) : - kernel_(program, name.c_str(), err) - {} + cl_int* err = NULL) : kernel_(program, name.c_str(), err) + { + } - Event operator() ( + Event operator()( const EnqueueArgs& args, T0 t0, T1 t1 = NullType(), @@ -6821,8 +7101,7 @@ public: T28 t28 = NullType(), T29 t29 = NullType(), T30 t30 = NullType(), - T31 t31 = NullType() - ) + T31 t31 = NullType()) { Event event; SetArg<0, T0>::set(kernel_, t0); @@ -6857,7 +7136,7 @@ public: SetArg<29, T29>::set(kernel_, t29); SetArg<30, T30>::set(kernel_, t30); SetArg<31, T31>::set(kernel_, t31); - + args.queue_.enqueueNDRangeKernel( kernel_, args.offset_, @@ -6865,5344 +7144,5174 @@ public: args.local_, &args.events_, &event); - + return event; } - }; //------------------------------------------------------------------------------------------------------ -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8, - typename T9, - typename T10, - typename T11, - typename T12, - typename T13, - typename T14, - typename T15, - typename T16, - typename T17, - typename T18, - typename T19, - typename T20, - typename T21, - typename T22, - typename T23, - typename T24, - typename T25, - typename T26, - typename T27, - typename T28, - typename T29, - typename T30, - typename T31> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename T11, + typename T12, + typename T13, + typename T14, + typename T15, + typename T16, + typename T17, + typename T18, + typename T19, + typename T20, + typename T21, + typename T22, + typename T23, + typename T24, + typename T25, + typename T26, + typename T27, + typename T28, + typename T29, + typename T30, + typename T31> struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + T23, + T24, + T25, + T26, + T27, + T28, + T29, + T30, + T31> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 32)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 32)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - T31); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5, - T6 arg6, - T7 arg7, - T8 arg8, - T9 arg9, - T10 arg10, - T11 arg11, - T12 arg12, - T13 arg13, - T14 arg14, - T15 arg15, - T16 arg16, - T17 arg17, - T18 arg18, - T19 arg19, - T20 arg20, - T21 arg21, - T22 arg22, - T23 arg23, - T24 arg24, - T25 arg25, - T26 arg26, - T27 arg27, - T28 arg28, - T29 arg29, - T30 arg30, - T31 arg31) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8, - arg9, - arg10, - arg11, - arg12, - arg13, - arg14, - arg15, - arg16, - arg17, - arg18, - arg19, - arg20, - arg21, - arg22, - arg23, - arg24, - arg25, - arg26, - arg27, - arg28, - arg29, - arg30, - arg31); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + T23, + T24, + T25, + T26, + T27, + T28, + T29, + T30, + T31); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7, + T8 arg8, + T9 arg9, + T10 arg10, + T11 arg11, + T12 arg12, + T13 arg13, + T14 arg14, + T15 arg15, + T16 arg16, + T17 arg17, + T18 arg18, + T19 arg19, + T20 arg20, + T21 arg21, + T22 arg22, + T23 arg23, + T24 arg24, + T25 arg25, + T26 arg26, + T27 arg27, + T28 arg28, + T29 arg29, + T30 arg30, + T31 arg31) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + arg16, + arg17, + arg18, + arg19, + arg20, + arg21, + arg22, + arg23, + arg24, + arg25, + arg26, + arg27, + arg28, + arg29, + arg30, + arg31); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8, - typename T9, - typename T10, - typename T11, - typename T12, - typename T13, - typename T14, - typename T15, - typename T16, - typename T17, - typename T18, - typename T19, - typename T20, - typename T21, - typename T22, - typename T23, - typename T24, - typename T25, - typename T26, - typename T27, - typename T28, - typename T29, - typename T30> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename T11, + typename T12, + typename T13, + typename T14, + typename T15, + typename T16, + typename T17, + typename T18, + typename T19, + typename T20, + typename T21, + typename T22, + typename T23, + typename T24, + typename T25, + typename T26, + typename T27, + typename T28, + typename T29, + typename T30> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + T23, + T24, + T25, + T26, + T27, + T28, + T29, + T30, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 31)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 31)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - T30); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5, - T6 arg6, - T7 arg7, - T8 arg8, - T9 arg9, - T10 arg10, - T11 arg11, - T12 arg12, - T13 arg13, - T14 arg14, - T15 arg15, - T16 arg16, - T17 arg17, - T18 arg18, - T19 arg19, - T20 arg20, - T21 arg21, - T22 arg22, - T23 arg23, - T24 arg24, - T25 arg25, - T26 arg26, - T27 arg27, - T28 arg28, - T29 arg29, - T30 arg30) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8, - arg9, - arg10, - arg11, - arg12, - arg13, - arg14, - arg15, - arg16, - arg17, - arg18, - arg19, - arg20, - arg21, - arg22, - arg23, - arg24, - arg25, - arg26, - arg27, - arg28, - arg29, - arg30); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + T23, + T24, + T25, + T26, + T27, + T28, + T29, + T30); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7, + T8 arg8, + T9 arg9, + T10 arg10, + T11 arg11, + T12 arg12, + T13 arg13, + T14 arg14, + T15 arg15, + T16 arg16, + T17 arg17, + T18 arg18, + T19 arg19, + T20 arg20, + T21 arg21, + T22 arg22, + T23 arg23, + T24 arg24, + T25 arg25, + T26 arg26, + T27 arg27, + T28 arg28, + T29 arg29, + T30 arg30) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + arg16, + arg17, + arg18, + arg19, + arg20, + arg21, + arg22, + arg23, + arg24, + arg25, + arg26, + arg27, + arg28, + arg29, + arg30); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8, - typename T9, - typename T10, - typename T11, - typename T12, - typename T13, - typename T14, - typename T15, - typename T16, - typename T17, - typename T18, - typename T19, - typename T20, - typename T21, - typename T22, - typename T23, - typename T24, - typename T25, - typename T26, - typename T27, - typename T28, - typename T29> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename T11, + typename T12, + typename T13, + typename T14, + typename T15, + typename T16, + typename T17, + typename T18, + typename T19, + typename T20, + typename T21, + typename T22, + typename T23, + typename T24, + typename T25, + typename T26, + typename T27, + typename T28, + typename T29> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + T23, + T24, + T25, + T26, + T27, + T28, + T29, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 30)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 30)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - T29); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5, - T6 arg6, - T7 arg7, - T8 arg8, - T9 arg9, - T10 arg10, - T11 arg11, - T12 arg12, - T13 arg13, - T14 arg14, - T15 arg15, - T16 arg16, - T17 arg17, - T18 arg18, - T19 arg19, - T20 arg20, - T21 arg21, - T22 arg22, - T23 arg23, - T24 arg24, - T25 arg25, - T26 arg26, - T27 arg27, - T28 arg28, - T29 arg29) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8, - arg9, - arg10, - arg11, - arg12, - arg13, - arg14, - arg15, - arg16, - arg17, - arg18, - arg19, - arg20, - arg21, - arg22, - arg23, - arg24, - arg25, - arg26, - arg27, - arg28, - arg29); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + T23, + T24, + T25, + T26, + T27, + T28, + T29); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7, + T8 arg8, + T9 arg9, + T10 arg10, + T11 arg11, + T12 arg12, + T13 arg13, + T14 arg14, + T15 arg15, + T16 arg16, + T17 arg17, + T18 arg18, + T19 arg19, + T20 arg20, + T21 arg21, + T22 arg22, + T23 arg23, + T24 arg24, + T25 arg25, + T26 arg26, + T27 arg27, + T28 arg28, + T29 arg29) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + arg16, + arg17, + arg18, + arg19, + arg20, + arg21, + arg22, + arg23, + arg24, + arg25, + arg26, + arg27, + arg28, + arg29); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8, - typename T9, - typename T10, - typename T11, - typename T12, - typename T13, - typename T14, - typename T15, - typename T16, - typename T17, - typename T18, - typename T19, - typename T20, - typename T21, - typename T22, - typename T23, - typename T24, - typename T25, - typename T26, - typename T27, - typename T28> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename T11, + typename T12, + typename T13, + typename T14, + typename T15, + typename T16, + typename T17, + typename T18, + typename T19, + typename T20, + typename T21, + typename T22, + typename T23, + typename T24, + typename T25, + typename T26, + typename T27, + typename T28> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + T23, + T24, + T25, + T26, + T27, + T28, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 29)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 29)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - T28); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5, - T6 arg6, - T7 arg7, - T8 arg8, - T9 arg9, - T10 arg10, - T11 arg11, - T12 arg12, - T13 arg13, - T14 arg14, - T15 arg15, - T16 arg16, - T17 arg17, - T18 arg18, - T19 arg19, - T20 arg20, - T21 arg21, - T22 arg22, - T23 arg23, - T24 arg24, - T25 arg25, - T26 arg26, - T27 arg27, - T28 arg28) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8, - arg9, - arg10, - arg11, - arg12, - arg13, - arg14, - arg15, - arg16, - arg17, - arg18, - arg19, - arg20, - arg21, - arg22, - arg23, - arg24, - arg25, - arg26, - arg27, - arg28); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + T23, + T24, + T25, + T26, + T27, + T28); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7, + T8 arg8, + T9 arg9, + T10 arg10, + T11 arg11, + T12 arg12, + T13 arg13, + T14 arg14, + T15 arg15, + T16 arg16, + T17 arg17, + T18 arg18, + T19 arg19, + T20 arg20, + T21 arg21, + T22 arg22, + T23 arg23, + T24 arg24, + T25 arg25, + T26 arg26, + T27 arg27, + T28 arg28) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + arg16, + arg17, + arg18, + arg19, + arg20, + arg21, + arg22, + arg23, + arg24, + arg25, + arg26, + arg27, + arg28); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8, - typename T9, - typename T10, - typename T11, - typename T12, - typename T13, - typename T14, - typename T15, - typename T16, - typename T17, - typename T18, - typename T19, - typename T20, - typename T21, - typename T22, - typename T23, - typename T24, - typename T25, - typename T26, - typename T27> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename T11, + typename T12, + typename T13, + typename T14, + typename T15, + typename T16, + typename T17, + typename T18, + typename T19, + typename T20, + typename T21, + typename T22, + typename T23, + typename T24, + typename T25, + typename T26, + typename T27> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + T23, + T24, + T25, + T26, + T27, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 28)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 28)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - T27); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5, - T6 arg6, - T7 arg7, - T8 arg8, - T9 arg9, - T10 arg10, - T11 arg11, - T12 arg12, - T13 arg13, - T14 arg14, - T15 arg15, - T16 arg16, - T17 arg17, - T18 arg18, - T19 arg19, - T20 arg20, - T21 arg21, - T22 arg22, - T23 arg23, - T24 arg24, - T25 arg25, - T26 arg26, - T27 arg27) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8, - arg9, - arg10, - arg11, - arg12, - arg13, - arg14, - arg15, - arg16, - arg17, - arg18, - arg19, - arg20, - arg21, - arg22, - arg23, - arg24, - arg25, - arg26, - arg27); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + T23, + T24, + T25, + T26, + T27); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7, + T8 arg8, + T9 arg9, + T10 arg10, + T11 arg11, + T12 arg12, + T13 arg13, + T14 arg14, + T15 arg15, + T16 arg16, + T17 arg17, + T18 arg18, + T19 arg19, + T20 arg20, + T21 arg21, + T22 arg22, + T23 arg23, + T24 arg24, + T25 arg25, + T26 arg26, + T27 arg27) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + arg16, + arg17, + arg18, + arg19, + arg20, + arg21, + arg22, + arg23, + arg24, + arg25, + arg26, + arg27); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8, - typename T9, - typename T10, - typename T11, - typename T12, - typename T13, - typename T14, - typename T15, - typename T16, - typename T17, - typename T18, - typename T19, - typename T20, - typename T21, - typename T22, - typename T23, - typename T24, - typename T25, - typename T26> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename T11, + typename T12, + typename T13, + typename T14, + typename T15, + typename T16, + typename T17, + typename T18, + typename T19, + typename T20, + typename T21, + typename T22, + typename T23, + typename T24, + typename T25, + typename T26> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + T23, + T24, + T25, + T26, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 27)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 27)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - T26); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5, - T6 arg6, - T7 arg7, - T8 arg8, - T9 arg9, - T10 arg10, - T11 arg11, - T12 arg12, - T13 arg13, - T14 arg14, - T15 arg15, - T16 arg16, - T17 arg17, - T18 arg18, - T19 arg19, - T20 arg20, - T21 arg21, - T22 arg22, - T23 arg23, - T24 arg24, - T25 arg25, - T26 arg26) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8, - arg9, - arg10, - arg11, - arg12, - arg13, - arg14, - arg15, - arg16, - arg17, - arg18, - arg19, - arg20, - arg21, - arg22, - arg23, - arg24, - arg25, - arg26); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + T23, + T24, + T25, + T26); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7, + T8 arg8, + T9 arg9, + T10 arg10, + T11 arg11, + T12 arg12, + T13 arg13, + T14 arg14, + T15 arg15, + T16 arg16, + T17 arg17, + T18 arg18, + T19 arg19, + T20 arg20, + T21 arg21, + T22 arg22, + T23 arg23, + T24 arg24, + T25 arg25, + T26 arg26) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + arg16, + arg17, + arg18, + arg19, + arg20, + arg21, + arg22, + arg23, + arg24, + arg25, + arg26); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8, - typename T9, - typename T10, - typename T11, - typename T12, - typename T13, - typename T14, - typename T15, - typename T16, - typename T17, - typename T18, - typename T19, - typename T20, - typename T21, - typename T22, - typename T23, - typename T24, - typename T25> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename T11, + typename T12, + typename T13, + typename T14, + typename T15, + typename T16, + typename T17, + typename T18, + typename T19, + typename T20, + typename T21, + typename T22, + typename T23, + typename T24, + typename T25> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + T23, + T24, + T25, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 26)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 26)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - T25); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5, - T6 arg6, - T7 arg7, - T8 arg8, - T9 arg9, - T10 arg10, - T11 arg11, - T12 arg12, - T13 arg13, - T14 arg14, - T15 arg15, - T16 arg16, - T17 arg17, - T18 arg18, - T19 arg19, - T20 arg20, - T21 arg21, - T22 arg22, - T23 arg23, - T24 arg24, - T25 arg25) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8, - arg9, - arg10, - arg11, - arg12, - arg13, - arg14, - arg15, - arg16, - arg17, - arg18, - arg19, - arg20, - arg21, - arg22, - arg23, - arg24, - arg25); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + T23, + T24, + T25); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7, + T8 arg8, + T9 arg9, + T10 arg10, + T11 arg11, + T12 arg12, + T13 arg13, + T14 arg14, + T15 arg15, + T16 arg16, + T17 arg17, + T18 arg18, + T19 arg19, + T20 arg20, + T21 arg21, + T22 arg22, + T23 arg23, + T24 arg24, + T25 arg25) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + arg16, + arg17, + arg18, + arg19, + arg20, + arg21, + arg22, + arg23, + arg24, + arg25); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8, - typename T9, - typename T10, - typename T11, - typename T12, - typename T13, - typename T14, - typename T15, - typename T16, - typename T17, - typename T18, - typename T19, - typename T20, - typename T21, - typename T22, - typename T23, - typename T24> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename T11, + typename T12, + typename T13, + typename T14, + typename T15, + typename T16, + typename T17, + typename T18, + typename T19, + typename T20, + typename T21, + typename T22, + typename T23, + typename T24> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + T23, + T24, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 25)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 25)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - T24); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5, - T6 arg6, - T7 arg7, - T8 arg8, - T9 arg9, - T10 arg10, - T11 arg11, - T12 arg12, - T13 arg13, - T14 arg14, - T15 arg15, - T16 arg16, - T17 arg17, - T18 arg18, - T19 arg19, - T20 arg20, - T21 arg21, - T22 arg22, - T23 arg23, - T24 arg24) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8, - arg9, - arg10, - arg11, - arg12, - arg13, - arg14, - arg15, - arg16, - arg17, - arg18, - arg19, - arg20, - arg21, - arg22, - arg23, - arg24); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + T23, + T24); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7, + T8 arg8, + T9 arg9, + T10 arg10, + T11 arg11, + T12 arg12, + T13 arg13, + T14 arg14, + T15 arg15, + T16 arg16, + T17 arg17, + T18 arg18, + T19 arg19, + T20 arg20, + T21 arg21, + T22 arg22, + T23 arg23, + T24 arg24) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + arg16, + arg17, + arg18, + arg19, + arg20, + arg21, + arg22, + arg23, + arg24); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8, - typename T9, - typename T10, - typename T11, - typename T12, - typename T13, - typename T14, - typename T15, - typename T16, - typename T17, - typename T18, - typename T19, - typename T20, - typename T21, - typename T22, - typename T23> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename T11, + typename T12, + typename T13, + typename T14, + typename T15, + typename T16, + typename T17, + typename T18, + typename T19, + typename T20, + typename T21, + typename T22, + typename T23> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + T23, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 24)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 24)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - T23); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5, - T6 arg6, - T7 arg7, - T8 arg8, - T9 arg9, - T10 arg10, - T11 arg11, - T12 arg12, - T13 arg13, - T14 arg14, - T15 arg15, - T16 arg16, - T17 arg17, - T18 arg18, - T19 arg19, - T20 arg20, - T21 arg21, - T22 arg22, - T23 arg23) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8, - arg9, - arg10, - arg11, - arg12, - arg13, - arg14, - arg15, - arg16, - arg17, - arg18, - arg19, - arg20, - arg21, - arg22, - arg23); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + T23); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7, + T8 arg8, + T9 arg9, + T10 arg10, + T11 arg11, + T12 arg12, + T13 arg13, + T14 arg14, + T15 arg15, + T16 arg16, + T17 arg17, + T18 arg18, + T19 arg19, + T20 arg20, + T21 arg21, + T22 arg22, + T23 arg23) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + arg16, + arg17, + arg18, + arg19, + arg20, + arg21, + arg22, + arg23); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8, - typename T9, - typename T10, - typename T11, - typename T12, - typename T13, - typename T14, - typename T15, - typename T16, - typename T17, - typename T18, - typename T19, - typename T20, - typename T21, - typename T22> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename T11, + typename T12, + typename T13, + typename T14, + typename T15, + typename T16, + typename T17, + typename T18, + typename T19, + typename T20, + typename T21, + typename T22> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 23)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 23)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - T22); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5, - T6 arg6, - T7 arg7, - T8 arg8, - T9 arg9, - T10 arg10, - T11 arg11, - T12 arg12, - T13 arg13, - T14 arg14, - T15 arg15, - T16 arg16, - T17 arg17, - T18 arg18, - T19 arg19, - T20 arg20, - T21 arg21, - T22 arg22) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8, - arg9, - arg10, - arg11, - arg12, - arg13, - arg14, - arg15, - arg16, - arg17, - arg18, - arg19, - arg20, - arg21, - arg22); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + T22); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7, + T8 arg8, + T9 arg9, + T10 arg10, + T11 arg11, + T12 arg12, + T13 arg13, + T14 arg14, + T15 arg15, + T16 arg16, + T17 arg17, + T18 arg18, + T19 arg19, + T20 arg20, + T21 arg21, + T22 arg22) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + arg16, + arg17, + arg18, + arg19, + arg20, + arg21, + arg22); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8, - typename T9, - typename T10, - typename T11, - typename T12, - typename T13, - typename T14, - typename T15, - typename T16, - typename T17, - typename T18, - typename T19, - typename T20, - typename T21> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename T11, + typename T12, + typename T13, + typename T14, + typename T15, + typename T16, + typename T17, + typename T18, + typename T19, + typename T20, + typename T21> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 22)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 22)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - T21); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5, - T6 arg6, - T7 arg7, - T8 arg8, - T9 arg9, - T10 arg10, - T11 arg11, - T12 arg12, - T13 arg13, - T14 arg14, - T15 arg15, - T16 arg16, - T17 arg17, - T18 arg18, - T19 arg19, - T20 arg20, - T21 arg21) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8, - arg9, - arg10, - arg11, - arg12, - arg13, - arg14, - arg15, - arg16, - arg17, - arg18, - arg19, - arg20, - arg21); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + T21); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7, + T8 arg8, + T9 arg9, + T10 arg10, + T11 arg11, + T12 arg12, + T13 arg13, + T14 arg14, + T15 arg15, + T16 arg16, + T17 arg17, + T18 arg18, + T19 arg19, + T20 arg20, + T21 arg21) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + arg16, + arg17, + arg18, + arg19, + arg20, + arg21); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8, - typename T9, - typename T10, - typename T11, - typename T12, - typename T13, - typename T14, - typename T15, - typename T16, - typename T17, - typename T18, - typename T19, - typename T20> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename T11, + typename T12, + typename T13, + typename T14, + typename T15, + typename T16, + typename T17, + typename T18, + typename T19, + typename T20> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 21)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 21)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - T20); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5, - T6 arg6, - T7 arg7, - T8 arg8, - T9 arg9, - T10 arg10, - T11 arg11, - T12 arg12, - T13 arg13, - T14 arg14, - T15 arg15, - T16 arg16, - T17 arg17, - T18 arg18, - T19 arg19, - T20 arg20) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8, - arg9, - arg10, - arg11, - arg12, - arg13, - arg14, - arg15, - arg16, - arg17, - arg18, - arg19, - arg20); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + T20); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7, + T8 arg8, + T9 arg9, + T10 arg10, + T11 arg11, + T12 arg12, + T13 arg13, + T14 arg14, + T15 arg15, + T16 arg16, + T17 arg17, + T18 arg18, + T19 arg19, + T20 arg20) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + arg16, + arg17, + arg18, + arg19, + arg20); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8, - typename T9, - typename T10, - typename T11, - typename T12, - typename T13, - typename T14, - typename T15, - typename T16, - typename T17, - typename T18, - typename T19> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename T11, + typename T12, + typename T13, + typename T14, + typename T15, + typename T16, + typename T17, + typename T18, + typename T19> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 20)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 20)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - T19); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5, - T6 arg6, - T7 arg7, - T8 arg8, - T9 arg9, - T10 arg10, - T11 arg11, - T12 arg12, - T13 arg13, - T14 arg14, - T15 arg15, - T16 arg16, - T17 arg17, - T18 arg18, - T19 arg19) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8, - arg9, - arg10, - arg11, - arg12, - arg13, - arg14, - arg15, - arg16, - arg17, - arg18, - arg19); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + T19); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7, + T8 arg8, + T9 arg9, + T10 arg10, + T11 arg11, + T12 arg12, + T13 arg13, + T14 arg14, + T15 arg15, + T16 arg16, + T17 arg17, + T18 arg18, + T19 arg19) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + arg16, + arg17, + arg18, + arg19); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8, - typename T9, - typename T10, - typename T11, - typename T12, - typename T13, - typename T14, - typename T15, - typename T16, - typename T17, - typename T18> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename T11, + typename T12, + typename T13, + typename T14, + typename T15, + typename T16, + typename T17, + typename T18> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 19)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 19)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - T18); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5, - T6 arg6, - T7 arg7, - T8 arg8, - T9 arg9, - T10 arg10, - T11 arg11, - T12 arg12, - T13 arg13, - T14 arg14, - T15 arg15, - T16 arg16, - T17 arg17, - T18 arg18) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8, - arg9, - arg10, - arg11, - arg12, - arg13, - arg14, - arg15, - arg16, - arg17, - arg18); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + T18); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7, + T8 arg8, + T9 arg9, + T10 arg10, + T11 arg11, + T12 arg12, + T13 arg13, + T14 arg14, + T15 arg15, + T16 arg16, + T17 arg17, + T18 arg18) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + arg16, + arg17, + arg18); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8, - typename T9, - typename T10, - typename T11, - typename T12, - typename T13, - typename T14, - typename T15, - typename T16, - typename T17> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename T11, + typename T12, + typename T13, + typename T14, + typename T15, + typename T16, + typename T17> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 18)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 18)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - T17); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5, - T6 arg6, - T7 arg7, - T8 arg8, - T9 arg9, - T10 arg10, - T11 arg11, - T12 arg12, - T13 arg13, - T14 arg14, - T15 arg15, - T16 arg16, - T17 arg17) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8, - arg9, - arg10, - arg11, - arg12, - arg13, - arg14, - arg15, - arg16, - arg17); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + T17); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7, + T8 arg8, + T9 arg9, + T10 arg10, + T11 arg11, + T12 arg12, + T13 arg13, + T14 arg14, + T15 arg15, + T16 arg16, + T17 arg17) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + arg16, + arg17); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8, - typename T9, - typename T10, - typename T11, - typename T12, - typename T13, - typename T14, - typename T15, - typename T16> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename T11, + typename T12, + typename T13, + typename T14, + typename T15, + typename T16> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 17)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 17)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - T16); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5, - T6 arg6, - T7 arg7, - T8 arg8, - T9 arg9, - T10 arg10, - T11 arg11, - T12 arg12, - T13 arg13, - T14 arg14, - T15 arg15, - T16 arg16) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8, - arg9, - arg10, - arg11, - arg12, - arg13, - arg14, - arg15, - arg16); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + T16); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7, + T8 arg8, + T9 arg9, + T10 arg10, + T11 arg11, + T12 arg12, + T13 arg13, + T14 arg14, + T15 arg15, + T16 arg16) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15, + arg16); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8, - typename T9, - typename T10, - typename T11, - typename T12, - typename T13, - typename T14, - typename T15> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename T11, + typename T12, + typename T13, + typename T14, + typename T15> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 16)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 16)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - T15); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5, - T6 arg6, - T7 arg7, - T8 arg8, - T9 arg9, - T10 arg10, - T11 arg11, - T12 arg12, - T13 arg13, - T14 arg14, - T15 arg15) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8, - arg9, - arg10, - arg11, - arg12, - arg13, - arg14, - arg15); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + T15); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7, + T8 arg8, + T9 arg9, + T10 arg10, + T11 arg11, + T12 arg12, + T13 arg13, + T14 arg14, + T15 arg15) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14, + arg15); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8, - typename T9, - typename T10, - typename T11, - typename T12, - typename T13, - typename T14> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename T11, + typename T12, + typename T13, + typename T14> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 15)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 15)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - T14); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5, - T6 arg6, - T7 arg7, - T8 arg8, - T9 arg9, - T10 arg10, - T11 arg11, - T12 arg12, - T13 arg13, - T14 arg14) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8, - arg9, - arg10, - arg11, - arg12, - arg13, - arg14); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + T14); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7, + T8 arg8, + T9 arg9, + T10 arg10, + T11 arg11, + T12 arg12, + T13 arg13, + T14 arg14) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13, + arg14); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8, - typename T9, - typename T10, - typename T11, - typename T12, - typename T13> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename T11, + typename T12, + typename T13> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 14)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 14)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - T13); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5, - T6 arg6, - T7 arg7, - T8 arg8, - T9 arg9, - T10 arg10, - T11 arg11, - T12 arg12, - T13 arg13) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8, - arg9, - arg10, - arg11, - arg12, - arg13); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + T13); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7, + T8 arg8, + T9 arg9, + T10 arg10, + T11 arg11, + T12 arg12, + T13 arg13) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12, + arg13); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8, - typename T9, - typename T10, - typename T11, - typename T12> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename T11, + typename T12> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 13)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 13)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - T12); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5, - T6 arg6, - T7 arg7, - T8 arg8, - T9 arg9, - T10 arg10, - T11 arg11, - T12 arg12) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8, - arg9, - arg10, - arg11, - arg12); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + T12); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7, + T8 arg8, + T9 arg9, + T10 arg10, + T11 arg11, + T12 arg12) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11, + arg12); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8, - typename T9, - typename T10, - typename T11> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10, + typename T11> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 12)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 12)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - T11); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5, - T6 arg6, - T7 arg7, - T8 arg8, - T9 arg9, - T10 arg10, - T11 arg11) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8, - arg9, - arg10, - arg11); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + T11); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7, + T8 arg8, + T9 arg9, + T10 arg10, + T11 arg11) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10, + arg11); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8, - typename T9, - typename T10> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9, + typename T10> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 11)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 11)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - T10); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5, - T6 arg6, - T7 arg7, - T8 arg8, - T9 arg9, - T10 arg10) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8, - arg9, - arg10); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + T10); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7, + T8 arg8, + T9 arg9, + T10 arg10) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9, + arg10); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8, - typename T9> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8, + typename T9> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 10)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 10)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - T9); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5, - T6 arg6, - T7 arg7, - T8 arg8, - T9 arg9) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8, - arg9); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + T9); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7, + T8 arg8, + T9 arg9) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8, + arg9); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7, - typename T8> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7, + typename T8> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 9)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 9)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - T8); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5, - T6 arg6, - T7 arg7, - T8 arg8) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7, - arg8); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + T8); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7, + T8 arg8) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7, + arg8); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6, - typename T7> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6, + typename T7> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 8)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 8)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5, - T6, - T7); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5, - T6 arg6, - T7 arg7) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6, - arg7); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6, + T7); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6, + T7 arg7) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6, + arg7); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5, - typename T6> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - T5, - T6, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5, + typename T6> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - T6, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + T6, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 7)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 7)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5, - T6); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5, - T6 arg6) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5, - arg6); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5, + T6); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5, + T6 arg6) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5, + arg6); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4, - typename T5> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - T5, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4, + typename T5> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - T5, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + T5, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 6)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 6)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4, - T5); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4, - T5 arg5) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4, - arg5); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4, + T5); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4, + T5 arg5) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4, + arg5); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3, - typename T4> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - T4, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3, + typename T4> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - T4, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + T4, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 5)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 5)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3, - T4); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3, - T4 arg4) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3, - arg4); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3, + T4); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3, + T4 arg4) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3, + arg4); + } }; -template< - typename T0, - typename T1, - typename T2, - typename T3> -struct functionImplementation_ -< T0, - T1, - T2, - T3, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2, + typename T3> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - T3, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + T3, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 4)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 4)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2, - T3); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2, - T3 arg3) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2, - arg3); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2, + T3); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2, + T3 arg3) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2, + arg3); + } }; -template< - typename T0, - typename T1, - typename T2> -struct functionImplementation_ -< T0, - T1, - T2, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1, + typename T2> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - T2, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + T2, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 3)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 3)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1, - T2); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1, - T2 arg2) - { - return functor_( - enqueueArgs, - arg0, - arg1, - arg2); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1, + T2); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1, + T2 arg2) + { + return functor_( + enqueueArgs, + arg0, + arg1, + arg2); + } }; -template< - typename T0, - typename T1> -struct functionImplementation_ -< T0, - T1, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0, + typename T1> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - T1, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + T1, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 2)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 2)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0, - T1); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0, - T1 arg1) - { - return functor_( - enqueueArgs, - arg0, - arg1); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0, + T1); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0, + T1 arg1) + { + return functor_( + enqueueArgs, + arg0, + arg1); + } }; -template< - typename T0> -struct functionImplementation_ -< T0, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> +template < + typename T0> +struct functionImplementation_ { - typedef detail::KernelFunctorGlobal< - T0, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType, - NullType> FunctorType; + typedef detail::KernelFunctorGlobal< + T0, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType, + NullType> + FunctorType; FunctorType functor_; - functionImplementation_(const FunctorType &functor) : - functor_(functor) + functionImplementation_(const FunctorType& functor) : functor_(functor) { - - #if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 1)) +#if (defined(_WIN32) && defined(_VARIADIC_MAX) && (_VARIADIC_MAX < 1)) // Fail variadic expansion for dev11 static_assert(0, "Visual Studio has a hard limit of argument count for a std::function expansion. Please define _VARIADIC_MAX to be 10. If you need more arguments than that VC12 and below cannot support it."); - #endif - +#endif } - //! \brief Return type of the functor - typedef Event result_type; - - //! \brief Function signature of kernel functor with no event dependency. - typedef Event type_( - const EnqueueArgs&, - T0); - - Event operator()( - const EnqueueArgs& enqueueArgs, - T0 arg0) - { - return functor_( - enqueueArgs, - arg0); - } + //! \brief Return type of the functor + typedef Event result_type; + //! \brief Function signature of kernel functor with no event dependency. + typedef Event type_( + const EnqueueArgs&, + T0); + Event operator()( + const EnqueueArgs& enqueueArgs, + T0 arg0) + { + return functor_( + enqueueArgs, + arg0); + } }; - - - -} // namespace detail +} // namespace detail //---------------------------------------------------------------------------------------------- template < - typename T0, typename T1 = detail::NullType, typename T2 = detail::NullType, - typename T3 = detail::NullType, typename T4 = detail::NullType, - typename T5 = detail::NullType, typename T6 = detail::NullType, - typename T7 = detail::NullType, typename T8 = detail::NullType, - typename T9 = detail::NullType, typename T10 = detail::NullType, - typename T11 = detail::NullType, typename T12 = detail::NullType, - typename T13 = detail::NullType, typename T14 = detail::NullType, - typename T15 = detail::NullType, typename T16 = detail::NullType, - typename T17 = detail::NullType, typename T18 = detail::NullType, - typename T19 = detail::NullType, typename T20 = detail::NullType, - typename T21 = detail::NullType, typename T22 = detail::NullType, - typename T23 = detail::NullType, typename T24 = detail::NullType, - typename T25 = detail::NullType, typename T26 = detail::NullType, - typename T27 = detail::NullType, typename T28 = detail::NullType, - typename T29 = detail::NullType, typename T30 = detail::NullType, - typename T31 = detail::NullType -> -struct make_kernel : - public detail::functionImplementation_< - T0, T1, T2, T3, - T4, T5, T6, T7, - T8, T9, T10, T11, - T12, T13, T14, T15, - T16, T17, T18, T19, - T20, T21, T22, T23, - T24, T25, T26, T27, - T28, T29, T30, T31 - > + typename T0, typename T1 = detail::NullType, typename T2 = detail::NullType, + typename T3 = detail::NullType, typename T4 = detail::NullType, + typename T5 = detail::NullType, typename T6 = detail::NullType, + typename T7 = detail::NullType, typename T8 = detail::NullType, + typename T9 = detail::NullType, typename T10 = detail::NullType, + typename T11 = detail::NullType, typename T12 = detail::NullType, + typename T13 = detail::NullType, typename T14 = detail::NullType, + typename T15 = detail::NullType, typename T16 = detail::NullType, + typename T17 = detail::NullType, typename T18 = detail::NullType, + typename T19 = detail::NullType, typename T20 = detail::NullType, + typename T21 = detail::NullType, typename T22 = detail::NullType, + typename T23 = detail::NullType, typename T24 = detail::NullType, + typename T25 = detail::NullType, typename T26 = detail::NullType, + typename T27 = detail::NullType, typename T28 = detail::NullType, + typename T29 = detail::NullType, typename T30 = detail::NullType, + typename T31 = detail::NullType> +struct make_kernel : public detail::functionImplementation_< + T0, T1, T2, T3, + T4, T5, T6, T7, + T8, T9, T10, T11, + T12, T13, T14, T15, + T16, T17, T18, T19, + T20, T21, T22, T23, + T24, T25, T26, T27, + T28, T29, T30, T31> { public: - typedef detail::KernelFunctorGlobal< - T0, T1, T2, T3, - T4, T5, T6, T7, - T8, T9, T10, T11, - T12, T13, T14, T15, - T16, T17, T18, T19, - T20, T21, T22, T23, - T24, T25, T26, T27, - T28, T29, T30, T31 - > FunctorType; + typedef detail::KernelFunctorGlobal< + T0, T1, T2, T3, + T4, T5, T6, T7, + T8, T9, T10, T11, + T12, T13, T14, T15, + T16, T17, T18, T19, + T20, T21, T22, T23, + T24, T25, T26, T27, + T28, T29, T30, T31> + FunctorType; make_kernel( const Program& program, const STRING_CLASS name, - cl_int * err = NULL) : - detail::functionImplementation_< - T0, T1, T2, T3, - T4, T5, T6, T7, - T8, T9, T10, T11, - T12, T13, T14, T15, - T16, T17, T18, T19, - T20, T21, T22, T23, - T24, T25, T26, T27, - T28, T29, T30, T31 - >( - FunctorType(program, name, err)) - {} + cl_int* err = NULL) : detail::functionImplementation_( + FunctorType(program, name, err)) + { + } make_kernel( - const Kernel kernel) : - detail::functionImplementation_< - T0, T1, T2, T3, - T4, T5, T6, T7, - T8, T9, T10, T11, - T12, T13, T14, T15, - T16, T17, T18, T19, - T20, T21, T22, T23, - T24, T25, T26, T27, - T28, T29, T30, T31 - >( - FunctorType(kernel)) - {} + const Kernel kernel) : detail::functionImplementation_( + FunctorType(kernel)) + { + } }; @@ -12275,7 +12384,7 @@ public: #undef __CL_EXPLICIT_CONSTRUCTORS #undef __UNLOAD_COMPILER_ERR -#endif //__CL_USER_OVERRIDE_ERROR_STRINGS +#endif //__CL_USER_OVERRIDE_ERROR_STRINGS #undef __CL_FUNCTION_TYPE @@ -12285,21 +12394,21 @@ public: */ #if defined(CL_VERSION_1_1) #undef __INIT_CL_EXT_FCN_PTR -#endif // #if defined(CL_VERSION_1_1) +#endif // #if defined(CL_VERSION_1_1) #undef __CREATE_SUB_DEVICES #if defined(USE_CL_DEVICE_FISSION) #undef __PARAM_NAME_DEVICE_FISSION -#endif // USE_CL_DEVICE_FISSION +#endif // USE_CL_DEVICE_FISSION -#undef __DEFAULT_NOT_INITIALIZED -#undef __DEFAULT_BEING_INITIALIZED +#undef __DEFAULT_NOT_INITIALIZED +#undef __DEFAULT_BEING_INITIALIZED #undef __DEFAULT_INITIALIZED -} // namespace cl +} // namespace cl #ifdef _WIN32 #pragma pop_macro("max") -#endif // _WIN32 +#endif // _WIN32 -#endif // CL_HPP_ +#endif // CL_HPP_ diff --git a/src/algorithms/libs/rtklib/rtklib_ephemeris.cc b/src/algorithms/libs/rtklib/rtklib_ephemeris.cc index a64b952ef..eff182fbd 100644 --- a/src/algorithms/libs/rtklib/rtklib_ephemeris.cc +++ b/src/algorithms/libs/rtklib/rtklib_ephemeris.cc @@ -663,7 +663,7 @@ int satpos_sbas(gtime_t time, gtime_t teph, int sat, const nav_t *nav, *svh = -1; return 0; } - /* satellite postion and clock by broadcast ephemeris */ + /* satellite position and clock by broadcast ephemeris */ if (!ephpos(time, teph, sat, nav, sbs->lcorr.iode, rs, dts, var, svh)) return 0; /* sbas satellite correction (long term and fast) */ @@ -734,7 +734,7 @@ int satpos_ssr(gtime_t time, gtime_t teph, int sat, const nav_t *nav, *svh = -1; return 0; } - /* satellite postion and clock by broadcast ephemeris */ + /* satellite position and clock by broadcast ephemeris */ if (!ephpos(time, teph, sat, nav, ssr->iode, rs, dts, var, svh)) return 0; /* satellite clock for gps, galileo and qzss */ diff --git a/src/algorithms/libs/rtklib/rtklib_pntpos.cc b/src/algorithms/libs/rtklib/rtklib_pntpos.cc index a03d64a29..3ef5c7185 100644 --- a/src/algorithms/libs/rtklib/rtklib_pntpos.cc +++ b/src/algorithms/libs/rtklib/rtklib_pntpos.cc @@ -768,7 +768,7 @@ int pntpos(const obsd_t *obs, int n, const nav_t *nav, opt_.ionoopt = IONOOPT_BRDC; opt_.tropopt = TROPOPT_SAAS; } - /* satellite positons, velocities and clocks */ + /* satellite positions, velocities and clocks */ satposs(sol->time, obs, n, nav, opt_.sateph, rs, dts, var, svh); /* estimate receiver position with pseudorange */ diff --git a/src/algorithms/libs/rtklib/rtklib_ppp.cc b/src/algorithms/libs/rtklib/rtklib_ppp.cc index 285424873..b60d627c9 100644 --- a/src/algorithms/libs/rtklib/rtklib_ppp.cc +++ b/src/algorithms/libs/rtklib/rtklib_ppp.cc @@ -425,7 +425,7 @@ int fix_amb_ROUND(rtk_t *rtk, int *sat1, int *sat2, const int *NW, int n) sat2[m] = sat2[i]; NC[m++] = BC; } - /* select fixed ambiguities by dependancy check */ + /* select fixed ambiguities by dependency check */ m = sel_amb(sat1, sat2, NC, var, m); /* fixed solution */ diff --git a/src/algorithms/libs/rtklib/rtklib_ppp.h b/src/algorithms/libs/rtklib/rtklib_ppp.h index a613ecb8e..8d90c3b3e 100644 --- a/src/algorithms/libs/rtklib/rtklib_ppp.h +++ b/src/algorithms/libs/rtklib/rtklib_ppp.h @@ -79,7 +79,7 @@ const double MIN_ARC_GAP = 300.0; /* min arc gap (s) */ const double CONST_AMB = 0.001; /* constraint to fixed ambiguity */ -const double THRES_RES = 0.3; /* threashold of residuals test (m) */ +const double THRES_RES = 0.3; /* threshold of residuals test (m) */ const double LOG_PI = 1.14472988584940017; /* log(pi) */ const double SQRT2 = 1.41421356237309510; /* sqrt(2) */ diff --git a/src/algorithms/libs/rtklib/rtklib_preceph.cc b/src/algorithms/libs/rtklib/rtklib_preceph.cc index f883b3e44..293d86543 100644 --- a/src/algorithms/libs/rtklib/rtklib_preceph.cc +++ b/src/algorithms/libs/rtklib/rtklib_preceph.cc @@ -843,7 +843,7 @@ void satantoff(gtime_t time, const double *rs, int sat, const nav_t *nav, * args : gtime_t time I time (gpst) * int sat I satellite number * nav_t *nav I navigation data - * int opt I sat postion option + * int opt I sat position option * (0: center of mass, 1: antenna phase center) * double *rs O sat position and velocity (ecef) * {x,y,z,vx,vy,vz} (m|m/s) diff --git a/src/algorithms/libs/rtklib/rtklib_rtcm.cc b/src/algorithms/libs/rtklib/rtklib_rtcm.cc index e3c0d15b9..40ec2f543 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtcm.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtcm.cc @@ -315,7 +315,7 @@ int input_rtcm3(rtcm_t *rtcm, unsigned char data) /* input rtcm 2 message from file ---------------------------------------------- - * fetch next rtcm 2 message and input a messsage from file + * fetch next rtcm 2 message and input a message from file * args : rtcm_t *rtcm IO rtcm control struct * FILE *fp I file pointer * return : status (-2: end of file, -1...10: same as above) @@ -337,7 +337,7 @@ int input_rtcm2f(rtcm_t *rtcm, FILE *fp) /* input rtcm 3 message from file ---------------------------------------------- - * fetch next rtcm 3 message and input a messsage from file + * fetch next rtcm 3 message and input a message from file * args : rtcm_t *rtcm IO rtcm control struct * FILE *fp I file pointer * return : status (-2: end of file, -1...10: same as above) diff --git a/src/algorithms/libs/rtklib/rtklib_rtcm3.cc b/src/algorithms/libs/rtklib/rtklib_rtcm3.cc index 53e88739d..d8fb3c334 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtcm3.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtcm3.cc @@ -1056,7 +1056,7 @@ int decode_type1021(rtcm_t *rtcm __attribute__((unused))) } -/* decode type 1022: moledenski-badekas transfromation -----------------------*/ +/* decode type 1022: moledenski-badekas transformation -----------------------*/ int decode_type1022(rtcm_t *rtcm __attribute__((unused))) { trace(2, "rtcm3 1022: not supported message\n"); @@ -2699,7 +2699,7 @@ void save_msm_obs(rtcm_t *rtcm, int sys, msm_h_t *h, const double *r, /* signal to rinex obs type */ code[i] = obs2code(sig[i], freq + i); - /* freqency index for beidou */ + /* frequency index for beidou */ if (sys == SYS_BDS) { if (freq[i] == 5) diff --git a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc index cf6f22508..bf4c7bf8a 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkcmn.cc @@ -1819,7 +1819,7 @@ unsigned int tickget(void) /* sleep ms -------------------------------------------------------------------- * sleep ms - * args : int ms I miliseconds to sleep (<0:no sleep) + * args : int ms I milliseconds to sleep (<0:no sleep) * return : none *-----------------------------------------------------------------------------*/ void sleepms(int ms) @@ -1884,7 +1884,7 @@ double dms2deg(const double *dms) } -/* transform ecef to geodetic postion ------------------------------------------ +/* transform ecef to geodetic position ------------------------------------------ * transform ecef position to geodetic position * args : double *r I ecef position {x,y,z} (m) * double *pos O geodetic position {lat,lon,h} (rad,m) @@ -1926,8 +1926,8 @@ void pos2ecef(const double *pos, double *r) } -/* ecef to local coordinate transfromation matrix ------------------------------ - * compute ecef to local coordinate transfromation matrix +/* ecef to local coordinate transformation matrix ------------------------------ + * compute ecef to local coordinate transformation matrix * args : double *pos I geodetic position {lat,lon} (rad) * double *E O ecef to local coord transformation matrix (3x3) * return : none @@ -2223,7 +2223,7 @@ void eci2ecef(gtime_t tutc, const double *erpv, double *U, double *gmst) matmul("NN", 3, 3, 3, 1.0, R1, R2, 0.0, R); matmul("NN", 3, 3, 3, 1.0, R, R3, 0.0, N); /* N=Rx(-eps)*Rz(-dspi)*Rx(eps) */ - /* greenwich aparent sidereal time (rad) */ + /* greenwich apparent sidereal time (rad) */ gmst_ = utc2gmst(tutc_, erpv[2]); gast = gmst_ + dpsi * cos(eps); gast += (0.00264 * sin(f[4]) + 0.000063 * sin(2.0 * f[4])) * AS2R; @@ -4166,7 +4166,7 @@ void sunmoonpos(gtime_t tutc, const double *erpv, double *rsun, /* eci to ecef transformation matrix */ eci2ecef(tutc, erpv, U, &gmst_); - /* sun and moon postion in ecef */ + /* 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_; diff --git a/src/algorithms/libs/rtklib/rtklib_rtkpos.cc b/src/algorithms/libs/rtklib/rtklib_rtkpos.cc index e5a43f517..872e186c2 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtkpos.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtkpos.cc @@ -599,7 +599,7 @@ void udpos(rtk_t *rtk, double tt) for (i = 0; i < 3; i++) initx_rtk(rtk, rtk->sol.rr[i], VAR_POS, i); return; } - /* check variance of estimated postion */ + /* check variance of estimated position */ for (i = 0; i < 3; i++) { var += rtk->P[i + i * rtk->nx]; @@ -2223,7 +2223,7 @@ void rtkfree(rtk_t *rtk) * .vs [r] O data valid single (r=0:rover,1:base) * .resp [f] O freq(f+1) pseudorange residual (m) * .resc [f] O freq(f+1) carrier-phase residual (m) - * .vsat [f] O freq(f+1) data vaild (0:invalid,1:valid) + * .vsat [f] O freq(f+1) data valid (0:invalid,1:valid) * .fix [f] O freq(f+1) ambiguity flag * (0:nodata,1:float,2:fix,3:hold) * .slip [f] O freq(f+1) slip flag @@ -2262,7 +2262,7 @@ int rtkpos(rtk_t *rtk, const obsd_t *obs, int n, const nav_t *nav) traceobs(4, obs, n); /*trace(5,"nav=\n"); tracenav(5,nav);*/ - /* set base staion position */ + /* set base station position */ if (opt->refpos <= POSOPT_RINEX && opt->mode != PMODE_SINGLE && opt->mode != PMODE_MOVEB) { diff --git a/src/algorithms/libs/rtklib/rtklib_rtksvr.cc b/src/algorithms/libs/rtklib/rtklib_rtksvr.cc index 732d5cc28..c835ac688 100644 --- a/src/algorithms/libs/rtklib/rtklib_rtksvr.cc +++ b/src/algorithms/libs/rtklib/rtklib_rtksvr.cc @@ -210,7 +210,7 @@ void updatesvr(rtksvr_t *svr, int ret, obs_t *obs, nav_t *nav, int sat, svr->nmsg[index][2]++; } else if (ret == 5) - { /* antenna postion parameters */ + { /* antenna position parameters */ if (svr->rtk.opt.refpos == 4 && index == 1) { for (i = 0; i < 3; i++) diff --git a/src/algorithms/libs/rtklib/rtklib_sbas.cc b/src/algorithms/libs/rtklib/rtklib_sbas.cc index ec9649ac2..3bd809d10 100644 --- a/src/algorithms/libs/rtklib/rtklib_sbas.cc +++ b/src/algorithms/libs/rtklib/rtklib_sbas.cc @@ -616,10 +616,10 @@ int cmpmsgs(const void *p1, const void *p2) * (gtime_t te I end time ) * sbs_t *sbs IO sbas messages * return : number of sbas messages - * notes : sbas message are appended and sorted. before calling the funciton, + * notes : sbas message are appended and sorted. before calling the function, * sbs->n, sbs->nmax and sbs->msgs must be set properly. (initially * sbs->n=sbs->nmax=0, sbs->msgs=NULL) - * only the following file extentions after wild card expanded are valid + * only the following file extensions after wild card expanded are valid * to read. others are skipped * .sbs, .SBS, .ems, .EMS *-----------------------------------------------------------------------------*/ diff --git a/src/algorithms/libs/rtklib/rtklib_solution.cc b/src/algorithms/libs/rtklib/rtklib_solution.cc index 2b679ac25..f559e9f4d 100644 --- a/src/algorithms/libs/rtklib/rtklib_solution.cc +++ b/src/algorithms/libs/rtklib/rtklib_solution.cc @@ -150,7 +150,7 @@ void covtosol(const double *P, sol_t *sol) } -/* decode nmea gprmc: recommended minumum data for gps -----------------------*/ +/* decode nmea gprmc: recommended minimum data for gps -----------------------*/ int decode_nmearmc(char **val, int n, sol_t *sol) { double tod = 0.0, lat = 0.0, lon = 0.0, vel = 0.0, dir = 0.0, date = 0.0, ang = 0.0, ep[6]; @@ -219,7 +219,7 @@ int decode_nmearmc(char **val, int n, sol_t *sol) sol->stat = mode == 'D' ? SOLQ_DGPS : SOLQ_SINGLE; sol->ns = 0; - sol->type = 0; /* postion type = xyz */ + sol->type = 0; /* position type = xyz */ trace(5, "decode_nmearmc: %s rr=%.3f %.3f %.3f stat=%d ns=%d vel=%.2f dir=%.0f ang=%.0f mew=%c mode=%c\n", time_str(sol->time, 0), sol->rr[0], sol->rr[1], sol->rr[2], sol->stat, sol->ns, @@ -310,7 +310,7 @@ int decode_nmeagga(char **val, int n, sol_t *sol) sol->stat = 0 <= solq && solq <= 8 ? solq_nmea[solq] : SOLQ_NONE; sol->ns = nrcv; - sol->type = 0; /* postion type = xyz */ + sol->type = 0; /* position type = xyz */ trace(5, "decode_nmeagga: %s rr=%.3f %.3f %.3f stat=%d ns=%d hdop=%.1f ua=%c um=%c\n", time_str(sol->time, 0), sol->rr[0], sol->rr[1], sol->rr[2], sol->stat, sol->ns, @@ -453,7 +453,7 @@ int decode_solxyz(char *buff, const solopt_t *opt, sol_t *sol) if (i < n) sol->age = (float)val[i++]; if (i < n) sol->ratio = (float)val[i]; - sol->type = 0; /* postion type = xyz */ + sol->type = 0; /* position type = xyz */ if (MAXSOLQ < sol->stat) sol->stat = SOLQ_NONE; return 1; @@ -512,7 +512,7 @@ int decode_solllh(char *buff, const solopt_t *opt, sol_t *sol) if (i < n) sol->age = (float)val[i++]; if (i < n) sol->ratio = (float)val[i]; - sol->type = 0; /* postion type = xyz */ + sol->type = 0; /* position type = xyz */ if (MAXSOLQ < sol->stat) sol->stat = SOLQ_NONE; return 1; @@ -558,7 +558,7 @@ int decode_solenu(char *buff, const solopt_t *opt, sol_t *sol) if (i < n) sol->age = (float)val[i++]; if (i < n) sol->ratio = (float)val[i]; - sol->type = 1; /* postion type = enu */ + sol->type = 1; /* position type = enu */ if (MAXSOLQ < sol->stat) sol->stat = SOLQ_NONE; return 1; @@ -1798,7 +1798,7 @@ int outsols(unsigned char *buff, const sol_t *sol, const double *rb, /* output solution extended ---------------------------------------------------- - * output solution exteneded infomation + * output solution exteneded information * args : unsigned char *buff IO output buffer * sol_t *sol I solution * ssat_t *ssat I satellite status @@ -1892,7 +1892,7 @@ void outsol(FILE *fp, const sol_t *sol, const double *rb, /* output solution extended ---------------------------------------------------- - * output solution exteneded infomation to file + * output solution exteneded information to file * args : FILE *fp I output file pointer * sol_t *sol I solution * ssat_t *ssat I satellite status diff --git a/src/algorithms/libs/rtklib/rtklib_stream.cc b/src/algorithms/libs/rtklib/rtklib_stream.cc index e7a7204b7..6dafde2ac 100644 --- a/src/algorithms/libs/rtklib/rtklib_stream.cc +++ b/src/algorithms/libs/rtklib/rtklib_stream.cc @@ -1916,7 +1916,7 @@ void strunlock(stream_t *stream) { rtk_unlock(&stream->lock); } /* read stream ----------------------------------------------------------------- * read data from stream (unblocked) * args : stream_t *stream I stream - * unsinged char *buff O data buffer + * unsigned char *buff O data buffer * int n I maximum data length * return : read data length * notes : if no data, return immediately with no data @@ -1978,7 +1978,7 @@ int strread(stream_t *stream, unsigned char *buff, int n) /* write stream ---------------------------------------------------------------- * write data to stream (unblocked) * args : stream_t *stream I stream - * unsinged char *buff I data buffer + * unsigned char *buff I data buffer * int n I data length * return : status (0:error, 1:ok) * notes : write data to buffer and return immediately diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/Doxyfile.in b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/Doxyfile.in index 2c0a87a3c..8fa50f08d 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/Doxyfile.in +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/Doxyfile.in @@ -145,7 +145,7 @@ INLINE_INHERITED_MEMB = NO # shortest path that makes the file name unique will be used # The default value is: YES. -FULL_PATH_NAMES = YES +FULL_PATH_NAMES = NO # The STRIP_FROM_PATH tag can be used to strip a user-defined part of the path. # Stripping is only done if one of the specified strings matches the left-hand diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/README.md b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/README.md index af32a2017..3b5e14513 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/README.md +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/README.md @@ -7,8 +7,8 @@ and contact information about the original VOLK library. The boilerplate of this code was initially generated with ```volk_modtool```, an application provided by VOLK that creates the -skeleton than can then be filled with custom kernels. Some modifications -were added to accomodate the specificities of Global Navigation +skeleton that can then be filled with custom kernels. Some modifications +were added to accommodate the specificities of Global Navigation Satellite Systems (GNSS) signal processing. Those changes are clearly indicated in the source code, and do not break compatibility. @@ -39,7 +39,7 @@ This library is automatically built and installed along with GNSS-SDR if it is not found by CMake on your system at configure time. However, you can install and use VOLK_GNSSSDR kernels as you use VOLK's, -independently from GNSS-SDR. +independently of GNSS-SDR. First, make sure that the required dependencies are installed in your machine: diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_option_helpers.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_option_helpers.h index da1e12821..a0f7406db 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_option_helpers.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_option_helpers.h @@ -16,8 +16,8 @@ * along with GNSS-SDR. If not, see . */ -#ifndef VOLK_VOLK_OPTION_HELPERS_H -#define VOLK_VOLK_OPTION_HELPERS_H +#ifndef VOLK_GNSSSDR_OPTION_HELPERS_H +#define VOLK_GNSSSDR_OPTION_HELPERS_H #include #include @@ -71,4 +71,4 @@ private: }; -#endif //VOLK_VOLK_OPTION_HELPERS_H +#endif //VOLK_GNSSSDR_OPTION_HELPERS_H diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc index f59c0cb60..ca340b729 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc @@ -148,7 +148,7 @@ int main(int argc, char *argv[]) } catch (std::string &error) { - std::cerr << "Caught Exception in 'run_volk_gnssdr_tests': " << error << std::endl; + std::cerr << "Caught Exception in 'run_volk_gnsssdr_tests': " << error << std::endl; } } } diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.h index 0b1a6a46e..bd22b3e84 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.h @@ -32,7 +32,7 @@ #include // for string #include // for vector -class volk_test_results_t; +class volk_gnsssdr_test_results_t; void read_results(std::vector *results); diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkAddTest.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkAddTest.cmake index 4106678e8..e78a3e30e 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkAddTest.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/VolkAddTest.cmake @@ -22,24 +22,40 @@ if(DEFINED __INCLUDED_VOLK_ADD_TEST) endif() set(__INCLUDED_VOLK_ADD_TEST TRUE) +######################################################################## +# Generate a test executable which can be used in ADD_TEST to call +# various subtests. +# +# SOURCES - sources for the test +# TARGET_DEPS - build target dependencies (e.g., libraries) +######################################################################## + +function(VOLK_GEN_TEST executable_name) + include(CMakeParseArgumentsCopy) + CMAKE_PARSE_ARGUMENTS(VOLK_TEST "" "" "SOURCES;TARGET_DEPS;EXTRA_LIB_DIRS;ENVIRONS;ARGS" ${ARGN}) + add_executable(${executable_name} ${VOLK_TEST_SOURCES}) + target_link_libraries(${executable_name} ${VOLK_TEST_TARGET_DEPS}) +endfunction() + ######################################################################## # Add a unit test and setup the environment for it. # Encloses ADD_TEST, with additional functionality to create a shell # script that sets the environment to gain access to in-build binaries # properly. The following variables are used to pass in settings: +# A test executable has to be generated with VOLK_GEN_TEST beforehand. +# The executable name has to be passed as argument. # # NAME - the test name -# SOURCES - sources for the test # TARGET_DEPS - build target dependencies (e.g., libraries) # EXTRA_LIB_DIRS - other directories for the library path # ENVIRONS - other environment key/value pairs # ARGS - arguments for the test ######################################################################## -function(VOLK_ADD_TEST test_name) +function(VOLK_ADD_TEST test_name executable_name) #parse the arguments for component names include(CMakeParseArgumentsCopy) - CMAKE_PARSE_ARGUMENTS(VOLK_TEST "" "" "SOURCES;TARGET_DEPS;EXTRA_LIB_DIRS;ENVIRONS;ARGS" ${ARGN}) + CMAKE_PARSE_ARGUMENTS(VOLK_TEST "" "" "TARGET_DEPS;EXTRA_LIB_DIRS;ENVIRONS;ARGS" ${ARGN}) #set the initial environs to use set(environs ${VOLK_TEST_ENVIRONS}) @@ -65,7 +81,7 @@ function(VOLK_ADD_TEST test_name) #"add_test" command, via the $ operator; make sure the #test's directory is first, since it ($1) is prepended to PATH. unset(TARGET_DIR_LIST) - foreach(target ${test_name} ${VOLK_TEST_TARGET_DEPS}) + foreach(target ${executable_name} ${VOLK_TEST_TARGET_DEPS}) list(APPEND TARGET_DIR_LIST "\$") endforeach() @@ -134,18 +150,17 @@ function(VOLK_ADD_TEST test_name) file(APPEND ${sh_file} "export ${environ}\n") endforeach(environ) + set(VOLK_TEST_ARGS "${test_name}") + #redo the test args to have a space between each string(REPLACE ";" " " VOLK_TEST_ARGS "${VOLK_TEST_ARGS}") #finally: append the test name to execute - file(APPEND ${sh_file} ${test_name} " " ${VOLK_TEST_ARGS} "\n") + file(APPEND ${sh_file} "${CMAKE_CROSSCOMPILING_EMULATOR} ${executable_name} ${VOLK_TEST_ARGS}\n") #make the shell file executable execute_process(COMMAND chmod +x ${sh_file}) - add_executable(${test_name} ${VOLK_TEST_SOURCES}) - target_link_libraries(${test_name} ${VOLK_TEST_TARGET_DEPS}) - #add the shell file as the test to execute; #use the form that allows for $ substitutions, #then combine the script arguments inside the script. @@ -196,10 +211,8 @@ function(VOLK_ADD_TEST test_name) file(APPEND ${bat_file} ${test_name} " " ${VOLK_TEST_ARGS} "\n") file(APPEND ${bat_file} "\n") - add_executable(${test_name} ${VOLK_TEST_SOURCES}) - target_link_libraries(${test_name} ${VOLK_TEST_TARGET_DEPS}) - add_test(${test_name} ${bat_file}) endif(WIN32) endfunction(VOLK_ADD_TEST) + diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_dot_prod_16ic.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_dot_prod_16ic.h index 313824556..ccf815d56 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_dot_prod_16ic.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_dot_prod_16ic.h @@ -187,7 +187,7 @@ static inline void volk_gnsssdr_16ic_x2_dot_prod_16ic_u_sse2(lv_16sc_t* out, con for (number = 0; number < sse_iters; number++) { //std::complex memory structure: real part -> reinterpret_cast(a)[2*i] - //imaginery part -> reinterpret_cast(a)[2*i + 1] + //imaginary part -> reinterpret_cast(a)[2*i + 1] // a[127:0]=[a3.i,a3.r,a2.i,a2.r,a1.i,a1.r,a0.i,a0.r] a = _mm_loadu_si128((__m128i*)_in_a); //load (2 byte imag, 2 byte real) x 4 into 128 bits reg __VOLK_GNSSSDR_PREFETCH(_in_a + 8); diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_multiply_16ic.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_multiply_16ic.h index 596c13bf5..9548f8954 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_multiply_16ic.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_x2_multiply_16ic.h @@ -94,7 +94,7 @@ static inline void volk_gnsssdr_16ic_x2_multiply_16ic_a_sse2(lv_16sc_t* out, con for (number = 0; number < sse_iters; number++) { //std::complex memory structure: real part -> reinterpret_cast(a)[2*i] - //imaginery part -> reinterpret_cast(a)[2*i + 1] + //imaginary part -> reinterpret_cast(a)[2*i + 1] // a[127:0]=[a3.i,a3.r,a2.i,a2.r,a1.i,a1.r,a0.i,a0.r] a = _mm_load_si128((__m128i*)_in_a); //load (2 byte imag, 2 byte real) x 4 into 128 bits reg b = _mm_load_si128((__m128i*)_in_b); @@ -148,7 +148,7 @@ static inline void volk_gnsssdr_16ic_x2_multiply_16ic_u_sse2(lv_16sc_t* out, con for (number = 0; number < sse_iters; number++) { //std::complex memory structure: real part -> reinterpret_cast(a)[2*i] - //imaginery part -> reinterpret_cast(a)[2*i + 1] + //imaginary part -> reinterpret_cast(a)[2*i + 1] // a[127:0]=[a3.i,a3.r,a2.i,a2.r,a1.i,a1.r,a0.i,a0.r] a = _mm_loadu_si128((__m128i*)_in_a); //load (2 byte imag, 2 byte real) x 4 into 128 bits reg b = _mm_loadu_si128((__m128i*)_in_b); diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_xn_resampler_fast_16ic_xn.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_xn_resampler_fast_16ic_xn.h index d583595a4..112c213df 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_xn_resampler_fast_16ic_xn.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/kernels/volk_gnsssdr/volk_gnsssdr_16ic_xn_resampler_fast_16ic_xn.h @@ -6,7 +6,7 @@ * * * VOLK_GNSSSDR kernel that esamples N 16 bits integer short complex vectors using zero hold resample algorithm. - * It is optimized to resample a sigle GNSS local code signal replica into N vectors fractional-resampled and fractional-delayed + * It is optimized to resample a single GNSS local code signal replica into N vectors fractional-resampled and fractional-delayed * (i.e. it creates the Early, Prompt, and Late code replicas) * * ------------------------------------------------------------------------- @@ -145,7 +145,7 @@ static inline void volk_gnsssdr_16ic_xn_resampler_fast_16ic_xn_a_sse2(lv_16sc_t* //common to all outputs _code_phase_out = _mm_mul_ps(_code_phase_step_chips, _4output_index); //compute the code phase point with the phase step - //output vector dependant (different code phase offset) + //output vector dependent (different code phase offset) for (current_vector = 0; current_vector < num_out_vectors; current_vector++) { tmp_rem_code_phase_chips = rem_code_phase_chips[current_vector] - 0.5f; // adjust offset to perform correct rounding (chip transition at 0) @@ -241,7 +241,7 @@ static inline void volk_gnsssdr_16ic_xn_resampler_fast_16ic_xn_u_sse2(lv_16sc_t* //common to all outputs _code_phase_out = _mm_mul_ps(_code_phase_step_chips, _4output_index); //compute the code phase point with the phase step - //output vector dependant (different code phase offset) + //output vector dependent (different code phase offset) for (current_vector = 0; current_vector < num_out_vectors; current_vector++) { tmp_rem_code_phase_chips = rem_code_phase_chips[current_vector] - 0.5f; // adjust offset to perform correct rounding (chip transition at 0) @@ -339,7 +339,7 @@ static inline void volk_gnsssdr_16ic_xn_resampler_fast_16ic_xn_neon(lv_16sc_t** //common to all outputs _code_phase_out = vmulq_f32(_code_phase_step_chips, _4output_index); //compute the code phase point with the phase step - //output vector dependant (different code phase offset) + //output vector dependent (different code phase offset) for (current_vector = 0; current_vector < num_out_vectors; current_vector++) { tmp_rem_code_phase_chips = rem_code_phase_chips[current_vector] - 0.5f; // adjust offset to perform correct rounding (chip transition at 0) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt index 97847d51c..bf0bdd3a2 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/CMakeLists.txt @@ -345,7 +345,7 @@ macro(gen_template tmpl output) ) endmacro(gen_template) -make_directory(${PROJECT_BINARY_DIR}/include/volk_gnsssdr) +file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/include/volk_gnsssdr) gen_template(${PROJECT_SOURCE_DIR}/tmpl/volk_gnsssdr.tmpl.h ${PROJECT_BINARY_DIR}/include/volk_gnsssdr/volk_gnsssdr.h) gen_template(${PROJECT_SOURCE_DIR}/tmpl/volk_gnsssdr.tmpl.c ${PROJECT_BINARY_DIR}/lib/volk_gnsssdr.c) @@ -604,18 +604,24 @@ if(ENABLE_TESTING) #include Boost headers include_directories(${Boost_INCLUDE_DIRS}) - link_directories(${Boost_LIBRARY_DIRS}) - make_directory(${CMAKE_CURRENT_BINARY_DIR}/.unittest) + file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/.unittest) set_source_files_properties( ${CMAKE_CURRENT_SOURCE_DIR}/testqa.cc PROPERTIES COMPILE_DEFINITIONS "BOOST_TEST_DYN_LINK;BOOST_TEST_MAIN" ) include(VolkAddTest) - VOLK_ADD_TEST(test_all + VOLK_GEN_TEST("volk_gnsssdr_test_all" SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/testqa.cc - ${CMAKE_CURRENT_SOURCE_DIR}/qa_utils.cc + ${CMAKE_CURRENT_SOURCE_DIR}/qa_utils.cc TARGET_DEPS volk_gnsssdr - ) + ) + foreach(kernel ${h_files}) + get_filename_component(kernel ${kernel} NAME) + string(REPLACE ".h" "" kernel ${kernel}) + if(NOT ${kernel} MATCHES puppet*) + VOLK_ADD_TEST(${kernel} "volk_gnsssdr_test_all") + endif(NOT ${kernel} MATCHES puppet*) + endforeach() endif(ENABLE_TESTING) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc index 18a4919e2..39c142a82 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/qa_utils.cc @@ -16,14 +16,10 @@ * along with GNSS-SDR. If not, see . */ +#include "volk_gnsssdr/volk_gnsssdr.h" // for volk_gnsssdr_func_desc_t #include "qa_utils.h" -#include "volk_gnsssdr/volk_gnsssdr.h" // for volk_gnsssdr_func_desc_t -#include "volk_gnsssdr/volk_gnsssdr_malloc.h" // for volk_gnsssdr_free, volk_gnsssdr_malloc -#include // for auto_any_base -#include // for lexical_cast -#include // for char_separator -#include // for token_iterator -#include // for tokenizer + +#include // for volk_gnsssdr_free, volk_gnsssdr_malloc #include // for assert #include // for system_clock, duration,... #include // for sqrt, fabs, abs @@ -122,6 +118,24 @@ static std::vector get_arch_list(volk_gnsssdr_func_desc_t desc) return archlist; } +template +T volk_lexical_cast(const std::string &str) +{ + for (unsigned int c_index = 0; c_index < str.size(); ++c_index) + { + if (str.at(c_index) < '0' || str.at(c_index) > '9') + { + throw "not all numbers!"; + } + } + T var; + std::istringstream iss; + iss.str(str); + iss >> var; + // deal with any error bits that may have been set on the stream + return var; +} + volk_gnsssdr_type_t volk_gnsssdr_type_from_string(std::string name) { volk_gnsssdr_type_t type; @@ -151,7 +165,7 @@ volk_gnsssdr_type_t volk_gnsssdr_type_from_string(std::string name) throw std::string("no size spec in type ").append(name); } //will throw if malformed - int size = boost::lexical_cast(name.substr(0, last_size_pos + 1)); + int size = volk_lexical_cast(name.substr(0, last_size_pos + 1)); assert(((size % 8) == 0) && (size <= 64) && (size != 0)); type.size = size / 8; //in bytes @@ -180,21 +194,42 @@ volk_gnsssdr_type_t volk_gnsssdr_type_from_string(std::string name) return type; } +std::vector split_signature(const std::string &protokernel_signature) +{ + std::vector signature_tokens; + std::string token; + for (unsigned int loc = 0; loc < protokernel_signature.size(); ++loc) + { + if (protokernel_signature.at(loc) == '_') + { + if (protokernel_signature.substr(loc + 1, 7).compare("gnsssdr") == 0) // jump the "gnsssdr" part of "volk_gnsssdr" + { + loc += 7; + } + else + { + // this is a break + signature_tokens.push_back(token); + token = ""; + } + } + else + { + token.push_back(protokernel_signature.at(loc)); + } + } + // Get the last one to the end of the string + signature_tokens.push_back(token); + return signature_tokens; +} + static void get_signatures_from_name(std::vector &inputsig, std::vector &outputsig, std::string name) { - boost::char_separator sep("_"); - boost::tokenizer > tok(name, sep); - std::vector toked; - tok.assign(name); - toked.assign(tok.begin(), tok.end()); + std::vector toked = split_signature(name); assert(toked[0] == "volk"); toked.erase(toked.begin()); - toked.erase(toked.begin()); - - //ok. we're assuming a string in the form - //(sig)_(multiplier-opt)_..._(name)_(sig)_(multiplier-opt)_..._(alignment) enum { @@ -204,8 +239,9 @@ static void get_signatures_from_name(std::vector &inputsig, } side = SIDE_INPUT; std::string fn_name; volk_gnsssdr_type_t type; - BOOST_FOREACH (std::string token, toked) + for (unsigned int token_index = 0; token_index < toked.size(); ++token_index) { + std::string token = toked[token_index]; try { type = volk_gnsssdr_type_from_string(token); @@ -224,7 +260,7 @@ static void get_signatures_from_name(std::vector &inputsig, assert(inputsig.size() > 0); else assert(outputsig.size() > 0); - int multiplier = boost::lexical_cast(token.substr(1, token.size() - 1)); //will throw if invalid /////////// + int multiplier = volk_lexical_cast(token.substr(1, token.size() - 1)); // will throw if invalid for (int i = 1; i < multiplier; i++) { if (side == SIDE_INPUT) @@ -523,7 +559,7 @@ bool run_volk_gnsssdr_tests(volk_gnsssdr_func_desc_t desc, { get_signatures_from_name(inputsig, outputsig, name); } - catch (boost::bad_lexical_cast &error) + catch (std::exception &error) { std::cerr << "Error: unable to get function signature from kernel name" << std::endl; std::cerr << " - " << name << std::endl; @@ -542,8 +578,9 @@ bool run_volk_gnsssdr_tests(volk_gnsssdr_func_desc_t desc, } } std::vector inbuffs; - BOOST_FOREACH (volk_gnsssdr_type_t sig, inputsig) + for (unsigned int inputsig_index = 0; inputsig_index < inputsig.size(); ++inputsig_index) { + volk_gnsssdr_type_t sig = inputsig[inputsig_index]; if (!sig.is_scalar) //we don't make buffers for scalars inbuffs.push_back(mem_pool.get_new(vlen * sig.size * (sig.is_complex ? 2 : 1))); } @@ -703,6 +740,9 @@ bool run_volk_gnsssdr_tests(volk_gnsssdr_func_desc_t desc, else throw "unsupported 3 arg function >1 scalars"; break; + case 4: + run_cast_test4((volk_gnsssdr_fn_4arg)(manual_func), test_data[i], vlen, iter, arch_list[i]); + break; default: throw "no function handler for this signature"; break; diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/testqa.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/testqa.cc index 7e22442da..ed57aeb03 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/testqa.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/lib/testqa.cc @@ -31,7 +31,7 @@ void print_qa_xml(std::vector results, unsigned int nfails); -int main() +int main(int argc, char* argv[]) { bool qa_ret_val = 0; @@ -45,47 +45,78 @@ int main() volk_gnsssdr_test_params_t test_params(def_tol, def_scalar, def_vlen, def_iter, def_benchmark_mode, def_kernel_regex); std::vector test_cases = init_test_list(test_params); - - std::vector qa_failures; std::vector results; - // Test every kernel reporting failures when they occur - for (unsigned int ii = 0; ii < test_cases.size(); ++ii) + if (argc > 1) { - bool qa_result = false; - volk_gnsssdr_test_case_t test_case = test_cases[ii]; - try + const size_t len = std::char_traits::length(argv[1]); + if (len == 0 || len > 2046) { - qa_result = run_volk_gnsssdr_tests(test_case.desc(), test_case.kernel_ptr(), test_case.name(), - test_case.test_parameters(), &results, test_case.puppet_master_name()); + std::cerr << "Test name is too long." << std::endl; + return 0; } - catch (...) + for (unsigned int ii = 0; ii < test_cases.size(); ++ii) { - // TODO: what exceptions might we need to catch and how do we handle them? - std::cerr << "Exception found on kernel: " << test_case.name() << std::endl; - qa_result = false; - } - - if (qa_result) - { - std::cerr << "Failure on " << test_case.name() << std::endl; - qa_failures.push_back(test_case.name()); + if (std::string(argv[1]) == test_cases[ii].name()) + { + volk_gnsssdr_test_case_t test_case = test_cases[ii]; + if (run_volk_gnsssdr_tests(test_case.desc(), test_case.kernel_ptr(), + test_case.name(), + test_case.test_parameters(), &results, + test_case.puppet_master_name())) + { + return 1; + } + else + { + return 0; + } + } } + std::cerr << "Did not run a test for kernel: " << std::string(argv[1]) << " !" << std::endl; + return 0; } - - // Generate XML results - print_qa_xml(results, qa_failures.size()); - - // Summarize QA results - std::cerr << "Kernel QA finished: " << qa_failures.size() << " failures out of " - << test_cases.size() << " tests." << std::endl; - if (qa_failures.size() > 0) + else { - std::cerr << "The following kernels failed QA:" << std::endl; - for (unsigned int ii = 0; ii < qa_failures.size(); ++ii) + std::vector qa_failures; + // Test every kernel reporting failures when they occur + for (unsigned int ii = 0; ii < test_cases.size(); ++ii) { - std::cerr << " " << qa_failures[ii] << std::endl; + bool qa_result = false; + volk_gnsssdr_test_case_t test_case = test_cases[ii]; + try + { + qa_result = run_volk_gnsssdr_tests(test_case.desc(), test_case.kernel_ptr(), test_case.name(), + test_case.test_parameters(), &results, test_case.puppet_master_name()); + } + catch (...) + { + // TODO: what exceptions might we need to catch and how do we handle them? + std::cerr << "Exception found on kernel: " << test_case.name() << std::endl; + qa_result = false; + } + + if (qa_result) + { + std::cerr << "Failure on " << test_case.name() << std::endl; + qa_failures.push_back(test_case.name()); + } + } + + // Generate XML results + print_qa_xml(results, qa_failures.size()); + + // Summarize QA results + std::cerr << "Kernel QA finished: " << qa_failures.size() << " failures out of " + << test_cases.size() << " tests." << std::endl; + if (qa_failures.size() > 0) + { + std::cerr << "The following kernels failed QA:" << std::endl; + for (unsigned int ii = 0; ii < qa_failures.size(); ++ii) + { + std::cerr << " " << qa_failures[ii] << std::endl; + } + qa_ret_val = 1; } - qa_ret_val = 1; } return qa_ret_val; @@ -128,7 +159,6 @@ void print_qa_xml(std::vector results, unsigned int qa_file << " " << std::endl; } - qa_file << "" << std::endl; qa_file.close(); } diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/tmpl/volk_gnsssdr.tmpl.h b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/tmpl/volk_gnsssdr.tmpl.h index 4164a29dd..8a4c7799b 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/tmpl/volk_gnsssdr.tmpl.h +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/tmpl/volk_gnsssdr.tmpl.h @@ -35,7 +35,7 @@ typedef struct volk_gnsssdr_func_desc const char **impl_names; const int *impl_deps; const bool *impl_alignment; - const size_t n_impls; + size_t n_impls; } volk_gnsssdr_func_desc_t; //! Prints a list of machines available @@ -68,12 +68,12 @@ VOLK_API size_t volk_gnsssdr_get_alignment(void); */ VOLK_API bool volk_gnsssdr_is_aligned(const void *ptr); +// clang-format off %for kern in kernels: //! A function pointer to the dispatcher implementation extern VOLK_API ${kern.pname} ${kern.name}; -// clang-format off //! A function pointer to the fastest aligned implementation extern VOLK_API ${kern.pname} ${kern.name}_a; @@ -86,9 +86,7 @@ extern VOLK_API void ${kern.name}_manual(${kern.arglist_full}, const char* impl_ //! Get description parameters for this kernel extern VOLK_API volk_gnsssdr_func_desc_t ${kern.name}_get_func_desc(void); %endfor -// clang-format off - __VOLK_DECL_END - +// clang-format on #endif /*INCLUDED_VOLK_GNSSSDR_RUNTIME*/ diff --git a/src/algorithms/resampler/adapters/CMakeLists.txt b/src/algorithms/resampler/adapters/CMakeLists.txt index e929c3ffc..0a44d3454 100644 --- a/src/algorithms/resampler/adapters/CMakeLists.txt +++ b/src/algorithms/resampler/adapters/CMakeLists.txt @@ -32,9 +32,9 @@ include_directories( ) -if(${PC_GNURADIO_RUNTIME_VERSION} VERSION_GREATER "3.7.13" ) +if(${PC_GNURADIO_RUNTIME_VERSION} VERSION_GREATER "3.7.15" ) add_definitions( -DGR_GREATER_38=1 ) -endif(${PC_GNURADIO_RUNTIME_VERSION} VERSION_GREATER "3.7.13" ) +endif(${PC_GNURADIO_RUNTIME_VERSION} VERSION_GREATER "3.7.15" ) file(GLOB RESAMPLER_ADAPTER_HEADERS "*.h") diff --git a/src/algorithms/signal_generator/adapters/signal_generator.cc b/src/algorithms/signal_generator/adapters/signal_generator.cc index 504a7896b..fab20c06e 100644 --- a/src/algorithms/signal_generator/adapters/signal_generator.cc +++ b/src/algorithms/signal_generator/adapters/signal_generator.cc @@ -35,7 +35,7 @@ #include "Galileo_E1.h" #include "GPS_L1_CA.h" #include "Galileo_E5a.h" -#include "GLONASS_L1_CA.h" +#include "GLONASS_L1_L2_CA.h" #include @@ -100,7 +100,14 @@ SignalGenerator::SignalGenerator(ConfigurationInterface* configuration, } else if (std::find(system.begin(), system.end(), "R") != system.end()) { - vector_length = round((float)fs_in / (GLONASS_L1_CA_CODE_RATE_HZ / GLONASS_L1_CA_CODE_LENGTH_CHIPS)); + if (signal1[0].at(0) == '1') + { + vector_length = round((float)fs_in / (GLONASS_L1_CA_CODE_RATE_HZ / GLONASS_L1_CA_CODE_LENGTH_CHIPS)); + } + else + { + vector_length = round((float)fs_in / (GLONASS_L2_CA_CODE_RATE_HZ / GLONASS_L2_CA_CODE_LENGTH_CHIPS)); + } } if (item_type_.compare("gr_complex") == 0) 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 545254016..3cd4c92d9 100644 --- a/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.cc +++ b/src/algorithms/signal_generator/gnuradio_blocks/signal_generator_c.cc @@ -36,11 +36,12 @@ #include "Galileo_E1.h" #include "Galileo_E5a.h" #include "GPS_L1_CA.h" -#include "GLONASS_L1_CA.h" +#include "GLONASS_L1_L2_CA.h" #include #include #include + /* * Create a new instance of signal_generator_c and return * a boost shared_ptr. This is effectively the public constructor. diff --git a/src/algorithms/signal_source/adapters/fmcomms2_signal_source.cc b/src/algorithms/signal_source/adapters/fmcomms2_signal_source.cc index 389e9fd36..6caf9ddee 100644 --- a/src/algorithms/signal_source/adapters/fmcomms2_signal_source.cc +++ b/src/algorithms/signal_source/adapters/fmcomms2_signal_source.cc @@ -32,7 +32,9 @@ #include "fmcomms2_signal_source.h" #include "configuration_interface.h" #include "gnss_sdr_valve.h" +#include "ad9361_manager.h" #include "GPS_L1_CA.h" +#include "GPS_L2C.h" #include #include @@ -55,6 +57,7 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration quadrature_ = configuration->property(role + ".quadrature", true); rf_dc_ = configuration->property(role + ".rf_dc", true); bb_dc_ = configuration->property(role + ".bb_dc", true); + RF_channels_ = configuration->property(role + ".RF_channels", 1); gain_mode_rx1_ = configuration->property(role + ".gain_mode_rx1", std::string("manual")); gain_mode_rx2_ = configuration->property(role + ".gain_mode_rx2", std::string("manual")); rf_gain_rx1_ = configuration->property(role + ".gain_rx1", 64.0); @@ -67,6 +70,14 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration dump_ = configuration->property(role + ".dump", false); dump_filename_ = configuration->property(role + ".dump_filename", default_dump_file); + //AD9361 Local Oscillator generation for dual band operation + enable_dds_lo_ = configuration->property(role + ".enable_dds_lo", false); + freq_rf_tx_hz_ = configuration->property(role + ".freq_rf_tx_hz", GPS_L1_FREQ_HZ - GPS_L2_FREQ_HZ - 1000); + freq_dds_tx_hz_ = configuration->property(role + ".freq_dds_tx_hz", 1000); + scale_dds_dbfs_ = configuration->property(role + ".scale_dds_dbfs", 0.0); + phase_dds_deg_ = configuration->property(role + ".phase_dds_deg", 0.0); + tx_attenuation_db_ = configuration->property(role + ".tx_attenuation_db", 0.0); + item_size_ = sizeof(gr_complex); std::cout << "device address: " << uri_ << std::endl; @@ -75,15 +86,73 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration if (item_type_.compare("gr_complex") == 0) { - fmcomms2_source_f32c_ = gr::iio::fmcomms2_source_f32c::make( - uri_.c_str(), freq_, sample_rate_, - bandwidth_, - rx1_en_, rx2_en_, - buffer_size_, quadrature_, rf_dc_, - bb_dc_, gain_mode_rx1_.c_str(), rf_gain_rx1_, - gain_mode_rx2_.c_str(), rf_gain_rx2_, - rf_port_select_.c_str(), filter_file_.c_str(), - filter_auto_); + if (RF_channels_ == 1) + { + if (rx1_en_ and rx2_en_) + { + LOG(FATAL) << "Configuration error: both rx1 and rx2 are enabled but RF_channels=1 !"; + } + else + { + fmcomms2_source_f32c_ = gr::iio::fmcomms2_source_f32c::make( + uri_.c_str(), freq_, sample_rate_, + bandwidth_, + rx1_en_, rx2_en_, + buffer_size_, quadrature_, rf_dc_, + bb_dc_, gain_mode_rx1_.c_str(), rf_gain_rx1_, + gain_mode_rx2_.c_str(), rf_gain_rx2_, + rf_port_select_.c_str(), filter_file_.c_str(), + filter_auto_); + + //configure LO + if (enable_dds_lo_ == true) + { + std::cout << "Enabling Local Oscillator generator in FMCOMMS2\n"; + config_ad9361_lo_remote(uri_, + bandwidth_, + sample_rate_, + freq_rf_tx_hz_, + tx_attenuation_db_, + freq_dds_tx_hz_, + scale_dds_dbfs_); + } + } + } + else if (RF_channels_ == 2) + { + if (!(rx1_en_ and rx2_en_)) + { + LOG(FATAL) << "Configuration error: RF_channels=2 but are not enabled both receivers in FMCOMMS2 !"; + } + else + { + fmcomms2_source_f32c_ = gr::iio::fmcomms2_source_f32c::make( + uri_.c_str(), freq_, sample_rate_, + bandwidth_, + rx1_en_, rx2_en_, + buffer_size_, quadrature_, rf_dc_, + bb_dc_, gain_mode_rx1_.c_str(), rf_gain_rx1_, + gain_mode_rx2_.c_str(), rf_gain_rx2_, + rf_port_select_.c_str(), filter_file_.c_str(), + filter_auto_); + //configure LO + if (enable_dds_lo_ == true) + { + std::cout << "Enabling Local Oscillator generator in FMCOMMS2\n"; + config_ad9361_lo_remote(uri_, + bandwidth_, + sample_rate_, + freq_rf_tx_hz_, + tx_attenuation_db_, + freq_dds_tx_hz_, + scale_dds_dbfs_); + } + } + } + else + { + LOG(FATAL) << "Configuration error: Unsupported number of RF_channels !"; + } } else { @@ -108,6 +177,10 @@ Fmcomms2SignalSource::Fmcomms2SignalSource(ConfigurationInterface* configuration Fmcomms2SignalSource::~Fmcomms2SignalSource() { + if (enable_dds_lo_ == true) + { + ad9361_disable_lo_remote(uri_); + } } diff --git a/src/algorithms/signal_source/adapters/fmcomms2_signal_source.h b/src/algorithms/signal_source/adapters/fmcomms2_signal_source.h index 1c24e4b4c..014299981 100644 --- a/src/algorithms/signal_source/adapters/fmcomms2_signal_source.h +++ b/src/algorithms/signal_source/adapters/fmcomms2_signal_source.h @@ -88,6 +88,7 @@ private: bool quadrature_; bool rf_dc_; bool bb_dc_; + int RF_channels_; std::string gain_mode_rx1_; std::string gain_mode_rx2_; double rf_gain_rx1_; @@ -96,6 +97,14 @@ private: std::string filter_file_; bool filter_auto_; + //DDS configuration for LO generation for external mixer + bool enable_dds_lo_; + unsigned long freq_rf_tx_hz_; + unsigned long freq_dds_tx_hz_; + double scale_dds_dbfs_; + double phase_dds_deg_; + double tx_attenuation_db_; + unsigned int in_stream_; unsigned int out_stream_; diff --git a/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.cc b/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.cc index 6d22cecc2..2eee7ac21 100644 --- a/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.cc +++ b/src/algorithms/signal_source/adapters/rtl_tcp_signal_source.cc @@ -55,7 +55,7 @@ RtlTcpSignalSource::RtlTcpSignalSource(ConfigurationInterface* configuration, dump_filename_ = configuration->property(role + ".dump_filename", default_dump_file); - // rtl_tcp PARAMTERS + // rtl_tcp PARAMETERS std::string default_address = "127.0.0.1"; short default_port = 1234; AGC_enabled_ = configuration->property(role + ".AGC_enabled", true); 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 e70531795..6af2f3dd7 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/unpack_2bit_samples.cc +++ b/src/algorithms/signal_source/gnuradio_blocks/unpack_2bit_samples.cc @@ -121,7 +121,7 @@ unpack_2bit_samples::unpack_2bit_samples(bool big_endian_bytes, bool big_endian_system = systemIsBigEndian(); // Only swap the item bytes if the item size > 1 byte and the system - // endianess is not the same as the item endianness: + // endianness is not the same as the item endianness: swap_endian_items_ = (item_size_ > 1) && (big_endian_system != big_endian_items); diff --git a/src/algorithms/signal_source/libs/CMakeLists.txt b/src/algorithms/signal_source/libs/CMakeLists.txt index 1ecb1edfd..5a35a7992 100644 --- a/src/algorithms/signal_source/libs/CMakeLists.txt +++ b/src/algorithms/signal_source/libs/CMakeLists.txt @@ -16,16 +16,61 @@ # along with GNSS-SDR. If not, see . # +if(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2) + find_package(iio REQUIRED) + if(NOT IIO_FOUND) + message(STATUS "gnuradio-iio not found, its installation is required.") + message(STATUS "Please build and install the following projects:") + message(STATUS " * libiio from https://github.com/analogdevicesinc/libiio") + message(STATUS " * libad9361-iio from https://github.com/analogdevicesinc/libad9361-iio") + message(STATUS " * gnuradio-iio from https://github.com/analogdevicesinc/gr-iio") + message(FATAL_ERROR "gnuradio-iio required for building gnss-sdr with this option enabled") + endif(NOT IIO_FOUND) + set(OPT_LIBRARIES ${OPT_LIBRARIES} ${IIO_LIBRARIES}) + set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS}) + + find_package(libiio REQUIRED) + if(NOT LIBIIO_FOUND) + message(STATUS "gnuradio-iio not found, its installation is required.") + message(STATUS "Please build and install the following projects:") + message(STATUS " * libiio from https://github.com/analogdevicesinc/libiio") + message(STATUS " * libad9361-iio from https://github.com/analogdevicesinc/libad9361-iio") + message(STATUS " * gnuradio-iio from https://github.com/analogdevicesinc/gr-iio") + message(FATAL_ERROR "gnuradio-iio required for building gnss-sdr with this option enabled") + endif(NOT LIBIIO_FOUND) + set(OPT_LIBRARIES ${OPT_LIBRARIES} ${LIBIIO_LIBRARIES}) + set(OPT_DRIVER_INCLUDE_DIRS ${OPT_DRIVER_INCLUDE_DIRS} ${LIBIIO_INCLUDE_DIRS}) + +endif(ENABLE_PLUTOSDR OR ENABLE_FMCOMMS2) + +if(ENABLE_FMCOMMS2) + ############################################### + # FMCOMMS2 based SDR Hardware + ############################################### + if(IIO_FOUND) + set(OPT_SIGNAL_SOURCE_LIB_SOURCES ad9361_manager.cc) + endif(IIO_FOUND) +endif(ENABLE_FMCOMMS2) + set (SIGNAL_SOURCE_LIB_SOURCES rtl_tcp_commands.cc - rtl_tcp_dongle_info.cc) + rtl_tcp_dongle_info.cc + ${OPT_SIGNAL_SOURCE_LIB_SOURCES}) include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${Boost_INCLUDE_DIRS} + ${GLOG_INCLUDE_DIRS} + ${GFlags_INCLUDE_DIRS} + ${OPT_DRIVER_INCLUDE_DIRS} ) + file(GLOB SIGNAL_SOURCE_LIB_HEADERS "*.h") list(SORT SIGNAL_SOURCE_LIB_HEADERS) +list(SORT SIGNAL_SOURCE_LIB_SOURCES) add_library(signal_source_lib ${SIGNAL_SOURCE_LIB_SOURCES} ${SIGNAL_SOURCE_LIB_HEADERS}) -source_group(Headers FILES ${SIGNAL_SOURCE_LIB_HEADERS}) \ No newline at end of file +source_group(Headers FILES ${SIGNAL_SOURCE_LIB_HEADERS}) +add_dependencies(signal_source_lib glog-${glog_RELEASE}) +target_link_libraries(signal_source_lib ${OPT_LIBRARIES}) + diff --git a/src/algorithms/signal_source/libs/ad9361_manager.cc b/src/algorithms/signal_source/libs/ad9361_manager.cc new file mode 100644 index 000000000..b0a41bd55 --- /dev/null +++ b/src/algorithms/signal_source/libs/ad9361_manager.cc @@ -0,0 +1,764 @@ +/*! + * \file ad9361_manager.cc + * \brief An Analog Devices AD9361 front-end configuration library wrapper for configure some functions via iiod link. + * \author Javier Arribas, jarribas(at)cttc.es + * + * This file contains information taken from librtlsdr: + * http://git.osmocom.org/rtl-sdr/ + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ +#include "ad9361_manager.h" +#include +#include +#include +#include + + +/* check return value of attr_write function */ +void errchk(int v, const char *what) +{ + if (v < 0) + { + LOG(WARNING) << "Error " << v << " writing to channel " << what << " value may not be supported. "; + } +} + + +/* write attribute: long long int */ +void wr_ch_lli(struct iio_channel *chn, const char *what, long long val) +{ + errchk(iio_channel_attr_write_longlong(chn, what, val), what); +} + + +/* write attribute: string */ +void wr_ch_str(struct iio_channel *chn, const char *what, const char *str) +{ + errchk(iio_channel_attr_write(chn, what, str), what); +} + + +/* returns ad9361 phy device */ +struct iio_device *get_ad9361_phy(struct iio_context *ctx) +{ + struct iio_device *dev = iio_context_find_device(ctx, "ad9361-phy"); + return dev; +} + + +/* finds AD9361 streaming IIO devices */ +bool get_ad9361_stream_dev(struct iio_context *ctx, enum iodev d, struct iio_device **dev) +{ + switch (d) + { + case TX: + *dev = iio_context_find_device(ctx, "cf-ad9361-dds-core-lpc"); + return *dev != NULL; + case RX: + *dev = iio_context_find_device(ctx, "cf-ad9361-lpc"); + return *dev != NULL; + default: + return false; + } +} + + +/* finds AD9361 streaming IIO channels */ +bool get_ad9361_stream_ch(struct iio_context *ctx, enum iodev d, struct iio_device *dev, int chid, struct iio_channel **chn) +{ + std::stringstream name; + name.str(""); + name << "voltage"; + name << chid; + *chn = iio_device_find_channel(dev, name.str().c_str(), d == TX); + if (!*chn) + { + name.str(""); + name << "altvoltage"; + name << chid; + *chn = iio_device_find_channel(dev, name.str().c_str(), d == TX); + } + return *chn != NULL; +} + + +/* finds AD9361 phy IIO configuration channel with id chid */ +bool get_phy_chan(struct iio_context *ctx, enum iodev d, int chid, struct iio_channel **chn) +{ + std::stringstream name; + switch (d) + { + case RX: + name.str(""); + name << "voltage"; + name << chid; + *chn = iio_device_find_channel(get_ad9361_phy(ctx), name.str().c_str(), false); + return *chn != NULL; + break; + case TX: + name.str(""); + name << "voltage"; + name << chid; + *chn = iio_device_find_channel(get_ad9361_phy(ctx), name.str().c_str(), true); + return *chn != NULL; + break; + default: + return false; + } +} + + +/* finds AD9361 local oscillator IIO configuration channels */ +bool get_lo_chan(struct iio_context *ctx, enum iodev d, struct iio_channel **chn) +{ + switch (d) + { + // LO chan is always output, i.e. true + case RX: + *chn = iio_device_find_channel(get_ad9361_phy(ctx), "altvoltage0", true); + return *chn != NULL; + case TX: + *chn = iio_device_find_channel(get_ad9361_phy(ctx), "altvoltage1", true); + return *chn != NULL; + default: + return false; + } +} + + +/* applies streaming configuration through IIO */ +bool cfg_ad9361_streaming_ch(struct iio_context *ctx, struct stream_cfg *cfg, enum iodev type, int chid) +{ + struct iio_channel *chn = NULL; + + // Configure phy and lo channels + //LOG(INFO)<<"* Acquiring AD9361 phy channel"<rfport); + wr_ch_lli(chn, "rf_bandwidth", cfg->bw_hz); + wr_ch_lli(chn, "sampling_frequency", cfg->fs_hz); + + // Configure LO channel + //LOG(INFO)<<"* Acquiring AD9361 "<lo_hz); + return true; +} + + +bool config_ad9361_rx_local(unsigned long bandwidth_, + unsigned long sample_rate_, + unsigned long freq_, + std::string rf_port_select_, + std::string gain_mode_rx1_, + std::string gain_mode_rx2_, + double rf_gain_rx1_, + double rf_gain_rx2_) + +{ + // RX stream config + // Stream configurations + struct stream_cfg rxcfg; + rxcfg.bw_hz = bandwidth_; // 2 MHz rf bandwidth + rxcfg.fs_hz = sample_rate_; // 2.5 MS/s rx sample rate + rxcfg.lo_hz = freq_; // 2.5 GHz rf frequency + rxcfg.rfport = rf_port_select_.c_str(); // port A (select for rf freq.) + + std::cout << "AD9361 Acquiring IIO LOCAL context\n"; + struct iio_context *ctx; + // Streaming devices + struct iio_device *rx; + struct iio_channel *rx0_i; + struct iio_channel *rx0_q; + + ctx = iio_create_default_context(); + if (!ctx) + { + std::cout << "No context\n"; + throw std::runtime_error("AD9361 IIO No context"); + } + + if (iio_context_get_devices_count(ctx) <= 0) + { + std::cout << "No devices\n"; + throw std::runtime_error("AD9361 IIO No devices"); + } + + std::cout << "* Acquiring AD9361 streaming devices\n"; + + if (!get_ad9361_stream_dev(ctx, RX, &rx)) + { + std::cout << "No rx dev found\n"; + throw std::runtime_error("AD9361 IIO No rx dev found"); + }; + + std::cout << "* Configuring AD9361 for streaming\n"; + if (!cfg_ad9361_streaming_ch(ctx, &rxcfg, RX, 0)) + { + std::cout << "RX port 0 not found\n"; + throw std::runtime_error("AD9361 IIO RX port 0 not found"); + } + + std::cout << "* Initializing AD9361 IIO streaming channels\n"; + if (!get_ad9361_stream_ch(ctx, RX, rx, 0, &rx0_i)) + { + std::cout << "RX chan i not found\n"; + throw std::runtime_error("RX chan i not found"); + } + + if (!get_ad9361_stream_ch(ctx, RX, rx, 1, &rx0_q)) + { + std::cout << "RX chan q not found\n"; + throw std::runtime_error("RX chan q not found"); + } + + std::cout << "* Enabling IIO streaming channels\n"; + iio_channel_enable(rx0_i); + iio_channel_enable(rx0_q); + + struct iio_device *ad9361_phy; + ad9361_phy = iio_context_find_device(ctx, "ad9361-phy"); + int ret; + ret = iio_device_attr_write(ad9361_phy, "trx_rate_governor", "nominal"); + if (ret < 0) + { + std::cout << "Failed to set trx_rate_governor: " << ret << std::endl; + } + ret = iio_device_attr_write(ad9361_phy, "ensm_mode", "fdd"); + if (ret < 0) + { + std::cout << "Failed to set ensm_mode: " << ret << std::endl; + } + ret = iio_device_attr_write(ad9361_phy, "calib_mode", "auto"); + if (ret < 0) + { + std::cout << "Failed to set calib_mode: " << ret << std::endl; + } + ret = iio_device_attr_write(ad9361_phy, "in_voltage0_gain_control_mode", gain_mode_rx1_.c_str()); + if (ret < 0) + { + std::cout << "Failed to set in_voltage0_gain_control_mode: " << ret << std::endl; + } + ret = iio_device_attr_write(ad9361_phy, "in_voltage1_gain_control_mode", gain_mode_rx2_.c_str()); + if (ret < 0) + { + std::cout << "Failed to set in_voltage1_gain_control_mode: " << ret << std::endl; + } + ret = iio_device_attr_write_double(ad9361_phy, "in_voltage0_hardwaregain", rf_gain_rx1_); + if (ret < 0) + { + std::cout << "Failed to set in_voltage0_hardwaregain: " << ret << std::endl; + } + ret = iio_device_attr_write_double(ad9361_phy, "in_voltage1_hardwaregain", rf_gain_rx2_); + if (ret < 0) + { + std::cout << "Failed to set in_voltage1_hardwaregain: " << ret << std::endl; + } + + std::cout << "End of AD9361 RX configuration.\n"; + iio_context_destroy(ctx); + return true; +} + + +bool config_ad9361_rx_remote(std::string remote_host, + unsigned long bandwidth_, + unsigned long sample_rate_, + unsigned long freq_, + std::string rf_port_select_, + std::string gain_mode_rx1_, + std::string gain_mode_rx2_, + double rf_gain_rx1_, + double rf_gain_rx2_) +{ + // RX stream config + // Stream configurations + struct stream_cfg rxcfg; + rxcfg.bw_hz = bandwidth_; // 2 MHz rf bandwidth + rxcfg.fs_hz = sample_rate_; // 2.5 MS/s rx sample rate + rxcfg.lo_hz = freq_; // 2.5 GHz rf frequency + rxcfg.rfport = rf_port_select_.c_str(); // port A (select for rf freq.) + + std::cout << "AD9361 Acquiring IIO REMOTE context in host " << remote_host << std::endl; + struct iio_context *ctx; + // Streaming devices + struct iio_device *rx; + struct iio_channel *rx0_i; + struct iio_channel *rx0_q; + + ctx = iio_create_network_context(remote_host.c_str()); + if (!ctx) + { + std::cout << "No context\n"; + throw std::runtime_error("AD9361 IIO No context"); + } + + if (iio_context_get_devices_count(ctx) <= 0) + { + std::cout << "No devices\n"; + throw std::runtime_error("AD9361 IIO No devices"); + } + + std::cout << "* Acquiring AD9361 streaming devices\n"; + + if (!get_ad9361_stream_dev(ctx, RX, &rx)) + { + std::cout << "No rx dev found\n"; + throw std::runtime_error("AD9361 IIO No rx dev found"); + }; + + std::cout << "* Configuring AD9361 for streaming\n"; + if (!cfg_ad9361_streaming_ch(ctx, &rxcfg, RX, 0)) + { + std::cout << "RX port 0 not found\n"; + throw std::runtime_error("AD9361 IIO RX port 0 not found"); + } + + std::cout << "* Initializing AD9361 IIO streaming channels\n"; + if (!get_ad9361_stream_ch(ctx, RX, rx, 0, &rx0_i)) + { + std::cout << "RX chan i not found\n"; + throw std::runtime_error("RX chan i not found"); + } + + if (!get_ad9361_stream_ch(ctx, RX, rx, 1, &rx0_q)) + { + std::cout << "RX chan q not found\n"; + throw std::runtime_error("RX chan q not found"); + } + + std::cout << "* Enabling IIO streaming channels\n"; + iio_channel_enable(rx0_i); + iio_channel_enable(rx0_q); + + struct iio_device *ad9361_phy; + ad9361_phy = iio_context_find_device(ctx, "ad9361-phy"); + int ret; + ret = iio_device_attr_write(ad9361_phy, "trx_rate_governor", "nominal"); + if (ret < 0) + { + std::cout << "Failed to set trx_rate_governor: " << ret << std::endl; + } + ret = iio_device_attr_write(ad9361_phy, "ensm_mode", "fdd"); + if (ret < 0) + { + std::cout << "Failed to set ensm_mode: " << ret << std::endl; + } + ret = iio_device_attr_write(ad9361_phy, "calib_mode", "auto"); + if (ret < 0) + { + std::cout << "Failed to set calib_mode: " << ret << std::endl; + } + ret = iio_device_attr_write(ad9361_phy, "in_voltage0_gain_control_mode", gain_mode_rx1_.c_str()); + if (ret < 0) + { + std::cout << "Failed to set in_voltage0_gain_control_mode: " << ret << std::endl; + } + ret = iio_device_attr_write(ad9361_phy, "in_voltage1_gain_control_mode", gain_mode_rx2_.c_str()); + if (ret < 0) + { + std::cout << "Failed to set in_voltage1_gain_control_mode: " << ret << std::endl; + } + ret = iio_device_attr_write_double(ad9361_phy, "in_voltage0_hardwaregain", rf_gain_rx1_); + if (ret < 0) + { + std::cout << "Failed to set in_voltage0_hardwaregain: " << ret << std::endl; + } + ret = iio_device_attr_write_double(ad9361_phy, "in_voltage1_hardwaregain", rf_gain_rx2_); + if (ret < 0) + { + std::cout << "Failed to set in_voltage1_hardwaregain: " << ret << std::endl; + } + + std::cout << "End of AD9361 RX configuration.\n"; + + iio_context_destroy(ctx); + return true; +} + + +bool config_ad9361_lo_local(unsigned long bandwidth_, + unsigned long sample_rate_, + unsigned long freq_rf_tx_hz_, + double tx_attenuation_db_, + long long freq_dds_tx_hz_, + double scale_dds_dbfs_) +{ + // TX stream config + std::cout << "Start of AD9361 TX Local Oscillator DDS configuration\n"; + struct stream_cfg txcfg; + txcfg.bw_hz = bandwidth_; + txcfg.fs_hz = sample_rate_; + txcfg.lo_hz = freq_rf_tx_hz_; + txcfg.rfport = "A"; + + std::cout << "AD9361 Acquiring IIO LOCAL context\n"; + struct iio_context *ctx; + ctx = iio_create_default_context(); + if (!ctx) + { + std::cout << "No context\n"; + throw std::runtime_error("AD9361 IIO No context"); + } + + //find tx device + struct iio_device *tx; + + std::cout << "* Acquiring AD9361 TX streaming devices\n"; + + if (!get_ad9361_stream_dev(ctx, TX, &tx)) + { + std::cout << "No tx dev found\n"; + throw std::runtime_error("AD9361 IIO No tx dev found"); + }; + + std::cout << "* Configuring AD9361 for streaming TX\n"; + if (!cfg_ad9361_streaming_ch(ctx, &txcfg, TX, 0)) + { + std::cout << "TX port 0 not found\n"; + throw std::runtime_error("AD9361 IIO TX port 0 not found"); + } + + //ENABLE DDS on TX1 + struct iio_device *ad9361_phy; + ad9361_phy = iio_context_find_device(ctx, "ad9361-phy"); + int ret; + //set output amplifier attenuation + ret = iio_device_attr_write_double(ad9361_phy, "out_voltage0_hardwaregain", -tx_attenuation_db_); + if (ret < 0) + { + std::cout << "Failed to set out_voltage0_hardwaregain value " << -tx_attenuation_db_ << " error " << ret << std::endl; + } + + struct iio_device *dds; + dds = iio_context_find_device(ctx, "cf-ad9361-dds-core-lpc"); + struct iio_channel *dds_channel0_I; + dds_channel0_I = iio_device_find_channel(dds, "TX1_I_F1", true); + + struct iio_channel *dds_channel0_Q; + dds_channel0_Q = iio_device_find_channel(dds, "TX1_Q_F1", true); + + ret = iio_channel_attr_write_bool(dds_channel0_I, "raw", true); + if (ret < 0) + { + std::cout << "Failed to toggle DDS: " << ret << std::endl; + } + + //set frequency, scale and phase + + ret = iio_channel_attr_write_longlong(dds_channel0_I, "frequency", (long long)freq_dds_tx_hz_); + if (ret < 0) + { + std::cout << "Failed to set TX DDS frequency I: " << ret << std::endl; + } + + ret = iio_channel_attr_write_longlong(dds_channel0_Q, "frequency", (long long)freq_dds_tx_hz_); + if (ret < 0) + { + std::cout << "Failed to set TX DDS frequency Q: " << ret << std::endl; + } + + ret = iio_channel_attr_write_double(dds_channel0_I, "phase", 0.0); + if (ret < 0) + { + std::cout << "Failed to set TX DDS phase I: " << ret << std::endl; + } + + ret = iio_channel_attr_write_double(dds_channel0_Q, "phase", 270000.0); + if (ret < 0) + { + std::cout << "Failed to set TX DDS phase Q: " << ret << std::endl; + } + + ret = iio_channel_attr_write_double(dds_channel0_I, "scale", pow(10, scale_dds_dbfs_ / 20.0)); + if (ret < 0) + { + std::cout << "Failed to set TX DDS scale I: " << ret << std::endl; + } + + ret = iio_channel_attr_write_double(dds_channel0_Q, "scale", pow(10, scale_dds_dbfs_ / 20.0)); + if (ret < 0) + { + std::cout << "Failed to set TX DDS scale Q: " << ret << std::endl; + } + + //disable TX2 + + ret = iio_device_attr_write_double(ad9361_phy, "out_voltage1_hardwaregain", -89.0); + if (ret < 0) + { + std::cout << "Failed to set out_voltage1_hardwaregain value " << -89.0 << " error " << ret << std::endl; + } + + struct iio_channel *dds_channel1_I; + dds_channel1_I = iio_device_find_channel(dds, "TX2_I_F1", true); + + struct iio_channel *dds_channel1_Q; + dds_channel1_Q = iio_device_find_channel(dds, "TX2_Q_F1", true); + + ret = iio_channel_attr_write_double(dds_channel1_I, "scale", 0); + if (ret < 0) + { + std::cout << "Failed to set TX2 DDS scale I: " << ret << std::endl; + } + + ret = iio_channel_attr_write_double(dds_channel1_Q, "scale", 0); + if (ret < 0) + { + std::cout << "Failed to set TX2 DDS scale Q: " << ret << std::endl; + } + + iio_context_destroy(ctx); + return true; +} + + +bool config_ad9361_lo_remote(std::string remote_host, + unsigned long bandwidth_, + unsigned long sample_rate_, + unsigned long freq_rf_tx_hz_, + double tx_attenuation_db_, + long long freq_dds_tx_hz_, + double scale_dds_dbfs_) +{ + // TX stream config + std::cout << "Start of AD9361 TX Local Oscillator DDS configuration\n"; + struct stream_cfg txcfg; + txcfg.bw_hz = bandwidth_; + txcfg.fs_hz = sample_rate_; + txcfg.lo_hz = freq_rf_tx_hz_; + txcfg.rfport = "A"; + + std::cout << "AD9361 Acquiring IIO REMOTE context in host " << remote_host << std::endl; + struct iio_context *ctx; + ctx = iio_create_network_context(remote_host.c_str()); + if (!ctx) + { + std::cout << "No context\n"; + throw std::runtime_error("AD9361 IIO No context"); + } + + //find tx device + struct iio_device *tx; + + std::cout << "* Acquiring AD9361 TX streaming devices\n"; + + if (!get_ad9361_stream_dev(ctx, TX, &tx)) + { + std::cout << "No tx dev found\n"; + throw std::runtime_error("AD9361 IIO No tx dev found"); + }; + + std::cout << "* Configuring AD9361 for streaming TX\n"; + if (!cfg_ad9361_streaming_ch(ctx, &txcfg, TX, 0)) + { + std::cout << "TX port 0 not found\n"; + throw std::runtime_error("AD9361 IIO TX port 0 not found"); + } + + //ENABLE DDS on TX1 + struct iio_device *ad9361_phy; + ad9361_phy = iio_context_find_device(ctx, "ad9361-phy"); + int ret; + //set output amplifier attenuation + ret = iio_device_attr_write_double(ad9361_phy, "out_voltage0_hardwaregain", -tx_attenuation_db_); + if (ret < 0) + { + std::cout << "Failed to set out_voltage0_hardwaregain value " << -tx_attenuation_db_ << " error " << ret << std::endl; + } + + struct iio_device *dds; + dds = iio_context_find_device(ctx, "cf-ad9361-dds-core-lpc"); + struct iio_channel *dds_channel0_I; + dds_channel0_I = iio_device_find_channel(dds, "TX1_I_F1", true); + + struct iio_channel *dds_channel0_Q; + dds_channel0_Q = iio_device_find_channel(dds, "TX1_Q_F1", true); + + ret = iio_channel_attr_write_bool(dds_channel0_I, "raw", true); + if (ret < 0) + { + std::cout << "Failed to toggle DDS: " << ret << std::endl; + } + + //set frequency, scale and phase + + ret = iio_channel_attr_write_longlong(dds_channel0_I, "frequency", (long long)freq_dds_tx_hz_); + if (ret < 0) + { + std::cout << "Failed to set TX DDS frequency I: " << ret << std::endl; + } + + ret = iio_channel_attr_write_longlong(dds_channel0_Q, "frequency", (long long)freq_dds_tx_hz_); + if (ret < 0) + { + std::cout << "Failed to set TX DDS frequency Q: " << ret << std::endl; + } + + ret = iio_channel_attr_write_double(dds_channel0_I, "phase", 0.0); + if (ret < 0) + { + std::cout << "Failed to set TX DDS phase I: " << ret << std::endl; + } + + ret = iio_channel_attr_write_double(dds_channel0_Q, "phase", 270000.0); + if (ret < 0) + { + std::cout << "Failed to set TX DDS phase Q: " << ret << std::endl; + } + + ret = iio_channel_attr_write_double(dds_channel0_I, "scale", pow(10, scale_dds_dbfs_ / 20.0)); + if (ret < 0) + { + std::cout << "Failed to set TX DDS scale I: " << ret << std::endl; + } + + ret = iio_channel_attr_write_double(dds_channel0_Q, "scale", pow(10, scale_dds_dbfs_ / 20.0)); + if (ret < 0) + { + std::cout << "Failed to set TX DDS scale Q: " << ret << std::endl; + } + + //disable TX2 + + ret = iio_device_attr_write_double(ad9361_phy, "out_voltage1_hardwaregain", -89.0); + if (ret < 0) + { + std::cout << "Failed to set out_voltage1_hardwaregain value " << -89.0 << " error " << ret << std::endl; + } + + struct iio_channel *dds_channel1_I; + dds_channel1_I = iio_device_find_channel(dds, "TX2_I_F1", true); + + struct iio_channel *dds_channel1_Q; + dds_channel1_Q = iio_device_find_channel(dds, "TX2_Q_F1", true); + + ret = iio_channel_attr_write_double(dds_channel1_I, "scale", 0); + if (ret < 0) + { + std::cout << "Failed to set TX2 DDS scale I: " << ret << std::endl; + } + + ret = iio_channel_attr_write_double(dds_channel1_Q, "scale", 0); + if (ret < 0) + { + std::cout << "Failed to set TX2 DDS scale Q: " << ret << std::endl; + } + + iio_context_destroy(ctx); + return true; +} + + +bool ad9361_disable_lo_remote(std::string remote_host) +{ + std::cout << "AD9361 Acquiring IIO REMOTE context in host " << remote_host << std::endl; + struct iio_context *ctx; + ctx = iio_create_network_context(remote_host.c_str()); + if (!ctx) + { + std::cout << "No context\n"; + throw std::runtime_error("AD9361 IIO No context"); + } + struct iio_device *dds; + dds = iio_context_find_device(ctx, "cf-ad9361-dds-core-lpc"); + struct iio_channel *dds_channel0_I; + dds_channel0_I = iio_device_find_channel(dds, "TX1_I_F1", true); + + struct iio_channel *dds_channel0_Q; + dds_channel0_Q = iio_device_find_channel(dds, "TX1_Q_F1", true); + int ret; + ret = iio_channel_attr_write_bool(dds_channel0_I, "raw", false); + if (ret < 0) + { + std::cout << "Failed to toggle DDS: " << ret << std::endl; + } + + ret = iio_channel_attr_write_double(dds_channel0_I, "scale", 0.0); + if (ret < 0) + { + std::cout << "Failed to set TX DDS scale I: " << ret << std::endl; + } + + ret = iio_channel_attr_write_double(dds_channel0_Q, "scale", 0.0); + if (ret < 0) + { + std::cout << "Failed to set TX DDS scale Q: " << ret << std::endl; + } + + iio_context_destroy(ctx); + + return true; +} + + +bool ad9361_disable_lo_local() +{ + std::cout << "AD9361 Acquiring IIO LOCAL context" << std::endl; + struct iio_context *ctx; + ctx = iio_create_default_context(); + if (!ctx) + { + std::cout << "No context\n"; + throw std::runtime_error("AD9361 IIO No context"); + } + struct iio_device *dds; + dds = iio_context_find_device(ctx, "cf-ad9361-dds-core-lpc"); + struct iio_channel *dds_channel0_I; + dds_channel0_I = iio_device_find_channel(dds, "TX1_I_F1", true); + + struct iio_channel *dds_channel0_Q; + dds_channel0_Q = iio_device_find_channel(dds, "TX1_Q_F1", true); + int ret; + ret = iio_channel_attr_write_bool(dds_channel0_I, "raw", false); + if (ret < 0) + { + std::cout << "Failed to toggle DDS: " << ret << std::endl; + } + + ret = iio_channel_attr_write_double(dds_channel0_I, "scale", 0.0); + if (ret < 0) + { + std::cout << "Failed to set TX DDS scale I: " << ret << std::endl; + } + + ret = iio_channel_attr_write_double(dds_channel0_Q, "scale", 0.0); + if (ret < 0) + { + std::cout << "Failed to set TX DDS scale Q: " << ret << std::endl; + } + + iio_context_destroy(ctx); + + return true; +} diff --git a/src/algorithms/signal_source/libs/ad9361_manager.h b/src/algorithms/signal_source/libs/ad9361_manager.h new file mode 100644 index 000000000..cd48e664f --- /dev/null +++ b/src/algorithms/signal_source/libs/ad9361_manager.h @@ -0,0 +1,130 @@ +/*! + * \file ad9361_manager.h + * \brief An Analog Devices AD9361 front-end configuration library wrapper for configure some functions via iiod link. + * \author Javier Arribas, jarribas(at)cttc.es + * + * This file contains information taken from librtlsdr: + * http://git.osmocom.org/rtl-sdr/ + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_AD9361_MANAGER_H +#define GNSS_SDR_AD9361_MANAGER_H + +#include + +#ifdef __APPLE__ +#include +#else +#include +#endif + +/* RX is input, TX is output */ +enum iodev +{ + RX, + TX +}; + +/* common RX and TX streaming params */ +struct stream_cfg +{ + long long bw_hz; // Analog banwidth in Hz + long long fs_hz; // Baseband sample rate in Hz + long long lo_hz; // Local oscillator frequency in Hz + const char *rfport; // Port name +}; + + +/* check return value of attr_write function */ +void errchk(int v, const char *what); + +/* write attribute: long long int */ +void wr_ch_lli(struct iio_channel *chn, const char *what, long long val); + +/* write attribute: string */ +void wr_ch_str(struct iio_channel *chn, const char *what, const char *str); + +/* helper function generating channel names */ +char *get_ch_name(const char *type, int id, char *tmpstr); + +/* returns ad9361 phy device */ +struct iio_device *get_ad9361_phy(struct iio_context *ctx); + +/* finds AD9361 streaming IIO devices */ +bool get_ad9361_stream_dev(struct iio_context *ctx, enum iodev d, struct iio_device **dev); + +/* finds AD9361 streaming IIO channels */ +bool get_ad9361_stream_ch(struct iio_context *ctx, enum iodev d, struct iio_device *dev, int chid, struct iio_channel **chn); + +/* finds AD9361 phy IIO configuration channel with id chid */ +bool get_phy_chan(struct iio_context *ctx, enum iodev d, int chid, struct iio_channel **chn); + +/* finds AD9361 local oscillator IIO configuration channels */ +bool get_lo_chan(struct iio_context *ctx, enum iodev d, struct iio_channel **chn); + +/* applies streaming configuration through IIO */ +bool cfg_ad9361_streaming_ch(struct iio_context *ctx, struct stream_cfg *cfg, enum iodev type, int chid); + +bool config_ad9361_rx_local(unsigned long bandwidth_, + unsigned long sample_rate_, + unsigned long freq_, + std::string rf_port_select_, + std::string gain_mode_rx1_, + std::string gain_mode_rx2_, + double rf_gain_rx1_, + double rf_gain_rx2_); + +bool config_ad9361_rx_remote(std::string remote_host, + unsigned long bandwidth_, + unsigned long sample_rate_, + unsigned long freq_, + std::string rf_port_select_, + std::string gain_mode_rx1_, + std::string gain_mode_rx2_, + double rf_gain_rx1_, + double rf_gain_rx2_); + +bool config_ad9361_lo_local(unsigned long bandwidth_, + unsigned long sample_rate_, + unsigned long freq_rf_tx_hz_, + double tx_attenuation_db_, + long long freq_dds_tx_hz_, + double scale_dds_dbfs_); + +bool config_ad9361_lo_remote(std::string remote_host, + unsigned long bandwidth_, + unsigned long sample_rate_, + unsigned long freq_rf_tx_hz_, + double tx_attenuation_db_, + long long freq_dds_tx_hz_, + double scale_dds_dbfs_); + + +bool ad9361_disable_lo_remote(std::string remote_host); + +bool ad9361_disable_lo_local(); + +#endif diff --git a/src/algorithms/telemetry_decoder/adapters/CMakeLists.txt b/src/algorithms/telemetry_decoder/adapters/CMakeLists.txt index cf09a7cde..f371e28c2 100644 --- a/src/algorithms/telemetry_decoder/adapters/CMakeLists.txt +++ b/src/algorithms/telemetry_decoder/adapters/CMakeLists.txt @@ -24,7 +24,8 @@ set(TELEMETRY_DECODER_ADAPTER_SOURCES galileo_e1b_telemetry_decoder.cc sbas_l1_telemetry_decoder.cc galileo_e5a_telemetry_decoder.cc - glonass_l1_ca_telemetry_decoder.cc + glonass_l1_ca_telemetry_decoder.cc + glonass_l2_ca_telemetry_decoder.cc ) include_directories( diff --git a/src/algorithms/telemetry_decoder/adapters/glonass_l2_ca_telemetry_decoder.cc b/src/algorithms/telemetry_decoder/adapters/glonass_l2_ca_telemetry_decoder.cc new file mode 100644 index 000000000..9070c8b85 --- /dev/null +++ b/src/algorithms/telemetry_decoder/adapters/glonass_l2_ca_telemetry_decoder.cc @@ -0,0 +1,103 @@ +/*! + * \file glonass_l2_ca_telemetry_decoder.cc + * \brief Implementation of an adapter of a GLONASS L2 C/A NAV data decoder block + * to a TelemetryDecoderInterface + * \author Damian Miralles, 2018. dmiralles2009(at)gmail.com + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#include "glonass_l2_ca_telemetry_decoder.h" +#include "configuration_interface.h" +#include "glonass_gnav_ephemeris.h" +#include "glonass_gnav_almanac.h" +#include "glonass_gnav_utc_model.h" +#include +#include + + +using google::LogMessage; + +GlonassL2CaTelemetryDecoder::GlonassL2CaTelemetryDecoder(ConfigurationInterface* configuration, + std::string role, + unsigned int in_streams, + unsigned int out_streams) : role_(role), + in_streams_(in_streams), + out_streams_(out_streams) +{ + std::string default_dump_filename = "./navigation.dat"; + DLOG(INFO) << "role " << role; + dump_ = configuration->property(role + ".dump", false); + dump_filename_ = configuration->property(role + ".dump_filename", default_dump_filename); + // make telemetry decoder object + telemetry_decoder_ = glonass_l2_ca_make_telemetry_decoder_cc(satellite_, dump_); + DLOG(INFO) << "telemetry_decoder(" << telemetry_decoder_->unique_id() << ")"; + channel_ = 0; +} + + +GlonassL2CaTelemetryDecoder::~GlonassL2CaTelemetryDecoder() +{ +} + + +void GlonassL2CaTelemetryDecoder::set_satellite(const Gnss_Satellite& satellite) +{ + satellite_ = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); + telemetry_decoder_->set_satellite(satellite_); + DLOG(INFO) << "TELEMETRY DECODER: satellite set to " << satellite_; +} + + +void GlonassL2CaTelemetryDecoder::connect(gr::top_block_sptr top_block) +{ + if (top_block) + { /* top_block is not null */ + }; + // Nothing to connect internally + DLOG(INFO) << "nothing to connect internally"; +} + + +void GlonassL2CaTelemetryDecoder::disconnect(gr::top_block_sptr top_block) +{ + if (top_block) + { /* top_block is not null */ + }; + // Nothing to disconnect +} + + +gr::basic_block_sptr GlonassL2CaTelemetryDecoder::get_left_block() +{ + return telemetry_decoder_; +} + + +gr::basic_block_sptr GlonassL2CaTelemetryDecoder::get_right_block() +{ + return telemetry_decoder_; +} diff --git a/src/algorithms/telemetry_decoder/adapters/glonass_l2_ca_telemetry_decoder.h b/src/algorithms/telemetry_decoder/adapters/glonass_l2_ca_telemetry_decoder.h new file mode 100644 index 000000000..890753f20 --- /dev/null +++ b/src/algorithms/telemetry_decoder/adapters/glonass_l2_ca_telemetry_decoder.h @@ -0,0 +1,90 @@ +/*! + * \file glonass_l2_ca_telemetry_decoder.h + * \brief Interface of an adapter of a GLONASS L2 C/A NAV data decoder block + * to a TelemetryDecoderInterface + * \author Damian Miralles, 2018. dmiralles2009(at)gmail.com + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#ifndef GNSS_SDR_GLONASS_L2_CA_TELEMETRY_DECODER_H_ +#define GNSS_SDR_GLONASS_L2_CA_TELEMETRY_DECODER_H_ + +#include "telemetry_decoder_interface.h" +#include "glonass_l2_ca_telemetry_decoder_cc.h" +#include + +class ConfigurationInterface; + +/*! + * \brief This class implements a NAV data decoder for GLONASS L2 C/A + */ +class GlonassL2CaTelemetryDecoder : public TelemetryDecoderInterface +{ +public: + GlonassL2CaTelemetryDecoder(ConfigurationInterface* configuration, + std::string role, + unsigned int in_streams, + unsigned int out_streams); + + virtual ~GlonassL2CaTelemetryDecoder(); + std::string role() override + { + return role_; + } + + //! Returns "GLONASS_L2_CA_Telemetry_Decoder" + std::string implementation() override + { + return "GLONASS_L2_CA_Telemetry_Decoder"; + } + void connect(gr::top_block_sptr top_block) override; + void disconnect(gr::top_block_sptr top_block) override; + gr::basic_block_sptr get_left_block() override; + gr::basic_block_sptr get_right_block() override; + void set_satellite(const Gnss_Satellite& satellite) override; + void set_channel(int channel) override { telemetry_decoder_->set_channel(channel); } + void reset() override + { + return; + } + size_t item_size() override + { + return 0; + } + +private: + glonass_l2_ca_telemetry_decoder_cc_sptr telemetry_decoder_; + Gnss_Satellite satellite_; + int channel_; + bool dump_; + std::string dump_filename_; + std::string role_; + unsigned int in_streams_; + unsigned int out_streams_; +}; + +#endif diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt b/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt index 29e83b79c..335ae52df 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/CMakeLists.txt @@ -24,6 +24,7 @@ set(TELEMETRY_DECODER_GR_BLOCKS_SOURCES sbas_l1_telemetry_decoder_cc.cc galileo_e5a_telemetry_decoder_cc.cc glonass_l1_ca_telemetry_decoder_cc.cc + glonass_l2_ca_telemetry_decoder_cc.cc ) include_directories( diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.cc index 294436c2d..764c35aac 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e1b_telemetry_decoder_cc.cc @@ -320,7 +320,7 @@ int galileo_e1b_telemetry_decoder_cc::general_work(int noutput_items __attribute d_stat = 1; // enter into frame pre-detection status } } - else if (d_stat == 1) // posible preamble lock + else if (d_stat == 1) // possible preamble lock { if (abs(corr_value) >= d_symbols_per_preamble) { diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc index 43c944a0a..640cbf009 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/galileo_e5a_telemetry_decoder_cc.cc @@ -338,7 +338,7 @@ int galileo_e5a_telemetry_decoder_cc::general_work(int noutput_items __attribute d_stat = 1; // enter into frame pre-detection status } } - else if ((d_stat == 1) && new_symbol) // posible preamble lock + else if ((d_stat == 1) && new_symbol) // possible preamble lock { if (abs(corr_value) >= GALILEO_FNAV_PREAMBLE_LENGTH_BITS) { diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc index dad1a5d2c..0bd2fae54 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.cc @@ -271,7 +271,7 @@ int glonass_l1_ca_telemetry_decoder_cc::general_work(int noutput_items __attribu d_preamble_time_samples = d_symbol_history.at(0).Tracking_sample_counter; // record the preamble sample stamp } } - else if (d_stat == 1) // posible preamble lock + else if (d_stat == 1) // possible preamble lock { if (abs(corr_value) >= d_symbols_per_preamble) { diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.h index 2fe728dcc..6cfafd197 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l1_ca_telemetry_decoder_cc.h @@ -34,13 +34,13 @@ #define GNSS_SDR_GLONASS_L1_CA_TELEMETRY_DECODER_CC_H -#include "GLONASS_L1_CA.h" #include "glonass_gnav_navigation_message.h" #include "glonass_gnav_ephemeris.h" #include "glonass_gnav_almanac.h" #include "glonass_gnav_utc_model.h" #include "gnss_satellite.h" #include "gnss_synchro.h" +#include "GLONASS_L1_L2_CA.h" #include #include #include diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc new file mode 100644 index 000000000..2b168a89c --- /dev/null +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.cc @@ -0,0 +1,449 @@ +/*! + * \file glonass_l2_ca_telemetry_decoder_cc.cc + * \brief Implementation of an adapter of a GLONASS L1 C/A NAV data decoder block + * to a TelemetryDecoderInterface + * \author Damian Miralles, 2018. dmiralles2009(at)gmail.com + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#include "glonass_l2_ca_telemetry_decoder_cc.h" +#include +#include +#include + + +#define CRC_ERROR_LIMIT 6 + +using google::LogMessage; + + +glonass_l2_ca_telemetry_decoder_cc_sptr +glonass_l2_ca_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump) +{ + return glonass_l2_ca_telemetry_decoder_cc_sptr(new glonass_l2_ca_telemetry_decoder_cc(satellite, dump)); +} + + +glonass_l2_ca_telemetry_decoder_cc::glonass_l2_ca_telemetry_decoder_cc( + const Gnss_Satellite &satellite, + bool dump) : gr::block("glonass_l2_ca_telemetry_decoder_cc", gr::io_signature::make(1, 1, sizeof(Gnss_Synchro)), + gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) +{ + // Telemetry Bit transition synchronization port out + this->message_port_register_out(pmt::mp("preamble_timestamp_s")); + // Ephemeris data port out + this->message_port_register_out(pmt::mp("telemetry")); + // initialize internal vars + d_dump = dump; + d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); + LOG(INFO) << "Initializing GLONASS L2 CA TELEMETRY DECODING"; + // Define the number of sampes per symbol. Notice that GLONASS has 2 rates, + //one for the navigation data and the other for the preamble information + d_samples_per_symbol = (GLONASS_L2_CA_CODE_RATE_HZ / GLONASS_L2_CA_CODE_LENGTH_CHIPS) / GLONASS_L2_CA_SYMBOL_RATE_BPS; + + // Set the preamble information + unsigned short int preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS] = GLONASS_GNAV_PREAMBLE; + // Since preamble rate is different than navigation data rate we use a constant + d_symbols_per_preamble = GLONASS_GNAV_PREAMBLE_LENGTH_SYMBOLS; + + memcpy(static_cast(this->d_preambles_bits), static_cast(preambles_bits), GLONASS_GNAV_PREAMBLE_LENGTH_BITS * sizeof(unsigned short int)); + + // preamble bits to sampled symbols + d_preambles_symbols = static_cast(malloc(sizeof(signed int) * d_symbols_per_preamble)); + int n = 0; + for (int i = 0; i < GLONASS_GNAV_PREAMBLE_LENGTH_BITS; i++) + { + for (unsigned int j = 0; j < GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_PREAMBLE_BIT; j++) + { + if (d_preambles_bits[i] == 1) + { + d_preambles_symbols[n] = 1; + } + else + { + d_preambles_symbols[n] = -1; + } + n++; + } + } + d_sample_counter = 0; + d_stat = 0; + d_preamble_index = 0; + + d_flag_frame_sync = false; + + d_flag_parity = false; + d_TOW_at_current_symbol = 0; + Flag_valid_word = false; + delta_t = 0; + d_CRC_error_counter = 0; + d_flag_preamble = false; + d_channel = 0; + flag_TOW_set = false; + d_preamble_time_samples = 0; +} + + +glonass_l2_ca_telemetry_decoder_cc::~glonass_l2_ca_telemetry_decoder_cc() +{ + delete d_preambles_symbols; + if (d_dump_file.is_open() == true) + { + try + { + d_dump_file.close(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Exception in destructor closing the dump file " << ex.what(); + } + } +} + + +void glonass_l2_ca_telemetry_decoder_cc::decode_string(double *frame_symbols, int frame_length) +{ + double chip_acc = 0.0; + int chip_acc_counter = 0; + + // 1. Transform from symbols to bits + std::string bi_binary_code; + std::string relative_code; + std::string data_bits; + + // Group samples into bi-binary code + for (int i = 0; i < (frame_length); i++) + { + chip_acc += frame_symbols[i]; + chip_acc_counter += 1; + + if (chip_acc_counter == (GLONASS_GNAV_TELEMETRY_SYMBOLS_PER_BIT)) + { + if (chip_acc > 0) + { + bi_binary_code.push_back('1'); + chip_acc_counter = 0; + chip_acc = 0; + } + else + { + bi_binary_code.push_back('0'); + chip_acc_counter = 0; + chip_acc = 0; + } + } + } + // Convert from bi-binary code to relative code + for (int i = 0; i < (GLONASS_GNAV_STRING_BITS); i++) + { + if (bi_binary_code[2 * i] == '1' && bi_binary_code[2 * i + 1] == '0') + { + relative_code.push_back('1'); + } + else + { + relative_code.push_back('0'); + } + } + // Convert from relative code to data bits + data_bits.push_back('0'); + for (int i = 1; i < (GLONASS_GNAV_STRING_BITS); i++) + { + data_bits.push_back(((relative_code[i - 1] - '0') ^ (relative_code[i] - '0')) + '0'); + } + + // 2. Call the GLONASS GNAV string decoder + d_nav.string_decoder(data_bits); + + // 3. Check operation executed correctly + if (d_nav.flag_CRC_test == true) + { + LOG(INFO) << "GLONASS GNAV CRC correct on channel " << d_channel << " from satellite " << d_satellite; + } + else + { + LOG(INFO) << "GLONASS GNAV CRC error on channel " << d_channel << " from satellite " << d_satellite; + } + // 4. Push the new navigation data to the queues + if (d_nav.have_new_ephemeris() == true) + { + // get object for this SV (mandatory) + d_nav.gnav_ephemeris.i_satellite_freq_channel = d_satellite.get_rf_link(); + std::shared_ptr tmp_obj = std::make_shared(d_nav.get_ephemeris()); + this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + LOG(INFO) << "GLONASS GNAV Ephemeris have been received on channel" << d_channel << " from satellite " << d_satellite; + } + if (d_nav.have_new_utc_model() == true) + { + // get object for this SV (mandatory) + std::shared_ptr tmp_obj = std::make_shared(d_nav.get_utc_model()); + this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + LOG(INFO) << "GLONASS GNAV UTC Model have been received on channel" << d_channel << " from satellite " << d_satellite; + } + if (d_nav.have_new_almanac() == true) + { + unsigned int slot_nbr = d_nav.i_alm_satellite_slot_number; + std::shared_ptr tmp_obj = std::make_shared(d_nav.get_almanac(slot_nbr)); + this->message_port_pub(pmt::mp("telemetry"), pmt::make_any(tmp_obj)); + LOG(INFO) << "GLONASS GNAV Almanac have been received on channel" << d_channel << " in slot number " << slot_nbr; + } + // 5. Update satellite information on system + if (d_nav.flag_update_slot_number == true) + { + LOG(INFO) << "GLONASS GNAV Slot Number Identified on channel " << d_channel; + d_satellite.update_PRN(d_nav.gnav_ephemeris.d_n); + d_satellite.what_block(d_satellite.get_system(), d_nav.gnav_ephemeris.d_n); + d_nav.flag_update_slot_number = false; + } +} + + +int glonass_l2_ca_telemetry_decoder_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), + gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) +{ + int corr_value = 0; + int preamble_diff = 0; + + Gnss_Synchro **out = reinterpret_cast(&output_items[0]); // Get the output buffer pointer + const Gnss_Synchro **in = reinterpret_cast(&input_items[0]); // Get the input buffer pointer + + Gnss_Synchro current_symbol; //structure to save the synchronization information and send the output object to the next block + //1. Copy the current tracking output + current_symbol = in[0][0]; + d_symbol_history.push_back(current_symbol); //add new symbol to the symbol queue + d_sample_counter++; //count for the processed samples + consume_each(1); + + d_flag_preamble = false; + unsigned int required_symbols = GLONASS_GNAV_STRING_SYMBOLS; + + if (d_symbol_history.size() > required_symbols) + { + //******* preamble correlation ******** + for (int i = 0; i < d_symbols_per_preamble; i++) + { + if (d_symbol_history.at(i).Prompt_I < 0) // symbols clipping + { + corr_value -= d_preambles_symbols[i]; + } + else + { + corr_value += d_preambles_symbols[i]; + } + } + } + + //******* frame sync ****************** + if (d_stat == 0) //no preamble information + { + if (abs(corr_value) >= d_symbols_per_preamble) + { + // Record the preamble sample stamp + d_preamble_index = d_sample_counter; + LOG(INFO) << "Preamble detection for GLONASS L2 C/A SAT " << this->d_satellite; + // Enter into frame pre-detection status + d_stat = 1; + d_preamble_time_samples = d_symbol_history.at(0).Tracking_sample_counter; // record the preamble sample stamp + } + } + else if (d_stat == 1) // possible preamble lock + { + if (abs(corr_value) >= d_symbols_per_preamble) + { + //check preamble separation + preamble_diff = d_sample_counter - d_preamble_index; + // Record the PRN start sample index associated to the preamble + d_preamble_time_samples = d_symbol_history.at(0).Tracking_sample_counter; + if (abs(preamble_diff - GLONASS_GNAV_PREAMBLE_PERIOD_SYMBOLS) == 0) + { + //try to decode frame + LOG(INFO) << "Starting string decoder for GLONASS L2 C/A SAT " << this->d_satellite; + d_preamble_index = d_sample_counter; //record the preamble sample stamp + d_stat = 2; + // send asynchronous message to tracking to inform of frame sync and extend correlation time + pmt::pmt_t value = pmt::from_double(static_cast(d_preamble_time_samples) / static_cast(d_symbol_history.at(0).fs) - 0.001); + this->message_port_pub(pmt::mp("preamble_timestamp_s"), value); + } + else + { + if (preamble_diff > GLONASS_GNAV_PREAMBLE_PERIOD_SYMBOLS) + { + d_stat = 0; // start again + } + DLOG(INFO) << "Failed string decoder for GLONASS L2 C/A SAT " << this->d_satellite; + } + } + } + else if (d_stat == 2) + { + // FIXME: The preamble index marks the first symbol of the string count. Here I just wait for another full string to be received before processing + if (d_sample_counter == d_preamble_index + GLONASS_GNAV_STRING_SYMBOLS) + { + // NEW GLONASS string received + // 0. fetch the symbols into an array + int string_length = GLONASS_GNAV_STRING_SYMBOLS - d_symbols_per_preamble; + double string_symbols[GLONASS_GNAV_DATA_SYMBOLS] = {0}; + + //******* SYMBOL TO BIT ******* + for (int i = 0; i < string_length; i++) + { + if (corr_value > 0) + { + string_symbols[i] = d_symbol_history.at(i + d_symbols_per_preamble).Prompt_I; // because last symbol of the preamble is just received now! + } + else + { + string_symbols[i] = -d_symbol_history.at(i + d_symbols_per_preamble).Prompt_I; // because last symbol of the preamble is just received now! + } + } + + //call the decoder + decode_string(string_symbols, string_length); + if (d_nav.flag_CRC_test == true) + { + d_CRC_error_counter = 0; + d_flag_preamble = true; //valid preamble indicator (initialized to false every work()) + d_preamble_index = d_sample_counter; //record the preamble sample stamp (t_P) + if (!d_flag_frame_sync) + { + d_flag_frame_sync = true; + DLOG(INFO) << " Frame sync SAT " << this->d_satellite << " with preamble start at " + << d_symbol_history.at(0).Tracking_sample_counter << " [samples]"; + } + } + else + { + d_CRC_error_counter++; + d_preamble_index = d_sample_counter; //record the preamble sample stamp + if (d_CRC_error_counter > CRC_ERROR_LIMIT) + { + LOG(INFO) << "Lost of frame sync SAT " << this->d_satellite; + d_flag_frame_sync = false; + d_stat = 0; + } + } + } + } + + // UPDATE GNSS SYNCHRO DATA + //2. Add the telemetry decoder information + if (this->d_flag_preamble == true and d_nav.flag_TOW_new == true) + //update TOW at the preamble instant + { + d_TOW_at_current_symbol = floor((d_nav.gnav_ephemeris.d_TOW - GLONASS_GNAV_PREAMBLE_DURATION_S) * 1000) / 1000; + d_nav.flag_TOW_new = false; + } + else //if there is not a new preamble, we define the TOW of the current symbol + { + d_TOW_at_current_symbol = d_TOW_at_current_symbol + GLONASS_L2_CA_CODE_PERIOD; + } + + //if (d_flag_frame_sync == true and d_nav.flag_TOW_set==true and d_nav.flag_CRC_test == true) + + // if(d_nav.flag_GGTO_1 == true and d_nav.flag_GGTO_2 == true and d_nav.flag_GGTO_3 == true and d_nav.flag_GGTO_4 == true) //all GGTO parameters arrived + // { + // delta_t = d_nav.A_0G_10 + d_nav.A_1G_10 * (d_TOW_at_current_symbol - d_nav.t_0G_10 + 604800.0 * (fmod((d_nav.WN_0 - d_nav.WN_0G_10), 64))); + // } + + if (d_flag_frame_sync == true and d_nav.flag_TOW_set == true) + { + current_symbol.Flag_valid_word = true; + } + else + { + current_symbol.Flag_valid_word = false; + } + + current_symbol.PRN = this->d_satellite.get_PRN(); + current_symbol.TOW_at_current_symbol_s = d_TOW_at_current_symbol; + current_symbol.TOW_at_current_symbol_s -= delta_t; // Galileo to GPS TOW + + if (d_dump == true) + { + // MULTIPLEXED FILE RECORDING - Record results to file + try + { + double tmp_double; + unsigned long int tmp_ulong_int; + tmp_double = d_TOW_at_current_symbol; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + tmp_ulong_int = current_symbol.Tracking_sample_counter; + d_dump_file.write(reinterpret_cast(&tmp_ulong_int), sizeof(unsigned long int)); + tmp_double = 0; + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "Exception writing observables dump file " << e.what(); + } + } + + // remove used symbols from history + if (d_symbol_history.size() > required_symbols) + { + d_symbol_history.pop_front(); + } + //3. Make the output (copy the object contents to the GNURadio reserved memory) + *out[0] = current_symbol; + + return 1; +} + + +void glonass_l2_ca_telemetry_decoder_cc::set_satellite(const Gnss_Satellite &satellite) +{ + d_satellite = Gnss_Satellite(satellite.get_system(), satellite.get_PRN()); + DLOG(INFO) << "Setting decoder Finite State Machine to satellite " << d_satellite; + DLOG(INFO) << "Navigation Satellite set to " << d_satellite; +} + + +void glonass_l2_ca_telemetry_decoder_cc::set_channel(int channel) +{ + d_channel = channel; + LOG(INFO) << "Navigation channel set to " << channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump == true) + { + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename = "telemetry"; + d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Telemetry decoder dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "channel " << d_channel << ": exception opening Glonass TLM dump file. " << e.what(); + } + } + } +} diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.h new file mode 100644 index 000000000..2751678a4 --- /dev/null +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/glonass_l2_ca_telemetry_decoder_cc.h @@ -0,0 +1,117 @@ +/*! + * \file glonass_l2_ca_telemetry_decoder_cc.h + * \brief Implementation of an adapter of a GLONASS L2 C/A NAV data decoder block + * to a TelemetryDecoderInterface + * \author Damian Miralles, 2018. dmiralles2009(at)gmail.com + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_GLONASS_L2_CA_TELEMETRY_DECODER_CC_H +#define GNSS_SDR_GLONASS_L2_CA_TELEMETRY_DECODER_CC_H + + +#include "GLONASS_L1_L2_CA.h" +#include "glonass_gnav_navigation_message.h" +#include "glonass_gnav_ephemeris.h" +#include "glonass_gnav_almanac.h" +#include "glonass_gnav_utc_model.h" +#include "gnss_satellite.h" +#include "gnss_synchro.h" +#include +#include +#include + + +class glonass_l2_ca_telemetry_decoder_cc; + +typedef boost::shared_ptr glonass_l2_ca_telemetry_decoder_cc_sptr; + +glonass_l2_ca_telemetry_decoder_cc_sptr glonass_l2_ca_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); + +/*! + * \brief This class implements a block that decodes the GNAV data defined in GLONASS ICD v5.1 + * \see GLONASS ICD + * + */ +class glonass_l2_ca_telemetry_decoder_cc : public gr::block +{ +public: + ~glonass_l2_ca_telemetry_decoder_cc(); //!< Class destructor + void set_satellite(const Gnss_Satellite &satellite); //!< Set satellite PRN + void set_channel(int channel); //!< Set receiver's channel + + /*! + * \brief This is where all signal processing takes place + */ + int general_work(int noutput_items, gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); + +private: + friend glonass_l2_ca_telemetry_decoder_cc_sptr + glonass_l2_ca_make_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); + glonass_l2_ca_telemetry_decoder_cc(const Gnss_Satellite &satellite, bool dump); + + void decode_string(double *symbols, int frame_length); + + //!< Help with coherent tracking + double d_preamble_time_samples; + + //!< Preamble decoding + unsigned short int d_preambles_bits[GLONASS_GNAV_PREAMBLE_LENGTH_BITS]; + int *d_preambles_symbols; + unsigned int d_samples_per_symbol; + int d_symbols_per_preamble; + + //!< Storage for incoming data + std::deque d_symbol_history; + + //!< Variables for internal functionality + long unsigned int d_sample_counter; //!< Sample counter as an index (1,2,3,..etc) indicating number of samples processed + long unsigned int d_preamble_index; //!< Index of sample number where preamble was found + unsigned int d_stat; //!< Status of decoder + bool d_flag_frame_sync; //!< Indicate when a frame sync is achieved + bool d_flag_parity; //!< Flag indicating when parity check was achieved (crc check) + bool d_flag_preamble; //!< Flag indicating when preamble was found + int d_CRC_error_counter; //!< Number of failed CRC operations + bool flag_TOW_set; //!< Indicates when time of week is set + double delta_t; //!< GPS-GLONASS time offset + + //!< Navigation Message variable + Glonass_Gnav_Navigation_Message d_nav; + + //!< Values to populate gnss synchronization structure + double d_TOW_at_current_symbol; + bool Flag_valid_word; + + //!< Satellite Information and logging capacity + Gnss_Satellite d_satellite; + int d_channel; + bool d_dump; + std::string d_dump_filename; + std::ofstream d_dump_file; +}; + +#endif diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc index 79b0fdb07..af9666c03 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.cc @@ -70,9 +70,9 @@ gps_l5_telemetry_decoder_cc::gps_l5_telemetry_decoder_cc( d_TOW_at_Preamble = 0.0; //initialize the CNAV frame decoder (libswiftcnav) cnav_msg_decoder_init(&d_cnav_decoder); - for (int aux = 0; aux < GPS_L5_NH_CODE_LENGTH; aux++) + for (int aux = 0; aux < GPS_L5i_NH_CODE_LENGTH; aux++) { - if (GPS_L5_NH_CODE[aux] == 0) + if (GPS_L5i_NH_CODE[aux] == 0) { bits_NH[aux] = -1.0; } @@ -119,9 +119,9 @@ int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((u int symbol_value = 0; //Search correlation with Neuman-Hofman Code (see IS-GPS-705D) - if (sym_hist.size() == GPS_L5_NH_CODE_LENGTH) + if (sym_hist.size() == GPS_L5i_NH_CODE_LENGTH) { - for (int i = 0; i < GPS_L5_NH_CODE_LENGTH; i++) + for (int i = 0; i < GPS_L5i_NH_CODE_LENGTH; i++) { if ((bits_NH[i] * sym_hist.at(i)) > 0.0) { @@ -132,7 +132,7 @@ int gps_l5_telemetry_decoder_cc::general_work(int noutput_items __attribute__((u corr_NH -= 1; } } - if (abs(corr_NH) == GPS_L5_NH_CODE_LENGTH) + if (abs(corr_NH) == GPS_L5i_NH_CODE_LENGTH) { sync_NH = true; if (corr_NH > 0) diff --git a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.h b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.h index c13c2832b..59f0bf108 100644 --- a/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.h +++ b/src/algorithms/telemetry_decoder/gnuradio_blocks/gps_l5_telemetry_decoder_cc.h @@ -42,8 +42,7 @@ #include #include -extern "C" -{ +extern "C" { #include "cnav_msg.h" #include "edc.h" #include "bits.h" @@ -91,7 +90,7 @@ private: bool d_flag_valid_word; Gps_CNAV_Navigation_Message d_CNAV_Message; - double bits_NH[GPS_L5_NH_CODE_LENGTH]; + double bits_NH[GPS_L5i_NH_CODE_LENGTH]; std::deque sym_hist; bool sync_NH; bool new_sym; diff --git a/src/algorithms/tracking/adapters/CMakeLists.txt b/src/algorithms/tracking/adapters/CMakeLists.txt index 18f98d42c..7b7e6b541 100644 --- a/src/algorithms/tracking/adapters/CMakeLists.txt +++ b/src/algorithms/tracking/adapters/CMakeLists.txt @@ -25,7 +25,7 @@ if(ENABLE_FPGA) SET(OPT_TRACKING_ADAPTERS ${OPT_TRACKING_ADAPTERS} gps_l1_ca_dll_pll_c_aid_tracking_fpga.cc) endif(ENABLE_FPGA) -set(TRACKING_ADAPTER_SOURCES +set(TRACKING_ADAPTER_SOURCES galileo_e1_dll_pll_veml_tracking.cc galileo_e1_tcp_connector_tracking.cc gps_l1_ca_dll_pll_tracking.cc @@ -37,9 +37,11 @@ set(TRACKING_ADAPTER_SOURCES glonass_l1_ca_dll_pll_c_aid_tracking.cc gps_l5i_dll_pll_tracking.cc gps_l1_ca_kf_tracking.cc + glonass_l2_ca_dll_pll_tracking.cc + glonass_l2_ca_dll_pll_c_aid_tracking.cc ${OPT_TRACKING_ADAPTERS} ) - + include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src/core/system_parameters 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 acae5564a..f6ca8df87 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 @@ -51,7 +51,6 @@ GalileoE1DllPllVemlTracking::GalileoE1DllPllVemlTracking( //################# CONFIGURATION PARAMETERS ######################## int fs_in; int vector_length; - int f_if; bool dump; std::string dump_filename; std::string item_type; @@ -64,11 +63,9 @@ GalileoE1DllPllVemlTracking::GalileoE1DllPllVemlTracking( float very_early_late_space_chips; float early_late_space_narrow_chips; float very_early_late_space_narrow_chips; - item_type = configuration->property(role + ".item_type", default_item_type); int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - f_if = configuration->property(role + ".if", 0); dump = configuration->property(role + ".dump", false); 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); @@ -94,8 +91,9 @@ GalileoE1DllPllVemlTracking::GalileoE1DllPllVemlTracking( if (item_type.compare("gr_complex") == 0) { item_size_ = sizeof(gr_complex); - tracking_ = galileo_e1_dll_pll_veml_make_tracking_cc( - f_if, + + char sig_[3] = "1B"; + tracking_ = dll_pll_veml_make_tracking( fs_in, vector_length, dump, @@ -109,7 +107,7 @@ GalileoE1DllPllVemlTracking::GalileoE1DllPllVemlTracking( early_late_space_narrow_chips, very_early_late_space_narrow_chips, extend_correlation_symbols, - track_pilot); + track_pilot, 'E', sig_); } else { diff --git a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking.h b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking.h index e702ff14d..ab72a2efb 100644 --- a/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking.h +++ b/src/algorithms/tracking/adapters/galileo_e1_dll_pll_veml_tracking.h @@ -38,7 +38,7 @@ #define GNSS_SDR_GALILEO_E1_DLL_PLL_VEML_TRACKING_H_ #include "tracking_interface.h" -#include "galileo_e1_dll_pll_veml_tracking_cc.h" +#include "dll_pll_veml_tracking.h" #include @@ -94,7 +94,7 @@ public: void start_tracking() override; private: - galileo_e1_dll_pll_veml_tracking_cc_sptr tracking_; + dll_pll_veml_tracking_sptr tracking_; size_t item_size_; unsigned int channel_; std::string role_; 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 4bc5e7e34..481be8080 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 @@ -39,8 +39,8 @@ #include "glonass_l1_ca_dll_pll_c_aid_tracking.h" #include "configuration_interface.h" -#include "GLONASS_L1_CA.h" #include "gnss_sdr_flags.h" +#include "GLONASS_L1_L2_CA.h" #include 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 b9feb622e..cf082d8b6 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 @@ -38,8 +38,8 @@ #include "glonass_l1_ca_dll_pll_tracking.h" #include "configuration_interface.h" -#include "GLONASS_L1_CA.h" #include "gnss_sdr_flags.h" +#include "GLONASS_L1_L2_CA.h" #include 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 new file mode 100644 index 000000000..59f0dedb0 --- /dev/null +++ b/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_c_aid_tracking.cc @@ -0,0 +1,241 @@ +/*! + * \file glonass_l2_ca_dll_pll_c_aid_tracking.cc + * \brief Interface of an adapter of a DLL+PLL tracking loop block + * for Glonass L2 C/A to a TrackingInterface + * \author Damian Miralles, 2018. dmiralles2009(at)gmail.com + * + * + * Code DLL + carrier PLL according to the algorithms described in: + * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, + * A Software-Defined GPS and Galileo Receiver. A Single-Frequency + * Approach, Birkha user, 2007 + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "glonass_l2_ca_dll_pll_c_aid_tracking.h" +#include "configuration_interface.h" +#include "GLONASS_L1_L2_CA.h" +#include "gnss_sdr_flags.h" +#include + + +using google::LogMessage; + +GlonassL2CaDllPllCAidTracking::GlonassL2CaDllPllCAidTracking( + ConfigurationInterface* configuration, std::string role, + unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) +{ + DLOG(INFO) << "role " << role; + //################# CONFIGURATION PARAMETERS ######################## + int fs_in; + int vector_length; + int f_if; + bool dump; + std::string dump_filename; + std::string default_item_type = "gr_complex"; + float pll_bw_hz; + float pll_bw_narrow_hz; + float dll_bw_hz; + float dll_bw_narrow_hz; + float early_late_space_chips; + item_type_ = configuration->property(role + ".item_type", default_item_type); + //vector_length = configuration->property(role + ".vector_length", 2048); + int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); + fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + f_if = configuration->property(role + ".if", 0); + 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); + 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); + 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; + extend_correlation_ms = configuration->property(role + ".extend_correlation_ms", 1); + + 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); //unused! + vector_length = std::round(fs_in / (GLONASS_L2_CA_CODE_RATE_HZ / GLONASS_L2_CA_CODE_LENGTH_CHIPS)); + + //################# MAKE TRACKING GNURadio object ################### + if (item_type_.compare("gr_complex") == 0) + { + item_size_ = sizeof(gr_complex); + tracking_cc = glonass_l2_ca_dll_pll_c_aid_make_tracking_cc( + f_if, + 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); + DLOG(INFO) << "tracking(" << tracking_cc->unique_id() << ")"; + } + else if (item_type_.compare("cshort") == 0) + { + item_size_ = sizeof(lv_16sc_t); + tracking_sc = glonass_l2_ca_dll_pll_c_aid_make_tracking_sc( + f_if, + 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); + DLOG(INFO) << "tracking(" << tracking_sc->unique_id() << ")"; + } + else + { + item_size_ = sizeof(gr_complex); + LOG(WARNING) << item_type_ << " unknown tracking item type."; + } + channel_ = 0; +} + + +GlonassL2CaDllPllCAidTracking::~GlonassL2CaDllPllCAidTracking() +{ +} + + +void GlonassL2CaDllPllCAidTracking::start_tracking() +{ + if (item_type_.compare("gr_complex") == 0) + { + tracking_cc->start_tracking(); + } + else if (item_type_.compare("cshort") == 0) + { + tracking_sc->start_tracking(); + } + else + { + LOG(WARNING) << item_type_ << " unknown tracking item type"; + } +} + + +/* + * Set tracking channel unique ID + */ +void GlonassL2CaDllPllCAidTracking::set_channel(unsigned int channel) +{ + channel_ = channel; + + if (item_type_.compare("gr_complex") == 0) + { + tracking_cc->set_channel(channel); + } + else if (item_type_.compare("cshort") == 0) + { + tracking_sc->set_channel(channel); + } + else + { + LOG(WARNING) << item_type_ << " unknown tracking item type"; + } +} + + +void GlonassL2CaDllPllCAidTracking::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) +{ + if (item_type_.compare("gr_complex") == 0) + { + tracking_cc->set_gnss_synchro(p_gnss_synchro); + } + else if (item_type_.compare("cshort") == 0) + { + tracking_sc->set_gnss_synchro(p_gnss_synchro); + } + else + { + LOG(WARNING) << item_type_ << " unknown tracking item type"; + } +} + + +void GlonassL2CaDllPllCAidTracking::connect(gr::top_block_sptr top_block) +{ + if (top_block) + { /* top_block is not null */ + }; + //nothing to connect, now the tracking uses gr_sync_decimator +} + + +void GlonassL2CaDllPllCAidTracking::disconnect(gr::top_block_sptr top_block) +{ + if (top_block) + { /* top_block is not null */ + }; + //nothing to disconnect, now the tracking uses gr_sync_decimator +} + + +gr::basic_block_sptr GlonassL2CaDllPllCAidTracking::get_left_block() +{ + if (item_type_.compare("gr_complex") == 0) + { + return tracking_cc; + } + else if (item_type_.compare("cshort") == 0) + { + return tracking_sc; + } + else + { + LOG(WARNING) << item_type_ << " unknown tracking item type"; + return nullptr; + } +} + + +gr::basic_block_sptr GlonassL2CaDllPllCAidTracking::get_right_block() +{ + if (item_type_.compare("gr_complex") == 0) + { + return tracking_cc; + } + else if (item_type_.compare("cshort") == 0) + { + return tracking_sc; + } + else + { + LOG(WARNING) << item_type_ << " unknown tracking item type"; + return nullptr; + } +} diff --git a/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_c_aid_tracking.h b/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_c_aid_tracking.h new file mode 100644 index 000000000..fc45d1cd1 --- /dev/null +++ b/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_c_aid_tracking.h @@ -0,0 +1,106 @@ +/*! + * \file glonass_l2_ca_dll_pll_c_aid_tracking.h + * \brief Interface of an adapter of a DLL+PLL tracking loop block + * for Glonass L2 C/A to a TrackingInterface + * \author Damian Miralles, 2018. dmiralles2009(at)gmail.com + * + * + * Code DLL + carrier PLL according to the algorithms described in: + * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, + * A Software-Defined GPS and Galileo Receiver. A Single-Frequency + * Approach, Birkha user, 2007 + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_GLONASS_L2_CA_DLL_PLL_C_AID_TRACKING_H_ +#define GNSS_SDR_GLONASS_L2_CA_DLL_PLL_C_AID_TRACKING_H_ + +#include "tracking_interface.h" +#include "glonass_l2_ca_dll_pll_c_aid_tracking_cc.h" +#include "glonass_l2_ca_dll_pll_c_aid_tracking_sc.h" +#include + +class ConfigurationInterface; + +/*! + * \brief This class implements a code DLL + carrier PLL tracking loop + */ +class GlonassL2CaDllPllCAidTracking : public TrackingInterface +{ +public: + GlonassL2CaDllPllCAidTracking(ConfigurationInterface* configuration, + std::string role, + unsigned int in_streams, + unsigned int out_streams); + + virtual ~GlonassL2CaDllPllCAidTracking(); + + inline std::string role() override + { + return role_; + } + + //! Returns "GLONASS_L2_CA_DLL_PLL_C_Aid_Tracking" + inline std::string implementation() override + { + return "GLONASS_L2_CA_DLL_PLL_C_Aid_Tracking"; + } + + inline size_t item_size() override + { + return item_size_; + } + + void connect(gr::top_block_sptr top_block) override; + void disconnect(gr::top_block_sptr top_block) override; + gr::basic_block_sptr get_left_block() override; + gr::basic_block_sptr get_right_block() override; + + /*! + * \brief Set tracking channel unique ID + */ + void set_channel(unsigned int channel) override; + + /*! + * \brief Set acquisition/tracking common Gnss_Synchro object pointer + * to efficiently exchange synchronization data between acquisition and tracking blocks + */ + void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; + + void start_tracking() override; + +private: + glonass_l2_ca_dll_pll_c_aid_tracking_cc_sptr tracking_cc; + glonass_l2_ca_dll_pll_c_aid_tracking_sc_sptr tracking_sc; + size_t item_size_; + std::string item_type_; + unsigned int channel_; + std::string role_; + unsigned int in_streams_; + unsigned int out_streams_; +}; + +#endif // GNSS_SDR_GLONASS_L2_CA_DLL_PLL_C_AID_TRACKING_H_ 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 new file mode 100644 index 000000000..12cd75953 --- /dev/null +++ b/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_tracking.cc @@ -0,0 +1,154 @@ +/*! + * \file glonass_l2_ca_dll_pll_tracking.cc + * \brief Interface of an adapter of a DLL+PLL tracking loop block + * for Glonass L2 C/A to a TrackingInterface + * \author Damian Miralles, 2018, dmiralles2009(at)gmail.com * + * + * Code DLL + carrier PLL according to the algorithms described in: + * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, + * A Software-Defined GPS and Galileo Receiver. A Single-Frequency + * Approach, Birkha user, 2007 + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "glonass_l2_ca_dll_pll_tracking.h" +#include "configuration_interface.h" +#include "GLONASS_L1_L2_CA.h" +#include "gnss_sdr_flags.h" +#include + + +using google::LogMessage; + +GlonassL2CaDllPllTracking::GlonassL2CaDllPllTracking( + ConfigurationInterface* configuration, std::string role, + unsigned int in_streams, unsigned int out_streams) : role_(role), in_streams_(in_streams), out_streams_(out_streams) +{ + DLOG(INFO) << "role " << role; + //################# CONFIGURATION PARAMETERS ######################## + int fs_in; + int vector_length; + int f_if; + bool dump; + std::string dump_filename; + std::string item_type; + std::string default_item_type = "gr_complex"; + float pll_bw_hz; + float dll_bw_hz; + float early_late_space_chips; + item_type = configuration->property(role + ".item_type", default_item_type); + int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); + fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); + f_if = configuration->property(role + ".if", 0); + 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); + 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); + 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); //unused! + vector_length = std::round(fs_in / (GLONASS_L2_CA_CODE_RATE_HZ / GLONASS_L2_CA_CODE_LENGTH_CHIPS)); + + //################# MAKE TRACKING GNURadio object ################### + if (item_type.compare("gr_complex") == 0) + { + item_size_ = sizeof(gr_complex); + tracking_ = glonass_l2_ca_dll_pll_make_tracking_cc( + f_if, + fs_in, + vector_length, + dump, + dump_filename, + pll_bw_hz, + dll_bw_hz, + early_late_space_chips); + } + else + { + item_size_ = sizeof(gr_complex); + LOG(WARNING) << item_type << " unknown tracking item type."; + } + channel_ = 0; + DLOG(INFO) << "tracking(" << tracking_->unique_id() << ")"; +} + + +GlonassL2CaDllPllTracking::~GlonassL2CaDllPllTracking() +{ +} + + +void GlonassL2CaDllPllTracking::start_tracking() +{ + tracking_->start_tracking(); +} + + +/* + * Set tracking channel unique ID + */ +void GlonassL2CaDllPllTracking::set_channel(unsigned int channel) +{ + channel_ = channel; + tracking_->set_channel(channel); +} + + +void GlonassL2CaDllPllTracking::set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) +{ + tracking_->set_gnss_synchro(p_gnss_synchro); +} + + +void GlonassL2CaDllPllTracking::connect(gr::top_block_sptr top_block) +{ + if (top_block) + { /* top_block is not null */ + }; + //nothing to connect, now the tracking uses gr_sync_decimator +} + + +void GlonassL2CaDllPllTracking::disconnect(gr::top_block_sptr top_block) +{ + if (top_block) + { /* top_block is not null */ + }; + //nothing to disconnect, now the tracking uses gr_sync_decimator +} + + +gr::basic_block_sptr GlonassL2CaDllPllTracking::get_left_block() +{ + return tracking_; +} + + +gr::basic_block_sptr GlonassL2CaDllPllTracking::get_right_block() +{ + return tracking_; +} diff --git a/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_tracking.h b/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_tracking.h new file mode 100644 index 000000000..700b5b8c1 --- /dev/null +++ b/src/algorithms/tracking/adapters/glonass_l2_ca_dll_pll_tracking.h @@ -0,0 +1,103 @@ +/*! + * \file glonass_l2_ca_dll_pll_tracking.h + * \brief Interface of an adapter of a DLL+PLL tracking loop block + * for Glonass L2 C/A to a TrackingInterface + * \author Damian Miralles, 2018, dmiralles2009(at)gmail.com + * + * + * Code DLL + carrier PLL according to the algorithms described in: + * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, + * A Software-Defined GPS and Galileo Receiver. A Single-Frequency + * Approach, Birkha user, 2007 + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_GLONASS_L2_CA_DLL_PLL_TRACKING_H_ +#define GNSS_SDR_GLONASS_L2_CA_DLL_PLL_TRACKING_H_ + +#include "tracking_interface.h" +#include "glonass_l2_ca_dll_pll_tracking_cc.h" +#include + +class ConfigurationInterface; + +/*! + * \brief This class implements a code DLL + carrier PLL tracking loop + */ +class GlonassL2CaDllPllTracking : public TrackingInterface +{ +public: + GlonassL2CaDllPllTracking(ConfigurationInterface* configuration, + std::string role, + unsigned int in_streams, + unsigned int out_streams); + + virtual ~GlonassL2CaDllPllTracking(); + + inline std::string role() override + { + return role_; + } + + //! Returns "GLONASS_L1_CA_DLL_PLL_Tracking" + inline std::string implementation() override + { + return "GLONASS_L2_CA_DLL_PLL_Tracking"; + } + + inline size_t item_size() override + { + return item_size_; + } + + void connect(gr::top_block_sptr top_block) override; + void disconnect(gr::top_block_sptr top_block) override; + gr::basic_block_sptr get_left_block() override; + gr::basic_block_sptr get_right_block() override; + + /*! + * \brief Set tracking channel unique ID + */ + void set_channel(unsigned int channel) override; + + /*! + * \brief Set acquisition/tracking common Gnss_Synchro object pointer + * to efficiently exchange synchronization data between acquisition and tracking blocks + */ + void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro) override; + + void start_tracking() override; + +private: + glonass_l2_ca_dll_pll_tracking_cc_sptr tracking_; + size_t item_size_; + unsigned int channel_; + std::string role_; + unsigned int in_streams_; + unsigned int out_streams_; +}; + +#endif // GNSS_SDR_GLONASS_L2_CA_DLL_PLL_TRACKING_H_ 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 d58329575..b95b003f2 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 @@ -52,41 +52,48 @@ GpsL1CaDllPllTracking::GpsL1CaDllPllTracking( //################# CONFIGURATION PARAMETERS ######################## int fs_in; int vector_length; - int f_if; bool dump; std::string dump_filename; std::string item_type; std::string default_item_type = "gr_complex"; - float pll_bw_hz; - float dll_bw_hz; - float early_late_space_chips; item_type = configuration->property(role + ".item_type", default_item_type); int fs_in_deprecated = configuration->property("GNSS-SDR.internal_fs_hz", 2048000); fs_in = configuration->property("GNSS-SDR.internal_fs_sps", fs_in_deprecated); - f_if = configuration->property(role + ".if", 0); dump = configuration->property(role + ".dump", false); - pll_bw_hz = configuration->property(role + ".pll_bw_hz", 50.0); + 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); - dll_bw_hz = configuration->property(role + ".dll_bw_hz", 2.0); + float pll_bw_narrow_hz = configuration->property(role + ".pll_bw_narrow_hz", 20.0); + float dll_bw_narrow_hz = configuration->property(role + ".dll_bw_narrow_hz", 2.0); + 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); - early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5); + float early_late_space_chips = configuration->property(role + ".early_late_space_chips", 0.5); + float early_late_space_narrow_chips = configuration->property(role + ".early_late_space_narrow_chips", 0.5); std::string default_dump_filename = "./track_ch"; dump_filename = configuration->property(role + ".dump_filename", default_dump_filename); //unused! vector_length = std::round(fs_in / (GPS_L1_CA_CODE_RATE_HZ / GPS_L1_CA_CODE_LENGTH_CHIPS)); - + int symbols_extended_correlator = configuration->property(role + ".extend_correlation_symbols", 1); + if (symbols_extended_correlator < 1) symbols_extended_correlator = 1; //################# MAKE TRACKING GNURadio object ################### if (item_type.compare("gr_complex") == 0) { item_size_ = sizeof(gr_complex); - tracking_ = gps_l1_ca_dll_pll_make_tracking_cc( - f_if, + char sig_[3] = "1C"; + tracking_ = dll_pll_veml_make_tracking( fs_in, vector_length, dump, dump_filename, pll_bw_hz, dll_bw_hz, - early_late_space_chips); + pll_bw_narrow_hz, + dll_bw_narrow_hz, + early_late_space_chips, + early_late_space_chips, + early_late_space_narrow_chips, + early_late_space_narrow_chips, + symbols_extended_correlator, + false, + 'G', sig_); } else { diff --git a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking.h b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking.h index ff5a91899..2b5557917 100644 --- a/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking.h +++ b/src/algorithms/tracking/adapters/gps_l1_ca_dll_pll_tracking.h @@ -39,7 +39,7 @@ #define GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_H_ #include "tracking_interface.h" -#include "gps_l1_ca_dll_pll_tracking_cc.h" +#include "dll_pll_veml_tracking.h" #include class ConfigurationInterface; @@ -92,7 +92,7 @@ public: void start_tracking() override; private: - gps_l1_ca_dll_pll_tracking_cc_sptr tracking_; + dll_pll_veml_tracking_sptr tracking_; size_t item_size_; unsigned int channel_; std::string role_; diff --git a/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt b/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt index 4afd844e1..5a427e8a6 100644 --- a/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt @@ -19,7 +19,7 @@ if(ENABLE_CUDA) set(OPT_TRACKING_BLOCKS ${OPT_TRACKING_BLOCKS} gps_l1_ca_dll_pll_tracking_gpu_cc.cc) set(OPT_TRACKING_INCLUDES ${OPT_TRACKING_INCLUDES} ${CUDA_INCLUDE_DIRS}) - set(OPT_TRACKING_LIBRARIES ${OPT_TRACKING_LIBRARIES} ${CUDA_LIBRARIES}) + set(OPT_TRACKING_LIBRARIES ${OPT_TRACKING_LIBRARIES} ${CUDA_LIBRARIES}) endif(ENABLE_CUDA) if(ENABLE_FPGA) @@ -27,9 +27,7 @@ if(ENABLE_FPGA) endif(ENABLE_FPGA) set(TRACKING_GR_BLOCKS_SOURCES - galileo_e1_dll_pll_veml_tracking_cc.cc galileo_e1_tcp_connector_tracking_cc.cc - gps_l1_ca_dll_pll_tracking_cc.cc gps_l1_ca_tcp_connector_tracking_cc.cc galileo_e5a_dll_pll_tracking_cc.cc gps_l2_m_dll_pll_tracking_cc.cc diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc new file mode 100755 index 000000000..e32905196 --- /dev/null +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc @@ -0,0 +1,1532 @@ +/*! + * \file dll_pll_veml_tracking.cc + * \brief Implementation of a code DLL + carrier PLL tracking block. + * \author Antonio Ramos, 2018 antonio.ramosdet(at)gmail.com + * + * Code DLL + carrier PLL according to the algorithms described in: + * [1] K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, + * A Software-Defined GPS and Galileo Receiver. A Single-Frequency + * Approach, Birkhauser, 2007 + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "dll_pll_veml_tracking.h" +#include "tracking_discriminators.h" +#include "lock_detectors.h" +#include "control_message_factory.h" +#include "MATH_CONSTANTS.h" +#include "Galileo_E1.h" +#include "galileo_e1_signal_processing.h" +#include "Galileo_E5a.h" +#include "galileo_e5_signal_processing.h" +#include "GPS_L1_CA.h" +#include "gps_sdr_signal_processing.h" +#include "GPS_L2C.h" +#include "gps_l2c_signal.h" +#include "GPS_L5.h" +#include "gps_l5_signal.h" +#include "gnss_sdr_flags.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using google::LogMessage; + +dll_pll_veml_tracking_sptr dll_pll_veml_make_tracking( + double fs_in, + unsigned int vector_length, + bool dump, + std::string dump_filename, + float pll_bw_hz, + float dll_bw_hz, + float pll_bw_narrow_hz, + float dll_bw_narrow_hz, + float early_late_space_chips, + float very_early_late_space_chips, + float early_late_space_narrow_chips, + float very_early_late_space_narrow_chips, + int extend_correlation_symbols, + bool track_pilot, + char system, char signal[3]) +{ + return dll_pll_veml_tracking_sptr(new dll_pll_veml_tracking( + fs_in, + vector_length, + dump, + dump_filename, + pll_bw_hz, + dll_bw_hz, + pll_bw_narrow_hz, + dll_bw_narrow_hz, + early_late_space_chips, + very_early_late_space_chips, + early_late_space_narrow_chips, + very_early_late_space_narrow_chips, + extend_correlation_symbols, + track_pilot, system, signal)); +} + + +void dll_pll_veml_tracking::forecast(int noutput_items, + gr_vector_int &ninput_items_required) +{ + if (noutput_items != 0) + { + ninput_items_required[0] = static_cast(d_vector_length) * 2; + } +} + + +dll_pll_veml_tracking::dll_pll_veml_tracking( + double fs_in, unsigned int vector_length, bool dump, + std::string dump_filename, float pll_bw_hz, float dll_bw_hz, + float pll_bw_narrow_hz, float dll_bw_narrow_hz, + float early_late_space_chips, float very_early_late_space_chips, + float early_late_space_narrow_chips, float very_early_late_space_narrow_chips, + int extend_correlation_symbols, bool track_pilot, char system, + char signal[3]) : gr::block("dll_pll_veml_tracking", gr::io_signature::make(1, 1, sizeof(gr_complex)), + gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) +{ + // Telemetry bit synchronization message port input + this->message_port_register_in(pmt::mp("preamble_timestamp_s")); + this->message_port_register_out(pmt::mp("events")); + this->set_relative_rate(1.0 / static_cast(vector_length)); + + // initialize internal vars + d_dump = dump; + d_veml = false; + d_cloop = true; + d_synchonizing = false; + d_track_pilot = track_pilot; + d_fs_in = fs_in; + d_vector_length = vector_length; + d_dump_filename = dump_filename; + d_code_chip_rate = 0.0; + d_secondary_code_length = 0; + d_secondary_code_string = nullptr; + signal_type = std::string(signal); + if (system == 'G') + { + systemName = "GPS"; + if (signal_type.compare("1C") == 0) + { + d_signal_carrier_freq = GPS_L1_FREQ_HZ; + d_code_period = GPS_L1_CA_CODE_PERIOD; + d_code_chip_rate = GPS_L1_CA_CODE_RATE_HZ; + d_symbols_per_bit = GPS_CA_TELEMETRY_SYMBOLS_PER_BIT; + d_correlation_length_ms = 1; + d_code_samples_per_chip = 1; + d_code_length_chips = static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS); + // GPS L1 C/A does not have pilot component nor secondary code + d_secondary = false; + d_track_pilot = false; + interchange_iq = false; + } + else if (signal_type.compare("2S") == 0) + { + d_signal_carrier_freq = GPS_L2_FREQ_HZ; + d_code_period = GPS_L2_M_PERIOD; + d_code_chip_rate = GPS_L2_M_CODE_RATE_HZ; + d_code_length_chips = static_cast(GPS_L2_M_CODE_LENGTH_CHIPS); + d_symbols_per_bit = GPS_L2_SAMPLES_PER_SYMBOL; + d_correlation_length_ms = 20; + d_code_samples_per_chip = 1; + // GPS L2 does not have pilot component nor secondary code + d_secondary = false; + d_track_pilot = false; + interchange_iq = false; + } + else if (signal_type.compare("L5") == 0) + { + d_signal_carrier_freq = GPS_L5_FREQ_HZ; + d_code_period = GPS_L5i_PERIOD; + d_code_chip_rate = GPS_L5i_CODE_RATE_HZ; + d_symbols_per_bit = GPS_L5_SAMPLES_PER_SYMBOL; + d_correlation_length_ms = 1; + d_code_samples_per_chip = 1; + d_code_length_chips = static_cast(GPS_L5i_CODE_LENGTH_CHIPS); + // GPS L5 does not have pilot secondary code + d_secondary = true; + if (d_track_pilot) + { + d_secondary_code_length = static_cast(GPS_L5q_NH_CODE_LENGTH); + d_secondary_code_string = const_cast(&GPS_L5q_NH_CODE_STR); + interchange_iq = true; + } + else + { + d_secondary_code_length = static_cast(GPS_L5i_NH_CODE_LENGTH); + d_secondary_code_string = const_cast(&GPS_L5i_NH_CODE_STR); + interchange_iq = false; + } + } + else + { + LOG(WARNING) << "Invalid Signal argument when instantiating tracking blocks"; + std::cerr << "Invalid Signal argument when instantiating tracking blocks" << std::endl; + d_correlation_length_ms = 1; + d_secondary = false; + interchange_iq = false; + d_signal_carrier_freq = 0.0; + d_code_period = 0.0; + d_code_length_chips = 0; + d_code_samples_per_chip = 0; + d_symbols_per_bit = 0; + } + } + else if (system == 'E') + { + systemName = "Galileo"; + if (signal_type.compare("1B") == 0) + { + d_signal_carrier_freq = Galileo_E1_FREQ_HZ; + d_code_period = Galileo_E1_CODE_PERIOD; + d_code_chip_rate = Galileo_E1_CODE_CHIP_RATE_HZ; + d_code_length_chips = static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS); + d_symbols_per_bit = 1; + d_correlation_length_ms = 4; + d_code_samples_per_chip = 2; // CBOC disabled: 2 samples per chip. CBOC enabled: 12 samples per chip + d_veml = true; + if (d_track_pilot) + { + d_secondary = true; + d_secondary_code_length = static_cast(Galileo_E1_C_SECONDARY_CODE_LENGTH); + d_secondary_code_string = const_cast(&Galileo_E1_C_SECONDARY_CODE); + } + else + { + d_secondary = false; + } + interchange_iq = false; // Note that E1-B and E1-C are in anti-phase, NOT IN QUADRATURE. See Galileo ICD. + } + else if (signal_type.compare("5X") == 0) + { + d_signal_carrier_freq = Galileo_E5a_FREQ_HZ; + d_code_period = GALILEO_E5a_CODE_PERIOD; + d_code_chip_rate = Galileo_E5a_CODE_CHIP_RATE_HZ; + d_symbols_per_bit = 20; + d_correlation_length_ms = 1; + d_code_samples_per_chip = 1; + d_code_length_chips = static_cast(Galileo_E5a_CODE_LENGTH_CHIPS); + d_secondary = true; + if (d_track_pilot) + { + interchange_iq = true; + d_secondary_code_length = static_cast(Galileo_E5a_Q_SECONDARY_CODE_LENGTH); + } + else + { + interchange_iq = false; + d_secondary_code_length = static_cast(Galileo_E5a_I_SECONDARY_CODE_LENGTH); + d_secondary_code_string = const_cast(&Galileo_E5a_I_SECONDARY_CODE); + } + } + else + { + LOG(WARNING) << "Invalid Signal argument when instantiating tracking blocks"; + std::cout << "Invalid Signal argument when instantiating tracking blocks" << std::endl; + d_correlation_length_ms = 1; + d_secondary = false; + interchange_iq = false; + d_signal_carrier_freq = 0.0; + d_code_period = 0.0; + d_code_length_chips = 0; + d_code_samples_per_chip = 0; + d_symbols_per_bit = 0; + } + } + else + { + LOG(WARNING) << "Invalid System argument when instantiating tracking blocks"; + std::cerr << "Invalid System argument when instantiating tracking blocks" << std::endl; + d_correlation_length_ms = 1; + d_secondary = false; + interchange_iq = false; + d_signal_carrier_freq = 0.0; + d_code_period = 0.0; + d_code_length_chips = 0; + d_code_samples_per_chip = 0; + d_symbols_per_bit = 0; + } + T_chip_seconds = 0.0; + T_prn_seconds = 0.0; + T_prn_samples = 0.0; + K_blk_samples = 0.0; + + // Initialize tracking ========================================== + + // Set bandwidth of code and carrier loop filters + d_dll_bw_hz = dll_bw_hz; + d_pll_bw_hz = pll_bw_hz; + d_dll_bw_narrow_hz = dll_bw_narrow_hz; + d_pll_bw_narrow_hz = pll_bw_narrow_hz; + + d_code_loop_filter.set_DLL_BW(d_dll_bw_hz); + d_carrier_loop_filter.set_PLL_BW(d_pll_bw_hz); + d_code_loop_filter = Tracking_2nd_DLL_filter(static_cast(d_code_period)); + d_carrier_loop_filter = Tracking_2nd_PLL_filter(static_cast(d_code_period)); + + // Correlator spacing + d_early_late_spc_chips = early_late_space_chips; // Define early-late offset (in chips) + d_very_early_late_spc_chips = very_early_late_space_chips; // Define very-early-late offset (in chips) + d_early_late_spc_narrow_chips = early_late_space_narrow_chips; // Define narrow early-late offset (in chips) + d_very_early_late_spc_narrow_chips = very_early_late_space_narrow_chips; // Define narrow very-early-late offset (in chips) + + // Initialization of local code replica + // Get space for a vector with the sinboc(1,1) replica sampled 2x/chip + d_tracking_code = static_cast(volk_gnsssdr_malloc(2 * d_code_length_chips * sizeof(float), volk_gnsssdr_get_alignment())); + // correlator outputs (scalar) + if (d_veml) + { + // Very-Early, Early, Prompt, Late, Very-Late + d_n_correlator_taps = 5; + } + else + { + // Early, Prompt, Late + d_n_correlator_taps = 3; + } + + d_correlator_outs = static_cast(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + d_local_code_shift_chips = static_cast(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(float), volk_gnsssdr_get_alignment())); + std::fill_n(d_correlator_outs, d_n_correlator_taps, gr_complex(0.0, 0.0)); + + // map memory pointers of correlator outputs + if (d_veml) + { + d_Very_Early = &d_correlator_outs[0]; + d_Early = &d_correlator_outs[1]; + d_Prompt = &d_correlator_outs[2]; + d_Late = &d_correlator_outs[3]; + d_Very_Late = &d_correlator_outs[4]; + d_local_code_shift_chips[0] = -d_very_early_late_spc_chips * static_cast(d_code_samples_per_chip); + d_local_code_shift_chips[1] = -d_early_late_spc_chips * static_cast(d_code_samples_per_chip); + d_local_code_shift_chips[2] = 0.0; + d_local_code_shift_chips[3] = d_early_late_spc_chips * static_cast(d_code_samples_per_chip); + d_local_code_shift_chips[4] = d_very_early_late_spc_chips * static_cast(d_code_samples_per_chip); + d_prompt_data_shift = &d_local_code_shift_chips[2]; + } + else + { + d_Very_Early = nullptr; + d_Early = &d_correlator_outs[0]; + d_Prompt = &d_correlator_outs[1]; + d_Late = &d_correlator_outs[2]; + d_Very_Late = nullptr; + d_local_code_shift_chips[0] = -d_early_late_spc_chips * static_cast(d_code_samples_per_chip); + d_local_code_shift_chips[1] = 0.0; + d_local_code_shift_chips[2] = d_early_late_spc_chips * static_cast(d_code_samples_per_chip); + d_prompt_data_shift = &d_local_code_shift_chips[1]; + } + + multicorrelator_cpu.init(2 * d_vector_length, d_n_correlator_taps); + + if (extend_correlation_symbols > 1) + { + d_enable_extended_integration = true; + d_extend_correlation_symbols = extend_correlation_symbols; + } + else + { + d_enable_extended_integration = false; + d_extend_correlation_symbols = 1; + } + + // Enable Data component prompt correlator (slave to Pilot prompt) if tracking uses Pilot signal + if (d_track_pilot) + { + // Extra correlator for the data component + correlator_data_cpu.init(2 * d_vector_length, 1); + d_Prompt_Data = static_cast(volk_gnsssdr_malloc(sizeof(gr_complex), volk_gnsssdr_get_alignment())); + d_Prompt_Data[0] = gr_complex(0.0, 0.0); + d_data_code = static_cast(volk_gnsssdr_malloc(2 * d_code_length_chips * sizeof(float), volk_gnsssdr_get_alignment())); + } + else + { + d_Prompt_Data = nullptr; + d_data_code = nullptr; + } + + //--- Initializations ---// + // Initial code frequency basis of NCO + d_code_freq_chips = d_code_chip_rate; + // Residual code phase (in chips) + d_rem_code_phase_samples = 0.0; + // Residual carrier phase + d_rem_carr_phase_rad = 0.0; + + // sample synchronization + d_sample_counter = 0; + d_acq_sample_stamp = 0; + + d_current_prn_length_samples = static_cast(d_vector_length); + + // CN0 estimation and lock detector buffers + d_cn0_estimation_counter = 0; + d_Prompt_buffer = new gr_complex[FLAGS_cn0_samples]; + d_carrier_lock_test = 1.0; + d_CN0_SNV_dB_Hz = 0.0; + d_carrier_lock_fail_counter = 0; + d_carrier_lock_threshold = FLAGS_carrier_lock_th; + + clear_tracking_vars(); + + d_acquisition_gnss_synchro = nullptr; + d_channel = 0; + d_acq_code_phase_samples = 0.0; + d_acq_carrier_doppler_hz = 0.0; + d_carrier_doppler_hz = 0.0; + d_acc_carrier_phase_rad = 0.0; + + d_extend_correlation_symbols_count = 0; + d_code_phase_step_chips = 0.0; + d_carrier_phase_step_rad = 0.0; + d_rem_code_phase_chips = 0.0; + d_K_blk_samples = 0.0; + d_code_phase_samples = 0.0; + d_last_prompt = gr_complex(0.0, 0.0); + d_state = 0; // initial state: standby +} + + +void dll_pll_veml_tracking::start_tracking() +{ + gr::thread::scoped_lock l(d_setlock); + /* + * correct the code phase according to the delay between acq and trk + */ + d_acq_code_phase_samples = d_acquisition_gnss_synchro->Acq_delay_samples; + d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz; + d_acq_sample_stamp = d_acquisition_gnss_synchro->Acq_samplestamp_samples; + + long int acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); + double acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / d_fs_in; + DLOG(INFO) << "Number of samples between Acquisition and Tracking = " << acq_trk_diff_samples; + DLOG(INFO) << "Number of seconds between Acquisition and Tracking = " << acq_trk_diff_seconds; + // Doppler effect Fd = (C / (C + Vr)) * F + double radial_velocity = (d_signal_carrier_freq + d_acq_carrier_doppler_hz) / d_signal_carrier_freq; + // new chip and prn sequence periods based on acq Doppler + d_code_freq_chips = radial_velocity * d_code_chip_rate; + d_code_phase_step_chips = d_code_freq_chips / d_fs_in; + double T_chip_mod_seconds = 1.0 / d_code_freq_chips; + double T_prn_mod_seconds = T_chip_mod_seconds * static_cast(d_code_length_chips); + double T_prn_mod_samples = T_prn_mod_seconds * d_fs_in; + + d_current_prn_length_samples = std::round(T_prn_mod_samples); + + double T_prn_true_seconds = static_cast(d_code_length_chips) / d_code_chip_rate; + double T_prn_true_samples = T_prn_true_seconds * d_fs_in; + double T_prn_diff_seconds = T_prn_true_seconds - T_prn_mod_seconds; + double N_prn_diff = acq_trk_diff_seconds / T_prn_true_seconds; + double corrected_acq_phase_samples = std::fmod(d_acq_code_phase_samples + T_prn_diff_seconds * N_prn_diff * d_fs_in, T_prn_true_samples); + if (corrected_acq_phase_samples < 0.0) + { + corrected_acq_phase_samples += T_prn_mod_samples; + } + double delay_correction_samples = d_acq_code_phase_samples - corrected_acq_phase_samples; + + d_acq_code_phase_samples = corrected_acq_phase_samples; + + d_carrier_doppler_hz = d_acq_carrier_doppler_hz; + d_carrier_phase_step_rad = PI_2 * d_carrier_doppler_hz / d_fs_in; + + // DLL/PLL filter initialization + d_carrier_loop_filter.initialize(); // initialize the carrier filter + d_code_loop_filter.initialize(); // initialize the code filter + + if (systemName.compare("GPS") == 0 and signal_type.compare("1C") == 0) + { + gps_l1_ca_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN, 0); + } + else if (systemName.compare("GPS") == 0 and signal_type.compare("2S") == 0) + { + gps_l2c_m_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN); + } + else if (systemName.compare("GPS") == 0 and signal_type.compare("L5") == 0) + { + if (d_track_pilot) + { + gps_l5q_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN); + gps_l5i_code_gen_float(d_data_code, d_acquisition_gnss_synchro->PRN); + d_Prompt_Data[0] = gr_complex(0.0, 0.0); + correlator_data_cpu.set_local_code_and_taps(d_code_length_chips, d_data_code, d_prompt_data_shift); + } + else + { + gps_l5i_code_gen_float(d_tracking_code, d_acquisition_gnss_synchro->PRN); + } + } + else if (systemName.compare("Galileo") == 0 and signal_type.compare("1B") == 0) + { + if (d_track_pilot) + { + char pilot_signal[3] = "1C"; + galileo_e1_code_gen_sinboc11_float(d_tracking_code, pilot_signal, d_acquisition_gnss_synchro->PRN); + galileo_e1_code_gen_sinboc11_float(d_data_code, d_acquisition_gnss_synchro->Signal, d_acquisition_gnss_synchro->PRN); + d_Prompt_Data[0] = gr_complex(0.0, 0.0); + correlator_data_cpu.set_local_code_and_taps(d_code_samples_per_chip * d_code_length_chips, d_data_code, d_prompt_data_shift); + } + else + { + galileo_e1_code_gen_sinboc11_float(d_tracking_code, d_acquisition_gnss_synchro->Signal, d_acquisition_gnss_synchro->PRN); + } + } + else if (systemName.compare("Galileo") == 0 and signal_type.compare("5X") == 0) + { + gr_complex *aux_code = static_cast(volk_gnsssdr_malloc(sizeof(gr_complex) * d_code_length_chips, volk_gnsssdr_get_alignment())); + galileo_e5_a_code_gen_complex_primary(aux_code, d_acquisition_gnss_synchro->PRN, const_cast(signal_type.c_str())); + if (d_track_pilot) + { + d_secondary_code_string = const_cast(&Galileo_E5a_Q_SECONDARY_CODE[d_acquisition_gnss_synchro->PRN - 1]); + for (unsigned int i = 0; i < d_code_length_chips; i++) + { + d_tracking_code[i] = aux_code[i].imag(); + d_data_code[i] = aux_code[i].real(); + } + d_Prompt_Data[0] = gr_complex(0.0, 0.0); + correlator_data_cpu.set_local_code_and_taps(d_code_length_chips, d_data_code, d_prompt_data_shift); + } + else + { + for (unsigned int i = 0; i < d_code_length_chips; i++) + { + d_tracking_code[i] = aux_code[i].real(); + } + } + volk_gnsssdr_free(aux_code); + } + + multicorrelator_cpu.set_local_code_and_taps(d_code_samples_per_chip * d_code_length_chips, d_tracking_code, d_local_code_shift_chips); + std::fill_n(d_correlator_outs, d_n_correlator_taps, gr_complex(0.0, 0.0)); + + d_carrier_lock_fail_counter = 0; + d_rem_code_phase_samples = 0.0; + d_rem_carr_phase_rad = 0.0; + d_rem_code_phase_chips = 0.0; + d_acc_carrier_phase_rad = 0.0; + d_cn0_estimation_counter = 0; + d_carrier_lock_test = 1.0; + d_CN0_SNV_dB_Hz = 0.0; + + if (d_veml) + { + d_local_code_shift_chips[0] = -d_very_early_late_spc_chips * static_cast(d_code_samples_per_chip); + d_local_code_shift_chips[1] = -d_early_late_spc_chips * static_cast(d_code_samples_per_chip); + d_local_code_shift_chips[3] = d_early_late_spc_chips * static_cast(d_code_samples_per_chip); + d_local_code_shift_chips[4] = d_very_early_late_spc_chips * static_cast(d_code_samples_per_chip); + } + else + { + d_local_code_shift_chips[0] = -d_early_late_spc_chips * static_cast(d_code_samples_per_chip); + d_local_code_shift_chips[2] = d_early_late_spc_chips * static_cast(d_code_samples_per_chip); + } + + d_code_phase_samples = d_acq_code_phase_samples; + d_code_loop_filter.set_DLL_BW(d_dll_bw_hz); + d_carrier_loop_filter.set_PLL_BW(d_pll_bw_hz); + d_carrier_loop_filter.set_pdi(static_cast(d_code_period)); + d_code_loop_filter.set_pdi(static_cast(d_code_period)); + + // DEBUG OUTPUT + std::cout << "Tracking of " << systemName << " " << signal_type << " signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; + LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; + + // enable tracking pull-in + d_state = 1; + d_synchonizing = false; + d_cloop = true; + d_Prompt_buffer_deque.clear(); + d_last_prompt = gr_complex(0.0, 0.0); + LOG(INFO) << "PULL-IN Doppler [Hz] = " << d_carrier_doppler_hz + << ". Code Phase correction [samples] = " << delay_correction_samples + << ". PULL-IN Code Phase [samples] = " << d_acq_code_phase_samples; +} + + +dll_pll_veml_tracking::~dll_pll_veml_tracking() +{ + if (d_dump_file.is_open()) + { + try + { + d_dump_file.close(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Exception in destructor " << ex.what(); + } + } + if (d_dump) + { + if (d_channel == 0) + { + std::cout << "Writing .mat files ..."; + } + save_matfile(); + if (d_channel == 0) + { + std::cout << " done." << std::endl; + } + } + try + { + volk_gnsssdr_free(d_local_code_shift_chips); + volk_gnsssdr_free(d_correlator_outs); + volk_gnsssdr_free(d_tracking_code); + if (d_track_pilot) + { + volk_gnsssdr_free(d_Prompt_Data); + volk_gnsssdr_free(d_data_code); + correlator_data_cpu.free(); + } + delete[] d_Prompt_buffer; + multicorrelator_cpu.free(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Exception in destructor " << ex.what(); + } +} + + +bool dll_pll_veml_tracking::acquire_secondary() +{ + // ******* preamble correlation ******** + int corr_value = 0; + for (unsigned int i = 0; i < d_secondary_code_length; i++) + { + if (d_Prompt_buffer_deque.at(i).real() < 0.0) // symbols clipping + { + if (d_secondary_code_string->at(i) == '0') + { + corr_value++; + } + else + { + corr_value--; + } + } + else + { + if (d_secondary_code_string->at(i) == '0') + { + corr_value--; + } + else + { + corr_value++; + } + } + } + + if (abs(corr_value) == d_secondary_code_length) + { + return true; + } + else + { + return false; + } +} + + +bool dll_pll_veml_tracking::cn0_and_tracking_lock_status() +{ + // ####### CN0 ESTIMATION AND LOCK DETECTORS ###### + if (d_cn0_estimation_counter < FLAGS_cn0_samples) + { + // fill buffer with prompt correlator output values + d_Prompt_buffer[d_cn0_estimation_counter] = d_P_accu; + d_cn0_estimation_counter++; + return true; + } + else + { + d_cn0_estimation_counter = 0; + // Code lock indicator + d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer, FLAGS_cn0_samples, static_cast(d_fs_in), static_cast(d_code_length_chips)); + // Carrier lock indicator + d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, FLAGS_cn0_samples); + // Loss of lock detection + if (d_carrier_lock_test < d_carrier_lock_threshold or d_CN0_SNV_dB_Hz < FLAGS_cn0_min) + { + d_carrier_lock_fail_counter++; + } + else + { + if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; + } + if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) + { + std::cout << "Loss of lock in channel " << d_channel << "!" << std::endl; + LOG(INFO) << "Loss of lock in channel " << d_channel << "!"; + this->message_port_pub(pmt::mp("events"), pmt::from_long(3)); // 3 -> loss of lock + d_carrier_lock_fail_counter = 0; + return false; + } + else + { + return true; + } + } +} + + +// correlation requires: +// - updated remnant carrier phase in radians (rem_carr_phase_rad) +// - updated remnant code phase in samples (d_rem_code_phase_samples) +// - d_code_freq_chips +// - d_carrier_doppler_hz +void dll_pll_veml_tracking::do_correlation_step(const gr_complex *input_samples) +{ + // ################# CARRIER WIPEOFF AND CORRELATORS ############################## + // perform carrier wipe-off and compute Early, Prompt and Late correlation + multicorrelator_cpu.set_input_output_vectors(d_correlator_outs, input_samples); + multicorrelator_cpu.Carrier_wipeoff_multicorrelator_resampler( + d_rem_carr_phase_rad, + d_carrier_phase_step_rad, + static_cast(d_rem_code_phase_chips) * static_cast(d_code_samples_per_chip), + static_cast(d_code_phase_step_chips) * static_cast(d_code_samples_per_chip), + d_vector_length); + + // DATA CORRELATOR (if tracking tracks the pilot signal) + if (d_track_pilot) + { + correlator_data_cpu.set_input_output_vectors(d_Prompt_Data, input_samples); + correlator_data_cpu.Carrier_wipeoff_multicorrelator_resampler( + d_rem_carr_phase_rad, + d_carrier_phase_step_rad, + static_cast(d_rem_code_phase_chips) * static_cast(d_code_samples_per_chip), + static_cast(d_code_phase_step_chips) * static_cast(d_code_samples_per_chip), + d_vector_length); + } +} + + +void dll_pll_veml_tracking::run_dll_pll() +{ + // ################## PLL ########################################################## + // PLL discriminator + if (d_cloop) + { + // Costas loop discriminator, insensitive to 180 deg phase transitions + d_carr_error_hz = pll_cloop_two_quadrant_atan(d_P_accu) / PI_2; + } + else + { + // Secondary code acquired. No symbols transition should be present in the signal + d_carr_error_hz = pll_four_quadrant_atan(d_P_accu) / PI_2; + } + + // Carrier discriminator filter + d_carr_error_filt_hz = d_carrier_loop_filter.get_carrier_nco(d_carr_error_hz); + // New carrier Doppler frequency estimation + d_carrier_doppler_hz = d_acq_carrier_doppler_hz + d_carr_error_filt_hz; + // New code Doppler frequency estimation + d_code_freq_chips = (1.0 + (d_carrier_doppler_hz / d_signal_carrier_freq)) * d_code_chip_rate; + + // ################## DLL ########################################################## + // DLL discriminator + if (d_veml) + { + d_code_error_chips = dll_nc_vemlp_normalized(d_VE_accu, d_E_accu, d_L_accu, d_VL_accu); // [chips/Ti] + } + else + { + d_code_error_chips = dll_nc_e_minus_l_normalized(d_E_accu, d_L_accu); // [chips/Ti] + } + // Code discriminator filter + d_code_error_filt_chips = d_code_loop_filter.get_code_nco(d_code_error_chips); // [chips/second] +} + + +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 (d_track_pilot) *d_Prompt_Data = 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; + d_code_error_filt_chips = 0.0; + d_current_symbol = 0; + d_Prompt_buffer_deque.clear(); + d_last_prompt = gr_complex(0.0, 0.0); +} + + +void dll_pll_veml_tracking::update_tracking_vars() +{ + T_chip_seconds = 1.0 / d_code_freq_chips; + T_prn_seconds = T_chip_seconds * static_cast(d_code_length_chips); + double code_error_filt_secs = T_prn_seconds * d_code_error_filt_chips * T_chip_seconds; //[seconds] + + // ################## CARRIER AND CODE NCO BUFFER ALIGNMENT ####################### + // keep alignment parameters for the next input buffer + // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation + T_prn_samples = T_prn_seconds * d_fs_in; + K_blk_samples = T_prn_samples + d_rem_code_phase_samples + code_error_filt_secs * d_fs_in; + d_current_prn_length_samples = static_cast(round(K_blk_samples)); // round to a discrete number of samples + + //################### PLL COMMANDS ################################################# + // carrier phase step (NCO phase increment per sample) [rads/sample] + d_carrier_phase_step_rad = PI_2 * d_carrier_doppler_hz / d_fs_in; + // remnant carrier phase to prevent overflow in the code NCO + d_rem_carr_phase_rad += d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples); + d_rem_carr_phase_rad = fmod(d_rem_carr_phase_rad, PI_2); + // carrier phase accumulator + d_acc_carrier_phase_rad -= d_carrier_phase_step_rad * static_cast(d_current_prn_length_samples); + + //################### DLL COMMANDS ################################################# + // code phase step (Code resampler phase increment per sample) [chips/sample] + d_code_phase_step_chips = d_code_freq_chips / d_fs_in; + // remnant code phase [chips] + d_rem_code_phase_samples = K_blk_samples - static_cast(d_current_prn_length_samples); // rounding error < 1 sample + d_rem_code_phase_chips = d_code_freq_chips * d_rem_code_phase_samples / d_fs_in; +} + + +void dll_pll_veml_tracking::save_correlation_results() +{ + if (d_secondary) + { + if (d_secondary_code_string->at(d_current_symbol) == '0') + { + if (d_veml) + { + d_VE_accu += *d_Very_Early; + d_VL_accu += *d_Very_Late; + } + d_E_accu += *d_Early; + d_P_accu += *d_Prompt; + d_L_accu += *d_Late; + } + else + { + if (d_veml) + { + d_VE_accu -= *d_Very_Early; + d_VL_accu -= *d_Very_Late; + } + d_E_accu -= *d_Early; + d_P_accu -= *d_Prompt; + d_L_accu -= *d_Late; + } + d_current_symbol++; + // secondary code roll-up + d_current_symbol %= d_secondary_code_length; + } + else + { + if (d_veml) + { + d_VE_accu += *d_Very_Early; + d_VL_accu += *d_Very_Late; + } + d_E_accu += *d_Early; + d_P_accu += *d_Prompt; + d_L_accu += *d_Late; + d_current_symbol++; + d_current_symbol %= d_symbols_per_bit; + } + // If tracking pilot, disable Costas loop + if (d_track_pilot) + d_cloop = false; + else + d_cloop = true; +} + + +void dll_pll_veml_tracking::log_data(bool integrating) +{ + if (d_dump) + { + // Dump results to file + float prompt_I; + float prompt_Q; + float tmp_VE, tmp_E, tmp_P, tmp_L, tmp_VL; + float tmp_float; + double tmp_double; + if (d_track_pilot) + { + if (interchange_iq) + { + prompt_I = d_Prompt_Data->imag(); + prompt_Q = d_Prompt_Data->real(); + } + else + { + prompt_I = d_Prompt_Data->real(); + prompt_Q = d_Prompt_Data->imag(); + } + } + else + { + if (interchange_iq) + { + prompt_I = d_Prompt->imag(); + prompt_Q = d_Prompt->real(); + } + else + { + prompt_I = d_Prompt->real(); + prompt_Q = d_Prompt->imag(); + } + } + if (d_veml) + { + tmp_VE = std::abs(d_VE_accu); + tmp_VL = std::abs(d_VL_accu); + } + else + { + tmp_VE = 0.0; + tmp_VL = 0.0; + } + tmp_E = std::abs(d_E_accu); + tmp_P = std::abs(d_P_accu); + tmp_L = std::abs(d_L_accu); + if (integrating) + { + // It compensates the amplitude difference while integrating + if (d_extend_correlation_symbols_count > 0) + { + float scale_factor = static_cast(d_extend_correlation_symbols) / static_cast(d_extend_correlation_symbols_count); + tmp_VE *= scale_factor; + tmp_E *= scale_factor; + tmp_P *= scale_factor; + tmp_L *= scale_factor; + tmp_VL *= scale_factor; + } + } + + try + { + // Dump correlators output + d_dump_file.write(reinterpret_cast(&tmp_VE), sizeof(float)); + d_dump_file.write(reinterpret_cast(&tmp_E), sizeof(float)); + d_dump_file.write(reinterpret_cast(&tmp_P), sizeof(float)); + d_dump_file.write(reinterpret_cast(&tmp_L), sizeof(float)); + d_dump_file.write(reinterpret_cast(&tmp_VL), sizeof(float)); + // PROMPT I and Q (to analyze navigation symbols) + d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); + d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); + // PRN start sample stamp + d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); + // accumulated carrier phase + tmp_float = d_acc_carrier_phase_rad; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // carrier and code frequency + tmp_float = d_carrier_doppler_hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_code_freq_chips; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // PLL commands + tmp_float = d_carr_error_hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_carr_error_filt_hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // DLL commands + tmp_float = d_code_error_chips; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_code_error_filt_chips; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // CN0 and carrier lock test + tmp_float = d_CN0_SNV_dB_Hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_carrier_lock_test; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // AUX vars (for debug purposes) + tmp_float = d_rem_code_phase_samples; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_double = static_cast(d_sample_counter + d_current_prn_length_samples); + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + // PRN + unsigned int prn_ = d_acquisition_gnss_synchro->PRN; + d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "Exception writing trk dump file " << e.what(); + } + } +} + + +int dll_pll_veml_tracking::save_matfile() +{ + // READ DUMP FILE + std::ifstream::pos_type size; + int number_of_double_vars = 1; + int number_of_float_vars = 17; + int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars + + sizeof(float) * number_of_float_vars + sizeof(unsigned int); + std::ifstream dump_file; + dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + try + { + dump_file.open(d_dump_filename.c_str(), std::ios::binary | std::ios::ate); + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem opening dump file:" << e.what() << std::endl; + return 1; + } + // count number of epochs and rewind + long int num_epoch = 0; + if (dump_file.is_open()) + { + size = dump_file.tellg(); + num_epoch = static_cast(size) / static_cast(epoch_size_bytes); + dump_file.seekg(0, std::ios::beg); + } + else + { + return 1; + } + float *abs_VE = new float[num_epoch]; + float *abs_E = new float[num_epoch]; + float *abs_P = new float[num_epoch]; + float *abs_L = new float[num_epoch]; + float *abs_VL = new float[num_epoch]; + float *Prompt_I = new float[num_epoch]; + float *Prompt_Q = new float[num_epoch]; + unsigned long int *PRN_start_sample_count = new unsigned long int[num_epoch]; + float *acc_carrier_phase_rad = new float[num_epoch]; + float *carrier_doppler_hz = new float[num_epoch]; + float *code_freq_chips = new float[num_epoch]; + float *carr_error_hz = new float[num_epoch]; + float *carr_error_filt_hz = new float[num_epoch]; + float *code_error_chips = new float[num_epoch]; + float *code_error_filt_chips = new float[num_epoch]; + float *CN0_SNV_dB_Hz = new float[num_epoch]; + float *carrier_lock_test = new float[num_epoch]; + float *aux1 = new float[num_epoch]; + double *aux2 = new double[num_epoch]; + unsigned int *PRN = new unsigned int[num_epoch]; + + try + { + if (dump_file.is_open()) + { + for (long int i = 0; i < num_epoch; i++) + { + dump_file.read(reinterpret_cast(&abs_VE[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_E[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_P[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_L[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_VL[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&Prompt_I[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&Prompt_Q[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(unsigned long int)); + dump_file.read(reinterpret_cast(&acc_carrier_phase_rad[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&carrier_doppler_hz[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&code_freq_chips[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&carr_error_hz[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&carr_error_filt_hz[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&code_error_chips[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&code_error_filt_chips[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&CN0_SNV_dB_Hz[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&carrier_lock_test[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&aux1[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&aux2[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&PRN[i]), sizeof(unsigned int)); + } + } + dump_file.close(); + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem reading dump file:" << e.what() << std::endl; + delete[] abs_VE; + delete[] abs_E; + delete[] abs_P; + delete[] abs_L; + delete[] abs_VL; + delete[] Prompt_I; + delete[] Prompt_Q; + delete[] PRN_start_sample_count; + delete[] acc_carrier_phase_rad; + delete[] carrier_doppler_hz; + delete[] code_freq_chips; + delete[] carr_error_hz; + delete[] carr_error_filt_hz; + delete[] code_error_chips; + delete[] code_error_filt_chips; + delete[] CN0_SNV_dB_Hz; + delete[] carrier_lock_test; + delete[] aux1; + delete[] aux2; + delete[] PRN; + return 1; + } + + // WRITE MAT FILE + mat_t *matfp; + matvar_t *matvar; + std::string filename = d_dump_filename; + filename.erase(filename.length() - 4, 4); + filename.append(".mat"); + matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); + if (reinterpret_cast(matfp) != NULL) + { + size_t dims[2] = {1, static_cast(num_epoch)}; + matvar = Mat_VarCreate("abs_VE", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_P", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_P, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_L", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_L, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_VL", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Prompt_I", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_I, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Prompt_Q", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_Q, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN_start_sample_count", MAT_C_UINT64, MAT_T_UINT64, 2, dims, PRN_start_sample_count, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("acc_carrier_phase_rad", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, acc_carrier_phase_rad, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carrier_doppler_hz", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carrier_doppler_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_freq_chips", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, code_freq_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carr_error_hz", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carr_error_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carr_error_filt_hz", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carr_error_filt_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_error_chips", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, code_error_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_error_filt_chips", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, code_error_filt_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("CN0_SNV_dB_Hz", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, CN0_SNV_dB_Hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carrier_lock_test", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carrier_lock_test, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("aux1", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, aux1, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("aux2", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux2, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN", MAT_C_UINT32, MAT_T_UINT32, 2, dims, PRN, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + } + Mat_Close(matfp); + delete[] abs_VE; + delete[] abs_E; + delete[] abs_P; + delete[] abs_L; + delete[] abs_VL; + delete[] Prompt_I; + delete[] Prompt_Q; + delete[] PRN_start_sample_count; + delete[] acc_carrier_phase_rad; + delete[] carrier_doppler_hz; + delete[] code_freq_chips; + delete[] carr_error_hz; + delete[] carr_error_filt_hz; + delete[] code_error_chips; + delete[] code_error_filt_chips; + delete[] CN0_SNV_dB_Hz; + delete[] carrier_lock_test; + delete[] aux1; + delete[] aux2; + delete[] PRN; + return 0; +} + + +void dll_pll_veml_tracking::set_channel(unsigned int channel) +{ + gr::thread::scoped_lock l(d_setlock); + d_channel = channel; + LOG(INFO) << "Tracking Channel set to " << d_channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump) + { + if (!d_dump_file.is_open()) + { + try + { + d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); + } + catch (const std::ifstream::failure &e) + { + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); + } + } + } +} + + +void dll_pll_veml_tracking::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) +{ + gr::thread::scoped_lock l(d_setlock); + d_acquisition_gnss_synchro = p_gnss_synchro; +} + + +int dll_pll_veml_tracking::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) +{ + gr::thread::scoped_lock l(d_setlock); + const gr_complex *in = reinterpret_cast(input_items[0]); + Gnss_Synchro **out = reinterpret_cast(&output_items[0]); + Gnss_Synchro current_synchro_data = Gnss_Synchro(); + + switch (d_state) + { + case 0: // Standby - Consume samples at full throttle, do nothing + { + d_sample_counter += ninput_items[0]; + consume_each(ninput_items[0]); + return 0; + break; + } + case 1: // Pull-in + { + // Signal alignment (skip samples until the incoming signal is aligned with local replica) + unsigned long int acq_to_trk_delay_samples = d_sample_counter - d_acq_sample_stamp; + double acq_trk_shif_correction_samples = static_cast(d_current_prn_length_samples) - std::fmod(static_cast(acq_to_trk_delay_samples), static_cast(d_current_prn_length_samples)); + int samples_offset = std::round(d_acq_code_phase_samples + acq_trk_shif_correction_samples); + if (samples_offset < 0) + { + samples_offset = 0; + } + d_acc_carrier_phase_rad -= d_carrier_phase_step_rad * d_acq_code_phase_samples; + d_state = 2; + d_sample_counter += samples_offset; // count for the processed samples + consume_each(samples_offset); // shift input to perform alignment with local replica + return 0; + } + case 2: // Wide tracking and symbol synchronization + { + do_correlation_step(in); + // Save single correlation step variables + if (d_veml) + { + d_VE_accu = *d_Very_Early; + d_VL_accu = *d_Very_Late; + } + d_E_accu = *d_Early; + d_P_accu = *d_Prompt; + d_L_accu = *d_Late; + + // Check lock status + if (!cn0_and_tracking_lock_status()) + { + clear_tracking_vars(); + d_state = 0; // loss-of-lock detected + } + else + { + bool next_state = false; + // Perform DLL/PLL tracking loop computations. Costas Loop enabled + run_dll_pll(); + update_tracking_vars(); + + // enable write dump file this cycle (valid DLL/PLL cycle) + log_data(false); + if (d_secondary) + { + // ####### SECONDARY CODE LOCK ##### + d_Prompt_buffer_deque.push_back(*d_Prompt); + if (d_Prompt_buffer_deque.size() == d_secondary_code_length) + { + next_state = acquire_secondary(); + if (next_state) + { + std::cout << "Secondary code locked for CH " << d_channel + << " : Satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; + } + + d_Prompt_buffer_deque.pop_front(); + } + } + else // Signal does not have secondary code. Search a bit transition by sign change + { + if (d_synchonizing) + { + if (d_Prompt->real() * d_last_prompt.real() > 0.0) + { + d_current_symbol++; + } + else if (d_current_symbol > d_symbols_per_bit) + { + d_synchonizing = false; + d_current_symbol = 1; + } + else + { + d_current_symbol = 1; + d_last_prompt = *d_Prompt; + } + } + else if (d_last_prompt.real() != 0.0) + { + d_current_symbol++; + if (d_current_symbol == d_symbols_per_bit) next_state = true; + } + else + { + d_last_prompt = *d_Prompt; + d_synchonizing = true; + d_current_symbol = 1; + } + } + if (next_state) + { // reset extended correlator + d_VE_accu = gr_complex(0.0, 0.0); + d_E_accu = gr_complex(0.0, 0.0); + d_P_accu = gr_complex(0.0, 0.0); + d_L_accu = gr_complex(0.0, 0.0); + d_VL_accu = gr_complex(0.0, 0.0); + d_last_prompt = gr_complex(0.0, 0.0); + d_Prompt_buffer_deque.clear(); + d_current_symbol = 0; + d_synchonizing = false; + // Set narrow taps delay values [chips] + d_code_loop_filter.set_DLL_BW(d_dll_bw_narrow_hz); + d_carrier_loop_filter.set_PLL_BW(d_pll_bw_narrow_hz); + if (d_veml) + { + d_local_code_shift_chips[0] = -d_very_early_late_spc_narrow_chips * static_cast(d_code_samples_per_chip); + d_local_code_shift_chips[1] = -d_early_late_spc_narrow_chips * static_cast(d_code_samples_per_chip); + d_local_code_shift_chips[3] = d_early_late_spc_narrow_chips * static_cast(d_code_samples_per_chip); + d_local_code_shift_chips[4] = d_very_early_late_spc_narrow_chips * static_cast(d_code_samples_per_chip); + } + else + { + d_local_code_shift_chips[0] = -d_early_late_spc_narrow_chips * static_cast(d_code_samples_per_chip); + d_local_code_shift_chips[2] = d_early_late_spc_narrow_chips * static_cast(d_code_samples_per_chip); + } + + // UPDATE INTEGRATION TIME + if (d_enable_extended_integration) + { + d_extend_correlation_symbols_count = 0; + float new_correlation_time_s = static_cast(d_extend_correlation_symbols) * static_cast(d_code_period); + d_carrier_loop_filter.set_pdi(new_correlation_time_s); + d_code_loop_filter.set_pdi(new_correlation_time_s); + d_state = 3; // next state is the extended correlator integrator + LOG(INFO) << "Enabled " << d_extend_correlation_symbols << " [symbols] extended correlator for CH " + << d_channel + << " : Satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN); + std::cout << "Enabled " << d_extend_correlation_symbols << " [symbols] extended correlator for CH " + << d_channel + << " : Satellite " << Gnss_Satellite(systemName, d_acquisition_gnss_synchro->PRN) << std::endl; + } + else + { + d_state = 4; + } + } + } + break; + } + case 3: // coherent integration (correlation time extension) + { + // Fill the acquisition data + current_synchro_data = *d_acquisition_gnss_synchro; + // perform a correlation step + do_correlation_step(in); + update_tracking_vars(); + save_correlation_results(); + + // ########### Output the tracking results to Telemetry block ########## + if (interchange_iq) + { + if (d_track_pilot) + { + // Note that data and pilot components are in quadrature. I and Q are interchanged + current_synchro_data.Prompt_I = static_cast((*d_Prompt_Data).imag()); + current_synchro_data.Prompt_Q = static_cast((*d_Prompt_Data).real()); + } + else + { + current_synchro_data.Prompt_I = static_cast((*d_Prompt).imag()); + current_synchro_data.Prompt_Q = static_cast((*d_Prompt).real()); + } + } + else + { + if (d_track_pilot) + { + // Note that data and pilot components are in quadrature. I and Q are interchanged + current_synchro_data.Prompt_I = static_cast((*d_Prompt_Data).real()); + current_synchro_data.Prompt_Q = static_cast((*d_Prompt_Data).imag()); + } + else + { + current_synchro_data.Prompt_I = static_cast((*d_Prompt).real()); + current_synchro_data.Prompt_Q = static_cast((*d_Prompt).imag()); + } + } + current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; + current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_rad; + current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; + current_synchro_data.CN0_dB_hz = d_CN0_SNV_dB_Hz; + current_synchro_data.Flag_valid_symbol_output = true; + current_synchro_data.correlation_length_ms = d_correlation_length_ms; + d_extend_correlation_symbols_count++; + if (d_extend_correlation_symbols_count == (d_extend_correlation_symbols - 1)) + { + d_extend_correlation_symbols_count = 0; + d_state = 4; + } + log_data(true); + break; + } + case 4: // narrow tracking + { + // Fill the acquisition data + current_synchro_data = *d_acquisition_gnss_synchro; + + // perform a correlation step + do_correlation_step(in); + save_correlation_results(); + + // check lock status + if (!cn0_and_tracking_lock_status()) + { + clear_tracking_vars(); + d_state = 0; // loss-of-lock detected + } + else + { + run_dll_pll(); + update_tracking_vars(); + + // ########### Output the tracking results to Telemetry block ########## + if (interchange_iq) + { + if (d_track_pilot) + { + // Note that data and pilot components are in quadrature. I and Q are interchanged + current_synchro_data.Prompt_I = static_cast((*d_Prompt_Data).imag()); + current_synchro_data.Prompt_Q = static_cast((*d_Prompt_Data).real()); + } + else + { + current_synchro_data.Prompt_I = static_cast((*d_Prompt).imag()); + current_synchro_data.Prompt_Q = static_cast((*d_Prompt).real()); + } + } + else + { + if (d_track_pilot) + { + // Note that data and pilot components are in quadrature. I and Q are interchanged + current_synchro_data.Prompt_I = static_cast((*d_Prompt_Data).real()); + current_synchro_data.Prompt_Q = static_cast((*d_Prompt_Data).imag()); + } + else + { + current_synchro_data.Prompt_I = static_cast((*d_Prompt).real()); + current_synchro_data.Prompt_Q = static_cast((*d_Prompt).imag()); + } + } + current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; + current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_rad; + current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; + current_synchro_data.CN0_dB_hz = d_CN0_SNV_dB_Hz; + current_synchro_data.Flag_valid_symbol_output = true; + current_synchro_data.correlation_length_ms = d_correlation_length_ms; + // enable write dump file this cycle (valid DLL/PLL cycle) + log_data(false); + // reset extended correlator + d_VE_accu = gr_complex(0.0, 0.0); + d_E_accu = gr_complex(0.0, 0.0); + d_P_accu = gr_complex(0.0, 0.0); + d_L_accu = gr_complex(0.0, 0.0); + d_VL_accu = gr_complex(0.0, 0.0); + if (d_enable_extended_integration) + { + d_state = 3; // new coherent integration (correlation time extension) cycle + } + } + } + } + consume_each(d_current_prn_length_samples); + d_sample_counter += d_current_prn_length_samples; + if (current_synchro_data.Flag_valid_symbol_output) + { + current_synchro_data.fs = static_cast(d_fs_in); + current_synchro_data.Tracking_sample_counter = d_sample_counter; + *out[0] = current_synchro_data; + return 1; + } + return 0; +} diff --git a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.h b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h old mode 100644 new mode 100755 similarity index 60% rename from src/algorithms/tracking/gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.h rename to src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h index c82d01681..1065f44ef --- a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.h +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.h @@ -1,12 +1,11 @@ /*! - * \file galileo_e1_dll_pll_veml_tracking_cc.h - * \brief Implementation of a code DLL + carrier PLL VEML (Very Early - * Minus Late) tracking block for Galileo E1 signals - * \author Luis Esteve, 2012. luis(at)epsilon-formacion.com + * \file dll_pll_veml_tracking.h + * \brief Implementation of a code DLL + carrier PLL tracking block. + * \author Antonio Ramos, 2018 antonio.ramosdet(at)gmail.com * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -29,8 +28,8 @@ * ------------------------------------------------------------------------- */ -#ifndef GNSS_SDR_GALILEO_E1_DLL_PLL_VEML_TRACKING_CC_H -#define GNSS_SDR_GALILEO_E1_DLL_PLL_VEML_TRACKING_CC_H +#ifndef GNSS_SDR_DLL_PLL_VEML_TRACKING_H +#define GNSS_SDR_DLL_PLL_VEML_TRACKING_H #include "gnss_synchro.h" #include "tracking_2nd_DLL_filter.h" @@ -39,72 +38,50 @@ #include #include #include -#include -class galileo_e1_dll_pll_veml_tracking_cc; +class dll_pll_veml_tracking; -typedef boost::shared_ptr galileo_e1_dll_pll_veml_tracking_cc_sptr; +typedef boost::shared_ptr dll_pll_veml_tracking_sptr; -galileo_e1_dll_pll_veml_tracking_cc_sptr -galileo_e1_dll_pll_veml_make_tracking_cc(long if_freq, - long fs_in, unsigned int vector_length, - bool dump, - std::string dump_filename, - float pll_bw_hz, - float dll_bw_hz, - float pll_bw_narrow_hz, - float dll_bw_narrow_hz, - float early_late_space_chips, - float very_early_late_space_chips, +dll_pll_veml_tracking_sptr dll_pll_veml_make_tracking(double fs_in, unsigned int vector_length, + bool dump, std::string dump_filename, + float pll_bw_hz, float dll_bw_hz, + float pll_bw_narrow_hz, float dll_bw_narrow_hz, + float early_late_space_chips, float very_early_late_space_chips, float early_late_space_narrow_chips, float very_early_late_space_narrow_chips, - int extend_correlation_symbols, - bool track_pilot); + int extend_correlation_symbols, bool track_pilot, + char system, char signal[3]); /*! - * \brief This class implements a code DLL + carrier PLL VEML (Very Early - * Minus Late) tracking block for Galileo E1 signals + * \brief This class implements a code DLL + carrier PLL tracking block. */ -class galileo_e1_dll_pll_veml_tracking_cc : public gr::block +class dll_pll_veml_tracking : public gr::block { public: - ~galileo_e1_dll_pll_veml_tracking_cc(); + ~dll_pll_veml_tracking(); void set_channel(unsigned int channel); void set_gnss_synchro(Gnss_Synchro *p_gnss_synchro); void start_tracking(); - /*! - * \brief Code DLL + carrier PLL according to the algorithms described in: - * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, - * A Software-Defined GPS and Galileo Receiver. A Single-Frequency Approach, - * Birkhauser, 2007 - */ int general_work(int noutput_items, gr_vector_int &ninput_items, gr_vector_const_void_star &input_items, gr_vector_void_star &output_items); void forecast(int noutput_items, gr_vector_int &ninput_items_required); private: - friend galileo_e1_dll_pll_veml_tracking_cc_sptr - galileo_e1_dll_pll_veml_make_tracking_cc(long if_freq, - long fs_in, unsigned int vector_length, - bool dump, - std::string dump_filename, - float pll_bw_hz, - float dll_bw_hz, - float pll_bw_narrow_hz, - float dll_bw_narrow_hz, - float early_late_space_chips, - float very_early_late_space_chips, - float early_late_space_narrow_chips, + friend dll_pll_veml_tracking_sptr dll_pll_veml_make_tracking(double fs_in, unsigned int vector_length, + bool dump, std::string dump_filename, + float pll_bw_hz, float dll_bw_hz, float pll_bw_narrow_hz, + float dll_bw_narrow_hz, float early_late_space_chips, + float very_early_late_space_chips, float early_late_space_narrow_chips, float very_early_late_space_narrow_chips, - int extend_correlation_symbols, - bool track_pilot); + int extend_correlation_symbols, bool track_pilot, + char system, char signal[3]); - galileo_e1_dll_pll_veml_tracking_cc(long if_freq, - long fs_in, unsigned int vector_length, + dll_pll_veml_tracking(double fs_in, unsigned int vector_length, bool dump, std::string dump_filename, float pll_bw_hz, @@ -116,61 +93,74 @@ private: float early_late_space_narrow_chips, float very_early_late_space_narrow_chips, int extend_correlation_symbols, - bool track_pilot); + bool track_pilot, + char system, char signal[3]); bool cn0_and_tracking_lock_status(); - void do_correlation_step(const gr_complex *input_samples); - void run_dll_pll(bool disable_costas_loop); - void update_local_code(); - void update_local_carrier(); bool acquire_secondary(); - + void do_correlation_step(const gr_complex *input_samples); + void run_dll_pll(); + void update_tracking_vars(); void clear_tracking_vars(); - - void log_data(); + void save_correlation_results(); + void log_data(bool integrating); + int save_matfile(); // tracking configuration vars - unsigned int d_vector_length; bool d_dump; - - Gnss_Synchro *d_acquisition_gnss_synchro; + bool d_veml; + bool d_cloop; + unsigned int d_vector_length; unsigned int d_channel; - long d_if_freq; - long d_fs_in; + double d_fs_in; + Gnss_Synchro *d_acquisition_gnss_synchro; + + //Signal parameters + bool d_secondary; + bool interchange_iq; + double d_signal_carrier_freq; + double d_code_period; + double d_code_chip_rate; + unsigned int d_secondary_code_length; + unsigned int d_code_length_chips; + unsigned int d_code_samples_per_chip; // All signals have 1 sample per chip code except Gal. E1 which has 2 (CBOC disabled) or 12 (CBOC enabled) + int d_symbols_per_bit; + std::string systemName; + std::string signal_type; + std::string *d_secondary_code_string; //tracking state machine int d_state; - + bool d_synchonizing; //Integration period in samples - int d_correlation_length_samples; + int d_correlation_length_ms; int d_n_correlator_taps; - double d_early_late_spc_chips; - double d_very_early_late_spc_chips; - - double d_early_late_spc_narrow_chips; - double d_very_early_late_spc_narrow_chips; + float d_early_late_spc_chips; + float d_very_early_late_spc_chips; + float d_early_late_spc_narrow_chips; + float d_very_early_late_spc_narrow_chips; float *d_tracking_code; float *d_data_code; float *d_local_code_shift_chips; - gr_complex *d_correlator_outs; + float *d_prompt_data_shift; cpu_multicorrelator_real_codes multicorrelator_cpu; - //todo: currently the multicorrelator does not support adding extra correlator - //with different local code, thus we need extra multicorrelator instance. - //Implement this functionality inside multicorrelator class - //as an enhancement to increase the performance - float *d_local_code_data_shift_chips; cpu_multicorrelator_real_codes correlator_data_cpu; //for data channel - + /* TODO: currently the multicorrelator does not support adding extra correlator + with different local code, thus we need extra multicorrelator instance. + Implement this functionality inside multicorrelator class + as an enhancement to increase the performance + */ + gr_complex *d_correlator_outs; gr_complex *d_Very_Early; gr_complex *d_Early; gr_complex *d_Prompt; gr_complex *d_Late; gr_complex *d_Very_Late; + bool d_enable_extended_integration; int d_extend_correlation_symbols; int d_extend_correlation_symbols_count; - bool d_enable_extended_integration; int d_current_symbol; gr_complex d_VE_accu; @@ -178,6 +168,7 @@ private: gr_complex d_P_accu; gr_complex d_L_accu; gr_complex d_VL_accu; + gr_complex d_last_prompt; bool d_track_pilot; gr_complex *d_Prompt_Data; @@ -206,39 +197,34 @@ private: double d_carr_error_filt_hz; double d_code_error_chips; double d_code_error_filt_chips; - double d_K_blk_samples; - double d_code_freq_chips; double d_carrier_doppler_hz; double d_acc_carrier_phase_rad; double d_rem_code_phase_chips; double d_code_phase_samples; - - //PRN period in samples + double T_chip_seconds; + double T_prn_seconds; + double T_prn_samples; + double K_blk_samples; + // PRN period in samples int d_current_prn_length_samples; - - //processing samples counters + // processing samples counters unsigned long int d_sample_counter; unsigned long int d_acq_sample_stamp; // CN0 estimation and lock detector int d_cn0_estimation_counter; - std::deque d_Prompt_buffer_deque; - gr_complex *d_Prompt_buffer; + int d_carrier_lock_fail_counter; double d_carrier_lock_test; double d_CN0_SNV_dB_Hz; double d_carrier_lock_threshold; - int d_carrier_lock_fail_counter; + std::deque d_Prompt_buffer_deque; + gr_complex *d_Prompt_buffer; // file dump std::string d_dump_filename; std::ofstream d_dump_file; - - std::map systemName; - std::string sys; - - int save_matfile(); }; -#endif //GNSS_SDR_GALILEO_E1_DLL_PLL_VEML_TRACKING_CC_H +#endif // GNSS_SDR_DLL_PLL_VEML_TRACKING_H diff --git a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.cc deleted file mode 100644 index 276f56939..000000000 --- a/src/algorithms/tracking/gnuradio_blocks/galileo_e1_dll_pll_veml_tracking_cc.cc +++ /dev/null @@ -1,1233 +0,0 @@ -/*! - * \file galileo_e1_dll_pll_veml_tracking_cc.cc - * \brief Implementation of a code DLL + carrier PLL VEML (Very Early - * Minus Late) tracking block for Galileo E1 signals - * \author Luis Esteve, 2012. luis(at)epsilon-formacion.com - * - * Code DLL + carrier PLL according to the algorithms described in: - * [1] K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, - * A Software-Defined GPS and Galileo Receiver. A Single-Frequency - * Approach, Birkhauser, 2007 - * - * ------------------------------------------------------------------------- - * - * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) - * - * GNSS-SDR is a software defined Global Navigation - * Satellite Systems receiver - * - * This file is part of GNSS-SDR. - * - * GNSS-SDR is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * GNSS-SDR is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with GNSS-SDR. If not, see . - * - * ------------------------------------------------------------------------- - */ - -#include "galileo_e1_dll_pll_veml_tracking_cc.h" -#include "galileo_e1_signal_processing.h" -#include "tracking_discriminators.h" -#include "lock_detectors.h" -#include "Galileo_E1.h" -#include "control_message_factory.h" -#include "gnss_sdr_flags.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using google::LogMessage; - -galileo_e1_dll_pll_veml_tracking_cc_sptr -galileo_e1_dll_pll_veml_make_tracking_cc( - long if_freq, - long fs_in, - unsigned int vector_length, - bool dump, - std::string dump_filename, - float pll_bw_hz, - float dll_bw_hz, - float pll_bw_narrow_hz, - float dll_bw_narrow_hz, - float early_late_space_chips, - float very_early_late_space_chips, - float early_late_space_narrow_chips, - float very_early_late_space_narrow_chips, - int extend_correlation_symbols, - bool track_pilot) -{ - return galileo_e1_dll_pll_veml_tracking_cc_sptr(new galileo_e1_dll_pll_veml_tracking_cc(if_freq, - fs_in, - vector_length, - dump, - dump_filename, - pll_bw_hz, - dll_bw_hz, - pll_bw_narrow_hz, - dll_bw_narrow_hz, - early_late_space_chips, - very_early_late_space_chips, - early_late_space_narrow_chips, - very_early_late_space_narrow_chips, - extend_correlation_symbols, - track_pilot)); -} - - -void galileo_e1_dll_pll_veml_tracking_cc::forecast(int noutput_items, - gr_vector_int &ninput_items_required) -{ - if (noutput_items != 0) - { - ninput_items_required[0] = static_cast(d_vector_length) * 2; //set the required available samples in each call - } -} - - -galileo_e1_dll_pll_veml_tracking_cc::galileo_e1_dll_pll_veml_tracking_cc( - long if_freq, - long fs_in, - unsigned int vector_length, - bool dump, - std::string dump_filename, - float pll_bw_hz, - float dll_bw_hz, - float pll_bw_narrow_hz, - float dll_bw_narrow_hz, - float early_late_space_chips, - float very_early_late_space_chips, - float early_late_space_narrow_chips, - float very_early_late_space_narrow_chips, - int extend_correlation_symbols, - bool track_pilot) : gr::block("galileo_e1_dll_pll_veml_tracking_cc", gr::io_signature::make(1, 1, sizeof(gr_complex)), - gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) -{ - // Telemetry bit synchronization message port input - this->message_port_register_in(pmt::mp("preamble_timestamp_s")); - this->set_relative_rate(1.0 / vector_length); - - this->message_port_register_out(pmt::mp("events")); - - // initialize internal vars - d_dump = dump; - d_if_freq = if_freq; - d_fs_in = fs_in; - d_vector_length = vector_length; - d_dump_filename = dump_filename; - d_code_loop_filter = Tracking_2nd_DLL_filter(Galileo_E1_CODE_PERIOD); - d_carrier_loop_filter = Tracking_2nd_PLL_filter(Galileo_E1_CODE_PERIOD); - - // Initialize tracking ========================================== - - // Set bandwidth of code and carrier loop filters - d_dll_bw_hz = dll_bw_hz; - d_pll_bw_hz = pll_bw_hz; - d_dll_bw_narrow_hz = dll_bw_narrow_hz; - d_pll_bw_narrow_hz = pll_bw_narrow_hz; - - d_code_loop_filter.set_DLL_BW(d_dll_bw_hz); - d_carrier_loop_filter.set_PLL_BW(d_pll_bw_hz); - - // Correlator spacing - d_early_late_spc_chips = early_late_space_chips; // Define early-late offset (in chips) - d_very_early_late_spc_chips = very_early_late_space_chips; // Define very-early-late offset (in chips) - d_early_late_spc_narrow_chips = early_late_space_narrow_chips; // Define narrow early-late offset (in chips) - d_very_early_late_spc_narrow_chips = very_early_late_space_narrow_chips; // Define narrow very-early-late offset (in chips) - - // Initialization of local code replica - // Get space for a vector with the sinboc(1,1) replica sampled 2x/chip - d_tracking_code = static_cast(volk_gnsssdr_malloc((2 * Galileo_E1_B_CODE_LENGTH_CHIPS) * sizeof(float), volk_gnsssdr_get_alignment())); - - // correlator outputs (scalar) - d_n_correlator_taps = 5; // Very-Early, Early, Prompt, Late, Very-Late - d_correlator_outs = static_cast(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment())); - for (int n = 0; n < d_n_correlator_taps; n++) - { - d_correlator_outs[n] = gr_complex(0, 0); - } - // map memory pointers of correlator outputs - d_Very_Early = &d_correlator_outs[0]; - d_Early = &d_correlator_outs[1]; - d_Prompt = &d_correlator_outs[2]; - d_Late = &d_correlator_outs[3]; - d_Very_Late = &d_correlator_outs[4]; - - d_local_code_shift_chips = static_cast(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(float), volk_gnsssdr_get_alignment())); - // Set TAPs delay values [chips] - d_local_code_shift_chips[0] = -d_very_early_late_spc_chips; - d_local_code_shift_chips[1] = -d_early_late_spc_chips; - d_local_code_shift_chips[2] = 0.0; - d_local_code_shift_chips[3] = d_early_late_spc_chips; - d_local_code_shift_chips[4] = d_very_early_late_spc_chips; - - d_correlation_length_samples = d_vector_length; - multicorrelator_cpu.init(2 * d_correlation_length_samples, d_n_correlator_taps); - - d_extend_correlation_symbols = extend_correlation_symbols; - // Enable Data component prompt correlator (slave to Pilot prompt) if tracking uses Pilot signal - d_track_pilot = track_pilot; - if (d_track_pilot) - { - // extended integration control - if (d_extend_correlation_symbols > 1) - { - d_enable_extended_integration = true; - } - else - { - d_enable_extended_integration = false; - } - // Extra correlator for the data component - d_local_code_data_shift_chips = static_cast(volk_gnsssdr_malloc(sizeof(float), volk_gnsssdr_get_alignment())); - d_local_code_data_shift_chips[0] = 0.0; - correlator_data_cpu.init(2 * d_correlation_length_samples, 1); - d_Prompt_Data = static_cast(volk_gnsssdr_malloc(sizeof(gr_complex), volk_gnsssdr_get_alignment())); - d_Prompt_Data[0] = gr_complex(0, 0); - d_data_code = static_cast(volk_gnsssdr_malloc((2 * Galileo_E1_B_CODE_LENGTH_CHIPS) * sizeof(float), volk_gnsssdr_get_alignment())); - } - else - { - // Disable extended integration if data component tracking is selected - d_enable_extended_integration = false; - } - - //--- Initializations ------------------------------ - // Initial code frequency basis of NCO - d_code_freq_chips = static_cast(Galileo_E1_CODE_CHIP_RATE_HZ); - // Residual code phase (in chips) - d_rem_code_phase_samples = 0.0; - // Residual carrier phase - d_rem_carr_phase_rad = 0.0; - - // sample synchronization - d_sample_counter = 0; - //d_sample_counter_seconds = 0; - d_acq_sample_stamp = 0; - - d_current_prn_length_samples = static_cast(d_vector_length); - - // CN0 estimation and lock detector buffers - d_cn0_estimation_counter = 0; - d_Prompt_buffer = new gr_complex[FLAGS_cn0_samples]; - d_carrier_lock_test = 1; - d_CN0_SNV_dB_Hz = 0; - d_carrier_lock_fail_counter = 0; - d_carrier_lock_threshold = FLAGS_carrier_lock_th; - - systemName["E"] = std::string("Galileo"); - - clear_tracking_vars(); - - d_acquisition_gnss_synchro = 0; - d_channel = 0; - d_acq_code_phase_samples = 0.0; - d_acq_carrier_doppler_hz = 0.0; - d_carrier_doppler_hz = 0.0; - d_acc_carrier_phase_rad = 0.0; - - d_extend_correlation_symbols_count = 0; - d_code_phase_step_chips = 0.0; - d_carrier_phase_step_rad = 0.0; - d_rem_code_phase_chips = 0.0; - d_K_blk_samples = 0.0; - d_code_phase_samples = 0.0; - - d_state = 0; // initial state: standby -} - - -void galileo_e1_dll_pll_veml_tracking_cc::start_tracking() -{ - /* - * correct the code phase according to the delay between acq and trk - */ - d_acq_code_phase_samples = d_acquisition_gnss_synchro->Acq_delay_samples; - d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz; - d_acq_sample_stamp = d_acquisition_gnss_synchro->Acq_samplestamp_samples; - - long int acq_trk_diff_samples; - double acq_trk_diff_seconds; - acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); //-d_vector_length; - DLOG(INFO) << "Number of samples between Acquisition and Tracking = " << acq_trk_diff_samples; - acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / static_cast(d_fs_in); - // Doppler effect - // Fd=(C/(C+Vr))*F - double radial_velocity = (Galileo_E1_FREQ_HZ + d_acq_carrier_doppler_hz) / Galileo_E1_FREQ_HZ; - // new chip and prn sequence periods based on acq Doppler - double T_chip_mod_seconds; - double T_prn_mod_seconds; - double T_prn_mod_samples; - d_code_freq_chips = radial_velocity * Galileo_E1_CODE_CHIP_RATE_HZ; - d_code_phase_step_chips = static_cast(d_code_freq_chips) / static_cast(d_fs_in); - T_chip_mod_seconds = 1 / d_code_freq_chips; - T_prn_mod_seconds = T_chip_mod_seconds * Galileo_E1_B_CODE_LENGTH_CHIPS; - T_prn_mod_samples = T_prn_mod_seconds * static_cast(d_fs_in); - - d_current_prn_length_samples = round(T_prn_mod_samples); - - double T_prn_true_seconds = Galileo_E1_B_CODE_LENGTH_CHIPS / Galileo_E1_CODE_CHIP_RATE_HZ; - double T_prn_true_samples = T_prn_true_seconds * static_cast(d_fs_in); - double T_prn_diff_seconds = T_prn_true_seconds - T_prn_mod_seconds; - double N_prn_diff = acq_trk_diff_seconds / T_prn_true_seconds; - double corrected_acq_phase_samples, delay_correction_samples; - corrected_acq_phase_samples = fmod((d_acq_code_phase_samples + T_prn_diff_seconds * N_prn_diff * static_cast(d_fs_in)), T_prn_true_samples); - if (corrected_acq_phase_samples < 0) - { - corrected_acq_phase_samples = T_prn_mod_samples + corrected_acq_phase_samples; - } - delay_correction_samples = d_acq_code_phase_samples - corrected_acq_phase_samples; - - d_acq_code_phase_samples = corrected_acq_phase_samples; - - d_carrier_doppler_hz = d_acq_carrier_doppler_hz; - d_carrier_phase_step_rad = GALILEO_TWO_PI * d_carrier_doppler_hz / static_cast(d_fs_in); - - // DLL/PLL filter initialization - d_carrier_loop_filter.initialize(); // initialize the carrier filter - d_code_loop_filter.initialize(); // initialize the code filter - - if (d_track_pilot) - { - char pilot_signal[3] = "1C"; - galileo_e1_code_gen_float_sampled(d_tracking_code, - pilot_signal, - false, - d_acquisition_gnss_synchro->PRN, - Galileo_E1_CODE_CHIP_RATE_HZ, - 0); - galileo_e1_code_gen_float_sampled(d_data_code, - d_acquisition_gnss_synchro->Signal, - false, - d_acquisition_gnss_synchro->PRN, - Galileo_E1_CODE_CHIP_RATE_HZ, - 0); - d_Prompt_Data[0] = gr_complex(0, 0); // clean data correlator output - correlator_data_cpu.set_local_code_and_taps(static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS), - d_data_code, - d_local_code_shift_chips); - } - else - { - galileo_e1_code_gen_float_sampled(d_tracking_code, - d_acquisition_gnss_synchro->Signal, - false, - d_acquisition_gnss_synchro->PRN, - Galileo_E1_CODE_CHIP_RATE_HZ, - 0); - } - - multicorrelator_cpu.set_local_code_and_taps(static_cast(Galileo_E1_B_CODE_LENGTH_CHIPS), d_tracking_code, d_local_code_shift_chips); - for (int n = 0; n < d_n_correlator_taps; n++) - { - d_correlator_outs[n] = gr_complex(0, 0); - } - - d_carrier_lock_fail_counter = 0; - d_rem_code_phase_samples = 0; - d_rem_carr_phase_rad = 0.0; - d_rem_code_phase_chips = 0.0; - d_acc_carrier_phase_rad = 0.0; - - d_code_phase_samples = d_acq_code_phase_samples; - - std::string sys_ = &d_acquisition_gnss_synchro->System; - sys = sys_.substr(0, 1); - - // DEBUG OUTPUT - std::cout << "Tracking of Galileo E1 signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << std::endl; - LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; - - // enable tracking pull-in - d_state = 1; - - LOG(INFO) << "PULL-IN Doppler [Hz]=" << d_carrier_doppler_hz - << " Code Phase correction [samples]=" << delay_correction_samples - << " PULL-IN Code Phase [samples]=" << d_acq_code_phase_samples; -} - - -galileo_e1_dll_pll_veml_tracking_cc::~galileo_e1_dll_pll_veml_tracking_cc() -{ - if (d_dump_file.is_open()) - { - try - { - d_dump_file.close(); - } - catch (const std::exception &ex) - { - LOG(WARNING) << "Exception in destructor " << ex.what(); - } - } - if (d_dump) - { - if (d_channel == 0) - { - std::cout << "Writing .mat files ..."; - } - galileo_e1_dll_pll_veml_tracking_cc::save_matfile(); - if (d_channel == 0) - { - std::cout << " done." << std::endl; - } - } - try - { - volk_gnsssdr_free(d_local_code_shift_chips); - volk_gnsssdr_free(d_correlator_outs); - volk_gnsssdr_free(d_tracking_code); - if (d_track_pilot) - { - volk_gnsssdr_free(d_Prompt_Data); - volk_gnsssdr_free(d_data_code); - volk_gnsssdr_free(d_local_code_data_shift_chips); - correlator_data_cpu.free(); - } - delete[] d_Prompt_buffer; - multicorrelator_cpu.free(); - } - catch (const std::exception &ex) - { - LOG(WARNING) << "Exception in destructor " << ex.what(); - } -} - - -bool galileo_e1_dll_pll_veml_tracking_cc::acquire_secondary() -{ - //******* preamble correlation ******** - int corr_value = 0; - for (unsigned int i = 0; i < Galileo_E1_C_SECONDARY_CODE_LENGTH; i++) - { - if (d_Prompt_buffer_deque.at(i).real() < 0) // symbols clipping - { - if (Galileo_E1_C_SECONDARY_CODE.at(i) == '0') - { - corr_value++; - } - else - { - corr_value--; - } - } - else - { - if (Galileo_E1_C_SECONDARY_CODE.at(i) == '0') - { - corr_value--; - } - else - { - corr_value++; - } - } - } - - if (abs(corr_value) == Galileo_E1_C_SECONDARY_CODE_LENGTH) - { - return true; - } - else - { - return false; - } -} - - -bool galileo_e1_dll_pll_veml_tracking_cc::cn0_and_tracking_lock_status() -{ - // ####### CN0 ESTIMATION AND LOCK DETECTORS ###### - if (d_cn0_estimation_counter < FLAGS_cn0_samples) - { - // fill buffer with prompt correlator output values - d_Prompt_buffer[d_cn0_estimation_counter] = d_P_accu; - d_cn0_estimation_counter++; - return true; - } - else - { - d_cn0_estimation_counter = 0; - // Code lock indicator - d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer, FLAGS_cn0_samples, d_fs_in, Galileo_E1_B_CODE_LENGTH_CHIPS); - // Carrier lock indicator - d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, FLAGS_cn0_samples); - // Loss of lock detection - if (d_carrier_lock_test < d_carrier_lock_threshold or d_CN0_SNV_dB_Hz < FLAGS_cn0_min) - { - d_carrier_lock_fail_counter++; - } - else - { - if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; - } - if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) - { - std::cout << "Loss of lock in channel " << d_channel << "!" << std::endl; - LOG(INFO) << "Loss of lock in channel " << d_channel << "!"; - this->message_port_pub(pmt::mp("events"), pmt::from_long(3)); // 3 -> loss of lock - d_carrier_lock_fail_counter = 0; - return false; - } - else - { - return true; - } - } -} - - -// correlation requires: -// - updated remnant carrier phase in radians (rem_carr_phase_rad) -// - updated remnant code phase in samples (d_rem_code_phase_samples) -// - d_code_freq_chips -// - d_carrier_doppler_hz -void galileo_e1_dll_pll_veml_tracking_cc::do_correlation_step(const gr_complex *input_samples) -{ - // ################# CARRIER WIPEOFF AND CORRELATORS ############################## - // perform carrier wipe-off and compute Early, Prompt and Late correlation - multicorrelator_cpu.set_input_output_vectors(d_correlator_outs, input_samples); - multicorrelator_cpu.Carrier_wipeoff_multicorrelator_resampler( - d_rem_carr_phase_rad, - d_carrier_phase_step_rad, - d_rem_code_phase_chips, - d_code_phase_step_chips, - d_correlation_length_samples); - - // DATA CORRELATOR (if tracking tracks the pilot signal) - if (d_track_pilot) - { - correlator_data_cpu.set_input_output_vectors(d_Prompt_Data, input_samples); - correlator_data_cpu.Carrier_wipeoff_multicorrelator_resampler( - d_rem_carr_phase_rad, - d_carrier_phase_step_rad, - d_rem_code_phase_chips, - d_code_phase_step_chips, - d_correlation_length_samples); - } -} - - -void galileo_e1_dll_pll_veml_tracking_cc::run_dll_pll(bool disable_costas_loop) -{ - // ################## PLL ########################################################## - // PLL discriminator - if (disable_costas_loop == true) - { - // Secondary code acquired. No symbols transition should be present in the signal - d_carr_error_hz = pll_four_quadrant_atan(d_P_accu) / GALILEO_TWO_PI; - } - else - { - // Costas loop discriminator, insensitive to 180 deg phase transitions - d_carr_error_hz = pll_cloop_two_quadrant_atan(d_P_accu) / GALILEO_TWO_PI; - } - - // Carrier discriminator filter - d_carr_error_filt_hz = d_carrier_loop_filter.get_carrier_nco(d_carr_error_hz); - // New carrier Doppler frequency estimation - d_carrier_doppler_hz = d_acq_carrier_doppler_hz + d_carr_error_filt_hz; - // New code Doppler frequency estimation - d_code_freq_chips = Galileo_E1_CODE_CHIP_RATE_HZ + ((d_carrier_doppler_hz * Galileo_E1_CODE_CHIP_RATE_HZ) / Galileo_E1_FREQ_HZ); - - // ################## DLL ########################################################## - // DLL discriminator - d_code_error_chips = dll_nc_vemlp_normalized(d_VE_accu, d_E_accu, d_L_accu, d_VL_accu); // [chips/Ti] - // Code discriminator filter - d_code_error_filt_chips = d_code_loop_filter.get_code_nco(d_code_error_chips); // [chips/second] -} - - -void galileo_e1_dll_pll_veml_tracking_cc::clear_tracking_vars() -{ - *d_Very_Early = gr_complex(0, 0); - *d_Early = gr_complex(0, 0); - *d_Prompt = gr_complex(0, 0); - *d_Late = gr_complex(0, 0); - *d_Very_Late = gr_complex(0, 0); - d_carr_error_hz = 0.0; - d_carr_error_filt_hz = 0.0; - d_code_error_chips = 0.0; - d_code_error_filt_chips = 0.0; - d_current_symbol = 0; -} - - -void galileo_e1_dll_pll_veml_tracking_cc::log_data() -{ - if (d_dump) - { - // Dump results to file - float prompt_I; - float prompt_Q; - float tmp_VE, tmp_E, tmp_P, tmp_L, tmp_VL; - float tmp_float; - double tmp_double; - - prompt_I = static_cast(d_P_accu.real()); - prompt_Q = static_cast(d_P_accu.imag()); - - tmp_VE = std::abs(d_VE_accu); - tmp_E = std::abs(d_E_accu); - tmp_P = std::abs(d_P_accu); - tmp_L = std::abs(d_L_accu); - tmp_VL = std::abs(d_VL_accu); - - try - { - // Dump correlators output - d_dump_file.write(reinterpret_cast(&tmp_VE), sizeof(float)); - d_dump_file.write(reinterpret_cast(&tmp_E), sizeof(float)); - d_dump_file.write(reinterpret_cast(&tmp_P), sizeof(float)); - d_dump_file.write(reinterpret_cast(&tmp_L), sizeof(float)); - d_dump_file.write(reinterpret_cast(&tmp_VL), sizeof(float)); - // PROMPT I and Q (to analyze navigation symbols) - d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); - d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); - // PRN start sample stamp - d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); - // accumulated carrier phase - tmp_float = d_acc_carrier_phase_rad; - d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); - // carrier and code frequency - tmp_float = d_carrier_doppler_hz; - d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); - tmp_float = d_code_freq_chips; - d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); - // PLL commands - tmp_float = d_carr_error_hz; - d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); - tmp_float = d_carr_error_filt_hz; - d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); - // DLL commands - tmp_float = d_code_error_chips; - d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); - tmp_float = d_code_error_filt_chips; - d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); - // CN0 and carrier lock test - tmp_float = d_CN0_SNV_dB_Hz; - d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); - tmp_float = d_carrier_lock_test; - d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); - // AUX vars (for debug purposes) - tmp_float = d_rem_code_phase_samples; - d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); - tmp_double = static_cast(d_sample_counter + d_current_prn_length_samples); - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - // PRN - unsigned int prn_ = d_acquisition_gnss_synchro->PRN; - d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); - } - catch (const std::ifstream::failure &e) - { - LOG(WARNING) << "Exception writing trk dump file " << e.what(); - } - } -} - - -int galileo_e1_dll_pll_veml_tracking_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), - gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) -{ - // Block input data and block output stream pointers - const gr_complex *in = reinterpret_cast(input_items[0]); - Gnss_Synchro **out = reinterpret_cast(&output_items[0]); - // GNSS_SYNCHRO OBJECT to interchange data between tracking->telemetry_decoder - Gnss_Synchro current_synchro_data = Gnss_Synchro(); - - switch (d_state) - { - case 0: // standby - bypass - { - current_synchro_data.Tracking_sample_counter = d_sample_counter; - break; - } - case 1: // pull-in - { - /* - * Signal alignment (skip samples until the incoming signal is aligned with local replica) - */ - // Fill the acquisition data - current_synchro_data = *d_acquisition_gnss_synchro; - int samples_offset; - double acq_trk_shif_correction_samples; - int acq_to_trk_delay_samples; - acq_to_trk_delay_samples = d_sample_counter - d_acq_sample_stamp; - acq_trk_shif_correction_samples = d_current_prn_length_samples - std::fmod(static_cast(acq_to_trk_delay_samples), static_cast(d_current_prn_length_samples)); - samples_offset = round(d_acq_code_phase_samples + acq_trk_shif_correction_samples); - current_synchro_data.Tracking_sample_counter = d_sample_counter; - current_synchro_data.fs = d_fs_in; - d_sample_counter = d_sample_counter + samples_offset; // count for the processed samples - consume_each(samples_offset); // shift input to perform alignment with local replica - d_state = 2; // next state is the symbol synchronization - return 0; - } - case 2: // wide tracking and symbol synchronization - { - // Fill the acquisition data - current_synchro_data = *d_acquisition_gnss_synchro; - // Current NCO and code generator parameters - d_carrier_phase_step_rad = GALILEO_TWO_PI * d_carrier_doppler_hz / static_cast(d_fs_in); - d_code_phase_step_chips = d_code_freq_chips / static_cast(d_fs_in); - d_rem_code_phase_chips = d_rem_code_phase_samples * d_code_freq_chips / d_fs_in; - // perform a correlation step - do_correlation_step(in); - // save single correlation step variables - d_VE_accu = *d_Very_Early; - d_E_accu = *d_Early; - d_P_accu = *d_Prompt; - d_L_accu = *d_Late; - d_VL_accu = *d_Very_Late; - // check lock status - if (cn0_and_tracking_lock_status() == false) - { - clear_tracking_vars(); - d_state = 0; // loss-of-lock detected - } - else - { - // perform DLL/PLL tracking loop computations - run_dll_pll(false); - - // ################## PLL COMMANDS ################################################# - // carrier phase accumulator for (K) Doppler estimation- - d_acc_carrier_phase_rad -= GALILEO_TWO_PI * d_carrier_doppler_hz * static_cast(d_current_prn_length_samples) / static_cast(d_fs_in); - // remnant carrier phase to prevent overflow in the code NCO - d_rem_carr_phase_rad = d_rem_carr_phase_rad + GALILEO_TWO_PI * d_carrier_doppler_hz * static_cast(d_current_prn_length_samples) / static_cast(d_fs_in); - d_rem_carr_phase_rad = std::fmod(d_rem_carr_phase_rad, GALILEO_TWO_PI); - - // ################## DLL COMMANDS ################################################# - // Code error from DLL - double code_error_filt_secs; - code_error_filt_secs = (Galileo_E1_CODE_PERIOD * d_code_error_filt_chips) / Galileo_E1_CODE_CHIP_RATE_HZ; // [seconds] - - // ################## CARRIER AND CODE NCO BUFFER ALIGNEMENT ####################### - // keep alignment parameters for the next input buffer - // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation - double T_chip_seconds = 1.0 / d_code_freq_chips; - double T_prn_seconds = T_chip_seconds * Galileo_E1_B_CODE_LENGTH_CHIPS; - double T_prn_samples = T_prn_seconds * static_cast(d_fs_in); - double K_blk_samples = T_prn_samples + d_rem_code_phase_samples + code_error_filt_secs * static_cast(d_fs_in); - d_current_prn_length_samples = round(K_blk_samples); // round to a discrete number of samples - - // ########### Output the tracking results to Telemetry block ########## - if (d_track_pilot) - { - current_synchro_data.Prompt_I = static_cast((*d_Prompt_Data).real()); - current_synchro_data.Prompt_Q = static_cast((*d_Prompt_Data).imag()); - } - else - { - current_synchro_data.Prompt_I = static_cast((*d_Prompt).real()); - current_synchro_data.Prompt_Q = static_cast((*d_Prompt).imag()); - } - current_synchro_data.Tracking_sample_counter = d_sample_counter; - current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; - // compute remnant code phase samples AFTER the Tracking timestamp - d_rem_code_phase_samples = K_blk_samples - d_current_prn_length_samples; // rounding error < 1 sample - current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_rad; - current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; - current_synchro_data.CN0_dB_hz = d_CN0_SNV_dB_Hz; - current_synchro_data.Flag_valid_symbol_output = true; - current_synchro_data.correlation_length_ms = Galileo_E1_CODE_PERIOD_MS; - - // enable write dump file this cycle (valid DLL/PLL cycle) - log_data(); - - //std::cout<<(d_Prompt->real()>0); - if (d_enable_extended_integration) - { - // ####### SECONDARY CODE LOCK ##### - d_Prompt_buffer_deque.push_back(*d_Prompt); - if (d_Prompt_buffer_deque.size() == Galileo_E1_C_SECONDARY_CODE_LENGTH) - { - if (acquire_secondary() == true) - { - d_extend_correlation_symbols_count = 0; - // reset extended correlator - d_VE_accu = gr_complex(0, 0); - d_E_accu = gr_complex(0, 0); - d_P_accu = gr_complex(0, 0); - d_L_accu = gr_complex(0, 0); - d_VL_accu = gr_complex(0, 0); - d_Prompt_buffer_deque.clear(); - d_current_symbol = 0; - d_code_loop_filter.set_DLL_BW(d_dll_bw_narrow_hz); - d_carrier_loop_filter.set_PLL_BW(d_pll_bw_narrow_hz); - - // Set TAPs delay values [chips] - d_local_code_shift_chips[0] = -d_very_early_late_spc_narrow_chips; - d_local_code_shift_chips[1] = -d_early_late_spc_narrow_chips; - d_local_code_shift_chips[2] = 0.0; - d_local_code_shift_chips[3] = d_early_late_spc_narrow_chips; - d_local_code_shift_chips[4] = d_very_early_late_spc_narrow_chips; - - LOG(INFO) << "Enabled " << d_extend_correlation_symbols << " [symbols] extended correlator for CH " - << d_channel - << " : Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN); - std::cout << "Enabled " << d_extend_correlation_symbols << " [symbols] extended correlator for CH " - << d_channel - << " : Satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << std::endl; - //std::cout << " pll_bw = " << d_pll_bw_hz << " [Hz], pll_narrow_bw = " << d_pll_bw_narrow_hz << " [Hz]" << std::endl; - //std::cout << " dll_bw = " << d_dll_bw_hz << " [Hz], dll_narrow_bw = " << d_dll_bw_narrow_hz << " [Hz]" << std::endl; - - // UPDATE INTEGRATION TIME - double new_correlation_time_s = static_cast(d_extend_correlation_symbols) * Galileo_E1_CODE_PERIOD; - d_carrier_loop_filter.set_pdi(new_correlation_time_s); - d_code_loop_filter.set_pdi(new_correlation_time_s); - - d_state = 3; // next state is the extended correlator integrator - } - - d_Prompt_buffer_deque.pop_front(); - } - } - } - break; - } - case 3: // coherent integration (correlation time extension) - { - // Fill the acquisition data - current_synchro_data = *d_acquisition_gnss_synchro; - // Current NCO and code generator parameters - d_carrier_phase_step_rad = GALILEO_TWO_PI * d_carrier_doppler_hz / static_cast(d_fs_in); - d_code_phase_step_chips = d_code_freq_chips / static_cast(d_fs_in); - d_rem_code_phase_chips = d_rem_code_phase_samples * d_code_freq_chips / d_fs_in; - // perform a correlation step - do_correlation_step(in); - // correct the integration sign using the current symbol of the secondary code - if (Galileo_E1_C_SECONDARY_CODE.at(d_current_symbol) == '0') - { - d_VE_accu += *d_Very_Early; - d_E_accu += *d_Early; - d_P_accu += *d_Prompt; - d_L_accu += *d_Late; - d_VL_accu += *d_Very_Late; - } - else - { - d_VE_accu -= *d_Very_Early; - d_E_accu -= *d_Early; - d_P_accu -= *d_Prompt; - d_L_accu -= *d_Late; - d_VL_accu -= *d_Very_Late; - } - d_current_symbol++; - // secondary code roll-up - d_current_symbol = d_current_symbol % Galileo_E1_C_SECONDARY_CODE_LENGTH; - - // PLL/DLL not enabled, we are in the middle of a coherent integration - // keep alignment parameters for the next input buffer - // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation - - // ################## PLL ########################################################## - // carrier phase accumulator for (K) Doppler estimation- - d_acc_carrier_phase_rad -= GALILEO_TWO_PI * d_carrier_doppler_hz * static_cast(d_current_prn_length_samples) / static_cast(d_fs_in); - // remnant carrier phase to prevent overflow in the code NCO - d_rem_carr_phase_rad = d_rem_carr_phase_rad + GALILEO_TWO_PI * d_carrier_doppler_hz * static_cast(d_current_prn_length_samples) / static_cast(d_fs_in); - d_rem_carr_phase_rad = std::fmod(d_rem_carr_phase_rad, GALILEO_TWO_PI); - - // ################## CARRIER AND CODE NCO BUFFER ALIGNEMENT ####################### - // keep alignment parameters for the next input buffer - // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation - double T_chip_seconds = 1.0 / d_code_freq_chips; - double T_prn_seconds = T_chip_seconds * Galileo_E1_B_CODE_LENGTH_CHIPS; - double T_prn_samples = T_prn_seconds * static_cast(d_fs_in); - double K_blk_samples = T_prn_samples + d_rem_code_phase_samples; - d_current_prn_length_samples = round(K_blk_samples); //round to a discrete samples - - // ########### Output the tracking results to Telemetry block ########## - current_synchro_data.Prompt_I = static_cast((*d_Prompt_Data).real()); - current_synchro_data.Prompt_Q = static_cast((*d_Prompt_Data).imag()); - current_synchro_data.Tracking_sample_counter = d_sample_counter; - current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; - // compute remnant code phase samples AFTER the Tracking timestamp - d_rem_code_phase_samples = K_blk_samples - d_current_prn_length_samples; //rounding error < 1 sample - current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_rad; - current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; - current_synchro_data.CN0_dB_hz = d_CN0_SNV_dB_Hz; - current_synchro_data.Flag_valid_symbol_output = true; - current_synchro_data.correlation_length_ms = Galileo_E1_CODE_PERIOD_MS; - - d_extend_correlation_symbols_count++; - if (d_extend_correlation_symbols_count >= (d_extend_correlation_symbols - 1)) - { - d_extend_correlation_symbols_count = 0; - d_state = 4; - } - break; - } - case 4: // narrow tracking - { - // Fill the acquisition data - current_synchro_data = *d_acquisition_gnss_synchro; - // perform a correlation step - do_correlation_step(in); - - // correct the integration using the current symbol - if (Galileo_E1_C_SECONDARY_CODE.at(d_current_symbol) == '0') - { - d_VE_accu += *d_Very_Early; - d_E_accu += *d_Early; - d_P_accu += *d_Prompt; - d_L_accu += *d_Late; - d_VL_accu += *d_Very_Late; - } - else - { - d_VE_accu -= *d_Very_Early; - d_E_accu -= *d_Early; - d_P_accu -= *d_Prompt; - d_L_accu -= *d_Late; - d_VL_accu -= *d_Very_Late; - } - d_current_symbol++; - // secondary code roll-up - d_current_symbol = d_current_symbol % Galileo_E1_C_SECONDARY_CODE_LENGTH; - - // check lock status - if (cn0_and_tracking_lock_status() == false) - { - clear_tracking_vars(); - d_state = 0; // loss-of-lock detected - } - else - { - run_dll_pll(true); // Costas loop disabled, use four quadrant atan - - // ################## PLL ########################################################## - // carrier phase accumulator for (K) Doppler estimation- - d_acc_carrier_phase_rad -= GALILEO_TWO_PI * d_carrier_doppler_hz * static_cast(d_current_prn_length_samples) / static_cast(d_fs_in); - // remnant carrier phase to prevent overflow in the code NCO - d_rem_carr_phase_rad = d_rem_carr_phase_rad + GALILEO_TWO_PI * d_carrier_doppler_hz * static_cast(d_current_prn_length_samples) / static_cast(d_fs_in); - d_rem_carr_phase_rad = std::fmod(d_rem_carr_phase_rad, GALILEO_TWO_PI); - - // ################## DLL ########################################################## - // Code phase accumulator - double code_error_filt_secs; - code_error_filt_secs = (Galileo_E1_CODE_PERIOD * d_code_error_filt_chips) / Galileo_E1_CODE_CHIP_RATE_HZ; //[seconds] - - // ################## CARRIER AND CODE NCO BUFFER ALIGNEMENT ####################### - // keep alignment parameters for the next input buffer - // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation - double T_chip_seconds = 1.0 / d_code_freq_chips; - double T_prn_seconds = T_chip_seconds * Galileo_E1_B_CODE_LENGTH_CHIPS; - double T_prn_samples = T_prn_seconds * static_cast(d_fs_in); - double K_blk_samples = T_prn_samples + d_rem_code_phase_samples + code_error_filt_secs * static_cast(d_fs_in); - d_current_prn_length_samples = round(K_blk_samples); // round to a discrete number of samples - - // ########### Output the tracking results to Telemetry block ########## - current_synchro_data.Prompt_I = static_cast((*d_Prompt_Data).real()); - current_synchro_data.Prompt_Q = static_cast((*d_Prompt_Data).imag()); - current_synchro_data.Tracking_sample_counter = d_sample_counter; - current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; - // compute remnant code phase samples AFTER the Tracking timestamp - d_rem_code_phase_samples = K_blk_samples - d_current_prn_length_samples; //rounding error < 1 sample - current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_rad; - current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; - current_synchro_data.CN0_dB_hz = d_CN0_SNV_dB_Hz; - current_synchro_data.Flag_valid_symbol_output = true; - current_synchro_data.correlation_length_ms = Galileo_E1_CODE_PERIOD_MS; - // enable write dump file this cycle (valid DLL/PLL cycle) - log_data(); - // reset extended correlator - d_VE_accu = gr_complex(0, 0); - d_E_accu = gr_complex(0, 0); - d_P_accu = gr_complex(0, 0); - d_L_accu = gr_complex(0, 0); - d_VL_accu = gr_complex(0, 0); - d_state = 3; //new coherent integration (correlation time extension) cycle - } - } - } - - //assign the GNURadio block output data - // current_synchro_data.System = {'E'}; - // std::string str_aux = "1B"; - // const char * str = str_aux.c_str(); // get a C style null terminated string - // std::memcpy(static_cast(current_synchro_data.Signal), str, 3); - - current_synchro_data.fs = d_fs_in; - *out[0] = current_synchro_data; - - consume_each(d_current_prn_length_samples); // this is required for gr_block derivates - d_sample_counter += d_current_prn_length_samples; // count for the processed samples - - if (current_synchro_data.Flag_valid_symbol_output) - { - return 1; - } - else - { - return 0; - } -} - - -int galileo_e1_dll_pll_veml_tracking_cc::save_matfile() -{ - // READ DUMP FILE - std::ifstream::pos_type size; - int number_of_double_vars = 1; - int number_of_float_vars = 17; - int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars + - sizeof(float) * number_of_float_vars + sizeof(unsigned int); - std::ifstream dump_file; - dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - try - { - dump_file.open(d_dump_filename.c_str(), std::ios::binary | std::ios::ate); - } - catch (const std::ifstream::failure &e) - { - std::cerr << "Problem opening dump file:" << e.what() << std::endl; - return 1; - } - // count number of epochs and rewind - long int num_epoch = 0; - if (dump_file.is_open()) - { - size = dump_file.tellg(); - num_epoch = static_cast(size) / static_cast(epoch_size_bytes); - dump_file.seekg(0, std::ios::beg); - } - else - { - return 1; - } - float *abs_VE = new float[num_epoch]; - float *abs_E = new float[num_epoch]; - float *abs_P = new float[num_epoch]; - float *abs_L = new float[num_epoch]; - float *abs_VL = new float[num_epoch]; - float *Prompt_I = new float[num_epoch]; - float *Prompt_Q = new float[num_epoch]; - unsigned long int *PRN_start_sample_count = new unsigned long int[num_epoch]; - float *acc_carrier_phase_rad = new float[num_epoch]; - float *carrier_doppler_hz = new float[num_epoch]; - float *code_freq_chips = new float[num_epoch]; - float *carr_error_hz = new float[num_epoch]; - float *carr_error_filt_hz = new float[num_epoch]; - float *code_error_chips = new float[num_epoch]; - float *code_error_filt_chips = new float[num_epoch]; - float *CN0_SNV_dB_Hz = new float[num_epoch]; - float *carrier_lock_test = new float[num_epoch]; - float *aux1 = new float[num_epoch]; - double *aux2 = new double[num_epoch]; - unsigned int *PRN = new unsigned int[num_epoch]; - - try - { - if (dump_file.is_open()) - { - for (long int i = 0; i < num_epoch; i++) - { - dump_file.read(reinterpret_cast(&abs_VE[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&abs_E[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&abs_P[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&abs_L[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&abs_VL[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&Prompt_I[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&Prompt_Q[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(unsigned long int)); - dump_file.read(reinterpret_cast(&acc_carrier_phase_rad[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&carrier_doppler_hz[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&code_freq_chips[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&carr_error_hz[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&carr_error_filt_hz[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&code_error_chips[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&code_error_filt_chips[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&CN0_SNV_dB_Hz[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&carrier_lock_test[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&aux1[i]), sizeof(float)); - dump_file.read(reinterpret_cast(&aux2[i]), sizeof(double)); - dump_file.read(reinterpret_cast(&PRN[i]), sizeof(unsigned int)); - } - } - dump_file.close(); - } - catch (const std::ifstream::failure &e) - { - std::cerr << "Problem reading dump file:" << e.what() << std::endl; - delete[] abs_VE; - delete[] abs_E; - delete[] abs_P; - delete[] abs_L; - delete[] abs_VL; - delete[] Prompt_I; - delete[] Prompt_Q; - delete[] PRN_start_sample_count; - delete[] acc_carrier_phase_rad; - delete[] carrier_doppler_hz; - delete[] code_freq_chips; - delete[] carr_error_hz; - delete[] carr_error_filt_hz; - delete[] code_error_chips; - delete[] code_error_filt_chips; - delete[] CN0_SNV_dB_Hz; - delete[] carrier_lock_test; - delete[] aux1; - delete[] aux2; - delete[] PRN; - return 1; - } - - // WRITE MAT FILE - mat_t *matfp; - matvar_t *matvar; - std::string filename = d_dump_filename; - filename.erase(filename.length() - 4, 4); - filename.append(".mat"); - matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); - if (reinterpret_cast(matfp) != NULL) - { - size_t dims[2] = {1, static_cast(num_epoch)}; - matvar = Mat_VarCreate("abs_VE", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("abs_P", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_P, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("abs_L", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_L, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("abs_VL", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("Prompt_I", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_I, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("Prompt_Q", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_Q, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("PRN_start_sample_count", MAT_C_UINT64, MAT_T_UINT64, 2, dims, PRN_start_sample_count, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("acc_carrier_phase_rad", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, acc_carrier_phase_rad, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("carrier_doppler_hz", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carrier_doppler_hz, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("code_freq_chips", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, code_freq_chips, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("carr_error_hz", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carr_error_hz, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("carr_error_filt_hz", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carr_error_filt_hz, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("code_error_chips", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, code_error_chips, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("code_error_filt_chips", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, code_error_filt_chips, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("CN0_SNV_dB_Hz", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, CN0_SNV_dB_Hz, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("carrier_lock_test", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, carrier_lock_test, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("aux1", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, aux1, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("aux2", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux2, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - - matvar = Mat_VarCreate("PRN", MAT_C_UINT32, MAT_T_UINT32, 2, dims, PRN, 0); - Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE - Mat_VarFree(matvar); - } - Mat_Close(matfp); - delete[] abs_VE; - delete[] abs_E; - delete[] abs_P; - delete[] abs_L; - delete[] abs_VL; - delete[] Prompt_I; - delete[] Prompt_Q; - delete[] PRN_start_sample_count; - delete[] acc_carrier_phase_rad; - delete[] carrier_doppler_hz; - delete[] code_freq_chips; - delete[] carr_error_hz; - delete[] carr_error_filt_hz; - delete[] code_error_chips; - delete[] code_error_filt_chips; - delete[] CN0_SNV_dB_Hz; - delete[] carrier_lock_test; - delete[] aux1; - delete[] aux2; - delete[] PRN; - return 0; -} - - -void galileo_e1_dll_pll_veml_tracking_cc::set_channel(unsigned int channel) -{ - d_channel = channel; - LOG(INFO) << "Tracking Channel set to " << d_channel; - // ############# ENABLE DATA FILE LOG ################# - if (d_dump == true) - { - if (d_dump_file.is_open() == false) - { - try - { - d_dump_filename.append(boost::lexical_cast(d_channel)); - d_dump_filename.append(".dat"); - d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); - d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); - LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str(); - } - catch (const std::ifstream::failure &e) - { - LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e.what(); - } - } - } -} - - -void galileo_e1_dll_pll_veml_tracking_cc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) -{ - d_acquisition_gnss_synchro = p_gnss_synchro; -} 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 190248626..e028893ca 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 @@ -355,13 +355,13 @@ int Galileo_E1_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attri code_error_filt_secs = (Galileo_E1_CODE_PERIOD * code_error_filt_chips) / Galileo_E1_CODE_CHIP_RATE_HZ; //[seconds] d_acc_code_phase_secs = d_acc_code_phase_secs + code_error_filt_secs; - // ################## CARRIER AND CODE NCO BUFFER ALIGNEMENT ####################### + // ################## CARRIER AND CODE NCO BUFFER ALIGNMENT ####################### // keep alignment parameters for the next input buffer double T_chip_seconds; double T_prn_seconds; double T_prn_samples; double K_blk_samples; - // Compute the next buffer lenght based in the new period of the PRN sequence and the code phase error estimation + // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation T_chip_seconds = 1 / static_cast(d_code_freq_chips); T_prn_seconds = T_chip_seconds * Galileo_E1_B_CODE_LENGTH_CHIPS; T_prn_samples = T_prn_seconds * static_cast(d_fs_in); @@ -443,21 +443,18 @@ int Galileo_E1_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attri // MULTIPLEXED FILE RECORDING - Record results to file float prompt_I; float prompt_Q; - float tmp_VE, tmp_E, tmp_P, tmp_L, tmp_VL; + float tmp_E, tmp_P, tmp_L; + float tmp_VE = 0.0; + float tmp_VL = 0.0; float tmp_float; - tmp_float = 0; - double tmp_double; - prompt_I = (*d_Prompt).real(); - prompt_Q = (*d_Prompt).imag(); - tmp_VE = std::abs(*d_Very_Early); - tmp_E = std::abs(*d_Early); - tmp_P = std::abs(*d_Prompt); - tmp_L = std::abs(*d_Late); - tmp_VL = std::abs(*d_Very_Late); - + prompt_I = d_correlator_outs[1].real(); + prompt_Q = d_correlator_outs[1].imag(); + tmp_E = std::abs(d_correlator_outs[0]); + tmp_P = std::abs(d_correlator_outs[1]); + tmp_L = std::abs(d_correlator_outs[2]); try { - // EPR + // Dump correlators output d_dump_file.write(reinterpret_cast(&tmp_VE), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_E), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_P), sizeof(float)); @@ -469,30 +466,33 @@ int Galileo_E1_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attri // PRN start sample stamp d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); // accumulated carrier phase - d_dump_file.write(reinterpret_cast(&d_acc_carrier_phase_rad), sizeof(float)); - + tmp_float = d_acc_carrier_phase_rad; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // carrier and code frequency - d_dump_file.write(reinterpret_cast(&d_carrier_doppler_hz), sizeof(float)); - d_dump_file.write(reinterpret_cast(&d_code_freq_chips), sizeof(float)); - - //PLL commands + tmp_float = d_carrier_doppler_hz; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); - d_dump_file.write(reinterpret_cast(&carr_error_filt_hz), sizeof(float)); - - //DLL commands + tmp_float = d_code_freq_chips; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // PLL commands + tmp_float = 0.0; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = carr_error_filt_hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // DLL commands + tmp_float = 0.0; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = code_error_filt_chips; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); - d_dump_file.write(reinterpret_cast(&code_error_filt_chips), sizeof(float)); - // CN0 and carrier lock test - d_dump_file.write(reinterpret_cast(&d_CN0_SNV_dB_Hz), sizeof(float)); - d_dump_file.write(reinterpret_cast(&d_carrier_lock_test), sizeof(float)); - - // AUX vars (for debug purposes) - tmp_float = d_rem_code_phase_samples; + tmp_float = d_CN0_SNV_dB_Hz; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); - tmp_double = static_cast(d_sample_counter + d_current_prn_length_samples); + tmp_float = d_carrier_lock_test; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // AUX vars (for debug purposes) + tmp_float = 0.0; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + double tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - // PRN unsigned int prn_ = d_acquisition_gnss_synchro->PRN; d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); 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 7acd09040..df57be51e 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 @@ -38,9 +38,9 @@ #include "glonass_l1_ca_dll_pll_c_aid_tracking_cc.h" #include "glonass_l1_signal_processing.h" +#include "GLONASS_L1_L2_CA.h" #include "tracking_discriminators.h" #include "lock_detectors.h" -#include "GLONASS_L1_CA.h" #include "gnss_sdr_flags.h" #include "control_message_factory.h" #include @@ -56,6 +56,8 @@ #include +#define CN0_ESTIMATION_SAMPLES 10 + using google::LogMessage; glonass_l1_ca_dll_pll_c_aid_tracking_cc_sptr @@ -605,7 +607,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at d_code_phase_step_chips, d_correlation_length_samples); - // ####### coherent intergration extension + // ####### coherent integration extension // keep the last symbols d_E_history.push_back(d_correlator_outs[0]); // save early output d_P_history.push_back(d_correlator_outs[1]); // save prompt output @@ -720,7 +722,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at d_code_error_filt_chips_Ti = d_code_error_filt_chips_s * CURRENT_INTEGRATION_TIME_S; code_error_filt_secs_Ti = d_code_error_filt_chips_Ti / d_code_freq_chips; // [s/Ti] - // ################## CARRIER AND CODE NCO BUFFER ALIGNEMENT ####################### + // ################## CARRIER AND CODE NCO BUFFER ALIGNMENT ####################### // keep alignment parameters for the next input buffer // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation double T_chip_seconds = 1.0 / d_code_freq_chips; @@ -750,7 +752,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at d_rem_code_phase_chips = d_rem_code_phase_samples * (d_code_freq_chips / static_cast(d_fs_in)); // ####### CN0 ESTIMATION AND LOCK DETECTORS ####################################### - if (d_cn0_estimation_counter < FLAGS_cn0_samples) + if (d_cn0_estimation_counter < CN0_ESTIMATION_SAMPLES) { // fill buffer with prompt correlator output values d_Prompt_buffer[d_cn0_estimation_counter] = d_correlator_outs[1]; // prompt @@ -760,9 +762,9 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at { d_cn0_estimation_counter = 0; // Code lock indicator - d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer, FLAGS_cn0_samples, d_fs_in, GLONASS_L1_CA_CODE_LENGTH_CHIPS); + d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES, d_fs_in, GLONASS_L1_CA_CODE_LENGTH_CHIPS); // Carrier lock indicator - d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, FLAGS_cn0_samples); + d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES); // Loss of lock detection if (d_carrier_lock_test < d_carrier_lock_threshold or d_CN0_SNV_dB_Hz < FLAGS_cn0_min) { @@ -829,7 +831,9 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at float prompt_I; float prompt_Q; float tmp_E, tmp_P, tmp_L; - double tmp_double; + float tmp_VE = 0.0; + float tmp_VL = 0.0; + float tmp_float; prompt_I = d_correlator_outs[1].real(); prompt_Q = d_correlator_outs[1].imag(); tmp_E = std::abs(d_correlator_outs[0]); @@ -837,42 +841,45 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __at tmp_L = std::abs(d_correlator_outs[2]); try { - // EPR + // Dump correlators output + d_dump_file.write(reinterpret_cast(&tmp_VE), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_E), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_P), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_L), sizeof(float)); + d_dump_file.write(reinterpret_cast(&tmp_VL), sizeof(float)); // PROMPT I and Q (to analyze navigation symbols) d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); // PRN start sample stamp - //tmp_float=(float)d_sample_counter; d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); // accumulated carrier phase - d_dump_file.write(reinterpret_cast(&d_acc_carrier_phase_cycles), sizeof(double)); - + tmp_float = d_acc_carrier_phase_cycles * GLONASS_TWO_PI; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // carrier and code frequency - double if_freq_carrier = d_carrier_doppler_hz + d_if_freq + (DFRQ1_GLO * static_cast(GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN))); - d_dump_file.write(reinterpret_cast(&if_freq_carrier), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_code_freq_chips), sizeof(double)); - - //PLL commands - d_dump_file.write(reinterpret_cast(&d_carr_phase_error_secs_Ti), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_carrier_doppler_hz), sizeof(double)); - - //DLL commands - d_dump_file.write(reinterpret_cast(&d_code_error_chips_Ti), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_code_error_filt_chips_Ti), sizeof(double)); - + tmp_float = d_carrier_doppler_hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_code_freq_chips; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // PLL commands + tmp_float = 1.0 / (d_carr_phase_error_secs_Ti * CURRENT_INTEGRATION_TIME_S); + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = 1.0 / (d_code_error_filt_chips_Ti * CURRENT_INTEGRATION_TIME_S); + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // DLL commands + tmp_float = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_code_error_filt_chips_Ti; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // CN0 and carrier lock test - d_dump_file.write(reinterpret_cast(&d_CN0_SNV_dB_Hz), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_carrier_lock_test), sizeof(double)); - + tmp_float = d_CN0_SNV_dB_Hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_carrier_lock_test; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // AUX vars (for debug purposes) - tmp_double = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; + tmp_float = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + double tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - // PRN unsigned int prn_ = d_acquisition_gnss_synchro->PRN; d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); 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 49dced3eb..313756921 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 @@ -39,9 +39,9 @@ #include "glonass_l1_ca_dll_pll_c_aid_tracking_sc.h" #include "gnss_synchro.h" #include "glonass_l1_signal_processing.h" +#include "GLONASS_L1_L2_CA.h" #include "tracking_discriminators.h" #include "lock_detectors.h" -#include "GLONASS_L1_CA.h" #include "gnss_sdr_flags.h" #include "control_message_factory.h" #include @@ -57,6 +57,7 @@ #include +#define CN0_ESTIMATION_SAMPLES 10 using google::LogMessage; glonass_l1_ca_dll_pll_c_aid_tracking_sc_sptr @@ -599,7 +600,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at d_code_phase_step_chips, d_correlation_length_samples); - // ####### coherent intergration extension + // ####### coherent integration extension // keep the last symbols d_E_history.push_back(d_correlator_outs_16sc[0]); // save early output d_P_history.push_back(d_correlator_outs_16sc[1]); // save prompt output @@ -712,7 +713,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at d_code_error_filt_chips_Ti = d_code_error_filt_chips_s * CURRENT_INTEGRATION_TIME_S; code_error_filt_secs_Ti = d_code_error_filt_chips_Ti / d_code_freq_chips; // [s/Ti] - // ################## CARRIER AND CODE NCO BUFFER ALIGNEMENT ####################### + // ################## CARRIER AND CODE NCO BUFFER ALIGNMENT ####################### // keep alignment parameters for the next input buffer // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation double T_chip_seconds = 1.0 / d_code_freq_chips; @@ -742,7 +743,7 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at d_rem_code_phase_chips = d_rem_code_phase_samples * (d_code_freq_chips / static_cast(d_fs_in)); // ####### CN0 ESTIMATION AND LOCK DETECTORS ####################################### - if (d_cn0_estimation_counter < FLAGS_cn0_samples) + if (d_cn0_estimation_counter < CN0_ESTIMATION_SAMPLES) { // fill buffer with prompt correlator output values d_Prompt_buffer[d_cn0_estimation_counter] = lv_cmake(static_cast(d_correlator_outs_16sc[1].real()), static_cast(d_correlator_outs_16sc[1].imag())); // prompt @@ -752,9 +753,9 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at { d_cn0_estimation_counter = 0; // Code lock indicator - d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer, FLAGS_cn0_samples, d_fs_in, GLONASS_L1_CA_CODE_LENGTH_CHIPS); + d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES, d_fs_in, GLONASS_L1_CA_CODE_LENGTH_CHIPS); // Carrier lock indicator - d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, FLAGS_cn0_samples); + d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES); // Loss of lock detection if (d_carrier_lock_test < d_carrier_lock_threshold or d_CN0_SNV_dB_Hz < FLAGS_cn0_min) { @@ -821,49 +822,55 @@ int glonass_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __at float prompt_I; float prompt_Q; float tmp_E, tmp_P, tmp_L; - double tmp_double; + float tmp_VE = 0.0; + float tmp_VL = 0.0; + float tmp_float; prompt_I = d_correlator_outs_16sc[1].real(); prompt_Q = d_correlator_outs_16sc[1].imag(); - tmp_E = std::abs(std::complex(d_correlator_outs_16sc[0].real(), d_correlator_outs_16sc[0].imag())); - tmp_P = std::abs(std::complex(d_correlator_outs_16sc[1].real(), d_correlator_outs_16sc[1].imag())); - tmp_L = std::abs(std::complex(d_correlator_outs_16sc[2].real(), d_correlator_outs_16sc[2].imag())); + tmp_E = std::abs(gr_complex(d_correlator_outs_16sc[0].real(), d_correlator_outs_16sc[0].imag())); + tmp_P = std::abs(gr_complex(d_correlator_outs_16sc[1].real(), d_correlator_outs_16sc[1].imag())); + tmp_L = std::abs(gr_complex(d_correlator_outs_16sc[2].real(), d_correlator_outs_16sc[2].imag())); try { - // EPR + // Dump correlators output + d_dump_file.write(reinterpret_cast(&tmp_VE), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_E), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_P), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_L), sizeof(float)); + d_dump_file.write(reinterpret_cast(&tmp_VL), sizeof(float)); // PROMPT I and Q (to analyze navigation symbols) d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); // PRN start sample stamp - //tmp_float=(float)d_sample_counter; d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); // accumulated carrier phase - d_dump_file.write(reinterpret_cast(&d_acc_carrier_phase_cycles), sizeof(double)); - + tmp_float = d_acc_carrier_phase_cycles * GLONASS_TWO_PI; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // carrier and code frequency - d_dump_file.write(reinterpret_cast(&d_carrier_doppler_hz), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_code_freq_chips), sizeof(double)); - - //PLL commands - d_dump_file.write(reinterpret_cast(&d_carr_phase_error_secs_Ti), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_carrier_doppler_hz), sizeof(double)); - - //DLL commands - d_dump_file.write(reinterpret_cast(&d_code_error_chips_Ti), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_code_error_filt_chips_Ti), sizeof(double)); - + tmp_float = d_carrier_doppler_hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_code_freq_chips; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // PLL commands + tmp_float = 1.0 / (d_carr_phase_error_secs_Ti * CURRENT_INTEGRATION_TIME_S); + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = 1.0 / (d_code_error_filt_chips_Ti * CURRENT_INTEGRATION_TIME_S); + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // DLL commands + tmp_float = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_code_error_filt_chips_Ti; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // CN0 and carrier lock test - d_dump_file.write(reinterpret_cast(&d_CN0_SNV_dB_Hz), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_carrier_lock_test), sizeof(double)); - + tmp_float = d_CN0_SNV_dB_Hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_carrier_lock_test; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // AUX vars (for debug purposes) - tmp_double = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; + tmp_float = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + double tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - // PRN unsigned int prn_ = d_acquisition_gnss_synchro->PRN; d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); 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 9d1e23d58..d35b6159c 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 @@ -38,9 +38,9 @@ #include "glonass_l1_ca_dll_pll_tracking_cc.h" #include "glonass_l1_signal_processing.h" +#include "GLONASS_L1_L2_CA.h" #include "tracking_discriminators.h" #include "lock_detectors.h" -#include "GLONASS_L1_CA.h" #include "gnss_sdr_flags.h" #include "control_message_factory.h" #include @@ -54,6 +54,7 @@ #include +#define CN0_ESTIMATION_SAMPLES 10 using google::LogMessage; glonass_l1_ca_dll_pll_tracking_cc_sptr @@ -584,7 +585,7 @@ int Glonass_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut double code_error_filt_secs = (T_prn_seconds * code_error_filt_chips * T_chip_seconds); //[seconds] //double code_error_filt_secs = (GPS_L1_CA_CODE_PERIOD * code_error_filt_chips) / GLONASS_L1_CA_CODE_RATE_HZ; // [seconds] - // ################## CARRIER AND CODE NCO BUFFER ALIGNEMENT ####################### + // ################## CARRIER AND CODE NCO BUFFER ALIGNMENT ####################### // keep alignment parameters for the next input buffer // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation //double T_chip_seconds = 1.0 / static_cast(d_code_freq_chips); @@ -611,7 +612,7 @@ int Glonass_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut d_rem_code_phase_chips = d_code_freq_chips * (d_rem_code_phase_samples / static_cast(d_fs_in)); // ####### CN0 ESTIMATION AND LOCK DETECTORS ###### - if (d_cn0_estimation_counter < FLAGS_cn0_samples) + if (d_cn0_estimation_counter < CN0_ESTIMATION_SAMPLES) { // fill buffer with prompt correlator output values d_Prompt_buffer[d_cn0_estimation_counter] = d_correlator_outs[1]; //prompt @@ -621,9 +622,9 @@ int Glonass_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut { d_cn0_estimation_counter = 0; // Code lock indicator - d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer, FLAGS_cn0_samples, d_fs_in, GLONASS_L1_CA_CODE_LENGTH_CHIPS); + d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES, d_fs_in, GLONASS_L1_CA_CODE_LENGTH_CHIPS); // Carrier lock indicator - d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, FLAGS_cn0_samples); + d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES); // Loss of lock detection if (d_carrier_lock_test < d_carrier_lock_threshold or d_CN0_SNV_dB_Hz < FLAGS_cn0_min) { @@ -674,8 +675,9 @@ int Glonass_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut float prompt_I; float prompt_Q; float tmp_E, tmp_P, tmp_L; - double tmp_double; - unsigned long int tmp_long; + float tmp_float; + float tmp_VE = 0.0; + float tmp_VL = 0.0; prompt_I = d_correlator_outs[1].real(); prompt_Q = d_correlator_outs[1].imag(); tmp_E = std::abs(d_correlator_outs[0]); @@ -683,41 +685,45 @@ int Glonass_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribut tmp_L = std::abs(d_correlator_outs[2]); try { - // EPR + // Dump correlators output + d_dump_file.write(reinterpret_cast(&tmp_VE), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_E), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_P), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_L), sizeof(float)); + d_dump_file.write(reinterpret_cast(&tmp_VL), sizeof(float)); // PROMPT I and Q (to analyze navigation symbols) d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); // PRN start sample stamp - tmp_long = d_sample_counter + d_current_prn_length_samples; - d_dump_file.write(reinterpret_cast(&tmp_long), sizeof(unsigned long int)); + d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); // accumulated carrier phase - d_dump_file.write(reinterpret_cast(&d_acc_carrier_phase_rad), sizeof(double)); - + tmp_float = d_acc_carrier_phase_rad; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // carrier and code frequency - d_dump_file.write(reinterpret_cast(&d_carrier_frequency_hz), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_code_freq_chips), sizeof(double)); - + tmp_float = d_carrier_doppler_hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_code_freq_chips; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // PLL commands - d_dump_file.write(reinterpret_cast(&carr_error_hz), sizeof(double)); - d_dump_file.write(reinterpret_cast(&carr_error_filt_hz), sizeof(double)); - + tmp_float = carr_error_hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = carr_error_filt_hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // DLL commands - d_dump_file.write(reinterpret_cast(&code_error_chips), sizeof(double)); - d_dump_file.write(reinterpret_cast(&code_error_filt_chips), sizeof(double)); - + tmp_float = code_error_chips; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = code_error_filt_chips; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // CN0 and carrier lock test - d_dump_file.write(reinterpret_cast(&d_CN0_SNV_dB_Hz), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_carrier_lock_test), sizeof(double)); - + tmp_float = d_CN0_SNV_dB_Hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_carrier_lock_test; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // AUX vars (for debug purposes) - tmp_double = d_rem_code_phase_samples; + tmp_float = d_rem_code_phase_samples; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + double tmp_double = static_cast(d_sample_counter + d_current_prn_length_samples); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = static_cast(d_sample_counter); - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - // PRN unsigned int prn_ = d_acquisition_gnss_synchro->PRN; d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); 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 new file mode 100644 index 000000000..53f8f704b --- /dev/null +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc @@ -0,0 +1,926 @@ +/*! + * \file glonass_l2_ca_dll_pll_c_aid_tracking_cc.h + * \brief Implementation of a code DLL + carrier PLL tracking block + * \author Damian Miralles, 2018. dmiralles2009(at)gmail.com + * + * + * Code DLL + carrier PLL according to the algorithms described in: + * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, + * A Software-Defined GPS and Galileo Receiver. A Single-Frequency + * Approach, Birkha user, 2007 + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "glonass_l2_ca_dll_pll_c_aid_tracking_cc.h" +#include "glonass_l2_signal_processing.h" +#include "tracking_discriminators.h" +#include "lock_detectors.h" +#include "GLONASS_L1_L2_CA.h" +#include "gnss_sdr_flags.h" +#include "control_message_factory.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define CN0_ESTIMATION_SAMPLES 10 + +using google::LogMessage; + +glonass_l2_ca_dll_pll_c_aid_tracking_cc_sptr +glonass_l2_ca_dll_pll_c_aid_make_tracking_cc( + long if_freq, + long fs_in, + unsigned int vector_length, + bool dump, + std::string dump_filename, + float pll_bw_hz, + float dll_bw_hz, + float pll_bw_narrow_hz, + float dll_bw_narrow_hz, + int extend_correlation_ms, + 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(if_freq, + 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)); +} + + +void glonass_l2_ca_dll_pll_c_aid_tracking_cc::forecast(int noutput_items, + gr_vector_int &ninput_items_required) +{ + if (noutput_items != 0) + { + ninput_items_required[0] = static_cast(d_vector_length) * 2; //set the required available samples in each call + } +} + + +void glonass_l2_ca_dll_pll_c_aid_tracking_cc::msg_handler_preamble_index(pmt::pmt_t msg) +{ + //pmt::print(msg); + 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(msg); + d_enable_extended_integration = true; + d_preamble_synchronized = false; + } +} + + +glonass_l2_ca_dll_pll_c_aid_tracking_cc::glonass_l2_ca_dll_pll_c_aid_tracking_cc( + long if_freq, + long fs_in, + unsigned int vector_length, + bool dump, + std::string dump_filename, + float pll_bw_hz, + float dll_bw_hz, + float pll_bw_narrow_hz, + float dll_bw_narrow_hz, + int extend_correlation_ms, + float early_late_space_chips) : gr::block("glonass_l2_ca_dll_pll_c_aid_tracking_cc", gr::io_signature::make(1, 1, sizeof(gr_complex)), + gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) +{ + // Telemetry bit synchronization message port input + this->message_port_register_in(pmt::mp("preamble_timestamp_s")); + + this->set_msg_handler(pmt::mp("preamble_timestamp_s"), + boost::bind(&glonass_l2_ca_dll_pll_c_aid_tracking_cc::msg_handler_preamble_index, this, _1)); + + this->message_port_register_out(pmt::mp("events")); + // initialize internal vars + d_dump = dump; + d_if_freq = if_freq; + d_fs_in = fs_in; + d_vector_length = vector_length; + d_dump_filename = dump_filename; + d_correlation_length_samples = static_cast(d_vector_length); + + // Initialize tracking ========================================== + d_pll_bw_hz = pll_bw_hz; + d_dll_bw_hz = dll_bw_hz; + d_pll_bw_narrow_hz = pll_bw_narrow_hz; + d_dll_bw_narrow_hz = dll_bw_narrow_hz; + d_extend_correlation_ms = extend_correlation_ms; + d_code_loop_filter.set_DLL_BW(d_dll_bw_hz); + d_carrier_loop_filter.set_params(10.0, d_pll_bw_hz, 2); + + // --- DLL variables -------------------------------------------------------- + d_early_late_spc_chips = early_late_space_chips; // Define early-late offset (in chips) + + // Initialization of local code replica + // Get space for a vector with the C/A code replica sampled 1x/chip + d_ca_code = static_cast(volk_gnsssdr_malloc(static_cast(GLONASS_L2_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + + // correlator outputs (scalar) + d_n_correlator_taps = 3; // Early, Prompt, and Late + d_correlator_outs = static_cast(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + for (int n = 0; n < d_n_correlator_taps; n++) + { + d_correlator_outs[n] = gr_complex(0, 0); + } + d_local_code_shift_chips = static_cast(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(float), volk_gnsssdr_get_alignment())); + // Set TAPs delay values [chips] + d_local_code_shift_chips[0] = -d_early_late_spc_chips; + d_local_code_shift_chips[1] = 0.0; + d_local_code_shift_chips[2] = d_early_late_spc_chips; + + multicorrelator_cpu.init(2 * d_correlation_length_samples, d_n_correlator_taps); + + //--- Perform initializations ------------------------------ + // define initial code frequency basis of NCO + d_code_freq_chips = GLONASS_L2_CA_CODE_RATE_HZ; + // define residual code phase (in chips) + d_rem_code_phase_samples = 0.0; + // define residual carrier phase + d_rem_carrier_phase_rad = 0.0; + + // sample synchronization + d_sample_counter = 0; //(from trk to tlm) + d_acq_sample_stamp = 0; + d_enable_tracking = false; + d_pull_in = false; + + // CN0 estimation and lock detector buffers + d_cn0_estimation_counter = 0; + d_Prompt_buffer = new gr_complex[FLAGS_cn0_samples]; + d_carrier_lock_test = 1; + d_CN0_SNV_dB_Hz = 0; + d_carrier_lock_fail_counter = 0; + d_carrier_lock_threshold = FLAGS_carrier_lock_th; + + systemName["R"] = std::string("Glonass"); + + set_relative_rate(1.0 / static_cast(d_vector_length)); + + d_acquisition_gnss_synchro = 0; + d_channel = 0; + d_acq_code_phase_samples = 0.0; + d_acq_carrier_doppler_hz = 0.0; + d_carrier_doppler_hz = 0.0; + d_code_error_filt_chips_Ti = 0.0; + d_acc_carrier_phase_cycles = 0.0; + d_code_phase_samples = 0.0; + + d_pll_to_dll_assist_secs_Ti = 0.0; + d_rem_code_phase_chips = 0.0; + d_code_phase_step_chips = 0.0; + d_carrier_phase_step_rad = 0.0; + d_enable_extended_integration = false; + d_preamble_synchronized = false; + d_rem_code_phase_integer_samples = 0; + d_code_error_chips_Ti = 0.0; + d_code_error_filt_chips_s = 0.0; + d_carr_phase_error_secs_Ti = 0.0; + d_preamble_timestamp_s = 0.0; + + d_carrier_frequency_hz = 0.0; + d_carrier_doppler_old_hz = 0.0; + + d_glonass_freq_ch = 0; + + //set_min_output_buffer((long int)300); +} + + +void glonass_l2_ca_dll_pll_c_aid_tracking_cc::start_tracking() +{ + /* + * correct the code phase according to the delay between acq and trk + */ + d_acq_code_phase_samples = d_acquisition_gnss_synchro->Acq_delay_samples; + d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz; + d_acq_sample_stamp = d_acquisition_gnss_synchro->Acq_samplestamp_samples; + + long int acq_trk_diff_samples; + double acq_trk_diff_seconds; + acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); //-d_vector_length; + DLOG(INFO) << "Number of samples between Acquisition and Tracking =" << acq_trk_diff_samples; + acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / static_cast(d_fs_in); + // Doppler effect + // Fd=(C/(C+Vr))*F + d_glonass_freq_ch = GLONASS_L2_CA_FREQ_HZ + (DFRQ2_GLO * static_cast(GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN))); + double radial_velocity = (d_glonass_freq_ch + d_acq_carrier_doppler_hz) / d_glonass_freq_ch; + // new chip and prn sequence periods based on acq Doppler + double T_chip_mod_seconds; + double T_prn_mod_seconds; + double T_prn_mod_samples; + d_code_freq_chips = radial_velocity * GLONASS_L2_CA_CODE_RATE_HZ; + d_code_phase_step_chips = static_cast(d_code_freq_chips) / static_cast(d_fs_in); + T_chip_mod_seconds = 1.0 / d_code_freq_chips; + T_prn_mod_seconds = T_chip_mod_seconds * GLONASS_L2_CA_CODE_LENGTH_CHIPS; + T_prn_mod_samples = T_prn_mod_seconds * static_cast(d_fs_in); + + d_correlation_length_samples = round(T_prn_mod_samples); + + double T_prn_true_seconds = GLONASS_L2_CA_CODE_LENGTH_CHIPS / GLONASS_L2_CA_CODE_RATE_HZ; + double T_prn_true_samples = T_prn_true_seconds * static_cast(d_fs_in); + double T_prn_diff_seconds = T_prn_true_seconds - T_prn_mod_seconds; + double N_prn_diff = acq_trk_diff_seconds / T_prn_true_seconds; + double corrected_acq_phase_samples, delay_correction_samples; + corrected_acq_phase_samples = fmod((d_acq_code_phase_samples + T_prn_diff_seconds * N_prn_diff * static_cast(d_fs_in)), T_prn_true_samples); + if (corrected_acq_phase_samples < 0) + { + corrected_acq_phase_samples = T_prn_mod_samples + corrected_acq_phase_samples; + } + delay_correction_samples = d_acq_code_phase_samples - corrected_acq_phase_samples; + + d_acq_code_phase_samples = corrected_acq_phase_samples; + + // d_carrier_doppler_hz = d_acq_carrier_doppler_hz + d_if_freq + (DFRQ2_GLO * GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN)); + // d_carrier_doppler_hz = d_acq_carrier_doppler_hz; + // d_carrier_phase_step_rad = GLONASS_TWO_PI * d_carrier_doppler_hz / static_cast(d_fs_in); + d_carrier_frequency_hz = d_acq_carrier_doppler_hz + d_if_freq + (DFRQ2_GLO * static_cast(GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN))); + d_carrier_doppler_hz = d_acq_carrier_doppler_hz; + d_carrier_phase_step_rad = GLONASS_TWO_PI * d_carrier_frequency_hz / static_cast(d_fs_in); + + + // DLL/PLL filter initialization + d_carrier_loop_filter.initialize(d_carrier_frequency_hz); // The carrier loop filter implements the Doppler accumulator + d_code_loop_filter.initialize(); // initialize the code filter + + // generate local reference ALWAYS starting at chip 1 (1 sample per chip) + glonass_l2_ca_code_gen_complex(d_ca_code, 0); + + multicorrelator_cpu.set_local_code_and_taps(static_cast(GLONASS_L2_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips); + for (int n = 0; n < d_n_correlator_taps; n++) + { + d_correlator_outs[n] = gr_complex(0, 0); + } + + d_carrier_lock_fail_counter = 0; + d_rem_code_phase_samples = 0.0; + d_rem_carrier_phase_rad = 0.0; + d_rem_code_phase_chips = 0.0; + d_acc_carrier_phase_cycles = 0.0; + d_pll_to_dll_assist_secs_Ti = 0.0; + d_code_phase_samples = d_acq_code_phase_samples; + + std::string sys_ = &d_acquisition_gnss_synchro->System; + sys = sys_.substr(0, 1); + + // DEBUG OUTPUT + std::cout << "Tracking start on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << std::endl; + LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; + + // enable tracking + d_pull_in = true; + d_enable_tracking = true; + d_enable_extended_integration = false; + d_preamble_synchronized = false; + LOG(INFO) << "PULL-IN Doppler [Hz]=" << d_carrier_doppler_hz + << " Code Phase correction [samples]=" << delay_correction_samples + << " PULL-IN Code Phase [samples]=" << d_acq_code_phase_samples; +} + + +glonass_l2_ca_dll_pll_c_aid_tracking_cc::~glonass_l2_ca_dll_pll_c_aid_tracking_cc() +{ + if (d_dump_file.is_open()) + { + try + { + d_dump_file.close(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Exception in destructor " << ex.what(); + } + } + + if (d_dump) + { + if (d_channel == 0) + { + std::cout << "Writing .mat files ..."; + } + glonass_l2_ca_dll_pll_c_aid_tracking_cc::save_matfile(); + if (d_channel == 0) + { + std::cout << " done." << std::endl; + } + } + + try + { + volk_gnsssdr_free(d_local_code_shift_chips); + volk_gnsssdr_free(d_correlator_outs); + volk_gnsssdr_free(d_ca_code); + delete[] d_Prompt_buffer; + multicorrelator_cpu.free(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Exception in destructor " << ex.what(); + } +} + + +int glonass_l2_ca_dll_pll_c_aid_tracking_cc::save_matfile() +{ + // READ DUMP FILE + std::ifstream::pos_type size; + int number_of_double_vars = 11; + int number_of_float_vars = 5; + int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars + + sizeof(float) * number_of_float_vars + sizeof(unsigned int); + std::ifstream dump_file; + dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + try + { + dump_file.open(d_dump_filename.c_str(), std::ios::binary | std::ios::ate); + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem opening dump file:" << e.what() << std::endl; + return 1; + } + // count number of epochs and rewind + long int num_epoch = 0; + if (dump_file.is_open()) + { + size = dump_file.tellg(); + num_epoch = static_cast(size) / static_cast(epoch_size_bytes); + dump_file.seekg(0, std::ios::beg); + } + else + { + return 1; + } + float *abs_E = new float[num_epoch]; + float *abs_P = new float[num_epoch]; + float *abs_L = new float[num_epoch]; + float *Prompt_I = new float[num_epoch]; + float *Prompt_Q = new float[num_epoch]; + unsigned long int *PRN_start_sample_count = new unsigned long int[num_epoch]; + double *acc_carrier_phase_rad = new double[num_epoch]; + double *carrier_doppler_hz = new double[num_epoch]; + double *code_freq_chips = new double[num_epoch]; + double *carr_error_hz = new double[num_epoch]; + double *carr_error_filt_hz = new double[num_epoch]; + double *code_error_chips = new double[num_epoch]; + double *code_error_filt_chips = new double[num_epoch]; + double *CN0_SNV_dB_Hz = new double[num_epoch]; + double *carrier_lock_test = new double[num_epoch]; + double *aux1 = new double[num_epoch]; + double *aux2 = new double[num_epoch]; + unsigned int *PRN = new unsigned int[num_epoch]; + + try + { + if (dump_file.is_open()) + { + for (long int i = 0; i < num_epoch; i++) + { + dump_file.read(reinterpret_cast(&abs_E[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_P[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_L[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&Prompt_I[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&Prompt_Q[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(unsigned long int)); + dump_file.read(reinterpret_cast(&acc_carrier_phase_rad[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carrier_doppler_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_freq_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carr_error_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carr_error_filt_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_error_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_error_filt_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&CN0_SNV_dB_Hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carrier_lock_test[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&aux1[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&aux2[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&PRN[i]), sizeof(unsigned int)); + } + } + dump_file.close(); + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem reading dump file:" << e.what() << std::endl; + delete[] abs_E; + delete[] abs_P; + delete[] abs_L; + delete[] Prompt_I; + delete[] Prompt_Q; + delete[] PRN_start_sample_count; + delete[] acc_carrier_phase_rad; + delete[] carrier_doppler_hz; + delete[] code_freq_chips; + delete[] carr_error_hz; + delete[] carr_error_filt_hz; + delete[] code_error_chips; + delete[] code_error_filt_chips; + delete[] CN0_SNV_dB_Hz; + delete[] carrier_lock_test; + delete[] aux1; + delete[] aux2; + delete[] PRN; + return 1; + } + + // WRITE MAT FILE + mat_t *matfp; + matvar_t *matvar; + std::string filename = d_dump_filename; + filename.erase(filename.length() - 4, 4); + filename.append(".mat"); + matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); + if (reinterpret_cast(matfp) != NULL) + { + size_t dims[2] = {1, static_cast(num_epoch)}; + matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_P", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_P, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_L", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_L, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Prompt_I", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_I, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Prompt_Q", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_Q, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN_start_sample_count", MAT_C_UINT64, MAT_T_UINT64, 2, dims, PRN_start_sample_count, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("acc_carrier_phase_rad", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, acc_carrier_phase_rad, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carrier_doppler_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_doppler_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_freq_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_freq_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carr_error_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carr_error_filt_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_filt_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_error_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_error_filt_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_filt_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("CN0_SNV_dB_Hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, CN0_SNV_dB_Hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carrier_lock_test", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_lock_test, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("aux1", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux1, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("aux2", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux2, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN", MAT_C_UINT32, MAT_T_UINT32, 2, dims, PRN, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + } + Mat_Close(matfp); + delete[] abs_E; + delete[] abs_P; + delete[] abs_L; + delete[] Prompt_I; + delete[] Prompt_Q; + delete[] PRN_start_sample_count; + delete[] acc_carrier_phase_rad; + delete[] carrier_doppler_hz; + delete[] code_freq_chips; + delete[] carr_error_hz; + delete[] carr_error_filt_hz; + delete[] code_error_chips; + delete[] code_error_filt_chips; + delete[] CN0_SNV_dB_Hz; + delete[] carrier_lock_test; + delete[] aux1; + delete[] aux2; + delete[] PRN; + return 0; +} + + +int glonass_l2_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), + gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) +{ + // Block input data and block output stream pointers + const gr_complex *in = reinterpret_cast(input_items[0]); // PRN start block alignment + Gnss_Synchro **out = reinterpret_cast(&output_items[0]); + + // GNSS_SYNCHRO OBJECT to interchange data between tracking->telemetry_decoder + Gnss_Synchro current_synchro_data = Gnss_Synchro(); + + // process vars + double code_error_filt_secs_Ti = 0.0; + double CURRENT_INTEGRATION_TIME_S = 0.0; + double CORRECTED_INTEGRATION_TIME_S = 0.0; + + if (d_enable_tracking == true) + { + // Fill the acquisition data + current_synchro_data = *d_acquisition_gnss_synchro; + // Receiver signal alignment + if (d_pull_in == true) + { + int samples_offset; + double acq_trk_shif_correction_samples; + int acq_to_trk_delay_samples; + acq_to_trk_delay_samples = d_sample_counter - d_acq_sample_stamp; + acq_trk_shif_correction_samples = d_correlation_length_samples - fmod(static_cast(acq_to_trk_delay_samples), static_cast(d_correlation_length_samples)); + samples_offset = round(d_acq_code_phase_samples + acq_trk_shif_correction_samples); + current_synchro_data.Tracking_sample_counter = d_sample_counter + samples_offset; + d_sample_counter += samples_offset; // count for the processed samples + d_pull_in = false; + d_acc_carrier_phase_cycles -= d_carrier_phase_step_rad * samples_offset / GLONASS_TWO_PI; + current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_cycles * GLONASS_TWO_PI; + current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; + current_synchro_data.fs = d_fs_in; + *out[0] = current_synchro_data; + consume_each(samples_offset); // shift input to perform alignment with local replica + return 1; + } + + // ################# CARRIER WIPEOFF AND CORRELATORS ############################## + // perform carrier wipe-off and compute Early, Prompt and Late correlation + multicorrelator_cpu.set_input_output_vectors(d_correlator_outs, in); + multicorrelator_cpu.Carrier_wipeoff_multicorrelator_resampler(d_rem_carrier_phase_rad, + d_carrier_phase_step_rad, + d_rem_code_phase_chips, + d_code_phase_step_chips, + d_correlation_length_samples); + + // ####### coherent integration extension + // keep the last symbols + d_E_history.push_back(d_correlator_outs[0]); // save early output + d_P_history.push_back(d_correlator_outs[1]); // save prompt output + d_L_history.push_back(d_correlator_outs[2]); // save late output + + if (static_cast(d_P_history.size()) > d_extend_correlation_ms) + { + d_E_history.pop_front(); + d_P_history.pop_front(); + d_L_history.pop_front(); + } + + bool enable_dll_pll; + if (d_enable_extended_integration == true) + { + long int symbol_diff = round(1000.0 * ((static_cast(d_sample_counter) + d_rem_code_phase_samples) / static_cast(d_fs_in) - d_preamble_timestamp_s)); + if (symbol_diff > 0 and symbol_diff % d_extend_correlation_ms == 0) + { + // compute coherent integration and enable tracking loop + // perform coherent integration using correlator output history + // std::cout<<"##### RESET COHERENT INTEGRATION ####"<PRN) + << " pll_bw = " << d_pll_bw_hz << " [Hz], pll_narrow_bw = " << d_pll_bw_narrow_hz << " [Hz]" << std::endl + << " dll_bw = " << d_dll_bw_hz << " [Hz], dll_narrow_bw = " << d_dll_bw_narrow_hz << " [Hz]" << std::endl; + } + // UPDATE INTEGRATION TIME + CURRENT_INTEGRATION_TIME_S = static_cast(d_extend_correlation_ms) * GLONASS_L2_CA_CODE_PERIOD; + d_code_loop_filter.set_pdi(CURRENT_INTEGRATION_TIME_S); + enable_dll_pll = true; + } + else + { + if (d_preamble_synchronized == true) + { + // continue extended coherent correlation + // Compute the next buffer length based on the period of the PRN sequence and the code phase error estimation + double T_chip_seconds = 1.0 / d_code_freq_chips; + double T_prn_seconds = T_chip_seconds * GLONASS_L2_CA_CODE_LENGTH_CHIPS; + double T_prn_samples = T_prn_seconds * static_cast(d_fs_in); + int K_prn_samples = round(T_prn_samples); + double K_T_prn_error_samples = K_prn_samples - T_prn_samples; + + d_rem_code_phase_samples = d_rem_code_phase_samples - K_T_prn_error_samples; + d_rem_code_phase_integer_samples = round(d_rem_code_phase_samples); // round to a discrete number of samples + d_correlation_length_samples = K_prn_samples + d_rem_code_phase_integer_samples; + d_rem_code_phase_samples = d_rem_code_phase_samples - d_rem_code_phase_integer_samples; + // code phase step (Code resampler phase increment per sample) [chips/sample] + d_code_phase_step_chips = d_code_freq_chips / static_cast(d_fs_in); + // remnant code phase [chips] + d_rem_code_phase_chips = d_rem_code_phase_samples * (d_code_freq_chips / static_cast(d_fs_in)); + d_rem_carrier_phase_rad = fmod(d_rem_carrier_phase_rad + d_carrier_phase_step_rad * static_cast(d_correlation_length_samples), GLONASS_TWO_PI); + + // UPDATE ACCUMULATED CARRIER PHASE + CORRECTED_INTEGRATION_TIME_S = (static_cast(d_correlation_length_samples) / static_cast(d_fs_in)); + d_acc_carrier_phase_cycles -= d_carrier_phase_step_rad * d_correlation_length_samples / GLONASS_TWO_PI; + + // disable tracking loop and inform telemetry decoder + enable_dll_pll = false; + } + else + { + // perform basic (1ms) correlation + // UPDATE INTEGRATION TIME + CURRENT_INTEGRATION_TIME_S = static_cast(d_correlation_length_samples) / static_cast(d_fs_in); + d_code_loop_filter.set_pdi(CURRENT_INTEGRATION_TIME_S); + enable_dll_pll = true; + } + } + } + else + { + // UPDATE INTEGRATION TIME + CURRENT_INTEGRATION_TIME_S = static_cast(d_correlation_length_samples) / static_cast(d_fs_in); + enable_dll_pll = true; + } + + if (enable_dll_pll == true) + { + // ################## PLL ########################################################## + // Update PLL discriminator [rads/Ti -> Secs/Ti] + d_carr_phase_error_secs_Ti = pll_cloop_two_quadrant_atan(d_correlator_outs[1]) / GLONASS_TWO_PI; // prompt output + d_carrier_doppler_old_hz = d_carrier_doppler_hz; + // Carrier discriminator filter + // NOTICE: The carrier loop filter includes the Carrier Doppler accumulator, as described in Kaplan + // Input [s/Ti] -> output [Hz] + d_carrier_doppler_hz = d_carrier_loop_filter.get_carrier_error(0.0, d_carr_phase_error_secs_Ti, CURRENT_INTEGRATION_TIME_S); + // PLL to DLL assistance [Secs/Ti] + d_pll_to_dll_assist_secs_Ti = (d_carrier_doppler_hz * CURRENT_INTEGRATION_TIME_S) / d_glonass_freq_ch; + // code Doppler frequency update + d_code_freq_chips = GLONASS_L2_CA_CODE_RATE_HZ + (((d_carrier_doppler_hz - d_carrier_doppler_old_hz) * GLONASS_L2_CA_CODE_RATE_HZ) / d_glonass_freq_ch); + + // ################## DLL ########################################################## + // DLL discriminator + d_code_error_chips_Ti = dll_nc_e_minus_l_normalized(d_correlator_outs[0], d_correlator_outs[2]); // [chips/Ti] //early and late + // Code discriminator filter + d_code_error_filt_chips_s = d_code_loop_filter.get_code_nco(d_code_error_chips_Ti); // input [chips/Ti] -> output [chips/second] + d_code_error_filt_chips_Ti = d_code_error_filt_chips_s * CURRENT_INTEGRATION_TIME_S; + code_error_filt_secs_Ti = d_code_error_filt_chips_Ti / d_code_freq_chips; // [s/Ti] + + // ################## CARRIER AND CODE NCO BUFFER ALIGNMENT ####################### + // keep alignment parameters for the next input buffer + // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation + double T_chip_seconds = 1.0 / d_code_freq_chips; + double T_prn_seconds = T_chip_seconds * GLONASS_L2_CA_CODE_LENGTH_CHIPS; + double T_prn_samples = T_prn_seconds * static_cast(d_fs_in); + double K_prn_samples = round(T_prn_samples); + double K_T_prn_error_samples = K_prn_samples - T_prn_samples; + + d_rem_code_phase_samples = d_rem_code_phase_samples - K_T_prn_error_samples + code_error_filt_secs_Ti * static_cast(d_fs_in); //(code_error_filt_secs_Ti + d_pll_to_dll_assist_secs_Ti) * static_cast(d_fs_in); + d_rem_code_phase_integer_samples = round(d_rem_code_phase_samples); // round to a discrete number of samples + d_correlation_length_samples = K_prn_samples + d_rem_code_phase_integer_samples; + d_rem_code_phase_samples = d_rem_code_phase_samples - d_rem_code_phase_integer_samples; + + //################### PLL COMMANDS ################################################# + //carrier phase step (NCO phase increment per sample) [rads/sample] + d_carrier_phase_step_rad = GLONASS_TWO_PI * d_carrier_doppler_hz / static_cast(d_fs_in); + d_acc_carrier_phase_cycles -= d_carrier_phase_step_rad * d_correlation_length_samples / GLONASS_TWO_PI; + // UPDATE ACCUMULATED CARRIER PHASE + CORRECTED_INTEGRATION_TIME_S = (static_cast(d_correlation_length_samples) / static_cast(d_fs_in)); + //remnant carrier phase [rad] + d_rem_carrier_phase_rad = fmod(d_rem_carrier_phase_rad + GLONASS_TWO_PI * d_carrier_doppler_hz * CORRECTED_INTEGRATION_TIME_S, GLONASS_TWO_PI); + + //################### DLL COMMANDS ################################################# + //code phase step (Code resampler phase increment per sample) [chips/sample] + d_code_phase_step_chips = d_code_freq_chips / static_cast(d_fs_in); + //remnant code phase [chips] + d_rem_code_phase_chips = d_rem_code_phase_samples * (d_code_freq_chips / static_cast(d_fs_in)); + + // ####### CN0 ESTIMATION AND LOCK DETECTORS ####################################### + if (d_cn0_estimation_counter < CN0_ESTIMATION_SAMPLES) + { + // fill buffer with prompt correlator output values + d_Prompt_buffer[d_cn0_estimation_counter] = d_correlator_outs[1]; // prompt + d_cn0_estimation_counter++; + } + else + { + d_cn0_estimation_counter = 0; + // Code lock indicator + d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES, d_fs_in, GLONASS_L2_CA_CODE_LENGTH_CHIPS); + // Carrier lock indicator + d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES); + // Loss of lock detection + if (d_carrier_lock_test < d_carrier_lock_threshold or d_CN0_SNV_dB_Hz < FLAGS_cn0_min) + { + d_carrier_lock_fail_counter++; + } + else + { + if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; + } + if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) + { + std::cout << "Loss of lock in channel " << d_channel << "!" << std::endl; + LOG(INFO) << "Loss of lock in channel " << d_channel << "!"; + this->message_port_pub(pmt::mp("events"), pmt::from_long(3)); //3 -> loss of lock + d_carrier_lock_fail_counter = 0; + d_enable_tracking = false; // TODO: check if disabling tracking is consistent with the channel state machine + } + } + // ########### Output the tracking data to navigation and PVT ########## + current_synchro_data.Prompt_I = static_cast((d_correlator_outs[1]).real()); + current_synchro_data.Prompt_Q = static_cast((d_correlator_outs[1]).imag()); + current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; + current_synchro_data.Carrier_phase_rads = GLONASS_TWO_PI * d_acc_carrier_phase_cycles; + current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; + current_synchro_data.CN0_dB_hz = d_CN0_SNV_dB_Hz; + current_synchro_data.Flag_valid_symbol_output = true; + if (d_preamble_synchronized == true) + { + current_synchro_data.correlation_length_ms = d_extend_correlation_ms; + } + else + { + current_synchro_data.correlation_length_ms = 1; + } + } + else + { + current_synchro_data.Prompt_I = static_cast((d_correlator_outs[1]).real()); + current_synchro_data.Prompt_Q = static_cast((d_correlator_outs[1]).imag()); + current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; + current_synchro_data.Carrier_phase_rads = GLONASS_TWO_PI * d_acc_carrier_phase_cycles; + current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; // todo: project the carrier doppler + current_synchro_data.CN0_dB_hz = d_CN0_SNV_dB_Hz; + } + } + else + { + for (int n = 0; n < d_n_correlator_taps; n++) + { + d_correlator_outs[n] = gr_complex(0, 0); + } + + current_synchro_data.System = {'R'}; + current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + } + //assign the GNURadio block output data + current_synchro_data.fs = d_fs_in; + *out[0] = current_synchro_data; + if (d_dump) + { + // MULTIPLEXED FILE RECORDING - Record results to file + float prompt_I; + float prompt_Q; + float tmp_E, tmp_P, tmp_L; + float tmp_VE = 0.0; + float tmp_VL = 0.0; + float tmp_float; + prompt_I = d_correlator_outs[1].real(); + prompt_Q = d_correlator_outs[1].imag(); + tmp_E = std::abs(d_correlator_outs[0]); + tmp_P = std::abs(d_correlator_outs[1]); + tmp_L = std::abs(d_correlator_outs[2]); + try + { + // Dump correlators output + d_dump_file.write(reinterpret_cast(&tmp_VE), sizeof(float)); + d_dump_file.write(reinterpret_cast(&tmp_E), sizeof(float)); + d_dump_file.write(reinterpret_cast(&tmp_P), sizeof(float)); + d_dump_file.write(reinterpret_cast(&tmp_L), sizeof(float)); + d_dump_file.write(reinterpret_cast(&tmp_VL), sizeof(float)); + // PROMPT I and Q (to analyze navigation symbols) + d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); + d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); + // PRN start sample stamp + d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); + // accumulated carrier phase + tmp_float = d_acc_carrier_phase_cycles * GLONASS_TWO_PI; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // carrier and code frequency + tmp_float = d_carrier_doppler_hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_code_freq_chips; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // PLL commands + tmp_float = 1.0 / (d_carr_phase_error_secs_Ti * CURRENT_INTEGRATION_TIME_S); + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = 1.0 / (d_code_error_filt_chips_Ti * CURRENT_INTEGRATION_TIME_S); + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // DLL commands + tmp_float = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_code_error_filt_chips_Ti; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // CN0 and carrier lock test + tmp_float = d_CN0_SNV_dB_Hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_carrier_lock_test; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // AUX vars (for debug purposes) + tmp_float = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + double tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + // PRN + unsigned int prn_ = d_acquisition_gnss_synchro->PRN; + d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); + } + catch (const std::ifstream::failure *e) + { + LOG(WARNING) << "Exception writing trk dump file " << e->what(); + } + } + + consume_each(d_correlation_length_samples); // this is necessary in gr::block derivates + d_sample_counter += d_correlation_length_samples; //count for the processed samples + + return 1; //output tracking result ALWAYS even in the case of d_enable_tracking==false +} + + +void glonass_l2_ca_dll_pll_c_aid_tracking_cc::set_channel(unsigned int channel) +{ + d_channel = channel; + LOG(INFO) << "Tracking Channel set to " << d_channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump == true) + { + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str() << std::endl; + } + catch (const std::ifstream::failure *e) + { + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl; + } + } + } +} + + +void glonass_l2_ca_dll_pll_c_aid_tracking_cc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) +{ + d_acquisition_gnss_synchro = p_gnss_synchro; +} diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.h b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.h new file mode 100644 index 000000000..df42cb442 --- /dev/null +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.h @@ -0,0 +1,203 @@ +/*! + * \file glonass_l2_ca_dll_pll_c_aid_tracking_cc.h + * \brief Implementation of a code DLL + carrier PLL tracking block + * \author Damian Miralles, 2018. dmiralles2009(at)gmail.com + * + * + * Code DLL + carrier PLL according to the algorithms described in: + * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, + * A Software-Defined GPS and Galileo Receiver. A Single-Frequency + * Approach, Birkha user, 2007 + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_GLONASS_L2_CA_DLL_PLL_C_AID_TRACKING_CC_H +#define GNSS_SDR_GLONASS_L2_CA_DLL_PLL_C_AID_TRACKING_CC_H + +#include "gnss_synchro.h" +#include "tracking_2nd_DLL_filter.h" +#include "tracking_FLL_PLL_filter.h" +//#include "tracking_loop_filter.h" +#include "cpu_multicorrelator.h" +#include +#include +#include +#include +#include +#include + +class glonass_l2_ca_dll_pll_c_aid_tracking_cc; + +typedef boost::shared_ptr + glonass_l2_ca_dll_pll_c_aid_tracking_cc_sptr; + +glonass_l2_ca_dll_pll_c_aid_tracking_cc_sptr +glonass_l2_ca_dll_pll_c_aid_make_tracking_cc(long if_freq, + long fs_in, unsigned int vector_length, + bool dump, + std::string dump_filename, + float pll_bw_hz, + float dll_bw_hz, + float pll_bw_narrow_hz, + float dll_bw_narrow_hz, + int extend_correlation_ms, + float early_late_space_chips); + + +/*! + * \brief This class implements a DLL + PLL tracking loop block + */ +class glonass_l2_ca_dll_pll_c_aid_tracking_cc : public gr::block +{ +public: + ~glonass_l2_ca_dll_pll_c_aid_tracking_cc(); + + void set_channel(unsigned int channel); + void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro); + void start_tracking(); + + int general_work(int noutput_items, gr_vector_int& ninput_items, + gr_vector_const_void_star& input_items, gr_vector_void_star& output_items); + + void forecast(int noutput_items, gr_vector_int& ninput_items_required); + +private: + friend glonass_l2_ca_dll_pll_c_aid_tracking_cc_sptr + glonass_l2_ca_dll_pll_c_aid_make_tracking_cc(long if_freq, + long fs_in, unsigned int vector_length, + bool dump, + std::string dump_filename, + float pll_bw_hz, + float dll_bw_hz, + float pll_bw_narrow_hz, + float dll_bw_narrow_hz, + int extend_correlation_ms, + float early_late_space_chips); + + glonass_l2_ca_dll_pll_c_aid_tracking_cc(long if_freq, + long fs_in, unsigned int vector_length, + bool dump, + std::string dump_filename, + float pll_bw_hz, + float dll_bw_hz, + float pll_bw_narrow_hz, + float dll_bw_narrow_hz, + int extend_correlation_ms, + float early_late_space_chips); + + // tracking configuration vars + unsigned int d_vector_length; + bool d_dump; + + Gnss_Synchro* d_acquisition_gnss_synchro; + unsigned int d_channel; + + long d_if_freq; + long d_fs_in; + double d_glonass_freq_ch; + + double d_early_late_spc_chips; + int d_n_correlator_taps; + + gr_complex* d_ca_code; + float* d_local_code_shift_chips; + gr_complex* d_correlator_outs; + cpu_multicorrelator multicorrelator_cpu; + + // remaining code phase and carrier phase between tracking loops + double d_rem_code_phase_samples; + double d_rem_code_phase_chips; + double d_rem_carrier_phase_rad; + int d_rem_code_phase_integer_samples; + + // PLL and DLL filter library + //Tracking_2nd_DLL_filter d_code_loop_filter; + Tracking_2nd_DLL_filter d_code_loop_filter; + Tracking_FLL_PLL_filter d_carrier_loop_filter; + + // acquisition + double d_acq_code_phase_samples; + double d_acq_carrier_doppler_hz; + + // tracking vars + float d_dll_bw_hz; + float d_pll_bw_hz; + float d_dll_bw_narrow_hz; + float d_pll_bw_narrow_hz; + double d_code_freq_chips; + double d_code_phase_step_chips; + double d_carrier_doppler_hz; + double d_carrier_frequency_hz; + double d_carrier_doppler_old_hz; + double d_carrier_phase_step_rad; + double d_acc_carrier_phase_cycles; + double d_code_phase_samples; + double d_pll_to_dll_assist_secs_Ti; + double d_code_error_chips_Ti; + double d_code_error_filt_chips_s; + double d_code_error_filt_chips_Ti; + double d_carr_phase_error_secs_Ti; + + // symbol history to detect bit transition + std::deque d_E_history; + std::deque d_P_history; + std::deque d_L_history; + double d_preamble_timestamp_s; + int d_extend_correlation_ms; + bool d_enable_extended_integration; + bool d_preamble_synchronized; + void msg_handler_preamble_index(pmt::pmt_t msg); + + //Integration period in samples + int d_correlation_length_samples; + + //processing samples counters + unsigned long int d_sample_counter; + unsigned long int d_acq_sample_stamp; + + // CN0 estimation and lock detector + int d_cn0_estimation_counter; + gr_complex* d_Prompt_buffer; + double d_carrier_lock_test; + double d_CN0_SNV_dB_Hz; + double d_carrier_lock_threshold; + int d_carrier_lock_fail_counter; + + // control vars + bool d_enable_tracking; + bool d_pull_in; + + // file dump + std::string d_dump_filename; + std::ofstream d_dump_file; + + std::map systemName; + std::string sys; + + int save_matfile(); +}; + +#endif //GNSS_SDR_GLONASS_L1_CA_DLL_PLL_C_AID_TRACKING_CC_H 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 new file mode 100644 index 000000000..decc5d5ca --- /dev/null +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc @@ -0,0 +1,918 @@ +/*! + * \file glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc + * \brief Implementation of a code DLL + carrier PLL tracking block + * \author Damian Miralles, 2018. dmiralles2009(at)gmail.com + * + * + * Code DLL + carrier PLL according to the algorithms described in: + * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, + * A Software-Defined GPS and Galileo Receiver. A Single-Frequency + * Approach, Birkha user, 2007 + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#include "glonass_l2_ca_dll_pll_c_aid_tracking_sc.h" +#include "gnss_synchro.h" +#include "glonass_l2_signal_processing.h" +#include "tracking_discriminators.h" +#include "lock_detectors.h" +#include "GLONASS_L1_L2_CA.h" +#include "gnss_sdr_flags.h" +#include "control_message_factory.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define CN0_ESTIMATION_SAMPLES 10 + +using google::LogMessage; + +glonass_l2_ca_dll_pll_c_aid_tracking_sc_sptr +glonass_l2_ca_dll_pll_c_aid_make_tracking_sc( + long if_freq, + long fs_in, + unsigned int vector_length, + bool dump, + std::string dump_filename, + float pll_bw_hz, + float dll_bw_hz, + float pll_bw_narrow_hz, + float dll_bw_narrow_hz, + int extend_correlation_ms, + float early_late_space_chips) +{ + return glonass_l2_ca_dll_pll_c_aid_tracking_sc_sptr(new glonass_l2_ca_dll_pll_c_aid_tracking_sc(if_freq, + 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)); +} + + +void glonass_l2_ca_dll_pll_c_aid_tracking_sc::forecast(int noutput_items, + gr_vector_int &ninput_items_required) +{ + if (noutput_items != 0) + { + ninput_items_required[0] = static_cast(d_vector_length) * 2; //set the required available samples in each call + } +} + + +void glonass_l2_ca_dll_pll_c_aid_tracking_sc::msg_handler_preamble_index(pmt::pmt_t msg) +{ + //pmt::print(msg); + 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(msg); + d_enable_extended_integration = true; + d_preamble_synchronized = false; + } +} + +glonass_l2_ca_dll_pll_c_aid_tracking_sc::glonass_l2_ca_dll_pll_c_aid_tracking_sc( + long if_freq, + long fs_in, + unsigned int vector_length, + bool dump, + std::string dump_filename, + float pll_bw_hz, + float dll_bw_hz, + float pll_bw_narrow_hz, + float dll_bw_narrow_hz, + int extend_correlation_ms, + float early_late_space_chips) : gr::block("glonass_l1_ca_dll_pll_c_aid_tracking_sc", gr::io_signature::make(1, 1, sizeof(lv_16sc_t)), + gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) +{ + // Telemetry bit synchronization message port input + this->message_port_register_in(pmt::mp("preamble_timestamp_s")); + this->set_msg_handler(pmt::mp("preamble_timestamp_s"), + boost::bind(&glonass_l2_ca_dll_pll_c_aid_tracking_sc::msg_handler_preamble_index, this, _1)); + this->message_port_register_out(pmt::mp("events")); + // initialize internal vars + d_dump = dump; + d_if_freq = if_freq; + d_fs_in = fs_in; + d_vector_length = vector_length; + d_dump_filename = dump_filename; + d_correlation_length_samples = static_cast(d_vector_length); + + // Initialize tracking ========================================== + d_pll_bw_hz = pll_bw_hz; + d_dll_bw_hz = dll_bw_hz; + d_pll_bw_narrow_hz = pll_bw_narrow_hz; + d_dll_bw_narrow_hz = dll_bw_narrow_hz; + d_code_loop_filter.set_DLL_BW(d_dll_bw_hz); + d_carrier_loop_filter.set_params(10.0, d_pll_bw_hz, 2); + d_extend_correlation_ms = extend_correlation_ms; + + // --- DLL variables -------------------------------------------------------- + d_early_late_spc_chips = early_late_space_chips; // Define early-late offset (in chips) + + // Initialization of local code replica + // Get space for a vector with the C/A code replica sampled 1x/chip + d_ca_code = static_cast(volk_gnsssdr_malloc(static_cast(GLONASS_L2_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment())); + d_ca_code_16sc = static_cast(volk_gnsssdr_malloc(static_cast(GLONASS_L2_CA_CODE_LENGTH_CHIPS) * sizeof(lv_16sc_t), volk_gnsssdr_get_alignment())); + + // correlator outputs (scalar) + d_n_correlator_taps = 3; // Early, Prompt, and Late + + d_correlator_outs_16sc = static_cast(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(lv_16sc_t), volk_gnsssdr_get_alignment())); + for (int n = 0; n < d_n_correlator_taps; n++) + { + d_correlator_outs_16sc[n] = lv_cmake(0, 0); + } + + d_local_code_shift_chips = static_cast(volk_gnsssdr_malloc(d_n_correlator_taps * sizeof(float), volk_gnsssdr_get_alignment())); + // Set TAPs delay values [chips] + d_local_code_shift_chips[0] = -d_early_late_spc_chips; + d_local_code_shift_chips[1] = 0.0; + d_local_code_shift_chips[2] = d_early_late_spc_chips; + + multicorrelator_cpu_16sc.init(2 * d_correlation_length_samples, d_n_correlator_taps); + + //--- Perform initializations ------------------------------ + // define initial code frequency basis of NCO + d_code_freq_chips = GLONASS_L2_CA_CODE_RATE_HZ; + // define residual code phase (in chips) + d_rem_code_phase_samples = 0.0; + // define residual carrier phase + d_rem_carrier_phase_rad = 0.0; + + // sample synchronization + d_sample_counter = 0; //(from trk to tlm) + d_acq_sample_stamp = 0; + d_enable_tracking = false; + d_pull_in = false; + + // CN0 estimation and lock detector buffers + d_cn0_estimation_counter = 0; + d_Prompt_buffer = new gr_complex[FLAGS_cn0_samples]; + d_carrier_lock_test = 1; + d_CN0_SNV_dB_Hz = 0; + d_carrier_lock_fail_counter = 0; + d_carrier_lock_threshold = FLAGS_carrier_lock_th; + + systemName["R"] = std::string("Glonass"); + + set_relative_rate(1.0 / static_cast(d_vector_length)); + + d_acquisition_gnss_synchro = 0; + d_channel = 0; + d_acq_code_phase_samples = 0.0; + d_acq_carrier_doppler_hz = 0.0; + d_carrier_doppler_hz = 0.0; + d_acc_carrier_phase_cycles = 0.0; + d_code_phase_samples = 0.0; + d_enable_extended_integration = false; + d_preamble_synchronized = false; + d_rem_code_phase_integer_samples = 0; + d_code_error_chips_Ti = 0.0; + d_pll_to_dll_assist_secs_Ti = 0.0; + d_rem_code_phase_chips = 0.0; + d_code_phase_step_chips = 0.0; + d_carrier_phase_step_rad = 0.0; + d_code_error_filt_chips_s = 0.0; + d_code_error_filt_chips_Ti = 0.0; + d_preamble_timestamp_s = 0.0; + d_carr_phase_error_secs_Ti = 0.0; + + d_carrier_frequency_hz = 0.0; + d_carrier_doppler_old_hz = 0.0; + + d_glonass_freq_ch = 0; + //set_min_output_buffer((long int)300); +} + + +void glonass_l2_ca_dll_pll_c_aid_tracking_sc::start_tracking() +{ + /* + * correct the code phase according to the delay between acq and trk + */ + d_acq_code_phase_samples = d_acquisition_gnss_synchro->Acq_delay_samples; + d_acq_carrier_doppler_hz = d_acquisition_gnss_synchro->Acq_doppler_hz; + d_acq_sample_stamp = d_acquisition_gnss_synchro->Acq_samplestamp_samples; + + long int acq_trk_diff_samples; + double acq_trk_diff_seconds; + acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); //-d_vector_length; + DLOG(INFO) << "Number of samples between Acquisition and Tracking =" << acq_trk_diff_samples; + acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / static_cast(d_fs_in); + // Doppler effect + // Fd=(C/(C+Vr))*F + d_glonass_freq_ch = GLONASS_L2_CA_FREQ_HZ + (GLONASS_L2_CA_FREQ_HZ * GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN)); + double radial_velocity = (d_glonass_freq_ch + d_acq_carrier_doppler_hz) / d_glonass_freq_ch; + // new chip and prn sequence periods based on acq Doppler + double T_chip_mod_seconds; + double T_prn_mod_seconds; + double T_prn_mod_samples; + d_code_freq_chips = radial_velocity * GLONASS_L2_CA_CODE_RATE_HZ; + d_code_phase_step_chips = static_cast(d_code_freq_chips) / static_cast(d_fs_in); + T_chip_mod_seconds = 1.0 / d_code_freq_chips; + T_prn_mod_seconds = T_chip_mod_seconds * GLONASS_L2_CA_CODE_LENGTH_CHIPS; + T_prn_mod_samples = T_prn_mod_seconds * static_cast(d_fs_in); + + d_correlation_length_samples = round(T_prn_mod_samples); + + double T_prn_true_seconds = GLONASS_L2_CA_CODE_LENGTH_CHIPS / GLONASS_L2_CA_CODE_RATE_HZ; + double T_prn_true_samples = T_prn_true_seconds * static_cast(d_fs_in); + double T_prn_diff_seconds = T_prn_true_seconds - T_prn_mod_seconds; + double N_prn_diff = acq_trk_diff_seconds / T_prn_true_seconds; + double corrected_acq_phase_samples, delay_correction_samples; + corrected_acq_phase_samples = fmod((d_acq_code_phase_samples + T_prn_diff_seconds * N_prn_diff * static_cast(d_fs_in)), T_prn_true_samples); + if (corrected_acq_phase_samples < 0) + { + corrected_acq_phase_samples = T_prn_mod_samples + corrected_acq_phase_samples; + } + delay_correction_samples = d_acq_code_phase_samples - corrected_acq_phase_samples; + + d_acq_code_phase_samples = corrected_acq_phase_samples; + + d_carrier_frequency_hz = d_acq_carrier_doppler_hz + d_if_freq + (DFRQ2_GLO * static_cast(GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN))); + ; + d_carrier_doppler_hz = d_acq_carrier_doppler_hz; + + d_carrier_phase_step_rad = GLONASS_TWO_PI * d_carrier_frequency_hz / static_cast(d_fs_in); + + // DLL/PLL filter initialization + d_carrier_loop_filter.initialize(d_carrier_frequency_hz); // The carrier loop filter implements the Doppler accumulator + d_code_loop_filter.initialize(); // initialize the code filter + + // generate local reference ALWAYS starting at chip 1 (1 sample per chip) + glonass_l2_ca_code_gen_complex(d_ca_code, 0); + volk_gnsssdr_32fc_convert_16ic(d_ca_code_16sc, d_ca_code, static_cast(GLONASS_L2_CA_CODE_LENGTH_CHIPS)); + + multicorrelator_cpu_16sc.set_local_code_and_taps(static_cast(GLONASS_L2_CA_CODE_LENGTH_CHIPS), d_ca_code_16sc, d_local_code_shift_chips); + for (int n = 0; n < d_n_correlator_taps; n++) + { + d_correlator_outs_16sc[n] = lv_16sc_t(0, 0); + } + + d_carrier_lock_fail_counter = 0; + d_rem_code_phase_samples = 0.0; + d_rem_carrier_phase_rad = 0.0; + d_rem_code_phase_chips = 0.0; + d_acc_carrier_phase_cycles = 0.0; + d_pll_to_dll_assist_secs_Ti = 0.0; + d_code_phase_samples = d_acq_code_phase_samples; + + std::string sys_ = &d_acquisition_gnss_synchro->System; + sys = sys_.substr(0, 1); + + // DEBUG OUTPUT + std::cout << "Tracking start on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << std::endl; + LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; + + // enable tracking + d_pull_in = true; + d_enable_tracking = true; + d_enable_extended_integration = true; + d_preamble_synchronized = true; + + LOG(INFO) << "PULL-IN Doppler [Hz]=" << d_carrier_doppler_hz + << " Code Phase correction [samples]=" << delay_correction_samples + << " PULL-IN Code Phase [samples]=" << d_acq_code_phase_samples; +} + + +int glonass_l2_ca_dll_pll_c_aid_tracking_sc::save_matfile() +{ + // READ DUMP FILE + std::ifstream::pos_type size; + int number_of_double_vars = 11; + int number_of_float_vars = 5; + int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars + + sizeof(float) * number_of_float_vars + sizeof(unsigned int); + std::ifstream dump_file; + dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + try + { + dump_file.open(d_dump_filename.c_str(), std::ios::binary | std::ios::ate); + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem opening dump file:" << e.what() << std::endl; + return 1; + } + // count number of epochs and rewind + long int num_epoch = 0; + if (dump_file.is_open()) + { + size = dump_file.tellg(); + num_epoch = static_cast(size) / static_cast(epoch_size_bytes); + dump_file.seekg(0, std::ios::beg); + } + else + { + return 1; + } + float *abs_E = new float[num_epoch]; + float *abs_P = new float[num_epoch]; + float *abs_L = new float[num_epoch]; + float *Prompt_I = new float[num_epoch]; + float *Prompt_Q = new float[num_epoch]; + unsigned long int *PRN_start_sample_count = new unsigned long int[num_epoch]; + double *acc_carrier_phase_rad = new double[num_epoch]; + double *carrier_doppler_hz = new double[num_epoch]; + double *code_freq_chips = new double[num_epoch]; + double *carr_error_hz = new double[num_epoch]; + double *carr_error_filt_hz = new double[num_epoch]; + double *code_error_chips = new double[num_epoch]; + double *code_error_filt_chips = new double[num_epoch]; + double *CN0_SNV_dB_Hz = new double[num_epoch]; + double *carrier_lock_test = new double[num_epoch]; + double *aux1 = new double[num_epoch]; + double *aux2 = new double[num_epoch]; + unsigned int *PRN = new unsigned int[num_epoch]; + + try + { + if (dump_file.is_open()) + { + for (long int i = 0; i < num_epoch; i++) + { + dump_file.read(reinterpret_cast(&abs_E[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_P[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&abs_L[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&Prompt_I[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&Prompt_Q[i]), sizeof(float)); + dump_file.read(reinterpret_cast(&PRN_start_sample_count[i]), sizeof(unsigned long int)); + dump_file.read(reinterpret_cast(&acc_carrier_phase_rad[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carrier_doppler_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_freq_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carr_error_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carr_error_filt_hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_error_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&code_error_filt_chips[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&CN0_SNV_dB_Hz[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&carrier_lock_test[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&aux1[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&aux2[i]), sizeof(double)); + dump_file.read(reinterpret_cast(&PRN[i]), sizeof(unsigned int)); + } + } + dump_file.close(); + } + catch (const std::ifstream::failure &e) + { + std::cerr << "Problem reading dump file:" << e.what() << std::endl; + delete[] abs_E; + delete[] abs_P; + delete[] abs_L; + delete[] Prompt_I; + delete[] Prompt_Q; + delete[] PRN_start_sample_count; + delete[] acc_carrier_phase_rad; + delete[] carrier_doppler_hz; + delete[] code_freq_chips; + delete[] carr_error_hz; + delete[] carr_error_filt_hz; + delete[] code_error_chips; + delete[] code_error_filt_chips; + delete[] CN0_SNV_dB_Hz; + delete[] carrier_lock_test; + delete[] aux1; + delete[] aux2; + delete[] PRN; + return 1; + } + + // WRITE MAT FILE + mat_t *matfp; + matvar_t *matvar; + std::string filename = d_dump_filename; + filename.erase(filename.length() - 4, 4); + filename.append(".mat"); + matfp = Mat_CreateVer(filename.c_str(), NULL, MAT_FT_MAT73); + if (reinterpret_cast(matfp) != NULL) + { + size_t dims[2] = {1, static_cast(num_epoch)}; + matvar = Mat_VarCreate("abs_E", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_E, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_P", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_P, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("abs_L", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, abs_L, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Prompt_I", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_I, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("Prompt_Q", MAT_C_SINGLE, MAT_T_SINGLE, 2, dims, Prompt_Q, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN_start_sample_count", MAT_C_UINT64, MAT_T_UINT64, 2, dims, PRN_start_sample_count, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("acc_carrier_phase_rad", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, acc_carrier_phase_rad, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carrier_doppler_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_doppler_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_freq_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_freq_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carr_error_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carr_error_filt_hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carr_error_filt_hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_error_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("code_error_filt_chips", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, code_error_filt_chips, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("CN0_SNV_dB_Hz", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, CN0_SNV_dB_Hz, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("carrier_lock_test", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, carrier_lock_test, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("aux1", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux1, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("aux2", MAT_C_DOUBLE, MAT_T_DOUBLE, 2, dims, aux2, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + + matvar = Mat_VarCreate("PRN", MAT_C_UINT32, MAT_T_UINT32, 2, dims, PRN, 0); + Mat_VarWrite(matfp, matvar, MAT_COMPRESSION_ZLIB); // or MAT_COMPRESSION_NONE + Mat_VarFree(matvar); + } + Mat_Close(matfp); + delete[] abs_E; + delete[] abs_P; + delete[] abs_L; + delete[] Prompt_I; + delete[] Prompt_Q; + delete[] PRN_start_sample_count; + delete[] acc_carrier_phase_rad; + delete[] carrier_doppler_hz; + delete[] code_freq_chips; + delete[] carr_error_hz; + delete[] carr_error_filt_hz; + delete[] code_error_chips; + delete[] code_error_filt_chips; + delete[] CN0_SNV_dB_Hz; + delete[] carrier_lock_test; + delete[] aux1; + delete[] aux2; + delete[] PRN; + return 0; +} + + +glonass_l2_ca_dll_pll_c_aid_tracking_sc::~glonass_l2_ca_dll_pll_c_aid_tracking_sc() +{ + if (d_dump_file.is_open()) + { + try + { + d_dump_file.close(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Exception in destructor " << ex.what(); + } + } + + if (d_dump) + { + if (d_channel == 0) + { + std::cout << "Writing .mat files ..."; + } + glonass_l2_ca_dll_pll_c_aid_tracking_sc::save_matfile(); + if (d_channel == 0) + { + std::cout << " done." << std::endl; + } + } + + volk_gnsssdr_free(d_local_code_shift_chips); + volk_gnsssdr_free(d_ca_code); + volk_gnsssdr_free(d_ca_code_16sc); + volk_gnsssdr_free(d_correlator_outs_16sc); + + delete[] d_Prompt_buffer; + multicorrelator_cpu_16sc.free(); +} + + +int glonass_l2_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), + gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) +{ + // Block input data and block output stream pointers + const lv_16sc_t *in = reinterpret_cast(input_items[0]); // PRN start block alignment + Gnss_Synchro **out = reinterpret_cast(&output_items[0]); + + // GNSS_SYNCHRO OBJECT to interchange data between tracking->telemetry_decoder + Gnss_Synchro current_synchro_data = Gnss_Synchro(); + + // process vars + double code_error_filt_secs_Ti = 0.0; + double CURRENT_INTEGRATION_TIME_S = 0.0; + double CORRECTED_INTEGRATION_TIME_S = 0.0; + + if (d_enable_tracking == true) + { + // Fill the acquisition data + current_synchro_data = *d_acquisition_gnss_synchro; + // Receiver signal alignment + if (d_pull_in == true) + { + int samples_offset; + double acq_trk_shif_correction_samples; + int acq_to_trk_delay_samples; + acq_to_trk_delay_samples = d_sample_counter - d_acq_sample_stamp; + acq_trk_shif_correction_samples = d_correlation_length_samples - fmod(static_cast(acq_to_trk_delay_samples), static_cast(d_correlation_length_samples)); + samples_offset = round(d_acq_code_phase_samples + acq_trk_shif_correction_samples); + current_synchro_data.Tracking_sample_counter = d_sample_counter + samples_offset; + d_sample_counter += samples_offset; // count for the processed samples + d_pull_in = false; + d_acc_carrier_phase_cycles -= d_carrier_phase_step_rad * samples_offset / GLONASS_TWO_PI; + current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_cycles * GLONASS_TWO_PI; + current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; + current_synchro_data.fs = d_fs_in; + *out[0] = current_synchro_data; + consume_each(samples_offset); // shift input to perform alignment with local replica + return 1; + } + + // ################# CARRIER WIPEOFF AND CORRELATORS ############################## + // perform carrier wipe-off and compute Early, Prompt and Late correlation + multicorrelator_cpu_16sc.set_input_output_vectors(d_correlator_outs_16sc, in); + multicorrelator_cpu_16sc.Carrier_wipeoff_multicorrelator_resampler(d_rem_carrier_phase_rad, + d_carrier_phase_step_rad, + d_rem_code_phase_chips, + d_code_phase_step_chips, + d_correlation_length_samples); + + // ####### coherent integration extension + // keep the last symbols + d_E_history.push_back(d_correlator_outs_16sc[0]); // save early output + d_P_history.push_back(d_correlator_outs_16sc[1]); // save prompt output + d_L_history.push_back(d_correlator_outs_16sc[2]); // save late output + + if (static_cast(d_P_history.size()) > d_extend_correlation_ms) + { + d_E_history.pop_front(); + d_P_history.pop_front(); + d_L_history.pop_front(); + } + + bool enable_dll_pll; + if (d_enable_extended_integration == true) + { + long int symbol_diff = round(1000.0 * ((static_cast(d_sample_counter) + d_rem_code_phase_samples) / static_cast(d_fs_in) - d_preamble_timestamp_s)); + if (symbol_diff > 0 and symbol_diff % d_extend_correlation_ms == 0) + { + // compute coherent integration and enable tracking loop + // perform coherent integration using correlator output history + // std::cout<<"##### RESET COHERENT INTEGRATION ####"<PRN) + << " pll_bw = " << d_pll_bw_hz << " [Hz], pll_narrow_bw = " << d_pll_bw_narrow_hz << " [Hz]" << std::endl + << " dll_bw = " << d_dll_bw_hz << " [Hz], dll_narrow_bw = " << d_dll_bw_narrow_hz << " [Hz]" << std::endl; + } + // UPDATE INTEGRATION TIME + CURRENT_INTEGRATION_TIME_S = static_cast(d_extend_correlation_ms) * GLONASS_L2_CA_CODE_PERIOD; + enable_dll_pll = true; + } + else + { + if (d_preamble_synchronized == true) + { + // continue extended coherent correlation + // Compute the next buffer length based on the period of the PRN sequence and the code phase error estimation + double T_chip_seconds = 1.0 / d_code_freq_chips; + double T_prn_seconds = T_chip_seconds * GLONASS_L2_CA_CODE_LENGTH_CHIPS; + double T_prn_samples = T_prn_seconds * static_cast(d_fs_in); + int K_prn_samples = round(T_prn_samples); + double K_T_prn_error_samples = K_prn_samples - T_prn_samples; + + d_rem_code_phase_samples = d_rem_code_phase_samples - K_T_prn_error_samples; + d_rem_code_phase_integer_samples = round(d_rem_code_phase_samples); // round to a discrete number of samples + d_correlation_length_samples = K_prn_samples + d_rem_code_phase_integer_samples; + d_rem_code_phase_samples = d_rem_code_phase_samples - d_rem_code_phase_integer_samples; + // code phase step (Code resampler phase increment per sample) [chips/sample] + d_code_phase_step_chips = d_code_freq_chips / static_cast(d_fs_in); + // remnant code phase [chips] + d_rem_code_phase_chips = d_rem_code_phase_samples * (d_code_freq_chips / static_cast(d_fs_in)); + d_rem_carrier_phase_rad = fmod(d_rem_carrier_phase_rad + d_carrier_phase_step_rad * static_cast(d_correlation_length_samples), GLONASS_TWO_PI); + + // UPDATE ACCUMULATED CARRIER PHASE + CORRECTED_INTEGRATION_TIME_S = (static_cast(d_correlation_length_samples) / static_cast(d_fs_in)); + d_acc_carrier_phase_cycles -= d_carrier_phase_step_rad * d_correlation_length_samples / GLONASS_TWO_PI; + + // disable tracking loop and inform telemetry decoder + enable_dll_pll = false; + } + else + { + // perform basic (1ms) correlation + // UPDATE INTEGRATION TIME + CURRENT_INTEGRATION_TIME_S = static_cast(d_correlation_length_samples) / static_cast(d_fs_in); + enable_dll_pll = true; + } + } + } + else + { + // UPDATE INTEGRATION TIME + CURRENT_INTEGRATION_TIME_S = static_cast(d_correlation_length_samples) / static_cast(d_fs_in); + enable_dll_pll = true; + } + + if (enable_dll_pll == true) + { + // ################## PLL ########################################################## + // Update PLL discriminator [rads/Ti -> Secs/Ti] + d_carr_phase_error_secs_Ti = pll_cloop_two_quadrant_atan(std::complex(d_correlator_outs_16sc[1].real(), d_correlator_outs_16sc[1].imag())) / GLONASS_TWO_PI; //prompt output + d_carrier_doppler_old_hz = d_carrier_doppler_hz; + // Carrier discriminator filter + // NOTICE: The carrier loop filter includes the Carrier Doppler accumulator, as described in Kaplan + // Input [s/Ti] -> output [Hz] + d_carrier_doppler_hz = d_carrier_loop_filter.get_carrier_error(0.0, d_carr_phase_error_secs_Ti, CURRENT_INTEGRATION_TIME_S); + // PLL to DLL assistance [Secs/Ti] + d_pll_to_dll_assist_secs_Ti = (d_carrier_doppler_hz * CURRENT_INTEGRATION_TIME_S) / d_glonass_freq_ch; + // code Doppler frequency update + d_code_freq_chips = GLONASS_L2_CA_CODE_RATE_HZ + (((d_carrier_doppler_hz - d_carrier_doppler_old_hz) * GLONASS_L2_CA_CODE_RATE_HZ) / d_glonass_freq_ch); + + // ################## DLL ########################################################## + // DLL discriminator + d_code_error_chips_Ti = dll_nc_e_minus_l_normalized(std::complex(d_correlator_outs_16sc[0].real(), d_correlator_outs_16sc[0].imag()), std::complex(d_correlator_outs_16sc[2].real(), d_correlator_outs_16sc[2].imag())); // [chips/Ti] //early and late + // Code discriminator filter + d_code_error_filt_chips_s = d_code_loop_filter.get_code_nco(d_code_error_chips_Ti); // input [chips/Ti] -> output [chips/second] + d_code_error_filt_chips_Ti = d_code_error_filt_chips_s * CURRENT_INTEGRATION_TIME_S; + code_error_filt_secs_Ti = d_code_error_filt_chips_Ti / d_code_freq_chips; // [s/Ti] + + // ################## CARRIER AND CODE NCO BUFFER ALIGNMENT ####################### + // keep alignment parameters for the next input buffer + // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation + double T_chip_seconds = 1.0 / d_code_freq_chips; + double T_prn_seconds = T_chip_seconds * GLONASS_L2_CA_CODE_LENGTH_CHIPS; + double T_prn_samples = T_prn_seconds * static_cast(d_fs_in); + double K_prn_samples = round(T_prn_samples); + double K_T_prn_error_samples = K_prn_samples - T_prn_samples; + + d_rem_code_phase_samples = d_rem_code_phase_samples - K_T_prn_error_samples + code_error_filt_secs_Ti * static_cast(d_fs_in); //(code_error_filt_secs_Ti + d_pll_to_dll_assist_secs_Ti) * static_cast(d_fs_in); + d_rem_code_phase_integer_samples = round(d_rem_code_phase_samples); // round to a discrete number of samples + d_correlation_length_samples = K_prn_samples + d_rem_code_phase_integer_samples; + d_rem_code_phase_samples = d_rem_code_phase_samples - d_rem_code_phase_integer_samples; + + //################### PLL COMMANDS ################################################# + //carrier phase step (NCO phase increment per sample) [rads/sample] + d_carrier_phase_step_rad = GLONASS_TWO_PI * d_carrier_doppler_hz / static_cast(d_fs_in); + d_acc_carrier_phase_cycles -= d_carrier_phase_step_rad * d_correlation_length_samples / GLONASS_TWO_PI; + // UPDATE ACCUMULATED CARRIER PHASE + CORRECTED_INTEGRATION_TIME_S = (static_cast(d_correlation_length_samples) / static_cast(d_fs_in)); + //remnant carrier phase [rad] + d_rem_carrier_phase_rad = fmod(d_rem_carrier_phase_rad + GLONASS_TWO_PI * d_carrier_doppler_hz * CORRECTED_INTEGRATION_TIME_S, GLONASS_TWO_PI); + + //################### DLL COMMANDS ################################################# + //code phase step (Code resampler phase increment per sample) [chips/sample] + d_code_phase_step_chips = d_code_freq_chips / static_cast(d_fs_in); + //remnant code phase [chips] + d_rem_code_phase_chips = d_rem_code_phase_samples * (d_code_freq_chips / static_cast(d_fs_in)); + + // ####### CN0 ESTIMATION AND LOCK DETECTORS ####################################### + if (d_cn0_estimation_counter < CN0_ESTIMATION_SAMPLES) + { + // fill buffer with prompt correlator output values + d_Prompt_buffer[d_cn0_estimation_counter] = lv_cmake(static_cast(d_correlator_outs_16sc[1].real()), static_cast(d_correlator_outs_16sc[1].imag())); // prompt + d_cn0_estimation_counter++; + } + else + { + d_cn0_estimation_counter = 0; + // Code lock indicator + d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES, d_fs_in, GLONASS_L2_CA_CODE_LENGTH_CHIPS); + // Carrier lock indicator + d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES); + // Loss of lock detection + if (d_carrier_lock_test < d_carrier_lock_threshold or d_CN0_SNV_dB_Hz < FLAGS_cn0_min) + { + d_carrier_lock_fail_counter++; + } + else + { + if (d_carrier_lock_fail_counter > 0) d_carrier_lock_fail_counter--; + } + if (d_carrier_lock_fail_counter > FLAGS_max_lock_fail) + { + std::cout << "Loss of lock in channel " << d_channel << "!" << std::endl; + LOG(INFO) << "Loss of lock in channel " << d_channel << "!"; + this->message_port_pub(pmt::mp("events"), pmt::from_long(3)); //3 -> loss of lock + d_carrier_lock_fail_counter = 0; + d_enable_tracking = false; // TODO: check if disabling tracking is consistent with the channel state machine + } + } + // ########### Output the tracking data to navigation and PVT ########## + current_synchro_data.Prompt_I = static_cast((d_correlator_outs_16sc[1]).real()); + current_synchro_data.Prompt_Q = static_cast((d_correlator_outs_16sc[1]).imag()); + // Tracking_timestamp_secs is aligned with the CURRENT PRN start sample (Hybridization OK!) + current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; + current_synchro_data.Carrier_phase_rads = GLONASS_TWO_PI * d_acc_carrier_phase_cycles; + current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; + current_synchro_data.CN0_dB_hz = d_CN0_SNV_dB_Hz; + current_synchro_data.Flag_valid_symbol_output = true; + if (d_preamble_synchronized == true) + { + current_synchro_data.correlation_length_ms = d_extend_correlation_ms; + } + else + { + current_synchro_data.correlation_length_ms = 1; + } + } + else + { + current_synchro_data.Prompt_I = static_cast((d_correlator_outs_16sc[1]).real()); + current_synchro_data.Prompt_Q = static_cast((d_correlator_outs_16sc[1]).imag()); + current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + current_synchro_data.Code_phase_samples = d_rem_code_phase_samples; + current_synchro_data.Carrier_phase_rads = GLONASS_TWO_PI * d_acc_carrier_phase_cycles; + current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; // todo: project the carrier doppler + current_synchro_data.CN0_dB_hz = d_CN0_SNV_dB_Hz; + } + } + else + { + for (int n = 0; n < d_n_correlator_taps; n++) + { + d_correlator_outs_16sc[n] = lv_cmake(0, 0); + } + + current_synchro_data.System = {'R'}; + current_synchro_data.Tracking_sample_counter = d_sample_counter + d_correlation_length_samples; + } + current_synchro_data.fs = d_fs_in; + *out[0] = current_synchro_data; + if (d_dump) + { + // MULTIPLEXED FILE RECORDING - Record results to file + float prompt_I; + float prompt_Q; + float tmp_E, tmp_P, tmp_L; + float tmp_VE = 0.0; + float tmp_VL = 0.0; + float tmp_float; + prompt_I = d_correlator_outs_16sc[1].real(); + prompt_Q = d_correlator_outs_16sc[1].imag(); + tmp_E = std::abs(gr_complex(d_correlator_outs_16sc[0].real(), d_correlator_outs_16sc[0].imag())); + tmp_P = std::abs(gr_complex(d_correlator_outs_16sc[1].real(), d_correlator_outs_16sc[1].imag())); + tmp_L = std::abs(gr_complex(d_correlator_outs_16sc[2].real(), d_correlator_outs_16sc[2].imag())); + try + { + // Dump correlators output + d_dump_file.write(reinterpret_cast(&tmp_VE), sizeof(float)); + d_dump_file.write(reinterpret_cast(&tmp_E), sizeof(float)); + d_dump_file.write(reinterpret_cast(&tmp_P), sizeof(float)); + d_dump_file.write(reinterpret_cast(&tmp_L), sizeof(float)); + d_dump_file.write(reinterpret_cast(&tmp_VL), sizeof(float)); + // PROMPT I and Q (to analyze navigation symbols) + d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); + d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); + // PRN start sample stamp + d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); + // accumulated carrier phase + tmp_float = d_acc_carrier_phase_cycles * GLONASS_TWO_PI; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // carrier and code frequency + tmp_float = d_carrier_doppler_hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_code_freq_chips; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // PLL commands + tmp_float = 1.0 / (d_carr_phase_error_secs_Ti * CURRENT_INTEGRATION_TIME_S); + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = 1.0 / (d_code_error_filt_chips_Ti * CURRENT_INTEGRATION_TIME_S); + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // DLL commands + tmp_float = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_code_error_filt_chips_Ti; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // CN0 and carrier lock test + tmp_float = d_CN0_SNV_dB_Hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_carrier_lock_test; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // AUX vars (for debug purposes) + tmp_float = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + double tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + // PRN + unsigned int prn_ = d_acquisition_gnss_synchro->PRN; + d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); + } + catch (const std::ifstream::failure *e) + { + LOG(WARNING) << "Exception writing trk dump file " << e->what(); + } + } + + consume_each(d_correlation_length_samples); // this is necessary in gr::block derivates + d_sample_counter += d_correlation_length_samples; //count for the processed samples + + return 1; //output tracking result ALWAYS even in the case of d_enable_tracking==false +} + + +void glonass_l2_ca_dll_pll_c_aid_tracking_sc::set_channel(unsigned int channel) +{ + d_channel = channel; + LOG(INFO) << "Tracking Channel set to " << d_channel; + // ############# ENABLE DATA FILE LOG ################# + if (d_dump == true) + { + if (d_dump_file.is_open() == false) + { + try + { + d_dump_filename.append(boost::lexical_cast(d_channel)); + d_dump_filename.append(".dat"); + d_dump_file.exceptions(std::ifstream::failbit | std::ifstream::badbit); + d_dump_file.open(d_dump_filename.c_str(), std::ios::out | std::ios::binary); + LOG(INFO) << "Tracking dump enabled on channel " << d_channel << " Log file: " << d_dump_filename.c_str() << std::endl; + } + catch (const std::ifstream::failure *e) + { + LOG(WARNING) << "channel " << d_channel << " Exception opening trk dump file " << e->what() << std::endl; + } + } + } +} + + +void glonass_l2_ca_dll_pll_c_aid_tracking_sc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) +{ + d_acquisition_gnss_synchro = p_gnss_synchro; +} diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.h b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.h new file mode 100644 index 000000000..6ee493185 --- /dev/null +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.h @@ -0,0 +1,206 @@ +/*! + * \file glonass_l2_ca_dll_pll_c_aid_tracking_sc.h + * \brief Implementation of a code DLL + carrier PLL tracking block + * \author Damian Miralles, 2018. dmiralles2009(at)gmail.com + * + * + * Code DLL + carrier PLL according to the algorithms described in: + * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, + * A Software-Defined GPS and Galileo Receiver. A Single-Frequency + * Approach, Birkha user, 2007 + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + +#ifndef GNSS_SDR_GLONASS_L2_CA_DLL_PLL_C_AID_TRACKING_SC_H +#define GNSS_SDR_GLONASS_L2_CA_DLL_PLL_C_AID_TRACKING_SC_H + +#include "glonass_l2_signal_processing.h" +#include "gnss_synchro.h" +#include "tracking_2nd_DLL_filter.h" +#include "tracking_FLL_PLL_filter.h" +#include "cpu_multicorrelator_16sc.h" +#include +#include +#include +#include +#include +#include +#include + +class glonass_l2_ca_dll_pll_c_aid_tracking_sc; + +typedef boost::shared_ptr + glonass_l2_ca_dll_pll_c_aid_tracking_sc_sptr; + +glonass_l2_ca_dll_pll_c_aid_tracking_sc_sptr +glonass_l2_ca_dll_pll_c_aid_make_tracking_sc(long if_freq, + long fs_in, unsigned int vector_length, + bool dump, + std::string dump_filename, + float pll_bw_hz, + float dll_bw_hz, + float pll_bw_narrow_hz, + float dll_bw_narrow_hz, + int extend_correlation_ms, + float early_late_space_chips); + + +/*! + * \brief This class implements a DLL + PLL tracking loop block + */ +class glonass_l2_ca_dll_pll_c_aid_tracking_sc : public gr::block +{ +public: + ~glonass_l2_ca_dll_pll_c_aid_tracking_sc(); + + void set_channel(unsigned int channel); + void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro); + void start_tracking(); + + int general_work(int noutput_items, gr_vector_int& ninput_items, + gr_vector_const_void_star& input_items, gr_vector_void_star& output_items); + + void forecast(int noutput_items, gr_vector_int& ninput_items_required); + +private: + friend glonass_l2_ca_dll_pll_c_aid_tracking_sc_sptr + glonass_l2_ca_dll_pll_c_aid_make_tracking_sc(long if_freq, + long fs_in, unsigned int vector_length, + bool dump, + std::string dump_filename, + float pll_bw_hz, + float dll_bw_hz, + float pll_bw_narrow_hz, + float dll_bw_narrow_hz, + int extend_correlation_ms, + float early_late_space_chips); + + glonass_l2_ca_dll_pll_c_aid_tracking_sc(long if_freq, + long fs_in, unsigned int vector_length, + bool dump, + std::string dump_filename, + float pll_bw_hz, + float dll_bw_hz, + float pll_bw_narrow_hz, + float dll_bw_narrow_hz, + int extend_correlation_ms, + float early_late_space_chips); + + // tracking configuration vars + unsigned int d_vector_length; + bool d_dump; + + Gnss_Synchro* d_acquisition_gnss_synchro; + unsigned int d_channel; + + long d_if_freq; + long d_fs_in; + long d_glonass_freq_ch; + + double d_early_late_spc_chips; + int d_n_correlator_taps; + + gr_complex* d_ca_code; + lv_16sc_t* d_ca_code_16sc; + float* d_local_code_shift_chips; + //gr_complex* d_correlator_outs; + lv_16sc_t* d_correlator_outs_16sc; + //cpu_multicorrelator multicorrelator_cpu; + cpu_multicorrelator_16sc multicorrelator_cpu_16sc; + + // remaining code phase and carrier phase between tracking loops + double d_rem_code_phase_samples; + double d_rem_code_phase_chips; + double d_rem_carrier_phase_rad; + int d_rem_code_phase_integer_samples; + + // PLL and DLL filter library + Tracking_2nd_DLL_filter d_code_loop_filter; + Tracking_FLL_PLL_filter d_carrier_loop_filter; + + // acquisition + double d_acq_code_phase_samples; + double d_acq_carrier_doppler_hz; + + // tracking vars + float d_dll_bw_hz; + float d_pll_bw_hz; + float d_dll_bw_narrow_hz; + float d_pll_bw_narrow_hz; + double d_code_freq_chips; + double d_code_phase_step_chips; + double d_carrier_doppler_hz; + double d_carrier_frequency_hz; + double d_carrier_doppler_old_hz; + double d_carrier_phase_step_rad; + double d_acc_carrier_phase_cycles; + double d_code_phase_samples; + double d_pll_to_dll_assist_secs_Ti; + double d_carr_phase_error_secs_Ti; + double d_code_error_chips_Ti; + double d_preamble_timestamp_s; + int d_extend_correlation_ms; + bool d_enable_extended_integration; + bool d_preamble_synchronized; + double d_code_error_filt_chips_s; + double d_code_error_filt_chips_Ti; + void msg_handler_preamble_index(pmt::pmt_t msg); + + // symbol history to detect bit transition + std::deque d_E_history; + std::deque d_P_history; + std::deque d_L_history; + + //Integration period in samples + int d_correlation_length_samples; + + //processing samples counters + unsigned long int d_sample_counter; + unsigned long int d_acq_sample_stamp; + + // CN0 estimation and lock detector + int d_cn0_estimation_counter; + gr_complex* d_Prompt_buffer; + double d_carrier_lock_test; + double d_CN0_SNV_dB_Hz; + double d_carrier_lock_threshold; + int d_carrier_lock_fail_counter; + + // control vars + bool d_enable_tracking; + bool d_pull_in; + + // file dump + std::string d_dump_filename; + std::ofstream d_dump_file; + + std::map systemName; + std::string sys; + + int save_matfile(); +}; + +#endif //GNSS_SDR_GLONASS_L2_CA_DLL_PLL_C_AID_TRACKING_SC_H diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc similarity index 83% rename from src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.cc rename to src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc index 48612d124..f6428bc5c 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.cc @@ -1,17 +1,19 @@ /*! - * \file gps_l1_ca_dll_pll_tracking_cc.cc - * \brief Implementation of a code DLL + carrier PLL tracking block - * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com - * Javier Arribas, 2011. jarribas(at)cttc.es + * \file glonass_l2_ca_dll_pll_tracking_cc.cc + * \brief Implementation of a code DLL + carrier PLL tracking block + * \author Gabriel Araujo, 2017. gabriel.araujo.5000(at)gmail.com + * \author Luis Esteve, 2017. luis(at)epsilon-formacion.com + * \author Damian Miralles, 2017. dmiralles2009(at)gmail.com + * * * Code DLL + carrier PLL according to the algorithms described in: - * [1] K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, + * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, * A Software-Defined GPS and Galileo Receiver. A Single-Frequency - * Approach, Birkhauser, 2007 + * Approach, Birkha user, 2007 * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -34,28 +36,29 @@ * ------------------------------------------------------------------------- */ -#include "gps_l1_ca_dll_pll_tracking_cc.h" -#include "gps_sdr_signal_processing.h" +#include "glonass_l2_ca_dll_pll_tracking_cc.h" +#include "glonass_l2_signal_processing.h" #include "tracking_discriminators.h" #include "lock_detectors.h" +#include "GLONASS_L1_L2_CA.h" #include "gnss_sdr_flags.h" -#include "GPS_L1_CA.h" #include "control_message_factory.h" #include #include #include -#include #include +#include #include #include #include #include +#define CN0_ESTIMATION_SAMPLES 10 using google::LogMessage; -gps_l1_ca_dll_pll_tracking_cc_sptr -gps_l1_ca_dll_pll_make_tracking_cc( +glonass_l2_ca_dll_pll_tracking_cc_sptr +glonass_l2_ca_dll_pll_make_tracking_cc( long if_freq, long fs_in, unsigned int vector_length, @@ -65,12 +68,12 @@ gps_l1_ca_dll_pll_make_tracking_cc( float dll_bw_hz, float early_late_space_chips) { - return gps_l1_ca_dll_pll_tracking_cc_sptr(new Gps_L1_Ca_Dll_Pll_Tracking_cc(if_freq, + return glonass_l2_ca_dll_pll_tracking_cc_sptr(new Glonass_L2_Ca_Dll_Pll_Tracking_cc(if_freq, fs_in, vector_length, dump, dump_filename, pll_bw_hz, dll_bw_hz, early_late_space_chips)); } -void Gps_L1_Ca_Dll_Pll_Tracking_cc::forecast(int noutput_items, +void Glonass_L2_Ca_Dll_Pll_Tracking_cc::forecast(int noutput_items, gr_vector_int &ninput_items_required) { if (noutput_items != 0) @@ -80,7 +83,7 @@ void Gps_L1_Ca_Dll_Pll_Tracking_cc::forecast(int noutput_items, } -Gps_L1_Ca_Dll_Pll_Tracking_cc::Gps_L1_Ca_Dll_Pll_Tracking_cc( +Glonass_L2_Ca_Dll_Pll_Tracking_cc::Glonass_L2_Ca_Dll_Pll_Tracking_cc( long if_freq, long fs_in, unsigned int vector_length, @@ -88,7 +91,7 @@ Gps_L1_Ca_Dll_Pll_Tracking_cc::Gps_L1_Ca_Dll_Pll_Tracking_cc( std::string dump_filename, float pll_bw_hz, float dll_bw_hz, - float early_late_space_chips) : gr::block("Gps_L1_Ca_Dll_Pll_Tracking_cc", gr::io_signature::make(1, 1, sizeof(gr_complex)), + float early_late_space_chips) : gr::block("Glonass_L2_Ca_Dll_Pll_Tracking_cc", gr::io_signature::make(1, 1, sizeof(gr_complex)), gr::io_signature::make(1, 1, sizeof(Gnss_Synchro))) { // Telemetry bit synchronization message port input @@ -113,7 +116,7 @@ Gps_L1_Ca_Dll_Pll_Tracking_cc::Gps_L1_Ca_Dll_Pll_Tracking_cc( // Initialization of local code replica // Get space for a vector with the C/A code replica sampled 1x/chip - d_ca_code = static_cast(volk_gnsssdr_malloc(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS) * sizeof(float), volk_gnsssdr_get_alignment())); + d_ca_code = static_cast(volk_gnsssdr_malloc(static_cast(GLONASS_L2_CA_CODE_LENGTH_CHIPS) * sizeof(gr_complex), volk_gnsssdr_get_alignment())); // correlator outputs (scalar) d_n_correlator_taps = 3; // Early, Prompt, and Late @@ -132,7 +135,7 @@ Gps_L1_Ca_Dll_Pll_Tracking_cc::Gps_L1_Ca_Dll_Pll_Tracking_cc( //--- Perform initializations ------------------------------ // define initial code frequency basis of NCO - d_code_freq_chips = GPS_L1_CA_CODE_RATE_HZ; + d_code_freq_chips = GLONASS_L2_CA_CODE_RATE_HZ; // define residual code phase (in chips) d_rem_code_phase_samples = 0.0; // define residual carrier phase @@ -154,27 +157,29 @@ Gps_L1_Ca_Dll_Pll_Tracking_cc::Gps_L1_Ca_Dll_Pll_Tracking_cc( d_carrier_lock_fail_counter = 0; d_carrier_lock_threshold = FLAGS_carrier_lock_th; - systemName["G"] = std::string("GPS"); - systemName["S"] = std::string("SBAS"); + systemName["R"] = std::string("Glonass"); d_acquisition_gnss_synchro = 0; d_channel = 0; d_acq_code_phase_samples = 0.0; d_acq_carrier_doppler_hz = 0.0; d_carrier_doppler_hz = 0.0; + d_carrier_doppler_phase_step_rad = 0.0; + d_carrier_frequency_hz = 0.0; d_acc_carrier_phase_rad = 0.0; d_code_phase_samples = 0.0; d_rem_code_phase_chips = 0.0; d_code_phase_step_chips = 0.0; d_carrier_phase_step_rad = 0.0; + d_glonass_freq_ch = 0; + set_relative_rate(1.0 / static_cast(d_vector_length)); } -void Gps_L1_Ca_Dll_Pll_Tracking_cc::start_tracking() +void Glonass_L2_Ca_Dll_Pll_Tracking_cc::start_tracking() { - gr::thread::scoped_lock lk(d_setlock); /* * correct the code phase according to the delay between acq and trk */ @@ -185,24 +190,25 @@ void Gps_L1_Ca_Dll_Pll_Tracking_cc::start_tracking() long int acq_trk_diff_samples; double acq_trk_diff_seconds; acq_trk_diff_samples = static_cast(d_sample_counter) - static_cast(d_acq_sample_stamp); //-d_vector_length; - DLOG(INFO) << "Number of samples between Acquisition and Tracking = " << acq_trk_diff_samples; + DLOG(INFO) << "Number of samples between Acquisition and Tracking =" << acq_trk_diff_samples; acq_trk_diff_seconds = static_cast(acq_trk_diff_samples) / static_cast(d_fs_in); // Doppler effect // Fd=(C/(C+Vr))*F - double radial_velocity = (GPS_L1_FREQ_HZ + d_acq_carrier_doppler_hz) / GPS_L1_FREQ_HZ; + d_glonass_freq_ch = GLONASS_L2_CA_FREQ_HZ + (DFRQ2_GLO * GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN)); + double radial_velocity = (d_glonass_freq_ch + d_acq_carrier_doppler_hz) / d_glonass_freq_ch; // new chip and prn sequence periods based on acq Doppler double T_chip_mod_seconds; double T_prn_mod_seconds; double T_prn_mod_samples; - d_code_freq_chips = radial_velocity * GPS_L1_CA_CODE_RATE_HZ; + d_code_freq_chips = radial_velocity * GLONASS_L2_CA_CODE_RATE_HZ; d_code_phase_step_chips = static_cast(d_code_freq_chips) / static_cast(d_fs_in); T_chip_mod_seconds = 1 / d_code_freq_chips; - T_prn_mod_seconds = T_chip_mod_seconds * GPS_L1_CA_CODE_LENGTH_CHIPS; + T_prn_mod_seconds = T_chip_mod_seconds * GLONASS_L2_CA_CODE_LENGTH_CHIPS; T_prn_mod_samples = T_prn_mod_seconds * static_cast(d_fs_in); d_current_prn_length_samples = round(T_prn_mod_samples); - double T_prn_true_seconds = GPS_L1_CA_CODE_LENGTH_CHIPS / GPS_L1_CA_CODE_RATE_HZ; + double T_prn_true_seconds = GLONASS_L2_CA_CODE_LENGTH_CHIPS / GLONASS_L2_CA_CODE_RATE_HZ; double T_prn_true_samples = T_prn_true_seconds * static_cast(d_fs_in); double T_prn_diff_seconds = T_prn_true_seconds - T_prn_mod_seconds; double N_prn_diff = acq_trk_diff_seconds / T_prn_true_seconds; @@ -216,17 +222,19 @@ void Gps_L1_Ca_Dll_Pll_Tracking_cc::start_tracking() d_acq_code_phase_samples = corrected_acq_phase_samples; + d_carrier_frequency_hz = d_acq_carrier_doppler_hz + d_if_freq + (DFRQ2_GLO * GLONASS_PRN.at(d_acquisition_gnss_synchro->PRN)); d_carrier_doppler_hz = d_acq_carrier_doppler_hz; - d_carrier_phase_step_rad = GPS_TWO_PI * d_carrier_doppler_hz / static_cast(d_fs_in); + d_carrier_phase_step_rad = GLONASS_TWO_PI * d_carrier_frequency_hz / static_cast(d_fs_in); + d_carrier_doppler_phase_step_rad = GLONASS_TWO_PI * (d_carrier_doppler_hz) / static_cast(d_fs_in); // DLL/PLL filter initialization d_carrier_loop_filter.initialize(); // initialize the carrier filter d_code_loop_filter.initialize(); // initialize the code filter // generate local reference ALWAYS starting at chip 1 (1 sample per chip) - gps_l1_ca_code_gen_float(d_ca_code, d_acquisition_gnss_synchro->PRN, 0); + glonass_l2_ca_code_gen_complex(d_ca_code, 0); - multicorrelator_cpu.set_local_code_and_taps(static_cast(GPS_L1_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips); + multicorrelator_cpu.set_local_code_and_taps(static_cast(GLONASS_L2_CA_CODE_LENGTH_CHIPS), d_ca_code, d_local_code_shift_chips); for (int n = 0; n < d_n_correlator_taps; n++) { d_correlator_outs[n] = gr_complex(0, 0); @@ -244,20 +252,60 @@ void Gps_L1_Ca_Dll_Pll_Tracking_cc::start_tracking() sys = sys_.substr(0, 1); // DEBUG OUTPUT - std::cout << "Tracking of GPS L1 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << std::endl; + std::cout << "Tracking of GLONASS L2 C/A signal started on channel " << d_channel << " for satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << std::endl; LOG(INFO) << "Starting tracking of satellite " << Gnss_Satellite(systemName[sys], d_acquisition_gnss_synchro->PRN) << " on channel " << d_channel; // enable tracking d_pull_in = true; d_enable_tracking = true; - LOG(INFO) << "PULL-IN Doppler [Hz]=" << d_carrier_doppler_hz + LOG(INFO) << "PULL-IN Doppler [Hz]=" << d_carrier_frequency_hz << " Code Phase correction [samples]=" << delay_correction_samples << " PULL-IN Code Phase [samples]=" << d_acq_code_phase_samples; } -int Gps_L1_Ca_Dll_Pll_Tracking_cc::save_matfile() +Glonass_L2_Ca_Dll_Pll_Tracking_cc::~Glonass_L2_Ca_Dll_Pll_Tracking_cc() +{ + if (d_dump_file.is_open()) + { + try + { + d_dump_file.close(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Exception in destructor " << ex.what(); + } + } + if (d_dump) + { + if (d_channel == 0) + { + std::cout << "Writing .mat files ..."; + } + Glonass_L2_Ca_Dll_Pll_Tracking_cc::save_matfile(); + if (d_channel == 0) + { + std::cout << " done." << std::endl; + } + } + try + { + volk_gnsssdr_free(d_local_code_shift_chips); + volk_gnsssdr_free(d_correlator_outs); + volk_gnsssdr_free(d_ca_code); + delete[] d_Prompt_buffer; + multicorrelator_cpu.free(); + } + catch (const std::exception &ex) + { + LOG(WARNING) << "Exception in destructor " << ex.what(); + } +} + + +int Glonass_L2_Ca_Dll_Pll_Tracking_cc::save_matfile() { // READ DUMP FILE std::ifstream::pos_type size; @@ -464,52 +512,9 @@ int Gps_L1_Ca_Dll_Pll_Tracking_cc::save_matfile() } -Gps_L1_Ca_Dll_Pll_Tracking_cc::~Gps_L1_Ca_Dll_Pll_Tracking_cc() -{ - if (d_dump_file.is_open()) - { - try - { - d_dump_file.close(); - } - catch (const std::exception &ex) - { - LOG(WARNING) << "Exception in destructor " << ex.what(); - } - } - - if (d_dump) - { - if (d_channel == 0) - { - std::cout << "Writing .mat files ..."; - } - Gps_L1_Ca_Dll_Pll_Tracking_cc::save_matfile(); - if (d_channel == 0) - { - std::cout << " done." << std::endl; - } - } - - try - { - volk_gnsssdr_free(d_local_code_shift_chips); - volk_gnsssdr_free(d_correlator_outs); - volk_gnsssdr_free(d_ca_code); - delete[] d_Prompt_buffer; - multicorrelator_cpu.free(); - } - catch (const std::exception &ex) - { - LOG(WARNING) << "Exception in destructor " << ex.what(); - } -} - - -int Gps_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), +int Glonass_L2_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribute__((unused)), gr_vector_int &ninput_items __attribute__((unused)), gr_vector_const_void_star &input_items, gr_vector_void_star &output_items) { - gr::thread::scoped_lock lk(d_setlock); // process vars double carr_error_hz = 0.0; double carr_error_filt_hz = 0.0; @@ -517,7 +522,7 @@ int Gps_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribute__( double code_error_filt_chips = 0.0; // Block input data and block output stream pointers - const gr_complex *in = reinterpret_cast(input_items[0]); + const gr_complex *in = reinterpret_cast(input_items[0]); // PRN start block alignment Gnss_Synchro **out = reinterpret_cast(&output_items[0]); // GNSS_SYNCHRO OBJECT to interchange data between tracking->telemetry_decoder @@ -540,13 +545,14 @@ int Gps_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribute__( d_sample_counter = d_sample_counter + samples_offset; // count for the processed samples d_pull_in = false; // take into account the carrier cycles accumulated in the pull in signal alignment - d_acc_carrier_phase_rad -= d_carrier_phase_step_rad * samples_offset; + d_acc_carrier_phase_rad -= d_carrier_doppler_phase_step_rad * samples_offset; current_synchro_data.Carrier_phase_rads = d_acc_carrier_phase_rad; current_synchro_data.Carrier_Doppler_hz = d_carrier_doppler_hz; current_synchro_data.fs = d_fs_in; current_synchro_data.correlation_length_ms = 1; + *out[0] = current_synchro_data; consume_each(samples_offset); // shift input to perform alignment with local replica - return 0; + return 1; } // ################# CARRIER WIPEOFF AND CORRELATORS ############################## @@ -561,13 +567,13 @@ int Gps_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribute__( // ################## PLL ########################################################## // PLL discriminator // Update PLL discriminator [rads/Ti -> Secs/Ti] - carr_error_hz = pll_cloop_two_quadrant_atan(d_correlator_outs[1]) / GPS_TWO_PI; // prompt output + carr_error_hz = pll_cloop_two_quadrant_atan(d_correlator_outs[1]) / GLONASS_TWO_PI; // prompt output // Carrier discriminator filter carr_error_filt_hz = d_carrier_loop_filter.get_carrier_nco(carr_error_hz); // New carrier Doppler frequency estimation - d_carrier_doppler_hz = d_acq_carrier_doppler_hz + carr_error_filt_hz; - // New code Doppler frequency estimation - d_code_freq_chips = GPS_L1_CA_CODE_RATE_HZ + ((d_carrier_doppler_hz * GPS_L1_CA_CODE_RATE_HZ) / GPS_L1_FREQ_HZ); + d_carrier_frequency_hz += carr_error_filt_hz; + d_carrier_doppler_hz += carr_error_filt_hz; + d_code_freq_chips = GLONASS_L2_CA_CODE_RATE_HZ + ((d_carrier_doppler_hz * GLONASS_L2_CA_CODE_RATE_HZ) / d_glonass_freq_ch); // ################## DLL ########################################################## // DLL discriminator @@ -575,27 +581,28 @@ int Gps_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribute__( // Code discriminator filter code_error_filt_chips = d_code_loop_filter.get_code_nco(code_error_chips); // [chips/second] double T_chip_seconds = 1.0 / static_cast(d_code_freq_chips); - double T_prn_seconds = T_chip_seconds * GPS_L1_CA_CODE_LENGTH_CHIPS; + double T_prn_seconds = T_chip_seconds * GLONASS_L2_CA_CODE_LENGTH_CHIPS; double code_error_filt_secs = (T_prn_seconds * code_error_filt_chips * T_chip_seconds); //[seconds] - //double code_error_filt_secs = (GPS_L1_CA_CODE_PERIOD * code_error_filt_chips) / GPS_L1_CA_CODE_RATE_HZ; // [seconds] + //double code_error_filt_secs = (GPS_L1_CA_CODE_PERIOD * code_error_filt_chips) / GLONASS_L1_CA_CODE_RATE_HZ; // [seconds] - // ################## CARRIER AND CODE NCO BUFFER ALIGNEMENT ####################### + // ################## CARRIER AND CODE NCO BUFFER ALIGNMENT ####################### // keep alignment parameters for the next input buffer // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation //double T_chip_seconds = 1.0 / static_cast(d_code_freq_chips); - //double T_prn_seconds = T_chip_seconds * GPS_L1_CA_CODE_LENGTH_CHIPS; + //double T_prn_seconds = T_chip_seconds * GLONASS_L1_CA_CODE_LENGTH_CHIPS; double T_prn_samples = T_prn_seconds * static_cast(d_fs_in); double K_blk_samples = T_prn_samples + d_rem_code_phase_samples + code_error_filt_secs * static_cast(d_fs_in); d_current_prn_length_samples = round(K_blk_samples); // round to a discrete number of samples //################### PLL COMMANDS ################################################# // carrier phase step (NCO phase increment per sample) [rads/sample] - d_carrier_phase_step_rad = GPS_TWO_PI * d_carrier_doppler_hz / static_cast(d_fs_in); + d_carrier_doppler_phase_step_rad = GLONASS_TWO_PI * d_carrier_doppler_hz / static_cast(d_fs_in); + d_carrier_phase_step_rad = GLONASS_TWO_PI * d_carrier_frequency_hz / static_cast(d_fs_in); // remnant carrier phase to prevent overflow in the code NCO d_rem_carr_phase_rad = d_rem_carr_phase_rad + d_carrier_phase_step_rad * d_current_prn_length_samples; - d_rem_carr_phase_rad = fmod(d_rem_carr_phase_rad, GPS_TWO_PI); + d_rem_carr_phase_rad = fmod(d_rem_carr_phase_rad, GLONASS_TWO_PI); // carrier phase accumulator - d_acc_carrier_phase_rad -= d_carrier_phase_step_rad * d_current_prn_length_samples; + d_acc_carrier_phase_rad -= d_carrier_doppler_phase_step_rad * d_current_prn_length_samples; //################### DLL COMMANDS ################################################# // code phase step (Code resampler phase increment per sample) [chips/sample] @@ -605,7 +612,7 @@ int Gps_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribute__( d_rem_code_phase_chips = d_code_freq_chips * (d_rem_code_phase_samples / static_cast(d_fs_in)); // ####### CN0 ESTIMATION AND LOCK DETECTORS ###### - if (d_cn0_estimation_counter < FLAGS_cn0_samples) + if (d_cn0_estimation_counter < CN0_ESTIMATION_SAMPLES) { // fill buffer with prompt correlator output values d_Prompt_buffer[d_cn0_estimation_counter] = d_correlator_outs[1]; //prompt @@ -615,9 +622,9 @@ int Gps_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribute__( { d_cn0_estimation_counter = 0; // Code lock indicator - d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer, FLAGS_cn0_samples, d_fs_in, GPS_L1_CA_CODE_LENGTH_CHIPS); + d_CN0_SNV_dB_Hz = cn0_svn_estimator(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES, d_fs_in, GLONASS_L2_CA_CODE_LENGTH_CHIPS); // Carrier lock indicator - d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, FLAGS_cn0_samples); + d_carrier_lock_test = carrier_lock_detector(d_Prompt_buffer, CN0_ESTIMATION_SAMPLES); // Loss of lock detection if (d_carrier_lock_test < d_carrier_lock_threshold or d_CN0_SNV_dB_Hz < FLAGS_cn0_min) { @@ -655,7 +662,7 @@ int Gps_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribute__( } current_synchro_data.Tracking_sample_counter = d_sample_counter + d_current_prn_length_samples; - current_synchro_data.System = {'G'}; + current_synchro_data.System = {'R'}; current_synchro_data.correlation_length_ms = 1; } @@ -668,8 +675,9 @@ int Gps_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribute__( float prompt_I; float prompt_Q; float tmp_E, tmp_P, tmp_L; - double tmp_double; - unsigned long int tmp_long; + float tmp_float; + float tmp_VE = 0.0; + float tmp_VL = 0.0; prompt_I = d_correlator_outs[1].real(); prompt_Q = d_correlator_outs[1].imag(); tmp_E = std::abs(d_correlator_outs[0]); @@ -677,41 +685,45 @@ int Gps_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribute__( tmp_L = std::abs(d_correlator_outs[2]); try { - // EPR + // Dump correlators output + d_dump_file.write(reinterpret_cast(&tmp_VE), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_E), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_P), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_L), sizeof(float)); + d_dump_file.write(reinterpret_cast(&tmp_VL), sizeof(float)); // PROMPT I and Q (to analyze navigation symbols) d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); // PRN start sample stamp - tmp_long = d_sample_counter + d_current_prn_length_samples; - d_dump_file.write(reinterpret_cast(&tmp_long), sizeof(unsigned long int)); + d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); // accumulated carrier phase - d_dump_file.write(reinterpret_cast(&d_acc_carrier_phase_rad), sizeof(double)); - + tmp_float = d_acc_carrier_phase_rad; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // carrier and code frequency - d_dump_file.write(reinterpret_cast(&d_carrier_doppler_hz), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_code_freq_chips), sizeof(double)); - + tmp_float = d_carrier_doppler_hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_code_freq_chips; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // PLL commands - d_dump_file.write(reinterpret_cast(&carr_error_hz), sizeof(double)); - d_dump_file.write(reinterpret_cast(&carr_error_filt_hz), sizeof(double)); - + tmp_float = carr_error_hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = carr_error_filt_hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // DLL commands - d_dump_file.write(reinterpret_cast(&code_error_chips), sizeof(double)); - d_dump_file.write(reinterpret_cast(&code_error_filt_chips), sizeof(double)); - + tmp_float = code_error_chips; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = code_error_filt_chips; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // CN0 and carrier lock test - d_dump_file.write(reinterpret_cast(&d_CN0_SNV_dB_Hz), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_carrier_lock_test), sizeof(double)); - + tmp_float = d_CN0_SNV_dB_Hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_carrier_lock_test; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // AUX vars (for debug purposes) - tmp_double = d_rem_code_phase_samples; + tmp_float = d_rem_code_phase_samples; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + double tmp_double = static_cast(d_sample_counter + d_current_prn_length_samples); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = static_cast(d_sample_counter); - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - // PRN unsigned int prn_ = d_acquisition_gnss_synchro->PRN; d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); @@ -724,19 +736,11 @@ int Gps_L1_Ca_Dll_Pll_Tracking_cc::general_work(int noutput_items __attribute__( consume_each(d_current_prn_length_samples); // this is necessary in gr::block derivates d_sample_counter += d_current_prn_length_samples; // count for the processed samples - - if (current_synchro_data.Flag_valid_symbol_output) - { - return 1; - } - else - { - return 0; - } + return 1; // output tracking result ALWAYS even in the case of d_enable_tracking==false } -void Gps_L1_Ca_Dll_Pll_Tracking_cc::set_channel(unsigned int channel) +void Glonass_L2_Ca_Dll_Pll_Tracking_cc::set_channel(unsigned int channel) { d_channel = channel; LOG(INFO) << "Tracking Channel set to " << d_channel; @@ -762,7 +766,7 @@ void Gps_L1_Ca_Dll_Pll_Tracking_cc::set_channel(unsigned int channel) } -void Gps_L1_Ca_Dll_Pll_Tracking_cc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) +void Glonass_L2_Ca_Dll_Pll_Tracking_cc::set_gnss_synchro(Gnss_Synchro *p_gnss_synchro) { d_acquisition_gnss_synchro = p_gnss_synchro; } diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.h b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.h similarity index 77% rename from src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.h rename to src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.h index 575b4feb4..b8fcc48f9 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_cc.h +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_tracking_cc.h @@ -1,18 +1,17 @@ /*! - * \file gps_l1_ca_dll_pll_tracking_cc.h - * \brief Interface of a code DLL + carrier PLL tracking block - * \author Carlos Aviles, 2010. carlos.avilesr(at)googlemail.com - * Javier Arribas, 2011. jarribas(at)cttc.es - * Cillian O'Driscoll, 2017. cillian.odriscoll(at)gmail.com + * \file glonass_l2_ca_dll_pll_tracking_cc.h + * \brief Implementation of a code DLL + carrier PLL tracking block + * \author Damian Miralles, 2018. dmiralles2009(at)gmail.com + * * * Code DLL + carrier PLL according to the algorithms described in: * K.Borre, D.M.Akos, N.Bertelsen, P.Rinder, and S.H.Jensen, - * A Software-Defined GPS and Galileo Receiver. A Single-Frequency Approach, - * Birkhauser, 2007 + * A Software-Defined GPS and Galileo Receiver. A Single-Frequency + * Approach, Birkha user, 2007 * * ------------------------------------------------------------------------- * - * Copyright (C) 2010-2015 (see AUTHORS file for a list of contributors) + * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) * * GNSS-SDR is a software defined Global Navigation * Satellite Systems receiver @@ -35,25 +34,25 @@ * ------------------------------------------------------------------------- */ -#ifndef GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_CC_H -#define GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_CC_H +#ifndef GNSS_SDR_GLONASS_L2_CA_DLL_PLL_TRACKING_CC_H +#define GNSS_SDR_GLONASS_L2_CA_DLL_PLL_TRACKING_CC_H #include "gnss_synchro.h" #include "tracking_2nd_DLL_filter.h" #include "tracking_2nd_PLL_filter.h" -#include "cpu_multicorrelator_real_codes.h" +#include "cpu_multicorrelator.h" #include #include #include #include -class Gps_L1_Ca_Dll_Pll_Tracking_cc; +class Glonass_L2_Ca_Dll_Pll_Tracking_cc; -typedef boost::shared_ptr - gps_l1_ca_dll_pll_tracking_cc_sptr; +typedef boost::shared_ptr + glonass_l2_ca_dll_pll_tracking_cc_sptr; -gps_l1_ca_dll_pll_tracking_cc_sptr -gps_l1_ca_dll_pll_make_tracking_cc(long if_freq, +glonass_l2_ca_dll_pll_tracking_cc_sptr +glonass_l2_ca_dll_pll_make_tracking_cc(long if_freq, long fs_in, unsigned int vector_length, bool dump, std::string dump_filename, @@ -65,10 +64,10 @@ gps_l1_ca_dll_pll_make_tracking_cc(long if_freq, /*! * \brief This class implements a DLL + PLL tracking loop block */ -class Gps_L1_Ca_Dll_Pll_Tracking_cc : public gr::block +class Glonass_L2_Ca_Dll_Pll_Tracking_cc : public gr::block { public: - ~Gps_L1_Ca_Dll_Pll_Tracking_cc(); + ~Glonass_L2_Ca_Dll_Pll_Tracking_cc(); void set_channel(unsigned int channel); void set_gnss_synchro(Gnss_Synchro* p_gnss_synchro); @@ -80,8 +79,8 @@ public: void forecast(int noutput_items, gr_vector_int& ninput_items_required); private: - friend gps_l1_ca_dll_pll_tracking_cc_sptr - gps_l1_ca_dll_pll_make_tracking_cc(long if_freq, + friend glonass_l2_ca_dll_pll_tracking_cc_sptr + glonass_l2_ca_dll_pll_make_tracking_cc(long if_freq, long fs_in, unsigned int vector_length, bool dump, std::string dump_filename, @@ -89,7 +88,7 @@ private: float dll_bw_hz, float early_late_space_chips); - Gps_L1_Ca_Dll_Pll_Tracking_cc(long if_freq, + Glonass_L2_Ca_Dll_Pll_Tracking_cc(long if_freq, long fs_in, unsigned int vector_length, bool dump, std::string dump_filename, @@ -97,7 +96,6 @@ private: float dll_bw_hz, float early_late_space_chips); - int save_matfile(); // tracking configuration vars unsigned int d_vector_length; bool d_dump; @@ -107,6 +105,7 @@ private: long d_if_freq; long d_fs_in; + long d_glonass_freq_ch; double d_early_late_spc_chips; @@ -124,15 +123,18 @@ private: double d_acq_carrier_doppler_hz; // correlator int d_n_correlator_taps; - float* d_ca_code; + gr_complex* d_ca_code; float* d_local_code_shift_chips; gr_complex* d_correlator_outs; - cpu_multicorrelator_real_codes multicorrelator_cpu; + cpu_multicorrelator multicorrelator_cpu; + // tracking vars double d_code_freq_chips; double d_code_phase_step_chips; double d_carrier_doppler_hz; + double d_carrier_doppler_phase_step_rad; + double d_carrier_frequency_hz; double d_carrier_phase_step_rad; double d_acc_carrier_phase_rad; double d_code_phase_samples; @@ -162,6 +164,8 @@ private: std::map systemName; std::string sys; + + int save_matfile(); }; -#endif //GNSS_SDR_GPS_L1_CA_DLL_PLL_TRACKING_CC_H +#endif //GNSS_SDR_GLONASS_L2_CA_DLL_PLL_TRACKING_CC_H 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 f207d25a4..c242a10b8 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 @@ -587,7 +587,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __attrib d_code_phase_step_chips, d_correlation_length_samples); - // ####### coherent intergration extension + // ####### coherent integration extension // keep the last symbols d_E_history.push_back(d_correlator_outs[0]); // save early output d_P_history.push_back(d_correlator_outs[1]); // save prompt output @@ -701,7 +701,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __attrib d_code_error_filt_chips_Ti = d_code_error_filt_chips_s * CURRENT_INTEGRATION_TIME_S; code_error_filt_secs_Ti = d_code_error_filt_chips_Ti / d_code_freq_chips; // [s/Ti] - // ################## CARRIER AND CODE NCO BUFFER ALIGNEMENT ####################### + // ################## CARRIER AND CODE NCO BUFFER ALIGNMENT ####################### // keep alignment parameters for the next input buffer // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation double T_chip_seconds = 1.0 / d_code_freq_chips; @@ -810,7 +810,9 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __attrib float prompt_I; float prompt_Q; float tmp_E, tmp_P, tmp_L; - double tmp_double; + float tmp_VE = 0.0; + float tmp_VL = 0.0; + float tmp_float; prompt_I = d_correlator_outs[1].real(); prompt_Q = d_correlator_outs[1].imag(); tmp_E = std::abs(d_correlator_outs[0]); @@ -818,41 +820,45 @@ int gps_l1_ca_dll_pll_c_aid_tracking_cc::general_work(int noutput_items __attrib tmp_L = std::abs(d_correlator_outs[2]); try { - // EPR + // Dump correlators output + d_dump_file.write(reinterpret_cast(&tmp_VE), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_E), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_P), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_L), sizeof(float)); + d_dump_file.write(reinterpret_cast(&tmp_VL), sizeof(float)); // PROMPT I and Q (to analyze navigation symbols) d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); // PRN start sample stamp - //tmp_float=(float)d_sample_counter; d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); // accumulated carrier phase - d_dump_file.write(reinterpret_cast(&d_acc_carrier_phase_cycles), sizeof(double)); - + tmp_float = d_acc_carrier_phase_cycles * GPS_TWO_PI; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // carrier and code frequency - d_dump_file.write(reinterpret_cast(&d_carrier_doppler_hz), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_code_freq_chips), sizeof(double)); - - //PLL commands - d_dump_file.write(reinterpret_cast(&d_carr_phase_error_secs_Ti), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_carrier_doppler_hz), sizeof(double)); - - //DLL commands - d_dump_file.write(reinterpret_cast(&d_code_error_chips_Ti), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_code_error_filt_chips_Ti), sizeof(double)); - + tmp_float = d_carrier_doppler_hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_code_freq_chips; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // PLL commands + tmp_float = 1.0 / (d_carr_phase_error_secs_Ti * CURRENT_INTEGRATION_TIME_S); + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = 1.0 / (d_code_error_filt_chips_Ti * CURRENT_INTEGRATION_TIME_S);; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // DLL commands + tmp_float = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_code_error_filt_chips_Ti; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // CN0 and carrier lock test - d_dump_file.write(reinterpret_cast(&d_CN0_SNV_dB_Hz), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_carrier_lock_test), sizeof(double)); - + tmp_float = d_CN0_SNV_dB_Hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_carrier_lock_test; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // AUX vars (for debug purposes) - tmp_double = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; + tmp_float = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + double tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - // PRN unsigned int prn_ = d_acquisition_gnss_synchro->PRN; d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc.cc index 827743c63..1d1561a21 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc.cc @@ -387,7 +387,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::general_work( d_rem_code_phase_chips, d_code_phase_step_chips, d_correlation_length_samples); - // ####### coherent intergration extension + // ####### coherent integration extension // keep the last symbols d_E_history.push_back(d_correlator_outs_16sc[0]); // save early output d_P_history.push_back(d_correlator_outs_16sc[1]); // save prompt output @@ -517,7 +517,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::general_work( d_code_error_filt_chips_Ti = d_code_error_filt_chips_s * CURRENT_INTEGRATION_TIME_S; code_error_filt_secs_Ti = d_code_error_filt_chips_Ti / d_code_freq_chips; // [s/Ti] - // ################## CARRIER AND CODE NCO BUFFER ALIGNEMENT ####################### + // ################## CARRIER AND CODE NCO BUFFER ALIGNMENT ####################### // keep alignment parameters for the next input buffer // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation double T_chip_seconds = 1.0 / d_code_freq_chips; @@ -632,49 +632,55 @@ int gps_l1_ca_dll_pll_c_aid_tracking_fpga_sc::general_work( float prompt_I; float prompt_Q; float tmp_E, tmp_P, tmp_L; - double tmp_double; + float tmp_VE = 0.0; + float tmp_VL = 0.0; + float tmp_float; prompt_I = d_correlator_outs_16sc[1].real(); prompt_Q = d_correlator_outs_16sc[1].imag(); - tmp_E = std::abs(std::complex(d_correlator_outs_16sc[0].real(), d_correlator_outs_16sc[0].imag())); - tmp_P = std::abs(std::complex(d_correlator_outs_16sc[1].real(), d_correlator_outs_16sc[1].imag())); - tmp_L = std::abs(std::complex(d_correlator_outs_16sc[2].real(), d_correlator_outs_16sc[2].imag())); + tmp_E = std::abs(gr_complex(d_correlator_outs_16sc[0].real(), d_correlator_outs_16sc[0].imag())); + tmp_P = std::abs(gr_complex(d_correlator_outs_16sc[1].real(), d_correlator_outs_16sc[1].imag())); + tmp_L = std::abs(gr_complex(d_correlator_outs_16sc[2].real(), d_correlator_outs_16sc[2].imag())); try { - // EPR + // Dump correlators output + d_dump_file.write(reinterpret_cast(&tmp_VE), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_E), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_P), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_L), sizeof(float)); + d_dump_file.write(reinterpret_cast(&tmp_VL), sizeof(float)); // PROMPT I and Q (to analyze navigation symbols) d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); // PRN start sample stamp - //tmp_float=(float)d_sample_counter; d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); // accumulated carrier phase - d_dump_file.write(reinterpret_cast(&d_acc_carrier_phase_cycles), sizeof(double)); - + tmp_float = d_acc_carrier_phase_cycles * GPS_TWO_PI; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // carrier and code frequency - d_dump_file.write(reinterpret_cast(&d_carrier_doppler_hz), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_code_freq_chips), sizeof(double)); - - //PLL commands - d_dump_file.write(reinterpret_cast(&d_carr_phase_error_secs_Ti), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_carrier_doppler_hz), sizeof(double)); - - //DLL commands - d_dump_file.write(reinterpret_cast(&d_code_error_chips_Ti), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_code_error_filt_chips_Ti), sizeof(double)); - + tmp_float = d_carrier_doppler_hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_code_freq_chips; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // PLL commands + tmp_float = 1.0 / (d_carr_phase_error_secs_Ti * CURRENT_INTEGRATION_TIME_S); + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = 1.0 / (d_code_error_filt_chips_Ti * CURRENT_INTEGRATION_TIME_S); + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // DLL commands + tmp_float = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_code_error_filt_chips_Ti; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // CN0 and carrier lock test - d_dump_file.write(reinterpret_cast(&d_CN0_SNV_dB_Hz), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_carrier_lock_test), sizeof(double)); - + tmp_float = d_CN0_SNV_dB_Hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_carrier_lock_test; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // AUX vars (for debug purposes) - tmp_double = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; + tmp_float = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + double tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - // PRN unsigned int prn_ = d_acquisition_gnss_synchro->PRN; d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); 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 b2be59bae..9a4332f06 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 @@ -590,7 +590,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __attrib d_code_phase_step_chips, d_correlation_length_samples); - // ####### coherent intergration extension + // ####### coherent integration extension // keep the last symbols d_E_history.push_back(d_correlator_outs_16sc[0]); // save early output d_P_history.push_back(d_correlator_outs_16sc[1]); // save prompt output @@ -703,7 +703,7 @@ int gps_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __attrib d_code_error_filt_chips_Ti = d_code_error_filt_chips_s * CURRENT_INTEGRATION_TIME_S; code_error_filt_secs_Ti = d_code_error_filt_chips_Ti / d_code_freq_chips; // [s/Ti] - // ################## CARRIER AND CODE NCO BUFFER ALIGNEMENT ####################### + // ################## CARRIER AND CODE NCO BUFFER ALIGNMENT ####################### // keep alignment parameters for the next input buffer // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation double T_chip_seconds = 1.0 / d_code_freq_chips; @@ -812,49 +812,55 @@ int gps_l1_ca_dll_pll_c_aid_tracking_sc::general_work(int noutput_items __attrib float prompt_I; float prompt_Q; float tmp_E, tmp_P, tmp_L; - double tmp_double; + float tmp_VE = 0.0; + float tmp_VL = 0.0; + float tmp_float; prompt_I = d_correlator_outs_16sc[1].real(); prompt_Q = d_correlator_outs_16sc[1].imag(); - tmp_E = std::abs(std::complex(d_correlator_outs_16sc[0].real(), d_correlator_outs_16sc[0].imag())); - tmp_P = std::abs(std::complex(d_correlator_outs_16sc[1].real(), d_correlator_outs_16sc[1].imag())); - tmp_L = std::abs(std::complex(d_correlator_outs_16sc[2].real(), d_correlator_outs_16sc[2].imag())); + tmp_E = std::abs(gr_complex(d_correlator_outs_16sc[0].real(), d_correlator_outs_16sc[0].imag())); + tmp_P = std::abs(gr_complex(d_correlator_outs_16sc[1].real(), d_correlator_outs_16sc[1].imag())); + tmp_L = std::abs(gr_complex(d_correlator_outs_16sc[2].real(), d_correlator_outs_16sc[2].imag())); try { - // EPR + // Dump correlators output + d_dump_file.write(reinterpret_cast(&tmp_VE), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_E), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_P), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_L), sizeof(float)); + d_dump_file.write(reinterpret_cast(&tmp_VL), sizeof(float)); // PROMPT I and Q (to analyze navigation symbols) d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); // PRN start sample stamp - //tmp_float=(float)d_sample_counter; d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); // accumulated carrier phase - d_dump_file.write(reinterpret_cast(&d_acc_carrier_phase_cycles), sizeof(double)); - + tmp_float = d_acc_carrier_phase_cycles * GPS_TWO_PI; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // carrier and code frequency - d_dump_file.write(reinterpret_cast(&d_carrier_doppler_hz), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_code_freq_chips), sizeof(double)); - - //PLL commands - d_dump_file.write(reinterpret_cast(&d_carr_phase_error_secs_Ti), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_carrier_doppler_hz), sizeof(double)); - - //DLL commands - d_dump_file.write(reinterpret_cast(&d_code_error_chips_Ti), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_code_error_filt_chips_Ti), sizeof(double)); - + tmp_float = d_carrier_doppler_hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_code_freq_chips; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // PLL commands + tmp_float = 1.0 / (d_carr_phase_error_secs_Ti * CURRENT_INTEGRATION_TIME_S); + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = 1.0 / (d_code_error_filt_chips_Ti * CURRENT_INTEGRATION_TIME_S); + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // DLL commands + tmp_float = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_code_error_filt_chips_Ti; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // CN0 and carrier lock test - d_dump_file.write(reinterpret_cast(&d_CN0_SNV_dB_Hz), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_carrier_lock_test), sizeof(double)); - + tmp_float = d_CN0_SNV_dB_Hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_carrier_lock_test; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // AUX vars (for debug purposes) - tmp_double = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; + tmp_float = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + double tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - // PRN unsigned int prn_ = d_acquisition_gnss_synchro->PRN; d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.cc index 2c8a688cb..759128d0b 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l1_ca_dll_pll_tracking_gpu_cc.cc @@ -368,7 +368,7 @@ int Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::general_work(int noutput_items __attribut // TODO: PLL carrier aid to DLL is disabled. Re-enable it and measure performance dll_code_error_secs_Ti = -code_error_filt_secs_Ti + d_pll_to_dll_assist_secs_Ti; - // ################## CARRIER AND CODE NCO BUFFER ALIGNEMENT ####################### + // ################## CARRIER AND CODE NCO BUFFER ALIGNMENT ####################### // keep alignment parameters for the next input buffer double T_chip_seconds; double T_prn_seconds; @@ -468,7 +468,9 @@ int Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::general_work(int noutput_items __attribut float prompt_I; float prompt_Q; float tmp_E, tmp_P, tmp_L; - double tmp_double; + float tmp_VE = 0.0; + float tmp_VL = 0.0; + float tmp_float; prompt_I = d_correlator_outs[1].real(); prompt_Q = d_correlator_outs[1].imag(); tmp_E = std::abs(d_correlator_outs[0]); @@ -476,41 +478,45 @@ int Gps_L1_Ca_Dll_Pll_Tracking_GPU_cc::general_work(int noutput_items __attribut tmp_L = std::abs(d_correlator_outs[2]); try { - // EPR + // Dump correlators output + d_dump_file.write(reinterpret_cast(&tmp_VE), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_E), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_P), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_L), sizeof(float)); + d_dump_file.write(reinterpret_cast(&tmp_VL), sizeof(float)); // PROMPT I and Q (to analyze navigation symbols) d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); // PRN start sample stamp - //tmp_float=(float)d_sample_counter; d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); // accumulated carrier phase - d_dump_file.write(reinterpret_cast(&d_acc_carrier_phase_cycles), sizeof(double)); - + tmp_float = d_acc_carrier_phase_cycles * GPS_TWO_PI; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // carrier and code frequency - d_dump_file.write(reinterpret_cast(&d_carrier_doppler_hz), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_code_freq_chips), sizeof(double)); - - //PLL commands - d_dump_file.write(reinterpret_cast(&carr_phase_error_secs_Ti), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_carrier_doppler_hz), sizeof(double)); - - //DLL commands - d_dump_file.write(reinterpret_cast(&code_error_chips_Ti), sizeof(double)); - d_dump_file.write(reinterpret_cast(&code_error_filt_chips), sizeof(double)); - + tmp_float = d_carrier_doppler_hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_code_freq_chips; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // PLL commands + tmp_float = 1.0 / (d_carr_phase_error_secs_Ti * CURRENT_INTEGRATION_TIME_S); + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = 1.0 / (d_code_error_filt_chips_Ti * CURRENT_INTEGRATION_TIME_S); + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // DLL commands + tmp_float = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_code_error_filt_chips_Ti; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // CN0 and carrier lock test - d_dump_file.write(reinterpret_cast(&d_CN0_SNV_dB_Hz), sizeof(double)); - d_dump_file.write(reinterpret_cast(&d_carrier_lock_test), sizeof(double)); - + tmp_float = d_CN0_SNV_dB_Hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_carrier_lock_test; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); // AUX vars (for debug purposes) - tmp_double = d_rem_code_phase_samples; + tmp_float = d_code_error_chips_Ti * CURRENT_INTEGRATION_TIME_S; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + double tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); - d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); - // PRN unsigned int prn_ = d_acquisition_gnss_synchro->PRN; d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); 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 560e05031..f4fe4c018 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 @@ -333,7 +333,7 @@ int Gps_L1_Ca_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attrib d_sample_counter_seconds = d_sample_counter_seconds + (static_cast(samples_offset) / static_cast(d_fs_in)); d_sample_counter = d_sample_counter + samples_offset; //count for the processed samples d_pull_in = false; - consume_each(samples_offset); //shift input to perform alignement with local replica + consume_each(samples_offset); //shift input to perform alignment with local replica return 1; } @@ -482,48 +482,55 @@ int Gps_L1_Ca_Tcp_Connector_Tracking_cc::general_work(int noutput_items __attrib float prompt_I; float prompt_Q; float tmp_E, tmp_P, tmp_L; + float tmp_VE = 0.0; + float tmp_VL = 0.0; float tmp_float; - prompt_I = (*d_Prompt).real(); - prompt_Q = (*d_Prompt).imag(); - tmp_E = std::abs(*d_Early); - tmp_P = std::abs(*d_Prompt); - tmp_L = std::abs(*d_Late); + prompt_I = d_correlator_outs[1].real(); + prompt_Q = d_correlator_outs[1].imag(); + tmp_E = std::abs(d_correlator_outs[0]); + tmp_P = std::abs(d_correlator_outs[1]); + tmp_L = std::abs(d_correlator_outs[2]); try { - // EPR + // Dump correlators output + d_dump_file.write(reinterpret_cast(&tmp_VE), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_E), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_P), sizeof(float)); d_dump_file.write(reinterpret_cast(&tmp_L), sizeof(float)); + d_dump_file.write(reinterpret_cast(&tmp_VL), sizeof(float)); // PROMPT I and Q (to analyze navigation symbols) d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); // PRN start sample stamp - //tmp_float=(float)d_sample_counter; d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); // accumulated carrier phase - d_dump_file.write(reinterpret_cast(&d_acc_carrier_phase_rad), sizeof(float)); - - // carrier and code frequency - d_dump_file.write(reinterpret_cast(&d_carrier_doppler_hz), sizeof(float)); - d_dump_file.write(reinterpret_cast(&d_code_freq_hz), sizeof(float)); - - //PLL commands - d_dump_file.write(reinterpret_cast(&carr_error), sizeof(float)); - d_dump_file.write(reinterpret_cast(&carr_nco), sizeof(float)); - - //DLL commands - d_dump_file.write(reinterpret_cast(&code_error), sizeof(float)); - d_dump_file.write(reinterpret_cast(&code_nco), sizeof(float)); - - // CN0 and carrier lock test - d_dump_file.write(reinterpret_cast(&d_CN0_SNV_dB_Hz), sizeof(float)); - d_dump_file.write(reinterpret_cast(&d_carrier_lock_test), sizeof(float)); - - // AUX vars (for debug purposes) - tmp_float = 0; + tmp_float = d_acc_carrier_phase_rad; d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); - d_dump_file.write(reinterpret_cast(&d_sample_counter_seconds), sizeof(double)); - + // carrier and code frequency + tmp_float = d_carrier_doppler_hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_code_freq_hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // PLL commands + tmp_float = 0.0; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = carr_error; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // DLL commands + tmp_float = 0.0; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = code_error; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // CN0 and carrier lock test + tmp_float = d_CN0_SNV_dB_Hz; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + tmp_float = d_carrier_lock_test; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + // AUX vars (for debug purposes) + tmp_float = 0.0; + d_dump_file.write(reinterpret_cast(&tmp_float), sizeof(float)); + double tmp_double = static_cast(d_sample_counter + d_correlation_length_samples); + d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); // PRN unsigned int prn_ = d_acquisition_gnss_synchro->PRN; d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l2_m_dll_pll_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l2_m_dll_pll_tracking_cc.cc index a10302d18..7d53de441 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l2_m_dll_pll_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l2_m_dll_pll_tracking_cc.cc @@ -579,7 +579,7 @@ int gps_l2_m_dll_pll_tracking_cc::general_work(int noutput_items __attribute__(( double code_error_filt_secs = (T_prn_seconds * code_error_filt_chips * T_chip_seconds); //[seconds] //double code_error_filt_secs = (GPS_L2_M_PERIOD * code_error_filt_chips) / GPS_L2_M_CODE_RATE_HZ; //[seconds] - // ################## CARRIER AND CODE NCO BUFFER ALIGNEMENT ####################### + // ################## CARRIER AND CODE NCO BUFFER ALIGNMENT ####################### // keep alignment parameters for the next input buffer // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation double T_prn_samples = T_prn_seconds * static_cast(d_fs_in); diff --git a/src/algorithms/tracking/gnuradio_blocks/gps_l5i_dll_pll_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/gps_l5i_dll_pll_tracking_cc.cc index 9966dc719..ad18db9cd 100644 --- a/src/algorithms/tracking/gnuradio_blocks/gps_l5i_dll_pll_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/gps_l5i_dll_pll_tracking_cc.cc @@ -580,7 +580,7 @@ int gps_l5i_dll_pll_tracking_cc::general_work(int noutput_items __attribute__((u double code_error_filt_secs = (T_prn_seconds * code_error_filt_chips * T_chip_seconds); //[seconds] //double code_error_filt_secs = (GPS_L5i_PERIOD * code_error_filt_chips) / GPS_L5i_CODE_RATE_HZ; //[seconds] - // ################## CARRIER AND CODE NCO BUFFER ALIGNEMENT ####################### + // ################## CARRIER AND CODE NCO BUFFER ALIGNMENT ####################### // keep alignment parameters for the next input buffer // Compute the next buffer length based in the new period of the PRN sequence and the code phase error estimation double T_prn_samples = T_prn_seconds * static_cast(d_fs_in); diff --git a/src/algorithms/tracking/libs/cpu_multicorrelator_real_codes.cc b/src/algorithms/tracking/libs/cpu_multicorrelator_real_codes.cc index 5de891064..6fa82351c 100644 --- a/src/algorithms/tracking/libs/cpu_multicorrelator_real_codes.cc +++ b/src/algorithms/tracking/libs/cpu_multicorrelator_real_codes.cc @@ -122,7 +122,7 @@ bool cpu_multicorrelator_real_codes::Carrier_wipeoff_multicorrelator_resampler( lv_32fc_t phase_offset_as_complex[1]; phase_offset_as_complex[0] = lv_cmake(std::cos(rem_carrier_phase_in_rad), -std::sin(rem_carrier_phase_in_rad)); // call VOLK_GNSSSDR kernel - volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn(d_corr_out, d_sig_in, std::exp(lv_32fc_t(0, -phase_step_rad)), phase_offset_as_complex, (const float**)d_local_codes_resampled, d_n_correlators, signal_length_samples); + volk_gnsssdr_32fc_32f_rotator_dot_prod_32fc_xn(d_corr_out, d_sig_in, std::exp(lv_32fc_t(0.0, -phase_step_rad)), phase_offset_as_complex, const_cast(d_local_codes_resampled), d_n_correlators, signal_length_samples); return true; } diff --git a/src/algorithms/tracking/libs/fpga_multicorrelator_8sc.cc b/src/algorithms/tracking/libs/fpga_multicorrelator_8sc.cc index f04d1bb6c..9af959232 100644 --- a/src/algorithms/tracking/libs/fpga_multicorrelator_8sc.cc +++ b/src/algorithms/tracking/libs/fpga_multicorrelator_8sc.cc @@ -136,7 +136,7 @@ bool fpga_multicorrelator_8sc::Carrier_wipeoff_multicorrelator_resampler( nb = read(d_device_descriptor, &irq_count, sizeof(irq_count)); if (nb != sizeof(irq_count)) { - printf("Tracking_module Read failed to retrive 4 bytes!\n"); + printf("Tracking_module Read failed to retrieve 4 bytes!\n"); printf("Tracking_module Interrupt number %d\n", irq_count); } diff --git a/src/algorithms/tracking/libs/lock_detectors.cc b/src/algorithms/tracking/libs/lock_detectors.cc index 331391978..4457e361f 100644 --- a/src/algorithms/tracking/libs/lock_detectors.cc +++ b/src/algorithms/tracking/libs/lock_detectors.cc @@ -67,20 +67,20 @@ */ float cn0_svn_estimator(gr_complex* Prompt_buffer, int length, long fs_in, double code_length) { - double SNR = 0; - double SNR_dB_Hz = 0; - double Psig = 0; - double Ptot = 0; + double SNR = 0.0; + double SNR_dB_Hz = 0.0; + double Psig = 0.0; + double Ptot = 0.0; for (int i = 0; i < length; i++) { Psig += std::abs(static_cast(Prompt_buffer[i].real())); Ptot += static_cast(Prompt_buffer[i].imag()) * static_cast(Prompt_buffer[i].imag()) + static_cast(Prompt_buffer[i].real()) * static_cast(Prompt_buffer[i].real()); } - Psig = Psig / static_cast(length); + Psig /= static_cast(length); Psig = Psig * Psig; - Ptot = Ptot / static_cast(length); + Ptot /= static_cast(length); SNR = Psig / (Ptot - Psig); - SNR_dB_Hz = 10 * log10(SNR) + 10 * log10(static_cast(fs_in) / 2) - 10 * log10(code_length); + SNR_dB_Hz = 10.0 * log10(SNR) + 10.0 * log10(static_cast(fs_in) / 2.0) - 10.0 * log10(code_length); return static_cast(SNR_dB_Hz); } @@ -96,10 +96,10 @@ float cn0_svn_estimator(gr_complex* Prompt_buffer, int length, long fs_in, doubl */ float carrier_lock_detector(gr_complex* Prompt_buffer, int length) { - float tmp_sum_I = 0; - float tmp_sum_Q = 0; - float NBD = 0; - float NBP = 0; + float tmp_sum_I = 0.0; + float tmp_sum_Q = 0.0; + float NBD = 0.0; + float NBP = 0.0; for (int i = 0; i < length; i++) { tmp_sum_I += Prompt_buffer[i].real(); diff --git a/src/algorithms/tracking/libs/tracking_2nd_DLL_filter.cc b/src/algorithms/tracking/libs/tracking_2nd_DLL_filter.cc index fe234322e..3c9fdb117 100644 --- a/src/algorithms/tracking/libs/tracking_2nd_DLL_filter.cc +++ b/src/algorithms/tracking/libs/tracking_2nd_DLL_filter.cc @@ -41,11 +41,10 @@ void Tracking_2nd_DLL_filter::calculate_lopp_coef(float* tau1, float* tau2, float lbw, float zeta, float k) { // Solve natural frequency - float Wn; - Wn = lbw * 8 * zeta / (4 * zeta * zeta + 1); + float Wn = lbw * 8.0 * zeta / (4.0 * zeta * zeta + 1.0); // solve for t1 & t2 *tau1 = k / (Wn * Wn); - *tau2 = (2.0 * zeta) / Wn; + *tau2 = 2.0 * zeta / Wn; } @@ -67,9 +66,7 @@ void Tracking_2nd_DLL_filter::initialize() float Tracking_2nd_DLL_filter::get_code_nco(float DLL_discriminator) { - float code_nco; - code_nco = d_old_code_nco + (d_tau2_code / d_tau1_code) * (DLL_discriminator - d_old_code_error) + (DLL_discriminator + d_old_code_error) * (d_pdi_code / (2 * d_tau1_code)); - //code_nco = d_old_code_nco + (d_tau2_code/d_tau1_code)*(DLL_discriminator - d_old_code_error) + DLL_discriminator * (d_pdi_code/d_tau1_code); + float code_nco = d_old_code_nco + (d_tau2_code / d_tau1_code) * (DLL_discriminator - d_old_code_error) + (DLL_discriminator + d_old_code_error) * (d_pdi_code / (2.0 * d_tau1_code)); d_old_code_nco = code_nco; d_old_code_error = DLL_discriminator; //[chips] return code_nco; diff --git a/src/algorithms/tracking/libs/tracking_2nd_DLL_filter.h b/src/algorithms/tracking/libs/tracking_2nd_DLL_filter.h index 57660c682..62c570a21 100644 --- a/src/algorithms/tracking/libs/tracking_2nd_DLL_filter.h +++ b/src/algorithms/tracking/libs/tracking_2nd_DLL_filter.h @@ -49,13 +49,13 @@ class Tracking_2nd_DLL_filter { private: // PLL filter parameters - float d_tau1_code = 0; - float d_tau2_code = 0; - float d_pdi_code = 0; - float d_dllnoisebandwidth = 0; - float d_dlldampingratio = 0; - float d_old_code_error = 0; - float d_old_code_nco = 0; + float d_tau1_code = 0.0; + float d_tau2_code = 0.0; + float d_pdi_code = 0.0; + float d_dllnoisebandwidth = 0.0; + float d_dlldampingratio = 0.0; + float d_old_code_error = 0.0; + float d_old_code_nco = 0.0; void calculate_lopp_coef(float* tau1, float* tau2, float lbw, float zeta, float k); public: diff --git a/src/algorithms/tracking/libs/tracking_2nd_PLL_filter.cc b/src/algorithms/tracking/libs/tracking_2nd_PLL_filter.cc index 90ec3331f..b455ce546 100644 --- a/src/algorithms/tracking/libs/tracking_2nd_PLL_filter.cc +++ b/src/algorithms/tracking/libs/tracking_2nd_PLL_filter.cc @@ -40,11 +40,10 @@ void Tracking_2nd_PLL_filter::calculate_lopp_coef(float* tau1, float* tau2, float lbw, float zeta, float k) { // Solve natural frequency - float Wn; - Wn = lbw * 8 * zeta / (4 * zeta * zeta + 1); + float Wn = lbw * 8.0 * zeta / (4.0 * zeta * zeta + 1.0); // solve for t1 & t2 *tau1 = k / (Wn * Wn); - *tau2 = (2.0 * zeta) / Wn; + *tau2 = 2.0 * zeta / Wn; } @@ -71,8 +70,7 @@ void Tracking_2nd_PLL_filter::initialize() */ float Tracking_2nd_PLL_filter::get_carrier_nco(float PLL_discriminator) { - float carr_nco; - carr_nco = d_old_carr_nco + (d_tau2_carr / d_tau1_carr) * (PLL_discriminator - d_old_carr_error) + (PLL_discriminator + d_old_carr_error) * (d_pdi_carr / (2 * d_tau1_carr)); + float carr_nco = d_old_carr_nco + (d_tau2_carr / d_tau1_carr) * (PLL_discriminator - d_old_carr_error) + (PLL_discriminator + d_old_carr_error) * (d_pdi_carr / (2.0 * d_tau1_carr)); //carr_nco = d_old_carr_nco + (d_tau2_carr/d_tau1_carr)*(PLL_discriminator - d_old_carr_error) + PLL_discriminator * (d_pdi_carr/d_tau1_carr); d_old_carr_nco = carr_nco; d_old_carr_error = PLL_discriminator; diff --git a/src/algorithms/tracking/libs/tracking_2nd_PLL_filter.h b/src/algorithms/tracking/libs/tracking_2nd_PLL_filter.h index d02cc17df..833e8a2c6 100644 --- a/src/algorithms/tracking/libs/tracking_2nd_PLL_filter.h +++ b/src/algorithms/tracking/libs/tracking_2nd_PLL_filter.h @@ -48,15 +48,15 @@ class Tracking_2nd_PLL_filter { private: // PLL filter parameters - float d_tau1_carr = 0; - float d_tau2_carr = 0; - float d_pdi_carr = 0; + float d_tau1_carr = 0.0; + float d_tau2_carr = 0.0; + float d_pdi_carr = 0.0; - float d_pllnoisebandwidth = 0; - float d_plldampingratio = 0; + float d_pllnoisebandwidth = 0.0; + float d_plldampingratio = 0.0; - float d_old_carr_error = 0; - float d_old_carr_nco = 0; + float d_old_carr_error = 0.0; + float d_old_carr_nco = 0.0; void calculate_lopp_coef(float* tau1, float* tau2, float lbw, float zeta, float k); diff --git a/src/algorithms/tracking/libs/tracking_discriminators.cc b/src/algorithms/tracking/libs/tracking_discriminators.cc index d4c9b2a48..0ab876591 100644 --- a/src/algorithms/tracking/libs/tracking_discriminators.cc +++ b/src/algorithms/tracking/libs/tracking_discriminators.cc @@ -83,7 +83,7 @@ double pll_cloop_two_quadrant_atan(gr_complex prompt_s1) } else { - return 0; + return 0.0; } } @@ -107,7 +107,7 @@ double dll_nc_e_minus_l_normalized(gr_complex early_s1, gr_complex late_s1) } else { - return 0.5 * (P_early - P_late) / ((P_early + P_late)); + return 0.5 * (P_early - P_late) / (P_early + P_late); } } @@ -131,6 +131,6 @@ double dll_nc_vemlp_normalized(gr_complex very_early_s1, gr_complex early_s1, gr } else { - return (P_early - P_late) / ((P_early + P_late)); + return (P_early - P_late) / (P_early + P_late); } } diff --git a/src/algorithms/tracking/libs/tracking_loop_filter.cc b/src/algorithms/tracking/libs/tracking_loop_filter.cc index 2571202c3..156a60d92 100644 --- a/src/algorithms/tracking/libs/tracking_loop_filter.cc +++ b/src/algorithms/tracking/libs/tracking_loop_filter.cc @@ -37,9 +37,6 @@ #include -#define MAX_LOOP_ORDER 3 -#define MAX_HISTORY_LENGTH 4 - Tracking_loop_filter::Tracking_loop_filter(float update_interval, float noise_bandwidth, int loop_order, @@ -50,8 +47,8 @@ Tracking_loop_filter::Tracking_loop_filter(float update_interval, d_noise_bandwidth(noise_bandwidth), d_update_interval(update_interval) { - d_inputs.resize(MAX_HISTORY_LENGTH, 0.0); - d_outputs.resize(MAX_HISTORY_LENGTH, 0.0); + d_inputs.resize(MAX_LOOP_HISTORY_LENGTH, 0.0); + d_outputs.resize(MAX_LOOP_HISTORY_LENGTH, 0.0); update_coefficients(); } @@ -62,8 +59,8 @@ Tracking_loop_filter::Tracking_loop_filter() d_noise_bandwidth(15.0), d_update_interval(0.001) { - d_inputs.resize(MAX_HISTORY_LENGTH, 0.0); - d_outputs.resize(MAX_HISTORY_LENGTH, 0.0); + d_inputs.resize(MAX_LOOP_HISTORY_LENGTH, 0.0); + d_outputs.resize(MAX_LOOP_HISTORY_LENGTH, 0.0); update_coefficients(); } @@ -75,12 +72,12 @@ Tracking_loop_filter::~Tracking_loop_filter() float Tracking_loop_filter::apply(float current_input) { // Now apply the filter coefficients: - float result = 0; + float result = 0.0; // Hanlde the old outputs first: for (unsigned int ii = 0; ii < d_output_coefficients.size(); ++ii) { - result += d_output_coefficients[ii] * d_outputs[(d_current_index + ii) % MAX_HISTORY_LENGTH]; + result += d_output_coefficients[ii] * d_outputs[(d_current_index + ii) % MAX_LOOP_HISTORY_LENGTH]; } // Now update the index to handle the inputs. @@ -93,7 +90,7 @@ float Tracking_loop_filter::apply(float current_input) d_current_index--; if (d_current_index < 0) { - d_current_index += MAX_HISTORY_LENGTH; + d_current_index += MAX_LOOP_HISTORY_LENGTH; } d_inputs[d_current_index] = current_input; @@ -101,7 +98,7 @@ float Tracking_loop_filter::apply(float current_input) for (unsigned int ii = 0; ii < d_input_coefficients.size(); ++ii) { - result += d_input_coefficients[ii] * d_inputs[(d_current_index + ii) % MAX_HISTORY_LENGTH]; + result += d_input_coefficients[ii] * d_inputs[(d_current_index + ii) % MAX_LOOP_HISTORY_LENGTH]; } @@ -122,7 +119,7 @@ void Tracking_loop_filter::update_coefficients(void) float wn; float T = d_update_interval; - float zeta = 1 / std::sqrt(2); + float zeta = 1.0 / std::sqrt(2.0); // The following is based on the bilinear transform approximation of // the analog integrator. The loop format is from Kaplan & Hegarty @@ -146,7 +143,7 @@ void Tracking_loop_filter::update_coefficients(void) d_input_coefficients[1] = g1 * T / 2.0; d_output_coefficients.resize(1); - d_output_coefficients[0] = 1; + d_output_coefficients[0] = 1.0; } else { @@ -157,28 +154,28 @@ void Tracking_loop_filter::update_coefficients(void) } break; case 2: - wn = d_noise_bandwidth * (8 * zeta) / (4 * zeta * zeta + 1); + wn = d_noise_bandwidth * (8.0 * zeta) / (4.0 * zeta * zeta + 1.0); g1 = wn * wn; - g2 = wn * 2 * zeta; + g2 = wn * 2.0 * zeta; if (d_include_last_integrator) { d_input_coefficients.resize(3); - d_input_coefficients[0] = T / 2 * (g1 * T / 2 + g2); - d_input_coefficients[1] = T * T / 2 * g1; - d_input_coefficients[2] = T / 2 * (g1 * T / 2 - g2); + d_input_coefficients[0] = T / 2.0 * (g1 * T / 2.0 + g2); + d_input_coefficients[1] = T * T / 2.0 * g1; + d_input_coefficients[2] = T / 2.0 * (g1 * T / 2.0 - g2); d_output_coefficients.resize(2); - d_output_coefficients[0] = 2; - d_output_coefficients[1] = -1; + d_output_coefficients[0] = 2.0; + d_output_coefficients[1] = -1.0; } else { d_input_coefficients.resize(2); d_input_coefficients[0] = (g1 * T / 2.0 + g2); - d_input_coefficients[1] = g1 * T / 2 - g2; + d_input_coefficients[1] = g1 * T / 2.0 - g2; d_output_coefficients.resize(1); - d_output_coefficients[0] = 1; + d_output_coefficients[0] = 1.0; } break; @@ -193,27 +190,27 @@ void Tracking_loop_filter::update_coefficients(void) if (d_include_last_integrator) { d_input_coefficients.resize(4); - d_input_coefficients[0] = T / 2 * (g3 + T / 2 * (g2 + T / 2 * g1)); - d_input_coefficients[1] = T / 2 * (-g3 + T / 2 * (g2 + 3 * T / 2 * g1)); - d_input_coefficients[2] = T / 2 * (-g3 - T / 2 * (g2 - 3 * T / 2 * g1)); - d_input_coefficients[3] = T / 2 * (g3 - T / 2 * (g2 - T / 2 * g1)); + d_input_coefficients[0] = T / 2.0 * (g3 + T / 2.0 * (g2 + T / 2.0 * g1)); + d_input_coefficients[1] = T / 2.0 * (-g3 + T / 2.0 * (g2 + 3.0 * T / 2.0 * g1)); + d_input_coefficients[2] = T / 2.0 * (-g3 - T / 2.0 * (g2 - 3.0 * T / 2.0 * g1)); + d_input_coefficients[3] = T / 2.0 * (g3 - T / 2.0 * (g2 - T / 2.0 * g1)); d_output_coefficients.resize(3); - d_output_coefficients[0] = 3; - d_output_coefficients[1] = -3; - d_output_coefficients[2] = 1; + d_output_coefficients[0] = 3.0; + d_output_coefficients[1] = -3.0; + d_output_coefficients[2] = 1.0; } else { d_input_coefficients.resize(3); - d_input_coefficients[0] = g3 + T / 2 * (g2 + T / 2 * g1); - d_input_coefficients[1] = g1 * T * T / 2 - 2 * g3; - d_input_coefficients[2] = g3 + T / 2 * (-g2 + T / 2 * g1); + d_input_coefficients[0] = g3 + T / 2.0 * (g2 + T / 2.0 * g1); + d_input_coefficients[1] = g1 * T * T / 2.0 - 2.0 * g3; + d_input_coefficients[2] = g3 + T / 2.0 * (-g2 + T / 2.0 * g1); d_output_coefficients.resize(2); - d_output_coefficients[0] = 2; - d_output_coefficients[1] = -1; + d_output_coefficients[0] = 2.0; + d_output_coefficients[1] = -1.0; } break; }; @@ -254,7 +251,7 @@ bool Tracking_loop_filter::get_include_last_integrator(void) const void Tracking_loop_filter::set_order(int loop_order) { - if (loop_order < 1 || loop_order > MAX_LOOP_ORDER) + if (loop_order < 1 or loop_order > MAX_LOOP_ORDER) { LOG(ERROR) << "Ignoring attempt to set loop order to " << loop_order << ". Maximum allowed order is: " << MAX_LOOP_ORDER @@ -274,7 +271,7 @@ int Tracking_loop_filter::get_order(void) const void Tracking_loop_filter::initialize(float initial_output) { - d_inputs.assign(MAX_HISTORY_LENGTH, 0.0); - d_outputs.assign(MAX_HISTORY_LENGTH, initial_output); - d_current_index = MAX_HISTORY_LENGTH - 1; + d_inputs.assign(MAX_LOOP_HISTORY_LENGTH, 0.0); + d_outputs.assign(MAX_LOOP_HISTORY_LENGTH, initial_output); + d_current_index = MAX_LOOP_HISTORY_LENGTH - 1; } diff --git a/src/algorithms/tracking/libs/tracking_loop_filter.h b/src/algorithms/tracking/libs/tracking_loop_filter.h index 7fa486960..9a852ba68 100644 --- a/src/algorithms/tracking/libs/tracking_loop_filter.h +++ b/src/algorithms/tracking/libs/tracking_loop_filter.h @@ -33,6 +33,8 @@ #ifndef GNSS_SDR_TRACKING_LOOP_FILTER_H_ #define GNSS_SDR_TRACKING_LOOP_FILTER_H_ +#define MAX_LOOP_ORDER 3 +#define MAX_LOOP_HISTORY_LENGTH 4 #include diff --git a/src/core/receiver/CMakeLists.txt b/src/core/receiver/CMakeLists.txt index 0e12422a6..e632d6833 100644 --- a/src/core/receiver/CMakeLists.txt +++ b/src/core/receiver/CMakeLists.txt @@ -90,9 +90,9 @@ if(ENABLE_FMCOMMS2) set(OPT_RECEIVER_INCLUDE_DIRS ${OPT_RECEIVER_INCLUDE_DIRS} ${IIO_INCLUDE_DIRS}) endif(ENABLE_FMCOMMS2) -if(${PC_GNURADIO_RUNTIME_VERSION} VERSION_GREATER "3.7.13" ) +if(${PC_GNURADIO_RUNTIME_VERSION} VERSION_GREATER "3.7.15" ) add_definitions( -DGR_GREATER_38=1 ) -endif(${PC_GNURADIO_RUNTIME_VERSION} VERSION_GREATER "3.7.13" ) +endif(${PC_GNURADIO_RUNTIME_VERSION} VERSION_GREATER "3.7.15" ) include_directories( diff --git a/src/core/receiver/gnss_block_factory.cc b/src/core/receiver/gnss_block_factory.cc index c9edbd8e8..d3b654a8d 100644 --- a/src/core/receiver/gnss_block_factory.cc +++ b/src/core/receiver/gnss_block_factory.cc @@ -79,6 +79,7 @@ #include "galileo_e5a_noncoherent_iq_acquisition_caf.h" #include "galileo_e5a_pcps_acquisition.h" #include "glonass_l1_ca_pcps_acquisition.h" +#include "glonass_l2_ca_pcps_acquisition.h" #include "gps_l1_ca_dll_pll_tracking.h" #include "gps_l1_ca_dll_pll_c_aid_tracking.h" #include "gps_l1_ca_tcp_connector_tracking.h" @@ -88,6 +89,8 @@ #include "gps_l2_m_dll_pll_tracking.h" #include "glonass_l1_ca_dll_pll_tracking.h" #include "glonass_l1_ca_dll_pll_c_aid_tracking.h" +#include "glonass_l2_ca_dll_pll_tracking.h" +#include "glonass_l2_ca_dll_pll_c_aid_tracking.h" #include "gps_l5i_dll_pll_tracking.h" #include "gps_l1_ca_telemetry_decoder.h" #include "gps_l2c_telemetry_decoder.h" @@ -95,6 +98,7 @@ #include "galileo_e1b_telemetry_decoder.h" #include "galileo_e5a_telemetry_decoder.h" #include "glonass_l1_ca_telemetry_decoder.h" +#include "glonass_l2_ca_telemetry_decoder.h" #include "sbas_l1_telemetry_decoder.h" #include "hybrid_observables.h" #include "rtklib_pvt.h" @@ -247,6 +251,7 @@ std::unique_ptr GNSSBlockFactory::GetObservables(std::shared GPS_channels += configuration->property("Channels_2S.count", 0); GPS_channels += configuration->property("Channels_L5.count", 0); unsigned int Glonass_channels = configuration->property("Channels_1G.count", 0); + Glonass_channels += configuration->property("Channels_2G.count", 0); return GetBlock(configuration, "Observables", implementation, Galileo_channels + GPS_channels + Glonass_channels, Galileo_channels + GPS_channels + Glonass_channels); } @@ -262,6 +267,7 @@ std::unique_ptr GNSSBlockFactory::GetPVT(std::shared_ptrproperty("Channels_2S.count", 0); GPS_channels += configuration->property("Channels_L5.count", 0); unsigned int Glonass_channels = configuration->property("Channels_1G.count", 0); + Glonass_channels += configuration->property("Channels_2G.count", 0); return GetBlock(configuration, "PVT", implementation, Galileo_channels + GPS_channels + Glonass_channels, 0); } @@ -605,6 +611,77 @@ std::unique_ptr GNSSBlockFactory::GetChannel_1G( } + +//********* GLONASS L2 C/A CHANNEL ***************** +std::unique_ptr GNSSBlockFactory::GetChannel_2G( + std::shared_ptr configuration, + std::string acq, std::string trk, std::string tlm, int channel, + boost::shared_ptr queue) +{ + std::stringstream stream; + stream << channel; + std::string id = stream.str(); + LOG(INFO) << "Instantiating Channel " << channel << " with Acquisition Implementation: " + << acq << ", Tracking Implementation: " << trk << ", Telemetry Decoder Implementation: " << tlm; + + std::string aux = configuration->property("Acquisition_2G" + boost::lexical_cast(channel) + ".implementation", std::string("W")); + std::string appendix1; + if (aux.compare("W") != 0) + { + appendix1 = boost::lexical_cast(channel); + } + else + { + appendix1 = ""; + } + aux = configuration->property("Tracking_2G" + boost::lexical_cast(channel) + ".implementation", std::string("W")); + std::string appendix2; + if (aux.compare("W") != 0) + { + appendix2 = boost::lexical_cast(channel); + } + else + { + appendix2 = ""; + } + aux = configuration->property("TelemetryDecoder_2G" + boost::lexical_cast(channel) + ".implementation", std::string("W")); + std::string appendix3; + if (aux.compare("W") != 0) + { + appendix3 = boost::lexical_cast(channel); + } + else + { + appendix3 = ""; + } + // Automatically detect input data type + std::shared_ptr config; + config = std::make_shared(); + std::string default_item_type = "gr_complex"; + std::string acq_item_type = configuration->property("Acquisition_2G" + appendix1 + ".item_type", default_item_type); + std::string trk_item_type = configuration->property("Tracking_2G" + appendix2 + ".item_type", default_item_type); + if (acq_item_type.compare(trk_item_type)) + { + LOG(ERROR) << "Acquisition and Tracking blocks must have the same input data type!"; + } + config->set_property("Channel.item_type", acq_item_type); + + std::unique_ptr pass_through_ = GetBlock(config, "Channel", "Pass_Through", 1, 1, queue); + std::unique_ptr acq_ = GetAcqBlock(configuration, "Acquisition_2G" + appendix1, acq, 1, 0); + std::unique_ptr trk_ = GetTrkBlock(configuration, "Tracking_2G" + appendix2, trk, 1, 1); + std::unique_ptr tlm_ = GetTlmBlock(configuration, "TelemetryDecoder_2G" + appendix3, tlm, 1, 1); + + std::unique_ptr channel_(new Channel(configuration.get(), channel, std::move(pass_through_), + std::move(acq_), + std::move(trk_), + std::move(tlm_), + "Channel", "2G", queue)); + + return channel_; +} + + + //********* GPS L5 CHANNEL ***************** std::unique_ptr GNSSBlockFactory::GetChannel_L5( std::shared_ptr configuration, @@ -688,6 +765,7 @@ std::unique_ptr>> GNSSBlockFacto unsigned int Channels_1B_count = configuration->property("Channels_1B.count", 0); unsigned int Channels_5X_count = configuration->property("Channels_5X.count", 0); unsigned int Channels_1G_count = configuration->property("Channels_1G.count", 0); + unsigned int Channels_2G_count = configuration->property("Channels_2G.count", 0); unsigned int Channels_L5_count = configuration->property("Channels_L5.count", 0); unsigned int total_channels = Channels_1C_count + @@ -695,6 +773,7 @@ std::unique_ptr>> GNSSBlockFacto Channels_1B_count + Channels_5X_count + Channels_1G_count + + Channels_2G_count + Channels_L5_count; std::unique_ptr>> channels(new std::vector>(total_channels)); @@ -875,6 +954,36 @@ std::unique_ptr>> GNSSBlockFacto channel_absolute_id++; } + //**************** GLONASS L2 C/A CHANNELS ********************** + LOG(INFO) << "Getting " << Channels_2G_count << " GLONASS L2 C/A channels"; + acquisition_implementation = configuration->property("Acquisition_2G.implementation", default_implementation); + tracking_implementation = configuration->property("Tracking_2G.implementation", default_implementation); + telemetry_decoder_implementation = configuration->property("TelemetryDecoder_2G.implementation", default_implementation); + + for (unsigned int i = 0; i < Channels_2G_count; i++) + { + //(i.e. Acquisition_2G0.implementation=xxxx) + std::string acquisition_implementation_specific = configuration->property( + "Acquisition_2G" + boost::lexical_cast(channel_absolute_id) + ".implementation", + acquisition_implementation); + //(i.e. Tracking_2G0.implementation=xxxx) + std::string tracking_implementation_specific = configuration->property( + "Tracking_2G" + boost::lexical_cast(channel_absolute_id) + ".implementation", + tracking_implementation); + std::string telemetry_decoder_implementation_specific = configuration->property( + "TelemetryDecoder_2G" + boost::lexical_cast(channel_absolute_id) + ".implementation", + telemetry_decoder_implementation); + + // Push back the channel to the vector of channels + channels->at(channel_absolute_id) = std::move(GetChannel_2G(configuration, + acquisition_implementation_specific, + tracking_implementation_specific, + telemetry_decoder_implementation_specific, + channel_absolute_id, + queue)); + channel_absolute_id++; + } + return channels; } @@ -1283,7 +1392,12 @@ std::unique_ptr GNSSBlockFactory::GetBlock( out_streams)); block = std::move(block_); } - + else if (implementation.compare("GLONASS_L2_CA_PCPS_Acquisition") == 0) + { + std::unique_ptr block_(new GlonassL2CaPcpsAcquisition(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } // TRACKING BLOCKS ------------------------------------------------------------- else if (implementation.compare("GPS_L1_CA_DLL_PLL_Tracking") == 0) { @@ -1367,7 +1481,18 @@ std::unique_ptr GNSSBlockFactory::GetBlock( out_streams)); block = std::move(block_); } - + else if (implementation.compare("GLONASS_L2_CA_DLL_PLL_Tracking") == 0) + { + std::unique_ptr block_(new GlonassL2CaDllPllTracking(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } + else if (implementation.compare("GLONASS_L2_CA_DLL_PLL_C_Aid_Tracking") == 0) + { + std::unique_ptr block_(new GlonassL2CaDllPllCAidTracking(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } // TELEMETRY DECODERS ---------------------------------------------------------- else if (implementation.compare("GPS_L1_CA_Telemetry_Decoder") == 0) { @@ -1411,7 +1536,12 @@ std::unique_ptr GNSSBlockFactory::GetBlock( out_streams)); block = std::move(block_); } - + else if (implementation.compare("GLONASS_L2_CA_Telemetry_Decoder") == 0) + { + std::unique_ptr block_(new GlonassL2CaTelemetryDecoder(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } // OBSERVABLES ----------------------------------------------------------------- else if ((implementation.compare("Hybrid_Observables") == 0) || (implementation.compare("GPS_L1_CA_Observables") == 0) || (implementation.compare("GPS_L2C_Observables") == 0) || (implementation.compare("Galileo_E5A_Observables") == 0)) @@ -1562,6 +1692,12 @@ std::unique_ptr GNSSBlockFactory::GetAcqBlock( out_streams)); block = std::move(block_); } + else if (implementation.compare("GLONASS_L2_CA_PCPS_Acquisition") == 0) + { + std::unique_ptr block_(new GlonassL2CaPcpsAcquisition(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } else { // Log fatal. This causes execution to stop. @@ -1662,6 +1798,18 @@ std::unique_ptr GNSSBlockFactory::GetTrkBlock( out_streams)); block = std::move(block_); } + else if (implementation.compare("GLONASS_L2_CA_DLL_PLL_Tracking") == 0) + { + std::unique_ptr block_(new GlonassL2CaDllPllTracking(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } + else if (implementation.compare("GLONASS_L2_CA_DLL_PLL_C_Aid_Tracking") == 0) + { + std::unique_ptr block_(new GlonassL2CaDllPllCAidTracking(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } else { // Log fatal. This causes execution to stop. @@ -1716,6 +1864,12 @@ std::unique_ptr GNSSBlockFactory::GetTlmBlock( out_streams)); block = std::move(block_); } + else if (implementation.compare("GLONASS_L2_CA_Telemetry_Decoder") == 0) + { + std::unique_ptr block_(new GlonassL2CaTelemetryDecoder(configuration.get(), role, in_streams, + out_streams)); + block = std::move(block_); + } else if (implementation.compare("GPS_L5_Telemetry_Decoder") == 0) { std::unique_ptr block_(new GpsL5TelemetryDecoder(configuration.get(), role, in_streams, diff --git a/src/core/receiver/gnss_block_factory.h b/src/core/receiver/gnss_block_factory.h index 4456cc400..f5db1a6cb 100644 --- a/src/core/receiver/gnss_block_factory.h +++ b/src/core/receiver/gnss_block_factory.h @@ -102,6 +102,10 @@ private: std::string acq, std::string trk, std::string tlm, int channel, boost::shared_ptr queue); + std::unique_ptr GetChannel_2G(std::shared_ptr configuration, + std::string acq, std::string trk, std::string tlm, int channel, + boost::shared_ptr queue); + std::unique_ptr GetAcqBlock( std::shared_ptr configuration, std::string role, diff --git a/src/core/receiver/gnss_flowgraph.cc b/src/core/receiver/gnss_flowgraph.cc index e379220a5..0488da8e4 100644 --- a/src/core/receiver/gnss_flowgraph.cc +++ b/src/core/receiver/gnss_flowgraph.cc @@ -544,6 +544,7 @@ void GNSSFlowgraph::set_signals_list() configuration_->property("Channels_1B.count", 0) + configuration_->property("Channels_5X.count", 0) + configuration_->property("Channels_1G.count", 0) + + configuration_->property("Channels_2G.count", 0) + configuration_->property("Channels_5X.count", 0) + configuration_->property("Channels_L5.count", 0); @@ -722,8 +723,8 @@ void GNSSFlowgraph::set_signals_list() if (configuration_->property("Channels_1G.count", 0) > 0) { /* - * Loop to create the list of GLONASS L1 C/A signals - */ + * Loop to create the list of GLONASS L1 C/A signals + */ for (available_gnss_prn_iter = available_glonass_prn.begin(); available_gnss_prn_iter != available_glonass_prn.end(); available_gnss_prn_iter++) @@ -733,6 +734,21 @@ void GNSSFlowgraph::set_signals_list() std::string("1G"))); } } + + if (configuration_->property("Channels_2G.count", 0) > 0) + { + /* + * Loop to create the list of GLONASS L2 C/A signals + */ + for (available_gnss_prn_iter = available_glonass_prn.begin(); + available_gnss_prn_iter != available_glonass_prn.end(); + available_gnss_prn_iter++) + { + available_GNSS_signals_.push_back(Gnss_Signal( + Gnss_Satellite(std::string("Glonass"), *available_gnss_prn_iter), + std::string("2G"))); + } + } /* * Ordering the list of signals from configuration file */ @@ -746,7 +762,7 @@ void GNSSFlowgraph::set_signals_list() std::string gnss_system; if ((gnss_signal.compare("1C") == 0) or (gnss_signal.compare("2S") == 0) or (gnss_signal.compare("L5") == 0)) gnss_system = "GPS"; if ((gnss_signal.compare("1B") == 0) or (gnss_signal.compare("5X") == 0)) gnss_system = "Galileo"; - if ((gnss_signal.compare("1G") == 0) /*or (gnss_signal.compare("") == 0)*/) gnss_system = "Glonass"; + if ((gnss_signal.compare("1G") == 0) or (gnss_signal.compare("2G") == 0)) gnss_system = "Glonass"; unsigned int sat = configuration_->property("Channel" + boost::lexical_cast(i) + ".satellite", 0); LOG(INFO) << "Channel " << i << " system " << gnss_system << ", signal " << gnss_signal << ", sat " << sat; if (sat == 0) // 0 = not PRN in configuration file diff --git a/src/core/receiver/gnss_flowgraph.h b/src/core/receiver/gnss_flowgraph.h index 615ee0dc4..7f8891f29 100644 --- a/src/core/receiver/gnss_flowgraph.h +++ b/src/core/receiver/gnss_flowgraph.h @@ -109,7 +109,7 @@ public: return running_; } /*! - * \brief Sends a GNURadio asyncronous message from telemetry to PVT + * \brief Sends a GNURadio asynchronous message from telemetry to PVT * * It is used to assist the receiver with external ephemeris data */ diff --git a/src/core/system_parameters/GLONASS_L1_CA.h b/src/core/system_parameters/GLONASS_L1_L2_CA.h similarity index 94% rename from src/core/system_parameters/GLONASS_L1_CA.h rename to src/core/system_parameters/GLONASS_L1_L2_CA.h index 0e12dab25..28bd25d3b 100644 --- a/src/core/system_parameters/GLONASS_L1_CA.h +++ b/src/core/system_parameters/GLONASS_L1_L2_CA.h @@ -1,6 +1,7 @@ /*! - * \file GLONASS_L1_CA.h + * \file GLONASS_L1_L2_CA.h * \brief Defines system parameters for GLONASS L1 C/A signal and NAV data + * \note File renamed from GLONASS_L1_CA.h to GLONASS_L1_L2_CA.h to accommodate GLO L2 addition * \author Damian Miralles, 2017. dmiralles2009(at)gmail.com * * ------------------------------------------------------------------------- @@ -29,8 +30,8 @@ */ -#ifndef GNSS_SDR_GLONASS_L1_CA_H_ -#define GNSS_SDR_GLONASS_L1_CA_H_ +#ifndef GNSS_SDR_GLONASS_L1_L2_CA_H_ +#define GNSS_SDR_GLONASS_L1_L2_CA_H_ #include "gnss_frequencies.h" #include "MATH_CONSTANTS.h" @@ -79,8 +80,13 @@ const double GLONASS_SUN_GM = 0.1325263e12; //!< Solar gravitational const double GLONASS_SUN_SEMI_MAJOR_AXIS = 1.49598e8; //!< Semi-major axis of solar orbit [km]; const double GLONASS_SUN_ECCENTRICITY = 0.016719; //!< Eccentricity of solar orbit -// carrier and code frequencies -const double GLONASS_L2_FREQ_HZ = FREQ2_GLO; //!< L1 [Hz] +const double GLONASS_L2_CA_FREQ_HZ = FREQ2_GLO; //!< L2 [Hz] +const double GLONASS_L2_CA_DFREQ_HZ = DFRQ2_GLO; //!< Freq Bias for GLONASS L1 [Hz] +const double GLONASS_L2_CA_CODE_RATE_HZ = 0.511e6; //!< GLONASS L1 C/A code rate [chips/s] +const double GLONASS_L2_CA_CODE_LENGTH_CHIPS = 511.0; //!< GLONASS L1 C/A code length [chips] +const double GLONASS_L2_CA_CODE_PERIOD = 0.001; //!< GLONASS L1 C/A code period [seconds] +const double GLONASS_L2_CA_CHIP_PERIOD = 1.9569e-06; //!< GLONASS L1 C/A chip period [seconds] +const double GLONASS_L2_CA_SYMBOL_RATE_BPS = 1000; const double GLONASS_L1_CA_FREQ_HZ = FREQ1_GLO; //!< L1 [Hz] const double GLONASS_L1_CA_DFREQ_HZ = DFRQ1_GLO; //!< Freq Bias for GLONASS L1 [Hz] @@ -89,7 +95,8 @@ const double GLONASS_L1_CA_CODE_LENGTH_CHIPS = 511.0; //!< GLONASS L1 C/A code const double GLONASS_L1_CA_CODE_PERIOD = 0.001; //!< GLONASS L1 C/A code period [seconds] const double GLONASS_L1_CA_CHIP_PERIOD = 1.9569e-06; //!< GLONASS L1 C/A chip period [seconds] const double GLONASS_L1_CA_SYMBOL_RATE_BPS = 1000; -const int GLONASS_L1_CA_NBR_SATS = 24; // STRING DATA WITHOUT PREAMBLE + +const int GLONASS_CA_NBR_SATS = 24; // STRING DATA WITHOUT PREAMBLE /*! * \brief Record of leap seconds definition for GLOT to GPST conversion and vice versa @@ -320,4 +327,4 @@ const std::vector> B1({{6, 11}}); const std::vector> B2({{17, 10}}); -#endif /* GNSS_SDR_GLONASS_L1_CA_H_ */ +#endif /* GNSS_SDR_GLONASS_L1_L2_CA_H_ */ diff --git a/src/core/system_parameters/GPS_L5.h b/src/core/system_parameters/GPS_L5.h index af317cfc3..ff7ded0d4 100644 --- a/src/core/system_parameters/GPS_L5.h +++ b/src/core/system_parameters/GPS_L5.h @@ -36,6 +36,7 @@ #include "GPS_CNAV.h" #include "MATH_CONSTANTS.h" #include +#include // Physical constants @@ -181,7 +182,11 @@ const int GPS_L5_SYMBOLS_PER_BIT = 2; const int GPS_L5_SAMPLES_PER_SYMBOL = 10; const int GPS_L5_CNAV_DATA_PAGE_SYMBOLS = 600; const int GPS_L5_CNAV_DATA_PAGE_DURATION_S = 6; -const int GPS_L5_NH_CODE_LENGTH = 10; -const int GPS_L5_NH_CODE[10] = {0, 0, 0, 0, 1, 1, 0, 1, 0, 1}; +const int GPS_L5i_NH_CODE_LENGTH = 10; +const int GPS_L5i_NH_CODE[10] = {0, 0, 0, 0, 1, 1, 0, 1, 0, 1}; +const std::string GPS_L5i_NH_CODE_STR = "0000110101"; +const int GPS_L5q_NH_CODE_LENGTH = 20; +const int GPS_L5q_NH_CODE[20] = {0, 0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 1, 1, 1, 0}; +const std::string GPS_L5q_NH_CODE_STR = "00000100110101001110"; #endif /* GNSS_SDR_GPS_L5_H_ */ diff --git a/src/core/system_parameters/galileo_ephemeris.cc b/src/core/system_parameters/galileo_ephemeris.cc index 6a61807f5..8941c46fd 100644 --- a/src/core/system_parameters/galileo_ephemeris.cc +++ b/src/core/system_parameters/galileo_ephemeris.cc @@ -42,7 +42,7 @@ Galileo_Ephemeris::Galileo_Ephemeris() M0_1 = 0; // Mean anomaly at reference time [semi-circles] delta_n_3 = 0; // Mean motion difference from computed value [semi-circles/sec] e_1 = 0; // Eccentricity - A_1 = 0; // Square root of the semi-major axis [metres^1/2] + A_1 = 0; // Square root of the semi-major axis [meters^1/2] OMEGA_0_2 = 0; // Longitude of ascending node of orbital plane at weekly epoch [semi-circles] i_0_2 = 0; // Inclination angle at reference time [semi-circles] omega_2 = 0; // Argument of perigee [semi-circles] diff --git a/src/core/system_parameters/galileo_ephemeris.h b/src/core/system_parameters/galileo_ephemeris.h index a250e0dba..b9fcd04d7 100644 --- a/src/core/system_parameters/galileo_ephemeris.h +++ b/src/core/system_parameters/galileo_ephemeris.h @@ -54,7 +54,7 @@ public: double M0_1; //!< Mean anomaly at reference time [semi-circles] double delta_n_3; //!< Mean motion difference from computed value [semi-circles/sec] double e_1; //!< Eccentricity - double A_1; //!< Square root of the semi-major axis [metres^1/2] + double A_1; //!< Square root of the semi-major axis [meters^1/2] double OMEGA_0_2; //!< Longitude of ascending node of orbital plane at weekly epoch [semi-circles] double i_0_2; //!< Inclination angle at reference time [semi-circles] double omega_2; //!< Argument of perigee [semi-circles] diff --git a/src/core/system_parameters/galileo_fnav_message.cc b/src/core/system_parameters/galileo_fnav_message.cc index fd3c6c982..e5f747cd5 100644 --- a/src/core/system_parameters/galileo_fnav_message.cc +++ b/src/core/system_parameters/galileo_fnav_message.cc @@ -604,7 +604,7 @@ Galileo_Ephemeris Galileo_Fnav_Message::get_ephemeris() ephemeris.M0_1 = FNAV_M0_2; // Mean anomaly at reference time [semi-circles] ephemeris.delta_n_3 = FNAV_deltan_3; // Mean motion difference from computed value [semi-circles/sec] ephemeris.e_1 = FNAV_e_2; // Eccentricity - ephemeris.A_1 = FNAV_a12_2; // Square root of the semi-major axis [metres^1/2] + ephemeris.A_1 = FNAV_a12_2; // Square root of the semi-major axis [meters^1/2] ephemeris.OMEGA_0_2 = FNAV_omega0_2; // Longitude of ascending node of orbital plane at weekly epoch [semi-circles] ephemeris.i_0_2 = FNAV_i0_3; // Inclination angle at reference time [semi-circles] ephemeris.omega_2 = FNAV_w_3; // Argument of perigee [semi-circles] diff --git a/src/core/system_parameters/galileo_navigation_message.cc b/src/core/system_parameters/galileo_navigation_message.cc index 933680e3e..c09fff2a5 100644 --- a/src/core/system_parameters/galileo_navigation_message.cc +++ b/src/core/system_parameters/galileo_navigation_message.cc @@ -530,7 +530,7 @@ Galileo_Ephemeris Galileo_Navigation_Message::get_ephemeris() ephemeris.M0_1 = M0_1; // Mean anomaly at reference time [semi-circles] ephemeris.delta_n_3 = delta_n_3; // Mean motion difference from computed value [semi-circles/sec] ephemeris.e_1 = e_1; // Eccentricity - ephemeris.A_1 = A_1; // Square root of the semi-major axis [metres^1/2] + ephemeris.A_1 = A_1; // Square root of the semi-major axis [meters^1/2] ephemeris.OMEGA_0_2 = OMEGA_0_2; // Longitude of ascending node of orbital plane at weekly epoch [semi-circles] ephemeris.i_0_2 = i_0_2; // Inclination angle at reference time [semi-circles] ephemeris.omega_2 = omega_2; // Argument of perigee [semi-circles] diff --git a/src/core/system_parameters/galileo_navigation_message.h b/src/core/system_parameters/galileo_navigation_message.h index 376db483e..ccb7ae7e5 100644 --- a/src/core/system_parameters/galileo_navigation_message.h +++ b/src/core/system_parameters/galileo_navigation_message.h @@ -97,7 +97,7 @@ public: double t0e_1; //!< Ephemeris reference time [s] double M0_1; //!< Mean anomaly at reference time [semi-circles] double e_1; //!< Eccentricity - double A_1; //!< Square root of the semi-major axis [metres^1/2] + double A_1; //!< Square root of the semi-major axis [meters^1/2] /*Word type 2: Ephemeris (2/4)*/ int IOD_nav_2; //!< IOD_nav page 2 diff --git a/src/core/system_parameters/glonass_gnav_ephemeris.cc b/src/core/system_parameters/glonass_gnav_ephemeris.cc index ab872226b..a6531fc60 100644 --- a/src/core/system_parameters/glonass_gnav_ephemeris.cc +++ b/src/core/system_parameters/glonass_gnav_ephemeris.cc @@ -31,10 +31,11 @@ */ #include "glonass_gnav_ephemeris.h" -#include "GLONASS_L1_CA.h" #include "gnss_satellite.h" +#include "GLONASS_L1_L2_CA.h" #include + Glonass_Gnav_Ephemeris::Glonass_Gnav_Ephemeris() { d_m = 0.0; //!< String number within frame [dimensionless] diff --git a/src/core/system_parameters/glonass_gnav_navigation_message.cc b/src/core/system_parameters/glonass_gnav_navigation_message.cc index 9f99723ab..7e4cd43fb 100644 --- a/src/core/system_parameters/glonass_gnav_navigation_message.cc +++ b/src/core/system_parameters/glonass_gnav_navigation_message.cc @@ -83,7 +83,7 @@ void Glonass_Gnav_Navigation_Message::reset() // Data update information d_previous_tb = 0.0; - for (unsigned int i = 0; i < GLONASS_L1_CA_NBR_SATS; i++) + for (unsigned int i = 0; i < GLONASS_CA_NBR_SATS; i++) d_previous_Na[i] = 0.0; std::map satelliteBlock; //!< Map that stores to which block the PRN belongs http://www.navcen.uscg.gov/?Do=constellationStatus diff --git a/src/core/system_parameters/glonass_gnav_navigation_message.h b/src/core/system_parameters/glonass_gnav_navigation_message.h index 1a932786b..2fdedd128 100644 --- a/src/core/system_parameters/glonass_gnav_navigation_message.h +++ b/src/core/system_parameters/glonass_gnav_navigation_message.h @@ -35,10 +35,10 @@ #define GNSS_SDR_GLONASS_GNAV_NAVIGATION_MESSAGE_H_ -#include "GLONASS_L1_CA.h" #include "glonass_gnav_ephemeris.h" #include "glonass_gnav_almanac.h" #include "glonass_gnav_utc_model.h" +#include "GLONASS_L1_L2_CA.h" #include @@ -63,9 +63,9 @@ public: int i_channel_ID; unsigned int i_satellite_PRN; - Glonass_Gnav_Ephemeris gnav_ephemeris; //!< Ephemeris information decoded - Glonass_Gnav_Utc_Model gnav_utc_model; //!< UTC model information - Glonass_Gnav_Almanac gnav_almanac[GLONASS_L1_CA_NBR_SATS]; //!< Almanac information for all 24 satellites + Glonass_Gnav_Ephemeris gnav_ephemeris; //!< Ephemeris information decoded + Glonass_Gnav_Utc_Model gnav_utc_model; //!< UTC model information + Glonass_Gnav_Almanac gnav_almanac[GLONASS_CA_NBR_SATS]; //!< Almanac information for all 24 satellites // Ephemeris Flags and control variables bool flag_all_ephemeris; //!< Flag indicating that all strings containing ephemeris have been received @@ -100,8 +100,8 @@ public: double d_dtr; //!< Relativistic clock correction term double d_satClkDrift; //!< Satellite clock drift - double d_previous_tb; //!< Previous iode for the Glonass_Gnav_Ephemeris object. Used to determine when new data arrives - double d_previous_Na[GLONASS_L1_CA_NBR_SATS]; //!< Previous time for almanac of the Glonass_Gnav_Almanac object + double d_previous_tb; //!< Previous iode for the Glonass_Gnav_Ephemeris object. Used to determine when new data arrives + double d_previous_Na[GLONASS_CA_NBR_SATS]; //!< Previous time for almanac of the Glonass_Gnav_Almanac object /*! * \brief Compute CRC for GLONASS GNAV strings diff --git a/src/core/system_parameters/gnss_satellite.cc b/src/core/system_parameters/gnss_satellite.cc index 0f6c5345a..ee6953db2 100644 --- a/src/core/system_parameters/gnss_satellite.cc +++ b/src/core/system_parameters/gnss_satellite.cc @@ -559,7 +559,7 @@ std::string Gnss_Satellite::what_block(const std::string& system_, unsigned int block_ = std::string("IOV-FM4**"); // Galileo In-Orbit Validation (IOV) satellite FM4 (Flight Model 4) / GSAT0104, launched on October 12, 2012. Payload power problem beginning May 27, 2014 led to permanent loss of E5 and E6 transmissions, E1 transmission restored. UNAVAILABLE FROM 2014-05-27 UNTIL FURTHER NOTICE break; case 21: - block_ = std::string("FOC-FM15"); // Galileo Full Operational Capability (FOC) satellite FM15 / GSAT0215, launched on Dec. 12, 2017. UNDER COMMISIONING. + block_ = std::string("FOC-FM15"); // Galileo Full Operational Capability (FOC) satellite FM15 / GSAT0215, launched on Dec. 12, 2017. UNDER COMMISSIONING. break; case 22: block_ = std::string("FOC-FM4**"); // Galileo Full Operational Capability (FOC) satellite FM4 / GSAT0204, launched on March 27, 2015. REMOVED FROM ACTIVE SERVICE ON 2017-12-08 UNTIL FURTHER NOTICE FOR CONSTELLATION MANAGEMENT PURPOSES. @@ -568,19 +568,19 @@ std::string Gnss_Satellite::what_block(const std::string& system_, unsigned int block_ = std::string("FOC-FM5"); // Galileo Full Operational Capability (FOC) satellite FM5 / GSAT0205, launched on Sept. 11, 2015. break; case 25: - block_ = std::string("FOC-FM16"); // Galileo Full Operational Capability (FOC) satellite FM16 / GSAT0216, launched on Dec. 12, 2017. UNDER COMMISIONING. + block_ = std::string("FOC-FM16"); // Galileo Full Operational Capability (FOC) satellite FM16 / GSAT0216, launched on Dec. 12, 2017. UNDER COMMISSIONING. break; case 26: block_ = std::string("FOC-FM3"); // Galileo Full Operational Capability (FOC) satellite FM3 / GSAT0203, launched on March 27, 2015. break; case 27: - block_ = std::string("FOC-FM17"); // Galileo Full Operational Capability (FOC) satellite FM17 / GSAT0217, launched on Dec. 12, 2017. UNDER COMMISIONING. + block_ = std::string("FOC-FM17"); // Galileo Full Operational Capability (FOC) satellite FM17 / GSAT0217, launched on Dec. 12, 2017. UNDER COMMISSIONING. break; case 30: block_ = std::string("FOC-FM6"); // Galileo Full Operational Capability (FOC) satellite FM6 / GSAT0206, launched on Sept. 11, 2015. break; case 31: - block_ = std::string("FOC-FM18"); // Galileo Full Operational Capability (FOC) satellite FM18 / GSAT0218, launched on Dec. 12, 2017. UNDER COMMISIONING. + block_ = std::string("FOC-FM18"); // Galileo Full Operational Capability (FOC) satellite FM18 / GSAT0218, launched on Dec. 12, 2017. UNDER COMMISSIONING. break; default: block_ = std::string("Unknown(Simulated)"); diff --git a/src/core/system_parameters/gps_cnav_navigation_message.h b/src/core/system_parameters/gps_cnav_navigation_message.h index 6128403ca..b9e8a8dae 100644 --- a/src/core/system_parameters/gps_cnav_navigation_message.h +++ b/src/core/system_parameters/gps_cnav_navigation_message.h @@ -67,8 +67,8 @@ public: double d_TOW; bool b_flag_ephemeris_1; bool b_flag_ephemeris_2; - bool b_flag_iono_valid; //!< If set, it indicates that the ionospheric parameters are filled and are not yet readed by the get_iono - bool b_flag_utc_valid; //!< If set, it indicates that the utc parameters are filled and are not yet readed by the get_utc_model + bool b_flag_iono_valid; //!< If set, it indicates that the ionospheric parameters are filled and are not yet read by the get_iono + bool b_flag_utc_valid; //!< If set, it indicates that the utc parameters are filled and are not yet read by the get_utc_model std::map satelliteBlock; //!< Map that stores to which block the PRN belongs http://www.navcen.uscg.gov/?Do=constellationStatus diff --git a/src/core/system_parameters/rtcm.cc b/src/core/system_parameters/rtcm.cc index 9cd546aed..91bb4b5f3 100644 --- a/src/core/system_parameters/rtcm.cc +++ b/src/core/system_parameters/rtcm.cc @@ -4014,7 +4014,7 @@ int Rtcm::set_DF047(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss //TODO Need to consider frequency channel in this fields int Rtcm::set_DF048(const Gnss_Synchro& gnss_synchroL1, const Gnss_Synchro& gnss_synchroL2) { - const double lambda2 = GLONASS_C_m_s / GLONASS_L2_FREQ_HZ; + const double lambda2 = GLONASS_C_m_s / GLONASS_L2_CA_FREQ_HZ; int l2_phaserange_minus_l1_pseudorange = 0xFFF80000; double ambiguity = std::floor(gnss_synchroL1.Pseudorange_m / 599584.92); double glonass_L1_pseudorange = std::round((gnss_synchroL1.Pseudorange_m - ambiguity * 599584.92) / 0.02); @@ -5260,12 +5260,12 @@ int Rtcm::set_DF401(const Gnss_Synchro& gnss_synchro) if ((sig.compare("2C") == 0) && (sys.compare("R") == 0)) { // TODO Need to add slot number and freq number to gnss_syncro - lambda = GLONASS_C_m_s / (GLONASS_L2_FREQ_HZ); + lambda = GLONASS_C_m_s / (GLONASS_L2_CA_FREQ_HZ); } phrng_m = (gnss_synchro.Carrier_phase_rads / GPS_TWO_PI) * lambda - rough_range_m; - /* Substract phase - pseudorange integer cycle offset */ + /* Subtract phase - pseudorange integer cycle offset */ /* TODO: check LLI! */ double cp = gnss_synchro.Carrier_phase_rads / GPS_TWO_PI; // ? if (std::fabs(phrng_m - cp) > 1171.0) @@ -5369,7 +5369,7 @@ int Rtcm::set_DF404(const Gnss_Synchro& gnss_synchro) if ((sig_.compare("2C") == 0) && (sys_.compare("R") == 0)) { //TODO Need to add slot number and freq number to gnss syncro - lambda = GLONASS_C_m_s / (GLONASS_L2_FREQ_HZ); + lambda = GLONASS_C_m_s / (GLONASS_L2_CA_FREQ_HZ); } double rough_phase_range_rate = std::round(-gnss_synchro.Carrier_Doppler_hz * lambda); double phrr = (-gnss_synchro.Carrier_Doppler_hz * lambda - rough_phase_range_rate); @@ -5456,11 +5456,11 @@ int Rtcm::set_DF406(const Gnss_Synchro& gnss_synchro) if ((sig_.compare("2C") == 0) && (sys_.compare("R") == 0)) { //TODO Need to add slot number and freq number to gnss syncro - lambda = GLONASS_C_m_s / (GLONASS_L2_FREQ_HZ); + lambda = GLONASS_C_m_s / (GLONASS_L2_CA_FREQ_HZ); } phrng_m = (gnss_synchro.Carrier_phase_rads / GPS_TWO_PI) * lambda - rough_range_m; - /* Substract phase - pseudorange integer cycle offset */ + /* Subtract phase - pseudorange integer cycle offset */ /* TODO: check LLI! */ double cp = gnss_synchro.Carrier_phase_rads / GPS_TWO_PI; // ? if (std::fabs(phrng_m - cp) > 1171.0) diff --git a/src/core/system_parameters/rtcm.h b/src/core/system_parameters/rtcm.h index d4ac17460..1a14cc988 100644 --- a/src/core/system_parameters/rtcm.h +++ b/src/core/system_parameters/rtcm.h @@ -50,6 +50,7 @@ #include #include #include +#include /*! @@ -641,7 +642,6 @@ private: { public: Rtcm_Session(boost::asio::ip::tcp::socket socket, Rtcm_Listener_Room& room) : socket_(std::move(socket)), room_(room) {} - inline void start() { room_.join(shared_from_this()); @@ -665,11 +665,11 @@ private: boost::asio::async_read(socket_, boost::asio::buffer(read_msg_.data(), Rtcm_Message::header_length), [this, self](boost::system::error_code ec, std::size_t /*length*/) { - if (!ec && read_msg_.decode_header()) + if (!ec and read_msg_.decode_header()) { do_read_message_body(); } - else if (!ec && !read_msg_.decode_header()) + else if (!ec and !read_msg_.decode_header()) { client_says += read_msg_.data(); bool first = true; @@ -687,7 +687,7 @@ private: } else { - std::cout << "Closing connection with client from " << socket_.remote_endpoint().address() << std::endl; + std::cout << "Closing connection with RTCM client" << std::endl; room_.leave(shared_from_this()); } }); @@ -709,7 +709,7 @@ private: } else { - std::cout << "Closing connection with client from " << socket_.remote_endpoint().address() << std::endl; + std::cout << "Closing connection with RTCM client" << std::endl; room_.leave(shared_from_this()); } }); @@ -719,8 +719,7 @@ private: { auto self(shared_from_this()); boost::asio::async_write(socket_, - boost::asio::buffer(write_msgs_.front().body(), - write_msgs_.front().body_length()), + boost::asio::buffer(write_msgs_.front().body(), write_msgs_.front().body_length()), [this, self](boost::system::error_code ec, std::size_t /*length*/) { if (!ec) { @@ -732,7 +731,7 @@ private: } else { - std::cout << "Closing connection with client from " << socket_.remote_endpoint().address() << std::endl; + std::cout << "Closing connection with RTCM client" << std::endl; room_.leave(shared_from_this()); } }); @@ -903,6 +902,7 @@ private: { std::cout << "Starting RTCM TCP server session..." << std::endl; std::cout << "Serving client from " << socket_.remote_endpoint().address() << std::endl; + LOG(INFO) << "Serving client from " << socket_.remote_endpoint().address(); } std::make_shared(std::move(socket_), room_)->start(); } diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 6090235b4..82f4e97d9 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -161,9 +161,9 @@ if(GNUPLOT_FOUND) add_definitions(-DGNUPLOT_EXECUTABLE="${GNUPLOT_EXECUTABLE}") endif(GNUPLOT_FOUND) -if(${PC_GNURADIO_RUNTIME_VERSION} VERSION_GREATER "3.7.13" ) +if(${PC_GNURADIO_RUNTIME_VERSION} VERSION_GREATER "3.7.15" ) add_definitions( -DGR_GREATER_38=1 ) -endif(${PC_GNURADIO_RUNTIME_VERSION} VERSION_GREATER "3.7.13" ) +endif(${PC_GNURADIO_RUNTIME_VERSION} VERSION_GREATER "3.7.15" ) ################################################################################ @@ -209,7 +209,7 @@ if(ENABLE_UNIT_TESTING_EXTRA OR ENABLE_SYSTEM_TESTING_EXTRA OR ENABLE_FPGA) ################################################################################ find_package(GPSTK) if(NOT GPSTK_FOUND OR ENABLE_OWN_GPSTK) - message(STATUS "GPSTk v${GNSSSDR_GPSTK_LOCAL_VERSION} will be automatically donwloaded and built when doing 'make'.") + message(STATUS "GPSTk v${GNSSSDR_GPSTK_LOCAL_VERSION} will be automatically downloaded and built when doing 'make'.") if(NOT ENABLE_FPGA) if(CMAKE_VERSION VERSION_LESS 3.2) ExternalProject_Add( @@ -271,9 +271,16 @@ if(ENABLE_UNIT_TESTING_EXTRA) SHOW_PROGRESS EXPECTED_HASH MD5=ffb72fc63c116be58d5e5ccb1daaed3a ) endif(NOT EXISTS ${CMAKE_SOURCE_DIR}/thirdparty/signal_samples/Glonass_L1_CA_SIM_Fs_62Msps_4ms.dat) + # if(NOT EXISTS ${CMAKE_SOURCE_DIR}/thirdparty/signal_samples/NT1065_GLONASS_L2_20160831_fs6625e6_if0e3_4ms.bin) + # message(STATUS "Downloading some data files for testing...") + # file(DOWNLOAD https://sourceforge.net/projects/gnss-sdr/files/data/NT1065_GLONASS_L2_20160831_fs6625e6_if0e3_4ms.bin ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/signal_samples/NT1065_GLONASS_L2_20160831_fs6625e6_if0e3_4ms.bin + # SHOW_PROGRESS + # EXPECTED_HASH MD5=d7055fc1dc931872b547a148af50a09b ) + # endif(NOT EXISTS ${CMAKE_SOURCE_DIR}/thirdparty/signal_samples/NT1065_GLONASS_L2_20160831_fs6625e6_if0e3_4ms.bin) if(ENABLE_INSTALL_TESTS) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/signal_samples/gps_l2c_m_prn7_5msps.dat DESTINATION share/gnss-sdr/signal_samples) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/signal_samples/Glonass_L1_CA_SIM_Fs_62Msps_4ms.dat DESTINATION share/gnss-sdr/signal_samples) + # install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../thirdparty/signal_samples/NT1065_GLONASS_L2_20160831_fs6625e6_if0e3_4ms.bin DESTINATION share/gnss-sdr/signal_samples) endif(ENABLE_INSTALL_TESTS) endif(ENABLE_UNIT_TESTING_EXTRA) @@ -780,4 +787,4 @@ if(ENABLE_PACKAGING) else(ENABLE_PACKAGING) add_dependencies(check control_thread_test flowgraph_test gnss_block_test gnuradio_block_test acq_test trk_test matio_test) -endif(ENABLE_PACKAGING) \ No newline at end of file +endif(ENABLE_PACKAGING) diff --git a/src/tests/common-files/gnuplot_i.h b/src/tests/common-files/gnuplot_i.h index ef0f6cecb..9c5f1a3c6 100644 --- a/src/tests/common-files/gnuplot_i.h +++ b/src/tests/common-files/gnuplot_i.h @@ -110,7 +110,7 @@ private: static std::string m_sGNUPlotFileName; ///\brief gnuplot path static std::string m_sGNUPlotPath; - ///\brief standart terminal, used by showonscreen + ///\brief standard terminal, used by showonscreen static std::string terminal_std; //---------------------------------------------------------------------------------- @@ -174,7 +174,7 @@ public: static bool set_GNUPlotPath(const std::string &path); // ---------------------------------------------------------------------------- - /// optional: set standart terminal, used by showonscreen + /// optional: set standard terminal, used by showonscreen /// defaults: Windows - win, Linux - x11, Mac - aqua /// /// \param type --> the terminal type @@ -260,7 +260,7 @@ public: /// interpolation and approximation of data, arguments: /// csplines, bezier, acsplines (for data values > 0), sbezier, unique, frequency /// (works only with plot_x, plot_xy, plotfile_x, plotfile_xy - /// (if smooth is set, set_style has no effekt on data plotting) + /// (if smooth is set, set_style has no effect on data plotting) Gnuplot &set_smooth(const std::string &stylestr = "csplines"); // ---------------------------------------------------------------------- @@ -610,14 +610,14 @@ public: /// plot an equation supplied as a std::string y=f(x), write only the function f(x) not y= /// the independent variable has to be x - /// binary operators: ** exponentiation, * multiply, / divide, + add, - substract, % modulo + /// binary operators: ** exponentiation, * multiply, / divide, + add, - subtract, % modulo /// unary operators: - minus, ! factorial /// elementary functions: rand(x), abs(x), sgn(x), ceil(x), floor(x), int(x), imag(x), real(x), arg(x), /// sqrt(x), exp(x), log(x), log10(x), sin(x), cos(x), tan(x), asin(x), acos(x), atan(x), atan2(y,x), /// sinh(x), cosh(x), tanh(x), asinh(x), acosh(x), atanh(x) /// special functions: erf(x), erfc(x), inverf(x), gamma(x), igamma(a,x), lgamma(x), ibeta(p,q,x), /// besj0(x), besj1(x), besy0(x), besy1(x), lambertw(x) - /// statistical fuctions: norm(x), invnorm(x) + /// statistical functions: norm(x), invnorm(x) Gnuplot &plot_equation(const std::string &equation, const std::string &title = ""); /// plot an equation supplied as a std::string z=f(x,y), write only the function f(x,y) not z= @@ -1014,7 +1014,7 @@ bool Gnuplot::set_GNUPlotPath(const std::string &path) //------------------------------------------------------------------------------ // -// define static member function: set standart terminal, used by showonscreen +// define static member function: set standard terminal, used by showonscreen // defaults: Windows - win, Linux - x11, Mac - aqua // void Gnuplot::set_terminal_std(const std::string &type) @@ -1106,7 +1106,7 @@ Gnuplot &Gnuplot::reset_plot() //------------------------------------------------------------------------------ // -// resets a gnuplot session and sets all varibles to default +// resets a gnuplot session and sets all variables to default // Gnuplot &Gnuplot::reset_all() { diff --git a/src/tests/test_main.cc b/src/tests/test_main.cc index f7c17fed3..49a2865db 100644 --- a/src/tests/test_main.cc +++ b/src/tests/test_main.cc @@ -114,6 +114,7 @@ DECLARE_string(log_dir); #include "unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_quicksync_ambiguous_acquisition_gsoc2014_test.cc" #include "unit-tests/signal-processing-blocks/acquisition/galileo_e5a_pcps_acquisition_gsoc2014_gensource_test.cc" #include "unit-tests/signal-processing-blocks/acquisition/glonass_l1_ca_pcps_acquisition_gsoc2017_test.cc" +// #include "unit-tests/signal-processing-blocks/acquisition/glonass_l2_ca_pcps_acquisition_test.cc" #if OPENCL_BLOCKS_TEST #include "unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_opencl_acquisition_gsoc2013_test.cc" 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 f1b97112f..89f251fd6 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 @@ -199,7 +199,7 @@ TEST_F(GlonassL1CaPcpsAcquisitionTest, ValidationOfResults) top_block = gr::make_top_block("Acquisition test"); double expected_delay_samples = 31874; - double expected_doppler_hz = -8000; + double expected_doppler_hz = -9500; init(); std::shared_ptr acquisition = std::make_shared(config.get(), "Acquisition_1G", 1, 1); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l2_ca_pcps_acquisition_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l2_ca_pcps_acquisition_test.cc new file mode 100644 index 000000000..c3b7ba24f --- /dev/null +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/glonass_l2_ca_pcps_acquisition_test.cc @@ -0,0 +1,659 @@ +/*! + * \file glonass_l2_ca_pcps_acquisition_test.cc + * \brief Tests a PCPS acquisition block for Glonass L2 C/A signals + * \author Damian Miralles, 2018, dmiralles2009(at)gmail.com + * + * + * ------------------------------------------------------------------------- + * + * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) + * + * GNSS-SDR is a software defined Global Navigation + * Satellite Systems receiver + * + * This file is part of GNSS-SDR. + * + * GNSS-SDR is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * GNSS-SDR is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNSS-SDR. If not, see . + * + * ------------------------------------------------------------------------- + */ + + +#include +#include +#include +#include +#include +#include +#include +#include +#include "gnss_block_interface.h" +#include "in_memory_configuration.h" +#include "configuration_interface.h" +#include "gnss_synchro.h" +#include "glonass_l2_ca_pcps_acquisition.h" +#include "signal_generator.h" +#include "signal_generator_c.h" +#include "fir_filter.h" +#include "gen_signal_source.h" +#include "gnss_sdr_valve.h" +#include "boost/shared_ptr.hpp" +#include "pass_through.h" + + +// ######## GNURADIO BLOCK MESSAGE RECEVER ######### +class GlonassL2CaPcpsAcquisitionTest_msg_rx; + +typedef boost::shared_ptr GlonassL2CaPcpsAcquisitionTest_msg_rx_sptr; + +GlonassL2CaPcpsAcquisitionTest_msg_rx_sptr GlonassL2CaPcpsAcquisitionTest_msg_rx_make(concurrent_queue& queue); + + +class GlonassL2CaPcpsAcquisitionTest_msg_rx : public gr::block +{ +private: + friend GlonassL2CaPcpsAcquisitionTest_msg_rx_sptr GlonassL2CaPcpsAcquisitionTest_msg_rx_make(concurrent_queue& queue); + void msg_handler_events(pmt::pmt_t msg); + GlonassL2CaPcpsAcquisitionTest_msg_rx(concurrent_queue& queue); + concurrent_queue& channel_internal_queue; + +public: + int rx_message; + ~GlonassL2CaPcpsAcquisitionTest_msg_rx(); //!< Default destructor +}; + + +GlonassL2CaPcpsAcquisitionTest_msg_rx_sptr GlonassL2CaPcpsAcquisitionTest_msg_rx_make(concurrent_queue& queue) +{ + return GlonassL2CaPcpsAcquisitionTest_msg_rx_sptr(new GlonassL2CaPcpsAcquisitionTest_msg_rx(queue)); +} + + +void GlonassL2CaPcpsAcquisitionTest_msg_rx::msg_handler_events(pmt::pmt_t msg) +{ + try + { + long int message = pmt::to_long(msg); + rx_message = message; + channel_internal_queue.push(rx_message); + } + catch (boost::bad_any_cast& e) + { + LOG(WARNING) << "msg_handler_telemetry Bad any cast!"; + rx_message = 0; + } +} + + +GlonassL2CaPcpsAcquisitionTest_msg_rx::GlonassL2CaPcpsAcquisitionTest_msg_rx(concurrent_queue& queue) : gr::block("GlonassL2CaPcpsAcquisitionTest_msg_rx", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)), channel_internal_queue(queue) +{ + this->message_port_register_in(pmt::mp("events")); + this->set_msg_handler(pmt::mp("events"), boost::bind(&GlonassL2CaPcpsAcquisitionTest_msg_rx::msg_handler_events, this, _1)); + rx_message = 0; +} + + +GlonassL2CaPcpsAcquisitionTest_msg_rx::~GlonassL2CaPcpsAcquisitionTest_msg_rx() +{ +} + + +// ########################################################### + +class GlonassL2CaPcpsAcquisitionTest : public ::testing::Test +{ +protected: + GlonassL2CaPcpsAcquisitionTest() + { + item_size = sizeof(gr_complex); + stop = false; + message = 0; + gnss_synchro = Gnss_Synchro(); + acquisition = 0; + init(); + } + + ~GlonassL2CaPcpsAcquisitionTest() + { + } + + void init(); + void config_1(); + void config_2(); + void start_queue(); + void wait_message(); + void process_message(); + void stop_queue(); + + concurrent_queue channel_internal_queue; + + gr::msg_queue::sptr queue; + gr::top_block_sptr top_block; + GlonassL2CaPcpsAcquisition* acquisition; + std::shared_ptr config; + Gnss_Synchro gnss_synchro; + size_t item_size; + bool stop; + int message; + boost::thread ch_thread; + + unsigned int integration_time_ms = 0; + unsigned int fs_in = 0; + + double expected_delay_chips = 0.0; + double expected_doppler_hz = 0.0; + float max_doppler_error_hz = 0.0; + float max_delay_error_chips = 0.0; + + unsigned int num_of_realizations = 0; + unsigned int realization_counter; + unsigned int detection_counter; + unsigned int correct_estimation_counter; + unsigned int acquired_samples; + unsigned int mean_acq_time_us; + + double mse_doppler; + double mse_delay; + + double Pd; + double Pfa_p; + double Pfa_a; +}; + + +void GlonassL2CaPcpsAcquisitionTest::init() +{ + message = 0; + realization_counter = 0; + detection_counter = 0; + correct_estimation_counter = 0; + acquired_samples = 0; + mse_doppler = 0; + mse_delay = 0; + mean_acq_time_us = 0; + Pd = 0; + Pfa_p = 0; + Pfa_a = 0; +} + + +void GlonassL2CaPcpsAcquisitionTest::config_1() +{ + gnss_synchro.Channel_ID = 0; + gnss_synchro.System = 'R'; + std::string signal = "2G"; + signal.copy(gnss_synchro.Signal, 2, 0); + + integration_time_ms = 1; + fs_in = 31.75e6; + + expected_delay_chips = 255; + expected_doppler_hz = -1500; + max_doppler_error_hz = 2 / (3 * integration_time_ms * 1e-3); + max_delay_error_chips = 0.50; + + num_of_realizations = 1; + + config = std::make_shared(); + + config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(fs_in)); + + config->set_property("SignalSource.fs_hz", std::to_string(fs_in)); + + config->set_property("SignalSource.item_type", "gr_complex"); + + config->set_property("SignalSource.num_satellites", "1"); + + config->set_property("SignalSource.system_0", "R"); + config->set_property("SignalSource.PRN_0", "10"); + config->set_property("SignalSource.CN0_dB_0", "44"); + config->set_property("SignalSource.doppler_Hz_0", std::to_string(expected_doppler_hz)); + config->set_property("SignalSource.delay_chips_0", std::to_string(expected_delay_chips)); + + config->set_property("SignalSource.noise_flag", "false"); + config->set_property("SignalSource.data_flag", "false"); + config->set_property("SignalSource.BW_BB", "0.97"); + + config->set_property("InputFilter.implementation", "Fir_Filter"); + config->set_property("InputFilter.input_item_type", "gr_complex"); + config->set_property("InputFilter.output_item_type", "gr_complex"); + config->set_property("InputFilter.taps_item_type", "float"); + config->set_property("InputFilter.number_of_taps", "11"); + config->set_property("InputFilter.number_of_bands", "2"); + config->set_property("InputFilter.band1_begin", "0.0"); + config->set_property("InputFilter.band1_end", "0.97"); + config->set_property("InputFilter.band2_begin", "0.98"); + config->set_property("InputFilter.band2_end", "1.0"); + config->set_property("InputFilter.ampl1_begin", "1.0"); + config->set_property("InputFilter.ampl1_end", "1.0"); + config->set_property("InputFilter.ampl2_begin", "0.0"); + config->set_property("InputFilter.ampl2_end", "0.0"); + config->set_property("InputFilter.band1_error", "1.0"); + config->set_property("InputFilter.band2_error", "1.0"); + config->set_property("InputFilter.filter_type", "bandpass"); + config->set_property("InputFilter.grid_density", "16"); + + config->set_property("Acquisition_2G.item_type", "gr_complex"); + config->set_property("Acquisition_2G.if", "4000000"); + config->set_property("Acquisition_2G.coherent_integration_time_ms", + std::to_string(integration_time_ms)); + config->set_property("Acquisition_2G.max_dwells", "1"); + config->set_property("Acquisition_2G.implementation", "GLONASS_L2_CA_PCPS_Acquisition"); + config->set_property("Acquisition_2G.threshold", "0.8"); + config->set_property("Acquisition_2G.doppler_max", "10000"); + config->set_property("Acquisition_2G.doppler_step", "250"); + config->set_property("Acquisition_2G.bit_transition_flag", "false"); + config->set_property("Acquisition_2G.dump", "false"); +} + + +void GlonassL2CaPcpsAcquisitionTest::config_2() +{ + gnss_synchro.Channel_ID = 0; + gnss_synchro.System = 'R'; + std::string signal = "2G"; + signal.copy(gnss_synchro.Signal, 2, 0); + + integration_time_ms = 1; + fs_in = 31.75e6; + + expected_delay_chips = 374; + expected_doppler_hz = -2000; + max_doppler_error_hz = 2 / (3 * integration_time_ms * 1e-3); + max_delay_error_chips = 0.50; + + num_of_realizations = 100; + + config = std::make_shared(); + + config->set_property("GNSS-SDR.internal_fs_sps", std::to_string(fs_in)); + + config->set_property("SignalSource.fs_hz", std::to_string(fs_in)); + + config->set_property("SignalSource.item_type", "gr_complex"); + + config->set_property("SignalSource.num_satellites", "4"); + + config->set_property("SignalSource.system_0", "R"); + config->set_property("SignalSource.PRN_0", "10"); + config->set_property("SignalSource.CN0_dB_0", "44"); + config->set_property("SignalSource.doppler_Hz_0", std::to_string(expected_doppler_hz)); + config->set_property("SignalSource.delay_chips_0", std::to_string(expected_delay_chips)); + + config->set_property("SignalSource.system_1", "R"); + config->set_property("SignalSource.PRN_1", "15"); + config->set_property("SignalSource.CN0_dB_1", "44"); + config->set_property("SignalSource.doppler_Hz_1", "1000"); + config->set_property("SignalSource.delay_chips_1", "100"); + + config->set_property("SignalSource.system_2", "R"); + config->set_property("SignalSource.PRN_2", "21"); + config->set_property("SignalSource.CN0_dB_2", "44"); + config->set_property("SignalSource.doppler_Hz_2", "2000"); + config->set_property("SignalSource.delay_chips_2", "200"); + + config->set_property("SignalSource.system_3", "R"); + config->set_property("SignalSource.PRN_3", "22"); + config->set_property("SignalSource.CN0_dB_3", "44"); + config->set_property("SignalSource.doppler_Hz_3", "3000"); + config->set_property("SignalSource.delay_chips_3", "300"); + + config->set_property("SignalSource.noise_flag", "true"); + config->set_property("SignalSource.data_flag", "true"); + config->set_property("SignalSource.BW_BB", "0.97"); + + config->set_property("InputFilter.implementation", "Fir_Filter"); + config->set_property("InputFilter.input_item_type", "gr_complex"); + config->set_property("InputFilter.output_item_type", "gr_complex"); + config->set_property("InputFilter.taps_item_type", "float"); + config->set_property("InputFilter.number_of_taps", "11"); + config->set_property("InputFilter.number_of_bands", "2"); + config->set_property("InputFilter.band1_begin", "0.0"); + config->set_property("InputFilter.band1_end", "0.97"); + config->set_property("InputFilter.band2_begin", "0.98"); + config->set_property("InputFilter.band2_end", "1.0"); + config->set_property("InputFilter.ampl1_begin", "1.0"); + config->set_property("InputFilter.ampl1_end", "1.0"); + config->set_property("InputFilter.ampl2_begin", "0.0"); + config->set_property("InputFilter.ampl2_end", "0.0"); + config->set_property("InputFilter.band1_error", "1.0"); + config->set_property("InputFilter.band2_error", "1.0"); + config->set_property("InputFilter.filter_type", "bandpass"); + config->set_property("InputFilter.grid_density", "16"); + + config->set_property("Acquisition_2G.item_type", "gr_complex"); + config->set_property("Acquisition_2G.if", "4000000"); + config->set_property("Acquisition_2G.coherent_integration_time_ms", + std::to_string(integration_time_ms)); + config->set_property("Acquisition_2G.max_dwells", "1"); + config->set_property("Acquisition_2G.implementation", "GLONASS_L2_CA_PCPS_Acquisition"); + config->set_property("Acquisition_2G.pfa", "0.01"); + config->set_property("Acquisition_2G.doppler_max", "10000"); + config->set_property("Acquisition_2G.doppler_step", "250"); + config->set_property("Acquisition_2G.bit_transition_flag", "false"); + config->set_property("Acquisition_2G.dump", "false"); +} + + +void GlonassL2CaPcpsAcquisitionTest::start_queue() +{ + stop = false; + ch_thread = boost::thread(&GlonassL2CaPcpsAcquisitionTest::wait_message, this); +} + + +void GlonassL2CaPcpsAcquisitionTest::wait_message() +{ + struct timeval tv; + long long int begin = 0; + long long int end = 0; + + while (!stop) + { + acquisition->reset(); + + gettimeofday(&tv, NULL); + begin = tv.tv_sec * 1e6 + tv.tv_usec; + + channel_internal_queue.wait_and_pop(message); + + gettimeofday(&tv, NULL); + end = tv.tv_sec * 1e6 + tv.tv_usec; + + mean_acq_time_us += (end - begin); + + process_message(); + } +} + + +void GlonassL2CaPcpsAcquisitionTest::process_message() +{ + if (message == 1) + { + detection_counter++; + + // The term -5 is here to correct the additional delay introduced by the FIR filter + // The value 511.0 must be a variable, chips/length + double delay_error_chips = std::abs(static_cast(expected_delay_chips) - (static_cast(gnss_synchro.Acq_delay_samples) - 5.0) * 511.0 / (static_cast(fs_in) * 1e-3)); + double doppler_error_hz = std::abs(expected_doppler_hz - gnss_synchro.Acq_doppler_hz); + + mse_delay += std::pow(delay_error_chips, 2); + mse_doppler += std::pow(doppler_error_hz, 2); + + if ((delay_error_chips < max_delay_error_chips) && (doppler_error_hz < max_doppler_error_hz)) + { + correct_estimation_counter++; + } + } + + realization_counter++; + + std::cout << "Progress: " << round(static_cast(realization_counter) / static_cast(num_of_realizations) * 100.0) << "% \r" << std::flush; + + if (realization_counter == num_of_realizations) + { + mse_delay /= num_of_realizations; + mse_doppler /= num_of_realizations; + + Pd = static_cast(correct_estimation_counter) / static_cast(num_of_realizations); + Pfa_a = static_cast(detection_counter) / static_cast(num_of_realizations); + Pfa_p = (static_cast(detection_counter) - static_cast(correct_estimation_counter)) / static_cast(num_of_realizations); + + mean_acq_time_us /= num_of_realizations; + + stop_queue(); + top_block->stop(); + } +} + + +void GlonassL2CaPcpsAcquisitionTest::stop_queue() +{ + stop = true; +} + + +TEST_F(GlonassL2CaPcpsAcquisitionTest, Instantiate) +{ + config_1(); + acquisition = new GlonassL2CaPcpsAcquisition(config.get(), "Acquisition", 1, 1); + delete acquisition; +} + + +TEST_F(GlonassL2CaPcpsAcquisitionTest, ConnectAndRun) +{ + int nsamples = floor(fs_in * integration_time_ms * 1e-3); + std::chrono::time_point begin, end; + std::chrono::duration elapsed_seconds(0); + queue = gr::msg_queue::make(0); + top_block = gr::make_top_block("Acquisition test"); + + config_1(); + acquisition = new GlonassL2CaPcpsAcquisition(config.get(), "Acquisition_2G", 1, 1); + boost::shared_ptr msg_rx = GlonassL2CaPcpsAcquisitionTest_msg_rx_make(channel_internal_queue); + + ASSERT_NO_THROW({ + acquisition->connect(top_block); + boost::shared_ptr source = gr::analog::sig_source_c::make(fs_in, gr::analog::GR_SIN_WAVE, 1000, 1, gr_complex(0)); + boost::shared_ptr valve = gnss_sdr_make_valve(sizeof(gr_complex), nsamples, queue); + top_block->connect(source, 0, valve, 0); + top_block->connect(valve, 0, acquisition->get_left_block(), 0); + top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + }) << "Failure connecting the blocks of acquisition test."; + + EXPECT_NO_THROW({ + begin = std::chrono::system_clock::now(); + top_block->run(); // Start threads and wait + end = std::chrono::system_clock::now(); + elapsed_seconds = end - begin; + }) << "Failure running the top_block."; + + std::cout << "Processed " << nsamples << " samples in " << elapsed_seconds.count() * 1e6 << " microseconds" << std::endl; + + delete acquisition; +} + + +TEST_F(GlonassL2CaPcpsAcquisitionTest, ValidationOfResults) +{ + config_1(); + queue = gr::msg_queue::make(0); + top_block = gr::make_top_block("Acquisition test"); + + acquisition = new GlonassL2CaPcpsAcquisition(config.get(), "Acquisition_2G", 1, 1); + boost::shared_ptr msg_rx = GlonassL2CaPcpsAcquisitionTest_msg_rx_make(channel_internal_queue); + + ASSERT_NO_THROW({ + acquisition->set_channel(1); + }) << "Failure setting channel."; + + ASSERT_NO_THROW({ + acquisition->set_gnss_synchro(&gnss_synchro); + }) << "Failure setting gnss_synchro."; + + ASSERT_NO_THROW({ + acquisition->set_doppler_max(10000); + }) << "Failure setting doppler_max."; + + ASSERT_NO_THROW({ + acquisition->set_doppler_step(500); + }) << "Failure setting doppler_step."; + + ASSERT_NO_THROW({ + acquisition->set_threshold(0.0005); + }) << "Failure setting threshold."; + + ASSERT_NO_THROW({ + acquisition->connect(top_block); + top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + }) << "Failure connecting acquisition to the top_block."; + + acquisition->init(); + + ASSERT_NO_THROW({ + boost::shared_ptr signal_source; + SignalGenerator* signal_generator = new SignalGenerator(config.get(), "SignalSource", 0, 1, queue); + FirFilter* filter = new FirFilter(config.get(), "InputFilter", 1, 1); + signal_source.reset(new GenSignalSource(signal_generator, filter, "SignalSource", queue)); + signal_source->connect(top_block); + top_block->connect(signal_source->get_right_block(), 0, acquisition->get_left_block(), 0); + }) << "Failure connecting the blocks of acquisition test."; + + // i = 0 --> satellite in acquisition is visible + // i = 1 --> satellite in acquisition is not visible + for (unsigned int i = 0; i < 2; i++) + { + init(); + + if (i == 0) + { + gnss_synchro.PRN = 10; // This satellite is visible + } + else if (i == 1) + { + gnss_synchro.PRN = 20; // This satellite is not visible + } + + acquisition->set_local_code(); + acquisition->set_state(1); // Ensure that acquisition starts at the first sample + start_queue(); + + EXPECT_NO_THROW({ + top_block->run(); // Start threads and wait + }) << "Failure running the top_block."; + + if (i == 0) + { + EXPECT_EQ(1, message) << "Acquisition failure. Expected message: 1=ACQ SUCCESS."; + if (message == 1) + { + EXPECT_EQ(static_cast(1), correct_estimation_counter) << "Acquisition failure. Incorrect parameters estimation."; + } + } + else if (i == 1) + { + EXPECT_EQ(2, message) << "Acquisition failure. Expected message: 2=ACQ FAIL."; + } +#ifdef OLD_BOOST + ASSERT_NO_THROW({ + ch_thread.timed_join(boost::posix_time::seconds(1)); + }) << "Failure while waiting the queue to stop."; +#endif +#ifndef OLD_BOOST + ASSERT_NO_THROW({ + ch_thread.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(50)); + }) << "Failure while waiting the queue to stop"; +#endif + } + + delete acquisition; +} + + +TEST_F(GlonassL2CaPcpsAcquisitionTest, ValidationOfResultsProbabilities) +{ + config_2(); + queue = gr::msg_queue::make(0); + top_block = gr::make_top_block("Acquisition test"); + acquisition = new GlonassL2CaPcpsAcquisition(config.get(), "Acquisition_2G", 1, 1); + boost::shared_ptr msg_rx = GlonassL2CaPcpsAcquisitionTest_msg_rx_make(channel_internal_queue); + + ASSERT_NO_THROW({ + acquisition->set_channel(1); + }) << "Failure setting channel."; + + ASSERT_NO_THROW({ + acquisition->set_gnss_synchro(&gnss_synchro); + }) << "Failure setting gnss_synchro."; + + ASSERT_NO_THROW({ + acquisition->set_doppler_max(config->property("Acquisition_2G.doppler_max", 10000)); + }) << "Failure setting doppler_max."; + + ASSERT_NO_THROW({ + acquisition->set_doppler_step(config->property("Acquisition_2G.doppler_step", 500)); + }) << "Failure setting doppler_step."; + + ASSERT_NO_THROW({ + acquisition->set_threshold(config->property("Acquisition_2G.threshold", 0.0)); + }) << "Failure setting threshold."; + + ASSERT_NO_THROW({ + acquisition->connect(top_block); + top_block->msg_connect(acquisition->get_right_block(), pmt::mp("events"), msg_rx, pmt::mp("events")); + }) << "Failure connecting acquisition to the top_block."; + + acquisition->init(); + + ASSERT_NO_THROW({ + boost::shared_ptr signal_source; + SignalGenerator* signal_generator = new SignalGenerator(config.get(), "SignalSource", 0, 1, queue); + FirFilter* filter = new FirFilter(config.get(), "InputFilter", 1, 1); + signal_source.reset(new GenSignalSource(signal_generator, filter, "SignalSource", queue)); + signal_source->connect(top_block); + top_block->connect(signal_source->get_right_block(), 0, acquisition->get_left_block(), 0); + }) << "Failure connecting the blocks of acquisition test."; + + std::cout << "Probability of false alarm (target) = " << 0.1 << std::endl; + + // i = 0 --> satellite in acquisition is visible (prob of detection and prob of detection with wrong estimation) + // i = 1 --> satellite in acquisition is not visible (prob of false detection) + for (unsigned int i = 0; i < 2; i++) + { + init(); + + if (i == 0) + { + gnss_synchro.PRN = 10; // This satellite is visible + } + else if (i == 1) + { + gnss_synchro.PRN = 1; // This satellite is not visible + } + + acquisition->set_local_code(); + + start_queue(); + + EXPECT_NO_THROW({ + top_block->run(); // Start threads and wait + }) << "Failure running the top_block."; + + if (i == 0) + { + std::cout << "Estimated probability of detection = " << Pd << std::endl; + std::cout << "Estimated probability of false alarm (satellite present) = " << Pfa_p << std::endl; + std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl; + } + else if (i == 1) + { + std::cout << "Estimated probability of false alarm (satellite absent) = " << Pfa_a << std::endl; + std::cout << "Mean acq time = " << mean_acq_time_us << " microseconds." << std::endl; + } +#ifdef OLD_BOOST + ASSERT_NO_THROW({ + ch_thread.timed_join(boost::posix_time::seconds(1)); + }) << "Failure while waiting the queue to stop"; +#endif +#ifndef OLD_BOOST + ASSERT_NO_THROW({ + ch_thread.try_join_until(boost::chrono::steady_clock::now() + boost::chrono::milliseconds(50)); + }) << "Failure while waiting the queue to stop"; +#endif + } + + delete acquisition; +} diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.cc b/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.cc index b8f259501..0f8dd9dc3 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.cc +++ b/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.cc @@ -35,24 +35,24 @@ bool tracking_dump_reader::read_binary_obs() { try { + d_dump_file.read(reinterpret_cast(&abs_VE), sizeof(float)); d_dump_file.read(reinterpret_cast(&abs_E), sizeof(float)); d_dump_file.read(reinterpret_cast(&abs_P), sizeof(float)); d_dump_file.read(reinterpret_cast(&abs_L), sizeof(float)); + d_dump_file.read(reinterpret_cast(&abs_VL), sizeof(float)); d_dump_file.read(reinterpret_cast(&prompt_I), sizeof(float)); d_dump_file.read(reinterpret_cast(&prompt_Q), sizeof(float)); - d_dump_file.read(reinterpret_cast(&PRN_start_sample_count), sizeof(unsigned long int)); - - d_dump_file.read(reinterpret_cast(&acc_carrier_phase_rad), sizeof(double)); - d_dump_file.read(reinterpret_cast(&carrier_doppler_hz), sizeof(double)); - d_dump_file.read(reinterpret_cast(&code_freq_chips), sizeof(double)); - d_dump_file.read(reinterpret_cast(&carr_error_hz), sizeof(double)); - d_dump_file.read(reinterpret_cast(&carr_error_filt_hz), sizeof(double)); - d_dump_file.read(reinterpret_cast(&code_error_chips), sizeof(double)); - d_dump_file.read(reinterpret_cast(&code_error_filt_chips), sizeof(double)); - d_dump_file.read(reinterpret_cast(&CN0_SNV_dB_Hz), sizeof(double)); - d_dump_file.read(reinterpret_cast(&carrier_lock_test), sizeof(double)); - d_dump_file.read(reinterpret_cast(&aux1), sizeof(double)); + d_dump_file.read(reinterpret_cast(&acc_carrier_phase_rad), sizeof(float)); + d_dump_file.read(reinterpret_cast(&carrier_doppler_hz), sizeof(float)); + d_dump_file.read(reinterpret_cast(&code_freq_chips), sizeof(float)); + d_dump_file.read(reinterpret_cast(&carr_error_hz), sizeof(float)); + d_dump_file.read(reinterpret_cast(&carr_error_filt_hz), sizeof(float)); + d_dump_file.read(reinterpret_cast(&code_error_chips), sizeof(float)); + d_dump_file.read(reinterpret_cast(&code_error_filt_chips), sizeof(float)); + d_dump_file.read(reinterpret_cast(&CN0_SNV_dB_Hz), sizeof(float)); + d_dump_file.read(reinterpret_cast(&carrier_lock_test), sizeof(float)); + d_dump_file.read(reinterpret_cast(&aux1), sizeof(float)); d_dump_file.read(reinterpret_cast(&aux2), sizeof(double)); d_dump_file.read(reinterpret_cast(&PRN), sizeof(unsigned int)); } @@ -82,8 +82,8 @@ bool tracking_dump_reader::restart() long int tracking_dump_reader::num_epochs() { std::ifstream::pos_type size; - int number_of_double_vars = 11; - int number_of_float_vars = 5; + int number_of_double_vars = 1; + int number_of_float_vars = 17; int epoch_size_bytes = sizeof(unsigned long int) + sizeof(double) * number_of_double_vars + sizeof(float) * number_of_float_vars + sizeof(unsigned int); std::ifstream tmpfile(d_dump_filename.c_str(), std::ios::binary | std::ios::ate); diff --git a/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.h b/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.h index 2a56fdd1c..e36dec1c8 100644 --- a/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.h +++ b/src/tests/unit-tests/signal-processing-blocks/libs/tracking_dump_reader.h @@ -45,10 +45,12 @@ public: bool open_obs_file(std::string out_file); //tracking dump variables - // EPR + // VEPLVL + float abs_VE; float abs_E; float abs_P; float abs_L; + float abs_VL; // PROMPT I and Q (to analyze navigation symbols) float prompt_I; float prompt_Q; @@ -56,26 +58,26 @@ public: unsigned long int PRN_start_sample_count; // accumulated carrier phase - double acc_carrier_phase_rad; + float acc_carrier_phase_rad; // carrier and code frequency - double carrier_doppler_hz; - double code_freq_chips; + float carrier_doppler_hz; + float code_freq_chips; // PLL commands - double carr_error_hz; - double carr_error_filt_hz; + float carr_error_hz; + float carr_error_filt_hz; // DLL commands - double code_error_chips; - double code_error_filt_chips; + float code_error_chips; + float code_error_filt_chips; // CN0 and carrier lock test - double CN0_SNV_dB_Hz; - double carrier_lock_test; + float CN0_SNV_dB_Hz; + float carrier_lock_test; // AUX vars (for debug purposes) - double aux1; + float aux1; double aux2; unsigned int PRN; diff --git a/src/tests/unit-tests/signal-processing-blocks/pvt/rtcm_test.cc b/src/tests/unit-tests/signal-processing-blocks/pvt/rtcm_test.cc index 44832da9f..c2b4bfad2 100644 --- a/src/tests/unit-tests/signal-processing-blocks/pvt/rtcm_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/pvt/rtcm_test.cc @@ -292,7 +292,7 @@ TEST(RtcmTest, MT1020) gnav_ephemeris.d_t_k = 7560; // Glonass signed values gnav_ephemeris.d_VXn = -0.490900039672852; - // Bit distribution per fields dependant on other factors + // Bit distribution per fields dependent on other factors gnav_ephemeris.d_t_b = 8100; // Binary flag representation gnav_ephemeris.d_P_3 = 1; 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 b4fe6b852..9d29b837d 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 @@ -240,6 +240,9 @@ void GpsL1CADllPllTrackingTest::configure_receiver() config->set_property("Tracking_1C.dll_bw_hz", "2.0"); } config->set_property("Tracking_1C.early_late_space_chips", "0.5"); + config->set_property("Tracking_1C.pll_bw_narrow_hz", "20.0"); + config->set_property("Tracking_1C.dll_bw_narrow_hz", "2.0"); + config->set_property("Tracking_1C.early_late_space_narrow_chips", "0.5"); config->set_property("Tracking_1C.extend_correlation_ms", "1"); config->set_property("Tracking_1C.dump", "true"); config->set_property("Tracking_1C.dump_filename", "./tracking_ch_"); diff --git a/src/utils/front-end-cal/main.cc b/src/utils/front-end-cal/main.cc index 70408c67a..306869392 100644 --- a/src/utils/front-end-cal/main.cc +++ b/src/utils/front-end-cal/main.cc @@ -154,7 +154,7 @@ void wait_message() { int message; channel_internal_queue.wait_and_pop(message); - //std::cout<<"Acq mesage rx="< gnuplot 8_sat_IFEN_accuracy_precision.plt - -#set terminal pdf color font "Bold,14" -#set output "IFEN_solutions_pdf" -set terminal jpeg font "Helvetica, 14" -set output "8_sat_accuracy_precision.jpeg" - -set grid -set xrange [-15:15] -set yrange [-10:20] -set ylabel "North [m]" -set xlabel "East [m]" - -set key Left left -set title "Accuracy-Precision (with respect to CORRECT coordinates)- 2DRMS" -file1="4_GPS_3_GAL_GNSS_SDR_solutions.txt" -file2="8_GAL_GNSS_SDR_solutions.txt" -file3="8_GPS_GNSS_SDR_solutions.txt" - -#values to copy from statistic file -DRMS_1=2*3.077 #it is 2*DRMS combined -DRMS_2=2*1.87 # gal -DRMS_3=2*2.034 # gps - -#difference with respect to the reference position - -#values to copy from statistic file -delta_E_1=-1.812 #combined -delta_N_1= 3.596 #combined - -delta_E_2= 1.191 #gal -delta_N_2= 1.923 #gal - -delta_E_3= -0.560 #gps -delta_N_3= 1.323 #gps - -set parametric -#dummy variable is t for curves, u/v for surfaces -set size square -set angle degree -set trange [0:360] - -plot file1 u 9:10 with points pointsize 0.3 lc rgb "green" title "4 GPS-3 GAL",\ -file3 u 9:10 with points pointsize 0.3 lc rgb "red" title "8 GPS",\ -file2 u 9:10 with points pointsize 0.3 lc rgb "blue" title "8 GAL",\ -DRMS_1*sin(t)+delta_E_1,DRMS_1*cos(t)+delta_N_1 lw 2 lc rgb "green" notitle,\ -DRMS_3*sin(t)+delta_E_3,DRMS_3*cos(t)+delta_N_3 lw 2 lc rgb "red" notitle,\ -DRMS_2*sin(t)+delta_E_2,DRMS_2*cos(t)+delta_N_2 lw 2 lc rgb "blue" notitle - diff --git a/src/utils/gnuplot/statistics/4_GPS_3_GAL_GNSS_SDR_statitics.txt b/src/utils/gnuplot/statistics/4_GPS_3_GAL_GNSS_SDR_statitics.txt deleted file mode 100644 index 158166f50..000000000 --- a/src/utils/gnuplot/statistics/4_GPS_3_GAL_GNSS_SDR_statitics.txt +++ /dev/null @@ -1,23 +0,0 @@ -Num of GPS observation 4 -Num of GALILEO observation 3 -GDOP mean= 2.380532594 - -ENU computed at (IFEN true coordinates): ref Longitude = 11.808005630, Ref Latitude = 48.171497670 for Accuracy -ENU computed at (average coordinates) mean Longitude = 11.807981252, mean Latitude = 48.171530020 for Precision - -ACCURACY (respect true position) -East offset [m] = -1.812959237, East st. dev = 1.899085141 -Nord offset [m] = 3.596061973,Noth st. dev = 2.422058671 -Up offset [m] = 8.995532878, Up st. dev = 3.881428324 - -DRMS= 3.077806456 -DUE_DRMS= 6.155612912 -CEP= 2.565164055 -MRSE= 4.953622757 -SEP= 12.514572993 - -PRECISION (respect average solution) -East offset [m] = 0.000000000, East st. dev = 1.899086239 -Nord offset [m] = -0.000000001, ,Noth st. dev = 2.422059160 -Up offset [m]= -0.000000003, Up st. dev = 3.881427482 ----------------------------------------------------------------------------------------------- diff --git a/src/utils/gnuplot/statistics/8_GAL_GNSS_SDR_statitics.txt b/src/utils/gnuplot/statistics/8_GAL_GNSS_SDR_statitics.txt deleted file mode 100644 index 88c48dde2..000000000 --- a/src/utils/gnuplot/statistics/8_GAL_GNSS_SDR_statitics.txt +++ /dev/null @@ -1,23 +0,0 @@ -Num of GPS observation 0 -Num of GALILEO observation 8 -GDOP mean= 1.769225604 - -ENU computed at (IFEN true coordinates): ref Longitude = 11.808005630, Ref Latitude = 48.171497670 for Accuracy -ENU computed at (average coordinates) mean Longitude = 11.808021645, mean Latitude = 48.171514975 for Precision - -ACCURACY (respect true position) -East offset [m] = 1.191616778, East st. dev = 1.370472661 -Nord offset [m] = 1.923075914,Noth st. dev = 1.272461214 -Up offset [m] = 13.774563698, Up st. dev = 3.492269580 - -DRMS= 1.870121081 -DUE_DRMS= 3.740242162 -CEP= 1.556390643 -MRSE= 3.961476957 -SEP= 8.003582836 - -PRECISION (respect average solution) -East offset [m] = -0.000000002, East st. dev = 1.370472897 -Nord offset [m] = -0.000000001, ,Noth st. dev = 1.272461012 -Up offset [m]= 0.000000002, Up st. dev = 3.492269562 ----------------------------------------------------------------------------------------------- diff --git a/src/utils/gnuplot/statistics/8_GPS_GNSS_SDR_statitics.txt b/src/utils/gnuplot/statistics/8_GPS_GNSS_SDR_statitics.txt deleted file mode 100644 index a0ce5df5f..000000000 --- a/src/utils/gnuplot/statistics/8_GPS_GNSS_SDR_statitics.txt +++ /dev/null @@ -1,23 +0,0 @@ -Num of GPS observation 8 -Num of GALILEO observation 0 -GDOP mean= 2.002216944 - -ENU computed at (IFEN true coordinates): ref Longitude = 11.808005630, Ref Latitude = 48.171497670 for Accuracy -ENU computed at (average coordinates) mean Longitude = 11.807998091, mean Latitude = 48.171509585 for Precision - -ACCURACY (respect true position) -East offset [m] = -0.560396234, East st. dev = 1.105718017 -Nord offset [m] = 1.323685667,Noth st. dev = 1.707810937 -Up offset [m] = 10.792857384, Up st. dev = 3.121160956 - -DRMS= 2.034509899 -DUE_DRMS= 4.069019799 -CEP= 1.678044871 -MRSE= 3.725704798 -SEP= 7.079246885 - -PRECISION (respect average solution) -East offset [m] = 0.000000000, East st. dev = 1.105718027 -Nord offset [m] = -0.000000005, ,Noth st. dev = 1.707811217 -Up offset [m]= -0.000000005, Up st. dev = 3.121160800 ----------------------------------------------------------------------------------------------- diff --git a/src/utils/matlab/dll_pll_veml_plot_sample.m b/src/utils/matlab/dll_pll_veml_plot_sample.m new file mode 100644 index 000000000..cd79955e3 --- /dev/null +++ b/src/utils/matlab/dll_pll_veml_plot_sample.m @@ -0,0 +1,83 @@ +% Reads GNSS-SDR Tracking dump binary file using the provided +% function and plots some internal variables +% Javier Arribas, 2011. jarribas(at)cttc.es +% Antonio Ramos, 2018. antonio.ramos(at)cttc.es +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- +% + +close all; +clear all; + +if ~exist('dll_pll_veml_read_tracking_dump.m', 'file') + addpath('./libs') +end + +samplingFreq = 5000000; %[Hz] +coherent_integration_time_ms = 20; %[ms] +channels = 5; % Number of channels +first_channel = 0; % Number of the first channel + +path = '/dump_dir/'; %% CHANGE THIS PATH + +for N=1:1:channels + tracking_log_path = [path 'track_ch_' num2str(N+first_channel-1) '.dat']; %% CHANGE track_ch_ BY YOUR dump_filename + GNSS_tracking(N) = dll_pll_veml_read_tracking_dump(tracking_log_path); +end + +% GNSS-SDR format conversion to MATLAB GPS receiver + +for N=1:1:channels + trackResults(N).status = 'T'; %fake track + trackResults(N).codeFreq = GNSS_tracking(N).code_freq_hz.'; + trackResults(N).carrFreq = GNSS_tracking(N).carrier_doppler_hz.'; + trackResults(N).dllDiscr = GNSS_tracking(N).code_error.'; + trackResults(N).dllDiscrFilt = GNSS_tracking(N).code_nco.'; + trackResults(N).pllDiscr = GNSS_tracking(N).carr_error.'; + trackResults(N).pllDiscrFilt = GNSS_tracking(N).carr_nco.'; + + trackResults(N).I_P = GNSS_tracking(N).P.'; + trackResults(N).Q_P = zeros(1,length(GNSS_tracking(N).P)); + + trackResults(N).I_VE = GNSS_tracking(N).VE.'; + trackResults(N).I_E = GNSS_tracking(N).E.'; + trackResults(N).I_L = GNSS_tracking(N).L.'; + trackResults(N).I_VL = GNSS_tracking(N).VL.'; + trackResults(N).Q_VE = zeros(1,length(GNSS_tracking(N).VE)); + trackResults(N).Q_E = zeros(1,length(GNSS_tracking(N).E)); + trackResults(N).Q_L = zeros(1,length(GNSS_tracking(N).L)); + trackResults(N).Q_VL = zeros(1,length(GNSS_tracking(N).VL)); + trackResults(N).data_I = GNSS_tracking(N).prompt_I.'; + trackResults(N).data_Q = GNSS_tracking(N).prompt_Q.'; + trackResults(N).PRN = GNSS_tracking(N).PRN.'; + trackResults(N).CNo = GNSS_tracking(N).CN0_SNV_dB_Hz.'; + + % Use original MATLAB tracking plot function + settings.numberOfChannels = channels; + settings.msToProcess = length(GNSS_tracking(N).E) * coherent_integration_time_ms; + plotVEMLTracking(N, trackResults, settings) +end + + + diff --git a/src/utils/matlab/galileo_e1_dll_pll_veml_plot_sample.m b/src/utils/matlab/galileo_e1_dll_pll_veml_plot_sample.m index 19bc3de13..240c279f7 100644 --- a/src/utils/matlab/galileo_e1_dll_pll_veml_plot_sample.m +++ b/src/utils/matlab/galileo_e1_dll_pll_veml_plot_sample.m @@ -1,80 +1,79 @@ -% /*! -% * \file galileo_l1_ca_dll_pll_vml_plot_sample.m -% * \brief Read GNSS-SDR Tracking dump binary file using the provided -% function and plot some internal variables -% * \author Javier Arribas, 2011. jarribas(at)cttc.es -% * ------------------------------------------------------------------------- -% * -% * Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors) -% * -% * GNSS-SDR is a software defined Global Navigation -% * Satellite Systems receiver -% * -% * This file is part of GNSS-SDR. -% * -% * GNSS-SDR is free software: you can redistribute it and/or modify -% * it under the terms of the GNU General Public License as published by -% * the Free Software Foundation, either version 3 of the License, or -% * at your option) any later version. -% * -% * GNSS-SDR is distributed in the hope that it will be useful, -% * but WITHOUT ANY WARRANTY; without even the implied warranty of -% * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% * GNU General Public License for more details. -% * -% * You should have received a copy of the GNU General Public License -% * along with GNSS-SDR. If not, see . -% * -% * ------------------------------------------------------------------------- -% */ -close all; -clear all; - -if ~exist('galileo_e1_dll_pll_veml_read_tracking_dump.m','file') - addpath('./libs') -end - -samplingFreq = 5000000; %[Hz] -channels = 7; % Number of channels -first_channel = 0; % Number of the first channel - -path = '/Users/carlesfernandez/git/cttc/build/'; %% CHANGE THIS PATH - -for N=1:1:channels - tracking_log_path = [path 'track_ch' num2str(N+first_channel-1) '.dat']; %% CHANGE track_ch BY YOUR dump_filename - GNSS_tracking(N)= galileo_e1_dll_pll_veml_read_tracking_dump(tracking_log_path); -end - -% GNSS-SDR format conversion to MATLAB GPS receiver - -for N=1:1:channels - trackResults(N).status = 'T'; %fake track - trackResults(N).codeFreq = GNSS_tracking(N).code_freq_hz.'; - trackResults(N).carrFreq = GNSS_tracking(N).carrier_doppler_hz.'; - trackResults(N).dllDiscr = GNSS_tracking(N).code_error.'; - trackResults(N).dllDiscrFilt = GNSS_tracking(N).code_nco.'; - trackResults(N).pllDiscr = GNSS_tracking(N).carr_error.'; - trackResults(N).pllDiscrFilt = GNSS_tracking(N).carr_nco.'; - - trackResults(N).I_P = GNSS_tracking(N).prompt_I.'; - trackResults(N).Q_P = GNSS_tracking(N).prompt_Q.'; - - trackResults(N).I_VE = GNSS_tracking(N).VE.'; - trackResults(N).I_E = GNSS_tracking(N).E.'; - trackResults(N).I_L = GNSS_tracking(N).L.'; - trackResults(N).I_VL = GNSS_tracking(N).VL.'; - trackResults(N).Q_VE = zeros(1,length(GNSS_tracking(N).VE)); - trackResults(N).Q_E = zeros(1,length(GNSS_tracking(N).E)); - trackResults(N).Q_L = zeros(1,length(GNSS_tracking(N).L)); - trackResults(N).Q_VL = zeros(1,length(GNSS_tracking(N).VL)); - trackResults(N).PRN = GNSS_tracking(N).PRN.'; - trackResults(N).CNo = GNSS_tracking(N).CN0_SNV_dB_Hz.'; - - % Use original MATLAB tracking plot function - settings.numberOfChannels = channels; - settings.msToProcess = length(GNSS_tracking(N).E)*4; - plotVEMLTracking(N,trackResults,settings) -end - - - +% Reads GNSS-SDR Tracking dump binary file using the provided +% function and plots some internal variables +% Javier Arribas, 2011. jarribas(at)cttc.es +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- +% + +close all; +clear all; + +if ~exist('dll_pll_veml_read_tracking_dump.m', 'file') + addpath('./libs') +end + +samplingFreq = 5000000; %[Hz] +channels = 7; % Number of channels +first_channel = 0; % Number of the first channel + +path = '/Users/carlesfernandez/git/cttc/build/'; %% CHANGE THIS PATH + +for N=1:1:channels + tracking_log_path = [path 'track_ch' num2str(N+first_channel-1) '.dat']; %% CHANGE track_ch BY YOUR dump_filename + GNSS_tracking(N) = dll_pll_veml_read_tracking_dump(tracking_log_path); +end + +% GNSS-SDR format conversion to MATLAB GPS receiver + +for N=1:1:channels + trackResults(N).status = 'T'; %fake track + trackResults(N).codeFreq = GNSS_tracking(N).code_freq_hz.'; + trackResults(N).carrFreq = GNSS_tracking(N).carrier_doppler_hz.'; + trackResults(N).dllDiscr = GNSS_tracking(N).code_error.'; + trackResults(N).dllDiscrFilt = GNSS_tracking(N).code_nco.'; + trackResults(N).pllDiscr = GNSS_tracking(N).carr_error.'; + trackResults(N).pllDiscrFilt = GNSS_tracking(N).carr_nco.'; + + trackResults(N).I_P = GNSS_tracking(N).prompt_I.'; + trackResults(N).Q_P = GNSS_tracking(N).prompt_Q.'; + + trackResults(N).I_VE = GNSS_tracking(N).VE.'; + trackResults(N).I_E = GNSS_tracking(N).E.'; + trackResults(N).I_L = GNSS_tracking(N).L.'; + trackResults(N).I_VL = GNSS_tracking(N).VL.'; + trackResults(N).Q_VE = zeros(1,length(GNSS_tracking(N).VE)); + trackResults(N).Q_E = zeros(1,length(GNSS_tracking(N).E)); + trackResults(N).Q_L = zeros(1,length(GNSS_tracking(N).L)); + trackResults(N).Q_VL = zeros(1,length(GNSS_tracking(N).VL)); + trackResults(N).PRN = GNSS_tracking(N).PRN.'; + trackResults(N).CNo = GNSS_tracking(N).CN0_SNV_dB_Hz.'; + + % Use original MATLAB tracking plot function + settings.numberOfChannels = channels; + settings.msToProcess = length(GNSS_tracking(N).E)*4; + plotVEMLTracking(N, trackResults, settings) +end + + + diff --git a/src/utils/matlab/galileo_e5a_dll_pll_plot_sample.m b/src/utils/matlab/galileo_e5a_dll_pll_plot_sample.m index 54ee9d81e..ad80b985c 100644 --- a/src/utils/matlab/galileo_e5a_dll_pll_plot_sample.m +++ b/src/utils/matlab/galileo_e5a_dll_pll_plot_sample.m @@ -1,33 +1,31 @@ -% /*! -% * \file galileo_e5a_dll_pll_plot_sample.m -% * \brief Read GNSS-SDR Tracking dump binary file using the provided -% function and plot some internal variables -% * \author Javier Arribas, Marc Sales 2014. jarribas(at)cttc.es -% marcsales92@gmail.com -% * ------------------------------------------------------------------------- -% * -% * Copyright (C) 2010-2014 (see AUTHORS file for a list of contributors) -% * -% * GNSS-SDR is a software defined Global Navigation -% * Satellite Systems receiver -% * -% * This file is part of GNSS-SDR. -% * -% * GNSS-SDR is free software: you can redistribute it and/or modify -% * it under the terms of the GNU General Public License as published by -% * the Free Software Foundation, either version 3 of the License, or -% * at your option) any later version. -% * -% * GNSS-SDR is distributed in the hope that it will be useful, -% * but WITHOUT ANY WARRANTY; without even the implied warranty of -% * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% * GNU General Public License for more details. -% * -% * You should have received a copy of the GNU General Public License -% * along with GNSS-SDR. If not, see . -% * -% * ------------------------------------------------------------------------- -% */ +% Reads GNSS-SDR Tracking dump binary file using the provided +% function and plots some internal variables +% Javier Arribas, Marc Sales 2014. jarribas(at)cttc.es, marcsales92@gmail.com +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- +% + close all; clear all; @@ -44,54 +42,54 @@ path = '/Users/carlesfernandez/git/cttc/build/'; %% CHANGE THIS PATH for N=1:1:channels tracking_log_path = [path 'tracking_ch_' num2str(N+first_channel-1) '.dat']; %% CHANGE tracking_ch_ BY YOUR dump_filename - GNSS_tracking(N)= gps_l1_ca_dll_pll_read_tracking_dump(tracking_log_path); + GNSS_tracking(N) = gps_l1_ca_dll_pll_read_tracking_dump(tracking_log_path); end % GNSS-SDR format conversion to MATLAB GPS receiver for N=1:1:channels - trackResults(N).status = 'T'; %fake track - trackResults(N).codeFreq = GNSS_tracking(N).code_freq_hz.'; - trackResults(N).carrFreq = GNSS_tracking(N).carrier_doppler_hz.'; - trackResults(N).dllDiscr = GNSS_tracking(N).code_error.'; - trackResults(N).dllDiscrFilt = GNSS_tracking(N).code_nco.'; - trackResults(N).pllDiscr = GNSS_tracking(N).carr_error.'; - trackResults(N).pllDiscrFilt = GNSS_tracking(N).carr_nco.'; - - trackResults(N).I_PN = GNSS_tracking(N).prompt_I.'; - trackResults(N).Q_PN = GNSS_tracking(N).prompt_Q.'; - trackResults(N).Q_P = zeros(1,length(GNSS_tracking(N).P)); - trackResults(N).I_P = GNSS_tracking(N).P.'; - - trackResults(N).I_E = GNSS_tracking(N).E.'; - trackResults(N).I_L = GNSS_tracking(N).L.'; - trackResults(N).Q_E = zeros(1,length(GNSS_tracking(N).E)); - trackResults(N).Q_L = zeros(1,length(GNSS_tracking(N).E)); - trackResults(N).PRN = GNSS_tracking(N).PRN.'; - - % Use original MATLAB tracking plot function - settings.numberOfChannels = channels; - settings.msToProcess = length(GNSS_tracking(N).E); - plotTrackingE5a(N,trackResults,settings) + trackResults(N).status = 'T'; %fake track + trackResults(N).codeFreq = GNSS_tracking(N).code_freq_hz.'; + trackResults(N).carrFreq = GNSS_tracking(N).carrier_doppler_hz.'; + trackResults(N).dllDiscr = GNSS_tracking(N).code_error.'; + trackResults(N).dllDiscrFilt = GNSS_tracking(N).code_nco.'; + trackResults(N).pllDiscr = GNSS_tracking(N).carr_error.'; + trackResults(N).pllDiscrFilt = GNSS_tracking(N).carr_nco.'; + + trackResults(N).I_PN = GNSS_tracking(N).prompt_I.'; + trackResults(N).Q_PN = GNSS_tracking(N).prompt_Q.'; + trackResults(N).Q_P = zeros(1,length(GNSS_tracking(N).P)); + trackResults(N).I_P = GNSS_tracking(N).P.'; + + trackResults(N).I_E = GNSS_tracking(N).E.'; + trackResults(N).I_L = GNSS_tracking(N).L.'; + trackResults(N).Q_E = zeros(1,length(GNSS_tracking(N).E)); + trackResults(N).Q_L = zeros(1,length(GNSS_tracking(N).E)); + trackResults(N).PRN = GNSS_tracking(N).PRN.'; + + % Use original MATLAB tracking plot function + settings.numberOfChannels = channels; + settings.msToProcess = length(GNSS_tracking(N).E); + plotTrackingE5a(N, trackResults, settings) end for N=1:1:channels -% figure; -% plot([GNSS_tracking(N).E,GNSS_tracking(N).P,GNSS_tracking(N).L],'-*'); -% title(['Early, Prompt, and Late correlator absolute value output for channel ' num2str(N)']); -% figure; -% plot(GNSS_tracking(N).prompt_I,GNSS_tracking(N).prompt_Q,'+'); -% title(['Navigation constellation plot for channel ' num2str(N)]); -% figure; -% -% plot(GNSS_tracking(N).prompt_Q,'r'); -% hold on; -% plot(GNSS_tracking(N).prompt_I); -% title(['Navigation symbols I(red) Q(blue) for channel ' num2str(N)]); -% - figure; - t=0:length(GNSS_tracking(N).carrier_doppler_hz)-1; - t=t/1000; - plot(t,GNSS_tracking(N).carrier_doppler_hz/1000); - xlabel('Time(s)');ylabel('Doppler(KHz)');title(['Doppler frequency channel ' num2str(N)]); -end \ No newline at end of file + % figure; + % plot([GNSS_tracking(N).E, GNSS_tracking(N).P, GNSS_tracking(N).L],'-*'); + % title(['Early, Prompt, and Late correlator absolute value output for channel ' num2str(N)']); + % figure; + % plot(GNSS_tracking(N).prompt_I, GNSS_tracking(N).prompt_Q, '+'); + % title(['Navigation constellation plot for channel ' num2str(N)]); + % figure; + % + % plot(GNSS_tracking(N).prompt_Q,'r'); + % hold on; + % plot(GNSS_tracking(N).prompt_I); + % title(['Navigation symbols I(red) Q(blue) for channel ' num2str(N)]); + % + figure; + t = 0:length(GNSS_tracking(N).carrier_doppler_hz)-1; + t = t/1000; + plot(t, GNSS_tracking(N).carrier_doppler_hz / 1000); + xlabel('Time(s)'); ylabel('Doppler(KHz)'); title(['Doppler frequency channel ' num2str(N)]); +end diff --git a/src/utils/matlab/glonass_ca_dll_pll_plot_sample.m b/src/utils/matlab/glonass_ca_dll_pll_plot_sample.m index 7cb6753b4..fc342eb26 100644 --- a/src/utils/matlab/glonass_ca_dll_pll_plot_sample.m +++ b/src/utils/matlab/glonass_ca_dll_pll_plot_sample.m @@ -1,74 +1,73 @@ -% /*! -% * \file glonass_ca_dll_pll_plot_sample.m -% * \brief Read GNSS-SDR Tracking dump binary file using the provided -% function and plot some internal variables -% * \author Damian Miralles, 2017. dmiralles2009(at)gmail.com -% * ------------------------------------------------------------------------- -% * -% * Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors) -% * -% * GNSS-SDR is a software defined Global Navigation -% * Satellite Systems receiver -% * -% * This file is part of GNSS-SDR. -% * -% * GNSS-SDR is free software: you can redistribute it and/or modify -% * it under the terms of the GNU General Public License as published by -% * the Free Software Foundation, either version 3 of the License, or -% * at your option) any later version. -% * -% * GNSS-SDR is distributed in the hope that it will be useful, -% * but WITHOUT ANY WARRANTY; without even the implied warranty of -% * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% * GNU General Public License for more details. -% * -% * You should have received a copy of the GNU General Public License -% * along with GNSS-SDR. If not, see . -% * -% * ------------------------------------------------------------------------- -% */ -close all; -clear all; - -if ~exist('glonass_ca_dll_pll_read_tracking_dump.m','file') - addpath('./libs') -end - - -samplingFreq = 6625000; %[Hz] -channels = 5; -first_channel = 0; - -path = '/archive/'; %% CHANGE THIS PATH - -for N=1:1:channels - tracking_log_path = [path 'glo_tracking_ch_' num2str(N+first_channel-1) '.dat']; %% CHANGE epl_tracking_ch_ BY YOUR dump_filename - GNSS_tracking(N)= glonass_ca_dll_pll_read_tracking_dump(tracking_log_path); -end - -% GNSS-SDR format conversion to MATLAB GPS receiver - -for N=1:1:channels - trackResults(N).status = 'T'; %fake track - trackResults(N).codeFreq = GNSS_tracking(N).code_freq_hz.'; - trackResults(N).carrFreq = GNSS_tracking(N).carrier_freq_hz.'; - trackResults(N).dllDiscr = GNSS_tracking(N).code_error.'; - trackResults(N).dllDiscrFilt = GNSS_tracking(N).code_nco.'; - trackResults(N).pllDiscr = GNSS_tracking(N).carr_error.'; - trackResults(N).pllDiscrFilt = GNSS_tracking(N).carr_nco.'; - - trackResults(N).I_P = GNSS_tracking(N).prompt_I.'; - trackResults(N).Q_P = GNSS_tracking(N).prompt_Q.'; - - trackResults(N).I_E = GNSS_tracking(N).E.'; - trackResults(N).I_L = GNSS_tracking(N).L.'; - trackResults(N).Q_E = zeros(1,length(GNSS_tracking(N).E)); - trackResults(N).Q_L = zeros(1,length(GNSS_tracking(N).E)); - trackResults(N).CNo = GNSS_tracking(N).CN0_SNV_dB_Hz.'; - trackResults(N).PRN = ones(1,length(GNSS_tracking(N).E)); - - % Use original MATLAB tracking plot function - settings.numberOfChannels = channels; - settings.msToProcess = length(GNSS_tracking(N).E); - plotTracking(N,trackResults,settings); -end +% Reads GNSS-SDR Tracking dump binary file using the provided +% function and plots some internal variables +% Damian Miralles, 2017. dmiralles2009(at)gmail.com +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- +% + +close all; +clear all; + +if ~exist('dll_pll_veml_read_tracking_dump.m', 'file') + addpath('./libs') +end + + +samplingFreq = 6625000; %[Hz] +channels = 5; +first_channel = 0; + +path = '/archive/'; %% CHANGE THIS PATH + +for N=1:1:channels + tracking_log_path = [path 'glo_tracking_ch_' num2str(N+first_channel-1) '.dat']; %% CHANGE glo_tracking_ch_ BY YOUR dump_filename + GNSS_tracking(N) = dll_pll_veml_read_tracking_dump(tracking_log_path); +end + +% GNSS-SDR format conversion to MATLAB GPS receiver + +for N=1:1:channels + trackResults(N).status = 'T'; %fake track + trackResults(N).codeFreq = GNSS_tracking(N).code_freq_hz.'; + trackResults(N).carrFreq = GNSS_tracking(N).carrier_freq_hz.'; + trackResults(N).dllDiscr = GNSS_tracking(N).code_error.'; + trackResults(N).dllDiscrFilt = GNSS_tracking(N).code_nco.'; + trackResults(N).pllDiscr = GNSS_tracking(N).carr_error.'; + trackResults(N).pllDiscrFilt = GNSS_tracking(N).carr_nco.'; + + trackResults(N).I_P = GNSS_tracking(N).prompt_I.'; + trackResults(N).Q_P = GNSS_tracking(N).prompt_Q.'; + + trackResults(N).I_E = GNSS_tracking(N).E.'; + trackResults(N).I_L = GNSS_tracking(N).L.'; + trackResults(N).Q_E = zeros(1,length(GNSS_tracking(N).E)); + trackResults(N).Q_L = zeros(1,length(GNSS_tracking(N).E)); + trackResults(N).CNo = GNSS_tracking(N).CN0_SNV_dB_Hz.'; + trackResults(N).PRN = ones(1,length(GNSS_tracking(N).E)); + + % Use original MATLAB tracking plot function + settings.numberOfChannels = channels; + settings.msToProcess = length(GNSS_tracking(N).E); + plotTracking(N, trackResults, settings) +end diff --git a/src/utils/matlab/gps_l1_ca_dll_pll_plot_sample.m b/src/utils/matlab/gps_l1_ca_dll_pll_plot_sample.m index 22ef63f79..093799f7d 100644 --- a/src/utils/matlab/gps_l1_ca_dll_pll_plot_sample.m +++ b/src/utils/matlab/gps_l1_ca_dll_pll_plot_sample.m @@ -1,76 +1,75 @@ -% /*! -% * \file gps_l1_ca_dll_pll_plot_sample.m -% * \brief Read GNSS-SDR Tracking dump binary file using the provided -% function and plot some internal variables -% * \author Javier Arribas, 2011. jarribas(at)cttc.es -% * ------------------------------------------------------------------------- -% * -% * Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors) -% * -% * GNSS-SDR is a software defined Global Navigation -% * Satellite Systems receiver -% * -% * This file is part of GNSS-SDR. -% * -% * GNSS-SDR is free software: you can redistribute it and/or modify -% * it under the terms of the GNU General Public License as published by -% * the Free Software Foundation, either version 3 of the License, or -% * at your option) any later version. -% * -% * GNSS-SDR is distributed in the hope that it will be useful, -% * but WITHOUT ANY WARRANTY; without even the implied warranty of -% * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% * GNU General Public License for more details. -% * -% * You should have received a copy of the GNU General Public License -% * along with GNSS-SDR. If not, see . -% * -% * ------------------------------------------------------------------------- -% */ -close all; -clear all; - -if ~exist('gps_l1_ca_dll_pll_read_tracking_dump.m','file') - addpath('./libs') -end - - -samplingFreq = 6625000; %[Hz] -channels = 5; -first_channel = 0; - -path = '/archive/'; %% CHANGE THIS PATH - -for N=1:1:channels - tracking_log_path = [path 'glo_tracking_ch_' num2str(N+first_channel-1) '.dat']; %% CHANGE epl_tracking_ch_ BY YOUR dump_filename - GNSS_tracking(N)= gps_l1_ca_dll_pll_read_tracking_dump(tracking_log_path); -end - -% GNSS-SDR format conversion to MATLAB GPS receiver - -for N=1:1:channels - trackResults(N).status = 'T'; %fake track - trackResults(N).codeFreq = GNSS_tracking(N).code_freq_hz.'; - trackResults(N).carrFreq = GNSS_tracking(N).carrier_doppler_hz.'; - trackResults(N).dllDiscr = GNSS_tracking(N).code_error.'; - trackResults(N).dllDiscrFilt = GNSS_tracking(N).code_nco.'; - trackResults(N).pllDiscr = GNSS_tracking(N).carr_error.'; - trackResults(N).pllDiscrFilt = GNSS_tracking(N).carr_nco.'; - - trackResults(N).I_P = GNSS_tracking(N).prompt_I.'; - trackResults(N).Q_P = GNSS_tracking(N).prompt_Q.'; - - trackResults(N).I_E = GNSS_tracking(N).E.'; - trackResults(N).I_L = GNSS_tracking(N).L.'; - trackResults(N).Q_E = zeros(1,length(GNSS_tracking(N).E)); - trackResults(N).Q_L = zeros(1,length(GNSS_tracking(N).E)); - trackResults(N).PRN = ones(1,length(GNSS_tracking(N).E)); - trackResults(N).CNo = GNSS_tracking(N).CN0_SNV_dB_Hz.'; - - % Use original MATLAB tracking plot function - settings.numberOfChannels = channels; - settings.msToProcess = length(GNSS_tracking(N).E); - plotTracking(N,trackResults,settings) -end - - +% Reads GNSS-SDR Tracking dump binary file using the provided +% function and plots some internal variables +% Javier Arribas, 2011. jarribas(at)cttc.es +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- +% + +close all; +clear all; + +if ~exist('dll_pll_veml_read_tracking_dump.m', 'file') + addpath('./libs') +end + + +samplingFreq = 6625000; %[Hz] +channels = 5; +first_channel = 0; + +path = '/archive/'; %% CHANGE THIS PATH + +for N=1:1:channels + tracking_log_path = [path 'epl_tracking_ch_' num2str(N+first_channel-1) '.dat']; %% CHANGE epl_tracking_ch_ BY YOUR dump_filename + GNSS_tracking(N) = dll_pll_veml_read_tracking_dump(tracking_log_path); +end + +% GNSS-SDR format conversion to MATLAB GPS receiver + +for N=1:1:channels + trackResults(N).status = 'T'; %fake track + trackResults(N).codeFreq = GNSS_tracking(N).code_freq_hz.'; + trackResults(N).carrFreq = GNSS_tracking(N).carrier_doppler_hz.'; + trackResults(N).dllDiscr = GNSS_tracking(N).code_error.'; + trackResults(N).dllDiscrFilt = GNSS_tracking(N).code_nco.'; + trackResults(N).pllDiscr = GNSS_tracking(N).carr_error.'; + trackResults(N).pllDiscrFilt = GNSS_tracking(N).carr_nco.'; + + trackResults(N).I_P = GNSS_tracking(N).prompt_I.'; + trackResults(N).Q_P = GNSS_tracking(N).prompt_Q.'; + + trackResults(N).I_E = GNSS_tracking(N).E.'; + trackResults(N).I_L = GNSS_tracking(N).L.'; + trackResults(N).Q_E = zeros(1,length(GNSS_tracking(N).E)); + trackResults(N).Q_L = zeros(1,length(GNSS_tracking(N).E)); + trackResults(N).PRN = ones(1,length(GNSS_tracking(N).E)); + trackResults(N).CNo = GNSS_tracking(N).CN0_SNV_dB_Hz.'; + + % Use original MATLAB tracking plot function + settings.numberOfChannels = channels; + settings.msToProcess = length(GNSS_tracking(N).E); + plotTracking(N, trackResults, settings) +end + + diff --git a/src/utils/matlab/gps_l1_ca_pvt_plot_sample_agilent_cap2.m b/src/utils/matlab/gps_l1_ca_pvt_plot_sample_agilent_cap2.m index aa26c38ae..694a3d615 100644 --- a/src/utils/matlab/gps_l1_ca_pvt_plot_sample_agilent_cap2.m +++ b/src/utils/matlab/gps_l1_ca_pvt_plot_sample_agilent_cap2.m @@ -1,32 +1,30 @@ -% /*! -% * \file gps_l1_ca_pvt_plot_sample.m -% * \brief Read GNSS-SDR PVT dump binary file using the provided -% function and plot some internal variables -% * \author Javier Arribas, 2011. jarribas(at)cttc.es -% * ------------------------------------------------------------------------- -% * -% * Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors) -% * -% * GNSS-SDR is a software defined Global Navigation -% * Satellite Systems receiver -% * -% * This file is part of GNSS-SDR. -% * -% * GNSS-SDR is free software: you can redistribute it and/or modify -% * it under the terms of the GNU General Public License as published by -% * the Free Software Foundation, either version 3 of the License, or -% * at your option) any later version. -% * -% * GNSS-SDR is distributed in the hope that it will be useful, -% * but WITHOUT ANY WARRANTY; without even the implied warranty of -% * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% * GNU General Public License for more details. -% * -% * You should have received a copy of the GNU General Public License -% * along with GNSS-SDR. If not, see . -% * -% * ------------------------------------------------------------------------- -% */ +% Reads GNSS-SDR PVT dump binary file using the provided +% function and plots some internal variables +% Javier Arribas, 2011. jarribas(at)cttc.es +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- +% close all; clear all; @@ -63,17 +61,17 @@ h=35; [X, Y, Z]=geo2cart(lat, long, h, 5); % geographical to cartesian conversion %=== Convert to UTM coordinate system ============================= -utmZone = findUtmZone(lat_deg, long_deg); +utmZone = findUtmZone(lat_deg, long_deg); - [settings.truePosition.E, ... - settings.truePosition.N, ... - settings.truePosition.U] = cart2utm(X, Y, Z, utmZone); +[settings.truePosition.E, ... + settings.truePosition.N, ... + settings.truePosition.U] = cart2utm(X, Y, Z, utmZone); for k=1:1:length(navSolutions.X) [navSolutions.E(k), ... - navSolutions.N(k), ... - navSolutions.U(k)]=cart2utm(navSolutions.X(k), navSolutions.Y(k), navSolutions.Z(k), utmZone); + navSolutions.N(k), ... + navSolutions.U(k)]=cart2utm(navSolutions.X(k), navSolutions.Y(k), navSolutions.Z(k), utmZone); end plot_skyplot=0; diff --git a/src/utils/matlab/gps_l1_ca_pvt_raw_plot_sample.m b/src/utils/matlab/gps_l1_ca_pvt_raw_plot_sample.m index 74f620a36..572924da6 100644 --- a/src/utils/matlab/gps_l1_ca_pvt_raw_plot_sample.m +++ b/src/utils/matlab/gps_l1_ca_pvt_raw_plot_sample.m @@ -1,4 +1,28 @@ % Read PVG raw dump +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- +% %clear all; @@ -6,4 +30,4 @@ samplingFreq = 64e6/16; %[Hz] channels=4; path='/home/javier/workspace/gnss-sdr-ref/trunk/install/'; pvt_raw_log_path=[path 'PVT_raw.dat']; -GNSS_PVT_raw= gps_l1_ca_read_pvt_raw_dump(channels,pvt_raw_log_path); +GNSS_PVT_raw= gps_l1_ca_read_pvt_raw_dump(channels,pvt_raw_log_path); diff --git a/src/utils/matlab/gps_l1_ca_telemetry_plot_sample.m b/src/utils/matlab/gps_l1_ca_telemetry_plot_sample.m index b5e60acc1..9e0e27125 100644 --- a/src/utils/matlab/gps_l1_ca_telemetry_plot_sample.m +++ b/src/utils/matlab/gps_l1_ca_telemetry_plot_sample.m @@ -1,40 +1,39 @@ -% /*! -% * \file gps_l1_ca_dll_fll_pll_plot_sample.m -% * \brief Read GNSS-SDR Tracking dump binary file using the provided -% function and plot some internal variables -% * \author Javier Arribas, 2011. jarribas(at)cttc.es -% * ------------------------------------------------------------------------- -% * -% * Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors) -% * -% * GNSS-SDR is a software defined Global Navigation -% * Satellite Systems receiver -% * -% * This file is part of GNSS-SDR. -% * -% * GNSS-SDR is free software: you can redistribute it and/or modify -% * it under the terms of the GNU General Public License as published by -% * the Free Software Foundation, either version 3 of the License, or -% * at your option) any later version. -% * -% * GNSS-SDR is distributed in the hope that it will be useful, -% * but WITHOUT ANY WARRANTY; without even the implied warranty of -% * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% * GNU General Public License for more details. -% * -% * You should have received a copy of the GNU General Public License -% * along with GNSS-SDR. If not, see . -% * -% * ------------------------------------------------------------------------- -% */ -%close all; -%clear all; -samplingFreq = 64e6/16; %[Hz] -channels=4; -path='/home/javier/workspace/gnss-sdr-ref/trunk/install/'; -clear PRN_absolute_sample_start; -for N=1:1:channels - telemetry_log_path=[path 'telemetry' num2str(N-1) '.dat']; - GNSS_telemetry(N)= gps_l1_ca_read_telemetry_dump(telemetry_log_path); -end - +% Reads GNSS-SDR Tracking dump binary file using the provided +% function and plots some internal variables +% Javier Arribas, 2011. jarribas(at)cttc.es +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- +% + +%close all; +%clear all; +samplingFreq = 64e6/16; %[Hz] +channels=4; +path='/home/javier/workspace/gnss-sdr-ref/trunk/install/'; +clear PRN_absolute_sample_start; +for N=1:1:channels + telemetry_log_path=[path 'telemetry' num2str(N-1) '.dat']; + GNSS_telemetry(N)= gps_l1_ca_read_telemetry_dump(telemetry_log_path); +end + diff --git a/src/utils/matlab/help_script1.m b/src/utils/matlab/help_script1.m index 2c08a8d91..0716950e8 100644 --- a/src/utils/matlab/help_script1.m +++ b/src/utils/matlab/help_script1.m @@ -1,3 +1,28 @@ +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- +% + %help script to compare GNSS-SDR Preambles starts channel=3; % From GNSS_SDR telemetry decoder @@ -25,9 +50,9 @@ error_ms=preambles_timestamp_sdr_ms(common_start_index:(common_start_index+lengt % figure % stem(tracking_loop_start+javi_subFrameStart_sample(channel,:),1000*trackResults_sdr(channel).absoluteSample(javi_subFrameStart_sample(channel,:))/settings.samplingFreq); -% +% % hold on; -% +% % plot(GNSS_observables.preamble_delay_ms(channel,:)); -% -% plot(GNSS_observables.prn_delay_ms(channel,:),'r') \ No newline at end of file +% +% plot(GNSS_observables.prn_delay_ms(channel,:),'r') diff --git a/src/utils/matlab/help_script2.m b/src/utils/matlab/help_script2.m index 4be6bfbb8..28fadb535 100644 --- a/src/utils/matlab/help_script2.m +++ b/src/utils/matlab/help_script2.m @@ -1,4 +1,29 @@ -% compare pseudoranges +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- +% + +% compare pseudoranges close all; % GNSS SDR diff --git a/src/utils/matlab/hybrid_observables_plot_sample.m b/src/utils/matlab/hybrid_observables_plot_sample.m index 45b6bf31d..3faca95b1 100644 --- a/src/utils/matlab/hybrid_observables_plot_sample.m +++ b/src/utils/matlab/hybrid_observables_plot_sample.m @@ -1,3 +1,28 @@ +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- +% + % Read observables dump %clear all; @@ -41,24 +66,24 @@ title('Doppler frequency') xlabel('TOW [s]') ylabel('[Hz]'); -% +% % %read true obs from simulator (optional) % GPS_STARTOFFSET_s = 68.802e-3; -% +% % true_observables_log_path='/home/javier/git/gnss-sdr/build/obs_out.bin'; % GNSS_true_observables= read_true_sim_observables_dump(true_observables_log_path); -% +% % %correct the clock error using true values (it is not possible for a receiver to correct % %the receiver clock offset error at the observables level because it is required the % %decoding of the ephemeris data and solve the PVT equations) -% -% SPEED_OF_LIGHT_M_S = 299792458.0; -% +% +% SPEED_OF_LIGHT_M_S = 299792458.0; +% % %find the reference satellite % [~,ref_sat_ch]=min(GNSS_observables.Pseudorange_m(:,min_idx+1)); % shift_time_s=GNSS_true_observables.Pseudorange_m(ref_sat_ch,:)/SPEED_OF_LIGHT_M_S-GPS_STARTOFFSET_s; -% -% +% +% % %Compute deltas if required and interpolate to measurement time % delta_true_psudorange_m=GNSS_true_observables.Pseudorange_m(1,:)-GNSS_true_observables.Pseudorange_m(2,:); % delta_true_interp_psudorange_m=interp1(GNSS_true_observables.RX_time(1,:)-shift_time_s, ... @@ -67,23 +92,23 @@ ylabel('[Hz]'); % GNSS_true_observables.Carrier_phase_hz(1,:),GNSS_observables.RX_time(1,min_idx+1:end),'lineal','extrap'); % true_interp_acc_carrier_phase_ch2_hz=interp1(GNSS_true_observables.RX_time(1,:)-shift_time_s, ... % GNSS_true_observables.Carrier_phase_hz(2,:),GNSS_observables.RX_time(2,min_idx+1:end),'lineal','extrap'); -% +% % %Compute measurement errors -% +% % delta_measured_psudorange_m=GNSS_observables.Pseudorange_m(1,min_idx+1:end)-GNSS_observables.Pseudorange_m(2,min_idx+1:end); % psudorange_error_m=delta_measured_psudorange_m-delta_true_interp_psudorange_m; % psudorange_rms_m=sqrt(sum(psudorange_error_m.^2)/length(psudorange_error_m)) -% +% % acc_carrier_error_ch1_hz=GNSS_observables.Carrier_phase_hz(1,min_idx+1:end)-true_interp_acc_carrier_phase_ch1_hz... % -GNSS_observables.Carrier_phase_hz(1,min_idx+1)+true_interp_acc_carrier_phase_ch1_hz(1); -% +% % acc_phase_rms_ch1_hz=sqrt(sum(acc_carrier_error_ch1_hz.^2)/length(acc_carrier_error_ch1_hz)) -% +% % acc_carrier_error_ch2_hz=GNSS_observables.Carrier_phase_hz(2,min_idx+1:end)-true_interp_acc_carrier_phase_ch2_hz... % -GNSS_observables.Carrier_phase_hz(2,min_idx+1)+true_interp_acc_carrier_phase_ch2_hz(1); % acc_phase_rms_ch2_hz=sqrt(sum(acc_carrier_error_ch2_hz.^2)/length(acc_carrier_error_ch2_hz)) -% -% +% +% % %plot results % figure; % plot(GNSS_true_observables.RX_time(1,:),delta_true_psudorange_m,'g'); @@ -92,25 +117,25 @@ ylabel('[Hz]'); % title('TRUE vs. measured Pseudoranges [m]') % xlabel('TOW [s]') % ylabel('[m]'); -% +% % figure; % plot(GNSS_observables.RX_time(1,min_idx+1:end),psudorange_error_m) % title('Pseudoranges error [m]') % xlabel('TOW [s]') % ylabel('[m]'); -% +% % figure; % plot(GNSS_observables.RX_time(1,min_idx+1:end),acc_carrier_error_ch1_hz) % title('Accumulated carrier phase error CH1 [hz]') % xlabel('TOW [s]') % ylabel('[hz]'); -% +% % figure; % plot(GNSS_observables.RX_time(1,min_idx+1:end),acc_carrier_error_ch2_hz) % title('Accumulated carrier phase error CH2 [hz]') % xlabel('TOW [s]') % ylabel('[hz]'); -% -% -% -% +% +% +% +% diff --git a/src/utils/matlab/libs/dll_pll_veml_read_tracking_dump.m b/src/utils/matlab/libs/dll_pll_veml_read_tracking_dump.m new file mode 100644 index 000000000..8405c9cf3 --- /dev/null +++ b/src/utils/matlab/libs/dll_pll_veml_read_tracking_dump.m @@ -0,0 +1,151 @@ +% Usage: dll_pll_veml_read_tracking_dump (filename, [count]) +% +% Opens GNSS-SDR tracking binary log file .dat and returns the contents + +% Read GNSS-SDR Tracking dump binary file into MATLAB. +% Luis Esteve, 2012. luis(at)epsilon-formacion.com +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- +% + +function [GNSS_tracking] = dll_pll_veml_read_tracking_dump (filename, count) + +m = nargchk (1,2,nargin); + +num_float_vars = 17; +num_unsigned_long_int_vars = 1; +num_double_vars = 1; +num_unsigned_int_vars = 1; + +if(~isempty(strfind(computer('arch'), '64'))) + % 64-bit computer + double_size_bytes = 8; + unsigned_long_int_size_bytes = 8; + float_size_bytes = 4; + unsigned_int_size_bytes = 4; +else + double_size_bytes = 8; + unsigned_long_int_size_bytes = 4; + float_size_bytes = 4; + unsigned_int_size_bytes = 4; +end + +skip_bytes_each_read = float_size_bytes * num_float_vars + unsigned_long_int_size_bytes * num_unsigned_long_int_vars + ... + double_size_bytes * num_double_vars + num_unsigned_int_vars*unsigned_int_size_bytes; + +bytes_shift = 0; + +if (m) + usage (m); +end + +if (nargin < 2) + count = Inf; +end +%loops_counter = fread (f, count, 'uint32',4*12); +f = fopen (filename, 'rb'); +if (f < 0) +else + v1 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v2 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v3 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v4 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v5 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v6 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v7 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next interleaved float + v8 = fread (f, count, 'long', skip_bytes_each_read - unsigned_long_int_size_bytes); + bytes_shift = bytes_shift + unsigned_long_int_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v9 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v10 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v11 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v12 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v13 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v14 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v15 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v16 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next interleaved float + v17 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next float + v18 = fread (f, count, 'float', skip_bytes_each_read-float_size_bytes); + bytes_shift = bytes_shift + float_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next double + v19 = fread (f, count, 'double', skip_bytes_each_read - double_size_bytes); + bytes_shift = bytes_shift + double_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next unsigned int + v20 = fread (f, count, 'uint', skip_bytes_each_read - unsigned_int_size_bytes); + fclose (f); + + GNSS_tracking.VE = v1; + GNSS_tracking.E = v2; + GNSS_tracking.P = v3; + GNSS_tracking.L = v4; + GNSS_tracking.VL = v5; + GNSS_tracking.prompt_I = v6; + GNSS_tracking.prompt_Q = v7; + GNSS_tracking.PRN_start_sample = v8; + GNSS_tracking.acc_carrier_phase_rad = v9; + GNSS_tracking.carrier_doppler_hz = v10; + GNSS_tracking.code_freq_hz = v11; + GNSS_tracking.carr_error = v12; + GNSS_tracking.carr_nco = v13; + GNSS_tracking.code_error = v14; + GNSS_tracking.code_nco = v15; + GNSS_tracking.CN0_SNV_dB_Hz = v16; + GNSS_tracking.carrier_lock_test = v17; + GNSS_tracking.var1 = v18; + GNSS_tracking.var2 = v19; + GNSS_tracking.PRN = v20; +end + diff --git a/src/utils/matlab/libs/galileo_e1_dll_pll_veml_read_tracking_dump.m b/src/utils/matlab/libs/galileo_e1_dll_pll_veml_read_tracking_dump.m deleted file mode 100644 index 0ccb1bb40..000000000 --- a/src/utils/matlab/libs/galileo_e1_dll_pll_veml_read_tracking_dump.m +++ /dev/null @@ -1,153 +0,0 @@ -% /*! -% * \file galileo_e1_dll_pll_veml_read_tracking_dump.m -% * \brief Read GNSS-SDR Tracking dump binary file into MATLAB. -% * \author Luis Esteve, 2012. luis(at)epsilon-formacion.com -% * ------------------------------------------------------------------------- -% * -% * Copyright (C) 2010-2012 (see AUTHORS file for a list of contributors) -% * -% * GNSS-SDR is a software defined Global Navigation -% * Satellite Systems receiver -% * -% * This file is part of GNSS-SDR. -% * -% * GNSS-SDR is free software: you can redistribute it and/or modify -% * it under the terms of the GNU General Public License as published by -% * the Free Software Foundation, either version 3 of the License, or -% * at your option) any later version. -% * -% * GNSS-SDR is distributed in the hope that it will be useful, -% * but WITHOUT ANY WARRANTY; without even the implied warranty of -% * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% * GNU General Public License for more details. -% * -% * You should have received a copy of the GNU General Public License -% * along with GNSS-SDR. If not, see . -% * -% * ------------------------------------------------------------------------- -% */ - -function [GNSS_tracking] = galileo_e1_dll_pll_veml_read_tracking_dump (filename, count) - %% usage: galileo_e1_dll_pll_veml_read_tracking_dump (filename, [count]) - %% - %% open GNSS-SDR tracking binary log file .dat and return the contents - %% - - m = nargchk (1,2,nargin); - - num_float_vars = 17; - num_unsigned_long_int_vars = 1; - num_double_vars = 1; - num_unsigned_int_vars = 1; - - if(~isempty(strfind(computer('arch'), '64'))) - % 64-bit computer - double_size_bytes = 8; - unsigned_long_int_size_bytes = 8; - float_size_bytes = 4; - unsigned_int_size_bytes = 4; - else - double_size_bytes = 8; - unsigned_long_int_size_bytes = 4; - float_size_bytes = 4; - unsigned_int_size_bytes = 4; - end - - skip_bytes_each_read = float_size_bytes * num_float_vars + unsigned_long_int_size_bytes * num_unsigned_long_int_vars + ... - double_size_bytes * num_double_vars + num_unsigned_int_vars*unsigned_int_size_bytes; - - bytes_shift = 0; - - if (m) - usage (m); - end - - if (nargin < 2) - count = Inf; - end - %loops_counter = fread (f, count, 'uint32',4*12); - f = fopen (filename, 'rb'); - if (f < 0) - else - v1 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); - bytes_shift = bytes_shift + float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next float - v2 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); - bytes_shift = bytes_shift + float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next float - v3 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); - bytes_shift = bytes_shift + float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next float - v4 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); - bytes_shift = bytes_shift + float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next float - v5 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); - bytes_shift = bytes_shift + float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next float - v6 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); - bytes_shift = bytes_shift + float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next float - v7 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); - bytes_shift = bytes_shift + float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved float - v8 = fread (f, count, 'long', skip_bytes_each_read - unsigned_long_int_size_bytes); - bytes_shift = bytes_shift + unsigned_long_int_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next float - v9 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); - bytes_shift = bytes_shift + float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next float - v10 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); - bytes_shift = bytes_shift + float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next float - v11 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); - bytes_shift = bytes_shift + float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next float - v12 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); - bytes_shift = bytes_shift + float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next float - v13 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); - bytes_shift = bytes_shift + float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next float - v14 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); - bytes_shift = bytes_shift + float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next float - v15 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); - bytes_shift = bytes_shift + float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next float - v16 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); - bytes_shift = bytes_shift + float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved float - v17 = fread (f, count, 'float', skip_bytes_each_read - float_size_bytes); - bytes_shift = bytes_shift + float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next float - v18 = fread (f, count, 'float', skip_bytes_each_read-float_size_bytes); - bytes_shift = bytes_shift + float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next double - v19 = fread (f, count, 'double', skip_bytes_each_read - double_size_bytes); - bytes_shift = bytes_shift + double_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next unsigned int - v20 = fread (f, count, 'uint', skip_bytes_each_read - unsigned_int_size_bytes); - fclose (f); - - GNSS_tracking.VE = v1; - GNSS_tracking.E = v2; - GNSS_tracking.P = v3; - GNSS_tracking.L = v4; - GNSS_tracking.VL = v5; - GNSS_tracking.prompt_I = v6; - GNSS_tracking.prompt_Q = v7; - GNSS_tracking.PRN_start_sample = v8; - GNSS_tracking.acc_carrier_phase_rad = v9; - GNSS_tracking.carrier_doppler_hz = v10; - GNSS_tracking.code_freq_hz = v11; - GNSS_tracking.carr_error = v12; - GNSS_tracking.carr_nco = v13; - GNSS_tracking.code_error = v14; - GNSS_tracking.code_nco = v15; - GNSS_tracking.CN0_SNV_dB_Hz = v16; - GNSS_tracking.carrier_lock_test = v17; - GNSS_tracking.var1 = v18; - GNSS_tracking.var2 = v19; - GNSS_tracking.PRN = v20; - end - diff --git a/src/utils/matlab/libs/geoFunctions/cart2geo.m b/src/utils/matlab/libs/geoFunctions/cart2geo.m index 99888b12e..324a226c1 100644 --- a/src/utils/matlab/libs/geoFunctions/cart2geo.m +++ b/src/utils/matlab/libs/geoFunctions/cart2geo.m @@ -1,60 +1,58 @@ -function [phi, lambda, h] = cart2geo(X, Y, Z, i) -%CART2GEO Conversion of Cartesian coordinates (X,Y,Z) to geographical -%coordinates (phi, lambda, h) on a selected reference ellipsoid. -% -%[phi, lambda, h] = cart2geo(X, Y, Z, i); -% -% Choices i of Reference Ellipsoid for Geographical Coordinates -% 1. International Ellipsoid 1924 -% 2. International Ellipsoid 1967 -% 3. World Geodetic System 1972 -% 4. Geodetic Reference System 1980 -% 5. World Geodetic System 1984 - -%Kai Borre 10-13-98 -%Copyright (c) by Kai Borre -%Revision: 1.0 Date: 1998/10/23 -% -% CVS record: -% $Id: cart2geo.m,v 1.1.2.3 2007/01/29 15:22:49 dpl Exp $ -%========================================================================== - -a = [6378388 6378160 6378135 6378137 6378137]; -f = [1/297 1/298.247 1/298.26 1/298.257222101 1/298.257223563]; - -lambda = atan2(Y,X); -ex2 = (2-f(i))*f(i)/((1-f(i))^2); -c = a(i)*sqrt(1+ex2); -phi = atan(Z/((sqrt(X^2+Y^2)*(1-(2-f(i)))*f(i)))); - -h = 0.1; oldh = 0; -iterations = 0; -while abs(h-oldh) > 1.e-12 - oldh = h; - N = c/sqrt(1+ex2*cos(phi)^2); - phi = atan(Z/((sqrt(X^2+Y^2)*(1-(2-f(i))*f(i)*N/(N+h))))); - h = sqrt(X^2+Y^2)/cos(phi)-N; - - iterations = iterations + 1; - if iterations > 100 - fprintf('Failed to approximate h with desired precision. h-oldh: %e.\n', h-oldh); - break; - end -end - -phi = phi*180/pi; -% b = zeros(1,3); -% b(1,1) = fix(phi); -% b(2,1) = fix(rem(phi,b(1,1))*60); -% b(3,1) = (phi-b(1,1)-b(1,2)/60)*3600; - -lambda = lambda*180/pi; -% l = zeros(1,3); -% l(1,1) = fix(lambda); -% l(2,1) = fix(rem(lambda,l(1,1))*60); -% l(3,1) = (lambda-l(1,1)-l(1,2)/60)*3600; - -%fprintf('\n phi =%3.0f %3.0f %8.5f',b(1),b(2),b(3)) -%fprintf('\n lambda =%3.0f %3.0f %8.5f',l(1),l(2),l(3)) -%fprintf('\n h =%14.3f\n',h) -%%%%%%%%%%%%%% end cart2geo.m %%%%%%%%%%%%%%%%%%% +function [phi, lambda, h] = cart2geo(X, Y, Z, i) +% CART2GEO Conversion of Cartesian coordinates (X,Y,Z) to geographical +% coordinates (phi, lambda, h) on a selected reference ellipsoid. +% +% [phi, lambda, h] = cart2geo(X, Y, Z, i); +% +% Choices i of Reference Ellipsoid for Geographical Coordinates +% 1. International Ellipsoid 1924 +% 2. International Ellipsoid 1967 +% 3. World Geodetic System 1972 +% 4. Geodetic Reference System 1980 +% 5. World Geodetic System 1984 + +% Kai Borre 10-13-98 +% Copyright (c) by Kai Borre +% Revision: 1.0 Date: 1998/10/23 +%========================================================================== + +a = [6378388 6378160 6378135 6378137 6378137]; +f = [1/297 1/298.247 1/298.26 1/298.257222101 1/298.257223563]; + +lambda = atan2(Y,X); +ex2 = (2-f(i))*f(i)/((1-f(i))^2); +c = a(i)*sqrt(1+ex2); +phi = atan(Z/((sqrt(X^2+Y^2)*(1-(2-f(i)))*f(i)))); + +h = 0.1; oldh = 0; +iterations = 0; +while abs(h-oldh) > 1.e-12 + oldh = h; + N = c/sqrt(1+ex2*cos(phi)^2); + phi = atan(Z/((sqrt(X^2+Y^2)*(1-(2-f(i))*f(i)*N/(N+h))))); + h = sqrt(X^2+Y^2)/cos(phi)-N; + + iterations = iterations + 1; + if iterations > 100 + fprintf('Failed to approximate h with desired precision. h-oldh: %e.\n', h-oldh); + break; + end +end + +phi = phi*180/pi; +% b = zeros(1,3); +% b(1,1) = fix(phi); +% b(2,1) = fix(rem(phi,b(1,1))*60); +% b(3,1) = (phi-b(1,1)-b(1,2)/60)*3600; + +lambda = lambda*180/pi; +% l = zeros(1,3); +% l(1,1) = fix(lambda); +% l(2,1) = fix(rem(lambda,l(1,1))*60); +% l(3,1) = (lambda-l(1,1)-l(1,2)/60)*3600; + +%fprintf('\n phi =%3.0f %3.0f %8.5f',b(1),b(2),b(3)) +%fprintf('\n lambda =%3.0f %3.0f %8.5f',l(1),l(2),l(3)) +%fprintf('\n h =%14.3f\n',h) + +%%%%%%%%%%%%%% end cart2geo.m %%%%%%%%%%%%%%%%%%% diff --git a/src/utils/matlab/libs/geoFunctions/cart2utm.m b/src/utils/matlab/libs/geoFunctions/cart2utm.m index b3bec8969..3a6034230 100644 --- a/src/utils/matlab/libs/geoFunctions/cart2utm.m +++ b/src/utils/matlab/libs/geoFunctions/cart2utm.m @@ -1,176 +1,173 @@ -function [E, N, U] = cart2utm(X, Y, Z, zone) -%CART2UTM Transformation of (X,Y,Z) to (N,E,U) in UTM, zone 'zone'. -% -%[E, N, U] = cart2utm(X, Y, Z, zone); -% -% Inputs: -% X,Y,Z - Cartesian coordinates. Coordinates are referenced -% with respect to the International Terrestrial Reference -% Frame 1996 (ITRF96) -% zone - UTM zone of the given position -% -% Outputs: -% E, N, U - UTM coordinates (Easting, Northing, Uping) - -%Kai Borre -11-1994 -%Copyright (c) by Kai Borre -% -% CVS record: -% $Id: cart2utm.m,v 1.1.1.1.2.6 2007/01/30 09:45:12 dpl Exp $ - -%This implementation is based upon -%O. Andersson & K. Poder (1981) Koordinattransformationer -% ved Geod\ae{}tisk Institut. Landinspekt\oe{}ren -% Vol. 30: 552--571 and Vol. 31: 76 -% -%An excellent, general reference (KW) is -%R. Koenig & K.H. Weise (1951) Mathematische Grundlagen der -% h\"oheren Geod\"asie und Kartographie. -% Erster Band, Springer Verlag - -% Explanation of variables used: -% f flattening of ellipsoid -% a semi major axis in m -% m0 1 - scale at central meridian; for UTM 0.0004 -% Q_n normalized meridian quadrant -% E0 Easting of central meridian -% L0 Longitude of central meridian -% bg constants for ellipsoidal geogr. to spherical geogr. -% gb constants for spherical geogr. to ellipsoidal geogr. -% gtu constants for ellipsoidal N, E to spherical N, E -% utg constants for spherical N, E to ellipoidal N, E -% tolutm tolerance for utm, 1.2E-10*meridian quadrant -% tolgeo tolerance for geographical, 0.00040 second of arc - -% B, L refer to latitude and longitude. Southern latitude is negative -% International ellipsoid of 1924, valid for ED50 - -a = 6378388; -f = 1/297; -ex2 = (2-f)*f / ((1-f)^2); -c = a * sqrt(1+ex2); -vec = [X; Y; Z-4.5]; -alpha = .756e-6; -R = [ 1 -alpha 0; - alpha 1 0; - 0 0 1]; -trans = [89.5; 93.8; 127.6]; -scale = 0.9999988; -v = scale*R*vec + trans; % coordinate vector in ED50 -L = atan2(v(2), v(1)); -N1 = 6395000; % preliminary value -B = atan2(v(3)/((1-f)^2*N1), norm(v(1:2))/N1); % preliminary value -U = 0.1; oldU = 0; - -iterations = 0; -while abs(U-oldU) > 1.e-4 - oldU = U; - N1 = c/sqrt(1+ex2*(cos(B))^2); - B = atan2(v(3)/((1-f)^2*N1+U), norm(v(1:2))/(N1+U) ); - U = norm(v(1:2))/cos(B)-N1; - - iterations = iterations + 1; - if iterations > 100 - fprintf('Failed to approximate U with desired precision. U-oldU: %e.\n', U-oldU); - break; - end -end - -%Normalized meridian quadrant, KW p. 50 (96), p. 19 (38b), p. 5 (21) -m0 = 0.0004; -n = f / (2-f); -m = n^2 * (1/4 + n*n/64); -w = (a*(-n-m0+m*(1-m0))) / (1+n); -Q_n = a + w; - -%Easting and longitude of central meridian -E0 = 500000; -L0 = (zone-30)*6 - 3; - -%Check tolerance for reverse transformation -tolutm = pi/2 * 1.2e-10 * Q_n; -tolgeo = 0.000040; - -%Coefficients of trigonometric series - -%ellipsoidal to spherical geographical, KW p. 186--187, (51)-(52) -% bg[1] = n*(-2 + n*(2/3 + n*(4/3 + n*(-82/45)))); -% bg[2] = n^2*(5/3 + n*(-16/15 + n*(-13/9))); -% bg[3] = n^3*(-26/15 + n*34/21); -% bg[4] = n^4*1237/630; - -%spherical to ellipsoidal geographical, KW p. 190--191, (61)-(62) -% gb[1] = n*(2 + n*(-2/3 + n*(-2 + n*116/45))); -% gb[2] = n^2*(7/3 + n*(-8/5 + n*(-227/45))); -% gb[3] = n^3*(56/15 + n*(-136/35)); -% gb[4] = n^4*4279/630; - -%spherical to ellipsoidal N, E, KW p. 196, (69) -% gtu[1] = n*(1/2 + n*(-2/3 + n*(5/16 + n*41/180))); -% gtu[2] = n^2*(13/48 + n*(-3/5 + n*557/1440)); -% gtu[3] = n^3*(61/240 + n*(-103/140)); -% gtu[4] = n^4*49561/161280; - -%ellipsoidal to spherical N, E, KW p. 194, (65) -% utg[1] = n*(-1/2 + n*(2/3 + n*(-37/96 + n*1/360))); -% utg[2] = n^2*(-1/48 + n*(-1/15 + n*437/1440)); -% utg[3] = n^3*(-17/480 + n*37/840); -% utg[4] = n^4*(-4397/161280); - -%With f = 1/297 we get - -bg = [-3.37077907e-3; - 4.73444769e-6; - -8.29914570e-9; - 1.58785330e-11]; - -gb = [ 3.37077588e-3; - 6.62769080e-6; - 1.78718601e-8; - 5.49266312e-11]; - -gtu = [ 8.41275991e-4; - 7.67306686e-7; - 1.21291230e-9; - 2.48508228e-12]; - -utg = [-8.41276339e-4; - -5.95619298e-8; - -1.69485209e-10; - -2.20473896e-13]; - -%Ellipsoidal latitude, longitude to spherical latitude, longitude -neg_geo = 'FALSE'; - -if B < 0 - neg_geo = 'TRUE '; -end - -Bg_r = abs(B); -[res_clensin] = clsin(bg, 4, 2*Bg_r); -Bg_r = Bg_r + res_clensin; -L0 = L0*pi / 180; -Lg_r = L - L0; - -%Spherical latitude, longitude to complementary spherical latitude -% i.e. spherical N, E -cos_BN = cos(Bg_r); -Np = atan2(sin(Bg_r), cos(Lg_r)*cos_BN); -Ep = atanh(sin(Lg_r) * cos_BN); - -%Spherical normalized N, E to ellipsoidal N, E -Np = 2 * Np; -Ep = 2 * Ep; -[dN, dE] = clksin(gtu, 4, Np, Ep); -Np = Np/2; -Ep = Ep/2; -Np = Np + dN; -Ep = Ep + dE; -N = Q_n * Np; -E = Q_n*Ep + E0; - -if neg_geo == 'TRUE ' - N = -N + 20000000; -end; - -%%%%%%%%%%%%%%%%%%%% end cart2utm.m %%%%%%%%%%%%%%%%%%%% \ No newline at end of file +function [E, N, U] = cart2utm(X, Y, Z, zone) +% CART2UTM Transformation of (X,Y,Z) to (N,E,U) in UTM, zone 'zone'. +% +% [E, N, U] = cart2utm(X, Y, Z, zone); +% +% Inputs: +% X,Y,Z - Cartesian coordinates. Coordinates are referenced +% with respect to the International Terrestrial Reference +% Frame 1996 (ITRF96) +% zone - UTM zone of the given position +% +% Outputs: +% E, N, U - UTM coordinates (Easting, Northing, Uping) + +% Kai Borre -11-1994 +% Copyright (c) by Kai Borre + +% This implementation is based upon +% O. Andersson & K. Poder (1981) Koordinattransformationer +% ved Geod\ae{}tisk Institut. Landinspekt\oe{}ren +% Vol. 30: 552--571 and Vol. 31: 76 +% +% An excellent, general reference (KW) is +% R. Koenig & K.H. Weise (1951) Mathematische Grundlagen der +% h\"oheren Geod\"asie und Kartographie. +% Erster Band, Springer Verlag + +% Explanation of variables used: +% f flattening of ellipsoid +% a semi major axis in m +% m0 1 - scale at central meridian; for UTM 0.0004 +% Q_n normalized meridian quadrant +% E0 Easting of central meridian +% L0 Longitude of central meridian +% bg constants for ellipsoidal geogr. to spherical geogr. +% gb constants for spherical geogr. to ellipsoidal geogr. +% gtu constants for ellipsoidal N, E to spherical N, E +% utg constants for spherical N, E to ellipoidal N, E +% tolutm tolerance for utm, 1.2E-10*meridian quadrant +% tolgeo tolerance for geographical, 0.00040 second of arc + +% B, L refer to latitude and longitude. Southern latitude is negative +% International ellipsoid of 1924, valid for ED50 + +a = 6378388; +f = 1/297; +ex2 = (2-f)*f / ((1-f)^2); +c = a * sqrt(1+ex2); +vec = [X; Y; Z-4.5]; +alpha = .756e-6; +R = [ 1 -alpha 0; + alpha 1 0; + 0 0 1]; +trans = [89.5; 93.8; 127.6]; +scale = 0.9999988; +v = scale*R*vec + trans; % coordinate vector in ED50 +L = atan2(v(2), v(1)); +N1 = 6395000; % preliminary value +B = atan2(v(3)/((1-f)^2*N1), norm(v(1:2))/N1); % preliminary value +U = 0.1; oldU = 0; + +iterations = 0; +while abs(U-oldU) > 1.e-4 + oldU = U; + N1 = c/sqrt(1+ex2*(cos(B))^2); + B = atan2(v(3)/((1-f)^2*N1+U), norm(v(1:2))/(N1+U) ); + U = norm(v(1:2))/cos(B)-N1; + + iterations = iterations + 1; + if iterations > 100 + fprintf('Failed to approximate U with desired precision. U-oldU: %e.\n', U-oldU); + break; + end +end + +% Normalized meridian quadrant, KW p. 50 (96), p. 19 (38b), p. 5 (21) +m0 = 0.0004; +n = f / (2-f); +m = n^2 * (1/4 + n*n/64); +w = (a*(-n-m0+m*(1-m0))) / (1+n); +Q_n = a + w; + +% Easting and longitude of central meridian +E0 = 500000; +L0 = (zone-30)*6 - 3; + +% Check tolerance for reverse transformation +tolutm = pi/2 * 1.2e-10 * Q_n; +tolgeo = 0.000040; + +% Coefficients of trigonometric series + +% ellipsoidal to spherical geographical, KW p. 186--187, (51)-(52) +% bg[1] = n*(-2 + n*(2/3 + n*(4/3 + n*(-82/45)))); +% bg[2] = n^2*(5/3 + n*(-16/15 + n*(-13/9))); +% bg[3] = n^3*(-26/15 + n*34/21); +% bg[4] = n^4*1237/630; + +% spherical to ellipsoidal geographical, KW p. 190--191, (61)-(62) +% gb[1] = n*(2 + n*(-2/3 + n*(-2 + n*116/45))); +% gb[2] = n^2*(7/3 + n*(-8/5 + n*(-227/45))); +% gb[3] = n^3*(56/15 + n*(-136/35)); +% gb[4] = n^4*4279/630; + +% spherical to ellipsoidal N, E, KW p. 196, (69) +% gtu[1] = n*(1/2 + n*(-2/3 + n*(5/16 + n*41/180))); +% gtu[2] = n^2*(13/48 + n*(-3/5 + n*557/1440)); +% gtu[3] = n^3*(61/240 + n*(-103/140)); +% gtu[4] = n^4*49561/161280; + +% ellipsoidal to spherical N, E, KW p. 194, (65) +% utg[1] = n*(-1/2 + n*(2/3 + n*(-37/96 + n*1/360))); +% utg[2] = n^2*(-1/48 + n*(-1/15 + n*437/1440)); +% utg[3] = n^3*(-17/480 + n*37/840); +% utg[4] = n^4*(-4397/161280); + +% With f = 1/297 we get + +bg = [-3.37077907e-3; + 4.73444769e-6; + -8.29914570e-9; + 1.58785330e-11]; + +gb = [ 3.37077588e-3; + 6.62769080e-6; + 1.78718601e-8; + 5.49266312e-11]; + +gtu = [ 8.41275991e-4; + 7.67306686e-7; + 1.21291230e-9; + 2.48508228e-12]; + +utg = [-8.41276339e-4; + -5.95619298e-8; + -1.69485209e-10; + -2.20473896e-13]; + +% Ellipsoidal latitude, longitude to spherical latitude, longitude +neg_geo = 'FALSE'; + +if B < 0 + neg_geo = 'TRUE '; +end + +Bg_r = abs(B); +[res_clensin] = clsin(bg, 4, 2*Bg_r); +Bg_r = Bg_r + res_clensin; +L0 = L0*pi / 180; +Lg_r = L - L0; + +% Spherical latitude, longitude to complementary spherical latitude +% i.e. spherical N, E +cos_BN = cos(Bg_r); +Np = atan2(sin(Bg_r), cos(Lg_r)*cos_BN); +Ep = atanh(sin(Lg_r) * cos_BN); + +%Spherical normalized N, E to ellipsoidal N, E +Np = 2 * Np; +Ep = 2 * Ep; +[dN, dE] = clksin(gtu, 4, Np, Ep); +Np = Np/2; +Ep = Ep/2; +Np = Np + dN; +Ep = Ep + dE; +N = Q_n * Np; +E = Q_n*Ep + E0; + +if neg_geo == 'TRUE ' + N = -N + 20000000; +end; + +%%%%%%%%%%%%%%%%%%%% end cart2utm.m %%%%%%%%%%%%%%%%%%%% diff --git a/src/utils/matlab/libs/geoFunctions/check_t.m b/src/utils/matlab/libs/geoFunctions/check_t.m index 9d503c3e9..1b3ed323c 100644 --- a/src/utils/matlab/libs/geoFunctions/check_t.m +++ b/src/utils/matlab/libs/geoFunctions/check_t.m @@ -1,28 +1,26 @@ -function corrTime = check_t(time) -%CHECK_T accounting for beginning or end of week crossover. -% -%corrTime = check_t(time); -% -% Inputs: -% time - time in seconds -% -% Outputs: -% corrTime - corrected time (seconds) - -%Kai Borre 04-01-96 -%Copyright (c) by Kai Borre -% -% CVS record: -% $Id: check_t.m,v 1.1.1.1.2.4 2006/08/22 13:45:59 dpl Exp $ -%========================================================================== - -half_week = 302400; % seconds - -corrTime = time; - -if time > half_week - corrTime = time - 2*half_week; -elseif time < -half_week - corrTime = time + 2*half_week; -end -%%%%%%% end check_t.m %%%%%%%%%%%%%%%%% \ No newline at end of file +function corrTime = check_t(time) +% CHECK_T accounting for beginning or end of week crossover. +% +% corrTime = check_t(time); +% +% Inputs: +% time - time in seconds +% +% Outputs: +% corrTime - corrected time (seconds) + +% Kai Borre 04-01-96 +% Copyright (c) by Kai Borre +%========================================================================== + +half_week = 302400; % seconds + +corrTime = time; + +if time > half_week + corrTime = time - 2*half_week; +elseif time < -half_week + corrTime = time + 2*half_week; +end + +%%%%%%% end check_t.m %%%%%%%%%%%%%%%%% diff --git a/src/utils/matlab/libs/geoFunctions/clksin.m b/src/utils/matlab/libs/geoFunctions/clksin.m index 7ccd4726f..f6f600c19 100644 --- a/src/utils/matlab/libs/geoFunctions/clksin.m +++ b/src/utils/matlab/libs/geoFunctions/clksin.m @@ -1,38 +1,36 @@ -function [re, im] = clksin(ar, degree, arg_real, arg_imag) -%Clenshaw summation of sinus with complex argument -%[re, im] = clksin(ar, degree, arg_real, arg_imag); - -% Written by Kai Borre -% December 20, 1995 -% -% See also WGS2UTM or CART2UTM -% -% CVS record: -% $Id: clksin.m,v 1.1.1.1.2.4 2006/08/22 13:45:59 dpl Exp $ -%========================================================================== - -sin_arg_r = sin(arg_real); -cos_arg_r = cos(arg_real); -sinh_arg_i = sinh(arg_imag); -cosh_arg_i = cosh(arg_imag); - -r = 2 * cos_arg_r * cosh_arg_i; -i =-2 * sin_arg_r * sinh_arg_i; - -hr1 = 0; hr = 0; hi1 = 0; hi = 0; - -for t = degree : -1 : 1 - hr2 = hr1; - hr1 = hr; - hi2 = hi1; - hi1 = hi; - z = ar(t) + r*hr1 - i*hi - hr2; - hi = i*hr1 + r*hi1 - hi2; - hr = z; -end - -r = sin_arg_r * cosh_arg_i; -i = cos_arg_r * sinh_arg_i; - -re = r*hr - i*hi; -im = r*hi + i*hr; +function [re, im] = clksin(ar, degree, arg_real, arg_imag) +% Clenshaw summation of sinus with complex argument +% [re, im] = clksin(ar, degree, arg_real, arg_imag); + +% Written by Kai Borre +% December 20, 1995 +% +% See also WGS2UTM or CART2UTM +% +%========================================================================== + +sin_arg_r = sin(arg_real); +cos_arg_r = cos(arg_real); +sinh_arg_i = sinh(arg_imag); +cosh_arg_i = cosh(arg_imag); + +r = 2 * cos_arg_r * cosh_arg_i; +i =-2 * sin_arg_r * sinh_arg_i; + +hr1 = 0; hr = 0; hi1 = 0; hi = 0; + +for t = degree : -1 : 1 + hr2 = hr1; + hr1 = hr; + hi2 = hi1; + hi1 = hi; + z = ar(t) + r*hr1 - i*hi - hr2; + hi = i*hr1 + r*hi1 - hi2; + hr = z; +end + +r = sin_arg_r * cosh_arg_i; +i = cos_arg_r * sinh_arg_i; + +re = r*hr - i*hi; +im = r*hi + i*hr; diff --git a/src/utils/matlab/libs/geoFunctions/clsin.m b/src/utils/matlab/libs/geoFunctions/clsin.m index d499e8598..46cf32524 100644 --- a/src/utils/matlab/libs/geoFunctions/clsin.m +++ b/src/utils/matlab/libs/geoFunctions/clsin.m @@ -1,26 +1,24 @@ -function result = clsin(ar, degree, argument) -%Clenshaw summation of sinus of argument. -% -%result = clsin(ar, degree, argument); - -% Written by Kai Borre -% December 20, 1995 -% -% See also WGS2UTM or CART2UTM -% -% CVS record: -% $Id: clsin.m,v 1.1.1.1.2.4 2006/08/22 13:45:59 dpl Exp $ -%========================================================================== - -cos_arg = 2 * cos(argument); -hr1 = 0; -hr = 0; - -for t = degree : -1 : 1 - hr2 = hr1; - hr1 = hr; - hr = ar(t) + cos_arg*hr1 - hr2; -end - -result = hr * sin(argument); -%%%%%%%%%%%%%%%%%%%%%%% end clsin.m %%%%%%%%%%%%%%%%%%%%% \ No newline at end of file +function result = clsin(ar, degree, argument) +% Clenshaw summation of sinus of argument. +% +% result = clsin(ar, degree, argument); + +% Written by Kai Borre +% December 20, 1995 +% +% See also WGS2UTM or CART2UTM +%========================================================================== + +cos_arg = 2 * cos(argument); +hr1 = 0; +hr = 0; + +for t = degree : -1 : 1 + hr2 = hr1; + hr1 = hr; + hr = ar(t) + cos_arg*hr1 - hr2; +end + +result = hr * sin(argument); + +%%%%%%%%%%%%%%%%%%%%%%% end clsin.m %%%%%%%%%%%%%%%%%%%%% diff --git a/src/utils/matlab/libs/geoFunctions/deg2dms.m b/src/utils/matlab/libs/geoFunctions/deg2dms.m index 56ce6ae90..1f925894d 100644 --- a/src/utils/matlab/libs/geoFunctions/deg2dms.m +++ b/src/utils/matlab/libs/geoFunctions/deg2dms.m @@ -1,43 +1,43 @@ -function dmsOutput = deg2dms(deg) -%DEG2DMS Conversion of degrees to degrees, minutes, and seconds. -%The output format (dms format) is: (degrees*100 + minutes + seconds/100) - -% Written by Kai Borre -% February 7, 2001 -% Updated by Darius Plausinaitis - -%%% Save the sign for later processing -neg_arg = false; -if deg < 0 - % Only positive numbers should be used while spliting into deg/min/sec - deg = -deg; - neg_arg = true; -end - -%%% Split degrees minutes and seconds -int_deg = floor(deg); -decimal = deg - int_deg; -min_part = decimal*60; -min = floor(min_part); -sec_part = min_part - floor(min_part); -sec = sec_part*60; - -%%% Check for overflow -if sec == 60 - min = min + 1; - sec = 0; -end -if min == 60 - int_deg = int_deg + 1; - min = 0; -end - -%%% Construct the output -dmsOutput = int_deg * 100 + min + sec/100; - -%%% Correct the sign -if neg_arg == true - dmsOutput = -dmsOutput; -end - -%%%%%%%%%%%%%%%%%%% end deg2dms.m %%%%%%%%%%%%%%%% \ No newline at end of file +function dmsOutput = deg2dms(deg) +% DEG2DMS Conversion of degrees to degrees, minutes, and seconds. +% The output format (dms format) is: (degrees*100 + minutes + seconds/100) + +% Written by Kai Borre +% February 7, 2001 +% Updated by Darius Plausinaitis + +%%% Save the sign for later processing +neg_arg = false; +if deg < 0 + % Only positive numbers should be used while spliting into deg/min/sec + deg = -deg; + neg_arg = true; +end + +%%% Split degrees minutes and seconds +int_deg = floor(deg); +decimal = deg - int_deg; +min_part = decimal*60; +min = floor(min_part); +sec_part = min_part - floor(min_part); +sec = sec_part*60; + +%%% Check for overflow +if sec == 60 + min = min + 1; + sec = 0; +end +if min == 60 + int_deg = int_deg + 1; + min = 0; +end + +%%% Construct the output +dmsOutput = int_deg * 100 + min + sec/100; + +%%% Correct the sign +if neg_arg == true + dmsOutput = -dmsOutput; +end + +%%%%%%%%%%%%%%%%%%% end deg2dms.m %%%%%%%%%%%%%%%% diff --git a/src/utils/matlab/libs/geoFunctions/dms2deg.m b/src/utils/matlab/libs/geoFunctions/dms2deg.m index 077fc8639..a8e99f9a6 100644 --- a/src/utils/matlab/libs/geoFunctions/dms2deg.m +++ b/src/utils/matlab/libs/geoFunctions/dms2deg.m @@ -1,12 +1,12 @@ - -function deg = dms2deg(dms) -%DMS2DEG Conversion of degrees, minutes, and seconds to degrees. - -% Written by Javier Arribas 2011 -% December 7, 2011 - -%if (dms(1)>=0) - deg=dms(1)+dms(2)/60+dms(3)/3600; -%else - %deg=dms(1)-dms(2)/60-dms(3)/3600; -%end + +function deg = dms2deg(dms) +% DMS2DEG Conversion of degrees, minutes, and seconds to degrees. + +% Written by Javier Arribas 2011 +% December 7, 2011 + +%if (dms(1)>=0) +deg=dms(1)+dms(2)/60+dms(3)/3600; +%else +%deg=dms(1)-dms(2)/60-dms(3)/3600; +%end diff --git a/src/utils/matlab/libs/geoFunctions/dms2mat.m b/src/utils/matlab/libs/geoFunctions/dms2mat.m index da17b590b..a5c449673 100644 --- a/src/utils/matlab/libs/geoFunctions/dms2mat.m +++ b/src/utils/matlab/libs/geoFunctions/dms2mat.m @@ -1,104 +1,103 @@ -function [dout,mout,sout] = dms2mat(dms,n) - -%DMS2MAT Converts a dms vector format to a [deg min sec] matrix -% -% [d,m,s] = DMS2MAT(dms) converts a dms vector format to a -% deg:min:sec matrix. The vector format is dms = 100*deg + min + sec/100. -% This allows compressed dms data to be expanded to a d,m,s triple, -% for easier reporting and viewing of the data. -% -% [d,m,s] = DMS2MAT(dms,n) uses n digits in the accuracy of the -% seconds calculation. n = -2 uses accuracy in the hundredths position, -% n = 0 uses accuracy in the units position. Default is n = -5. -% For further discussion of the input n, see ROUNDN. -% -% mat = DMS2MAT(...) returns a single output argument of mat = [d m s]. -% This is useful only if the input dms is a single column vector. -% -% See also MAT2DMS - -% Copyright 1996-2002 Systems Planning and Analysis, Inc. and The MathWorks, Inc. -% Written by: E. Byrns, E. Brown -% $Revision: 1.10 $ $Date: 2002/03/20 21:25:06 $ - - -if nargin == 0 - error('Incorrect number of arguments') -elseif nargin == 1 - n = -5; -end - -% Test for empty arguments - -if isempty(dms); dout = []; mout = []; sout = []; return; end - -% Test for complex arguments - -if ~isreal(dms) - warning('Imaginary parts of complex ANGLE argument ignored') - dms = real(dms); -end - -% Don't let seconds be rounded beyond the tens place. -% If you did, then 55 seconds rounds to 100, which is not good. - -if n == 2; n = 1; end - -% Construct a sign vector which has +1 when dms >= 0 and -1 when dms < 0. - -signvec = sign(dms); -signvec = signvec + (signvec == 0); % Ensure +1 when dms = 0 - -% Decompress the dms data vector - -dms = abs(dms); -d = fix(dms/100); % Degrees -m = fix(dms) - abs(100*d); % Minutes -[s,msg] = roundn(100*rem(dms,1),n); % Seconds: Truncate to roundoff error -if ~isempty(msg); error(msg); end - -% Adjust for 60 seconds or 60 minutes. -% Test for seconds > 60 to allow for round-off from roundn, -% Test for minutes > 60 as a ripple effect from seconds > 60 - - -indx = find(s >= 60); -if ~isempty(indx); m(indx) = m(indx) + 1; s(indx) = s(indx) - 60; end -indx = find(m >= 60); -if ~isempty(indx); d(indx) = d(indx) + 1; m(indx) = m(indx) - 60; end - -% Data consistency checks - -if any(m > 59) | any (m < 0) - error('Minutes must be >= 0 and <= 59') - -elseif any(s >= 60) | any( s < 0) - error('Seconds must be >= 0 and < 60') -end - -% Determine where to store the sign of the angle. It should be -% associated with the largest nonzero component of d:m:s. - -dsign = signvec .* (d~=0); -msign = signvec .* (d==0 & m~=0); -ssign = signvec .* (d==0 & m==0 & s~=0); - -% In the application of signs below, the comparison with 0 is used so that -% the sign vector contains only +1 and -1. Any zero occurances causes -% data to be lost when the sign has been applied to a higher component -% of d:m:s. Use fix function to eliminate potential round-off errors. - -d = ((dsign==0) + dsign).*fix(d); % Apply signs to the degrees -m = ((msign==0) + msign).*fix(m); % Apply signs to minutes -s = ((ssign==0) + ssign).*s; % Apply signs to seconds - -% Set the output arguments - -if nargout <= 1 - dout = [d m s]; -elseif nargout == 3 - dout = d; mout = m; sout = s; -else - error('Invalid number of output arguments') -end - +function [dout,mout,sout] = dms2mat(dms,n) + +% DMS2MAT Converts a dms vector format to a [deg min sec] matrix +% +% [d,m,s] = DMS2MAT(dms) converts a dms vector format to a +% deg:min:sec matrix. The vector format is dms = 100*deg + min + sec/100. +% This allows compressed dms data to be expanded to a d,m,s triple, +% for easier reporting and viewing of the data. +% +% [d,m,s] = DMS2MAT(dms,n) uses n digits in the accuracy of the +% seconds calculation. n = -2 uses accuracy in the hundredths position, +% n = 0 uses accuracy in the units position. Default is n = -5. +% For further discussion of the input n, see ROUNDN. +% +% mat = DMS2MAT(...) returns a single output argument of mat = [d m s]. +% This is useful only if the input dms is a single column vector. +% +% See also MAT2DMS + +% Copyright 1996-2002 Systems Planning and Analysis, Inc. and The MathWorks, Inc. +% Written by: E. Byrns, E. Brown +% Revision: 1.10 $Date: 2002/03/20 21:25:06 + + +if nargin == 0 + error('Incorrect number of arguments') +elseif nargin == 1 + n = -5; +end + +% Test for empty arguments + +if isempty(dms); dout = []; mout = []; sout = []; return; end + +% Test for complex arguments + +if ~isreal(dms) + warning('Imaginary parts of complex ANGLE argument ignored') + dms = real(dms); +end + +% Don't let seconds be rounded beyond the tens place. +% If you did, then 55 seconds rounds to 100, which is not good. + +if n == 2; n = 1; end + +% Construct a sign vector which has +1 when dms >= 0 and -1 when dms < 0. + +signvec = sign(dms); +signvec = signvec + (signvec == 0); % Ensure +1 when dms = 0 + +% Decompress the dms data vector + +dms = abs(dms); +d = fix(dms/100); % Degrees +m = fix(dms) - abs(100*d); % Minutes +[s,msg] = roundn(100*rem(dms,1),n); % Seconds: Truncate to roundoff error +if ~isempty(msg); error(msg); end + +% Adjust for 60 seconds or 60 minutes. +% Test for seconds > 60 to allow for round-off from roundn, +% Test for minutes > 60 as a ripple effect from seconds > 60 + + +indx = find(s >= 60); +if ~isempty(indx); m(indx) = m(indx) + 1; s(indx) = s(indx) - 60; end +indx = find(m >= 60); +if ~isempty(indx); d(indx) = d(indx) + 1; m(indx) = m(indx) - 60; end + +% Data consistency checks + +if any(m > 59) | any (m < 0) + error('Minutes must be >= 0 and <= 59') + +elseif any(s >= 60) | any( s < 0) + error('Seconds must be >= 0 and < 60') +end + +% Determine where to store the sign of the angle. It should be +% associated with the largest nonzero component of d:m:s. + +dsign = signvec .* (d~=0); +msign = signvec .* (d==0 & m~=0); +ssign = signvec .* (d==0 & m==0 & s~=0); + +% In the application of signs below, the comparison with 0 is used so that +% the sign vector contains only +1 and -1. Any zero occurances causes +% data to be lost when the sign has been applied to a higher component +% of d:m:s. Use fix function to eliminate potential round-off errors. + +d = ((dsign==0) + dsign).*fix(d); % Apply signs to the degrees +m = ((msign==0) + msign).*fix(m); % Apply signs to minutes +s = ((ssign==0) + ssign).*s; % Apply signs to seconds + +% Set the output arguments + +if nargout <= 1 + dout = [d m s]; +elseif nargout == 3 + dout = d; mout = m; sout = s; +else + error('Invalid number of output arguments') +end diff --git a/src/utils/matlab/libs/geoFunctions/e_r_corr.m b/src/utils/matlab/libs/geoFunctions/e_r_corr.m index 974b233ba..b668a714a 100644 --- a/src/utils/matlab/libs/geoFunctions/e_r_corr.m +++ b/src/utils/matlab/libs/geoFunctions/e_r_corr.m @@ -1,34 +1,31 @@ -function X_sat_rot = e_r_corr(traveltime, X_sat) -%E_R_CORR Returns rotated satellite ECEF coordinates due to Earth -%rotation during signal travel time -% -%X_sat_rot = e_r_corr(traveltime, X_sat); -% -% Inputs: -% travelTime - signal travel time -% X_sat - satellite's ECEF coordinates -% -% Outputs: -% X_sat_rot - rotated satellite's coordinates (ECEF) - -%Written by Kai Borre -%Copyright (c) by Kai Borre -% -% CVS record: -% $Id: e_r_corr.m,v 1.1.1.1.2.6 2006/08/22 13:45:59 dpl Exp $ -%========================================================================== - -Omegae_dot = 7.292115147e-5; % rad/sec - -%--- Find rotation angle -------------------------------------------------- -omegatau = Omegae_dot * traveltime; - -%--- Make a rotation matrix ----------------------------------------------- -R3 = [ cos(omegatau) sin(omegatau) 0; - -sin(omegatau) cos(omegatau) 0; - 0 0 1]; - -%--- Do the rotation ------------------------------------------------------ -X_sat_rot = R3 * X_sat; - -%%%%%%%% end e_r_corr.m %%%%%%%%%%%%%%%%%%%% \ No newline at end of file +function X_sat_rot = e_r_corr(traveltime, X_sat) +% E_R_CORR Returns rotated satellite ECEF coordinates due to Earth +% rotation during signal travel time +% +% X_sat_rot = e_r_corr(traveltime, X_sat); +% +% Inputs: +% travelTime - signal travel time +% X_sat - satellite's ECEF coordinates +% +% Outputs: +% X_sat_rot - rotated satellite's coordinates (ECEF) + +% Written by Kai Borre +% Copyright (c) by Kai Borre +%========================================================================== + +Omegae_dot = 7.292115147e-5; % rad/sec + +%--- Find rotation angle -------------------------------------------------- +omegatau = Omegae_dot * traveltime; + +%--- Make a rotation matrix ----------------------------------------------- +R3 = [ cos(omegatau) sin(omegatau) 0; + -sin(omegatau) cos(omegatau) 0; + 0 0 1]; + +%--- Do the rotation ------------------------------------------------------ +X_sat_rot = R3 * X_sat; + +%%%%%%%% end e_r_corr.m %%%%%%%%%%%%%%%%%%%% diff --git a/src/utils/matlab/libs/geoFunctions/findUtmZone.m b/src/utils/matlab/libs/geoFunctions/findUtmZone.m index 7630bf8e1..e5717d635 100644 --- a/src/utils/matlab/libs/geoFunctions/findUtmZone.m +++ b/src/utils/matlab/libs/geoFunctions/findUtmZone.m @@ -1,72 +1,69 @@ -function utmZone = findUtmZone(latitude, longitude) -%Function finds the UTM zone number for given longitude and latitude. -%The longitude value must be between -180 (180 degree West) and 180 (180 -%degree East) degree. The latitude must be within -80 (80 degree South) and -%84 (84 degree North). -% -%utmZone = findUtmZone(latitude, longitude); -% -%Latitude and longitude must be in decimal degrees (e.g. 15.5 degrees not -%15 deg 30 min). - -%-------------------------------------------------------------------------- -% SoftGNSS v3.0 -% -% Copyright (C) Darius Plausinaitis -% Written by Darius Plausinaitis -%-------------------------------------------------------------------------- -%This program is free software; you can redistribute it and/or -%modify it under the terms of the GNU General Public License -%as published by the Free Software Foundation; either version 2 -%of the License, or (at your option) any later version. -% -%This program is distributed in the hope that it will be useful, -%but WITHOUT ANY WARRANTY; without even the implied warranty of -%MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -%GNU General Public License for more details. -% -%You should have received a copy of the GNU General Public License -%along with this program; if not, write to the Free Software -%Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -%USA. -%========================================================================== - -%CVS record: -%$Id: findUtmZone.m,v 1.1.2.2 2006/08/22 13:45:59 dpl Exp $ - -%% Check value bounds ===================================================== - -if ((longitude > 180) || (longitude < -180)) - error('Longitude value exceeds limits (-180:180).'); -end - -if ((latitude > 84) || (latitude < -80)) - error('Latitude value exceeds limits (-80:84).'); -end - -%% Find zone ============================================================== - -% Start at 180 deg west = -180 deg - -utmZone = fix((180 + longitude)/ 6) + 1; - -%% Correct zone numbers for particular areas ============================== - -if (latitude > 72) - % Corrections for zones 31 33 35 37 - if ((longitude >= 0) && (longitude < 9)) - utmZone = 31; - elseif ((longitude >= 9) && (longitude < 21)) - utmZone = 33; - elseif ((longitude >= 21) && (longitude < 33)) - utmZone = 35; - elseif ((longitude >= 33) && (longitude < 42)) - utmZone = 37; - end - -elseif ((latitude >= 56) && (latitude < 64)) - % Correction for zone 32 - if ((longitude >= 3) && (longitude < 12)) - utmZone = 32; - end -end \ No newline at end of file +function utmZone = findUtmZone(latitude, longitude) +% Function finds the UTM zone number for given longitude and latitude. +% The longitude value must be between -180 (180 degree West) and 180 (180 +% degree East) degree. The latitude must be within -80 (80 degree South) and +% 84 (84 degree North). +% +% utmZone = findUtmZone(latitude, longitude); +% +% Latitude and longitude must be in decimal degrees (e.g. 15.5 degrees not +% 15 deg 30 min). + +%-------------------------------------------------------------------------- +% SoftGNSS v3.0 +% +% Copyright (C) Darius Plausinaitis +% Written by Darius Plausinaitis +%-------------------------------------------------------------------------- +%This program is free software; you can redistribute it and/or +%modify it under the terms of the GNU General Public License +%as published by the Free Software Foundation; either version 2 +%of the License, or (at your option) any later version. +% +%This program is distributed in the hope that it will be useful, +%but WITHOUT ANY WARRANTY; without even the implied warranty of +%MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%GNU General Public License for more details. +% +%You should have received a copy of the GNU General Public License +%along with this program; if not, write to the Free Software +%Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +%USA. +%========================================================================== + +%% Check value bounds ===================================================== + +if ((longitude > 180) || (longitude < -180)) + error('Longitude value exceeds limits (-180:180).'); +end + +if ((latitude > 84) || (latitude < -80)) + error('Latitude value exceeds limits (-80:84).'); +end + +%% Find zone ============================================================== + +% Start at 180 deg west = -180 deg + +utmZone = fix((180 + longitude)/ 6) + 1; + +%% Correct zone numbers for particular areas ============================== + +if (latitude > 72) + % Corrections for zones 31 33 35 37 + if ((longitude >= 0) && (longitude < 9)) + utmZone = 31; + elseif ((longitude >= 9) && (longitude < 21)) + utmZone = 33; + elseif ((longitude >= 21) && (longitude < 33)) + utmZone = 35; + elseif ((longitude >= 33) && (longitude < 42)) + utmZone = 37; + end + +elseif ((latitude >= 56) && (latitude < 64)) + % Correction for zone 32 + if ((longitude >= 3) && (longitude < 12)) + utmZone = 32; + end +end diff --git a/src/utils/matlab/libs/geoFunctions/geo2cart.m b/src/utils/matlab/libs/geoFunctions/geo2cart.m index 02f0d5768..90cd6a10f 100644 --- a/src/utils/matlab/libs/geoFunctions/geo2cart.m +++ b/src/utils/matlab/libs/geoFunctions/geo2cart.m @@ -1,48 +1,46 @@ -function [X, Y, Z] = geo2cart(phi, lambda, h, i) -%GEO2CART Conversion of geographical coordinates (phi, lambda, h) to -%Cartesian coordinates (X, Y, Z). -% -%[X, Y, Z] = geo2cart(phi, lambda, h, i); -% -%Format for phi and lambda: [degrees minutes seconds]. -%h, X, Y, and Z are in meters. -% -%Choices i of Reference Ellipsoid -% 1. International Ellipsoid 1924 -% 2. International Ellipsoid 1967 -% 3. World Geodetic System 1972 -% 4. Geodetic Reference System 1980 -% 5. World Geodetic System 1984 -% -% Inputs: -% phi - geocentric latitude (format [degrees minutes seconds]) -% lambda - geocentric longitude (format [degrees minutes seconds]) -% h - height -% i - reference ellipsoid type -% -% Outputs: -% X, Y, Z - Cartesian coordinates (meters) - -%Kai Borre 10-13-98 -%Copyright (c) by Kai Borre -% -% CVS record: -% $Id: geo2cart.m,v 1.1.2.7 2006/08/22 13:45:59 dpl Exp $ -%========================================================================== - -b = phi(1) + phi(2)/60 + phi(3)/3600; -b = b*pi / 180; -l = lambda(1) + lambda(2)/60 + lambda(3)/3600; -l = l*pi / 180; - -a = [6378388 6378160 6378135 6378137 6378137]; -f = [1/297 1/298.247 1/298.26 1/298.257222101 1/298.257223563]; - -ex2 = (2-f(i))*f(i) / ((1-f(i))^2); -c = a(i) * sqrt(1+ex2); -N = c / sqrt(1 + ex2*cos(b)^2); - -X = (N+h) * cos(b) * cos(l); -Y = (N+h) * cos(b) * sin(l); -Z = ((1-f(i))^2*N + h) * sin(b); -%%%%%%%%%%%%%% end geo2cart.m %%%%%%%%%%%%%%%%%%%%%%%% +function [X, Y, Z] = geo2cart(phi, lambda, h, i) +% GEO2CART Conversion of geographical coordinates (phi, lambda, h) to +% Cartesian coordinates (X, Y, Z). +% +% [X, Y, Z] = geo2cart(phi, lambda, h, i); +% +% Format for phi and lambda: [degrees minutes seconds]. +% h, X, Y, and Z are in meters. +% +% Choices i of Reference Ellipsoid +% 1. International Ellipsoid 1924 +% 2. International Ellipsoid 1967 +% 3. World Geodetic System 1972 +% 4. Geodetic Reference System 1980 +% 5. World Geodetic System 1984 +% +% Inputs: +% phi - geocentric latitude (format [degrees minutes seconds]) +% lambda - geocentric longitude (format [degrees minutes seconds]) +% h - height +% i - reference ellipsoid type +% +% Outputs: +% X, Y, Z - Cartesian coordinates (meters) + +% Kai Borre 10-13-98 +% Copyright (c) by Kai Borre +%========================================================================== + +b = phi(1) + phi(2)/60 + phi(3)/3600; +b = b*pi / 180; +l = lambda(1) + lambda(2)/60 + lambda(3)/3600; +l = l*pi / 180; + +a = [6378388 6378160 6378135 6378137 6378137]; +f = [1/297 1/298.247 1/298.26 1/298.257222101 1/298.257223563]; + +ex2 = (2-f(i))*f(i) / ((1-f(i))^2); +c = a(i) * sqrt(1+ex2); +N = c / sqrt(1 + ex2*cos(b)^2); + +X = (N+h) * cos(b) * cos(l); +Y = (N+h) * cos(b) * sin(l); +Z = ((1-f(i))^2*N + h) * sin(b); + +%%%%%%%%%%%%%% end geo2cart.m %%%%%%%%%%%%%%%%%%%%%%%% diff --git a/src/utils/matlab/libs/geoFunctions/leastSquarePos.m b/src/utils/matlab/libs/geoFunctions/leastSquarePos.m index 07d04f080..dee7e2180 100644 --- a/src/utils/matlab/libs/geoFunctions/leastSquarePos.m +++ b/src/utils/matlab/libs/geoFunctions/leastSquarePos.m @@ -1,114 +1,111 @@ -function [pos, el, az, dop] = leastSquarePos(satpos, obs, settings) -%Function calculates the Least Square Solution. -% -%[pos, el, az, dop] = leastSquarePos(satpos, obs, settings); -% -% Inputs: -% satpos - Satellites positions (in ECEF system: [X; Y; Z;] - -% one column per satellite) -% obs - Observations - the pseudorange measurements to each -% satellite: -% (e.g. [20000000 21000000 .... .... .... .... ....]) -% settings - receiver settings -% -% Outputs: -% pos - receiver position and receiver clock error -% (in ECEF system: [X, Y, Z, dt]) -% el - Satellites elevation angles (degrees) -% az - Satellites azimuth angles (degrees) -% dop - Dilutions Of Precision ([GDOP PDOP HDOP VDOP TDOP]) - -%-------------------------------------------------------------------------- -% SoftGNSS v3.0 -%-------------------------------------------------------------------------- -%Based on Kai Borre -%Copyright (c) by Kai Borre -%Updated by Darius Plausinaitis, Peter Rinder and Nicolaj Bertelsen -% -% CVS record: -% $Id: leastSquarePos.m,v 1.1.2.12 2006/08/22 13:45:59 dpl Exp $ -%========================================================================== - -%=== Initialization ======================================================= -nmbOfIterations = 7; - -dtr = pi/180; -pos = zeros(4, 1); -X = satpos; -nmbOfSatellites = size(satpos, 2); - -A = zeros(nmbOfSatellites, 4); -omc = zeros(nmbOfSatellites, 1); -az = zeros(1, nmbOfSatellites); -el = az; - -%=== Iteratively find receiver position =================================== -for iter = 1:nmbOfIterations - - for i = 1:nmbOfSatellites - if iter == 1 - %--- Initialize variables at the first iteration -------------- - Rot_X = X(:, i); - trop = 2; - else - %--- Update equations ----------------------------------------- - rho2 = (X(1, i) - pos(1))^2 + (X(2, i) - pos(2))^2 + ... - (X(3, i) - pos(3))^2; - traveltime = sqrt(rho2) / settings.c ; - - %--- Correct satellite position (do to earth rotation) -------- - Rot_X = e_r_corr(traveltime, X(:, i)); - - %--- Find the elevation angel of the satellite ---------------- - [az(i), el(i), dist] = topocent(pos(1:3, :), Rot_X - pos(1:3, :)); - - if (settings.useTropCorr == 1) - %--- Calculate tropospheric correction -------------------- - trop = tropo(sin(el(i) * dtr), ... - 0.0, 1013.0, 293.0, 50.0, 0.0, 0.0, 0.0); - else - % Do not calculate or apply the tropospheric corrections - trop = 0; - end - end % if iter == 1 ... ... else - - %--- Apply the corrections ---------------------------------------- - omc(i) = (obs(i) - norm(Rot_X - pos(1:3), 'fro') - pos(4) - trop); - - %--- Construct the A matrix --------------------------------------- - A(i, :) = [ (-(Rot_X(1) - pos(1))) / obs(i) ... - (-(Rot_X(2) - pos(2))) / obs(i) ... - (-(Rot_X(3) - pos(3))) / obs(i) ... - 1 ]; - end % for i = 1:nmbOfSatellites - - % These lines allow the code to exit gracefully in case of any errors - if rank(A) ~= 4 - pos = zeros(1, 4); - return - end - - %--- Find position update --------------------------------------------- - x = A \ omc; - - %--- Apply position update -------------------------------------------- - pos = pos + x; - -end % for iter = 1:nmbOfIterations - -pos = pos'; - -%=== Calculate Dilution Of Precision ====================================== -if nargout == 4 - %--- Initialize output ------------------------------------------------ - dop = zeros(1, 5); - - %--- Calculate DOP ---------------------------------------------------- - Q = inv(A'*A); - - dop(1) = sqrt(trace(Q)); % GDOP - dop(2) = sqrt(Q(1,1) + Q(2,2) + Q(3,3)); % PDOP - dop(3) = sqrt(Q(1,1) + Q(2,2)); % HDOP - dop(4) = sqrt(Q(3,3)); % VDOP - dop(5) = sqrt(Q(4,4)); % TDOP -end +function [pos, el, az, dop] = leastSquarePos(satpos, obs, settings) +% Function calculates the Least Square Solution. +% +% [pos, el, az, dop] = leastSquarePos(satpos, obs, settings); +% +% Inputs: +% satpos - Satellites positions (in ECEF system: [X; Y; Z;] - +% one column per satellite) +% obs - Observations - the pseudorange measurements to each +% satellite: +% (e.g. [20000000 21000000 .... .... .... .... ....]) +% settings - receiver settings +% +% Outputs: +% pos - receiver position and receiver clock error +% (in ECEF system: [X, Y, Z, dt]) +% el - Satellites elevation angles (degrees) +% az - Satellites azimuth angles (degrees) +% dop - Dilutions Of Precision ([GDOP PDOP HDOP VDOP TDOP]) + +%-------------------------------------------------------------------------- +% SoftGNSS v3.0 +%-------------------------------------------------------------------------- +%Based on Kai Borre +%Copyright (c) by Kai Borre +%Updated by Darius Plausinaitis, Peter Rinder and Nicolaj Bertelsen +%========================================================================== + +%=== Initialization ======================================================= +nmbOfIterations = 7; + +dtr = pi/180; +pos = zeros(4, 1); +X = satpos; +nmbOfSatellites = size(satpos, 2); + +A = zeros(nmbOfSatellites, 4); +omc = zeros(nmbOfSatellites, 1); +az = zeros(1, nmbOfSatellites); +el = az; + +%=== Iteratively find receiver position =================================== +for iter = 1:nmbOfIterations + + for i = 1:nmbOfSatellites + if iter == 1 + %--- Initialize variables at the first iteration -------------- + Rot_X = X(:, i); + trop = 2; + else + %--- Update equations ----------------------------------------- + rho2 = (X(1, i) - pos(1))^2 + (X(2, i) - pos(2))^2 + ... + (X(3, i) - pos(3))^2; + traveltime = sqrt(rho2) / settings.c ; + + %--- Correct satellite position (do to earth rotation) -------- + Rot_X = e_r_corr(traveltime, X(:, i)); + + %--- Find the elevation angel of the satellite ---------------- + [az(i), el(i), dist] = topocent(pos(1:3, :), Rot_X - pos(1:3, :)); + + if (settings.useTropCorr == 1) + %--- Calculate tropospheric correction -------------------- + trop = tropo(sin(el(i) * dtr), ... + 0.0, 1013.0, 293.0, 50.0, 0.0, 0.0, 0.0); + else + % Do not calculate or apply the tropospheric corrections + trop = 0; + end + end % if iter == 1 ... ... else + + %--- Apply the corrections ---------------------------------------- + omc(i) = (obs(i) - norm(Rot_X - pos(1:3), 'fro') - pos(4) - trop); + + %--- Construct the A matrix --------------------------------------- + A(i, :) = [ (-(Rot_X(1) - pos(1))) / obs(i) ... + (-(Rot_X(2) - pos(2))) / obs(i) ... + (-(Rot_X(3) - pos(3))) / obs(i) ... + 1 ]; + end % for i = 1:nmbOfSatellites + + % These lines allow the code to exit gracefully in case of any errors + if rank(A) ~= 4 + pos = zeros(1, 4); + return + end + + %--- Find position update --------------------------------------------- + x = A \ omc; + + %--- Apply position update -------------------------------------------- + pos = pos + x; + +end % for iter = 1:nmbOfIterations + +pos = pos'; + +%=== Calculate Dilution Of Precision ====================================== +if nargout == 4 + %--- Initialize output ------------------------------------------------ + dop = zeros(1, 5); + + %--- Calculate DOP ---------------------------------------------------- + Q = inv(A'*A); + + dop(1) = sqrt(trace(Q)); % GDOP + dop(2) = sqrt(Q(1,1) + Q(2,2) + Q(3,3)); % PDOP + dop(3) = sqrt(Q(1,1) + Q(2,2)); % HDOP + dop(4) = sqrt(Q(3,3)); % VDOP + dop(5) = sqrt(Q(4,4)); % TDOP +end diff --git a/src/utils/matlab/libs/geoFunctions/mat2dms.m b/src/utils/matlab/libs/geoFunctions/mat2dms.m index 839a0a62a..fad0eca81 100644 --- a/src/utils/matlab/libs/geoFunctions/mat2dms.m +++ b/src/utils/matlab/libs/geoFunctions/mat2dms.m @@ -1,125 +1,124 @@ -function dmsvec = mat2dms(d,m,s,n) - -%MAT2DMS Converts a [deg min sec] matrix to vector format -% -% dms = MAT2DMS(d,m,s) converts a deg:min:sec matrix into a vector -% format. The vector format is dms = 100*deg + min + sec/100. -% This allows d,m,s triple to be compressed into a single value, -% which can then be employed similar to a degree or radian vector. -% The inputs d, m and s must be of equal size. Minutes and -% second must be between 0 and 60. -% -% dms = MAT2DMS(mat) assumes and input matrix of [d m s]. This is -% useful only for single column vectors for d, m and s. -% -% dms = MAT2DMS(d,m) and dms = MAT2DMS([d m]) assume that seconds -% are zero, s = 0. -% -% dms = MAT2DMS(d,m,s,n) uses n as the accuracy of the seconds -% calculation. n = -2 uses accuracy in the hundredths position, -% n = 0 uses accuracy in the units position. Default is n = -5. -% For further discussion of the input n, see ROUNDN. -% -% See also DMS2MAT - -% Copyright 1996-2002 Systems Planning and Analysis, Inc. and The MathWorks, Inc. -% Written by: E. Byrns, E. Brown -% $Revision: 1.10 $ $Date: 2002/03/20 21:25:51 $ - - -if nargin == 0 - error('Incorrect number of arguments') - -elseif nargin==1 - if size(d,2)== 3 - s = d(:,3); m = d(:,2); d = d(:,1); - elseif size(d,2)== 2 - m = d(:,2); d = d(:,1); s = zeros(size(d)); - elseif size(d,2) == 0 - d = []; m = []; s = []; - else - error('Single input matrices must be n-by-2 or n-by-3.'); - end - n = -5; - -elseif nargin == 2 - s = zeros(size(d)); - n = -5; - -elseif nargin == 3 - n = -5; -end - -% Test for empty arguments - -if isempty(d) & isempty(m) & isempty(s); dmsvec = []; return; end - -% Don't let seconds be rounded beyond the tens place. -% If you did, then 55 seconds rounds to 100, which is not good. - -if n == 2; n = 1; end - -% Complex argument tests - -if any([~isreal(d) ~isreal(m) ~isreal(s)]) - warning('Imaginary parts of complex ANGLE argument ignored') - d = real(d); m = real(m); s = real(s); -end - -% Dimension and value tests - -if ~isequal(size(d),size(m),size(s)) - error('Inconsistent dimensions for input arguments') -elseif any(rem(d(~isnan(d)),1) ~= 0 | rem(m(~isnan(m)),1) ~= 0) - error('Degrees and minutes must be integers') -end - -if any(abs(m) > 60) | any (abs(m) < 0) % Actually algorithm allows for - error('Minutes must be >= 0 and < 60') % up to exactly 60 seconds or - % 60 minutes, but the error message -elseif any(abs(s) > 60) | any(abs(s) < 0) % doesn't reflect this so that angst - error('Seconds must be >= 0 and < 60') % is minimized in the user docs -end - -% Ensure that only one negative sign is present and at the correct location - -if any((s<0 & m<0) | (s<0 & d<0) | (m<0 & d<0) ) - error('Multiple negative entries in a DMS specification') -elseif any((s<0 & (m~=0 | d~= 0)) | (m<0 & d~=0)) - error('Incorrect negative DMS specification') -end - -% Construct a sign vector which has +1 when -% angle >= 0 and -1 when angle < 0. Note that the sign of the -% angle is associated with the largest nonzero component of d:m:s - -negvec = (d<0) | (m<0) | (s<0); -signvec = ~negvec - negvec; - -% Convert to all positive numbers. Allows for easier -% adjusting at 60 seconds and 60 minutes - -d = abs(d); m = abs(m); s = abs(s); - -% Truncate seconds to a specified accuracy to eliminate round-off errors - -[s,msg] = roundn(s,n); -if ~isempty(msg); error(msg); end - -% Adjust for 60 seconds or 60 minutes. If s > 60, this can only be -% from round-off during roundn since s > 60 is already tested above. -% This round-off effect has happened though. - -indx = find(s >= 60); -if ~isempty(indx); m(indx) = m(indx) + 1; s(indx) = 0; end - -% The user can not put minutes > 60 as input. However, the line -% above may create minutes > 60 (since the user can put in m == 60), -% thus, the test below includes the greater than condition. - -indx = find(m >= 60); -if ~isempty(indx); d(indx) = d(indx) + 1; m(indx) = m(indx)-60; end - -% Construct the dms vector format - -dmsvec = signvec .* (100*d + m + s/100); +function dmsvec = mat2dms(d,m,s,n) +% MAT2DMS Converts a [deg min sec] matrix to vector format +% +% dms = MAT2DMS(d,m,s) converts a deg:min:sec matrix into a vector +% format. The vector format is dms = 100*deg + min + sec/100. +% This allows d,m,s triple to be compressed into a single value, +% which can then be employed similar to a degree or radian vector. +% The inputs d, m and s must be of equal size. Minutes and +% second must be between 0 and 60. +% +% dms = MAT2DMS(mat) assumes and input matrix of [d m s]. This is +% useful only for single column vectors for d, m and s. +% +% dms = MAT2DMS(d,m) and dms = MAT2DMS([d m]) assume that seconds +% are zero, s = 0. +% +% dms = MAT2DMS(d,m,s,n) uses n as the accuracy of the seconds +% calculation. n = -2 uses accuracy in the hundredths position, +% n = 0 uses accuracy in the units position. Default is n = -5. +% For further discussion of the input n, see ROUNDN. +% +% See also DMS2MAT + +% Copyright 1996-2002 Systems Planning and Analysis, Inc. and The MathWorks, Inc. +% Written by: E. Byrns, E. Brown +% Revision: 1.10 Date: 2002/03/20 21:25:51 + + +if nargin == 0 + error('Incorrect number of arguments') + +elseif nargin==1 + if size(d,2)== 3 + s = d(:,3); m = d(:,2); d = d(:,1); + elseif size(d,2)== 2 + m = d(:,2); d = d(:,1); s = zeros(size(d)); + elseif size(d,2) == 0 + d = []; m = []; s = []; + else + error('Single input matrices must be n-by-2 or n-by-3.'); + end + n = -5; + +elseif nargin == 2 + s = zeros(size(d)); + n = -5; + +elseif nargin == 3 + n = -5; +end + +% Test for empty arguments + +if isempty(d) & isempty(m) & isempty(s); dmsvec = []; return; end + +% Don't let seconds be rounded beyond the tens place. +% If you did, then 55 seconds rounds to 100, which is not good. + +if n == 2; n = 1; end + +% Complex argument tests + +if any([~isreal(d) ~isreal(m) ~isreal(s)]) + warning('Imaginary parts of complex ANGLE argument ignored') + d = real(d); m = real(m); s = real(s); +end + +% Dimension and value tests + +if ~isequal(size(d),size(m),size(s)) + error('Inconsistent dimensions for input arguments') +elseif any(rem(d(~isnan(d)),1) ~= 0 | rem(m(~isnan(m)),1) ~= 0) + error('Degrees and minutes must be integers') +end + +if any(abs(m) > 60) | any (abs(m) < 0) % Actually algorithm allows for + error('Minutes must be >= 0 and < 60') % up to exactly 60 seconds or + % 60 minutes, but the error message +elseif any(abs(s) > 60) | any(abs(s) < 0) % doesn't reflect this so that angst + error('Seconds must be >= 0 and < 60') % is minimized in the user docs +end + +% Ensure that only one negative sign is present and at the correct location + +if any((s<0 & m<0) | (s<0 & d<0) | (m<0 & d<0) ) + error('Multiple negative entries in a DMS specification') +elseif any((s<0 & (m~=0 | d~= 0)) | (m<0 & d~=0)) + error('Incorrect negative DMS specification') +end + +% Construct a sign vector which has +1 when +% angle >= 0 and -1 when angle < 0. Note that the sign of the +% angle is associated with the largest nonzero component of d:m:s + +negvec = (d<0) | (m<0) | (s<0); +signvec = ~negvec - negvec; + +% Convert to all positive numbers. Allows for easier +% adjusting at 60 seconds and 60 minutes + +d = abs(d); m = abs(m); s = abs(s); + +% Truncate seconds to a specified accuracy to eliminate round-off errors + +[s,msg] = roundn(s,n); +if ~isempty(msg); error(msg); end + +% Adjust for 60 seconds or 60 minutes. If s > 60, this can only be +% from round-off during roundn since s > 60 is already tested above. +% This round-off effect has happened though. + +indx = find(s >= 60); +if ~isempty(indx); m(indx) = m(indx) + 1; s(indx) = 0; end + +% The user can not put minutes > 60 as input. However, the line +% above may create minutes > 60 (since the user can put in m == 60), +% thus, the test below includes the greater than condition. + +indx = find(m >= 60); +if ~isempty(indx); d(indx) = d(indx) + 1; m(indx) = m(indx)-60; end + +% Construct the dms vector format + +dmsvec = signvec .* (100*d + m + s/100); diff --git a/src/utils/matlab/libs/geoFunctions/roundn.m b/src/utils/matlab/libs/geoFunctions/roundn.m index 936e114a5..ca2eb8998 100644 --- a/src/utils/matlab/libs/geoFunctions/roundn.m +++ b/src/utils/matlab/libs/geoFunctions/roundn.m @@ -1,46 +1,46 @@ -function [x,msg] = roundn(x,n) - -%ROUNDN Rounds input data at specified power of 10 -% -% y = ROUNDN(x) rounds the input data x to the nearest hundredth. -% -% y = ROUNDN(x,n) rounds the input data x at the specified power -% of tens position. For example, n = -2 rounds the input data to -% the 10E-2 (hundredths) position. -% -% [y,msg] = ROUNDN(...) returns the text of any error condition -% encountered in the output variable msg. -% -% See also ROUND - -% Copyright 1996-2002 Systems Planning and Analysis, Inc. and The MathWorks, Inc. -% Written by: E. Byrns, E. Brown -% $Revision: 1.9 $ $Date: 2002/03/20 21:26:19 $ - -msg = []; % Initialize output - -if nargin == 0 - error('Incorrect number of arguments') -elseif nargin == 1 - n = -2; -end - -% Test for scalar n - -if max(size(n)) ~= 1 - msg = 'Scalar accuracy required'; - if nargout < 2; error(msg); end - return -elseif ~isreal(n) - warning('Imaginary part of complex N argument ignored') - n = real(n); -end - -% Compute the exponential factors for rounding at specified -% power of 10. Ensure that n is an integer. - -factors = 10 ^ (fix(-n)); - -% Set the significant digits for the input data - -x = round(x * factors) / factors; \ No newline at end of file +function [x,msg] = roundn(x,n) + +% ROUNDN Rounds input data at specified power of 10 +% +% y = ROUNDN(x) rounds the input data x to the nearest hundredth. +% +% y = ROUNDN(x,n) rounds the input data x at the specified power +% of tens position. For example, n = -2 rounds the input data to +% the 10E-2 (hundredths) position. +% +% [y,msg] = ROUNDN(...) returns the text of any error condition +% encountered in the output variable msg. +% +% See also ROUND + +% Copyright 1996-2002 Systems Planning and Analysis, Inc. and The MathWorks, Inc. +% Written by: E. Byrns, E. Brown +% Revision: 1.9 Date: 2002/03/20 21:26:19 + +msg = []; % Initialize output + +if nargin == 0 + error('Incorrect number of arguments') +elseif nargin == 1 + n = -2; +end + +% Test for scalar n + +if max(size(n)) ~= 1 + msg = 'Scalar accuracy required'; + if nargout < 2; error(msg); end + return +elseif ~isreal(n) + warning('Imaginary part of complex N argument ignored') + n = real(n); +end + +% Compute the exponential factors for rounding at specified +% power of 10. Ensure that n is an integer. + +factors = 10 ^ (fix(-n)); + +% Set the significant digits for the input data + +x = round(x * factors) / factors; diff --git a/src/utils/matlab/libs/geoFunctions/satpos.m b/src/utils/matlab/libs/geoFunctions/satpos.m index 14adf6570..e359a5df1 100644 --- a/src/utils/matlab/libs/geoFunctions/satpos.m +++ b/src/utils/matlab/libs/geoFunctions/satpos.m @@ -1,141 +1,138 @@ -function [satPositions, satClkCorr] = satpos(transmitTime, prnList, ... - eph, settings) -%SATPOS Computation of satellite coordinates X,Y,Z at TRANSMITTIME for -%given ephemeris EPH. Coordinates are computed for each satellite in the -%list PRNLIST. -%[satPositions, satClkCorr] = satpos(transmitTime, prnList, eph, settings); -% -% Inputs: -% transmitTime - transmission time -% prnList - list of PRN-s to be processed -% eph - ephemerides of satellites -% settings - receiver settings -% -% Outputs: -% satPositions - position of satellites (in ECEF system [X; Y; Z;]) -% satClkCorr - correction of satellite clocks - -%-------------------------------------------------------------------------- -% SoftGNSS v3.0 -%-------------------------------------------------------------------------- -%Based on Kai Borre 04-09-96 -%Copyright (c) by Kai Borre -%Updated by Darius Plausinaitis, Peter Rinder and Nicolaj Bertelsen -% -% CVS record: -% $Id: satpos.m,v 1.1.2.17 2007/01/30 09:45:12 dpl Exp $ - -%% Initialize constants =================================================== -numOfSatellites = size(prnList, 2); - -% GPS constatns - -gpsPi = 3.1415926535898; % Pi used in the GPS coordinate - % system - -%--- Constants for satellite position calculation ------------------------- -Omegae_dot = 7.2921151467e-5; % Earth rotation rate, [rad/s] -GM = 3.986005e14; % Universal gravitational constant times - % the mass of the Earth, [m^3/s^2] -F = -4.442807633e-10; % Constant, [sec/(meter)^(1/2)] - -%% Initialize results ===================================================== -satClkCorr = zeros(1, numOfSatellites); -satPositions = zeros(3, numOfSatellites); - -%% Process each satellite ================================================= - -for satNr = 1 : numOfSatellites - - prn = prnList(satNr); - -%% Find initial satellite clock correction -------------------------------- - - %--- Find time difference --------------------------------------------- - dt = check_t(transmitTime - eph(prn).t_oc); - - %--- Calculate clock correction --------------------------------------- - satClkCorr(satNr) = (eph(prn).a_f2 * dt + eph(prn).a_f1) * dt + ... - eph(prn).a_f0 - ... - eph(prn).T_GD; - - time = transmitTime - satClkCorr(satNr); - -%% Find satellite's position ---------------------------------------------- - - %Restore semi-major axis - a = eph(prn).sqrtA * eph(prn).sqrtA; - - %Time correction - tk = check_t(time - eph(prn).t_oe); - - %Initial mean motion - n0 = sqrt(GM / a^3); - %Mean motion - n = n0 + eph(prn).deltan; - - %Mean anomaly - M = eph(prn).M_0 + n * tk; - %Reduce mean anomaly to between 0 and 360 deg - M = rem(M + 2*gpsPi, 2*gpsPi); - - %Initial guess of eccentric anomaly - E = M; - - %--- Iteratively compute eccentric anomaly ---------------------------- - for ii = 1:10 - E_old = E; - E = M + eph(prn).e * sin(E); - dE = rem(E - E_old, 2*gpsPi); - - if abs(dE) < 1.e-12 - % Necessary precision is reached, exit from the loop - break; - end - end - - %Reduce eccentric anomaly to between 0 and 360 deg - E = rem(E + 2*gpsPi, 2*gpsPi); - - %Compute relativistic correction term - dtr = F * eph(prn).e * eph(prn).sqrtA * sin(E); - - %Calculate the true anomaly - nu = atan2(sqrt(1 - eph(prn).e^2) * sin(E), cos(E)-eph(prn).e); - - %Compute angle phi - phi = nu + eph(prn).omega; - %Reduce phi to between 0 and 360 deg - phi = rem(phi, 2*gpsPi); - - %Correct argument of latitude - u = phi + ... - eph(prn).C_uc * cos(2*phi) + ... - eph(prn).C_us * sin(2*phi); - %Correct radius - r = a * (1 - eph(prn).e*cos(E)) + ... - eph(prn).C_rc * cos(2*phi) + ... - eph(prn).C_rs * sin(2*phi); - %Correct inclination - i = eph(prn).i_0 + eph(prn).iDot * tk + ... - eph(prn).C_ic * cos(2*phi) + ... - eph(prn).C_is * sin(2*phi); - - %Compute the angle between the ascending node and the Greenwich meridian - Omega = eph(prn).omega_0 + (eph(prn).omegaDot - Omegae_dot)*tk - ... - Omegae_dot * eph(prn).t_oe; - %Reduce to between 0 and 360 deg - Omega = rem(Omega + 2*gpsPi, 2*gpsPi); - - %--- Compute satellite coordinates ------------------------------------ - satPositions(1, satNr) = cos(u)*r * cos(Omega) - sin(u)*r * cos(i)*sin(Omega); - satPositions(2, satNr) = cos(u)*r * sin(Omega) + sin(u)*r * cos(i)*cos(Omega); - satPositions(3, satNr) = sin(u)*r * sin(i); - - -%% Include relativistic correction in clock correction -------------------- - satClkCorr(satNr) = (eph(prn).a_f2 * dt + eph(prn).a_f1) * dt + ... - eph(prn).a_f0 - ... - eph(prn).T_GD + dtr; - -end % for satNr = 1 : numOfSatellites +function [satPositions, satClkCorr] = satpos(transmitTime, prnList, ... + eph, settings) +% SATPOS Computation of satellite coordinates X,Y,Z at TRANSMITTIME for +% given ephemeris EPH. Coordinates are computed for each satellite in the +% list PRNLIST. +%[ satPositions, satClkCorr] = satpos(transmitTime, prnList, eph, settings); +% +% Inputs: +% transmitTime - transmission time +% prnList - list of PRN-s to be processed +% eph - ephemerides of satellites +% settings - receiver settings +% +% Outputs: +% satPositions - position of satellites (in ECEF system [X; Y; Z;]) +% satClkCorr - correction of satellite clocks + +%-------------------------------------------------------------------------- +% SoftGNSS v3.0 +%-------------------------------------------------------------------------- +% Based on Kai Borre 04-09-96 +% Copyright (c) by Kai Borre +% Updated by Darius Plausinaitis, Peter Rinder and Nicolaj Bertelsen + +%% Initialize constants =================================================== +numOfSatellites = size(prnList, 2); + +% GPS constatns + +gpsPi = 3.1415926535898; % Pi used in the GPS coordinate +% system + +%--- Constants for satellite position calculation ------------------------- +Omegae_dot = 7.2921151467e-5; % Earth rotation rate, [rad/s] +GM = 3.986005e14; % Universal gravitational constant times +% the mass of the Earth, [m^3/s^2] +F = -4.442807633e-10; % Constant, [sec/(meter)^(1/2)] + +%% Initialize results ===================================================== +satClkCorr = zeros(1, numOfSatellites); +satPositions = zeros(3, numOfSatellites); + +%% Process each satellite ================================================= + +for satNr = 1 : numOfSatellites + + prn = prnList(satNr); + + %% Find initial satellite clock correction -------------------------------- + + %--- Find time difference --------------------------------------------- + dt = check_t(transmitTime - eph(prn).t_oc); + + %--- Calculate clock correction --------------------------------------- + satClkCorr(satNr) = (eph(prn).a_f2 * dt + eph(prn).a_f1) * dt + ... + eph(prn).a_f0 - ... + eph(prn).T_GD; + + time = transmitTime - satClkCorr(satNr); + + %% Find satellite's position ---------------------------------------------- + + %Restore semi-major axis + a = eph(prn).sqrtA * eph(prn).sqrtA; + + %Time correction + tk = check_t(time - eph(prn).t_oe); + + %Initial mean motion + n0 = sqrt(GM / a^3); + %Mean motion + n = n0 + eph(prn).deltan; + + %Mean anomaly + M = eph(prn).M_0 + n * tk; + %Reduce mean anomaly to between 0 and 360 deg + M = rem(M + 2*gpsPi, 2*gpsPi); + + %Initial guess of eccentric anomaly + E = M; + + %--- Iteratively compute eccentric anomaly ---------------------------- + for ii = 1:10 + E_old = E; + E = M + eph(prn).e * sin(E); + dE = rem(E - E_old, 2*gpsPi); + + if abs(dE) < 1.e-12 + % Necessary precision is reached, exit from the loop + break; + end + end + + %Reduce eccentric anomaly to between 0 and 360 deg + E = rem(E + 2*gpsPi, 2*gpsPi); + + %Compute relativistic correction term + dtr = F * eph(prn).e * eph(prn).sqrtA * sin(E); + + %Calculate the true anomaly + nu = atan2(sqrt(1 - eph(prn).e^2) * sin(E), cos(E)-eph(prn).e); + + %Compute angle phi + phi = nu + eph(prn).omega; + %Reduce phi to between 0 and 360 deg + phi = rem(phi, 2*gpsPi); + + %Correct argument of latitude + u = phi + ... + eph(prn).C_uc * cos(2*phi) + ... + eph(prn).C_us * sin(2*phi); + %Correct radius + r = a * (1 - eph(prn).e*cos(E)) + ... + eph(prn).C_rc * cos(2*phi) + ... + eph(prn).C_rs * sin(2*phi); + %Correct inclination + i = eph(prn).i_0 + eph(prn).iDot * tk + ... + eph(prn).C_ic * cos(2*phi) + ... + eph(prn).C_is * sin(2*phi); + + %Compute the angle between the ascending node and the Greenwich meridian + Omega = eph(prn).omega_0 + (eph(prn).omegaDot - Omegae_dot)*tk - ... + Omegae_dot * eph(prn).t_oe; + %Reduce to between 0 and 360 deg + Omega = rem(Omega + 2*gpsPi, 2*gpsPi); + + %--- Compute satellite coordinates ------------------------------------ + satPositions(1, satNr) = cos(u)*r * cos(Omega) - sin(u)*r * cos(i)*sin(Omega); + satPositions(2, satNr) = cos(u)*r * sin(Omega) + sin(u)*r * cos(i)*cos(Omega); + satPositions(3, satNr) = sin(u)*r * sin(i); + + + %% Include relativistic correction in clock correction -------------------- + satClkCorr(satNr) = (eph(prn).a_f2 * dt + eph(prn).a_f1) * dt + ... + eph(prn).a_f0 - ... + eph(prn).T_GD + dtr; + +end % for satNr = 1 : numOfSatellites diff --git a/src/utils/matlab/libs/geoFunctions/togeod.m b/src/utils/matlab/libs/geoFunctions/togeod.m index 99a43cc2c..b9d7bbb28 100644 --- a/src/utils/matlab/libs/geoFunctions/togeod.m +++ b/src/utils/matlab/libs/geoFunctions/togeod.m @@ -1,112 +1,109 @@ -function [dphi, dlambda, h] = togeod(a, finv, X, Y, Z) -%TOGEOD Subroutine to calculate geodetic coordinates latitude, longitude, -% height given Cartesian coordinates X,Y,Z, and reference ellipsoid -% values semi-major axis (a) and the inverse of flattening (finv). -% -%[dphi, dlambda, h] = togeod(a, finv, X, Y, Z); -% -% The units of linear parameters X,Y,Z,a must all agree (m,km,mi,ft,..etc) -% The output units of angular quantities will be in decimal degrees -% (15.5 degrees not 15 deg 30 min). The output units of h will be the -% same as the units of X,Y,Z,a. -% -% Inputs: -% a - semi-major axis of the reference ellipsoid -% finv - inverse of flattening of the reference ellipsoid -% X,Y,Z - Cartesian coordinates -% -% Outputs: -% dphi - latitude -% dlambda - longitude -% h - height above reference ellipsoid - -% Copyright (C) 1987 C. Goad, Columbus, Ohio -% Reprinted with permission of author, 1996 -% Fortran code translated into MATLAB -% Kai Borre 03-30-96 -% -% CVS record: -% $Id: togeod.m,v 1.1.1.1.2.4 2006/08/22 13:45:59 dpl Exp $ -%========================================================================== - -h = 0; -tolsq = 1.e-10; -maxit = 10; - -% compute radians-to-degree factor -rtd = 180/pi; - -% compute square of eccentricity -if finv < 1.e-20 - esq = 0; -else - esq = (2 - 1/finv) / finv; -end - -oneesq = 1 - esq; - -% first guess -% P is distance from spin axis -P = sqrt(X^2+Y^2); -% direct calculation of longitude - -if P > 1.e-20 - dlambda = atan2(Y,X) * rtd; -else - dlambda = 0; -end - -if (dlambda < 0) - dlambda = dlambda + 360; -end - -% r is distance from origin (0,0,0) -r = sqrt(P^2 + Z^2); - -if r > 1.e-20 - sinphi = Z/r; -else - sinphi = 0; -end - -dphi = asin(sinphi); - -% initial value of height = distance from origin minus -% approximate distance from origin to surface of ellipsoid -if r < 1.e-20 - h = 0; - return -end - -h = r - a*(1-sinphi*sinphi/finv); - -% iterate -for i = 1:maxit - sinphi = sin(dphi); - cosphi = cos(dphi); - - % compute radius of curvature in prime vertical direction - N_phi = a/sqrt(1-esq*sinphi*sinphi); - - % compute residuals in P and Z - dP = P - (N_phi + h) * cosphi; - dZ = Z - (N_phi*oneesq + h) * sinphi; - - % update height and latitude - h = h + (sinphi*dZ + cosphi*dP); - dphi = dphi + (cosphi*dZ - sinphi*dP)/(N_phi + h); - - % test for convergence - if (dP*dP + dZ*dZ < tolsq) - break; - end - - % Not Converged--Warn user - if i == maxit - fprintf([' Problem in TOGEOD, did not converge in %2.0f',... - ' iterations\n'], i); - end -end % for i = 1:maxit - -dphi = dphi * rtd; -%%%%%%%% end togeod.m %%%%%%%%%%%%%%%%%%%%%% +function [dphi, dlambda, h] = togeod(a, finv, X, Y, Z) +% TOGEOD Subroutine to calculate geodetic coordinates latitude, longitude, +% height given Cartesian coordinates X,Y,Z, and reference ellipsoid +% values semi-major axis (a) and the inverse of flattening (finv). +% +% [dphi, dlambda, h] = togeod(a, finv, X, Y, Z); +% +% The units of linear parameters X,Y,Z,a must all agree (m,km,mi,ft,..etc) +% The output units of angular quantities will be in decimal degrees +% (15.5 degrees not 15 deg 30 min). The output units of h will be the +% same as the units of X,Y,Z,a. +% +% Inputs: +% a - semi-major axis of the reference ellipsoid +% finv - inverse of flattening of the reference ellipsoid +% X,Y,Z - Cartesian coordinates +% +% Outputs: +% dphi - latitude +% dlambda - longitude +% h - height above reference ellipsoid + +% Copyright (C) 1987 C. Goad, Columbus, Ohio +% Reprinted with permission of author, 1996 +% Fortran code translated into MATLAB +% Kai Borre 03-30-96 +%========================================================================== + +h = 0; +tolsq = 1.e-10; +maxit = 10; + +% compute radians-to-degree factor +rtd = 180/pi; + +% compute square of eccentricity +if finv < 1.e-20 + esq = 0; +else + esq = (2 - 1/finv) / finv; +end + +oneesq = 1 - esq; + +% first guess +% P is distance from spin axis +P = sqrt(X^2+Y^2); +% direct calculation of longitude + +if P > 1.e-20 + dlambda = atan2(Y,X) * rtd; +else + dlambda = 0; +end + +if (dlambda < 0) + dlambda = dlambda + 360; +end + +% r is distance from origin (0,0,0) +r = sqrt(P^2 + Z^2); + +if r > 1.e-20 + sinphi = Z/r; +else + sinphi = 0; +end + +dphi = asin(sinphi); + +% initial value of height = distance from origin minus +% approximate distance from origin to surface of ellipsoid +if r < 1.e-20 + h = 0; + return +end + +h = r - a*(1-sinphi*sinphi/finv); + +% iterate +for i = 1:maxit + sinphi = sin(dphi); + cosphi = cos(dphi); + + % compute radius of curvature in prime vertical direction + N_phi = a/sqrt(1-esq*sinphi*sinphi); + + % compute residuals in P and Z + dP = P - (N_phi + h) * cosphi; + dZ = Z - (N_phi*oneesq + h) * sinphi; + + % update height and latitude + h = h + (sinphi*dZ + cosphi*dP); + dphi = dphi + (cosphi*dZ - sinphi*dP)/(N_phi + h); + + % test for convergence + if (dP*dP + dZ*dZ < tolsq) + break; + end + + % Not Converged--Warn user + if i == maxit + fprintf([' Problem in TOGEOD, did not converge in %2.0f',... + ' iterations\n'], i); + end +end % for i = 1:maxit + +dphi = dphi * rtd; +%%%%%%%% end togeod.m %%%%%%%%%%%%%%%%%%%%%% diff --git a/src/utils/matlab/libs/geoFunctions/topocent.m b/src/utils/matlab/libs/geoFunctions/topocent.m index a6f680bd1..723cb3dfb 100644 --- a/src/utils/matlab/libs/geoFunctions/topocent.m +++ b/src/utils/matlab/libs/geoFunctions/topocent.m @@ -1,57 +1,54 @@ -function [Az, El, D] = topocent(X, dx) -%TOPOCENT Transformation of vector dx into topocentric coordinate -% system with origin at X. -% Both parameters are 3 by 1 vectors. -% -%[Az, El, D] = topocent(X, dx); -% -% Inputs: -% X - vector origin corrdinates (in ECEF system [X; Y; Z;]) -% dx - vector ([dX; dY; dZ;]). -% -% Outputs: -% D - vector length. Units like units of the input -% Az - azimuth from north positive clockwise, degrees -% El - elevation angle, degrees - -%Kai Borre 11-24-96 -%Copyright (c) by Kai Borre -% -% CVS record: -% $Id: topocent.m,v 1.1.1.1.2.4 2006/08/22 13:45:59 dpl Exp $ -%========================================================================== - -dtr = pi/180; - -[phi, lambda, h] = togeod(6378137, 298.257223563, X(1), X(2), X(3)); - -cl = cos(lambda * dtr); -sl = sin(lambda * dtr); -cb = cos(phi * dtr); -sb = sin(phi * dtr); - -F = [-sl -sb*cl cb*cl; - cl -sb*sl cb*sl; - 0 cb sb]; - -local_vector = F' * dx; -E = local_vector(1); -N = local_vector(2); -U = local_vector(3); - -hor_dis = sqrt(E^2 + N^2); - -if hor_dis < 1.e-20 - Az = 0; - El = 90; -else - Az = atan2(E, N)/dtr; - El = atan2(U, hor_dis)/dtr; -end - -if Az < 0 - Az = Az + 360; -end - -D = sqrt(dx(1)^2 + dx(2)^2 + dx(3)^2); -%%%%%%%%% end topocent.m %%%%%%%%% \ No newline at end of file +function [Az, El, D] = topocent(X, dx) +% TOPOCENT Transformation of vector dx into topocentric coordinate +% system with origin at X. +% Both parameters are 3 by 1 vectors. +% +% [Az, El, D] = topocent(X, dx); +% +% Inputs: +% X - vector origin corrdinates (in ECEF system [X; Y; Z;]) +% dx - vector ([dX; dY; dZ;]). +% +% Outputs: +% D - vector length. Units like units of the input +% Az - azimuth from north positive clockwise, degrees +% El - elevation angle, degrees + +% Kai Borre 11-24-96 +% Copyright (c) by Kai Borre +%========================================================================== + +dtr = pi/180; + +[phi, lambda, h] = togeod(6378137, 298.257223563, X(1), X(2), X(3)); + +cl = cos(lambda * dtr); +sl = sin(lambda * dtr); +cb = cos(phi * dtr); +sb = sin(phi * dtr); + +F = [-sl -sb*cl cb*cl; + cl -sb*sl cb*sl; + 0 cb sb]; + +local_vector = F' * dx; +E = local_vector(1); +N = local_vector(2); +U = local_vector(3); + +hor_dis = sqrt(E^2 + N^2); + +if hor_dis < 1.e-20 + Az = 0; + El = 90; +else + Az = atan2(E, N)/dtr; + El = atan2(U, hor_dis)/dtr; +end + +if Az < 0 + Az = Az + 360; +end + +D = sqrt(dx(1)^2 + dx(2)^2 + dx(3)^2); +%%%%%%%%% end topocent.m %%%%%%%%% diff --git a/src/utils/matlab/libs/geoFunctions/tropo.m b/src/utils/matlab/libs/geoFunctions/tropo.m index bd14b8c52..4e1801aac 100644 --- a/src/utils/matlab/libs/geoFunctions/tropo.m +++ b/src/utils/matlab/libs/geoFunctions/tropo.m @@ -1,98 +1,95 @@ -function ddr = tropo(sinel, hsta, p, tkel, hum, hp, htkel, hhum) -%TROPO Calculation of tropospheric correction. -% The range correction ddr in m is to be subtracted from -% pseudo-ranges and carrier phases -% -%ddr = tropo(sinel, hsta, p, tkel, hum, hp, htkel, hhum); -% -% Inputs: -% sinel - sin of elevation angle of satellite -% hsta - height of station in km -% p - atmospheric pressure in mb at height hp -% tkel - surface temperature in degrees Kelvin at height htkel -% hum - humidity in % at height hhum -% hp - height of pressure measurement in km -% htkel - height of temperature measurement in km -% hhum - height of humidity measurement in km -% -% Outputs: -% ddr - range correction (meters) -% -% Reference -% Goad, C.C. & Goodman, L. (1974) A Modified Tropospheric -% Refraction Correction Model. Paper presented at the -% American Geophysical Union Annual Fall Meeting, San -% Francisco, December 12-17 - -% A Matlab reimplementation of a C code from driver. -% Kai Borre 06-28-95 -% -% CVS record: -% $Id: tropo.m,v 1.1.1.1.2.4 2006/08/22 13:46:00 dpl Exp $ -%========================================================================== - -a_e = 6378.137; % semi-major axis of earth ellipsoid -b0 = 7.839257e-5; -tlapse = -6.5; -tkhum = tkel + tlapse*(hhum-htkel); -atkel = 7.5*(tkhum-273.15) / (237.3+tkhum-273.15); -e0 = 0.0611 * hum * 10^atkel; -tksea = tkel - tlapse*htkel; -em = -978.77 / (2.8704e6*tlapse*1.0e-5); -tkelh = tksea + tlapse*hhum; -e0sea = e0 * (tksea/tkelh)^(4*em); -tkelp = tksea + tlapse*hp; -psea = p * (tksea/tkelp)^em; - -if sinel < 0 - sinel = 0; -end - -tropo = 0; -done = 'FALSE'; -refsea = 77.624e-6 / tksea; -htop = 1.1385e-5 / refsea; -refsea = refsea * psea; -ref = refsea * ((htop-hsta)/htop)^4; - -while 1 - rtop = (a_e+htop)^2 - (a_e+hsta)^2*(1-sinel^2); - - % check to see if geometry is crazy - if rtop < 0 - rtop = 0; - end - - rtop = sqrt(rtop) - (a_e+hsta)*sinel; - a = -sinel/(htop-hsta); - b = -b0*(1-sinel^2) / (htop-hsta); - rn = zeros(8,1); - - for i = 1:8 - rn(i) = rtop^(i+1); - end - - alpha = [2*a, 2*a^2+4*b/3, a*(a^2+3*b),... - a^4/5+2.4*a^2*b+1.2*b^2, 2*a*b*(a^2+3*b)/3,... - b^2*(6*a^2+4*b)*1.428571e-1, 0, 0]; - - if b^2 > 1.0e-35 - alpha(7) = a*b^3/2; - alpha(8) = b^4/9; - end - - dr = rtop; - dr = dr + alpha*rn; - tropo = tropo + dr*ref*1000; - - if done == 'TRUE ' - ddr = tropo; - break; - end - - done = 'TRUE '; - refsea = (371900.0e-6/tksea-12.92e-6)/tksea; - htop = 1.1385e-5 * (1255/tksea+0.05)/refsea; - ref = refsea * e0sea * ((htop-hsta)/htop)^4; -end; -%%%%%%%%% end tropo.m %%%%%%%%%%%%%%%%%%% +function ddr = tropo(sinel, hsta, p, tkel, hum, hp, htkel, hhum) +% TROPO Calculation of tropospheric correction. +% The range correction ddr in m is to be subtracted from +% pseudo-ranges and carrier phases +% +% ddr = tropo(sinel, hsta, p, tkel, hum, hp, htkel, hhum); +% +% Inputs: +% sinel - sin of elevation angle of satellite +% hsta - height of station in km +% p - atmospheric pressure in mb at height hp +% tkel - surface temperature in degrees Kelvin at height htkel +% hum - humidity in % at height hhum +% hp - height of pressure measurement in km +% htkel - height of temperature measurement in km +% hhum - height of humidity measurement in km +% +% Outputs: +% ddr - range correction (meters) +% +% Reference +% Goad, C.C. & Goodman, L. (1974) A Modified Tropospheric +% Refraction Correction Model. Paper presented at the +% American Geophysical Union Annual Fall Meeting, San +% Francisco, December 12-17 + +% A Matlab reimplementation of a C code from driver. +% Kai Borre 06-28-95 +%========================================================================== + +a_e = 6378.137; % semi-major axis of earth ellipsoid +b0 = 7.839257e-5; +tlapse = -6.5; +tkhum = tkel + tlapse*(hhum-htkel); +atkel = 7.5*(tkhum-273.15) / (237.3+tkhum-273.15); +e0 = 0.0611 * hum * 10^atkel; +tksea = tkel - tlapse*htkel; +em = -978.77 / (2.8704e6*tlapse*1.0e-5); +tkelh = tksea + tlapse*hhum; +e0sea = e0 * (tksea/tkelh)^(4*em); +tkelp = tksea + tlapse*hp; +psea = p * (tksea/tkelp)^em; + +if sinel < 0 + sinel = 0; +end + +tropo = 0; +done = 'FALSE'; +refsea = 77.624e-6 / tksea; +htop = 1.1385e-5 / refsea; +refsea = refsea * psea; +ref = refsea * ((htop-hsta)/htop)^4; + +while 1 + rtop = (a_e+htop)^2 - (a_e+hsta)^2*(1-sinel^2); + + % check to see if geometry is crazy + if rtop < 0 + rtop = 0; + end + + rtop = sqrt(rtop) - (a_e+hsta)*sinel; + a = -sinel/(htop-hsta); + b = -b0*(1-sinel^2) / (htop-hsta); + rn = zeros(8,1); + + for i = 1:8 + rn(i) = rtop^(i+1); + end + + alpha = [2*a, 2*a^2+4*b/3, a*(a^2+3*b),... + a^4/5+2.4*a^2*b+1.2*b^2, 2*a*b*(a^2+3*b)/3,... + b^2*(6*a^2+4*b)*1.428571e-1, 0, 0]; + + if b^2 > 1.0e-35 + alpha(7) = a*b^3/2; + alpha(8) = b^4/9; + end + + dr = rtop; + dr = dr + alpha*rn; + tropo = tropo + dr*ref*1000; + + if done == 'TRUE ' + ddr = tropo; + break; + end + + done = 'TRUE '; + refsea = (371900.0e-6/tksea-12.92e-6)/tksea; + htop = 1.1385e-5 * (1255/tksea+0.05)/refsea; + ref = refsea * e0sea * ((htop-hsta)/htop)^4; +end; +%%%%%%%%% end tropo.m %%%%%%%%%%%%%%%%%%% diff --git a/src/utils/matlab/libs/glonass_ca_dll_pll_read_tracking_dump.m b/src/utils/matlab/libs/glonass_ca_dll_pll_read_tracking_dump.m deleted file mode 100644 index 7141d1970..000000000 --- a/src/utils/matlab/libs/glonass_ca_dll_pll_read_tracking_dump.m +++ /dev/null @@ -1,191 +0,0 @@ -% /*! -% * \file glonass_ca_dll_pll_read_tracking_dump.m -% * \brief Read GNSS-SDR Tracking dump binary file into MATLAB. -% * \author Damian Miralles, 2017. dmiralles2009(at)gmail.com -% * ------------------------------------------------------------------------- -% * -% * Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors) -% * -% * GNSS-SDR is a software defined Global Navigation -% * Satellite Systems receiver -% * -% * This file is part of GNSS-SDR. -% * -% * GNSS-SDR is free software: you can redistribute it and/or modify -% * it under the terms of the GNU General Public License as published by -% * the Free Software Foundation, either version 3 of the License, or -% * at your option) any later version. -% * -% * GNSS-SDR is distributed in the hope that it will be useful, -% * but WITHOUT ANY WARRANTY; without even the implied warranty of -% * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% * GNU General Public License for more details. -% * -% * You should have received a copy of the GNU General Public License -% * along with GNSS-SDR. If not, see . -% * -% * ------------------------------------------------------------------------- -% */ -function [GNSS_tracking] = glonass_ca_dll_pll_read_tracking_dump (filename, count) - - %% usage: gps_l1_ca_dll_pll_read_tracking_dump_64bits (filename, [count]) - %% - %% open GNSS-SDR tracking binary log file .dat and return the contents - %% - - narginchk (1,2); - num_float_vars=5; - num_unsigned_long_int_vars=1; - num_double_vars=11; - num_unsigned_int_vars=1; - double_size_bytes=8; - unsigned_long_int_size_bytes=8; - float_size_bytes=4; - long_int_size_bytes=4; - - skip_bytes_each_read=float_size_bytes*num_float_vars+unsigned_long_int_size_bytes*num_unsigned_long_int_vars+double_size_bytes*num_double_vars+long_int_size_bytes*num_unsigned_int_vars; - bytes_shift=0; - - if (nargin < 2) - %count = Inf; - file_stats = dir(filename); - %round num bytes to read to integer number of samples (to protect the script from binary - %dump end file transitory) - count = (file_stats.bytes - mod(file_stats.bytes,skip_bytes_each_read))/skip_bytes_each_read; - end - %loops_counter = fread (f, count, 'uint32',4*12); - f = fopen (filename, 'rb'); - if (f < 0) - else - v1 = fread (f, count, 'float',skip_bytes_each_read-float_size_bytes); - bytes_shift=bytes_shift+float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved float - v2 = fread (f, count, 'float',skip_bytes_each_read-float_size_bytes); - bytes_shift=bytes_shift+float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved float - v3 = fread (f, count, 'float',skip_bytes_each_read-float_size_bytes); - bytes_shift=bytes_shift+float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved float - v4 = fread (f, count, 'float',skip_bytes_each_read-float_size_bytes); - bytes_shift=bytes_shift+float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved float - v5 = fread (f, count, 'float',skip_bytes_each_read-float_size_bytes); - bytes_shift=bytes_shift+float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved unsigned_long_int - v6 = fread (f, count, 'uint64',skip_bytes_each_read-unsigned_long_int_size_bytes); - bytes_shift=bytes_shift+unsigned_long_int_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved double - v7 = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved double - v8 = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved double - v9 = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved double - v10 = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved double - v11 = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved double - v12 = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved double - v13 = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved double - v14 = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved double - v15 = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved double - v16 = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved double - v17 = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved double - v18 = fread (f, count, 'uint32',skip_bytes_each_read-double_size_bytes); - fclose (f); - - %%%%%%%% output vars %%%%%%%% - -% // EPR -% d_dump_file.write(reinterpret_cast(&tmp_E), sizeof(float)); -% d_dump_file.write(reinterpret_cast(&tmp_P), sizeof(float)); -% d_dump_file.write(reinterpret_cast(&tmp_L), sizeof(float)); -% // PROMPT I and Q (to analyze navigation symbols) -% d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); -% d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); -% // PRN start sample stamp -% //tmp_float=(float)d_sample_counter; -% d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); -% // accumulated carrier phase -% d_dump_file.write(reinterpret_cast(&d_acc_carrier_phase_rad), sizeof(double)); -% -% // carrier and code frequency -% d_dump_file.write(reinterpret_cast(&d_carrier_doppler_hz), sizeof(double)); -% d_dump_file.write(reinterpret_cast(&d_code_freq_chips), sizeof(double)); -% -% //PLL commands -% d_dump_file.write(reinterpret_cast(&carr_phase_error_secs_Ti), sizeof(double)); -% d_dump_file.write(reinterpret_cast(&d_carrier_doppler_hz), sizeof(double)); -% -% //DLL commands -% d_dump_file.write(reinterpret_cast(&code_error_chips_Ti), sizeof(double)); -% d_dump_file.write(reinterpret_cast(&code_error_filt_chips), sizeof(double)); -% -% // CN0 and carrier lock test -% d_dump_file.write(reinterpret_cast(&d_CN0_SNV_dB_Hz), sizeof(double)); -% d_dump_file.write(reinterpret_cast(&d_carrier_lock_test), sizeof(double)); -% -% // AUX vars (for debug purposes) -% tmp_double = d_rem_code_phase_samples; -% d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); -% tmp_double = static_cast(d_sample_counter + d_current_prn_length_samples); -% d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); -% // PRN -% unsigned int prn_ = d_acquisition_gnss_synchro->PRN; -% d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); - E=v1; - P=v2; - L=v3; - prompt_I=v4; - prompt_Q=v5; - PRN_start_sample=v6; - acc_carrier_phase_rad=v7; - carrier_freq_hz=v8; - code_freq_hz=v9; - carr_error=v10; - carr_nco=v11; - code_error=v12; - code_nco=v13; - CN0_SNV_dB_Hz=v14; - carrier_lock_test=v15; - var1=v16; - var2=v17; - PRN=v18; - - GNSS_tracking.E=E; - GNSS_tracking.P=P; - GNSS_tracking.L=L; - GNSS_tracking.prompt_I=prompt_I; - GNSS_tracking.prompt_Q=prompt_Q; - GNSS_tracking.PRN_start_sample=PRN_start_sample; - GNSS_tracking.acc_carrier_phase_rad=acc_carrier_phase_rad; - GNSS_tracking.carrier_freq_hz=carrier_freq_hz; - GNSS_tracking.code_freq_hz=code_freq_hz; - GNSS_tracking.carr_error=carr_error; - GNSS_tracking.carr_nco=carr_nco; - GNSS_tracking.code_error=code_error; - GNSS_tracking.code_nco=code_nco; - GNSS_tracking.CN0_SNV_dB_Hz=CN0_SNV_dB_Hz; - GNSS_tracking.carrier_lock_test=carrier_lock_test; - GNSS_tracking.d_rem_code_phase_samples=var1; - GNSS_tracking.var2=var2; - GNSS_tracking.PRN=PRN; - end - diff --git a/src/utils/matlab/libs/gps_l1_ca_dll_fll_pll_read_tracking_dump.m b/src/utils/matlab/libs/gps_l1_ca_dll_fll_pll_read_tracking_dump.m deleted file mode 100644 index d7f7bb58a..000000000 --- a/src/utils/matlab/libs/gps_l1_ca_dll_fll_pll_read_tracking_dump.m +++ /dev/null @@ -1,178 +0,0 @@ -% /*! -% * \file gps_l1_ca_dll_fll_pll_read_tracking_dump.m -% * \brief Read GNSS-SDR Tracking dump binary file into MATLAB. -% * \author Javier Arribas, 2011. jarribas(at)cttc.es -% * ------------------------------------------------------------------------- -% * -% * Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors) -% * -% * GNSS-SDR is a software defined Global Navigation -% * Satellite Systems receiver -% * -% * This file is part of GNSS-SDR. -% * -% * GNSS-SDR is free software: you can redistribute it and/or modify -% * it under the terms of the GNU General Public License as published by -% * the Free Software Foundation, either version 3 of the License, or -% * at your option) any later version. -% * -% * GNSS-SDR is distributed in the hope that it will be useful, -% * but WITHOUT ANY WARRANTY; without even the implied warranty of -% * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% * GNU General Public License for more details. -% * -% * You should have received a copy of the GNU General Public License -% * along with GNSS-SDR. If not, see . -% * -% * ------------------------------------------------------------------------- -% */ -function [GNSS_tracking] = gps_l1_ca_dll_fll_pll_read_tracking_dump (filename, samplingFreq, count) - - %% usage: gps_l1_ca_dll_fll_pll_read_tracking_dump (filename, [count]) - %% - %% open GNSS-SDR tracking binary log file .dat and return the contents - %% - - m = nargchk (1,3,nargin); - num_float_vars=16; - num_double_vars=1; - double_size_bytes=8; - float_size_bytes=4; - skip_bytes_each_read=float_size_bytes*num_float_vars+double_size_bytes*num_double_vars; - bytes_shift=0; - if (m) - usage (m); - end - - if (nargin < 3) - count = Inf; - end - %loops_counter = fread (f, count, 'uint32',4*12); - f = fopen (filename, 'rb'); - if (f < 0) - else - v1 = fread (f, count, 'float',skip_bytes_each_read-float_size_bytes); - bytes_shift=bytes_shift+float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved float - v2 = fread (f, count, 'float',skip_bytes_each_read-float_size_bytes); - bytes_shift=bytes_shift+float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved float - v3 = fread (f, count, 'float',skip_bytes_each_read-float_size_bytes); - bytes_shift=bytes_shift+float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved float - v4 = fread (f, count, 'float',skip_bytes_each_read-float_size_bytes); - bytes_shift=bytes_shift+float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved float - v5 = fread (f, count, 'float',skip_bytes_each_read-float_size_bytes); - bytes_shift=bytes_shift+float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved float - v6 = fread (f, count, 'uint32',skip_bytes_each_read-float_size_bytes); - bytes_shift=bytes_shift+float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved float - v7 = fread (f, count, 'float',skip_bytes_each_read-float_size_bytes); - bytes_shift=bytes_shift+float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved float - v8 = fread (f, count, 'float',skip_bytes_each_read-float_size_bytes); - bytes_shift=bytes_shift+float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved float - v9 = fread (f, count, 'float',skip_bytes_each_read-float_size_bytes); - bytes_shift=bytes_shift+float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved float - v10 = fread (f, count, 'float',skip_bytes_each_read-float_size_bytes); - bytes_shift=bytes_shift+float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved float - v11 = fread (f, count, 'float',skip_bytes_each_read-float_size_bytes); - bytes_shift=bytes_shift+float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved float - v12 = fread (f, count, 'float',skip_bytes_each_read-float_size_bytes); - bytes_shift=bytes_shift+float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved float - v13 = fread (f, count, 'float',skip_bytes_each_read-float_size_bytes); - bytes_shift=bytes_shift+float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved float - v14 = fread (f, count, 'float',skip_bytes_each_read-float_size_bytes); - bytes_shift=bytes_shift+float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved float - v15 = fread (f, count, 'float',skip_bytes_each_read-float_size_bytes); - bytes_shift=bytes_shift+float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved float - v16 = fread (f, count, 'float',skip_bytes_each_read-float_size_bytes); - bytes_shift=bytes_shift+float_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved float - v17 = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - fclose (f); - - %%%%%%%% output vars %%%%%%%% - -% // EPR -% d_dump_file.write((char*)&tmp_E, sizeof(float)); -% d_dump_file.write((char*)&tmp_P, sizeof(float)); -% d_dump_file.write((char*)&tmp_L, sizeof(float)); -% // PROMPT I and Q (to analyze navigation symbols) -% d_dump_file.write((char*)&prompt_I, sizeof(float)); -% d_dump_file.write((char*)&prompt_Q, sizeof(float)); -% // PRN start sample stamp -% //tmp_float=(float)d_sample_counter; -% d_dump_file.write((char*)&d_sample_counter, sizeof(unsigned long int)); -% // accumulated carrier phase -% d_dump_file.write((char*)&d_acc_carrier_phase_rad, sizeof(float)); -% -% // carrier and code frequency -% d_dump_file.write((char*)&d_carrier_doppler_hz, sizeof(float)); -% d_dump_file.write((char*)&d_code_freq_hz, sizeof(float)); -% -% //PLL commands -% d_dump_file.write((char*)&PLL_discriminator_hz, sizeof(float)); -% d_dump_file.write((char*)&carr_nco_hz, sizeof(float)); -% -% //DLL commands -% d_dump_file.write((char*)&code_error_chips, sizeof(float)); -% d_dump_file.write((char*)&d_code_phase_samples, sizeof(float)); -% -% // CN0 and carrier lock test -% d_dump_file.write((char*)&d_CN0_SNV_dB_Hz, sizeof(float)); -% d_dump_file.write((char*)&d_carrier_lock_test, sizeof(float)); -% -% // AUX vars (for debug purposes) -% tmp_float=0; -% d_dump_file.write((char*)&tmp_float, sizeof(float)); -% d_dump_file.write((char*)&d_sample_counter_seconds, sizeof(double)); - - E=v1; - P=v2; - L=v3; - prompt_I=v4; - prompt_Q=v5; - PRN_start_sample=v6; - acc_carrier_phase_rad=v7; - carrier_doppler_hz=v8; - code_freq_hz=v9; - PLL_discriminator_hz=v10; - carr_nco_hz=v11; - code_error_chips=v12; - code_phase_samples=v13; - CN0_SNV_dB_Hz=v14; - carrier_lock_test=v15; - var1=v16; - var2=v17; - - GNSS_tracking.E=E; - GNSS_tracking.P=P; - GNSS_tracking.L=L; - GNSS_tracking.prompt_I=prompt_I; - GNSS_tracking.prompt_Q=prompt_Q; - GNSS_tracking.PRN_start_sample=PRN_start_sample; - GNSS_tracking.acc_carrier_phase_rad=acc_carrier_phase_rad; - GNSS_tracking.carrier_doppler_hz=carrier_doppler_hz; - GNSS_tracking.code_freq_hz=code_freq_hz; - GNSS_tracking.PLL_discriminator_hz=PLL_discriminator_hz; - GNSS_tracking.carr_nco=carr_nco_hz; - GNSS_tracking.code_error_chips=code_error_chips; - GNSS_tracking.code_phase_samples=code_phase_samples; - GNSS_tracking.CN0_SNV_dB_Hz=CN0_SNV_dB_Hz; - GNSS_tracking.carrier_lock_test=carrier_lock_test; - GNSS_tracking.var1=var1; - GNSS_tracking.var2=var2; - GNSS_tracking.prn_delay_ms=1000*(GNSS_tracking.var2+GNSS_tracking.var1)./samplingFreq; - end - diff --git a/src/utils/matlab/libs/gps_l1_ca_dll_pll_read_tracking_dump.m b/src/utils/matlab/libs/gps_l1_ca_dll_pll_read_tracking_dump.m index 4a060118f..1346816eb 100644 --- a/src/utils/matlab/libs/gps_l1_ca_dll_pll_read_tracking_dump.m +++ b/src/utils/matlab/libs/gps_l1_ca_dll_pll_read_tracking_dump.m @@ -1,158 +1,156 @@ -% /*! -% * \file gps_l1_ca_dll_pll_read_tracking_dump.m -% * \brief Read GNSS-SDR Tracking dump binary file into MATLAB. -% * \author Javier Arribas, 2011. jarribas(at)cttc.es -% * ------------------------------------------------------------------------- -% * -% * Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors) -% * -% * GNSS-SDR is a software defined Global Navigation -% * Satellite Systems receiver -% * -% * This file is part of GNSS-SDR. -% * -% * GNSS-SDR is free software: you can redistribute it and/or modify -% * it under the terms of the GNU General Public License as published by -% * the Free Software Foundation, either version 3 of the License, or -% * at your option) any later version. -% * -% * GNSS-SDR is distributed in the hope that it will be useful, -% * but WITHOUT ANY WARRANTY; without even the implied warranty of -% * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% * GNU General Public License for more details. -% * -% * You should have received a copy of the GNU General Public License -% * along with GNSS-SDR. If not, see . -% * -% * ------------------------------------------------------------------------- -% */ +% Usage: gps_l1_ca_dll_pll_read_tracking_dump_64bits (filename, [count]) +% +% Opens GNSS-SDR tracking binary log file .dat and returns the contents + +% Read GNSS-SDR Tracking dump binary file into MATLAB. +% Javier Arribas, 2011. jarribas(at)cttc.es +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- +% + function [GNSS_tracking] = gps_l1_ca_dll_pll_read_tracking_dump (filename, count) - %% usage: gps_l1_ca_dll_pll_read_tracking_dump_64bits (filename, [count]) - %% - %% open GNSS-SDR tracking binary log file .dat and return the contents - %% +m = nargchk (1,2,nargin); +num_float_vars=5; +num_unsigned_long_int_vars=1; +num_double_vars=11; +num_unsigned_int_vars=1; +double_size_bytes=8; +unsigned_long_int_size_bytes=8; +float_size_bytes=4; +long_int_size_bytes=4; - m = nargchk (1,2,nargin); - num_float_vars=5; - num_unsigned_long_int_vars=1; - num_double_vars=11; - num_unsigned_int_vars=1; - double_size_bytes=8; - unsigned_long_int_size_bytes=8; - float_size_bytes=4; - long_int_size_bytes=4; - - skip_bytes_each_read=float_size_bytes*num_float_vars+unsigned_long_int_size_bytes*num_unsigned_long_int_vars+double_size_bytes*num_double_vars+long_int_size_bytes*num_unsigned_int_vars; - bytes_shift=0; - if (m) +skip_bytes_each_read=float_size_bytes*num_float_vars+unsigned_long_int_size_bytes*num_unsigned_long_int_vars+double_size_bytes*num_double_vars+long_int_size_bytes*num_unsigned_int_vars; +bytes_shift=0; +if (m) usage (m); - end +end - if (nargin < 2) +if (nargin < 2) %count = Inf; file_stats = dir(filename); %round num bytes to read to integer number of samples (to protect the script from binary %dump end file transitory) count = (file_stats.bytes - mod(file_stats.bytes,skip_bytes_each_read))/skip_bytes_each_read; - end - %loops_counter = fread (f, count, 'uint32',4*12); - f = fopen (filename, 'rb'); - if (f < 0) - else +end +%loops_counter = fread (f, count, 'uint32',4*12); +f = fopen (filename, 'rb'); +if (f < 0) +else v1 = fread (f, count, 'float',skip_bytes_each_read-float_size_bytes); - bytes_shift=bytes_shift+float_size_bytes; + bytes_shift=bytes_shift+float_size_bytes; fseek(f,bytes_shift,'bof'); % move to next interleaved float v2 = fread (f, count, 'float',skip_bytes_each_read-float_size_bytes); - bytes_shift=bytes_shift+float_size_bytes; + bytes_shift=bytes_shift+float_size_bytes; fseek(f,bytes_shift,'bof'); % move to next interleaved float v3 = fread (f, count, 'float',skip_bytes_each_read-float_size_bytes); - bytes_shift=bytes_shift+float_size_bytes; + bytes_shift=bytes_shift+float_size_bytes; fseek(f,bytes_shift,'bof'); % move to next interleaved float v4 = fread (f, count, 'float',skip_bytes_each_read-float_size_bytes); - bytes_shift=bytes_shift+float_size_bytes; + bytes_shift=bytes_shift+float_size_bytes; fseek(f,bytes_shift,'bof'); % move to next interleaved float v5 = fread (f, count, 'float',skip_bytes_each_read-float_size_bytes); - bytes_shift=bytes_shift+float_size_bytes; + bytes_shift=bytes_shift+float_size_bytes; fseek(f,bytes_shift,'bof'); % move to next interleaved unsigned_long_int v6 = fread (f, count, 'uint64',skip_bytes_each_read-unsigned_long_int_size_bytes); - bytes_shift=bytes_shift+unsigned_long_int_size_bytes; + bytes_shift=bytes_shift+unsigned_long_int_size_bytes; fseek(f,bytes_shift,'bof'); % move to next interleaved double v7 = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; + bytes_shift=bytes_shift+double_size_bytes; fseek(f,bytes_shift,'bof'); % move to next interleaved double v8 = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; + bytes_shift=bytes_shift+double_size_bytes; fseek(f,bytes_shift,'bof'); % move to next interleaved double v9 = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; + bytes_shift=bytes_shift+double_size_bytes; fseek(f,bytes_shift,'bof'); % move to next interleaved double v10 = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; + bytes_shift=bytes_shift+double_size_bytes; fseek(f,bytes_shift,'bof'); % move to next interleaved double v11 = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; + bytes_shift=bytes_shift+double_size_bytes; fseek(f,bytes_shift,'bof'); % move to next interleaved double v12 = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; + bytes_shift=bytes_shift+double_size_bytes; fseek(f,bytes_shift,'bof'); % move to next interleaved double v13 = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; + bytes_shift=bytes_shift+double_size_bytes; fseek(f,bytes_shift,'bof'); % move to next interleaved double v14 = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; + bytes_shift=bytes_shift+double_size_bytes; fseek(f,bytes_shift,'bof'); % move to next interleaved double v15 = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; + bytes_shift=bytes_shift+double_size_bytes; fseek(f,bytes_shift,'bof'); % move to next interleaved double v16 = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; + bytes_shift=bytes_shift+double_size_bytes; fseek(f,bytes_shift,'bof'); % move to next interleaved double v17 = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; + bytes_shift=bytes_shift+double_size_bytes; fseek(f,bytes_shift,'bof'); % move to next interleaved double v18 = fread (f, count, 'uint32',skip_bytes_each_read-double_size_bytes); fclose (f); %%%%%%%% output vars %%%%%%%% -% // EPR -% d_dump_file.write(reinterpret_cast(&tmp_E), sizeof(float)); -% d_dump_file.write(reinterpret_cast(&tmp_P), sizeof(float)); -% d_dump_file.write(reinterpret_cast(&tmp_L), sizeof(float)); -% // PROMPT I and Q (to analyze navigation symbols) -% d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); -% d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); -% // PRN start sample stamp -% //tmp_float=(float)d_sample_counter; -% d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); -% // accumulated carrier phase -% d_dump_file.write(reinterpret_cast(&d_acc_carrier_phase_rad), sizeof(double)); -% -% // carrier and code frequency -% d_dump_file.write(reinterpret_cast(&d_carrier_doppler_hz), sizeof(double)); -% d_dump_file.write(reinterpret_cast(&d_code_freq_chips), sizeof(double)); -% -% //PLL commands -% d_dump_file.write(reinterpret_cast(&carr_phase_error_secs_Ti), sizeof(double)); -% d_dump_file.write(reinterpret_cast(&d_carrier_doppler_hz), sizeof(double)); -% -% //DLL commands -% d_dump_file.write(reinterpret_cast(&code_error_chips_Ti), sizeof(double)); -% d_dump_file.write(reinterpret_cast(&code_error_filt_chips), sizeof(double)); -% -% // CN0 and carrier lock test -% d_dump_file.write(reinterpret_cast(&d_CN0_SNV_dB_Hz), sizeof(double)); -% d_dump_file.write(reinterpret_cast(&d_carrier_lock_test), sizeof(double)); -% -% // AUX vars (for debug purposes) -% tmp_double = d_rem_code_phase_samples; -% d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); -% tmp_double = static_cast(d_sample_counter + d_current_prn_length_samples); -% d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); -% // PRN -% unsigned int prn_ = d_acquisition_gnss_synchro->PRN; -% d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); + % // EPR + % d_dump_file.write(reinterpret_cast(&tmp_E), sizeof(float)); + % d_dump_file.write(reinterpret_cast(&tmp_P), sizeof(float)); + % d_dump_file.write(reinterpret_cast(&tmp_L), sizeof(float)); + % // PROMPT I and Q (to analyze navigation symbols) + % d_dump_file.write(reinterpret_cast(&prompt_I), sizeof(float)); + % d_dump_file.write(reinterpret_cast(&prompt_Q), sizeof(float)); + % // PRN start sample stamp + % //tmp_float=(float)d_sample_counter; + % d_dump_file.write(reinterpret_cast(&d_sample_counter), sizeof(unsigned long int)); + % // accumulated carrier phase + % d_dump_file.write(reinterpret_cast(&d_acc_carrier_phase_rad), sizeof(double)); + % + % // carrier and code frequency + % d_dump_file.write(reinterpret_cast(&d_carrier_doppler_hz), sizeof(double)); + % d_dump_file.write(reinterpret_cast(&d_code_freq_chips), sizeof(double)); + % + % //PLL commands + % d_dump_file.write(reinterpret_cast(&carr_phase_error_secs_Ti), sizeof(double)); + % d_dump_file.write(reinterpret_cast(&d_carrier_doppler_hz), sizeof(double)); + % + % //DLL commands + % d_dump_file.write(reinterpret_cast(&code_error_chips_Ti), sizeof(double)); + % d_dump_file.write(reinterpret_cast(&code_error_filt_chips), sizeof(double)); + % + % // CN0 and carrier lock test + % d_dump_file.write(reinterpret_cast(&d_CN0_SNV_dB_Hz), sizeof(double)); + % d_dump_file.write(reinterpret_cast(&d_carrier_lock_test), sizeof(double)); + % + % // AUX vars (for debug purposes) + % tmp_double = d_rem_code_phase_samples; + % d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + % tmp_double = static_cast(d_sample_counter + d_current_prn_length_samples); + % d_dump_file.write(reinterpret_cast(&tmp_double), sizeof(double)); + % // PRN + % unsigned int prn_ = d_acquisition_gnss_synchro->PRN; + % d_dump_file.write(reinterpret_cast(&prn_), sizeof(unsigned int)); E=v1; P=v2; L=v3; @@ -190,5 +188,5 @@ function [GNSS_tracking] = gps_l1_ca_dll_pll_read_tracking_dump (filename, count GNSS_tracking.d_rem_code_phase_samples=var1; GNSS_tracking.var2=var2; GNSS_tracking.PRN=PRN; - end - +end + diff --git a/src/utils/matlab/libs/gps_l1_ca_pvt_read_pvt_dump.m b/src/utils/matlab/libs/gps_l1_ca_pvt_read_pvt_dump.m index d52958a53..ce538a755 100644 --- a/src/utils/matlab/libs/gps_l1_ca_pvt_read_pvt_dump.m +++ b/src/utils/matlab/libs/gps_l1_ca_pvt_read_pvt_dump.m @@ -1,39 +1,40 @@ -% /*! -% * \file gps_l1_ca_pvt_read_pvt_dump.m -% * \brief Read GNSS-SDR PVT lib dump binary file into MATLAB. The resulting +% +% \file gps_l1_ca_pvt_read_pvt_dump.m +% \brief Read GNSS-SDR PVT lib dump binary file into MATLAB. The resulting % structure is compatible with the K.Borre MATLAB-based receiver. -% * \author Javier Arribas, 2011. jarribas(at)cttc.es -% * ------------------------------------------------------------------------- -% * -% * Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors) -% * -% * GNSS-SDR is a software defined Global Navigation -% * Satellite Systems receiver -% * -% * This file is part of GNSS-SDR. -% * -% * GNSS-SDR is free software: you can redistribute it and/or modify -% * it under the terms of the GNU General Public License as published by -% * the Free Software Foundation, either version 3 of the License, or -% * at your option) any later version. -% * -% * GNSS-SDR is distributed in the hope that it will be useful, -% * but WITHOUT ANY WARRANTY; without even the implied warranty of -% * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% * GNU General Public License for more details. -% * -% * You should have received a copy of the GNU General Public License -% * along with GNSS-SDR. If not, see . -% * -% * ------------------------------------------------------------------------- -% */ +% \author Javier Arribas, 2011. jarribas(at)cttc.es +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- +% + function [navSolutions] = gps_l1_ca_pvt_read_pvt_dump (filename, count) - %% usage: gps_l1_ca_pvt_read_pvt_dump (filename, [count]) - %% - %% open GNSS-SDR PVT binary log file .dat and return the contents - %% -% +%% usage: gps_l1_ca_pvt_read_pvt_dump (filename, [count]) +%% +%% open GNSS-SDR PVT binary log file .dat and return the contents +%% +% % // PVT GPS time % tmp_double=GPS_current_time; % d_dump_file.write((char*)&tmp_double, sizeof(double)); @@ -58,57 +59,56 @@ function [navSolutions] = gps_l1_ca_pvt_read_pvt_dump (filename, count) % // GEO user position Height [m] % tmp_double=d_height_m; % d_dump_file.write((char*)&tmp_double, sizeof(double)); - - m = nargchk (1,2,nargin); - num_double_vars=8; - double_size_bytes=8; - skip_bytes_each_read=double_size_bytes*num_double_vars; - bytes_shift=0; - if (m) - usage (m); - end - if (nargin < 3) +m = nargchk (1,2,nargin); +num_double_vars=8; +double_size_bytes=8; +skip_bytes_each_read=double_size_bytes*num_double_vars; +bytes_shift=0; +if (m) + usage (m); +end + +if (nargin < 3) count = Inf; - end - %loops_counter = fread (f, count, 'uint32',4*12); - f = fopen (filename, 'rb'); - if (f < 0) - else - GPS_current_time = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved - ECEF_X = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved - ECEF_Y = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved - ECEF_Z = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved - Clock_Offset = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved - Lat = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved - Long = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved - Height = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved - fclose (f); - end - - navSolutions.X=ECEF_X.'; - navSolutions.Y=ECEF_Y.'; - navSolutions.Z=ECEF_Z.'; - navSolutions.dt=Clock_Offset.'; - navSolutions.latitude=Lat.'; - navSolutions.longitude=Long.'; - navSolutions.height=Height.'; - navSolutions.TransmitTime=GPS_current_time.'; - - \ No newline at end of file +end +%loops_counter = fread (f, count, 'uint32',4*12); +f = fopen (filename, 'rb'); +if (f < 0) +else + GPS_current_time = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); + bytes_shift=bytes_shift+double_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next interleaved + ECEF_X = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); + bytes_shift=bytes_shift+double_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next interleaved + ECEF_Y = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); + bytes_shift=bytes_shift+double_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next interleaved + ECEF_Z = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); + bytes_shift=bytes_shift+double_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next interleaved + Clock_Offset = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); + bytes_shift=bytes_shift+double_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next interleaved + Lat = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); + bytes_shift=bytes_shift+double_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next interleaved + Long = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); + bytes_shift=bytes_shift+double_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next interleaved + Height = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); + bytes_shift=bytes_shift+double_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next interleaved + fclose (f); +end + +navSolutions.X=ECEF_X.'; +navSolutions.Y=ECEF_Y.'; +navSolutions.Z=ECEF_Z.'; +navSolutions.dt=Clock_Offset.'; +navSolutions.latitude=Lat.'; +navSolutions.longitude=Long.'; +navSolutions.height=Height.'; +navSolutions.TransmitTime=GPS_current_time.'; + diff --git a/src/utils/matlab/libs/gps_l1_ca_read_pvt_raw_dump.m b/src/utils/matlab/libs/gps_l1_ca_read_pvt_raw_dump.m index b363bc1a5..b818b326b 100644 --- a/src/utils/matlab/libs/gps_l1_ca_read_pvt_raw_dump.m +++ b/src/utils/matlab/libs/gps_l1_ca_read_pvt_raw_dump.m @@ -1,27 +1,52 @@ -% Javier Arribas 2011 +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- +% +% Javier Arribas 2011 + function [pvt_raw] = gps_l1_ca_read_pvt_raw_dump (channels, filename, count) - %% usage: read_tracking_dat (filename, [count]) - %% - %% open GNSS-SDR pvt binary log file .dat and return the contents - %% +%% usage: read_tracking_dat (filename, [count]) +%% +%% open GNSS-SDR pvt binary log file .dat and return the contents +%% - m = nargchk (1,2,nargin); - num_double_vars=3; - double_size_bytes=8; - skip_bytes_each_read=double_size_bytes*num_double_vars*channels; - bytes_shift=0; - if (m) +m = nargchk (1,2,nargin); +num_double_vars=3; +double_size_bytes=8; +skip_bytes_each_read=double_size_bytes*num_double_vars*channels; +bytes_shift=0; +if (m) usage (m); - end +end - if (nargin < 3) +if (nargin < 3) count = Inf; - end - %loops_counter = fread (f, count, 'uint32',4*12); - f = fopen (filename, 'rb'); - if (f < 0) - else +end +%loops_counter = fread (f, count, 'uint32',4*12); +f = fopen (filename, 'rb'); +if (f < 0) +else for N=1:1:channels pvt_raw.Pseudorange_m(N,:) = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); bytes_shift=bytes_shift+double_size_bytes; @@ -33,17 +58,17 @@ function [pvt_raw] = gps_l1_ca_read_pvt_raw_dump (channels, filename, count) bytes_shift=bytes_shift+double_size_bytes; fseek(f,bytes_shift,'bof'); % move to next interleaved end - + fclose (f); %%%%%%%% output vars %%%%%%%% -% for (unsigned int i=0; i. +% +% ------------------------------------------------------------------------- +% +% Javier Arribas 2011 + function [telemetry] = gps_l1_ca_read_telemetry_dump (filename, count) - %% usage: read_tracking_dat (filename, [count]) - %% - %% open GNSS-SDR tracking binary log file .dat and return the contents - %% +%% usage: read_tracking_dat (filename, [count]) +%% +%% open GNSS-SDR tracking binary log file .dat and return the contents +%% - m = nargchk (1,2,nargin); - num_double_vars=3; - double_size_bytes=8; - skip_bytes_each_read=double_size_bytes*num_double_vars; - bytes_shift=0; - if (m) +m = nargchk (1,2,nargin); +num_double_vars=3; +double_size_bytes=8; +skip_bytes_each_read=double_size_bytes*num_double_vars; +bytes_shift=0; +if (m) usage (m); - end +end - if (nargin < 3) +if (nargin < 3) count = Inf; - end - %loops_counter = fread (f, count, 'uint32',4*12); - f = fopen (filename, 'rb'); - if (f < 0) - else - telemetry.preamble_delay_ms = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved - telemetry.prn_delay_ms = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved - telemetry.Preamble_symbol_counter = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); - bytes_shift=bytes_shift+double_size_bytes; - fseek(f,bytes_shift,'bof'); % move to next interleaved - +end +%loops_counter = fread (f, count, 'uint32',4*12); +f = fopen (filename, 'rb'); +if (f < 0) +else + telemetry.preamble_delay_ms = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); + bytes_shift=bytes_shift+double_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next interleaved + telemetry.prn_delay_ms = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); + bytes_shift=bytes_shift+double_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next interleaved + telemetry.Preamble_symbol_counter = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); + bytes_shift=bytes_shift+double_size_bytes; + fseek(f,bytes_shift,'bof'); % move to next interleaved + fclose (f); %%%%%%%% output vars %%%%%%%% -% { -% double tmp_double; -% tmp_double = current_synchro_data.Preamble_delay_ms; -% d_dump_file.write((char*)&tmp_double, sizeof(double)); -% tmp_double = current_synchro_data.Prn_delay_ms; -% d_dump_file.write((char*)&tmp_double, sizeof(double)); -% tmp_double = current_synchro_data.Preamble_symbol_counter; -% d_dump_file.write((char*)&tmp_double, sizeof(double)); -% } - end - + % { + % double tmp_double; + % tmp_double = current_synchro_data.Preamble_delay_ms; + % d_dump_file.write((char*)&tmp_double, sizeof(double)); + % tmp_double = current_synchro_data.Prn_delay_ms; + % d_dump_file.write((char*)&tmp_double, sizeof(double)); + % tmp_double = current_synchro_data.Preamble_symbol_counter; + % d_dump_file.write((char*)&tmp_double, sizeof(double)); + % } +end + diff --git a/src/utils/matlab/libs/plotNavigation.m b/src/utils/matlab/libs/plotNavigation.m index 057a1926d..9e27fc4d2 100644 --- a/src/utils/matlab/libs/plotNavigation.m +++ b/src/utils/matlab/libs/plotNavigation.m @@ -1,170 +1,166 @@ -% /*! -% * \file plotNavigation.m -% * \brief -% Functions plots variations of coordinates over time and a 3D position -% plot. It plots receiver coordinates in UTM system or coordinate offsets if -% the true UTM receiver coordinates are provided. -% * \author Darius Plausinaitis -% * Modified by Javier Arribas, 2011. jarribas(at)cttc.es -% * ------------------------------------------------------------------------- -% * -% * Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors) -% * -% * GNSS-SDR is a software defined Global Navigation -% * Satellite Systems receiver -% * -% * This file is part of GNSS-SDR. -% * -% * GNSS-SDR is free software: you can redistribute it and/or modify -% * it under the terms of the GNU General Public License as published by -% * the Free Software Foundation, either version 3 of the License, or -% * at your option) any later version. -% * -% * GNSS-SDR is distributed in the hope that it will be useful, -% * but WITHOUT ANY WARRANTY; without even the implied warranty of -% * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% * GNU General Public License for more details. -% * -% * You should have received a copy of the GNU General Public License -% * along with GNSS-SDR. If not, see . -% * -% * ------------------------------------------------------------------------- -% */ - -function plotNavigation(navSolutions, settings,plot_skyplot) -%Functions plots variations of coordinates over time and a 3D position -%plot. It plots receiver coordinates in UTM system or coordinate offsets if -%the true UTM receiver coordinates are provided. -% -%plotNavigation(navSolutions, settings) -% -% Inputs: -% navSolutions - Results from navigation solution function. It -% contains measured pseudoranges and receiver -% coordinates. -% settings - Receiver settings. The true receiver coordinates -% are contained in this structure. -% plot_skyplot - If ==1 then use satellite coordinates to plot the -% the satellite positions - -%% Plot results in the necessary data exists ============================== -if (~isempty(navSolutions)) - - %% If reference position is not provided, then set reference position - %% to the average postion - if isnan(settings.truePosition.E) || isnan(settings.truePosition.N) ... - || isnan(settings.truePosition.U) - - %=== Compute mean values ========================================== - % Remove NaN-s or the output of the function MEAN will be NaN. - refCoord.E = mean(navSolutions.E(~isnan(navSolutions.E))); - refCoord.N = mean(navSolutions.N(~isnan(navSolutions.N))); - refCoord.U = mean(navSolutions.U(~isnan(navSolutions.U))); - - %Also convert geodetic coordinates to deg:min:sec vector format - meanLongitude = dms2mat(deg2dms(... - mean(navSolutions.longitude(~isnan(navSolutions.longitude)))), -5); - meanLatitude = dms2mat(deg2dms(... - mean(navSolutions.latitude(~isnan(navSolutions.latitude)))), -5); - - LatLong_str=[num2str(meanLatitude(1)), 'º', ... - num2str(meanLatitude(2)), '''', ... - num2str(meanLatitude(3)), '''''', ... - ',', ... - num2str(meanLongitude(1)), 'º', ... - num2str(meanLongitude(2)), '''', ... - num2str(meanLongitude(3)), ''''''] - - - - refPointLgText = ['Mean Position\newline Lat: ', ... - num2str(meanLatitude(1)), '{\circ}', ... - num2str(meanLatitude(2)), '{\prime}', ... - num2str(meanLatitude(3)), '{\prime}{\prime}', ... - '\newline Lng: ', ... - num2str(meanLongitude(1)), '{\circ}', ... - num2str(meanLongitude(2)), '{\prime}', ... - num2str(meanLongitude(3)), '{\prime}{\prime}', ... - '\newline Hgt: ', ... - num2str(mean(navSolutions.height(~isnan(navSolutions.height))), '%+6.1f')]; - - else - % compute the mean error for static receiver - mean_position.E = mean(navSolutions.E(~isnan(navSolutions.E))); - mean_position.N = mean(navSolutions.N(~isnan(navSolutions.N))); - mean_position.U = mean(navSolutions.U(~isnan(navSolutions.U))); - refCoord.E = settings.truePosition.E; - refCoord.N = settings.truePosition.N; - refCoord.U = settings.truePosition.U; - - error_meters=sqrt((mean_position.E-refCoord.E)^2+(mean_position.N-refCoord.N)^2+(mean_position.U-refCoord.U)^2); - - refPointLgText = ['Reference Position, Mean 3D error = ' num2str(error_meters) ' [m]']; - end - - figureNumber = 300; - % The 300 is chosen for more convenient handling of the open - % figure windows, when many figures are closed and reopened. Figures - % drawn or opened by the user, will not be "overwritten" by this - % function if the auto numbering is not used. - - %=== Select (or create) and clear the figure ========================== - figure(figureNumber); - clf (figureNumber); - set (figureNumber, 'Name', 'Navigation solutions'); - - %--- Draw axes -------------------------------------------------------- - handles(1, 1) = subplot(4, 2, 1 : 4); - handles(3, 1) = subplot(4, 2, [5, 7]); - handles(3, 2) = subplot(4, 2, [6, 8]); - -%% Plot all figures ======================================================= - - %--- Coordinate differences in UTM system ----------------------------- - plot(handles(1, 1), [(navSolutions.E - refCoord.E)', ... - (navSolutions.N - refCoord.N)',... - (navSolutions.U - refCoord.U)']); - - title (handles(1, 1), 'Coordinates variations in UTM system'); - legend(handles(1, 1), 'E', 'N', 'U'); - xlabel(handles(1, 1), ['Measurement period: ', ... - num2str(settings.navSolPeriod), 'ms']); - ylabel(handles(1, 1), 'Variations (m)'); - grid (handles(1, 1)); - axis (handles(1, 1), 'tight'); - - %--- Position plot in UTM system -------------------------------------- - plot3 (handles(3, 1), navSolutions.E - refCoord.E, ... - navSolutions.N - refCoord.N, ... - navSolutions.U - refCoord.U, '+'); - hold (handles(3, 1), 'on'); - - %Plot the reference point - plot3 (handles(3, 1), 0, 0, 0, 'r+', 'LineWidth', 1.5, 'MarkerSize', 10); - hold (handles(3, 1), 'off'); - - view (handles(3, 1), 0, 90); - axis (handles(3, 1), 'equal'); - grid (handles(3, 1), 'minor'); - - legend(handles(3, 1), 'Measurements', refPointLgText); - - title (handles(3, 1), 'Positions in UTM system (3D plot)'); - xlabel(handles(3, 1), 'East (m)'); - ylabel(handles(3, 1), 'North (m)'); - zlabel(handles(3, 1), 'Upping (m)'); - - if (plot_skyplot==1) - %--- Satellite sky plot ----------------------------------------------- - skyPlot(handles(3, 2), ... - navSolutions.channel.az, ... - navSolutions.channel.el, ... - navSolutions.channel.PRN(:, 1)); - - title (handles(3, 2), ['Sky plot (mean PDOP: ', ... - num2str(mean(navSolutions.DOP(2,:))), ')']); - end - -else - disp('plotNavigation: No navigation data to plot.'); -end % if (~isempty(navSolutions)) +% Function plots variations of coordinates over time and a 3D position +% plot. It plots receiver coordinates in UTM system or coordinate offsets if +% the true UTM receiver coordinates are provided. +% +% plotNavigation(navSolutions, settings) +% +% Inputs: +% navSolutions - Results from navigation solution function. It +% contains measured pseudoranges and receiver +% coordinates. +% settings - Receiver settings. The true receiver coordinates +% are contained in this structure. +% plot_skyplot - If ==1 then use satellite coordinates to plot the +% the satellite positions + +% Darius Plausinaitis +% Modified by Javier Arribas, 2011. jarribas(at)cttc.es +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- +% + +function plotNavigation(navSolutions, settings,plot_skyplot) + + +%% Plot results in the necessary data exists ============================== +if (~isempty(navSolutions)) + + %% If reference position is not provided, then set reference position + %% to the average postion + if isnan(settings.truePosition.E) || isnan(settings.truePosition.N) ... + || isnan(settings.truePosition.U) + + %=== Compute mean values ========================================== + % Remove NaN-s or the output of the function MEAN will be NaN. + refCoord.E = mean(navSolutions.E(~isnan(navSolutions.E))); + refCoord.N = mean(navSolutions.N(~isnan(navSolutions.N))); + refCoord.U = mean(navSolutions.U(~isnan(navSolutions.U))); + + %Also convert geodetic coordinates to deg:min:sec vector format + meanLongitude = dms2mat(deg2dms(... + mean(navSolutions.longitude(~isnan(navSolutions.longitude)))), -5); + meanLatitude = dms2mat(deg2dms(... + mean(navSolutions.latitude(~isnan(navSolutions.latitude)))), -5); + + LatLong_str=[num2str(meanLatitude(1)), '??', ... + num2str(meanLatitude(2)), '''', ... + num2str(meanLatitude(3)), '''''', ... + ',', ... + num2str(meanLongitude(1)), '??', ... + num2str(meanLongitude(2)), '''', ... + num2str(meanLongitude(3)), ''''''] + + + + refPointLgText = ['Mean Position\newline Lat: ', ... + num2str(meanLatitude(1)), '{\circ}', ... + num2str(meanLatitude(2)), '{\prime}', ... + num2str(meanLatitude(3)), '{\prime}{\prime}', ... + '\newline Lng: ', ... + num2str(meanLongitude(1)), '{\circ}', ... + num2str(meanLongitude(2)), '{\prime}', ... + num2str(meanLongitude(3)), '{\prime}{\prime}', ... + '\newline Hgt: ', ... + num2str(mean(navSolutions.height(~isnan(navSolutions.height))), '%+6.1f')]; + + else + % compute the mean error for static receiver + mean_position.E = mean(navSolutions.E(~isnan(navSolutions.E))); + mean_position.N = mean(navSolutions.N(~isnan(navSolutions.N))); + mean_position.U = mean(navSolutions.U(~isnan(navSolutions.U))); + refCoord.E = settings.truePosition.E; + refCoord.N = settings.truePosition.N; + refCoord.U = settings.truePosition.U; + + error_meters=sqrt((mean_position.E-refCoord.E)^2+(mean_position.N-refCoord.N)^2+(mean_position.U-refCoord.U)^2); + + refPointLgText = ['Reference Position, Mean 3D error = ' num2str(error_meters) ' [m]']; + end + + figureNumber = 300; + % The 300 is chosen for more convenient handling of the open + % figure windows, when many figures are closed and reopened. Figures + % drawn or opened by the user, will not be "overwritten" by this + % function if the auto numbering is not used. + + %=== Select (or create) and clear the figure ========================== + figure(figureNumber); + clf (figureNumber); + set (figureNumber, 'Name', 'Navigation solutions'); + + %--- Draw axes -------------------------------------------------------- + handles(1, 1) = subplot(4, 2, 1 : 4); + handles(3, 1) = subplot(4, 2, [5, 7]); + handles(3, 2) = subplot(4, 2, [6, 8]); + + %% Plot all figures ======================================================= + + %--- Coordinate differences in UTM system ----------------------------- + plot(handles(1, 1), [(navSolutions.E - refCoord.E)', ... + (navSolutions.N - refCoord.N)',... + (navSolutions.U - refCoord.U)']); + + title (handles(1, 1), 'Coordinates variations in UTM system'); + legend(handles(1, 1), 'E', 'N', 'U'); + xlabel(handles(1, 1), ['Measurement period: ', ... + num2str(settings.navSolPeriod), 'ms']); + ylabel(handles(1, 1), 'Variations (m)'); + grid (handles(1, 1)); + axis (handles(1, 1), 'tight'); + + %--- Position plot in UTM system -------------------------------------- + plot3 (handles(3, 1), navSolutions.E - refCoord.E, ... + navSolutions.N - refCoord.N, ... + navSolutions.U - refCoord.U, '+'); + hold (handles(3, 1), 'on'); + + %Plot the reference point + plot3 (handles(3, 1), 0, 0, 0, 'r+', 'LineWidth', 1.5, 'MarkerSize', 10); + hold (handles(3, 1), 'off'); + + view (handles(3, 1), 0, 90); + axis (handles(3, 1), 'equal'); + grid (handles(3, 1), 'minor'); + + legend(handles(3, 1), 'Measurements', refPointLgText); + + title (handles(3, 1), 'Positions in UTM system (3D plot)'); + xlabel(handles(3, 1), 'East (m)'); + ylabel(handles(3, 1), 'North (m)'); + zlabel(handles(3, 1), 'Upping (m)'); + + if (plot_skyplot==1) + %--- Satellite sky plot ----------------------------------------------- + skyPlot(handles(3, 2), ... + navSolutions.channel.az, ... + navSolutions.channel.el, ... + navSolutions.channel.PRN(:, 1)); + + title (handles(3, 2), ['Sky plot (mean PDOP: ', ... + num2str(mean(navSolutions.DOP(2,:))), ')']); + end + +else + disp('plotNavigation: No navigation data to plot.'); +end % if (~isempty(navSolutions)) diff --git a/src/utils/matlab/libs/plotTracking.m b/src/utils/matlab/libs/plotTracking.m index 9abe9c729..b280d82aa 100644 --- a/src/utils/matlab/libs/plotTracking.m +++ b/src/utils/matlab/libs/plotTracking.m @@ -1,189 +1,187 @@ -function plotTracking(channelList, trackResults, settings) -%This function plots the tracking results for the given channel list. -% -%plotTracking(channelList, trackResults, settings) -% -% Inputs: -% channelList - list of channels to be plotted. -% trackResults - tracking results from the tracking function. -% settings - receiver settings. - -%-------------------------------------------------------------------------- -% SoftGNSS v3.0 -% -% Copyright (C) Darius Plausinaitis -% Written by Darius Plausinaitis -%-------------------------------------------------------------------------- -%This program is free software; you can redistribute it and/or -%modify it under the terms of the GNU General Public License -%as published by the Free Software Foundation; either version 2 -%of the License, or (at your option) any later version. -% -%This program is distributed in the hope that it will be useful, -%but WITHOUT ANY WARRANTY; without even the implied warranty of -%MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -%GNU General Public License for more details. -% -%You should have received a copy of the GNU General Public License -%along with this program; if not, write to the Free Software -%Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -%USA. -%-------------------------------------------------------------------------- - -%CVS record: -%$Id: plotTracking.m,v 1.5.2.23 2006/08/14 14:45:14 dpl Exp $ - -% Protection - if the list contains incorrect channel numbers -channelList = intersect(channelList, 1:settings.numberOfChannels); - -%=== For all listed channels ============================================== -for channelNr = channelList - -%% Select (or create) and clear the figure ================================ - % The number 200 is added just for more convenient handling of the open - % figure windows, when many figures are closed and reopened. - % Figures drawn or opened by the user, will not be "overwritten" by - % this function. - - figure(channelNr +200); - clf(channelNr +200); - set(channelNr +200, 'Name', ['Channel ', num2str(channelNr), ... - ' (PRN ', ... - num2str(trackResults(channelNr).PRN(end-1)), ... - ') results']); - -%% Draw axes ============================================================== - % Row 1 - handles(1, 1) = subplot(4, 3, 1); - handles(1, 2) = subplot(4, 3, [2 3]); - % Row 2 - handles(2, 1) = subplot(4, 3, 4); - handles(2, 2) = subplot(4, 3, [5 6]); - % Row 3 - handles(3, 1) = subplot(4, 3, 7); - handles(3, 2) = subplot(4, 3, 8); - handles(3, 3) = subplot(4, 3, 9); - % Row 4 - handles(4, 1) = subplot(4, 3, 10); - handles(4, 2) = subplot(4, 3, 11); - handles(4, 3) = subplot(4, 3, 12); - - -%% Plot all figures ======================================================= - - timeAxisInSeconds = (1:settings.msToProcess)/1000; - - %----- Discrete-Time Scatter Plot --------------------------------- - plot(handles(1, 1), trackResults(channelNr).I_P,... - trackResults(channelNr).Q_P, ... - '.'); - - grid (handles(1, 1)); - axis (handles(1, 1), 'equal'); - title (handles(1, 1), 'Discrete-Time Scatter Plot'); - xlabel(handles(1, 1), 'I prompt'); - ylabel(handles(1, 1), 'Q prompt'); - - %----- Nav bits --------------------------------------------------- - plot (handles(1, 2), timeAxisInSeconds, ... - trackResults(channelNr).I_P); - - grid (handles(1, 2)); - title (handles(1, 2), 'Bits of the navigation message'); - xlabel(handles(1, 2), 'Time (s)'); - axis (handles(1, 2), 'tight'); - - %----- PLL discriminator unfiltered-------------------------------- - plot (handles(2, 1), timeAxisInSeconds, ... - trackResults(channelNr).pllDiscr, 'r'); - - grid (handles(2, 1)); - axis (handles(2, 1), 'tight'); - xlabel(handles(2, 1), 'Time (s)'); - ylabel(handles(2, 1), 'Amplitude'); - title (handles(2, 1), 'Raw PLL discriminator'); - - %----- Correlation ------------------------------------------------ - plot(handles(2, 2), timeAxisInSeconds, ... - [sqrt(trackResults(channelNr).I_E.^2 + ... - trackResults(channelNr).Q_E.^2)', ... - sqrt(trackResults(channelNr).I_P.^2 + ... - trackResults(channelNr).Q_P.^2)', ... - sqrt(trackResults(channelNr).I_L.^2 + ... - trackResults(channelNr).Q_L.^2)'], ... - '-*'); - - grid (handles(2, 2)); - title (handles(2, 2), 'Correlation results'); - xlabel(handles(2, 2), 'Time (s)'); - axis (handles(2, 2), 'tight'); - - hLegend = legend(handles(2, 2), '$\sqrt{I_{E}^2 + Q_{E}^2}$', ... - '$\sqrt{I_{P}^2 + Q_{P}^2}$', ... - '$\sqrt{I_{L}^2 + Q_{L}^2}$'); - - %set interpreter from tex to latex. This will draw \sqrt correctly - set(hLegend, 'Interpreter', 'Latex'); - - %----- PLL discriminator filtered---------------------------------- - plot (handles(3, 1), timeAxisInSeconds, ... - trackResults(channelNr).pllDiscrFilt(1:settings.msToProcess), 'b'); - - grid (handles(3, 1)); - axis (handles(3, 1), 'tight'); - xlabel(handles(3, 1), 'Time (s)'); - ylabel(handles(3, 1), 'Amplitude'); - title (handles(3, 1), 'Filtered PLL discriminator'); - - %----- DLL discriminator unfiltered-------------------------------- - plot (handles(3, 2), timeAxisInSeconds, ... - trackResults(channelNr).dllDiscr, 'r'); - - grid (handles(3, 2)); - axis (handles(3, 2), 'tight'); - xlabel(handles(3, 2), 'Time (s)'); - ylabel(handles(3, 2), 'Amplitude'); - title (handles(3, 2), 'Raw DLL discriminator'); - - %----- DLL discriminator filtered---------------------------------- - plot (handles(3, 3), timeAxisInSeconds, ... - trackResults(channelNr).dllDiscrFilt, 'b'); - - grid (handles(3, 3)); - axis (handles(3, 3), 'tight'); - xlabel(handles(3, 3), 'Time (s)'); - ylabel(handles(3, 3), 'Amplitude'); - title (handles(3, 3), 'Filtered DLL discriminator'); - - %----- CNo for signal---------------------------------- - plot (handles(4, 1), timeAxisInSeconds, ... - trackResults(channelNr).CNo(1:settings.msToProcess), 'b'); - - grid (handles(4, 1)); - axis (handles(4, 1), 'tight'); - xlabel(handles(4, 1), 'Time (s)'); - ylabel(handles(4, 1), 'CNo (dB-Hz)'); - title (handles(4, 1), 'Carrier to Noise Ratio'); - - %----- Carrier Frequency -------------------------------- - plot (handles(4, 2), timeAxisInSeconds(2:end), ... - trackResults(channelNr).carrFreq(2:settings.msToProcess), 'Color',[0.42 0.25 0.39]); - - grid (handles(4, 2)); - axis (handles(4, 2)); - xlabel(handles(4, 2), 'Time (s)'); - ylabel(handles(4, 2), 'Freq (hz)'); - title (handles(4, 2), 'Carrier Freq'); - - %----- Code Frequency---------------------------------- - %--- Skip sample 0 to help with results display - plot (handles(4, 3), timeAxisInSeconds(2:end), ... - trackResults(channelNr).codeFreq(2:settings.msToProcess), 'Color',[0.2 0.3 0.49]); - - grid (handles(4, 3)); - axis (handles(4, 3), 'tight'); - xlabel(handles(4, 3), 'Time (s)'); - ylabel(handles(4, 3), 'Freq (Hz)'); - title (handles(4, 3), 'Code Freq'); - -end % for channelNr = channelList +function plotTracking(channelList, trackResults, settings) +% This function plots the tracking results for the given channel list. +% +% plotTracking(channelList, trackResults, settings) +% +% Inputs: +% channelList - list of channels to be plotted. +% trackResults - tracking results from the tracking function. +% settings - receiver settings. + +%-------------------------------------------------------------------------- +% SoftGNSS v3.0 +% +% Copyright (C) Darius Plausinaitis +% Written by Darius Plausinaitis +%-------------------------------------------------------------------------- +%This program is free software; you can redistribute it and/or +%modify it under the terms of the GNU General Public License +%as published by the Free Software Foundation; either version 2 +%of the License, or (at your option) any later version. +% +%This program is distributed in the hope that it will be useful, +%but WITHOUT ANY WARRANTY; without even the implied warranty of +%MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%GNU General Public License for more details. +% +%You should have received a copy of the GNU General Public License +%along with this program; if not, write to the Free Software +%Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +%USA. +%-------------------------------------------------------------------------- + + +% Protection - if the list contains incorrect channel numbers +channelList = intersect(channelList, 1:settings.numberOfChannels); + +%=== For all listed channels ============================================== +for channelNr = channelList + + %% Select (or create) and clear the figure ================================ + % The number 200 is added just for more convenient handling of the open + % figure windows, when many figures are closed and reopened. + % Figures drawn or opened by the user, will not be "overwritten" by + % this function. + + figure(channelNr +200); + clf(channelNr +200); + set(channelNr +200, 'Name', ['Channel ', num2str(channelNr), ... + ' (PRN ', ... + num2str(trackResults(channelNr).PRN(end-1)), ... + ') results']); + + %% Draw axes ============================================================== + % Row 1 + handles(1, 1) = subplot(4, 3, 1); + handles(1, 2) = subplot(4, 3, [2 3]); + % Row 2 + handles(2, 1) = subplot(4, 3, 4); + handles(2, 2) = subplot(4, 3, [5 6]); + % Row 3 + handles(3, 1) = subplot(4, 3, 7); + handles(3, 2) = subplot(4, 3, 8); + handles(3, 3) = subplot(4, 3, 9); + % Row 4 + handles(4, 1) = subplot(4, 3, 10); + handles(4, 2) = subplot(4, 3, 11); + handles(4, 3) = subplot(4, 3, 12); + + + %% Plot all figures ======================================================= + + timeAxisInSeconds = (1:settings.msToProcess)/1000; + + %----- Discrete-Time Scatter Plot --------------------------------- + plot(handles(1, 1), trackResults(channelNr).I_P,... + trackResults(channelNr).Q_P, ... + '.'); + + grid (handles(1, 1)); + axis (handles(1, 1), 'equal'); + title (handles(1, 1), 'Discrete-Time Scatter Plot'); + xlabel(handles(1, 1), 'I prompt'); + ylabel(handles(1, 1), 'Q prompt'); + + %----- Nav bits --------------------------------------------------- + plot (handles(1, 2), timeAxisInSeconds, ... + trackResults(channelNr).I_P); + + grid (handles(1, 2)); + title (handles(1, 2), 'Bits of the navigation message'); + xlabel(handles(1, 2), 'Time (s)'); + axis (handles(1, 2), 'tight'); + + %----- PLL discriminator unfiltered-------------------------------- + plot (handles(2, 1), timeAxisInSeconds, ... + trackResults(channelNr).pllDiscr, 'r'); + + grid (handles(2, 1)); + axis (handles(2, 1), 'tight'); + xlabel(handles(2, 1), 'Time (s)'); + ylabel(handles(2, 1), 'Amplitude'); + title (handles(2, 1), 'Raw PLL discriminator'); + + %----- Correlation ------------------------------------------------ + plot(handles(2, 2), timeAxisInSeconds, ... + [sqrt(trackResults(channelNr).I_E.^2 + ... + trackResults(channelNr).Q_E.^2)', ... + sqrt(trackResults(channelNr).I_P.^2 + ... + trackResults(channelNr).Q_P.^2)', ... + sqrt(trackResults(channelNr).I_L.^2 + ... + trackResults(channelNr).Q_L.^2)'], ... + '-*'); + + grid (handles(2, 2)); + title (handles(2, 2), 'Correlation results'); + xlabel(handles(2, 2), 'Time (s)'); + axis (handles(2, 2), 'tight'); + + hLegend = legend(handles(2, 2), '$\sqrt{I_{E}^2 + Q_{E}^2}$', ... + '$\sqrt{I_{P}^2 + Q_{P}^2}$', ... + '$\sqrt{I_{L}^2 + Q_{L}^2}$'); + + %set interpreter from tex to latex. This will draw \sqrt correctly + set(hLegend, 'Interpreter', 'Latex'); + + %----- PLL discriminator filtered---------------------------------- + plot (handles(3, 1), timeAxisInSeconds, ... + trackResults(channelNr).pllDiscrFilt(1:settings.msToProcess), 'b'); + + grid (handles(3, 1)); + axis (handles(3, 1), 'tight'); + xlabel(handles(3, 1), 'Time (s)'); + ylabel(handles(3, 1), 'Amplitude'); + title (handles(3, 1), 'Filtered PLL discriminator'); + + %----- DLL discriminator unfiltered-------------------------------- + plot (handles(3, 2), timeAxisInSeconds, ... + trackResults(channelNr).dllDiscr, 'r'); + + grid (handles(3, 2)); + axis (handles(3, 2), 'tight'); + xlabel(handles(3, 2), 'Time (s)'); + ylabel(handles(3, 2), 'Amplitude'); + title (handles(3, 2), 'Raw DLL discriminator'); + + %----- DLL discriminator filtered---------------------------------- + plot (handles(3, 3), timeAxisInSeconds, ... + trackResults(channelNr).dllDiscrFilt, 'b'); + + grid (handles(3, 3)); + axis (handles(3, 3), 'tight'); + xlabel(handles(3, 3), 'Time (s)'); + ylabel(handles(3, 3), 'Amplitude'); + title (handles(3, 3), 'Filtered DLL discriminator'); + + %----- CNo for signal---------------------------------- + plot (handles(4, 1), timeAxisInSeconds, ... + trackResults(channelNr).CNo(1:settings.msToProcess), 'b'); + + grid (handles(4, 1)); + axis (handles(4, 1), 'tight'); + xlabel(handles(4, 1), 'Time (s)'); + ylabel(handles(4, 1), 'CNo (dB-Hz)'); + title (handles(4, 1), 'Carrier to Noise Ratio'); + + %----- Carrier Frequency -------------------------------- + plot (handles(4, 2), timeAxisInSeconds(2:end), ... + trackResults(channelNr).carrFreq(2:settings.msToProcess), 'Color',[0.42 0.25 0.39]); + + grid (handles(4, 2)); + axis (handles(4, 2)); + xlabel(handles(4, 2), 'Time (s)'); + ylabel(handles(4, 2), 'Freq (hz)'); + title (handles(4, 2), 'Carrier Freq'); + + %----- Code Frequency---------------------------------- + %--- Skip sample 0 to help with results display + plot (handles(4, 3), timeAxisInSeconds(2:end), ... + trackResults(channelNr).codeFreq(2:settings.msToProcess), 'Color',[0.2 0.3 0.49]); + + grid (handles(4, 3)); + axis (handles(4, 3), 'tight'); + xlabel(handles(4, 3), 'Time (s)'); + ylabel(handles(4, 3), 'Freq (Hz)'); + title (handles(4, 3), 'Code Freq'); + +end % for channelNr = channelList diff --git a/src/utils/matlab/libs/plotVEMLTracking.m b/src/utils/matlab/libs/plotVEMLTracking.m index 8af2225f9..bc4e4e806 100644 --- a/src/utils/matlab/libs/plotVEMLTracking.m +++ b/src/utils/matlab/libs/plotVEMLTracking.m @@ -1,159 +1,162 @@ -function plotVEMLTracking(channelList, trackResults, settings) -%This function plots the tracking results for the given channel list. -% -%plotTracking(channelList, trackResults, settings) -% -% Inputs: -% channelList - list of channels to be plotted. -% trackResults - tracking results from the tracking function. -% settings - receiver settings. - -%-------------------------------------------------------------------------- -% SoftGNSS v3.0 -% -% Copyright (C) Darius Plausinaitis -% Written by Darius Plausinaitis -%-------------------------------------------------------------------------- -%This program is free software; you can redistribute it and/or -%modify it under the terms of the GNU General Public License -%as published by the Free Software Foundation; either version 2 -%of the License, or (at your option) any later version. -% -%This program is distributed in the hope that it will be useful, -%but WITHOUT ANY WARRANTY; without even the implied warranty of -%MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -%GNU General Public License for more details. -% -%You should have received a copy of the GNU General Public License -%along with this program; if not, write to the Free Software -%Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -%USA. -%-------------------------------------------------------------------------- - -%CVS record: -%$Id: plotTracking.m,v 1.5.2.23 2006/08/14 14:45:14 dpl Exp $ - -% Protection - if the list contains incorrect channel numbers -channelList = intersect(channelList, 1:settings.numberOfChannels); - -%=== For all listed channels ============================================== -for channelNr = channelList - -%% Select (or create) and clear the figure ================================ - % The number 200 is added just for more convenient handling of the open - % figure windows, when many figures are closed and reopened. - % Figures drawn or opened by the user, will not be "overwritten" by - % this function. - - figure(channelNr +200); - clf(channelNr +200); - set(channelNr +200, 'Name', ['Channel ', num2str(channelNr), ... - ' (PRN ', ... - num2str(trackResults(channelNr).PRN(end-1)), ... - ') results']); - -%% Draw axes ============================================================== - % Row 1 - handles(1, 1) = subplot(3, 3, 1); - handles(1, 2) = subplot(3, 3, [2 3]); - % Row 2 - handles(2, 1) = subplot(3, 3, 4); - handles(2, 2) = subplot(3, 3, [5 6]); - % Row 3 - handles(3, 1) = subplot(3, 3, 7); - handles(3, 2) = subplot(3, 3, 8); - handles(3, 3) = subplot(3, 3, 9); - -%% Plot all figures ======================================================= - - timeAxisInSeconds = (1:4:settings.msToProcess)/1000; - - %----- Discrete-Time Scatter Plot --------------------------------- - plot(handles(1, 1), trackResults(channelNr).I_P,... - trackResults(channelNr).Q_P, ... - '.'); - - grid (handles(1, 1)); - axis (handles(1, 1), 'equal'); - title (handles(1, 1), 'Discrete-Time Scatter Plot'); - xlabel(handles(1, 1), 'I prompt'); - ylabel(handles(1, 1), 'Q prompt'); - - %----- Nav bits --------------------------------------------------- - plot (handles(1, 2), timeAxisInSeconds, ... - trackResults(channelNr).I_P); - - grid (handles(1, 2)); - title (handles(1, 2), 'Bits of the navigation message'); - xlabel(handles(1, 2), 'Time (s)'); - axis (handles(1, 2), 'tight'); - - %----- PLL discriminator unfiltered-------------------------------- - plot (handles(2, 1), timeAxisInSeconds, ... - trackResults(channelNr).pllDiscr, 'r'); - - grid (handles(2, 1)); - axis (handles(2, 1), 'tight'); - xlabel(handles(2, 1), 'Time (s)'); - ylabel(handles(2, 1), 'Amplitude'); - title (handles(2, 1), 'Raw PLL discriminator'); - - %----- Correlation ------------------------------------------------ - plot(handles(2, 2), timeAxisInSeconds, ... - [sqrt(trackResults(channelNr).I_VE.^2 + ... - trackResults(channelNr).Q_VE.^2)', ... - sqrt(trackResults(channelNr).I_E.^2 + ... - trackResults(channelNr).Q_E.^2)', ... - sqrt(trackResults(channelNr).I_P.^2 + ... - trackResults(channelNr).Q_P.^2)', ... - sqrt(trackResults(channelNr).I_L.^2 + ... - trackResults(channelNr).Q_L.^2)', ... - sqrt(trackResults(channelNr).I_VL.^2 + ... - trackResults(channelNr).Q_VL.^2)'], ... - '-*'); - - grid (handles(2, 2)); - title (handles(2, 2), 'Correlation results'); - xlabel(handles(2, 2), 'Time (s)'); - axis (handles(2, 2), 'tight'); - - hLegend = legend(handles(2, 2), '$\sqrt{I_{VE}^2 + Q_{VE}^2}$', ... - '$\sqrt{I_{E}^2 + Q_{E}^2}$', ... - '$\sqrt{I_{P}^2 + Q_{P}^2}$', ... - '$\sqrt{I_{L}^2 + Q_{L}^2}$', ... - '$\sqrt{I_{VL}^2 + Q_{VL}^2}$'); - - %set interpreter from tex to latex. This will draw \sqrt correctly - set(hLegend, 'Interpreter', 'Latex'); - - %----- PLL discriminator filtered---------------------------------- - plot (handles(3, 1), timeAxisInSeconds, ... - trackResults(channelNr).pllDiscrFilt, 'b'); - - grid (handles(3, 1)); - axis (handles(3, 1), 'tight'); - xlabel(handles(3, 1), 'Time (s)'); - ylabel(handles(3, 1), 'Amplitude'); - title (handles(3, 1), 'Filtered PLL discriminator'); - - %----- DLL discriminator unfiltered-------------------------------- - plot (handles(3, 2), timeAxisInSeconds, ... - trackResults(channelNr).dllDiscr, 'r'); - - grid (handles(3, 2)); - axis (handles(3, 2), 'tight'); - xlabel(handles(3, 2), 'Time (s)'); - ylabel(handles(3, 2), 'Amplitude'); - title (handles(3, 2), 'Raw DLL discriminator'); - - %----- DLL discriminator filtered---------------------------------- - plot (handles(3, 3), timeAxisInSeconds, ... - trackResults(channelNr).dllDiscrFilt, 'b'); - - grid (handles(3, 3)); - axis (handles(3, 3), 'tight'); - xlabel(handles(3, 3), 'Time (s)'); - ylabel(handles(3, 3), 'Amplitude'); - title (handles(3, 3), 'Filtered DLL discriminator'); - -end % for channelNr = channelList +function plotVEMLTracking(channelList, trackResults, settings) +% This function plots the tracking results for the given channel list. +% +% plotTracking(channelList, trackResults, settings) +% +% Inputs: +% channelList - list of channels to be plotted. +% trackResults - tracking results from the tracking function. +% settings - receiver settings. + +%-------------------------------------------------------------------------- +% SoftGNSS v3.0 +% +% Copyright (C) Darius Plausinaitis +% Written by Darius Plausinaitis +%-------------------------------------------------------------------------- +%This program is free software; you can redistribute it and/or +%modify it under the terms of the GNU General Public License +%as published by the Free Software Foundation; either version 2 +%of the License, or (at your option) any later version. +% +%This program is distributed in the hope that it will be useful, +%but WITHOUT ANY WARRANTY; without even the implied warranty of +%MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +%GNU General Public License for more details. +% +%You should have received a copy of the GNU General Public License +%along with this program; if not, write to the Free Software +%Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +%USA. +%-------------------------------------------------------------------------- + +% Protection - if the list contains incorrect channel numbers +channelList = intersect(channelList, 1:settings.numberOfChannels); + +%=== For all listed channels ============================================== +for channelNr = channelList + + %% Select (or create) and clear the figure ================================ + % The number 200 is added just for more convenient handling of the open + % figure windows, when many figures are closed and reopened. + % Figures drawn or opened by the user, will not be "overwritten" by + % this function. + + figure(channelNr +200); + clf(channelNr +200); + set(channelNr +200, 'Name', ['Channel ', num2str(channelNr), ... + ' (PRN ', ... + num2str(trackResults(channelNr).PRN(end-1)), ... + ') results']); + + %% Draw axes ============================================================== + % Row 1 + handles(1, 1) = subplot(3, 3, 1); + handles(1, 2) = subplot(3, 3, [2 3]); + % Row 2 + handles(2, 1) = subplot(3, 3, 4); + handles(2, 2) = subplot(3, 3, [5 6]); + % Row 3 + handles(3, 1) = subplot(3, 3, 7); + handles(3, 2) = subplot(3, 3, 8); + handles(3, 3) = subplot(3, 3, 9); + + %% Plot all figures ======================================================= + + timeAxisInSeconds = (1:4:settings.msToProcess)/1000; + + %----- Discrete-Time Scatter Plot --------------------------------- + plot(handles(1, 1), trackResults(channelNr).data_I,... + trackResults(channelNr).data_Q, ... + '.'); + + grid (handles(1, 1)); + axis (handles(1, 1), 'equal'); + title (handles(1, 1), 'Discrete-Time Scatter Plot'); + xlabel(handles(1, 1), 'I prompt'); + ylabel(handles(1, 1), 'Q prompt'); + + %----- Nav bits --------------------------------------------------- + t = (1:length(trackResults(channelNr).data_I)); + plot (handles(1, 2), t, ... + trackResults(channelNr).data_I); + + grid (handles(1, 2)); + title (handles(1, 2), 'Bits of the navigation message'); + xlabel(handles(1, 2), 'Time (s)'); + axis (handles(1, 2), 'tight'); + + %----- PLL discriminator unfiltered-------------------------------- + t = (1:length(trackResults(channelNr).pllDiscr)); + plot (handles(2, 1), t, ... + trackResults(channelNr).pllDiscr, 'r'); + + grid (handles(2, 1)); + axis (handles(2, 1), 'tight'); + xlabel(handles(2, 1), 'Time (s)'); + ylabel(handles(2, 1), 'Amplitude'); + title (handles(2, 1), 'Raw PLL discriminator'); + + %----- Correlation ------------------------------------------------ + t = (1:length(trackResults(channelNr).I_VE)); + plot(handles(2, 2), t, ... + [sqrt(trackResults(channelNr).I_VE.^2 + ... + trackResults(channelNr).Q_VE.^2)', ... + sqrt(trackResults(channelNr).I_E.^2 + ... + trackResults(channelNr).Q_E.^2)', ... + sqrt(trackResults(channelNr).I_P.^2 + ... + trackResults(channelNr).Q_P.^2)', ... + sqrt(trackResults(channelNr).I_L.^2 + ... + trackResults(channelNr).Q_L.^2)', ... + sqrt(trackResults(channelNr).I_VL.^2 + ... + trackResults(channelNr).Q_VL.^2)'], ... + '-*'); + + grid (handles(2, 2)); + title (handles(2, 2), 'Correlation results'); + xlabel(handles(2, 2), 'Time (s)'); + axis (handles(2, 2), 'tight'); + + hLegend = legend(handles(2, 2), '$\sqrt{I_{VE}^2 + Q_{VE}^2}$', ... + '$\sqrt{I_{E}^2 + Q_{E}^2}$', ... + '$\sqrt{I_{P}^2 + Q_{P}^2}$', ... + '$\sqrt{I_{L}^2 + Q_{L}^2}$', ... + '$\sqrt{I_{VL}^2 + Q_{VL}^2}$'); + + %set interpreter from tex to latex. This will draw \sqrt correctly + set(hLegend, 'Interpreter', 'Latex'); + + %----- PLL discriminator filtered---------------------------------- + t = (1:length(trackResults(channelNr).pllDiscrFilt)); + plot (handles(3, 1), t, ... + trackResults(channelNr).pllDiscrFilt, 'b'); + + grid (handles(3, 1)); + axis (handles(3, 1), 'tight'); + xlabel(handles(3, 1), 'Time (s)'); + ylabel(handles(3, 1), 'Amplitude'); + title (handles(3, 1), 'Filtered PLL discriminator'); + + %----- DLL discriminator unfiltered-------------------------------- + t = (1:length(trackResults(channelNr).dllDiscr)); + plot (handles(3, 2), t, ... + trackResults(channelNr).dllDiscr, 'r'); + + grid (handles(3, 2)); + axis (handles(3, 2), 'tight'); + xlabel(handles(3, 2), 'Time (s)'); + ylabel(handles(3, 2), 'Amplitude'); + title (handles(3, 2), 'Raw DLL discriminator'); + + %----- DLL discriminator filtered---------------------------------- + t = (1:length(trackResults(channelNr).dllDiscrFilt)); + plot (handles(3, 3), t, ... + trackResults(channelNr).dllDiscrFilt, 'b'); + + grid (handles(3, 3)); + axis (handles(3, 3), 'tight'); + xlabel(handles(3, 3), 'Time (s)'); + ylabel(handles(3, 3), 'Amplitude'); + title (handles(3, 3), 'Filtered DLL discriminator'); + +end % for channelNr = channelList diff --git a/src/utils/matlab/libs/read_complex_binary.m b/src/utils/matlab/libs/read_complex_binary.m index a201b99bb..dc26a459f 100644 --- a/src/utils/matlab/libs/read_complex_binary.m +++ b/src/utils/matlab/libs/read_complex_binary.m @@ -1,50 +1,54 @@ +% Usage: read_complex_binary (filename, [count], [start_sample]) % -% Copyright 2001 Free Software Foundation, Inc. +% Opens filename and returns the contents as a column vector, +% treating them as 32 bit complex numbers % -% This file is part of GNU Radio + +% ------------------------------------------------------------------------- % -% GNU Radio is free software; you can redistribute it and/or modify +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by -% the Free Software Foundation; either version 3, or (at your option) -% any later version. +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. % -% GNU Radio is distributed in the hope that it will be useful, +% GNSS-SDR is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. % % You should have received a copy of the GNU General Public License -% along with GNU Radio; see the file COPYING. If not, write to -% the Free Software Foundation, Inc., 51 Franklin Street, -% Boston, MA 02110-1301, USA. +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- % function v = read_complex_binary (filename, count, start_sample) - %% usage: read_complex_binary (filename, [count], [start_sample]) - %% - %% open filename and return the contents as a column vector, - %% treating them as 32 bit complex numbers - %% - - m = nargchk (1,2,nargin); - if (m) +m = nargchk (1,2,nargin); +if (m) %usage (m); - end +end - if (nargin < 2) +if (nargin < 2) count = Inf; start_sample=0; - end +end - if (nargin < 3) +if (nargin < 3) start_sample=0; - end - - f = fopen (filename, 'rb'); - if (f < 0) +end + +f = fopen (filename, 'rb'); +if (f < 0) v = 0; - else +else if (start_sample>0) bytes_per_sample=4; fseek(f,start_sample*bytes_per_sample,'bof'); @@ -54,4 +58,4 @@ function v = read_complex_binary (filename, count, start_sample) v = t(1,:) + t(2,:)*i; [r, c] = size (v); v = reshape (v, c, r); - end +end diff --git a/src/utils/matlab/libs/read_complex_char_binary.m b/src/utils/matlab/libs/read_complex_char_binary.m index cafaedcc7..e339ec158 100644 --- a/src/utils/matlab/libs/read_complex_char_binary.m +++ b/src/utils/matlab/libs/read_complex_char_binary.m @@ -1,48 +1,52 @@ +% Usage: read_complex_binary (filename, [count]) % -% Copyright 2001 Free Software Foundation, Inc. -% -% This file is part of GNU Radio -% -% GNU Radio is free software; you can redistribute it and/or modify +% Opens filename and returns the contents as a column vector, +% treating them as 32 bit complex numbers +% + +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by -% the Free Software Foundation; either version 3, or (at your option) -% any later version. -% -% GNU Radio is distributed in the hope that it will be useful, +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. -% +% % You should have received a copy of the GNU General Public License -% along with GNU Radio; see the file COPYING. If not, write to -% the Free Software Foundation, Inc., 51 Franklin Street, -% Boston, MA 02110-1301, USA. -% +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- +% function v = read_complex_char_binary (filename, count) - %% usage: read_complex_binary (filename, [count]) - %% - %% open filename and return the contents as a column vector, - %% treating them as 32 bit complex numbers - %% - - m = nargchk (1,2,nargin); - if (m) +m = nargchk (1,2,nargin); +if (m) usage (m); - end +end - if (nargin < 2) +if (nargin < 2) count = Inf; - end +end - f = fopen (filename, 'rb'); - if (f < 0) +f = fopen (filename, 'rb'); +if (f < 0) v = 0; - else +else t = fread (f, [2, count], 'int8'); fclose (f); v = t(1,:) + t(2,:)*i; [r, c] = size (v); v = reshape (v, c, r); - end +end diff --git a/src/utils/matlab/libs/read_complex_short_binary.m b/src/utils/matlab/libs/read_complex_short_binary.m index 55118528b..1d4e80bef 100644 --- a/src/utils/matlab/libs/read_complex_short_binary.m +++ b/src/utils/matlab/libs/read_complex_short_binary.m @@ -1,48 +1,52 @@ +% Usage: read_complex_binary (filename, [count]) % -% Copyright 2001 Free Software Foundation, Inc. -% -% This file is part of GNU Radio -% -% GNU Radio is free software; you can redistribute it and/or modify +% Opens filename and returns the contents as a column vector, +% treating them as 32 bit complex numbers +% + +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify % it under the terms of the GNU General Public License as published by -% the Free Software Foundation; either version 3, or (at your option) -% any later version. -% -% GNU Radio is distributed in the hope that it will be useful, +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR is distributed in the hope that it will be useful, % but WITHOUT ANY WARRANTY; without even the implied warranty of % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the % GNU General Public License for more details. -% +% % You should have received a copy of the GNU General Public License -% along with GNU Radio; see the file COPYING. If not, write to -% the Free Software Foundation, Inc., 51 Franklin Street, -% Boston, MA 02110-1301, USA. -% +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- +% function v = read_complex_short_binary (filename, count) - %% usage: read_complex_binary (filename, [count]) - %% - %% open filename and return the contents as a column vector, - %% treating them as 32 bit complex numbers - %% - - m = nargchk (1,2,nargin); - if (m) +m = nargchk (1,2,nargin); +if (m) usage (m); - end +end - if (nargin < 2) +if (nargin < 2) count = Inf; - end +end - f = fopen (filename, 'rb'); - if (f < 0) +f = fopen (filename, 'rb'); +if (f < 0) v = 0; - else +else t = fread (f, [2, count], 'short'); fclose (f); v = t(1,:) + t(2,:)*i; [r, c] = size (v); v = reshape (v, c, r); - end +end diff --git a/src/utils/matlab/libs/read_hybrid_observables_dump.m b/src/utils/matlab/libs/read_hybrid_observables_dump.m index b14090a2a..3d8cc3703 100644 --- a/src/utils/matlab/libs/read_hybrid_observables_dump.m +++ b/src/utils/matlab/libs/read_hybrid_observables_dump.m @@ -1,27 +1,52 @@ -% Javier Arribas 2011 +% Usage: read_tracking_dat (filename, [count]) +% +% Opens GNSS-SDR tracking binary log file .dat and returns the contents +% + +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- +% +% Javier Arribas 2011 + function [observables] = read_hybrid_observables_dump (channels, filename, count) - %% usage: read_tracking_dat (filename, [count]) - %% - %% open GNSS-SDR tracking binary log file .dat and return the contents - %% - - m = nargchk (1,2,nargin); - num_double_vars=7; - double_size_bytes=8; - skip_bytes_each_read=double_size_bytes*num_double_vars*channels; - bytes_shift=0; - if (m) +m = nargchk (1,2,nargin); +num_double_vars=7; +double_size_bytes=8; +skip_bytes_each_read=double_size_bytes*num_double_vars*channels; +bytes_shift=0; +if (m) usage (m); - end +end - if (nargin < 3) +if (nargin < 3) count = Inf; - end - %loops_counter = fread (f, count, 'uint32',4*12); - f = fopen (filename, 'rb'); - if (f < 0) - else +end +%loops_counter = fread (f, count, 'uint32',4*12); +f = fopen (filename, 'rb'); +if (f < 0) +else for N=1:1:channels observables.RX_time(N,:) = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); bytes_shift=bytes_shift+double_size_bytes; @@ -45,27 +70,27 @@ function [observables] = read_hybrid_observables_dump (channels, filename, count bytes_shift=bytes_shift+double_size_bytes; fseek(f,bytes_shift,'bof'); % move to next interleaved end - + fclose (f); %%%%%%%% output vars %%%%%%%% -% double tmp_double; -% for (unsigned int i = 0; i < d_nchannels; i++) -% { -% tmp_double = current_gnss_synchro[i].RX_time; -% d_dump_file.write((char*)&tmp_double, sizeof(double)); -% tmp_double = current_gnss_synchro[i].TOW_at_current_symbol_s; -% d_dump_file.write((char*)&tmp_double, sizeof(double)); -% tmp_double = current_gnss_synchro[i].Carrier_Doppler_hz; -% d_dump_file.write((char*)&tmp_double, sizeof(double)); -% tmp_double = current_gnss_synchro[i].Carrier_phase_rads/GPS_TWO_PI; -% d_dump_file.write((char*)&tmp_double, sizeof(double)); -% tmp_double = current_gnss_synchro[i].Pseudorange_m; -% d_dump_file.write((char*)&tmp_double, sizeof(double)); -% tmp_double = current_gnss_synchro[i].PRN; -% d_dump_file.write((char*)&tmp_double, sizeof(double)); -% tmp_double = current_gnss_synchro[i].Flag_valid_pseudorange; -% d_dump_file.write((char*)&tmp_double, sizeof(double)); -% } - end - + % double tmp_double; + % for (unsigned int i = 0; i < d_nchannels; i++) + % { + % tmp_double = current_gnss_synchro[i].RX_time; + % d_dump_file.write((char*)&tmp_double, sizeof(double)); + % tmp_double = current_gnss_synchro[i].TOW_at_current_symbol_s; + % d_dump_file.write((char*)&tmp_double, sizeof(double)); + % tmp_double = current_gnss_synchro[i].Carrier_Doppler_hz; + % d_dump_file.write((char*)&tmp_double, sizeof(double)); + % tmp_double = current_gnss_synchro[i].Carrier_phase_rads/GPS_TWO_PI; + % d_dump_file.write((char*)&tmp_double, sizeof(double)); + % tmp_double = current_gnss_synchro[i].Pseudorange_m; + % d_dump_file.write((char*)&tmp_double, sizeof(double)); + % tmp_double = current_gnss_synchro[i].PRN; + % d_dump_file.write((char*)&tmp_double, sizeof(double)); + % tmp_double = current_gnss_synchro[i].Flag_valid_pseudorange; + % d_dump_file.write((char*)&tmp_double, sizeof(double)); + % } +end + diff --git a/src/utils/matlab/libs/read_true_sim_observables_dump.m b/src/utils/matlab/libs/read_true_sim_observables_dump.m index af2001b69..04c45f989 100644 --- a/src/utils/matlab/libs/read_true_sim_observables_dump.m +++ b/src/utils/matlab/libs/read_true_sim_observables_dump.m @@ -1,29 +1,54 @@ -% Javier Arribas 2011 +% Usage: read_true_sim_observables_dump (filename, [count]) +% +% Opens gnss-sdr-sim observables dump and reads all chennels +% + +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- +% +% Javier Arribas 2011 + function [observables] = read_true_sim_observables_dump (filename, count) - %% usage: read_true_sim_observables_dump (filename, [count]) - %% - %% open gnss-sdr-sim observables dump and read all chennels - %% +m = nargchk (1,2,nargin); +channels=12; %Simulator always use 12 channels +num_double_vars=7; +double_size_bytes=8; +skip_bytes_each_read=double_size_bytes*num_double_vars*channels; +bytes_shift=0; - m = nargchk (1,2,nargin); - channels=12; %Simulator always use 12 channels - num_double_vars=7; - double_size_bytes=8; - skip_bytes_each_read=double_size_bytes*num_double_vars*channels; - bytes_shift=0; - - if (m) +if (m) usage (m); - end +end - if (nargin < 2) +if (nargin < 2) count = Inf; - end - %loops_counter = fread (f, count, 'uint32',4*12); - f = fopen (filename, 'rb'); - if (f < 0) - else +end +%loops_counter = fread (f, count, 'uint32',4*12); +f = fopen (filename, 'rb'); +if (f < 0) +else for N=1:1:channels observables.RX_time(N,:) = fread (f, count, 'float64',skip_bytes_each_read-double_size_bytes); bytes_shift=bytes_shift+double_size_bytes; @@ -47,19 +72,19 @@ function [observables] = read_true_sim_observables_dump (filename, count) bytes_shift=bytes_shift+double_size_bytes; fseek(f,bytes_shift,'bof'); % move to next interleaved end - + fclose (f); -% %%%%%%%% output vars %%%%%%%% -% for(int i=0;i<12;i++) -% { -% d_dump_file.read((char *) &gps_time_sec[i], sizeof(double)); -% d_dump_file.read((char *) &doppler_l1_hz, sizeof(double)); -% d_dump_file.read((char *) &acc_carrier_phase_l1_cycles[i], sizeof(double)); -% d_dump_file.read((char *) &dist_m[i], sizeof(double)); -% d_dump_file.read((char *) &true_dist_m[i], sizeof(double)); -% d_dump_file.read((char *) &carrier_phase_l1_cycles[i], sizeof(double)); -% d_dump_file.read((char *) &prn[i], sizeof(double)); -% } - end - + % %%%%%%%% output vars %%%%%%%% + % for(int i=0;i<12;i++) + % { + % d_dump_file.read((char *) &gps_time_sec[i], sizeof(double)); + % d_dump_file.read((char *) &doppler_l1_hz, sizeof(double)); + % d_dump_file.read((char *) &acc_carrier_phase_l1_cycles[i], sizeof(double)); + % d_dump_file.read((char *) &dist_m[i], sizeof(double)); + % d_dump_file.read((char *) &true_dist_m[i], sizeof(double)); + % d_dump_file.read((char *) &carrier_phase_l1_cycles[i], sizeof(double)); + % d_dump_file.read((char *) &prn[i], sizeof(double)); + % } +end + diff --git a/src/utils/matlab/plotTrackingE5a.m b/src/utils/matlab/plotTrackingE5a.m index b017accf3..e63d23162 100644 --- a/src/utils/matlab/plotTrackingE5a.m +++ b/src/utils/matlab/plotTrackingE5a.m @@ -1,153 +1,150 @@ -function plotTracking(channelList, trackResults, settings) -%This function plots the tracking results for the given channel list. -% -%plotTracking(channelList, trackResults, settings) -% -% Inputs: -% channelList - list of channels to be plotted. -% trackResults - tracking results from the tracking function. -% settings - receiver settings. - -%-------------------------------------------------------------------------- -% SoftGNSS v3.0 -% -% Copyright (C) Darius Plausinaitis -% Written by Darius Plausinaitis -%-------------------------------------------------------------------------- -%This program is free software; you can redistribute it and/or -%modify it under the terms of the GNU General Public License -%as published by the Free Software Foundation; either version 2 -%of the License, or (at your option) any later version. -% -%This program is distributed in the hope that it will be useful, -%but WITHOUT ANY WARRANTY; without even the implied warranty of -%MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -%GNU General Public License for more details. -% -%You should have received a copy of the GNU General Public License -%along with this program; if not, write to the Free Software -%Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, -%USA. -%-------------------------------------------------------------------------- - -%CVS record: -%$Id: plotTracking.m,v 1.5.2.23 2006/08/14 14:45:14 dpl Exp $ - -% Protection - if the list contains incorrect channel numbers -channelList = intersect(channelList, 1:settings.numberOfChannels); - -%=== For all listed channels ============================================== -for channelNr = channelList - -%% Select (or create) and clear the figure ================================ - % The number 200 is added just for more convenient handling of the open - % figure windows, when many figures are closed and reopened. - % Figures drawn or opened by the user, will not be "overwritten" by - % this function. - - figure(channelNr +200); - clf(channelNr +200); - set(channelNr +200, 'Name', ['Channel ', num2str(channelNr), ... - ' (PRN ', ... - num2str(trackResults(channelNr).PRN), ... - ') results']); - -%% Draw axes ============================================================== - % Row 1 - handles(1, 1) = subplot(3, 3, 1); - handles(1, 2) = subplot(3, 3, [2 3]); - % Row 2 - handles(2, 1) = subplot(3, 3, 4); - handles(2, 2) = subplot(3, 3, [5 6]); - % Row 3 - handles(3, 1) = subplot(3, 3, 7); - handles(3, 2) = subplot(3, 3, 8); - handles(3, 3) = subplot(3, 3, 9); - -%% Plot all figures ======================================================= - - timeAxisInSeconds = (1:settings.msToProcess-1)/1000; - - %----- Discrete-Time Scatter Plot --------------------------------- - plot(handles(1, 1), trackResults(channelNr).I_PN,... - trackResults(channelNr).Q_PN, ... - '.'); - - grid (handles(1, 1)); - axis (handles(1, 1), 'equal'); - title (handles(1, 1), 'Discrete-Time Scatter Plot'); - xlabel(handles(1, 1), 'I prompt'); - ylabel(handles(1, 1), 'Q prompt'); - - %----- Nav bits --------------------------------------------------- - plot (handles(1, 2), timeAxisInSeconds, ... - trackResults(channelNr).I_PN(1:settings.msToProcess-1)); - - grid (handles(1, 2)); - title (handles(1, 2), 'Bits of the navigation message'); - xlabel(handles(1, 2), 'Time (s)'); - axis (handles(1, 2), 'tight'); - - %----- PLL discriminator unfiltered-------------------------------- - plot (handles(2, 1), timeAxisInSeconds, ... - trackResults(channelNr).pllDiscr(1:settings.msToProcess-1), 'r'); - - grid (handles(2, 1)); - axis (handles(2, 1), 'tight'); - xlabel(handles(2, 1), 'Time (s)'); - ylabel(handles(2, 1), 'Amplitude'); - title (handles(2, 1), 'Raw PLL discriminator'); - - %----- Correlation ------------------------------------------------ - plot(handles(2, 2), timeAxisInSeconds, ... - [sqrt(trackResults(channelNr).I_E(1:settings.msToProcess-1).^2 + ... - trackResults(channelNr).Q_E(1:settings.msToProcess-1).^2)', ... - sqrt(trackResults(channelNr).I_P(1:settings.msToProcess-1).^2 + ... - trackResults(channelNr).Q_P(1:settings.msToProcess-1).^2)', ... - sqrt(trackResults(channelNr).I_L(1:settings.msToProcess-1).^2 + ... - trackResults(channelNr).Q_L(1:settings.msToProcess-1).^2)'], ... - '-*'); - - grid (handles(2, 2)); - title (handles(2, 2), 'Correlation results'); - xlabel(handles(2, 2), 'Time (s)'); - axis (handles(2, 2), 'tight'); - - hLegend = legend(handles(2, 2), '$\sqrt{I_{E}^2 + Q_{E}^2}$', ... - '$\sqrt{I_{P}^2 + Q_{P}^2}$', ... - '$\sqrt{I_{L}^2 + Q_{L}^2}$'); - - %set interpreter from tex to latex. This will draw \sqrt correctly - set(hLegend, 'Interpreter', 'Latex'); - - %----- PLL discriminator filtered---------------------------------- - plot (handles(3, 1), timeAxisInSeconds, ... - trackResults(channelNr).pllDiscrFilt(1:settings.msToProcess-1), 'b'); - - grid (handles(3, 1)); - axis (handles(3, 1), 'tight'); - xlabel(handles(3, 1), 'Time (s)'); - ylabel(handles(3, 1), 'Amplitude'); - title (handles(3, 1), 'Filtered PLL discriminator'); - - %----- DLL discriminator unfiltered-------------------------------- - plot (handles(3, 2), timeAxisInSeconds, ... - trackResults(channelNr).dllDiscr(1:settings.msToProcess-1), 'r'); - - grid (handles(3, 2)); - axis (handles(3, 2), 'tight'); - xlabel(handles(3, 2), 'Time (s)'); - ylabel(handles(3, 2), 'Amplitude'); - title (handles(3, 2), 'Raw DLL discriminator'); - - %----- DLL discriminator filtered---------------------------------- - plot (handles(3, 3), timeAxisInSeconds, ... - trackResults(channelNr).dllDiscrFilt(1:settings.msToProcess-1), 'b'); - - grid (handles(3, 3)); - axis (handles(3, 3), 'tight'); - xlabel(handles(3, 3), 'Time (s)'); - ylabel(handles(3, 3), 'Amplitude'); - title (handles(3, 3), 'Filtered DLL discriminator'); - -end % for channelNr = channelList +function plotTracking(channelList, trackResults, settings) +% This function plots the tracking results for the given channel list. +% +% plotTracking(channelList, trackResults, settings) +% +% Inputs: +% channelList - list of channels to be plotted. +% trackResults - tracking results from the tracking function. +% settings - receiver settings. + +%-------------------------------------------------------------------------- +% SoftGNSS v3.0 +% +% Copyright (C) Darius Plausinaitis +% Written by Darius Plausinaitis +%-------------------------------------------------------------------------- +% This program is free software; you can redistribute it and/or +% modify it under the terms of the GNU General Public License +% as published by the Free Software Foundation; either version 2 +% of the License, or (at your option) any later version. +% +% This program is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with this program; if not, write to the Free Software +% Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, +% USA. +%-------------------------------------------------------------------------- + +% Protection - if the list contains incorrect channel numbers +channelList = intersect(channelList, 1:settings.numberOfChannels); + +%=== For all listed channels ============================================== +for channelNr = channelList + + %% Select (or create) and clear the figure ================================ + % The number 200 is added just for more convenient handling of the open + % figure windows, when many figures are closed and reopened. + % Figures drawn or opened by the user, will not be "overwritten" by + % this function. + + figure(channelNr +200); + clf(channelNr +200); + set(channelNr +200, 'Name', ['Channel ', num2str(channelNr), ... + ' (PRN ', ... + num2str(trackResults(channelNr).PRN), ... + ') results']); + + %% Draw axes ============================================================== + % Row 1 + handles(1, 1) = subplot(3, 3, 1); + handles(1, 2) = subplot(3, 3, [2 3]); + % Row 2 + handles(2, 1) = subplot(3, 3, 4); + handles(2, 2) = subplot(3, 3, [5 6]); + % Row 3 + handles(3, 1) = subplot(3, 3, 7); + handles(3, 2) = subplot(3, 3, 8); + handles(3, 3) = subplot(3, 3, 9); + + %% Plot all figures ======================================================= + + timeAxisInSeconds = (1:settings.msToProcess-1)/1000; + + %----- Discrete-Time Scatter Plot --------------------------------- + plot(handles(1, 1), trackResults(channelNr).I_PN,... + trackResults(channelNr).Q_PN, ... + '.'); + + grid (handles(1, 1)); + axis (handles(1, 1), 'equal'); + title (handles(1, 1), 'Discrete-Time Scatter Plot'); + xlabel(handles(1, 1), 'I prompt'); + ylabel(handles(1, 1), 'Q prompt'); + + %----- Nav bits --------------------------------------------------- + plot (handles(1, 2), timeAxisInSeconds, ... + trackResults(channelNr).I_PN(1:settings.msToProcess-1)); + + grid (handles(1, 2)); + title (handles(1, 2), 'Bits of the navigation message'); + xlabel(handles(1, 2), 'Time (s)'); + axis (handles(1, 2), 'tight'); + + %----- PLL discriminator unfiltered-------------------------------- + plot (handles(2, 1), timeAxisInSeconds, ... + trackResults(channelNr).pllDiscr(1:settings.msToProcess-1), 'r'); + + grid (handles(2, 1)); + axis (handles(2, 1), 'tight'); + xlabel(handles(2, 1), 'Time (s)'); + ylabel(handles(2, 1), 'Amplitude'); + title (handles(2, 1), 'Raw PLL discriminator'); + + %----- Correlation ------------------------------------------------ + plot(handles(2, 2), timeAxisInSeconds, ... + [sqrt(trackResults(channelNr).I_E(1:settings.msToProcess-1).^2 + ... + trackResults(channelNr).Q_E(1:settings.msToProcess-1).^2)', ... + sqrt(trackResults(channelNr).I_P(1:settings.msToProcess-1).^2 + ... + trackResults(channelNr).Q_P(1:settings.msToProcess-1).^2)', ... + sqrt(trackResults(channelNr).I_L(1:settings.msToProcess-1).^2 + ... + trackResults(channelNr).Q_L(1:settings.msToProcess-1).^2)'], ... + '-*'); + + grid (handles(2, 2)); + title (handles(2, 2), 'Correlation results'); + xlabel(handles(2, 2), 'Time (s)'); + axis (handles(2, 2), 'tight'); + + hLegend = legend(handles(2, 2), '$\sqrt{I_{E}^2 + Q_{E}^2}$', ... + '$\sqrt{I_{P}^2 + Q_{P}^2}$', ... + '$\sqrt{I_{L}^2 + Q_{L}^2}$'); + + %set interpreter from tex to latex. This will draw \sqrt correctly + set(hLegend, 'Interpreter', 'Latex'); + + %----- PLL discriminator filtered---------------------------------- + plot (handles(3, 1), timeAxisInSeconds, ... + trackResults(channelNr).pllDiscrFilt(1:settings.msToProcess-1), 'b'); + + grid (handles(3, 1)); + axis (handles(3, 1), 'tight'); + xlabel(handles(3, 1), 'Time (s)'); + ylabel(handles(3, 1), 'Amplitude'); + title (handles(3, 1), 'Filtered PLL discriminator'); + + %----- DLL discriminator unfiltered-------------------------------- + plot (handles(3, 2), timeAxisInSeconds, ... + trackResults(channelNr).dllDiscr(1:settings.msToProcess-1), 'r'); + + grid (handles(3, 2)); + axis (handles(3, 2), 'tight'); + xlabel(handles(3, 2), 'Time (s)'); + ylabel(handles(3, 2), 'Amplitude'); + title (handles(3, 2), 'Raw DLL discriminator'); + + %----- DLL discriminator filtered---------------------------------- + plot (handles(3, 3), timeAxisInSeconds, ... + trackResults(channelNr).dllDiscrFilt(1:settings.msToProcess-1), 'b'); + + grid (handles(3, 3)); + axis (handles(3, 3), 'tight'); + xlabel(handles(3, 3), 'Time (s)'); + ylabel(handles(3, 3), 'Amplitude'); + title (handles(3, 3), 'Filtered DLL discriminator'); + +end % for channelNr = channelList diff --git a/src/utils/matlab/plot_acq_grid.m b/src/utils/matlab/plot_acq_grid.m index 523f3d03a..b1d63ed58 100644 --- a/src/utils/matlab/plot_acq_grid.m +++ b/src/utils/matlab/plot_acq_grid.m @@ -1,36 +1,32 @@ -% /*! -% * \file plot_acq_grid.m -% * \brief Read GNSS-SDR Acquisition dump .mat file using the provided -% function and plot acquisition grid of acquisition statistic of PRN sat +% Reads GNSS-SDR Acquisition dump .mat file using the provided +% function and plots acquisition grid of acquisition statistic of PRN sat +% Antonio Ramos, 2017. antonio.ramos(at)cttc.es +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- % -% -% * \author Antonio Ramos, 2017. antonio.ramos(at)cttc.es -% * ------------------------------------------------------------------------- -% * -% * Copyright (C) 2010-2017 (see AUTHORS file for a list of contributors) -% * -% * GNSS-SDR is a software defined Global Navigation -% * Satellite Systems receiver -% * -% * This file is part of GNSS-SDR. -% * -% * GNSS-SDR is free software: you can redistribute it and/or modify -% * it under the terms of the GNU General Public License as published by -% * the Free Software Foundation, either version 3 of the License, or -% * at your option) any later version. -% * -% * GNSS-SDR is distributed in the hope that it will be useful, -% * but WITHOUT ANY WARRANTY; without even the implied warranty of -% * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% * GNU General Public License for more details. -% * -% * You should have received a copy of the GNU General Public License -% * along with GNSS-SDR. If not, see . -% * -% * ------------------------------------------------------------------------- -% */ -%%%%%%%%% ¡¡¡ CONFIGURE !!! %%%%%%%%%%%%% +%%%%%%%%% ?????? CONFIGURE !!! %%%%%%%%%%%%% path = '/archive/'; file = 'acq'; diff --git a/src/utils/matlab/plot_acq_grid_gsoc.m b/src/utils/matlab/plot_acq_grid_gsoc.m index c38d5ea18..155de2528 100644 --- a/src/utils/matlab/plot_acq_grid_gsoc.m +++ b/src/utils/matlab/plot_acq_grid_gsoc.m @@ -1,37 +1,35 @@ -% /*! -% * \file plot_acq_grid_gsoc.m -% * \brief Read GNSS-SDR Acquisition dump binary file using the provided -% function and plot acquisition grid of acquisition statistic of PRN sat +% Reads GNSS-SDR Acquisition dump binary file using the provided +% function and plots acquisition grid of acquisition statistic of PRN sat % -% This function analyzes a experiment performed by Luis Esteve in the framework +% This function analyzes a experiment performed by Luis Esteve in the framework % of the Google Summer of Code (GSoC) 2012, with the collaboration of Javier Arribas -% and Carles Fernández, related to the extension of GNSS-SDR to Galileo. +% and Carles Fern??ndez, related to the extension of GNSS-SDR to Galileo. +% +% Luis Esteve, 2012. luis(at)epsilon-formacion.com +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- % -% * \author Luis Esteve, 2012. luis(at)epsilon-formacion.com -% * ------------------------------------------------------------------------- -% * -% * Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors) -% * -% * GNSS-SDR is a software defined Global Navigation -% * Satellite Systems receiver -% * -% * This file is part of GNSS-SDR. -% * -% * GNSS-SDR is free software: you can redistribute it and/or modify -% * it under the terms of the GNU General Public License as published by -% * the Free Software Foundation, either version 3 of the License, or -% * at your option) any later version. -% * -% * GNSS-SDR is distributed in the hope that it will be useful, -% * but WITHOUT ANY WARRANTY; without even the implied warranty of -% * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% * GNU General Public License for more details. -% * -% * You should have received a copy of the GNU General Public License -% * along with GNSS-SDR. If not, see . -% * -% * ------------------------------------------------------------------------- -% */ function plot_acq_grid_gsoc(sat) @@ -61,7 +59,7 @@ for k=Doppler_min_Hz:Doppler_step_Hz:Doppler_max_Hz index=index+1; filename=['test_statistics_E_1C_sat_' num2str(sat) '_doppler_' num2str(k) '.dat']; acq_grid(index,:)=abs(read_complex_binary (filename)); - end +end maximum_correlation_peak = max(max(acq_grid)) diff --git a/src/utils/matlab/plot_acq_grid_gsoc_e5.m b/src/utils/matlab/plot_acq_grid_gsoc_e5.m index 2259c1b93..00ed7b226 100644 --- a/src/utils/matlab/plot_acq_grid_gsoc_e5.m +++ b/src/utils/matlab/plot_acq_grid_gsoc_e5.m @@ -1,39 +1,38 @@ -% /*! -% * \file plot_acq_grid_gsoc_e5.m -% * \brief Read GNSS-SDR Acquisition dump binary file using the provided -% function and plot acquisition grid of acquisition statistic of PRN sat. -% CAF input must be 0 or 1 depending if the user desires to read the file -% that resolves doppler ambiguity or not. +% Reads GNSS-SDR Acquisition dump binary file using the provided +% function and plot acquisition grid of acquisition statistic of PRN sat. +% CAF input must be 0 or 1 depending if the user desires to read the file +% that resolves doppler ambiguity or not. % -% This function analyzes a experiment performed by Marc Sales in the framework -% of the Google Summer of Code (GSoC) 2014, with the collaboration of Luis Esteve, Javier Arribas -% and Carles Fernández, related to the extension of GNSS-SDR to Galileo. +% This function analyzes a experiment performed by Marc Sales in the framework +% of the Google Summer of Code (GSoC) 2014, with the collaboration of Luis Esteve, Javier Arribas +% and Carles Fernandez, related to the extension of GNSS-SDR to Galileo. +% +% Marc Sales marcsales92(at)gmail.com, +% Luis Esteve, 2014. luis(at)epsilon-formacion.com +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- % -% * \author Marc Sales marcsales92(at)gmail.com, Luis Esteve, 2014. luis(at)epsilon-formacion.com -% * ------------------------------------------------------------------------- -% * -% * Copyright (C) 2010-2014 (see AUTHORS file for a list of contributors) -% * -% * GNSS-SDR is a software defined Global Navigation -% * Satellite Systems receiver -% * -% * This file is part of GNSS-SDR. -% * -% * GNSS-SDR is free software: you can redistribute it and/or modify -% * it under the terms of the GNU General Public License as published by -% * the Free Software Foundation, either version 3 of the License, or -% * at your option) any later version. -% * -% * GNSS-SDR is distributed in the hope that it will be useful, -% * but WITHOUT ANY WARRANTY; without even the implied warranty of -% * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% * GNU General Public License for more details. -% * -% * You should have received a copy of the GNU General Public License -% * along with GNSS-SDR. If not, see . -% * -% * ------------------------------------------------------------------------- -% */ function plot_acq_grid_gsoc_e5(sat,CAF) @@ -127,7 +126,7 @@ myFile = java.io.File(file); flen = length(myFile); num_samples=flen/8; % 8 bytes (2 single floats) per complex sample -for k=1:num_samples +for k=1:num_samples a(1:2) = fread(fid, 2, 'float'); x(k) = a(1) + a(2)*1i; k=k+1; diff --git a/src/utils/matlab/plot_acq_grid_gsoc_glonass.m b/src/utils/matlab/plot_acq_grid_gsoc_glonass.m index 9742e5107..9cc6b3ec3 100644 --- a/src/utils/matlab/plot_acq_grid_gsoc_glonass.m +++ b/src/utils/matlab/plot_acq_grid_gsoc_glonass.m @@ -1,37 +1,34 @@ -% /*! -% * \file plot_acq_grid_gsoc.m -% * \brief Read GNSS-SDR Acquisition dump binary file using the provided -% function and plot acquisition grid of acquisition statistic of PRN sat +% Reads GNSS-SDR Acquisition dump binary file using the provided +% function and plots acquisition grid of acquisition statistic of PRN sat % -% This function analyzes a experiment performed by Luis Esteve in the framework +% This function analyzes a experiment performed by Luis Esteve in the framework % of the Google Summer of Code (GSoC) 2012, with the collaboration of Javier Arribas -% and Carles Fernández, related to the extension of GNSS-SDR to Galileo. +% and Carles Fernandez, related to the extension of GNSS-SDR to Galileo. +% +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- % -% * \author Luis Esteve, 2012. luis(at)epsilon-formacion.com -% * ------------------------------------------------------------------------- -% * -% * Copyright (C) 2010-2011 (see AUTHORS file for a list of contributors) -% * -% * GNSS-SDR is a software defined Global Navigation -% * Satellite Systems receiver -% * -% * This file is part of GNSS-SDR. -% * -% * GNSS-SDR is free software: you can redistribute it and/or modify -% * it under the terms of the GNU General Public License as published by -% * the Free Software Foundation, either version 3 of the License, or -% * at your option) any later version. -% * -% * GNSS-SDR is distributed in the hope that it will be useful, -% * but WITHOUT ANY WARRANTY; without even the implied warranty of -% * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% * GNU General Public License for more details. -% * -% * You should have received a copy of the GNU General Public License -% * along with GNSS-SDR. If not, see . -% * -% * ------------------------------------------------------------------------- -% */ function plot_acq_grid_gsoc_glonass(sat) @@ -62,9 +59,9 @@ for k=Doppler_min_Hz:Doppler_step_Hz:Doppler_max_Hz index=index+1; filename=['acquisition_R_1G_sat_' num2str(sat) '_doppler_' num2str(k) '.dat']; acq_grid(index,:)=abs(read_complex_binary (filename)); - end +end - acq_grid = acq_grid.^2; +acq_grid = acq_grid.^2; maximum_correlation_peak = max(max(acq_grid)) diff --git a/src/utils/reproducibility/ieee-access18/plot_dump.m b/src/utils/reproducibility/ieee-access18/plot_dump.m index 09941acf9..202c14355 100644 --- a/src/utils/reproducibility/ieee-access18/plot_dump.m +++ b/src/utils/reproducibility/ieee-access18/plot_dump.m @@ -1,32 +1,28 @@ -% /*! -% * \file plot_dump.m -% * \brief Read GNSS-SDR Tracking dump binary file and plot some internal -% variables -% * \author Antonio Ramos, 2018. antonio.ramos(at)cttc.es -% * ------------------------------------------------------------------------- -% * -% * Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) -% * -% * GNSS-SDR is a software defined Global Navigation -% * Satellite Systems receiver -% * -% * This file is part of GNSS-SDR. -% * -% * GNSS-SDR is free software: you can redistribute it and/or modify -% * it under the terms of the GNU General Public License as published by -% * the Free Software Foundation, either version 3 of the License, or -% * at your option) any later version. -% * -% * GNSS-SDR is distributed in the hope that it will be useful, -% * but WITHOUT ANY WARRANTY; without even the implied warranty of -% * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -% * GNU General Public License for more details. -% * -% * You should have received a copy of the GNU General Public License -% * along with GNSS-SDR. If not, see . -% * -% * ------------------------------------------------------------------------- -% */ +% ------------------------------------------------------------------------- +% +% Copyright (C) 2010-2018 (see AUTHORS file for a list of contributors) +% +% GNSS-SDR is a software defined Global Navigation +% Satellite Systems receiver +% +% This file is part of GNSS-SDR. +% +% GNSS-SDR is free software: you can redistribute it and/or modify +% it under the terms of the GNU General Public License as published by +% the Free Software Foundation, either version 3 of the License, or +% at your option) any later version. +% +% GNSS-SDR is distributed in the hope that it will be useful, +% but WITHOUT ANY WARRANTY; without even the implied warranty of +% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +% GNU General Public License for more details. +% +% You should have received a copy of the GNU General Public License +% along with GNSS-SDR. If not, see . +% +% ------------------------------------------------------------------------- +% +% Antonio Ramos, 2018. antonio.ramos(at)cttc.es clear all; clc; @@ -84,158 +80,136 @@ end fclose(fileID); -mean_Latitude=mean(navsol.lat); -mean_Longitude=mean(navsol.long); -mean_h=mean(navsol.height); -utmZone = findUtmZone(mean_Latitude,mean_Longitude); -[ref_X_cart,ref_Y_cart,ref_Z_cart]=geo2cart(dms2mat(deg2dms(mean_Latitude)), dms2mat(deg2dms(mean_Longitude)), mean_h, 5); -[mean_utm_X,mean_utm_Y,mean_utm_Z]=cart2utm(ref_X_cart,ref_Y_cart,ref_Z_cart,utmZone); +mean_Latitude = mean(navsol.lat); +mean_Longitude = mean(navsol.long); +mean_h = mean(navsol.height); +utmZone = findUtmZone(mean_Latitude, mean_Longitude); +[ref_X_cart, ref_Y_cart, ref_Z_cart] = geo2cart(dms2mat(deg2dms(mean_Latitude)), dms2mat(deg2dms(mean_Longitude)), mean_h, 5); +[mean_utm_X, mean_utm_Y, mean_utm_Z] = cart2utm(ref_X_cart, ref_Y_cart, ref_Z_cart, utmZone); -numPoints=length(navsol.X); -aux=0; -for n=1:numPoints - aux=aux+1; - [E(aux),N(aux),U(aux)]=cart2utm(navsol.X(n), navsol.Y(n), navsol.Z(n), utmZone); +numPoints = length(navsol.X); +aux = 0; +for n = 1:numPoints + aux = aux+1; + [E(aux), N(aux), U(aux)] = cart2utm(navsol.X(n), navsol.Y(n), navsol.Z(n), utmZone); end -v_2d=[E;N].'; %2D East Nort position vectors -v_3d=[E;N;U].'; %2D East Nort position vectors +v_2d = [E;N].'; % 2D East Nort position vectors +v_3d = [E;N;U].'; % 2D East Nort position vectors %% ACCURACY % 2D ------------------- -sigma_E_accuracy=sqrt((1/(numPoints-1))*sum((v_2d(:,1)-mean_utm_X).^2)); -sigma_N_accuracy=sqrt((1/(numPoints-1))*sum((v_2d(:,2)-mean_utm_Y).^2)); - -sigma_ratio_2d_accuracy=sigma_N_accuracy/sigma_E_accuracy +sigma_E_accuracy = sqrt((1/(numPoints-1)) * sum((v_2d(:,1) - mean_utm_X).^2)); +sigma_N_accuracy = sqrt((1/(numPoints-1)) * sum((v_2d(:,2) - mean_utm_Y).^2)); +sigma_ratio_2d_accuracy = sigma_N_accuracy / sigma_E_accuracy % if sigma_ratio=1 -> Prob in circle with r=DRMS -> 65% -DRMS_accuracy=sqrt(sigma_E_accuracy^2+sigma_N_accuracy^2) +DRMS_accuracy = sqrt(sigma_E_accuracy^2 + sigma_N_accuracy^2) % if sigma_ratio=1 -> Prob in circle with r=2DRMS -> 95% -TWO_DRMS_accuracy=2*DRMS_accuracy +TWO_DRMS_accuracy = 2 * DRMS_accuracy % if sigma_ratio>0.3 -> Prob in circle with r=CEP -> 50% -CEP_accuracy=0.62*sigma_E_accuracy+0.56*sigma_N_accuracy +CEP_accuracy = 0.62 * sigma_E_accuracy + 0.56 * sigma_N_accuracy % 3D ------------------- -sigma_U_accuracy=sqrt((1/(numPoints-1))*sum((v_3d(:,3)-mean_utm_Z).^2)); +sigma_U_accuracy = sqrt((1/(numPoints-1)) * sum((v_3d(:,3) - mean_utm_Z).^2)); % if sigma_ratio=1 -> Prob in circle with r=DRMS -> 50% -SEP_accuracy=0.51*sqrt(sigma_E_accuracy^2+sigma_N_accuracy^2+sigma_U_accuracy^2) - +SEP_accuracy = 0.51 * sqrt(sigma_E_accuracy^2 + sigma_N_accuracy^2 + sigma_U_accuracy^2) % if sigma_ratio=1 -> Prob in circle with r=DRMS -> 61% -MRSE_accuracy=sqrt(sigma_E_accuracy^2+sigma_N_accuracy^2+sigma_U_accuracy^2) +MRSE_accuracy = sqrt(sigma_E_accuracy^2 + sigma_N_accuracy^2 + sigma_U_accuracy^2) % if sigma_ratio=1 -> Prob in circle with r=2DRMS -> 95% -TWO_MRSE_accuracy=2*MRSE_accuracy +TWO_MRSE_accuracy=2 * MRSE_accuracy %% PRECISION -% 2D analysis -% Simulated X,Y measurements -%v1=randn(1000,2); - % 2D Mean and Variance mean_2d = [mean(v_2d(:,1)) ; mean(v_2d(:,2))]; sigma_2d = [sqrt(var(v_2d(:,1))) ; sqrt(var(v_2d(:,2)))]; - -sigma_ratio_2d=sigma_2d(2)/sigma_2d(1) +sigma_ratio_2d = sigma_2d(2) / sigma_2d(1) % if sigma_ratio=1 -> Prob in circle with r=DRMS -> 65% -DRMS=sqrt(sigma_2d(1)^2+sigma_2d(2)^2) +DRMS = sqrt(sigma_2d(1)^2 + sigma_2d(2)^2) % if sigma_ratio=1 -> Prob in circle with r=2DRMS -> 95% -TWO_DRMS=2*DRMS +TWO_DRMS = 2 * DRMS % if sigma_ratio>0.3 -> Prob in circle with r=CEP -> 50% -CEP=0.62*sigma_2d(1)+0.56*sigma_2d(2) +CEP = 0.62 * sigma_2d(1) + 0.56 * sigma_2d(2) - -% Mean and Variance -mean_3d=[mean(v_3d(:,1)) ; mean(v_3d(:,2)) ; mean(v_3d(:,3))]; -sigma_3d=[sqrt(var(v_3d(:,1))) ; sqrt(var(v_3d(:,2))) ; sqrt(var(v_3d(:,3)))]; +% 3D Mean and Variance +mean_3d = [mean(v_3d(:,1)) ; mean(v_3d(:,2)) ; mean(v_3d(:,3))]; +sigma_3d = [sqrt(var(v_3d(:,1))) ; sqrt(var(v_3d(:,2))) ; sqrt(var(v_3d(:,3)))]; % absolute mean error -% 2D +error_2D_vec = [mean_utm_X-mean_2d(1) mean_utm_Y-mean_2d(2)]; +error_2D_m = norm(error_2D_vec) -error_2D_vec=[mean_utm_X-mean_2d(1) mean_utm_Y-mean_2d(2)]; -error_2D_m=norm(error_2D_vec) +error_3D_vec = [mean_utm_X-mean_3d(1) mean_utm_Y-mean_3d(2) mean_utm_Z-mean_3d(3)]; +error_3D_m = norm(error_3D_vec) -error_3D_vec=[mean_utm_X-mean_3d(1) mean_utm_Y-mean_3d(2) mean_utm_Z-mean_3d(3)]; -error_3D_m=norm(error_3D_vec) +RMSE_X = sqrt(mean((v_3d(:,1)-mean_utm_X).^2)) +RMSE_Y = sqrt(mean((v_3d(:,2)-mean_utm_Y).^2)) +RMSE_Z = sqrt(mean((v_3d(:,3)-mean_utm_Z).^2)) -% RMSE 2D +RMSE_2D = sqrt(mean((v_2d(:,1)-mean_utm_X).^2 + (v_2d(:,2)-mean_utm_Y).^2)) +RMSE_3D = sqrt(mean((v_3d(:,1)-mean_utm_X).^2 + (v_3d(:,2)-mean_utm_Y).^2 + (v_3d(:,3)-mean_utm_Z).^2)) -RMSE_X=sqrt(mean((v_3d(:,1)-mean_utm_X).^2)) -RMSE_Y=sqrt(mean((v_3d(:,2)-mean_utm_Y).^2)) -RMSE_Z=sqrt(mean((v_3d(:,3)-mean_utm_Z).^2)) +% if sigma_ratio=1 -> Prob in circle with r=DRMS -> 50% +SEP = 0.51 * sqrt(sigma_3d(1)^2 + sigma_3d(2)^2 + sigma_3d(3)^2) +% if sigma_ratio=1 -> Prob in circle with r=DRMS -> 61% +MRSE = sqrt(sigma_3d(1)^2 + sigma_3d(2)^2 + sigma_3d(3)^2) +% if sigma_ratio=1 -> Prob in circle with r=2DRMS -> 95% +TWO_MRSE = 2 * MRSE -RMSE_2D=sqrt(mean((v_2d(:,1)-mean_utm_X).^2+(v_2d(:,2)-mean_utm_Y).^2)) - -RMSE_3D=sqrt(mean((v_3d(:,1)-mean_utm_X).^2+(v_3d(:,2)-mean_utm_Y).^2+(v_3d(:,3)-mean_utm_Z).^2)) - -% SCATTER PLOT +%% SCATTER PLOT 2D subplot(3,3,8) -scatter(v_2d(:,1)-mean_2d(1),v_2d(:,2)-mean_2d(2)); +scatter(v_2d(:,1)-mean_2d(1), v_2d(:,2)-mean_2d(2)); hold on; -plot(0,0,'k*'); +plot(0, 0, 'k*'); +[x,y,z] = cylinder([TWO_DRMS TWO_DRMS], 200); +plot(x(1,:), y(1,:), 'Color', [0 0.6 0]); +str = strcat('2DRMS=', num2str(TWO_DRMS), ' m'); +text(cosd(65)*TWO_DRMS, sind(65)*TWO_DRMS, str, 'Color', [0 0.6 0]); -[x,y,z] = cylinder([TWO_DRMS TWO_DRMS],200); -plot(x(1,:),y(1,:),'Color',[0 0.6 0]); -str = strcat('2DRMS=',num2str(TWO_DRMS), ' m'); -text(cosd(65)*TWO_DRMS,sind(65)*TWO_DRMS,str,'Color',[0 0.6 0]); - - -[x,y,z] = cylinder([CEP CEP],200); - -plot(x(1,:),y(1,:),'r--'); -str = strcat('CEP=',num2str(CEP), ' m'); -text(cosd(80)*CEP,sind(80)*CEP,str,'Color','r'); +[x,y,z] = cylinder([CEP CEP], 200); +plot(x(1,:), y(1,:), 'r--'); +str = strcat('CEP=', num2str(CEP), ' m'); +text(cosd(80)*CEP, sind(80)*CEP, str, 'Color','r'); grid on axis equal; xlabel('North [m]','fontname','Times','fontsize', fontsize) ylabel('East [m]','fontname','Times','fontsize', fontsize) -% 3D analysis -% Simulated X,Y,Z measurements - -% if sigma_ratio=1 -> Prob in circle with r=DRMS -> 50% -SEP=0.51*sqrt(sigma_3d(1)^2+sigma_3d(2)^2+sigma_3d(3)^2) - -% if sigma_ratio=1 -> Prob in circle with r=DRMS -> 61% -MRSE=sqrt(sigma_3d(1)^2+sigma_3d(2)^2+sigma_3d(3)^2) -% if sigma_ratio=1 -> Prob in circle with r=2DRMS -> 95% -TWO_MRSE=2*MRSE - -% SCATTER PLOT +%% SCATTER PLOT 3D subplot(3,3,9) -scatter3(v_3d(:,1)-mean_3d(1),v_3d(:,2)-mean_3d(2), v_3d(:,3)-mean_3d(3)); +scatter3(v_3d(:,1)-mean_3d(1), v_3d(:,2)-mean_3d(2), v_3d(:,3)-mean_3d(3)); hold on; [x,y,z] = sphere(); -hSurface=surf(MRSE*x,MRSE*y,MRSE*z); % sphere centered at origin +hSurface = surf(MRSE*x, MRSE*y, MRSE*z); % sphere centered at origin +set(hSurface, 'facecolor', 'none', 'edgecolor', [0 0.6 0], 'edgealpha', 1, 'facealpha', 1); -set(hSurface,'facecolor','none','edgecolor',[0 0.6 0],'edgealpha',1,'facealpha',1); +xlabel('North [m]', 'fontname', 'Times', 'fontsize', fontsize-2) +ylabel('East [m]', 'fontname', 'Times', 'fontsize', fontsize-2) +zlabel('Up [m]', 'fontname', 'Times', 'fontsize', fontsize-2) +str = strcat('MRSE=', num2str(MRSE), ' m') +text(cosd(45)*MRSE, sind(45)*MRSE, 20, str, 'Color', [0 0.6 0]); +a = gca; +set(a, 'fontsize', fontsize-6) -%axis equal; -xlabel('North [m]','fontname','Times','fontsize', fontsize-2) -ylabel('East [m]','fontname','Times','fontsize', fontsize-2) -zlabel('Up [m]','fontname','Times','fontsize', fontsize-2) -str = strcat('MRSE=',num2str(MRSE), ' m') -text(cosd(45)*MRSE,sind(45)*MRSE,20,str,'Color',[0 0.6 0]); -a=gca; -set(a,'fontsize',fontsize-6) - -hh=findall(hf,'-property','FontName'); -set(hh,'FontName','Times'); +hh = findall(hf, '-property', 'FontName'); +set(hh, 'FontName', 'Times'); print(hf, 'Figure2.eps', '-depsc') close(hf);