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
#########################
* 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.
* Release 2.0.0 (2010/10/22)
......
#!/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])
dnl These three define the plug-in version number
m4_define([major_version], [2])
m4_define([minor_version], [0])
m4_define([minor_version], [1])
m4_define([micro_version], [0])
# Comment build_version for stable release
# m4_define([build_version], [beta3])
m4_define([build_version], [rc1])
m4_ifdef([build_version], [
m4_define([version],
......
......@@ -59,18 +59,22 @@ MaxTolerableLatency 60 # Raw Stream, NOT use 'ShortTermComplet
DefaultNetworkCode IV # Default network code where in 'ChannelFile' or 'Channel' is not declared.
# 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
# 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.
# STA can be '*', stands for all stations.
# 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'.
# Network code will be assigned from the first
# pattern that includes station and channel.
# Example: N1.AAA.HH?,N2.*.HH?,MMM.BH?
# Network and location code will be assigned from the
# first pattern that include station and channel.
# Example: N1.AAA.HH?.01,N2.*.HH?,MMM.BH?.03
# Second pattern includes the first. Unless AAA, all
# 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'.
#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
# Channel ES.BOB.HH?
# Channel MN.TIR.HH?
# Channel MDI.HH?
# Channel DOI.HH?
# Channel DOI.HH?.01
# Channel SALO.HH?
# Channel MONC.HH?
# Channel IV.MONC.HH?.03
# Channel *.BHZ # Channel selection
# Please, for other details about parameters, refer to the command line "nmxptool -h"
......
......@@ -57,6 +57,7 @@ Nanometrics server and connection parameters:<br>
<a href="#TimeoutRecv">TimeoutRecv</a> optional<br>
<a href="#mschan">mschan</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="#Channel">Channel</a> required Xor ChannelFile<br>
<br>
......@@ -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>
<blockquote><!-- command description goes here --> Specifies one stream
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
separated by period. network is optional and it is used only for output.
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 and location are optional and they are used only for output.
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>!
<pre>
Default: none
Example: Channel ES.BOB.HH?
Channel MN.TIR.HH?
Channel SALO.HH?
Channel IV.MVVM.HH?.01
Channel SALO.HH?.03
Channel *.HHZ
N.B. Network 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>.
N.B. Network and location code will be assigned from the first pattern that includes station and channel.
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>
</blockquote>
......@@ -113,34 +116,60 @@ Default: none
Example: ChannelFile /home/ew/list_channels_naqs1.txt
Example of file created by the user:
ES.BOB.HH?
MN.TIR.HH?
SALO.HH?
*.HH?
TIR.HHZ.01
ARCI.HHZ.02
MM.JOPP.HHZ
OO.FRES.HHZ
N.B. Network 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>.
N.B. Network and location code will be assigned from the first pattern that includes station and channel.
See <a href="#DefaultNetworkCode">DefaultNetworkCode</a> and <a href="#DefaultLocationCode">DefaultLocationCode</a>
Example of file updated by nmxptool:
1228603650 ES.BOB.HHE 2008.063,07:48:15.5799 2008.063,07:50:12.9000
1228603649 ES.BOB.HHN 2008.063,07:48:16.0000 2008.063,07:50:13.6400
1228603648 ES.BOB.HHZ 2008.063,07:48:16.0000 2008.063,07:50:12.4900
1225851138 MN.TIR.HHE 2008.063,07:48:07.2200 2008.063,07:50:07.7999
1225851137 MN.TIR.HHN 2008.063,07:48:16.0000 2008.063,07:50:07.9000
1225851136 MN.TIR.HHZ 2008.063,07:48:05.7999 2008.063,07:50:08.2000
1253900546 IV.SALO.HHE 2008.063,07:48:00.3199 2008.063,07:50:15.4800
1253900545 IV.SALO.HHN 2008.063,07:48:16.0000 2008.063,07:50:15.7500
1253900544 IV.SALO.HHZ 2008.063,07:48:16.0000 2008.063,07:50:16.3299
1244987650 IV.AMUR.HHE 2008.063,07:48:09.0599 2008.063,07:50:13.3599
1244987649 IV.AMUR.HHN 2008.063,07:48:10.9600 2008.063,07:50:11.8000
1244987648 IV.AMUR.HHZ 2008.063,07:48:02.4600 2008.063,07:50:12.2799
1237188866 IV.ARCI.HHE 2008.063,07:48:10.0099 2008.063,07:50:13.0100
1237188865 IV.ARCI.HHN 2008.063,07:48:10.3399 2008.063,07:50:12.6200
1237188864 IV.ARCI.HHZ 2008.063,07:48:16.0000 2008.063,07:50:11.6700
MM.JOPP.HHZ.-- 1 4321620 3596991 2012.027,23:38:33.7799 208pts lat. 4.1s
MM.JOPP.HHZ.-- 1 4321621 3596992 2012.027,23:38:35.8599 216pts lat. 2.0s
IV.ARCI.HHZ.02 1 21431342 20706713 2012.027,23:38:27.6800 224pts lat. 10.1s
IV.ARCI.HHZ.02 1 21431343 20706714 2012.027,23:38:29.9200 224pts lat. 8.8s
IV.TIR.HHZ.01 1 103725441 103000812 2012.027,23:38:28.4600 224pts lat. 10.3s
IV.ARCI.HHZ.02 1 21431344 20706715 2012.027,23:38:32.1600 224pts lat. 6.6s
IV.TIR.HHZ.01 1 103725442 103000813 2012.027,23:38:30.7000 224pts lat. 8.1s
IV.ARCI.HHZ.02 1 21431345 20706716 2012.027,23:38:34.4000 224pts lat. 4.4s
IV.TIR.HHZ.01 1 103725443 103000814 2012.027,23:38:32.9400 224pts lat. 5.8s
IV.TIR.HHZ.01 1 103725444 103000815 2012.027,23:38:35.1800 224pts lat. 3.6s
IV.ARCI.HHZ.02 1 21431346 20706717 2012.027,23:38:36.6400 224pts lat. 2.1s
OO.FRES.HHZ.-- 1 42036166 41311537 2012.027,23:38:36.8199 128pts lat. 11.9s
OO.FRES.HHZ.-- 1 42036167 41311538 2012.027,23:38:38.0999 124pts lat. 10.7s
OO.FRES.HHZ.-- 1 42036168 41311539 2012.027,23:38:39.3399 118pts lat. 9.5s
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>
</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 -->
<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>
......
......@@ -1093,6 +1093,7 @@ int nmxp_sendAddTimeSeriesChannel(int isock, NMXP_CHAN_LIST_NET *channelList, in
* \param isock A descriptor referencing the socket.
* \param channelList Channel list.
* \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[out] recv_errno errno value after recv()
*
......@@ -1100,7 +1101,7 @@ int nmxp_sendAddTimeSeriesChannel(int isock, NMXP_CHAN_LIST_NET *channelList, in
* \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
......
......@@ -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 channelList Pointer to the Channel List.
* \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.
*
*/
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().
......@@ -181,11 +182,12 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data
* \param length_data Buffer length in bytes.
* \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 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.
*
*/
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
......
......@@ -124,7 +124,8 @@ typedef struct {
* \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] 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!
*
......@@ -132,7 +133,7 @@ typedef struct {
* \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.
......@@ -204,13 +205,14 @@ NMXP_CHAN_LIST *nmxp_chan_getType(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE dat
* \param dataType Type of channel.
* \param sta_chan_list String list of item STA.CHAN, separeted by comma.
* \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!
*
* \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
......
......@@ -109,6 +109,7 @@ typedef struct {
/*! \brief Length in bytes of channel strings */
#define NMXP_DATA_CHANNEL_LENGTH 10
#define NMXP_DATA_LOCATION_LENGTH 3
/*! Time-out for keeping the DataServer connection alive */
#define NMXP_DAP_TIMEOUT_KEEPALIVE 15
......@@ -119,6 +120,7 @@ typedef struct {
char network[NMXP_DATA_NETWORK_LENGTH]; /*!< \brief Network code */
char station[NMXP_DATA_STATION_LENGTH]; /*!< \brief Station 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 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 */
......
......@@ -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;
char buffer[NMXP_MAX_LENGTH_DATA_BUFFER]={0};
int32_t length;
......@@ -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(type == NMXP_MSG_COMPRESSED) {
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) {
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 {
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
}
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 pKey = 0;
......@@ -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 channel_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;
NMXP_DATA_PROCESS *pd = NULL;
......@@ -514,7 +515,7 @@ NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_da
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_STR(nmxp_channel_name));
}
......@@ -531,6 +532,11 @@ NMXP_DATA_PROCESS *nmxp_processDecompressedData(char* buffer_data, int length_da
if(channel_code[0] != 0) {
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->x0 = -1;
pd->xn = -1;
......@@ -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;
double pTime = 0.0;
......@@ -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 channel_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;
......@@ -673,7 +680,7 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data
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_STR(nmxp_channel_name));
}
......@@ -729,6 +736,11 @@ NMXP_DATA_PROCESS *nmxp_processCompressedData(char* buffer_data, int length_data
if(channel_code[0] != 0) {
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->x0 = nmx_x0;
pd->xn = pDataPtr[nout];
......
......@@ -18,18 +18,19 @@
#include <string.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 errors = 0;
int i;
char *period1 = NULL, *period2 = NULL;
char *period1 = NULL, *period2 = NULL, *period3 = 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;
channel_code[0] = 0;
network_code[0] = 0;
location_code[0] = 0;
tmp_name = NMXP_MEM_STRDUP(net_dot_station_dot_channel);
/* count '.' */
......@@ -40,6 +41,8 @@ int nmxp_chan_cpy_sta_chan(const char *net_dot_station_dot_channel, char *statio
period1 = tmp_name+i;
} else if(!period2) {
period2 = tmp_name+i;
} else if(!period3) {
period3 = tmp_name+i;
} else {
errors++;
}
......@@ -48,13 +51,38 @@ int nmxp_chan_cpy_sta_chan(const char *net_dot_station_dot_channel, char *statio
}
if(!errors && period1) {
ret = 1;
if(period2) {
/* NET.STA.CHAN */
if(period3) {
/* NET.STA.CHAN.LOC */
*period1++ = '\0';
*period2++ = '\0';
*period3++ = '\0';
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);
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 {
/* STA.CHAN */
*period1++ = '\0';
......@@ -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 cha_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 *cha_sdc;
/* 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_STR(pattern));
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);
i = 0;
while(i < l && ret != -1) {
......@@ -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;
int istalist, ista;
char sta_chan_code_pattern[100];
......@@ -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 station_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_duplicated = -1;
char *nmxp_channel_name = NULL;
......@@ -320,10 +367,11 @@ NMXP_CHAN_LIST_NET *nmxp_chan_subset(NMXP_CHAN_LIST *channelList, NMXP_DATATYPE
i_chan_found = i_chan;
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);
nmxp_chan_cpy_sta_chan(sta_chan_code_pattern, station_code, channel_code, network_code);
snprintf(ret_channelList->channel[ret_channelList->number].name, NMXP_CHAN_MAX_SIZE_NAME, "%s.%s",
(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",
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.%s",
(network_code[0] != 0)? network_code : network_code_default, channelList->channel[i_chan_found].name,
(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->number++;
} else {
......
......@@ -82,6 +82,7 @@ int nmxp_data_init(NMXP_DATA_PROCESS *pd) {
pd->network[0] = 0;
pd->station[0] = 0;
pd->channel[0] = 0;
pd->location[0] = 0;
pd->packet_type = -1;
pd->x0 = -1;
pd->xn = -1;
......@@ -356,11 +357,12 @@ int nmxp_data_log(NMXP_DATA_PROCESS *pd, int flag_sample) {
/* nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_PACKETMAN, "%12d %5s.%3s rate=%03d (%s - %s) [%d, %d] pts=%04d (%d, %d, %d, %d) lat=%.1f len=%d\n", */
/* printf("%10d %5s.%3s 03dHz (%s - %s) lat=%.1fs [%d, %d] pts=%04d (%d, %d, %d, %d) len=%d\n", */
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "%s.%s.%3s %3dHz (%s - %s) lat %.1fs [%d, %d] (%d) %4dpts (%d, %d, %d, %d, %d)\n",
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "%s.%s.%3s.%2s %3dHz (%s - %s) lat %.1fs [%d, %d] (%d) %4dpts (%d, %d, %d, %d, %d)\n",
/* pd->key, */
NMXP_LOG_STR(pd->network),
(strlen(pd->station) == 0)? "XXXX" : NMXP_LOG_STR(pd->station),
(strlen(pd->channel) == 0)? "XXX" : NMXP_LOG_STR(pd->channel),
(strlen(pd->location) == 0)? "XX" : NMXP_LOG_STR(pd->location),
pd->sampRate,
NMXP_LOG_STR(str_start),
NMXP_LOG_STR(str_end),
......@@ -964,9 +966,10 @@ int nmxp_data_get_filename_ms(NMXP_DATA_SEED *data_seed, char *dirseedchan, char
msr->station,
nmxp_data_sepdir,
msr->channel);
snprintf(filenameseed, NMXP_DATA_MAX_SIZE_FILENAME, "%s.%s..%s.D.%d.%03d",
snprintf(filenameseed, NMXP_DATA_MAX_SIZE_FILENAME, "%s.%s.%s.%s.D.%d.%03d",
NMXP_DATA_NETCODE_OR_DEFAULT_NETWORK,
msr->station,
(msr->location[0] == 0)? "" : msr->location,
msr->channel,
nmxp_data_year_from_epoch(MS_HPTIME2EPOCH(msr->starttime)),
nmxp_data_yday_from_epoch(MS_HPTIME2EPOCH(msr->starttime)));
......@@ -976,9 +979,10 @@ int nmxp_data_get_filename_ms(NMXP_DATA_SEED *data_seed, char *dirseedchan, char
NMXP_DATA_NETCODE_OR_DEFAULT_NETWORK,
nmxp_data_sepdir,
msr->station);
snprintf(filenameseed, NMXP_DATA_MAX_SIZE_FILENAME, "%s.%s..%s.%d.%03d",
snprintf(filenameseed, NMXP_DATA_MAX_SIZE_FILENAME, "%s.%s.%s.%s.%d.%03d",
msr->station,
NMXP_DATA_NETCODE_OR_DEFAULT_NETWORK,
(msr->location[0] == 0)? "" : msr->location,
msr->channel,
nmxp_data_year_from_epoch(MS_HPTIME2EPOCH(msr->starttime)),
nmxp_data_yday_from_epoch(MS_HPTIME2EPOCH(msr->starttime)));
......@@ -1019,7 +1023,7 @@ int nmxp_data_msr_pack(NMXP_DATA_PROCESS *pd, NMXP_DATA_SEED *data_seed, void *p
int ret =0;
MSRecord *msr = pmsr;
int psamples;
int64_t psamples;
int precords;
flag verbose = 0;
int i;
......
......@@ -62,6 +62,8 @@ int if_dap_condition_only_one_time = 0;
#define EXIT_CONDITION ( EXIT_CONDITION_PRELIM )
#endif
#define CURRENT_LOCATION ( (params.location)? params.location : DEFAULT_NULL_LOCATION )
#define LOCCODE_OR_CURRENT_LOCATION ( (location_code[0] != 0)? location_code : CURRENT_LOCATION )
#define CURRENT_NETWORK ( (params.network)? params.network : DEFAULT_NETWORK )
#define NETCODE_OR_CURRENT_NETWORK ( (network_code[0] != 0)? network_code : CURRENT_NETWORK )
......@@ -168,7 +170,7 @@ int main (int argc, char **argv) {
#endif
char filename[500] = "";
char station_code[20] = "", channel_code[20] = "", network_code[20] = "";
char station_code[20] = "", channel_code[20] = "", network_code[20] = "", location_code[20] = "";
char cur_after_start_time_str[1024];
double cur_after_start_time = DEFAULT_BUFFERED_TIME;
......@@ -372,7 +374,7 @@ int main (int argc, char **argv) {
return 1;
}
channelList_subset = nmxp_chan_subset(channelList, NMXP_DATA_TIMESERIES, params.channels, CURRENT_NETWORK);
channelList_subset = nmxp_chan_subset(channelList, NMXP_DATA_TIMESERIES, params.channels, CURRENT_NETWORK, CURRENT_LOCATION);
/* Free the complete channel list */
if(channelList) {
......@@ -402,13 +404,18 @@ int main (int argc, char **argv) {
msr_list_chan[i_chan] = msr_init(NULL);
/* Separate station_code and channel_code */
if(nmxp_chan_cpy_sta_chan(channelList_subset->channel[i_chan].name, station_code, channel_code, network_code)) {
if(nmxp_chan_cpy_sta_chan(channelList_subset->channel[i_chan].name, station_code, channel_code, network_code, location_code)) {
nmxp_log(NMXP_LOG_NORM, NMXP_LOG_D_EXTRA, "%s.%s.%s\n",
NMXP_LOG_STR(NETCODE_OR_CURRENT_NETWORK), NMXP_LOG_STR(station_code), NMXP_LOG_STR(channel_code));
strncpy(msr_list_chan[i_chan]->network, NETCODE_OR_CURRENT_NETWORK, 11);
strncpy(msr_list_chan[i_chan]->station, station_code, 11);
strncpy(msr_list_chan[i_chan]->channel, channel_code, 11);
if(location_code[0] != 0) {
if(strcmp(location_code, DEFAULT_NULL_LOCATION) != 0) {
strncpy(msr_list_chan[i_chan]->location, location_code, 11);
}
}
msr_list_chan[i_chan]->reclen = params.reclen; /* Byte record length */
msr_list_chan[i_chan]->encoding = params.encoding; /* Steim 1 compression by default */
......@@ -569,7 +576,7 @@ int main (int argc, char **argv) {
/*Possible bug params not inited*/
if(params.flag_writefile) {
/* Open output file */
if(nmxp_chan_cpy_sta_chan(channelList_subset->channel[request_chan].name, station_code, channel_code, network_code)) {
if(nmxp_chan_cpy_sta_chan(channelList_subset->channel[request_chan].name, station_code, channel_code, network_code, location_code)) {
sprintf(filename, "%s.%s.%s_%s_%s.nmx",
NETCODE_OR_CURRENT_NETWORK,
station_code,
......@@ -594,7 +601,7 @@ int main (int argc, char **argv) {
/* Compute SNCL line */
/* Separate station_code_old_way and channel_code_old_way */
if(nmxp_chan_cpy_sta_chan(channelList_subset->channel[request_chan].name, station_code, channel_code, network_code)) {
if(nmxp_chan_cpy_sta_chan(channelList_subset->channel[request_chan].name, station_code, channel_code, network_code, location_code)) {
/* Write SNCL line */
fprintf(outfile, "%s.%s.%s.%s\n",
station_code,
......@@ -625,7 +632,7 @@ int main (int argc, char **argv) {
NMXP_MEM_FREE(pd);
}
pd = nmxp_processCompressedData(buffer, length, channelList_subset, NETCODE_OR_CURRENT_NETWORK);
pd = nmxp_processCompressedData(buffer, length, channelList_subset, NETCODE_OR_CURRENT_NETWORK, LOCCODE_OR_CURRENT_LOCATION);
/* Force value for timing_quality if declared in the command-line */
if(pd && params.timing_quality != -1) {
......@@ -833,7 +840,7 @@ int main (int argc, char **argv) {
return 1;
}
/* Get a subset of channel from arguments, in respect to the step 3 of PDS */
channelList_subset_waste = nmxp_chan_subset(channelList, NMXP_DATA_TIMESERIES, params.channels, CURRENT_NETWORK);
channelList_subset_waste = nmxp_chan_subset(channelList, NMXP_DATA_TIMESERIES, params.channels, CURRENT_NETWORK, CURRENT_LOCATION);
/* Free the complete channel list */
if(channelList) {
......@@ -898,7 +905,7 @@ int main (int argc, char **argv) {
NMXP_MEM_FREE(pd);
}
/* Process Compressed or Decompressed Data */
pd = nmxp_receiveData(naqssock, channelList_subset, NETCODE_OR_CURRENT_NETWORK, params.timeoutrecv, &recv_errno);
pd = nmxp_receiveData(naqssock, channelList_subset, NETCODE_OR_CURRENT_NETWORK, LOCCODE_OR_CURRENT_LOCATION, params.timeoutrecv, &recv_errno);
......@@ -1517,7 +1524,7 @@ int nmxptool_msr_send_mseed(NMXP_DATA_PROCESS *pd) {
int cur_chan;
MSRecord *msr = NULL;
int psamples;
int64_t psamples;
int precords;
flag verbose = 0;
......@@ -1574,10 +1581,11 @@ int nmxptool_print_seq_no(NMXP_DATA_PROCESS *pd) {
char str_time[200];
nmxp_data_to_str(str_time, pd->time);
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "Process %s.%s.%s %2d %d %d %s %dpts lat. %.1fs\n",
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "Process %s.%s.%s.%s %2d %d %d %s %dpts lat. %.1fs\n",
NMXP_LOG_STR(pd->network),
NMXP_LOG_STR(pd->station),
NMXP_LOG_STR(pd->channel),
NMXP_LOG_STR(pd->location),
pd->packet_type,
pd->seq_no,
pd->oldest_seq_no,
......
......@@ -109,7 +109,7 @@ int nmxptool_ew_pd2ewring (NMXP_DATA_PROCESS *pd, SHM_INFO *pregionOut, MSG_LOGO
strncpy(tbuf.trh2.sta, pd->station, TRACE2_STA_LEN);
strncpy(tbuf.trh2.chan, pd->channel, TRACE2_CHAN_LEN);
strncpy(tbuf.trh2.loc, LOC_NULL_STRING, 2);
strncpy(tbuf.trh2.loc, (pd->location[0]==0)? LOC_NULL_STRING : ( strcmp(pd->location, DEFAULT_NULL_LOCATION)==0? LOC_NULL_STRING : pd->location ), 2);
tbuf.trh2.version[0] = TRACE2_VERSION0;
tbuf.trh2.version[1] = TRACE2_VERSION1;
......@@ -443,6 +443,17 @@ int nmxptool_ew_proc_configfile (char * configfile, NMXPTOOL_PARAMS *params) {
}
}
else if (k_its ("DefaultLocationCode")) {
if ( (str = k_str ()) ) {
if(params->location) {
logit("et", "DefaultLocationCode has been replicated!\n");
return EW_FAILURE;
} else {
params->location = NMXP_MEM_STRDUP(str);
}
}
}
else if (k_its ("Channel")) {
if ( (str = k_str ()) ) {
if(params->statefile) {
......
......@@ -194,16 +194,18 @@ NMXP_LOG_STR(DAP_VERSION)
nmxp_log(NMXP_LOG_NORM_NO, NMXP_LOG_D_ANY, "\
Main arguments:\n\
-H, --hostname=HOST NaqsServer/DataServer hostname or IP address.\n\
-C, --channels=LIST List of NET.STA.CHAN separated by comma.\n\
-C, --channels=LIST List of NET.STA.CHAN.LOC separated by comma.\n\
NET is optional and used only for output.\n\
STA can be '*', it stands for all stations.\n\
CHAN can contain '?', it stands for any character.\n\
Network code will be assigned from the first\n\
pattern that includes station and channel.\n\