00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef DBA_AOF_IMPORTERS_COMMON_H
00023 #define DBA_AOF_IMPORTERS_COMMON_H
00024
00025
00026 #define _ISOC99_SOURCE
00027
00028
00029
00030
00031
00032 #include <dballe/core/conv.h>
00033 #include <dballe/msg/msg.h>
00034
00035 #include <stdio.h>
00036 #include <stdint.h>
00037 #include <math.h>
00038
00039
00040
00041 #ifdef TRACE_DECODER
00042 #define TRACE(...) fprintf(stderr, __VA_ARGS__)
00043 #define IFTRACE if (1)
00044 #else
00045 #define TRACE(...) do { } while (0)
00046 #define IFTRACE if (0)
00047 #endif
00048
00049 #define AOF_UNDEF 0x7fffffff
00050
00051 #define OBS(n) (obs[n-1])
00052
00053
00054
00055 static inline int get_conf2(int conf)
00056 {
00057 switch (conf & 3)
00058 {
00059 case 0: return 76; break;
00060 case 1: return 51; break;
00061 case 2: return 26; break;
00062 case 3: return 0; break;
00063 }
00064 return 0;
00065 }
00066
00067
00068 static inline int get_conf6(int conf)
00069 {
00070 return get_conf2(conf >> 3);
00071 }
00072
00073
00074 static inline double totemp(double k) { return k / 10.0; }
00075
00076
00077 void dba_aof_dump_word(const char* prefix, uint32_t x);
00078
00079
00080 dba_err dba_aof_parse_lat_lon_datetime(dba_msg msg, const uint32_t* obs);
00081
00082
00083 dba_err dba_aof_parse_st_block_station(dba_msg msg, const uint32_t* obs);
00084
00085
00086 dba_err dba_aof_parse_st_ident(dba_msg msg, const uint32_t* obs);
00087
00088
00089 dba_err dba_aof_parse_altitude(dba_msg msg, const uint32_t* obs);
00090
00091
00092 dba_err dba_aof_parse_weather_group(dba_msg msg, const uint32_t* obs);
00093
00094
00095 dba_err dba_aof_parse_general_cloud_group(dba_msg msg, const uint32_t* obs);
00096
00097
00098 dba_err dba_aof_parse_cloud_group(uint32_t val, int* ns, int* c, int* h);
00099
00100 uint32_t dba_aof_get_extra_conf(const uint32_t* obs, int idx);
00101
00102
00103 static inline int count_bits(uint32_t v)
00104 {
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122 unsigned int c;
00123 for (c = 0; v; c++)
00124 {
00125 v &= v - 1;
00126 }
00127
00128 return c;
00129 }
00130
00131
00132 #endif