nmxp_chan.h 2.44 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*! \file
 *
 * \brief Channels for Nanometrics Protocol Libray
 *
 * Author:
 * 	Matteo Quintiliani
 * 	Istituto Nazionale di Geofisica e Vulcanologia - Italy
 *	quintiliani@ingv.it
 *
 */

#ifndef NMXP_CHAN_H
#define NMXP_CHAN_H 1

#include <sys/types.h>

/*! \brief The key/name info for one channel */
Matteo Quintiliani's avatar
Matteo Quintiliani committed
18
typedef struct {
19
20
    uint32_t key;
    char name[12];
Matteo Quintiliani's avatar
Matteo Quintiliani committed
21
} NMXP_CHAN_KEY;
22

Matteo Quintiliani's avatar
Matteo Quintiliani committed
23
/*! \brief Max number of channels */
24
#define MAX_N_CHAN 1000
Matteo Quintiliani's avatar
Matteo Quintiliani committed
25
26
27

/*! \brief Channel list */
typedef struct {
28
    uint32_t number;
Matteo Quintiliani's avatar
Matteo Quintiliani committed
29
30
    NMXP_CHAN_KEY channel[MAX_N_CHAN];
} NMXP_CHAN_LIST;
31
32


Matteo Quintiliani's avatar
Matteo Quintiliani committed
33
34
35
36
37
38
39
40
/*! \brief Type of Data */
typedef enum {
    NMXP_DATA_TIMESERIES	= 1,
    NMXP_DATA_SOH		= 2,
    NMXP_DATA_TRANSERIAL	= 6
} NMXP_DATATYPE;


41
42
43
44
/*! \brief Character separator for channel list */
#define sep_chan_list  ','


45
46
47
48
/*! \brief Return type of data from a channel key */
#define getDataTypeFromKey(key) ((key >> 8) & 0xff)


49
/*! \brief Looks up a channel key in the list using the name
50
 *
Matteo Quintiliani's avatar
Matteo Quintiliani committed
51
52
 * \param name Channel name.
 * \param channelList Channel list.
53
 *
Matteo Quintiliani's avatar
Matteo Quintiliani committed
54
 * \return Key of the channel with name. -1 On error.
55
56
 *
 */
Matteo Quintiliani's avatar
Matteo Quintiliani committed
57
int nmxp_chan_lookupKey(char* name, NMXP_CHAN_LIST *channelList);
58

59
/*! \brief Looks up a channel name in the list using a key
60
 *
Matteo Quintiliani's avatar
Matteo Quintiliani committed
61
62
 * \param key Channel key.
 * \param channelList Channel list.
63
 *
Matteo Quintiliani's avatar
Matteo Quintiliani committed
64
 * \return Name of channel with key. NULL on error.
65
66
 *
 */
Matteo Quintiliani's avatar
Matteo Quintiliani committed
67
char *nmxp_chan_lookupName(uint32_t key, NMXP_CHAN_LIST *channelList);
68

69

70
71
72
73
74
75
76
77
78
79
/*! \brief Looks up a channel with specified data type.
 *
 * \param channelList Channel list.
 * \param dataType Type of channel.
 *
 * \return Channel list with specified dataType. It will need to be freed!
 *
 * \warning Returned value will need to be freed!
 *
 */
Matteo Quintiliani's avatar
Matteo Quintiliani committed
80
NMXP_CHAN_LIST *nmxp_chan_getType(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE dataType);
81

82

83
84
85
86
/*! \brief Looks up a channel with specified data type.
 *
 * \param channelList Channel list.
 * \param dataType Type of channel.
87
 * \param sta_chan_list String list of item STA.CHAN, separeted by comma.
88
89
90
91
92
93
94
95
96
 *
 * \return Channel list with specified dataType. It will need to be freed!
 *
 * \warning Returned value will need to be freed!
 *
 */
NMXP_CHAN_LIST *nmxp_chan_subset(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE dataType, char *sta_chan_list);


97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*! Sort list by channel key
 *
 * \param channelList Channel List
 *
 */
void nmxp_chan_sortByKey(NMXP_CHAN_LIST *channelList);


/*! Sort list by channel name
 *
 * \param channelList Channel List
 *
 */
void nmxp_chan_sortByName(NMXP_CHAN_LIST *channelList);

112
113
#endif