Commit a95dcad7 authored by thomas.forbriger's avatar thomas.forbriger

Merge branch 'master' into copying

This is a legacy commit from before 2015-03-01.
It may be incomplete as well as inconsistent.
See COPYING.legacy and README.history for details.
parents 5f832c0e 5345be49
......@@ -45,9 +45,18 @@ junk*
*.log
*.tar.bz2
#
# secondary files which are produced by test cases for example
*.ps
*.pdf
*.TZ
*.TR
*.TT
*.su
*.sff
# ignore all source code files, which can automatically be created
# and which store user specific settings
# ----------------------------------------------------------------
src/green/gremlin1/libs/glq_dim.inc
#
#
# ----- END OF .gitignore -----
......@@ -17,7 +17,7 @@ all:
flist: $(filter-out %.bak,$(wildcard README* Makefile*)) \
TFbashrc GPLphrase LICENSE.GPL \
$(filter-out %.bak,$(wildcard pakete/README* pakete/Makefile*)) \
$(wildcard pakete/*.bashrc) $(wildcard pakete/*.sh) pakete/packagetest
$(wildcard pakete/*.bashrc) $(wildcard pakete/*.sh *.sh) pakete/packagetest
echo $^ | tr ' ' '\n' | sort > $@
.PHONY: edit
......
......@@ -109,7 +109,8 @@ CPPFLAGS=$(addprefix -I,$(LOCINCLUDEDIR) $(subst :, ,$(SERVERINCLUDEDIR))) \
# Fortran dependencies
# --------------------
%.d: %.f
echo $<: $(shell cat $< | egrep '^ +include' | cut -f 2 -d \' | sort | uniq) > $@
echo $< $(patsubst %.f,%.o,$<): \
$(shell cat $< | egrep '^ +include' | cut -f 2 -d \' | sort | uniq) > $@
include $(patsubst %.f,%.d,$(wildcard *.f))
#======================================================================
......
#!/bin/sh
# this is <compile.sh>
# ----------------------------------------------------------------------------
# $Id: $
#
# Copyright (c) 2014 by Thomas Forbriger (BFO Schiltach)
#
# compile TFSoftware
#
# ----
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
# ----
#
# Support automatic sequential compilation of maintained components in
# TFSoftware
#
# REVISIONS and CHANGES
# 13/02/2014 V1.0 Thomas Forbriger (thof)
# 19/02/2014 thof: added a few directories
#
# ============================================================================
#
# indicate version
VERSION=2014-02-19
#
# ============================================================================
# **** define usage functions ****
# ============================================================================
#
usage() {
cat >&2 << HERE
usage: compile.sh goal [goal ...]
[--verbose|-v]
or: compile.sh --help|-h
HERE
}
#
# ----------------------------------------------------------------------------
#
longusage() {
cat >&2 <<HERE
Compile maintained modules of TFSoftware
-v or --verbose be verbose
goal make goal
The script traverses along a list of directories, checks, whether the selected
goal is present in the Makefile in the directory and then executes make for
this goal. Several goals may be passed as a white-space separated list.
Options can be passed to make by enclosing them in quotes together with the
goal. The goal must be given first followed by options. Example:
compile.sh "install -i -j"
HERE
}
#
# ============================================================================
# **** define action functions ****
# ============================================================================
#
# true, if there a Makefile in the directory
hasmake() {
DIR="$1"
test -r $DIR/Makefile
}
#
# ----------------------------------------------------------------------------
#
# true, if the specific goal is available in the Makefile
hasgoal() {
THEGOAL=$(echo $1 | cut -f 1 -d ' ')
THEDIR="$2"
hasmake "$THEDIR" \
&& test $(egrep -c '^'"${THEGOAL}": ${THEDIR}/Makefile) -gt 0
}
#
# ----------------------------------------------------------------------------
#
# report directories
reportdirs() {
echo -e "\nDirectories:"
while test -n "$1"
do
echo " $1"
if ! hasmake "$1"
then
echo " ** missing Makefile!"
fi
shift
done
}
#
# ----------------------------------------------------------------------------
#
# make goal in given directory
makegoalindir() {
GOAL="$1"
DIR="$2"
echo -e "\nnext:\n directory: $DIR\n goal: $GOAL"
if hasmake "$DIR"
then
if hasgoal "$GOAL" "$DIR"
then
make -C "$DIR" $GOAL || { \
echo "make returns with error! aborting..."; exit 2; }
else
echo " ** goal missing in Makefile!"
fi
else
echo " ** missing Makefile!"
fi
}
#
# ----------------------------------------------------------------------------
#
# make goal
makegoal() {
GOAL="$1"
shift
while test -n "$1"
do
makegoalindir "$GOAL" "$1"
shift
done
}
#
# ============================================================================
# **** define variables ****
# ============================================================================
#
DIRECTORIES="libs \
conv/many conv/misc \
green/disan green/grepg green/tools green/synt green/gremlin1 \
green/gremlin1/tools \
misc/util \
synt/ref/refmet synt/misc synt/disper synt/tt \
ts/wf ts/hd ts/refract ts/cal ts/fidase ts/lisousi ts/misc \
ts/plot ts/sousou ts/stuploxx \
3rd/software-for-seismometry \
3rd/eterna/src \
conv/gfs/mine \
conv/su"
#
# ============================================================================
# **** action ****
# ============================================================================
#
#
echo '******* compile.sh V'$VERSION' *******'
#
# ----
# read command line options
# -------------------------
TEMP=$(getopt -o hl:irdvDfI:L: --long \
help,log:,install,report,docinstall,verbose,forcelocal,includedir:,libdir: \
-n $(basename $0) -- "$@") || {
echo >&2
echo >&2 "ERROR: command line parameters are incorrect!"
echo >&2 "aborting $0..."; exit 2
}
eval set -- "$TEMP"
#
# print usage if no command line parameter is present
USAGE=0
if test $# -le 1
then
USAGE=1
fi
#
# extract command line options
# ----------------------------
VERBOSE=0
while true; do
case "$1" in
--help|-h) usage; echo; longusage; exit 1;;
--) shift; break;;
-v|--verbose) VERBOSE=1;;
-D) set -x ;;
*) echo >&2 "ERROR: option $1 unprocessed!";
echo >&2 "aborting $0..."; exit 2;;
esac
shift
done
#
# ============================================================================
# print greetings
test $USAGE -gt 0 && usage
#
if test 0$VERBOSE -gt 0
then
reportdirs $DIRECTORIES
fi
while test -n "$1"
do
makegoal "$1" $DIRECTORIES
shift
done
# ----- END OF compile.sh -----
this is <COPYING>
============================================================================
conv/ThiesDL1
-------------
$Id: $
============================================================================
This is a collection of code that supports serial line access to the Thies
DL1 precipitation data logger. The binary executable DL1logger provides
continuous data acquisition and data logger control.
Copyright (C) 2008, 2014 by Thomas Forbriger
----
DL1logger is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
----
----- END OF COPYING -----
......@@ -50,6 +50,7 @@
#include <tfxx/commandline.h>
#include <serialxx/serialport.h>
#include "thiesdl1.h"
#include "functions.h"
#include "error.h"
using std::cout;
......@@ -71,7 +72,7 @@ int main(int iargc, char* argv[])
DL1DIRECT_VERSION "\n"
"usage: DL1direct [-v] [-D] [-d device] command [argument]" "\n"
" [-timeout d]" "\n"
" or: DL1direct --help|-h" "\n"
" or: DL1direct --help|-h | --Id|-I" "\n"
};
// define full help text
......@@ -86,6 +87,7 @@ int main(int iargc, char* argv[])
"-D debug mode" "\n"
"-d dev device file dev" "\n"
"-timeout d set timeout to \"d\" seconds" "\n"
"-Id report source code Id\n"
"\n"
"supported commands are:" "\n"
"HH display commands accepted by DL1" "\n"
......@@ -116,6 +118,8 @@ int main(int iargc, char* argv[])
{"D",arg_no,"-"},
// 4: debug mode
{"timeout",arg_yes,"2"},
// 5: debug mode
{"Id",arg_no,"-"},
{NULL}
};
......@@ -137,6 +141,19 @@ int main(int iargc, char* argv[])
exit(0);
}
// request source code Id
if (cmdline.optset(5))
{
cerr << "Thies DL1 data logger source code version:" << endl;
int i=0;
while (dl1::CVSIDS[i]!=0)
{
cerr << dl1::CVSIDS[i] << endl;
++i;
}
exit(0);
}
Options opt;
opt.verbose=cmdline.optset(1);
opt.device=cmdline.string_arg(2);
......
This diff is collapsed.
......@@ -3,7 +3,7 @@
# ----------------------------------------------------------------------------
# $Id$
#
# Copyright (c) 2008 by Thomas Forbriger (BFO Schiltach)
# Copyright (c) 2008, 2014 by Thomas Forbriger (BFO Schiltach)
#
# start DL1logger with specific path settings
#
......@@ -11,6 +11,8 @@
# 19/12/2008 V1.0 Thomas Forbriger
# 13/01/2009 V1.1 issue port settings
# 13/11/2009 V1.2 after hardware replacement: uses genuine serial port
# 24/03/2014 V1.3 adjust values for flocke
# 31/03/2014 V1.4 separate data and log path; remove bin type output
#
# ============================================================================
......@@ -20,22 +22,20 @@ LOGGERBINARY=$HOME/bin/linux/DL1logger
DLDEVICE=/dev/ttyS0
PORTSETTINGS=1c00:4:dad:a30:3:1c:7f:15:4:0:1:0:11:13:1a:0:12:f:17:16:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0
DATADIR=$HOME/data/DL1
DATADIR=$HOME/DL1/data
GSEDIR=$DATADIR/gse
DUMPDIR=$DATADIR/dump
DATAPATH=$DATADIR/%T/%Y/%M/DL1data%Y%M%D.%T
ACTIVEPATH=$DATADIR/%T/DL1current.%T
DATATYPES=ascii
MEMORY=$DATADIR/DL1memory
mkdir -pv $GSEDIR | /bin/logger -i -t "DL1logger $0" 2>&1
mkdir -pv $DUMPDIR | /bin/logger -i -t "DL1logger $0" 2>&1
echo stty -F $DLDEVICE $PORTSETTINGS | /bin/logger -i -t "DL1logger $0" 2>&1
stty -F $DLDEVICE $PORTSETTINGS | /bin/logger -i -t "DL1logger $0" 2>&1
stty -F $DLDEVICE -a | /bin/logger -i -t "DL1logger $0" 2>&1
$LOGGERBINARY -port $DLDEVICE \
-memory $MEMORY -datadir $GSEDIR -dumpdir $DUMPDIR \
-tolerateredundant -toleratewrongtime
$LOGGERBINARY -port $DLDEVICE -memory $MEMORY \
-datapath $DATAPATH -activepath $ACTIVEPATH \
-datatypes $DATATYPES -toleratewrongtime
# ----- END OF DL1logger.sh -----
This program controls data logging from a Thies DL1 data logger.
-xhelp print extended usage information
-verbose be verbose
-port device use device file "device"
-lastdate d in case the memory file is missing use this date
-memory path path to memory file
-activepath pattern pattern for path to store current data
-datapath pattern pattern for path to store data for completed days
-datatypes t[,t,...] data types to be used for output
-interval i poll data every i minutes
-toleratewrongtime tolerate lines with wrong time, do not abort
Path patterns
-------------
The patterned passed as an agrument of option '-datapath' specifies the
complete file path, including the actual file name. It must contain the
following templates:
%Y: will be replaced by current year
%M: will be replaced by current month
%D: will be replaced by current day of month
%T: will be replaced by file type (i.e. the libdatrwxx file type passed as
argument to option '-datatypes' or 'thiesdl1' in case of raw dumps)
All patterns must be present in order to make data files unique. If a pattern
is missing, this is reported as an error and causes the program to terminate.
Example: data/ThiesDL1/%T/%Y/%M/DL1%Y%M%D.%T
Data for the current (not yet completed) day are stored separately and are
updated in intervals specified by option '-interval'. Option '-activepath'
defines the data path for current files. The templates %Y, %M, and %D need not
be used in this pattern, however %T is mandatory.
Sampling interval
-----------------
Notice that the sampling interval of 60s used by the DL1 cannot be specified
properly in output formats storing sampling in terms of sampling rate. This
applies to the GSE and SFF formats. The data files will indicate a sampling
rate of 0.016667 Hz. This equals a sampling interval of
1 s / 0.016667 = 59.988002 s
The samples of one day thus span a time of
59.988002 s * 1440 = 86382.723 s
Hence there is an apparent sampling residual of
86400 s - 86382.723 s = 17.276545 s
in each file.
Tolerance mode
--------------
The Thies DL1 logger has a sequential memory. It simply adds data lines.
In cases lines with illegal time values can appear if the logger was set to a
wrong time value. These non-matching lines simply appear in the list of data
lines without comment and without the possibility to remove them. The Record
module checks for these conditions. If the program would inevitably abort upon
such conditions, it would be impossible to retrieve data in case of a
corrupted data set in the DL1 memory. For this reason the tolerance mode was
introduced. In case of weird data lines, a comment is written to the output
file.
Apparently a line for a specific minute can be added twice in case the logger
is interrupted. This is considered as normal operation. Sample values for
lines with identical time stamps are added. For details see the doxygen
documentation and page "Duplicate entries in Thies DL1 data" there.
Message logging
---------------
All informational log messages concerning parameter settings, daily operation,
etc are sent with log level "notice". Frequent informations concerning the
poll cycle are sent with log level "info". Non-matching data and time out
conditions are reported with log level "err" or "warning". All conditions that
may terminate the program are reported as "crit" or "emerg".
Operation
---------
This program controls the Thies DL1 data logger through a serial port
interface. I runs in an infinite loop.
Each morning at approximately 1:00 UT the data logger's clock is synchronized
with the time of the system the program is running on. The timing precision
cannot be better than +-1s. Its accuracy will depend on the system time of the
host running DL1logger.
The program maintains data files:
1. A dump of raw DL1 data tables
2. Data files in specified formats (as requested by option '-datatypes')
The daily files are created at about 1:00 UT. The files containing the current
day's data are updated after an interval specified by option '-interval'.
To ensure that no data is missed in case of unexpected termination of the
program, the date of the last complete data file is stored in a memory file
specified by the '-memory' option.
All messages are written to the system log. If the '-verbose' option is
selected, standard message are also sent to the terminal. The messages are
tagged with "DL1logger" mapped to uniform sampling with 60s sampling interval.
The DL1 provides samples at the end of a full minute. The value for the past
minute is mapped to the middle of the past minute (at 30s).
##
## config file to save and send DL1 messages on flocke
## thof 24.3.2014
##
## rsyslog configuration file to be placed in /etc/rsyslog.d
## on the host running DL1logger
##
## log messages are stored in local files in /etc/log
## an are sent to two hosts via TCP port 2222
##
# ######### Receiving Messages from Remote Hosts ##########
# TCP Syslog Server:
# provides TCP syslog reception and GSS-API (if compiled to support it)
$ModLoad imtcp.so # load module
$InputTCPServerRun 2222 # Starts a TCP server on selected port
if ($programname == 'DL1logger' or $syslogtag == 'DL1logger') and \
($syslogseverity <= 5 /* notice */) \
then action(type="omfile" File="/var/log/dl1log" FileCreateMode="0644")
& action(type="omfile" File="/var/log/dl1logall" FileCreateMode="0644")
& @@192.168.1.41:2222
& @@192.168.1.17:2222
& ~
if ($programname == 'DL1logger' or $syslogtag == 'DL1logger') and \
($syslogseverity <= 8 /* any */) \
then action(type="omfile" File="/var/log/dl1logall" FileCreateMode="0644")
& @@192.168.1.41:2222
& @@192.168.1.17:2222
& ~
##
## config file to save and send DL1 messages on stromboli and pinatubo
## thof 24.3.2014
##
## rsyslog configuration file to be placed in /etc/rsyslog.d
## on data control hosts (like stromboli and pinatubo)
##
## log messages are received via TCP port 2222 and are stored
## in local files in /etc/log
##
# ######### Receiving Messages from Remote Hosts ##########
# TCP Syslog Server:
# provides TCP syslog reception and GSS-API (if compiled to support it)
$ModLoad imtcp.so # load module
$InputTCPServerRun 2222 # Starts a TCP server on selected port
if ($programname == 'DL1logger' or $syslogtag == 'DL1logger') and \
($syslogseverity <= 5 /* notice */) \
then action(type="omfile" File="/var/log/dl1log" FileCreateMode="0644")
& action(type="omfile" File="/var/log/dl1logall" FileCreateMode="0644")
& ~
if ($programname == 'DL1logger' or $syslogtag == 'DL1logger') and \
($syslogseverity <= 8 /* any */) \
then action(type="omfile" File="/var/log/dl1log" FileCreateMode="0644")
& ~
# this is <DL1logger_syslog-ng_local.conf>
# ============================================================================
# configuration file for syslog-ng on DL1 recording host
# ------------------------------------------------------
# 2014-03-27
# ============================================================================
# BFO Thies DL1
destination dl1logall { file("/var/log/dl1logall" fsync(yes) perm(0644)); };
destination dl1log { file("/var/log/dl1log" fsync(yes) perm(0644)); };
destination dl1logremote1 { tcp("192.168.1.41" port(2222)); };
destination dl1logremote2 { tcp("192.168.1.17" port(2222)); };
filter f_dl1 { match('^DL1logger' value(MSGHDR)); };
filter f_dl1_notice { match('^DL1logger' value(MSGHDR)) and not level(info); };
log { source(src); filter(f_dl1); destination(dl1logall); };
log { source(src); filter(f_dl1_notice); destination(dl1log); };
log { source(src); filter(f_dl1); destination(dl1logremote1); };
log { source(src); filter(f_dl1); destination(dl1logremote2); };
#
# remove DL1 messages from normal system log
# replace the standard filter by the following filter:
## filter f_messages { not facility(news, mail) and not filter(f_iptables)
## and not filter(f_dl1); };
#
# ----- END OF DL1logger_syslog-ng_local.conf -----
# this is <DL1logger_syslog-ng_remote.conf>
# ============================================================================
# configuration file for syslog-ng on host receiving messages from DL1
# --------------------------------------------------------------------
# 2014-03-27
# ============================================================================
#
# BFO Thies DL1
destination dl1log { file("/var/log/dl1log" fsync(yes) perm(0644)); };
destination dl1logall { file("/var/log/dl1logall" fsync(yes) perm(0644)); };
source DL1 { tcp(port(2222)); };
filter f_dl1 { match('^DL1logger' value(MSGHDR)); };
filter f_dl1_notice { match('^DL1logger' value(MSGHDR)) and not level(info); };
log { source(DL1); filter(f_dl1); destination(dl1logall); };
log { source(DL1); filter(f_dl1_notice); destination(dl1log); };
#
# remove DL1 messages from normal system log
# replace the standard filter by the following filter:
## filter f_messages { not facility(news, mail) and not filter(f_iptables)
## and not filter(f_dl1); };
#
# ----- END OF DL1logger_syslog-ng_remote.conf -----
usage: DL1logger [-verbose] [-port device] [-lastdate date] [-memory path]
[-interval i] [-toleratewrongtime] [-activepath pattern]
[-datapath pattern] [-datatypes type[,type,...]]