1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
.. _`odc-encode-custom`:
Custom Encoding
===============
Shown below is a simple program that encodes sample data using a customised, periodic memory layout specified for each of the columns independently, before outputting an ODB-2 file.
.. tabs::
.. group-tab:: C
.. literalinclude:: ../../../tests/c_api/odc_encode_custom.c
:language: c
:class: copybutton
To use this sample program, invoke it from the command line with a path to an ODB-2 output file:
.. code-block:: none
./odc-c-encode-custom example.odb
Written 20 rows to example.odb
.. code-block:: none
odc ls example.odb
expver date@hdr statid@hdr wigos@hdr obsvalue@body integer_missing double_missing bitfield_column
'xxxx' 20210524 'stat00' '0-12345-0-67800' 0.000000 1234 12.340000 1
'xxxx' 20210524 'stat01' '0-12345-0-67801' 12.345600 4321 43.209999 11
'xxxx' 20210524 'stat02' '0-12345-0-67802' 24.691200 . . 107
'xxxx' 20210524 'stat03' '0-12345-0-67803' 37.036800 1234 12.340000 1
'xxxx' 20210524 'stat04' '0-12345-0-67804' 49.382401 4321 43.209999 11
'xxxx' 20210524 'stat05' '0-12345-0-67805' 61.728001 . . 107
'xxxx' 20210524 'stat06' '0-12345-0-67806' 74.073601 1234 12.340000 1
'xxxx' 20210524 'stat07' '0-12345-0-67807' 86.419197 4321 43.209999 11
'xxxx' 20210524 'stat08' '0-12345-0-67808' 98.764801 . . 107
'xxxx' 20210524 'stat09' '0-12345-0-67809' 111.110397 1234 12.340000 1
'xxxx' 20210524 'stat10' '0-12345-0-67810' 123.456001 4321 43.209999 11
'xxxx' 20210524 'stat11' '0-12345-0-67811' 135.801605 . . 107
'xxxx' 20210524 'stat12' '0-12345-0-67812' 148.147202 1234 12.340000 1
'xxxx' 20210524 'stat13' '0-12345-0-67813' 160.492798 4321 43.209999 11
'xxxx' 20210524 'stat14' '0-12345-0-67814' 172.838394 . . 107
'xxxx' 20210524 'stat15' '0-12345-0-67815' 185.184006 1234 12.340000 1
'xxxx' 20210524 'stat16' '0-12345-0-67816' 197.529602 4321 43.209999 11
'xxxx' 20210524 'stat17' '0-12345-0-67817' 209.875198 . . 107
'xxxx' 20210524 'stat18' '0-12345-0-67818' 222.220795 1234 12.340000 1
'xxxx' 20210524 'stat19' '0-12345-0-67819' 234.566406 4321 43.209999 11
000 2021-05-24 14:06:05 (I) Selected 20 row(s).
.. group-tab:: C++
.. literalinclude:: ../../../tests/api/odc_encode_custom.cc
:language: cpp
:class: copybutton
To use this sample program, invoke it from the command line with a path to an ODB-2 output file:
.. code-block:: none
./odc-cpp-encode-custom example.odb
Written 20 rows to example.odb
.. code-block:: none
odc ls example.odb
expver date@hdr statid@hdr wigos@hdr obsvalue@body integer_missing double_missing bitfield_column
'xxxx' 20210524 'stat00' '0-12345-0-67800' 0.000000 1234 12.340000 1
'xxxx' 20210524 'stat01' '0-12345-0-67801' 12.345600 4321 43.209999 11
'xxxx' 20210524 'stat02' '0-12345-0-67802' 24.691200 . . 107
'xxxx' 20210524 'stat03' '0-12345-0-67803' 37.036800 1234 12.340000 1
'xxxx' 20210524 'stat04' '0-12345-0-67804' 49.382401 4321 43.209999 11
'xxxx' 20210524 'stat05' '0-12345-0-67805' 61.728001 . . 107
'xxxx' 20210524 'stat06' '0-12345-0-67806' 74.073601 1234 12.340000 1
'xxxx' 20210524 'stat07' '0-12345-0-67807' 86.419197 4321 43.209999 11
'xxxx' 20210524 'stat08' '0-12345-0-67808' 98.764801 . . 107
'xxxx' 20210524 'stat09' '0-12345-0-67809' 111.110397 1234 12.340000 1
'xxxx' 20210524 'stat10' '0-12345-0-67810' 123.456001 4321 43.209999 11
'xxxx' 20210524 'stat11' '0-12345-0-67811' 135.801605 . . 107
'xxxx' 20210524 'stat12' '0-12345-0-67812' 148.147202 1234 12.340000 1
'xxxx' 20210524 'stat13' '0-12345-0-67813' 160.492798 4321 43.209999 11
'xxxx' 20210524 'stat14' '0-12345-0-67814' 172.838394 . . 107
'xxxx' 20210524 'stat15' '0-12345-0-67815' 185.184006 1234 12.340000 1
'xxxx' 20210524 'stat16' '0-12345-0-67816' 197.529602 4321 43.209999 11
'xxxx' 20210524 'stat17' '0-12345-0-67817' 209.875198 . . 107
'xxxx' 20210524 'stat18' '0-12345-0-67818' 222.220795 1234 12.340000 1
'xxxx' 20210524 'stat19' '0-12345-0-67819' 234.566406 4321 43.209999 11
000 2021-05-24 14:17:09 (I) Selected 20 row(s).
.. group-tab:: Fortran
.. literalinclude:: ../../../tests/f_api/odc_encode_custom.f90
:language: fortran
:class: copybutton
To use this sample program, invoke it from the command line with a path to an ODB-2 output file:
.. code-block:: none
./odc-fortran-encode-custom example.odb
Written 20 rows to example.odb
.. code-block:: none
odc ls example.odb
expver date@hdr statid@hdr wigos@hdr obsvalue@body integer_missing double_missing bitfield_column
'xxxx' 20210524 'stat00' '0-12345-0-67800' 0.000000 1234 12.340000 1
'xxxx' 20210524 'stat01' '0-12345-0-67801' 12.345600 4321 43.209999 11
'xxxx' 20210524 'stat02' '0-12345-0-67802' 24.691200 . . 107
'xxxx' 20210524 'stat03' '0-12345-0-67803' 37.036800 1234 12.340000 1
'xxxx' 20210524 'stat04' '0-12345-0-67804' 49.382401 4321 43.209999 11
'xxxx' 20210524 'stat05' '0-12345-0-67805' 61.728001 . . 107
'xxxx' 20210524 'stat06' '0-12345-0-67806' 74.073601 1234 12.340000 1
'xxxx' 20210524 'stat07' '0-12345-0-67807' 86.419205 4321 43.209999 11
'xxxx' 20210524 'stat08' '0-12345-0-67808' 98.764801 . . 107
'xxxx' 20210524 'stat09' '0-12345-0-67809' 111.110397 1234 12.340000 1
'xxxx' 20210524 'stat10' '0-12345-0-67810' 123.456001 4321 43.209999 11
'xxxx' 20210524 'stat11' '0-12345-0-67811' 135.801605 . . 107
'xxxx' 20210524 'stat12' '0-12345-0-67812' 148.147202 1234 12.340000 1
'xxxx' 20210524 'stat13' '0-12345-0-67813' 160.492798 4321 43.209999 11
'xxxx' 20210524 'stat14' '0-12345-0-67814' 172.838409 . . 107
'xxxx' 20210524 'stat15' '0-12345-0-67815' 185.184006 1234 12.340000 1
'xxxx' 20210524 'stat16' '0-12345-0-67816' 197.529602 4321 43.209999 11
'xxxx' 20210524 'stat17' '0-12345-0-67817' 209.875198 . . 107
'xxxx' 20210524 'stat18' '0-12345-0-67818' 222.220795 1234 12.340000 1
'xxxx' 20210524 'stat19' '0-12345-0-67819' 234.566406 4321 43.209999 11
000 2021-05-24 14:38:35 (I) Selected 20 row(s).
|