Commit 0b61e2e6 authored by thomas.forbriger's avatar thomas.forbriger Committed by thomas.forbriger
Browse files

new tested

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: 1439
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent 82341c6a
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: gsexx.h,v 1.12 2003-12-17 17:07:43 tforb Exp $
* $Id: gsexx.h,v 1.13 2003-12-30 17:22:40 tforb Exp $
* \author Thomas Forbriger
* \date 16/03/2002
*
......@@ -13,6 +13,7 @@
*
* REVISIONS and CHANGES
* - 16/03/2002 V1.0 Thomas Forbriger
* - 26/12/2003 V1.1 final checksum is defined to be absolute value
*
* ============================================================================
*/
......@@ -21,9 +22,9 @@
#ifndef TF_GSEXX_H_VERSION
#define TF_GSEXX_H_VERSION \
"TF_GSEXX_H V1.0 "
"TF_GSEXX_H V1.1 "
#define TF_GSEXX_H_CVSID \
"$Id: gsexx.h,v 1.12 2003-12-17 17:07:43 tforb Exp $"
"$Id: gsexx.h,v 1.13 2003-12-30 17:22:40 tforb Exp $"
// #include <libtime++.h>
#include<string>
......@@ -146,7 +147,7 @@ class TCHK2 {
//! Add a value to the checksum.
void add(const intT& value);
//! Return the checksum value.
intT value() const { return(Msum); }
intT value() const { return(abs(Msum)); }
//! write CHK2 line to string
std::string write() const;
//! read CHK2 line from istream
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: gsexx_TCHK2.cc,v 1.3 2003-12-15 07:53:34 tforb Exp $
* $Id: gsexx_TCHK2.cc,v 1.4 2003-12-30 17:22:41 tforb Exp $
* \author Thomas Forbriger
* \date 29/03/2002
*
......@@ -19,7 +19,7 @@
#define TF_GSEXX_TCHK2_CC_VERSION \
"TF_GSEXX_TCHK2_CC V1.0 "
#define TF_GSEXX_TCHK2_CC_CVSID \
"$Id: gsexx_TCHK2.cc,v 1.3 2003-12-15 07:53:34 tforb Exp $"
"$Id: gsexx_TCHK2.cc,v 1.4 2003-12-30 17:22:41 tforb Exp $"
#include<cmath>
#include <gsexx.h>
......@@ -53,7 +53,7 @@ void TCHK2::add(const intT& value)
// check for sample value overflow
if (abs(sample_value) >= modulo)
{
sample_value = sample_value - (sample_value/modulo)*modulo;
sample_value = sample_value - int(sample_value/modulo)*modulo;
}
// add the sample value to the checksum
......@@ -62,9 +62,8 @@ void TCHK2::add(const intT& value)
// check for checksum overflow
if (abs(Msum) >= modulo)
{
Msum = Msum - (Msum/modulo)*modulo;
Msum = Msum - int(Msum/modulo)*modulo;
}
}
/*----------------------------------------------------------------------*/
......@@ -88,10 +87,11 @@ std::string TCHK2::write() const
*/
void TCHK2::read(std::istream& is)
{
std::cerr << "std::istream& operator>>(std::istream& os, TCHK2& chk2)"
<< std::endl
<< "not yet defined!" << std::endl;
abort();
std::string lineID;
is >> lineID;
if (!GSEIDmatch<TCHK2>(lineID)) throw
Terror("ERROR (TCHK2::read): missing CHK2 line!");
is >> this->Msum;
}
} // namespace waveform
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: gsexx_TDAT2.cc,v 1.6 2003-12-23 16:39:16 tforb Exp $
* $Id: gsexx_TDAT2.cc,v 1.7 2003-12-30 17:22:41 tforb Exp $
* \author Thomas Forbriger
* \date 29/03/2002
*
......@@ -19,7 +19,7 @@
#define TF_GSEXX_TDAT2_CC_VERSION \
"TF_GSEXX_TDAT2_CC V1.0 "
#define TF_GSEXX_TDAT2_CC_CVSID \
"$Id: gsexx_TDAT2.cc,v 1.6 2003-12-23 16:39:16 tforb Exp $"
"$Id: gsexx_TDAT2.cc,v 1.7 2003-12-30 17:22:41 tforb Exp $"
#include <gsexx.h>
#include "gsexx_TDAT2.h"
......@@ -112,24 +112,31 @@ intT TDAT2read::operator()(std::istream& is)
std::string lineID;
is >> lineID;
if (!GSEIDmatch<TDAT2sum>(lineID)) throw
Terror("ERROR (TDAT2read): missing DAT2 line!");
Terror("ERROR (TDAT2::read): missing DAT2 line!");
char c=' ';
while (c != '\n') { is.get(c); }
}
if (!this->TDAT2sum::hot()) throw
Terror("ERROR (TDAT2read): requesting more samples than specified!");
Terror("ERROR (TDAT2::read): requesting more samples than specified!");
retval=convert(is);
this->TDAT2sum::add(retval);
// check checksum
if (!TDAT2sum::hot()) {
std::string lineID;
is >> lineID;
if (!GSEIDmatch<TCHK2>(lineID)) throw
Terror("ERROR (TDAT2read): missing CHK2 line!");
intT checksum;
is >> checksum;
if (this->TDAT2sum::checksum().value()!=checksum) throw
Terror("ERROR (TDAT2read): conflicting checksum in CHK2 line!");
TCHK2 checksum;
checksum.read(is);
if (this->TDAT2sum::checksum().value()!=checksum.value())
{
if (!Terror::silent)
{
std::cerr << "checksum read: " << checksum.value()
<< " calculated: " << this->TDAT2sum::checksum().value()
<< std::endl;
}
throw
Terror("ERROR (TDAT2::read): conflicting checksum in CHK2 line!");
}
}
return(retval);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment