Commit 8826e627 authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

restoring changes in CVS repository

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.


SVN Path:     http://gpitrsvn.gpi.uni-karlsruhe.de/repos/TFSoftware/trunk
SVN Revision: 2670
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 79cb40d2
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: DL1direct.cc,v 1.4 2008-11-25 10:22:30 tforb Exp $
* $Id: DL1direct.cc,v 1.5 2008-11-27 16:26:08 tforb Exp $
* \author Thomas Forbriger
* \date 24/11/2008
*
......@@ -36,21 +36,22 @@
#define DL1DIRECT_VERSION \
"DL1DIRECT V1.0 directly send command to DL1 and receive the response"
#define DL1DIRECT_CVSID \
"$Id: DL1direct.cc,v 1.4 2008-11-25 10:22:30 tforb Exp $"
"$Id: DL1direct.cc,v 1.5 2008-11-27 16:26:08 tforb Exp $"
#include <iostream>
#include <string>
#include <tfxx/commandline.h>
#include <serialxx/serialport.h>
#include "thiesdl1.h"
#include "error.h"
using std::cout;
using std::cerr;
using std::endl;
struct Options {
bool verbose, timespecified;
std::string device, command,timestring;
bool verbose, debug;
std::string device;
};
int main(int iargc, char* argv[])
......@@ -60,7 +61,7 @@ int main(int iargc, char* argv[])
char usage_text[]=
{
DL1DIRECT_VERSION "\n"
"usage: DL1direct" "\n"
"usage: DL1direct [-v] [-D] [-d device] command [argument]" "\n"
" or: DL1direct --help|-h" "\n"
};
......@@ -68,6 +69,27 @@ int main(int iargc, char* argv[])
char help_text[]=
{
DL1DIRECT_CVSID
"\n"
"This program submits exactly one command to the DL1 data logger" "\n"
"and presents the response on standard output." "\n"
"\n"
"-v verbose mode" "\n"
"-D debug mode" "\n"
"-d dev device file dev" "\n"
"\n"
"supported commands are:" "\n"
"HH display commands accepted by DL1" "\n"
"LL dump status" "\n"
"PD power down" "\n"
"SS dump entire data buffer" "\n"
"MM display current data value" "\n"
"DD display date" "\n"
"ZZ display time" "\n"
"XX display station code" "\n"
"SD d set date and time" "\n"
"SCT set current date and time" "\n"
"ts d request data of day d" "\n"
"ds d request data since date d" "\n"
};
// define commandline options
......@@ -79,11 +101,9 @@ int main(int iargc, char* argv[])
// 1: verbose mode
{"v",arg_no,"-"},
// 2: device file name
{"p",arg_yes,"/dev/ttyS0"},
// 3: command
{"c",arg_yes,"LL"},
// 4: time
{"t",arg_yes,"-"},
{"d",arg_yes,"/dev/ttyS0"},
// 3: debug mode
{"D",arg_no,"-"},
{NULL}
};
......@@ -105,47 +125,70 @@ int main(int iargc, char* argv[])
exit(0);
}
/*
// dummy operation: print option settings
for (int iopt=0; iopt<2; iopt++)
{
cout << "option: '" << options[iopt].opt_string << "'" << endl;
if (cmdline.optset(iopt)) { cout << " option was set"; }
else { cout << "option was not set"; }
cout << endl;
cout << " argument (string): '" << cmdline.string_arg(iopt) << "'" << endl;
cout << " argument (int): '" << cmdline.int_arg(iopt) << "'" << endl;
cout << " argument (long): '" << cmdline.long_arg(iopt) << "'" << endl;
cout << " argument (float): '" << cmdline.float_arg(iopt) << "'" << endl;
cout << " argument (double): '" << cmdline.double_arg(iopt) << "'" << endl;
cout << " argument (bool): '";
if (cmdline.bool_arg(iopt))
{ cout << "true"; } else { cout << "false"; }
cout << "'" << endl;
}
while (cmdline.extra()) { cout << cmdline.next() << endl; }
// dummy operation: print rest of command line
while (cmdline.extra()) { cout << cmdline.next() << endl; }
*/
Options opt;
opt.verbose=cmdline.optset(1);
opt.device=cmdline.string_arg(2);
opt.command=cmdline.string_arg(3);
opt.timespecified=cmdline.optset(4);
opt.timestring=cmdline.string_arg(4);
opt.debug=cmdline.optset(3);
if (opt.verbose) { cout << "open port " << opt.device << endl; }
dl1::DL1 port(opt.device);
// send command
if (opt.verbose) { cout << "send command " << opt.command << endl; }
port.sendcommand(opt.command);
dl1::DL1 port(opt.device, opt.debug);
int timeout=2;
DL1_assert(cmdline.extra(), "ERROR: missing command");
std::string command=cmdline.next();
if (opt.verbose) { cout << "issue command " << command << endl; }
if (command == "LL") { port.sendLL(); }
else if ( command == "HH") { port.sendHH(); }
else if ( command == "PD") { port.sendPD(); }
else if ( command == "SS") { port.sendSS(); }
else if ( command == "MM") { port.sendMM(); }
else if ( command == "DD") { port.sendDD(); }
else if ( command == "ZZ") { port.sendZZ(); }
else if ( command == "XX") { port.sendXX(); }
else if ( command == "ts")
{
DL1_assert(cmdline.extra(), "ERROR: missing time string");
libtime::TAbsoluteTime date(cmdline.next());
if (opt.verbose) { cout << "request data for day "
<< date.timestring() << endl; }
port.sendts(date);
}
else if ( command == "ds")
{
DL1_assert(cmdline.extra(), "ERROR: missing time string");
libtime::TAbsoluteTime date(cmdline.next());
if (opt.verbose) { cout << "request all data since "
<< date.timestring() << endl; }
port.sendds(date);
// increase timeout
timeout=20;
if (opt.verbose) { cout << "increased timeout value to "
<< timeout << " seconds" << endl; }
}
else if ( command == "SD")
{
port.activate();
DL1_assert(cmdline.extra(), "ERROR: missing time string");
libtime::TAbsoluteTime date(cmdline.next());
if (opt.verbose) { cout << "set time to " << date.timestring() << endl; }
port.settime(date);
port.sendLL();
}
else if ( command == "SCD")
{
if (opt.verbose) { cout << "set curent time" << endl; }
libtime::TAbsoluteTime now=libtime::utc();
cout << "waiting for " << 60-now.second() << " seconds." << endl;
port.setcurrenttime();
port.sendLL();
}
else
{
DL1_abort("ERROR: unknown command");
}
// receive response
const int timeout=2;
while (true) { cout << "L: " << port.getline(timeout) << endl; }
while (true) { cout << port.getline(timeout) << endl; }
}
/* ----- END OF DL1direct.cc ----- */
/*! \file DL1logger.cc
* \brief data logging program
*
* ----------------------------------------------------------------------------
*
* $Id: DL1logger.cc,v 1.1 2008-11-27 16:26:08 tforb Exp $
* \author Thomas Forbriger
* \date 27/11/2008
*
* data logging program
*
* Copyright (c) 2008 by Thomas Forbriger (BFO Schiltach)
*
* ----
* 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
* ----
*
*
* REVISIONS and CHANGES
* - 27/11/2008 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define DL1LOGGER_VERSION \
"DL1LOGGER V1.0 data logging program for Thies DL1"
#define DL1LOGGER_CVSID \
"$Id: DL1logger.cc,v 1.1 2008-11-27 16:26:08 tforb Exp $"
#include <iostream>
#include <tfxx/commandline.h>
using std::cout;
using std::cerr;
using std::endl;
struct Options {
bool verbose;
}; // Options
/*======================================================================*/
int main(int iargc, char* argv[])
{
// define usage information
char usage_text[]=
{
DL1LOGGER_VERSION "\n"
"usage: DL1logger [-v] [-device device]" "\n"
" or: DL1logger --help|-h" "\n"
};
// define full help text
char help_text[]=
{
DL1LOGGER_CVSID
"\n"
"This program controls data logging from a Thies DL1 data logger." "\n"
"\n"
"-v be verbose" "\n"
"-device dev use device file \"dev\"" "\n"
};
// define commandline options
using namespace tfxx::cmdline;
static Declare options[]=
{
// 0: print help
{"help",arg_no,"-"},
// 1: verbose mode
{"v",arg_no,"-"},
// 2: verbose mode
{"device",arg_no,"/dev/ttyS0"},
{NULL}
};
// no arguments? print usage...
if (iargc<2)
{
cerr << usage_text << endl;
exit(0);
}
// collect options from commandline
Commandline cmdline(iargc, argv, options);
// help requested? print full help text...
if (cmdline.optset(0))
{
cerr << usage_text << endl;
cerr << help_text << endl;
exit(0);
}
/*
// dummy operation: print option settings
for (int iopt=0; iopt<2; iopt++)
{
cout << "option: '" << options[iopt].opt_string << "'" << endl;
if (cmdline.optset(iopt)) { cout << " option was set"; }
else { cout << "option was not set"; }
cout << endl;
cout << " argument (string): '" << cmdline.string_arg(iopt) << "'" << endl;
cout << " argument (int): '" << cmdline.int_arg(iopt) << "'" << endl;
cout << " argument (long): '" << cmdline.long_arg(iopt) << "'" << endl;
cout << " argument (float): '" << cmdline.float_arg(iopt) << "'" << endl;
cout << " argument (double): '" << cmdline.double_arg(iopt) << "'" << endl;
cout << " argument (bool): '";
if (cmdline.bool_arg(iopt))
{ cout << "true"; } else { cout << "false"; }
cout << "'" << endl;
}
while (cmdline.extra()) { cout << cmdline.next() << endl; }
// dummy operation: print rest of command line
while (cmdline.extra()) { cout << cmdline.next() << endl; }
*/
/*----------------------------------------------------------------------*/
Options opt;
opt.verbose=cmdline.optset(1);
/*----------------------------------------------------------------------*/
}
/* ----- END OF DL1logger.cc ----- */
# this is <Makefile>
# ----------------------------------------------------------------------------
# $Id: Makefile,v 1.4 2008-11-25 10:22:30 tforb Exp $
# $Id: Makefile,v 1.5 2008-11-27 16:26:09 tforb Exp $
#
# Copyright (c) 2008 by Thomas Forbriger (BFO Schiltach)
#
......@@ -31,7 +31,7 @@
HEADERS=$(wildcard *.h)
SUBSRC=error.cc dataline.cc record.cc thiesdl1.cc
SUBSRC=error.cc dataline.cc record.cc thiesdl1.cc functions.cc memory.cc
SUBOBS=$(patsubst %.cc,%.o,$(SUBSRC))
all:
......@@ -89,7 +89,7 @@ doxyview: doxyfullview
#======================================================================
DL1direct: %: %.o $(SUBOBS)
DL1logger DL1direct: %: %.o $(SUBOBS)
$(CXX) $(FLAGS) -o $@ $^ -I$(LOCINCLUDEDIR) \
-lserialxx -ltime++ -ltfxx \
-L$(LOCLIBDIR)
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: dataline.cc,v 1.3 2008-11-25 09:46:15 tforb Exp $
* $Id: dataline.cc,v 1.4 2008-11-27 16:26:09 tforb Exp $
* \author Thomas Forbriger
* \date 25/11/2008
*
......@@ -33,10 +33,10 @@
*
* ============================================================================
*/
#define TF_DATALINE_CC_VERSION \
"TF_DATALINE_CC V1.0 "
#define TF_DATALINE_CC_CVSID \
"$Id: dataline.cc,v 1.3 2008-11-25 09:46:15 tforb Exp $"
#define DL_DATALINE_CC_VERSION \
"DL_DATALINE_CC V1.0 "
#define DL_DATALINE_CC_CVSID \
"$Id: dataline.cc,v 1.4 2008-11-27 16:26:09 tforb Exp $"
#include "dataline.h"
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: dataline.h,v 1.2 2008-11-25 08:37:03 tforb Exp $
* $Id: dataline.h,v 1.3 2008-11-27 16:26:09 tforb Exp $
* \author Thomas Forbriger
* \date 25/11/2008
*
......@@ -35,17 +35,17 @@
*/
// include guard
#ifndef TF_DATALINE_H_VERSION
#ifndef DL_DATALINE_H_VERSION
#define TF_DATALINE_H_VERSION \
"TF_DATALINE_H V1.0 "
#define TF_DATALINE_H_CVSID \
"$Id: dataline.h,v 1.2 2008-11-25 08:37:03 tforb Exp $"
#define DL_DATALINE_H_VERSION \
"DL_DATALINE_H V1.0 "
#define DL_DATALINE_H_CVSID \
"$Id: dataline.h,v 1.3 2008-11-27 16:26:09 tforb Exp $"
namespace dl1 {
} // namespace dl1
#endif // TF_DATALINE_H_VERSION (includeguard)
#endif // DL_DATALINE_H_VERSION (includeguard)
/* ----- END OF dataline.h ----- */
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: error.h,v 1.3 2008-11-25 09:46:15 tforb Exp $
* $Id: error.h,v 1.4 2008-11-27 16:26:09 tforb Exp $
* \author Thomas Forbriger
* \date 25/11/2008
*
......@@ -35,12 +35,12 @@
*/
// include guard
#ifndef TF_ERROR_H_VERSION
#ifndef DL1_TF_ERROR_H_VERSION
#define TF_ERROR_H_VERSION \
"TF_ERROR_H V1.0 "
#define TF_ERROR_H_CVSID \
"$Id: error.h,v 1.3 2008-11-25 09:46:15 tforb Exp $"
#define DL1_TF_ERROR_H_VERSION \
"DL1_TF_ERROR_H V1.0 "
#define DL1_TF_ERROR_H_CVSID \
"$Id: error.h,v 1.4 2008-11-27 16:26:09 tforb Exp $"
namespace dl1 {
......@@ -184,6 +184,6 @@ namespace dl1 {
#define DL1_nonfatal_assert(F,C,M,V) \
if (F) { DL1_report_assert(C,M,V) } else { DL1_assert(C,M) }
#endif // TF_ERROR_H_VERSION (includeguard)
#endif // DL1_TF_ERROR_H_VERSION (includeguard)
/* ----- END OF error.h ----- */
/*! \file functions.cc
* \brief some functions to be used together with the DL1 data logger (implementation)
*
* ----------------------------------------------------------------------------
*
* $Id: functions.cc,v 1.1 2008-11-27 16:26:09 tforb Exp $
* \author Thomas Forbriger
* \date 27/11/2008
*
* some functions to be used together with the DL1 data logger (implementation)
*
* Copyright (c) 2008 by Thomas Forbriger (BFO Schiltach)
*
* ----
* 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
* ----
*
*
* REVISIONS and CHANGES
* - 27/11/2008 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define DL_FUNCTIONS_CC_VERSION \
"DL_FUNCTIONS_CC V1.0 "
#define DL_FUNCTIONS_CC_CVSID \
"$Id: functions.cc,v 1.1 2008-11-27 16:26:09 tforb Exp $"
#include "functions.h"
namespace dl1 {
} // namespace dl1
/* ----- END OF functions.cc ----- */
/*! \file functions.h
* \brief some functions to be used together with the DL1 data logger (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: functions.h,v 1.1 2008-11-27 16:26:10 tforb Exp $
* \author Thomas Forbriger
* \date 27/11/2008
*
* some functions to be used together with the DL1 data logger (prototypes)
*
* Copyright (c) 2008 by Thomas Forbriger (BFO Schiltach)
*
* ----
* 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
* ----
*
*
* REVISIONS and CHANGES
* - 27/11/2008 V1.0 Thomas Forbriger
*
* ============================================================================
*/
// include guard
#ifndef DL_FUNCTIONS_H_VERSION
#define DL_FUNCTIONS_H_VERSION \
"DL_FUNCTIONS_H V1.0 "
#define DL_FUNCTIONS_H_CVSID \
"$Id: functions.h,v 1.1 2008-11-27 16:26:10 tforb Exp $"
namespace dl1 {
} // namespace dl1
#endif // DL_FUNCTIONS_H_VERSION (includeguard)
/* ----- END OF functions.h ----- */
/*! \file memory.cc
* \brief maintain a local memory files (implementation)
*
* ----------------------------------------------------------------------------
*
* $Id: memory.cc,v 1.1 2008-11-27 16:26:10 tforb Exp $
* \author Thomas Forbriger
* \date 27/11/2008
*
* maintain a local memory files (implementation)
*
* Copyright (c) 2008 by Thomas Forbriger (BFO Schiltach)
*
* ----
* 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
* ----
*
*
* REVISIONS and CHANGES
* - 27/11/2008 V1.0 Thomas Forbriger
*
* ============================================================================
*/
#define DL_MEMORY_CC_VERSION \
"DL_MEMORY_CC V1.0 "
#define DL_MEMORY_CC_CVSID \
"$Id: memory.cc,v 1.1 2008-11-27 16:26:10 tforb Exp $"
#include "memory.h"
namespace dl1 {
} // namespace dl1
/* ----- END OF memory.cc ----- */
/*! \file memory.h
* \brief maintain a local memory files (prototypes)
*
* ----------------------------------------------------------------------------
*
* $Id: memory.h,v 1.1 2008-11-27 16:26:10 tforb Exp $
* \author Thomas Forbriger
* \date 27/11/2008
*
* maintain a local memory files (prototypes)
*
* Copyright (c) 2008 by Thomas Forbriger (BFO Schiltach)
*
* ----
* 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
* ----
*
*
* REVISIONS and CHANGES
* - 27/11/2008 V1.0 Thomas Forbriger
*
* ============================================================================