Commit 3bc7baf0 authored by Matteo Quintiliani's avatar Matteo Quintiliani

Added capability to specify the location code within the channel pattern declaration

git-svn-id: file:///home/quintiliani/svncopy/nmxptool/trunk@1396 3cd66e75-5955-46cb-a940-c26e5fc5497d
parent 9d85a036
...@@ -3,6 +3,8 @@ nmxptool Release History ...@@ -3,6 +3,8 @@ nmxptool Release History
######################### #########################
* Release 2.1.0-rc1 (2012/02/07) * Release 2.1.0-rc1 (2012/02/07)
- Added capability to specify the location code within the channel
pattern declaration (options -C, -n).
- Incremented value of NMXP_MAX_LENGTH_DATA_BUFFER. - Incremented value of NMXP_MAX_LENGTH_DATA_BUFFER.
* Release 2.0.0 (2010/10/22) * Release 2.0.0 (2010/10/22)
......
#!/bin/sh #!/bin/sh
glibtoolize --force --copy && autoheader && aclocal && autoconf && automake -a -c # glibtoolize --force --copy && autoheader && aclocal && autoconf && automake -a -c
glibtoolize --copy && autoheader && aclocal && autoconf && automake -a
...@@ -10,10 +10,10 @@ m4_define([full_package_name], [nmxptool]) ...@@ -10,10 +10,10 @@ m4_define([full_package_name], [nmxptool])
dnl These three define the plug-in version number dnl These three define the plug-in version number
m4_define([major_version], [2]) m4_define([major_version], [2])
m4_define([minor_version], [0]) m4_define([minor_version], [1])
m4_define([micro_version], [0]) m4_define([micro_version], [0])
# Comment build_version for stable release # Comment build_version for stable release
# m4_define([build_version], [beta3]) m4_define([build_version], [rc1])
m4_ifdef([build_version], [ m4_ifdef([build_version], [
m4_define([version], m4_define([version],
......
...@@ -59,18 +59,22 @@ MaxTolerableLatency 60 # Raw Stream, NOT use 'ShortTermComplet ...@@ -59,18 +59,22 @@ MaxTolerableLatency 60 # Raw Stream, NOT use 'ShortTermComplet
DefaultNetworkCode IV # Default network code where in 'ChannelFile' or 'Channel' is not declared. DefaultNetworkCode IV # Default network code where in 'ChannelFile' or 'Channel' is not declared.
# It is equivalent to the option -N. # It is equivalent to the option -N.
# DefaultLocationCode 01 # Default location code where in 'ChannelFile' or 'Channel' is not declared.
# It is equivalent to the option -n. (Default is NULL location)
# N.B. nmxptool channel definition IS NOT equal to SCNL # N.B. nmxptool channel definition IS NOT equal to SCNL
# It is NSC, that is NET.STA.CHAN # It is NSCL, that is NET.STA.CHAN.LOC
# NET is optional and used only for output. # NET is optional and used only for output.
# STA can be '*', stands for all stations. # STA can be '*', stands for all stations.
# CHAN can contain '?', stands for any character. # CHAN can contain '?', stands for any character.
# Localtion value is always equal to "--". # LOC is optional and used only for output.
# Related to the parameters 'ChannelFile' and 'Channel'. # Related to the parameters 'ChannelFile' and 'Channel'.
# Network code will be assigned from the first # Network and location code will be assigned from the
# pattern that includes station and channel. # first pattern that include station and channel.
# Example: N1.AAA.HH?,N2.*.HH?,MMM.BH? # Example: N1.AAA.HH?.01,N2.*.HH?,MMM.BH?.03
# Second pattern includes the first. Unless AAA, all # Second pattern includes the first. Unless AAA, all
# stations with HH channels will have network to N2. # stations with HH channels will have network to N2.
# Stations N2.*.HH? will have default location defined by 'DefaultLocationCode'.
# Station MMM will have default network defined by 'DefaultNetworkCode'. # Station MMM will have default network defined by 'DefaultNetworkCode'.
#MaxDataToRetrieve 3600 # Max amount of data of the past to retrieve from the #MaxDataToRetrieve 3600 # Max amount of data of the past to retrieve from the
...@@ -114,9 +118,9 @@ ChannelFile /home/ew/nmxptool.list.txt # List of channel patterns, as in 'Chan ...@@ -114,9 +118,9 @@ ChannelFile /home/ew/nmxptool.list.txt # List of channel patterns, as in 'Chan
# Channel ES.BOB.HH? # Channel ES.BOB.HH?
# Channel MN.TIR.HH? # Channel MN.TIR.HH?
# Channel MDI.HH? # Channel MDI.HH?
# Channel DOI.HH? # Channel DOI.HH?.01
# Channel SALO.HH? # Channel SALO.HH?
# Channel MONC.HH? # Channel IV.MONC.HH?.03
# Channel *.BHZ # Channel selection # Channel *.BHZ # Channel selection
# Please, for other details about parameters, refer to the command line "nmxptool -h" # Please, for other details about parameters, refer to the command line "nmxptool -h"
......
...@@ -57,6 +57,7 @@ Nanometrics server and connection parameters:<br> ...@@ -57,6 +57,7 @@ Nanometrics server and connection parameters:<br>
<a href="#TimeoutRecv">TimeoutRecv</a> optional<br> <a href="#TimeoutRecv">TimeoutRecv</a> optional<br>
<a href="#mschan">mschan</a> optional<br> <a href="#mschan">mschan</a> optional<br>
<a href="#DefaultNetworkCode">DefaultNetworkCode</a> optional<br> <a href="#DefaultNetworkCode">DefaultNetworkCode</a> optional<br>
<a href="#DefaultLocationCode">DefaultLocationCode</a> optional<br>
<a href="#ChannelFile">ChannelFile</a> required Xor Channel<br> <a href="#ChannelFile">ChannelFile</a> required Xor Channel<br>
<a href="#Channel">Channel</a> required Xor ChannelFile<br> <a href="#Channel">Channel</a> required Xor ChannelFile<br>
<br> <br>
...@@ -82,20 +83,22 @@ and example commands are listed after each command description. </p> ...@@ -82,20 +83,22 @@ and example commands are listed after each command description. </p>
<pre><a name="Channel"><b>Channel <font color="red">streamkey</font> ReadConfig nmxptool parameters<br></b><!-- command args ... --> <br></a></pre> <pre><a name="Channel"><b>Channel <font color="red">streamkey</font> ReadConfig nmxptool parameters<br></b><!-- command args ... --> <br></a></pre>
<blockquote><!-- command description goes here --> Specifies one stream <blockquote><!-- command description goes here --> Specifies one stream
of data to be requested from the NmxpHost. of data to be requested from the NmxpHost.
The <font color="red">streamkey</font> is not in SCNL format. It is composed of a network, station and channel code The <font color="red">streamkey</font> is not in SCNL format. It is composed of a network, station, channel and location code
separated by period. network is optional and it is used only for output. separated by period. network and location are optional and they are used only for output.
Station code can be &quot;&#42;&quot; that stands for all stations. Station code can be &quot;&#42;&quot; that stands for all stations.
Within channel code can appear character &quot;&#63;&quot; that stands for any characters. Location value is always set to &quot;--&quot;. Within channel code can appear character &quot;&#63;&quot; that stands for any characters. Default location is NULL and printed out as &quot;--&quot;.
DO NOT USE WITH <a href="#ChannelFile">ChannelFile</a>! DO NOT USE WITH <a href="#ChannelFile">ChannelFile</a>!
<pre> <pre>
Default: none Default: none
Example: Channel ES.BOB.HH? Example: Channel ES.BOB.HH?
Channel MN.TIR.HH? Channel MN.TIR.HH?
Channel SALO.HH? Channel IV.MVVM.HH?.01
Channel SALO.HH?.03
Channel *.HHZ Channel *.HHZ
N.B. Network code will be assigned from the first pattern that includes station and channel. N.B. Network and location code will be assigned from the first pattern that includes station and channel.
Unless HH channels of BOB and TIR, all other stations will have default network code from <a href="#DefaultNetworkCode">DefaultNetworkCode</a>. Unless HH channels of BOB, TIR and MVVM, all other stations will have default network code from <a href="#DefaultNetworkCode">DefaultNetworkCode</a>.
Unless HH channels of MVVM and SALO, all other stations will have NULL location or the default location code from <a href="#DefaultLocationCode">DefaultLocationCode</a>, if it is declared.
</pre> </pre>
</blockquote> </blockquote>
...@@ -113,34 +116,60 @@ Default: none ...@@ -113,34 +116,60 @@ Default: none
Example: ChannelFile /home/ew/list_channels_naqs1.txt Example: ChannelFile /home/ew/list_channels_naqs1.txt
Example of file created by the user: Example of file created by the user:
ES.BOB.HH? TIR.HHZ.01
MN.TIR.HH? ARCI.HHZ.02
SALO.HH? MM.JOPP.HHZ
*.HH? OO.FRES.HHZ
N.B. Network code will be assigned from the first pattern that includes station and channel. N.B. Network and location code will be assigned from the first pattern that includes station and channel.
Unless HH channels of BOB and TIR, all other stations will have default network code from <a href="#DefaultNetworkCode">DefaultNetworkCode</a>. See <a href="#DefaultNetworkCode">DefaultNetworkCode</a> and <a href="#DefaultLocationCode">DefaultLocationCode</a>
Example of file updated by nmxptool: Example of file updated by nmxptool:
1228603650 ES.BOB.HHE 2008.063,07:48:15.5799 2008.063,07:50:12.9000 MM.JOPP.HHZ.-- 1 4321620 3596991 2012.027,23:38:33.7799 208pts lat. 4.1s
1228603649 ES.BOB.HHN 2008.063,07:48:16.0000 2008.063,07:50:13.6400 MM.JOPP.HHZ.-- 1 4321621 3596992 2012.027,23:38:35.8599 216pts lat. 2.0s
1228603648 ES.BOB.HHZ 2008.063,07:48:16.0000 2008.063,07:50:12.4900 IV.ARCI.HHZ.02 1 21431342 20706713 2012.027,23:38:27.6800 224pts lat. 10.1s
1225851138 MN.TIR.HHE 2008.063,07:48:07.2200 2008.063,07:50:07.7999 IV.ARCI.HHZ.02 1 21431343 20706714 2012.027,23:38:29.9200 224pts lat. 8.8s
1225851137 MN.TIR.HHN 2008.063,07:48:16.0000 2008.063,07:50:07.9000 IV.TIR.HHZ.01 1 103725441 103000812 2012.027,23:38:28.4600 224pts lat. 10.3s
1225851136 MN.TIR.HHZ 2008.063,07:48:05.7999 2008.063,07:50:08.2000 IV.ARCI.HHZ.02 1 21431344 20706715 2012.027,23:38:32.1600 224pts lat. 6.6s
1253900546 IV.SALO.HHE 2008.063,07:48:00.3199 2008.063,07:50:15.4800 IV.TIR.HHZ.01 1 103725442 103000813 2012.027,23:38:30.7000 224pts lat. 8.1s
1253900545 IV.SALO.HHN 2008.063,07:48:16.0000 2008.063,07:50:15.7500 IV.ARCI.HHZ.02 1 21431345 20706716 2012.027,23:38:34.4000 224pts lat. 4.4s
1253900544 IV.SALO.HHZ 2008.063,07:48:16.0000 2008.063,07:50:16.3299 IV.TIR.HHZ.01 1 103725443 103000814 2012.027,23:38:32.9400 224pts lat. 5.8s
1244987650 IV.AMUR.HHE 2008.063,07:48:09.0599 2008.063,07:50:13.3599 IV.TIR.HHZ.01 1 103725444 103000815 2012.027,23:38:35.1800 224pts lat. 3.6s
1244987649 IV.AMUR.HHN 2008.063,07:48:10.9600 2008.063,07:50:11.8000 IV.ARCI.HHZ.02 1 21431346 20706717 2012.027,23:38:36.6400 224pts lat. 2.1s
1244987648 IV.AMUR.HHZ 2008.063,07:48:02.4600 2008.063,07:50:12.2799 OO.FRES.HHZ.-- 1 42036166 41311537 2012.027,23:38:36.8199 128pts lat. 11.9s
1237188866 IV.ARCI.HHE 2008.063,07:48:10.0099 2008.063,07:50:13.0100 OO.FRES.HHZ.-- 1 42036167 41311538 2012.027,23:38:38.0999 124pts lat. 10.7s
1237188865 IV.ARCI.HHN 2008.063,07:48:10.3399 2008.063,07:50:12.6200 OO.FRES.HHZ.-- 1 42036168 41311539 2012.027,23:38:39.3399 118pts lat. 9.5s
1237188864 IV.ARCI.HHZ 2008.063,07:48:16.0000 2008.063,07:50:11.6700 OO.FRES.HHZ.-- 1 42036169 41311540 2012.027,23:38:40.5199 114pts lat. 8.3s
OO.FRES.HHZ.-- 1 42036170 41311541 2012.027,23:38:41.6600 116pts lat. 7.2s
OO.FRES.HHZ.-- 1 42036171 41311542 2012.027,23:38:42.8199 114pts lat. 6.0s
MM.JOPP.HHZ.-- 1 4321622 3596993 2012.027,23:38:38.0199 190pts lat. 10.1s
OO.FRES.HHZ.-- 1 42036172 41311543 2012.027,23:38:43.9600 114pts lat. 4.9s
OO.FRES.HHZ.-- 1 42036173 41311544 2012.027,23:38:45.0999 116pts lat. 3.7s
MM.JOPP.HHZ.-- 1 4321623 3596994 2012.027,23:38:39.9200 218pts lat. 7.9s
OO.FRES.HHZ.-- 1 42036174 41311545 2012.027,23:38:46.2599 114pts lat. 2.6s
MM.JOPP.HHZ.-- 1 4321624 3596995 2012.027,23:38:42.0999 198pts lat. 5.9s
MM.JOPP.HHZ.-- 1 4321625 3596996 2012.027,23:38:44.0799 224pts lat. 3.7s
IV.ARCI.HHZ.02 1 21431347 20706718 2012.027,23:38:38.8800 224pts lat. 9.9s
IV.TIR.HHZ.01 1 103725445 103000816 2012.027,23:38:37.4200 224pts lat. 11.3s
IV.ARCI.HHZ.02 1 21431348 20706719 2012.027,23:38:41.1199 224pts lat. 7.6s
IV.TIR.HHZ.01 1 103725446 103000817 2012.027,23:38:39.6600 224pts lat. 9.1s
IV.ARCI.HHZ.02 1 21431349 20706720 2012.027,23:38:43.3599 224pts lat. 5.4s
IV.TIR.HHZ.01 1 103725447 103000818 2012.027,23:38:41.9000 224pts lat. 6.9s
IV.ARCI.HHZ.02 1 21431350 20706721 2012.027,23:38:45.5999 224pts lat. 3.2s
IV.TIR.HHZ.01 1 103725448 103000819 2012.027,23:38:44.1400 224pts lat. 4.6s
MM.JOPP.HHZ.-- 1 4321626 3596997 2012.027,23:38:46.3199 220pts lat. 2.5s
IV.TIR.HHZ.01 1 103725449 103000820 2012.027,23:38:46.3800 224pts lat. 2.4s
... ...
</pre> </pre>
</blockquote> </blockquote>
<hr><!-- ADD HERE: all commands; below is a sample command blank: --><!-- command name as anchor inside quotes -->
<pre><a name="DefaultLocationCode"><b>DefaultLocationCode <font color="red">network_code</font> ReadConfig nmxptool parameters<br></b><!-- command args ... --> <br></a></pre>
<blockquote><!-- command description goes here --> Specifies default <font color="red">location code</font>
for channels where is omitted.
<pre><br>Default: NULL location (also printed out as &quot;--&quot;)<br>Example: DefaultLocationCode 01</pre>
</blockquote>
<hr><!-- ADD HERE: all commands; below is a sample command blank: --><!-- command name as anchor inside quotes --> <hr><!-- ADD HERE: all commands; below is a sample command blank: --><!-- command name as anchor inside quotes -->
<pre><a name="DefaultNetworkCode"><b>DefaultNetworkCode <font color="red">network_code</font> ReadConfig nmxptool parameters<br></b><!-- command args ... --> <br></a></pre> <pre><a name="DefaultNetworkCode"><b>DefaultNetworkCode <font color="red">network_code</font> ReadConfig nmxptool parameters<br></b><!-- command args ... --> <br></a></pre>
<blockquote><!-- command description goes here --> Specifies default <font color="red">network code</font> <blockquote><!-- command description goes here --> Specifies default <font color="red">network code</font>
......
...@@ -1093,6 +1093,7 @@ int nmxp_sendAddTimeSeriesChannel(int isock, NMXP_CHAN_LIST_NET *channelList, in ...@@ -1093,6 +1093,7 @@ int nmxp_sendAddTimeSeriesChannel(int isock, NMXP_CHAN_LIST_NET *channelList, in
* \param isock A descriptor referencing the socket. * \param isock A descriptor referencing the socket.
* \param channelList Channel list. * \param channelList Channel list.
* \param network_code Network code. It can be NULL. * \param network_code Network code. It can be NULL.
* \param location_code Location code. It can be NULL.
* \param timeoutsec Time-out in seconds * \param timeoutsec Time-out in seconds
* \param[out] recv_errno errno value after recv() * \param[out] recv_errno errno value after recv()
* *
...@@ -1100,7 +1101,7 @@ int nmxp_sendAddTimeSeriesChannel(int isock, NMXP_CHAN_LIST_NET *channelList, in ...@@ -1100,7 +1101,7 @@ int nmxp_sendAddTimeSeriesChannel(int isock, NMXP_CHAN_LIST_NET *channelList, in
* \retval NULL on error * \retval NULL on error
* *
*/ */
NMXP_DATA_PROCESS *nmxp_receiveData(int isock, NMXP_CHAN_LIST_NET *channelList, const char *network_code, int timeoutsec, int *recv_errno ); NMXP_DATA_PROCESS *nmxp_receiveData(int isock, NMXP_CHAN_LIST_NET *channelList, const char *network_code, const char *location_code, int timeoutsec, int *recv_errno );
/*! \brief Sends the message "ConnectRequest" on a socket /*! \brief Sends the message "ConnectRequest" on a socket
......
...@@ -168,11 +168,12 @@ int nmxp_receiveMessage(int isock, NMXP_MSG_SERVER *type, void *buffer, int32_t ...@@ -168,11 +168,12 @@ int nmxp_receiveMessage(int isock, NMXP_MSG_SERVER *type, void *buffer, int32_t
* \param length_data Buffer length in bytes. * \param length_data Buffer length in bytes.
* \param channelList Pointer to the Channel List. * \param channelList Pointer to the Channel List.
* \param network_code_default Value of network code to assign returned structure. It should not be NULL. * \param network_code_default Value of network code to assign returned structure. It should not be NULL.
* \param location_code_default Value of location code to assign returned structure. It should not be NULL.
* *
* \return Return a pointer to static struct NMXP_DATA_PROCESS. * \return Return a pointer to static struct NMXP_DATA_PROCESS.
* *
*/ */
NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data, NMXP_CHAN_LIST_NET *channelList, const char *network_code_default); NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data, NMXP_CHAN_LIST_NET *channelList, const char *network_code_default, const char *location_code_default);
/*! \brief Process decompressed Data message by function func_processData(). /*! \brief Process decompressed Data message by function func_processData().
...@@ -181,11 +182,12 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data ...@@ -181,11 +182,12 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data
* \param length_data Buffer length in bytes. * \param length_data Buffer length in bytes.
* \param channelList Pointer to the Channel List. * \param channelList Pointer to the Channel List.
* \param network_code_default Value of network code to assign returned structure. It should not be NULL. * \param network_code_default Value of network code to assign returned structure. It should not be NULL.
* \param location_code_default Value of location code to assign returned structure. It should not be NULL.
* *
* \return Return a pointer to static struct NMXP_DATA_PROCESS. * \return Return a pointer to static struct NMXP_DATA_PROCESS.
* *
*/ */
NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_data, NMXP_CHAN_LIST_NET *channelList, const char *network_code_default); NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_data, NMXP_CHAN_LIST_NET *channelList, const char *network_code_default, const char *location_code_default);
/*! \brief Wrapper for functions sleep on different platforms /*! \brief Wrapper for functions sleep on different platforms
......
...@@ -124,7 +124,8 @@ typedef struct { ...@@ -124,7 +124,8 @@ typedef struct {
* \param net_dot_station_dot_channel string containing NET.STA.CHAN where NET. is optional * \param net_dot_station_dot_channel string containing NET.STA.CHAN where NET. is optional
* \param[out] station_code Pointer to string for station code * \param[out] station_code Pointer to string for station code
* \param[out] channel_code Pointer to string for channel code * \param[out] channel_code Pointer to string for channel code
* \param[out] network_code Pointer to string for station code * \param[out] network_code Pointer to string for network code
* \param[out] location_code Pointer to string for location code
* *
* \warning Parametes can not be NULL! * \warning Parametes can not be NULL!
* *
...@@ -132,7 +133,7 @@ typedef struct { ...@@ -132,7 +133,7 @@ typedef struct {
* \retval 0 on error * \retval 0 on error
* *
*/ */
int nmxp_chan_cpy_sta_chan(const char *net_dot_station_dot_channel, char *station_code, char *channel_code, char *network_code); int nmxp_chan_cpy_sta_chan(const char *net_dot_station_dot_channel, char *station_code, char *channel_code, char *network_code, char *location_code);
/*! \brief Match station_dot_channel against pattern, treating errors as no match. /*! \brief Match station_dot_channel against pattern, treating errors as no match.
...@@ -204,13 +205,14 @@ NMXP_CHAN_LIST *nmxp_chan_getType(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE dat ...@@ -204,13 +205,14 @@ NMXP_CHAN_LIST *nmxp_chan_getType(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE dat
* \param dataType Type of channel. * \param dataType Type of channel.
* \param sta_chan_list String list of item STA.CHAN, separeted by comma. * \param sta_chan_list String list of item STA.CHAN, separeted by comma.
* \param network_code_default Default Network code * \param network_code_default Default Network code
* \param location_code_default Default Location code
* *
* \return Channel list with specified dataType. It will need to be freed! * \return Channel list with specified dataType. It will need to be freed!
* *
* \warning Returned value will need to be freed! * \warning Returned value will need to be freed!
* *
*/ */
NMXP_CHAN_LIST_NET *nmxp_chan_subset(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE dataType, char *sta_chan_list, const char *network_code_default); NMXP_CHAN_LIST_NET *nmxp_chan_subset(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE dataType, char *sta_chan_list, const char *network_code_default, const char *location_code_default);
/*! Sort list by channel key /*! Sort list by channel key
......
...@@ -109,6 +109,7 @@ typedef struct { ...@@ -109,6 +109,7 @@ typedef struct {
/*! \brief Length in bytes of channel strings */ /*! \brief Length in bytes of channel strings */
#define NMXP_DATA_CHANNEL_LENGTH 10 #define NMXP_DATA_CHANNEL_LENGTH 10
#define NMXP_DATA_LOCATION_LENGTH 3
/*! Time-out for keeping the DataServer connection alive */ /*! Time-out for keeping the DataServer connection alive */
#define NMXP_DAP_TIMEOUT_KEEPALIVE 15 #define NMXP_DAP_TIMEOUT_KEEPALIVE 15
...@@ -119,6 +120,7 @@ typedef struct { ...@@ -119,6 +120,7 @@ typedef struct {
char network[NMXP_DATA_NETWORK_LENGTH]; /*!< \brief Network code */ char network[NMXP_DATA_NETWORK_LENGTH]; /*!< \brief Network code */
char station[NMXP_DATA_STATION_LENGTH]; /*!< \brief Station code */ char station[NMXP_DATA_STATION_LENGTH]; /*!< \brief Station code */
char channel[NMXP_DATA_CHANNEL_LENGTH]; /*!< \brief Channel code */ char channel[NMXP_DATA_CHANNEL_LENGTH]; /*!< \brief Channel code */
char location[NMXP_DATA_LOCATION_LENGTH]; /*!< \brief Location code */
int32_t packet_type; /*!< \brief Packet type */ int32_t packet_type; /*!< \brief Packet type */
int32_t x0; /*!< \brief First sample. It is significant only if x0n_significant != 0 */ int32_t x0; /*!< \brief First sample. It is significant only if x0n_significant != 0 */
int32_t xn; /*!< \brief Last sample. It is significant only if x0n_significant != 0 */ int32_t xn; /*!< \brief Last sample. It is significant only if x0n_significant != 0 */
......
...@@ -222,7 +222,7 @@ int nmxp_sendAddTimeSeriesChannel(int isock, NMXP_CHAN_LIST_NET *channelList, in ...@@ -222,7 +222,7 @@ int nmxp_sendAddTimeSeriesChannel(int isock, NMXP_CHAN_LIST_NET *channelList, in
} }
NMXP_DATA_PROCESS *nmxp_receiveData(int isock, NMXP_CHAN_LIST_NET *channelList, const char *network_code, int timeoutsec, int *recv_errno ) { NMXP_DATA_PROCESS *nmxp_receiveData(int isock, NMXP_CHAN_LIST_NET *channelList, const char *network_code, const char *location_code, int timeoutsec, int *recv_errno ) {
NMXP_MSG_SERVER type; NMXP_MSG_SERVER type;
char buffer[NMXP_MAX_LENGTH_DATA_BUFFER]={0}; char buffer[NMXP_MAX_LENGTH_DATA_BUFFER]={0};
int32_t length; int32_t length;
...@@ -231,10 +231,10 @@ NMXP_DATA_PROCESS *nmxp_receiveData(int isock, NMXP_CHAN_LIST_NET *channelList, ...@@ -231,10 +231,10 @@ NMXP_DATA_PROCESS *nmxp_receiveData(int isock, NMXP_CHAN_LIST_NET *channelList,
if(nmxp_receiveMessage(isock, &type, buffer, &length, timeoutsec, recv_errno, NMXP_MAX_LENGTH_DATA_BUFFER) == NMXP_SOCKET_OK) { if(nmxp_receiveMessage(isock, &type, buffer, &length, timeoutsec, recv_errno, NMXP_MAX_LENGTH_DATA_BUFFER) == NMXP_SOCKET_OK) {
if(type == NMXP_MSG_COMPRESSED) { if(type == NMXP_MSG_COMPRESSED) {
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_PACKETMAN, "Type %d is NMXP_MSG_COMPRESSED!\n", type); nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_PACKETMAN, "Type %d is NMXP_MSG_COMPRESSED!\n", type);
pd = nmxp_processCompressedData(buffer, length, channelList, network_code); pd = nmxp_processCompressedData(buffer, length, channelList, network_code, location_code);
} else if(type == NMXP_MSG_DECOMPRESSED) { } else if(type == NMXP_MSG_DECOMPRESSED) {
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_PACKETMAN, "Type %d is NMXP_MSG_DECOMPRESSED!\n", type); nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_PACKETMAN, "Type %d is NMXP_MSG_DECOMPRESSED!\n", type);
pd = nmxp_processDecompressedData(buffer, length, channelList, network_code); pd = nmxp_processDecompressedData(buffer, length, channelList, network_code, location_code);
} else { } else {
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_PACKETMAN, "Type %d is not NMXP_MSG_COMPRESSED or NMXP_MSG_DECOMPRESSED!\n", type); nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_PACKETMAN, "Type %d is not NMXP_MSG_COMPRESSED or NMXP_MSG_DECOMPRESSED!\n", type);
} }
......
...@@ -461,7 +461,7 @@ int nmxp_receiveMessage(int isock, NMXP_MSG_SERVER *type, void *buffer, int32_t ...@@ -461,7 +461,7 @@ int nmxp_receiveMessage(int isock, NMXP_MSG_SERVER *type, void *buffer, int32_t
} }
NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_data, NMXP_CHAN_LIST_NET *channelList, const char *network_code_default) NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_data, NMXP_CHAN_LIST_NET *channelList, const char *network_code_default, const char *location_code_default)
{ {
int32_t netInt = 0; int32_t netInt = 0;
int32_t pKey = 0; int32_t pKey = 0;
...@@ -477,6 +477,7 @@ NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_da ...@@ -477,6 +477,7 @@ NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_da
char station_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN]; char station_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN];
char channel_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN]; char channel_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN];
char network_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN]; char network_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN];
char location_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN];
char *nmxp_channel_name = NULL; char *nmxp_channel_name = NULL;
NMXP_DATA_PROCESS *pd = NULL; NMXP_DATA_PROCESS *pd = NULL;
...@@ -514,7 +515,7 @@ NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_da ...@@ -514,7 +515,7 @@ NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_da
pDataPtr[idx] = netInt; pDataPtr[idx] = netInt;
} }
if(!nmxp_chan_cpy_sta_chan(nmxp_channel_name, station_code, channel_code, network_code)) { if(!nmxp_chan_cpy_sta_chan(nmxp_channel_name, station_code, channel_code, network_code, location_code)) {
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_PACKETMAN, "Channel name not in STA.CHAN format: %s\n", nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_PACKETMAN, "Channel name not in STA.CHAN format: %s\n",
NMXP_LOG_STR(nmxp_channel_name)); NMXP_LOG_STR(nmxp_channel_name));
} }
...@@ -531,6 +532,11 @@ NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_da ...@@ -531,6 +532,11 @@ NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_da
if(channel_code[0] != 0) { if(channel_code[0] != 0) {
strncpy(pd->channel, channel_code, NMXP_DATA_CHANNEL_LENGTH); strncpy(pd->channel, channel_code, NMXP_DATA_CHANNEL_LENGTH);
} }
if(location_code[0] != 0) {
strncpy(pd->location, location_code, NMXP_DATA_LOCATION_LENGTH);
} else {
strncpy(pd->location, location_code_default, NMXP_DATA_LOCATION_LENGTH);
}
pd->packet_type = NMXP_MSG_DECOMPRESSED; pd->packet_type = NMXP_MSG_DECOMPRESSED;
pd->x0 = -1; pd->x0 = -1;
pd->xn = -1; pd->xn = -1;
...@@ -555,7 +561,7 @@ NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_da ...@@ -555,7 +561,7 @@ NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_da
} }
NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data, NMXP_CHAN_LIST_NET *channelList, const char *network_code_default) NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data, NMXP_CHAN_LIST_NET *channelList, const char *network_code_default, const char *location_code_default)
{ {
int32_t pKey = 0; int32_t pKey = 0;
double pTime = 0.0; double pTime = 0.0;
...@@ -566,6 +572,7 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data ...@@ -566,6 +572,7 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data
char station_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN]; char station_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN];
char channel_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN]; char channel_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN];
char network_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN]; char network_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN];
char location_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN];
NMXP_DATA_PROCESS *pd = NULL; NMXP_DATA_PROCESS *pd = NULL;
...@@ -673,7 +680,7 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data ...@@ -673,7 +680,7 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data
if(nmxp_channel_name) { if(nmxp_channel_name) {
if(!nmxp_chan_cpy_sta_chan(nmxp_channel_name, station_code, channel_code, network_code)) { if(!nmxp_chan_cpy_sta_chan(nmxp_channel_name, station_code, channel_code, network_code, location_code)) {
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_PACKETMAN, "Channel name not in STA.CHAN format: %s\n", nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_PACKETMAN, "Channel name not in STA.CHAN format: %s\n",
NMXP_LOG_STR(nmxp_channel_name)); NMXP_LOG_STR(nmxp_channel_name));
} }
...@@ -729,6 +736,11 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data ...@@ -729,6 +736,11 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data
if(channel_code[0] != 0) { if(channel_code[0] != 0) {
strncpy(pd->channel, channel_code, NMXP_DATA_CHANNEL_LENGTH); strncpy(pd->channel, channel_code, NMXP_DATA_CHANNEL_LENGTH);
} }
if(location_code[0] != 0) {
strncpy(pd->location, location_code, NMXP_DATA_LOCATION_LENGTH);
} else {
strncpy(pd->location, location_code_default, NMXP_DATA_LOCATION_LENGTH);
}
pd->packet_type = nmx_ptype; pd->packet_type = nmx_ptype;
pd->x0 = nmx_x0; pd->x0 = nmx_x0;
pd->xn = pDataPtr[nout]; pd->xn = pDataPtr[nout];
......
...@@ -18,18 +18,19 @@ ...@@ -18,18 +18,19 @@
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
int nmxp_chan_cpy_sta_chan(const char *net_dot_station_dot_channel, char *station_code, char *channel_code, char *network_code) { int nmxp_chan_cpy_sta_chan(const char *net_dot_station_dot_channel, char *station_code, char *channel_code, char *network_code, char *location_code) {
int ret = 0; int ret = 0;
int errors = 0; int errors = 0;
int i; int i;
char *period1 = NULL, *period2 = NULL; char *period1 = NULL, *period2 = NULL, *period3 = NULL;
char *tmp_name = NULL; char *tmp_name = NULL;
if(net_dot_station_dot_channel || station_code || channel_code || network_code) { if(net_dot_station_dot_channel || station_code || channel_code || network_code || location_code) {
station_code[0] = 0; station_code[0] = 0;
channel_code[0] = 0; channel_code[0] = 0;
network_code[0] = 0; network_code[0] = 0;
location_code[0] = 0;
tmp_name = NMXP_MEM_STRDUP(net_dot_station_dot_channel); tmp_name = NMXP_MEM_STRDUP(net_dot_station_dot_channel);
/* count '.' */ /* count '.' */
...@@ -40,6 +41,8 @@ int nmxp_chan_cpy_sta_chan(const char *net_dot_station_dot_channel, char *statio ...@@ -40,6 +41,8 @@ int nmxp_chan_cpy_sta_chan(const char *net_dot_station_dot_channel, char *statio
period1 = tmp_name+i; period1 = tmp_name+i;
} else if(!period2) { } else if(!period2) {
period2 = tmp_name+i; period2 = tmp_name+i;
} else if(!period3) {
period3 = tmp_name+i;
} else { } else {
errors++; errors++;
} }
...@@ -48,13 +51,38 @@ int nmxp_chan_cpy_sta_chan(const char *net_dot_station_dot_channel, char *statio ...@@ -48,13 +51,38 @@ int nmxp_chan_cpy_sta_chan(const char *net_dot_station_dot_channel, char *statio
} }
if(!errors && period1) { if(!errors && period1) {
ret = 1; ret = 1;
if(period2) { if(period3) {
/* NET.STA.CHAN */ /* NET.STA.CHAN.LOC */
*period1++ = '\0'; *period1++ = '\0';
*period2++ = '\0'; *period2++ = '\0';
*period3++ = '\0';
strncpy(network_code, tmp_name, NMXP_CHAN_MAX_SIZE_STR_PATTERN); strncpy(network_code, tmp_name, NMXP_CHAN_MAX_SIZE_STR_PATTERN);
strncpy(station_code, period1, NMXP_CHAN_MAX_SIZE_STR_PATTERN); strncpy(station_code, period1, NMXP_CHAN_MAX_SIZE_STR_PATTERN);
strncpy(channel_code, period2, NMXP_CHAN_MAX_SIZE_STR_PATTERN); strncpy(channel_code, period2, NMXP_CHAN_MAX_SIZE_STR_PATTERN);
strncpy(location_code, period3, NMXP_CHAN_MAX_SIZE_STR_PATTERN);
} else
if(period2) {
/* TODO NECESSARY */
/* NET.STA.CHAN */
/* OR */
/* STA.CHAN.LOC */
*period1++ = '\0';
*period2++ = '\0';
if( strlen(period1) == 3 && strlen(period2) == 2) {
/* STA.CHAN.LOC */
strncpy(station_code, tmp_name, NMXP_CHAN_MAX_SIZE_STR_PATTERN);
strncpy(channel_code, period1, NMXP_CHAN_MAX_SIZE_STR_PATTERN);
strncpy(location_code, period2, NMXP_CHAN_MAX_SIZE_STR_PATTERN);
} else
if( strlen(tmp_name) == 2 && strlen(period2) == 3) {
/* NET.STA.CHAN */
strncpy(network_code, tmp_name, NMXP_CHAN_MAX_SIZE_STR_PATTERN);
strncpy(station_code, period1, NMXP_CHAN_MAX_SIZE_STR_PATTERN);
strncpy(channel_code, period2, NMXP_CHAN_MAX_SIZE_STR_PATTERN);
} else {
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CHANNEL, "Name %s is not in NET.STA.CHA.LOC format! (NET. .LOC are optional)\n",
NMXP_LOG_STR(net_dot_station_dot_channel));
}
} else { } else {
/* STA.CHAN */ /* STA.CHAN */
*period1++ = '\0'; *period1++ = '\0';
...@@ -93,16 +121,34 @@ int nmxp_chan_match(const char *net_dot_station_dot_channel, char *pattern) ...@@ -93,16 +121,34 @@ int nmxp_chan_match(const char *net_dot_station_dot_channel, char *pattern)
char sta_pattern[NMXP_CHAN_MAX_SIZE_STR_PATTERN]; char sta_pattern[NMXP_CHAN_MAX_SIZE_STR_PATTERN];
char cha_pattern[NMXP_CHAN_MAX_SIZE_STR_PATTERN]; char cha_pattern[NMXP_CHAN_MAX_SIZE_STR_PATTERN];
char net_pattern[NMXP_CHAN_MAX_SIZE_STR_PATTERN]; char net_pattern[NMXP_CHAN_MAX_SIZE_STR_PATTERN];
char loc_pattern[NMXP_CHAN_MAX_SIZE_STR_PATTERN];
char sta_sdc[NMXP_CHAN_MAX_SIZE_STR_PATTERN]; char sta_sdc[NMXP_CHAN_MAX_SIZE_STR_PATTERN];
char *cha_sdc; char *cha_sdc;
/* validate pattern channel */ /* validate pattern channel */
if(!nmxp_chan_cpy_sta_chan(pattern, sta_pattern, cha_pattern, net_pattern)) { if(!nmxp_chan_cpy_sta_chan(pattern, sta_pattern, cha_pattern, net_pattern, loc_pattern)) {
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CHANNEL, "Channel pattern %s is not in STA.CHAN format!\n", nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CHANNEL, "Channel pattern %s is not in STA.CHAN format!\n",
NMXP_LOG_STR(pattern)); NMXP_LOG_STR(pattern));
return -1; return -1;
} }
l = strlen(loc_pattern);
i = 0;
while(i < l && ret != -1) {
if( !(
(loc_pattern[i] >= 'A' && loc_pattern[i] <= 'Z')
|| (loc_pattern[i] >= 'a' && loc_pattern[i] <= 'z')
|| (loc_pattern[i] >= '0' && loc_pattern[i] <= '9')
|| (loc_pattern[i] == '-')
)
) {
nmxp_log(NMXP_LOG_ERR, NMXP_LOG_D_CHANNEL, "Channel pattern %s has not valid LOC format!\n",
NMXP_LOG_STR(pattern));
return -1;
}
i++;
}
l = strlen(net_pattern); l = strlen(net_pattern);
i = 0; i = 0;
while(i < l && ret != -1) { while(i < l && ret != -1) {
...@@ -273,7 +319,7 @@ NMXP_CHAN_LIST *nmxp_chan_getType(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE dat ...@@ -273,7 +319,7 @@ NMXP_CHAN_LIST *nmxp_chan_getType(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE dat
} }
NMXP_CHAN_LIST_NET *nmxp_chan_subset(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE dataType, char *sta_chan_list, const char *network_code_default) { NMXP_CHAN_LIST_NET *nmxp_chan_subset(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE dataType, char *sta_chan_list, const char *network_code_default, const char *location_code_default) {
NMXP_CHAN_LIST_NET *ret_channelList = NULL; NMXP_CHAN_LIST_NET *ret_channelList = NULL;
int istalist, ista; int istalist, ista;
char sta_chan_code_pattern[100]; char sta_chan_code_pattern[100];
...@@ -281,6 +327,7 @@ NMXP_CHAN_LIST_NET *nmxp_chan_subset(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE ...@@ -281,6 +327,7 @@ NMXP_CHAN_LIST_NET *nmxp_chan_subset(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE
char network_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN]; char network_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN];
char station_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN]; char station_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN];
char channel_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN]; char channel_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN];
char location_code[NMXP_CHAN_MAX_SIZE_STR_PATTERN];
int i_chan_found = -1; int i_chan_found = -1;
int i_chan_duplicated = -1; int i_chan_duplicated = -1;
char *nmxp_channel_name = NULL; char *nmxp_channel_name = NULL;
...@@ -320,10 +367,11 @@ NMXP_CHAN_LIST_NET *nmxp_chan_subset(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE ...@@ -320,10 +367,11 @@ NMXP_CHAN_LIST_NET *nmxp_chan_subset(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE
i_chan_found = i_chan; i_chan_found = i_chan;
ret_channelList->channel[ret_channelList->number].key = channelList->channel[i_chan_found].key; ret_channelList->channel[ret_channelList->number].key = channelList->channel[i_chan_found].key;
strncpy(ret_channelList->channel[ret_channelList->number].name, channelList->channel[i_chan_found].name, NMXP_CHAN_MAX_SIZE_NAME); strncpy(ret_channelList->channel[ret_channelList->number].name, channelList->channel[i_chan_found].name, NMXP_CHAN_MAX_SIZE_NAME);
nmxp_chan_cpy_sta_chan(sta_chan_code_pattern, station_code, channel_code, network_code); nmxp_chan_cpy_sta_chan(sta_chan_code_pattern, station_code, channel_code, network_code, location_code);
snprintf(ret_channelList->channel[ret_channelList->number].name, NMXP_CHAN_MAX_SIZE_NAME, "%s.%s", snprintf(ret_channelList->channel[ret_channelList->number].name, NMXP_CHAN_MAX_SIZE_NAME, "%s.%s.%s",
(network_code[0] != 0)? network_code : network_code_default, channelList->channel[i_chan_found].name); (network_code[0] != 0)? network_code : network_code_default, channelList->channel[i_chan_found].name,
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_CHANNEL, "Added %s for %s.\n", (location_code[0] != 0)? location_code : location_code_default );
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_CHANNEL, "Added %s for %s .\n",
ret_channelList->channel[ret_channelList->number].name, sta_chan_code_pattern); ret_channelList->channel[ret_channelList->number].name, sta_chan_code_pattern);
ret_channelList->number++; ret_channelList->number++;
} else { } else {
......
...@@ -82,6 +82,7 @@ int nmxp_data_init(NMXP_DATA_PROCESS *pd) { ...@@ -82,6 +82,7 @@ int nmxp_data_init(NMXP_DATA_PROCESS *pd) {
pd->network[0] = 0; pd->network[0] = 0;
pd->station[0] = 0; pd->station[0] = 0;
pd->channel[0] = 0;