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

new code

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: 1349
SVN UUID:     67feda4a-a26e-11df-9d6e-31afc202ad0c
parent d48f8799
# this is <Makefile>
# ----------------------------------------------------------------------------
# $Id: Makefile,v 1.4 2002-11-14 14:34:52 forbrig Exp $
# $Id: Makefile,v 1.5 2003-06-24 07:45:54 tforb Exp $
#
# Copyright (c) 2002 by Thomas Forbriger (IMG Frankfurt)
#
......@@ -85,8 +85,8 @@ doxybrief: docbrief/html/index.html
doxyfull: doc/html/index.html
doxydoc: doxybrief doxyfull
doxyfullview: doxyfull; netscape doc/html/index.html &
doxybriefview: doxybrief; netscape docbrief/html/index.html &
doxyfullview: doxyfull; mozilla file:$(DOXYWWWPATH)/html/index.html &
doxybriefview: doxybrief; mozilla file:/docbrief/html/index.html &
doxyview: doxyfullview doxybrief
#======================================================================
......
......@@ -3,7 +3,7 @@
*
* ----------------------------------------------------------------------------
*
* $Id: gsexx_cm6.cc,v 1.2 2002-04-01 21:48:34 forbrig Exp $
* $Id: gsexx_cm6.cc,v 1.3 2003-06-24 07:45:54 tforb Exp $
* \author Thomas Forbriger
* \date 29/03/2002
*
......@@ -19,10 +19,11 @@
#define TF_GSEXX_CM6_CC_VERSION \
"TF_GSEXX_CM6_CC V1.0 "
#define TF_GSEXX_CM6_CC_CVSID \
"$Id: gsexx_cm6.cc,v 1.2 2002-04-01 21:48:34 forbrig Exp $"
"$Id: gsexx_cm6.cc,v 1.3 2003-06-24 07:45:54 tforb Exp $"
#include <gsexx.h>
#include "gsexx_TDAT2.h"
#include <cmath>
namespace GSE2 {
namespace waveform {
......@@ -52,7 +53,79 @@ namespace CM6 {
*/
string encode(const intT& value)
{
// string variable to store return value
string retval;
// The original version of the core of this function was coded by Stefan
// Stange. The code (compress_6b) can be found in gse_functions.c in is
// library. Here is the original comment by Stefan Stange:
/*********************************************************************
Function: compress_6b
This routine computes the 6Byte encoding of integer data according
GSE2.0 based on cmprs6.f in CODECO by Urs Kradolfer. Again, here we
can cope with consecutive chunks of a data series.
Input is the data series (integer) and the # of samples. The character
representation of the data is successively stored to the dynamic
character buffer written by Andreas Greve.
Attention: Clipping is at 2**27 - 1 although it looks like 2**28 -1
in the FORTRAN-Code.
St. Stange, 28.4.1998
*********************************************************************/
// this defines the value to character mapping
char achar[] =
" +-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
// some powers of 2
// 2**5 2**10 2**15 2**20 2**25 2**27
long expo_2[] = { 0, 32, 1024, 32768, 1048576, 33554432, 134217728 };
// some powers of 2 minus 1
// -1 + 2**5 2**10 2**15 2**20 2**25
long expo_2m1_o[] = { 01, 037, 01777, 077777, 03777777, 0177777777 };
// internal values
int nflag;
int mflag = 32;
long jc, si;
int case_expo;
nflag = 1;
// convert sign
if (value < 0 )
{ nflag += 16; value = -value; }
// clip at 2**27 -1
// value = (value >= expo_2[6]) ? expo_2[6] - 1 : value;
// the original code clipped at 2**27 -1
// we consider a number that large to be illegal
if (value >= expo_2[6])
throw GSE::Terror("ERROR (CM6::encode): illegal value");
// compute the exponent base 2
std::frexp (double(value), &case_expo);
// and reduce by integer division
case_expo = case_expo/5;
// check value
if (case_expo > 5 || case_expo < 0)
throw GSE::Terror("ERROR (CM6::encode): illegal exponent");
for ( ; case_expo > 0; case_expo--)
{
// create one character per turn
jc = value/expo_2[case_expo] + nflag + mflag;
/*if (jc > 64 || jc < 1) return jc;*/
retval.append(achar[jc]);
value = value & expo_2m1_o[case_expo];
nflag = 1;
}
// one character to go
jc = value + nflag;
retval.append(achar[jc]);
return(retval);
}
......@@ -60,10 +133,10 @@ string encode(const intT& value)
//! %CM6 subformat decoding function.
/*!
* The function dencodes an integer value from %CM6 subformat. It takes an
* The function decodes an integer value from %CM6 subformat. It takes an
* input stream to read from. This is necessary since the function has to skip
* line-ends on its own. If you want to read from a character string, use
* string streams. The numerical value return ist just the next decoded
* string streams. The numerical value returned is just the next decoded
* integer value from the stream. It is a second difference value. You still
* have to remove second differences afterwards.
*
......
Markdown is supported
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