openETCS
case study for the European Train Control System developed for the authors dissertation
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Attributes | List of all members
oETCS::DF::CVariable Class Reference

class for holding variable values More...

#include <Language.h>

Inheritance diagram for oETCS::DF::CVariable:
Inheritance graph
Collaboration diagram for oETCS::DF::CVariable:
Collaboration graph

Public Types

enum  UNIT_T {
  SECONDS = 0,
  KILO_METERS_PER_HOUR = 1,
  METERS = 2,
  CENTI_METERS = 3,
  PER_MILL = 4,
  INTEGER = 5,
  DOUBLE = 6,
  STRING = 7
}
 enum type for the physical unit type of a variable More...

Public Member Functions

void Calculate () throw (::oETCS::DF::Error::CException)
 calculates the value
 CVariable (oETCS::DF::CEVCStateMachine *const pStateMachine, const unsigned int &iResolution, const UNIT_T &eUnit, const unsigned long &lSize, const bool &bIsConditional=false, const long &lConditonalValue=0, const ::std::map< VARIABLE_VALUE_VECTOR_T, CVariable * > &ValueMap=::std::map< VARIABLE_VALUE_VECTOR_T, CVariable * >()) throw ()
 general constructor
 CVariable (const CVariable &Source)
 deleted copy constructor
unsigned long GetSize () const throw ()
 gets the size of the variable depending on the value stored
CVariableoperator<< (const ::std::vector< bool > &Bits) throw (::oETCS::DF::Error::CException)
 streaming operator for filling a telegram with raw data
CVariableoperator= (const CVariable &Source)
 deleted assignment operator
CVariableoperator>> (::std::vector< bool > &Bits) throw (::oETCS::DF::Error::CException)
 streaming operator for getting the raw data in a variable
void SetValue (const ::std::string &Value) throw ()
 sets explicitly the value of a variable by a string
virtual ~CVariable () throw ()

Static Public Member Functions

static
oETCS::DF::VARIABLE_VALUE_VECTOR_T 
StringToValueVector (const ::std::string &Value) throw ()
 convertion method

Public Attributes

::std::vector
< oETCS::DF::CBitFlow * > 
m_BitValues
 vector of pointers to bit flows to storages
const UNIT_T m_eUnit
 unit of variable value
const unsigned int m_iResolution
 fixed resolution of a variable
::std::vector< CVariable * > m_IteratedVariables
 vector with pointers to all variables which are iterated by this instance
const unsigned long m_lSize
 size of the variable in bit
::std::vector< CVariable * > m_ScaledVariables
 vector with pointers to allvariable objecst which are scaled by this instance

Private Attributes

const bool m_bConditionalIterator
 flag for variable being a conditional iterator
double m_dFactor
 scalar factor
unsigned int m_iIterated
 iteration factor
const long m_lConditionalValue
 conditional value used, if conditional operator
::std::vector
< oETCS::DF::VARIABLE_VALUE_T
m_Value
 vector as bit storages for the value of a variable
const ::std::map
< oETCS::DF::VARIABLE_VALUE_VECTOR_T,
CVariable * > 
m_ValueMap
 optional map of certain byte values to predefined variables

Detailed Description

class for holding variable values

Definition at line 80 of file Language.h.

Member Enumeration Documentation

enum type for the physical unit type of a variable

Enumerator:
SECONDS 

seconds as physical unit

KILO_METERS_PER_HOUR 

km/h as physical unit

METERS 

meters as physical unit

CENTI_METERS 

centi meters as physical unit

PER_MILL 

per mill as physical unit (unit less)

INTEGER 

plain integer as physical unit (unit less)

DOUBLE 

plain double as physical unit (unit less)

STRING 

plain string as physical unit (unit less)

Definition at line 86 of file Language.h.

Constructor & Destructor Documentation

oETCS::DF::CVariable::CVariable ( oETCS::DF::CEVCStateMachine *const  pStateMachine,
const unsigned int &  iResolution,
const UNIT_T eUnit,
const unsigned long &  lSize,
const bool &  bIsConditional = false,
const long &  lConditonalValue = 0,
const ::std::map< VARIABLE_VALUE_VECTOR_T, CVariable * > &  ValueMap = ::std::map< VARIABLE_VALUE_VECTOR_TCVariable * >() 
) throw ()
explicit

general constructor

Parameterises the Packet with all constant members. The Packet object takes over the posession of all variables/memory passed by pointer.

Parameters
[in]pStateMachinepointer to parent EVC state machine
[in]iResolutionnumerical resolution
[in]eUnitphysical unit
[in]bIsConditionaloptional flag for an conditional iterator
in]lConditionalValue optional value used for the conditional iterator
[in]ValueMapoptional map of values

Definition at line 64 of file Language.cpp.

oETCS::DF::CVariable::CVariable ( const CVariable Source)

deleted copy constructor

oETCS::DF::CVariable::~CVariable ( ) throw ()
virtual

Definition at line 88 of file Language.cpp.

Member Function Documentation

void oETCS::DF::CVariable::Calculate ( ) throw (::oETCS::DF::Error::CException)

calculates the value

Calculates the real value, including value map and scaling, and stores it in the storage object under m_pValueStorage, if available.

Definition at line 99 of file Language.cpp.

References oETCS::DF::CStorage::Calculate(), oETCS::DF::DOUBLE, m_bConditionalIterator, m_BitValues, oETCS::DF::CStorage::m_dDoubleInput, m_dFactor, oETCS::DF::CStorage::m_DoubleArrayInput, m_eUnit, oETCS::DF::CStorage::m_iIntInput, m_iIterated, m_iResolution, m_IteratedVariables, m_lConditionalValue, m_lSize, m_ScaledVariables, oETCS::DF::CStorage::m_StringInput, m_Value, m_ValueMap, oETCS::DF::STRING, and STRING.

Here is the call graph for this function:

unsigned long oETCS::DF::CVariable::GetSize ( ) const throw ()

gets the size of the variable depending on the value stored

Returns
size of the variable in bits

Definition at line 668 of file Language.cpp.

References m_iIterated, and m_lSize.

oETCS::DF::CVariable & oETCS::DF::CVariable::operator<< ( const ::std::vector< bool > &  Bits) throw (::oETCS::DF::Error::CException)

streaming operator for filling a telegram with raw data

Parameters
[in]Bitsvector of boolean holding the the exact amount of bit raw data in little endian format

Definition at line 703 of file Language.cpp.

CVariable& oETCS::DF::CVariable::operator= ( const CVariable Source)

deleted assignment operator

oETCS::DF::CVariable & oETCS::DF::CVariable::operator>> ( ::std::vector< bool > &  Bits) throw (::oETCS::DF::Error::CException)

streaming operator for getting the raw data in a variable

Parameters
[out]Bitsvector of boolean holding the bit raw data in little endian format
Returns
reference to this instance

Definition at line 745 of file Language.cpp.

void oETCS::DF::CVariable::SetValue ( const ::std::string &  Value) throw ()

sets explicitly the value of a variable by a string

Parameters
[in]Valuenew value as string

Definition at line 680 of file Language.cpp.

oETCS::DF::VARIABLE_VALUE_VECTOR_T oETCS::DF::CVariable::StringToValueVector ( const ::std::string &  Value) throw ()
static

convertion method

Converts a string (encoded by a prefix) to the value vector type used by language variables.

Prefixes:
d - double value s - string value i - integer value all other - binary value

Parameters
[in]Valuestring with the value to convert
Returns
converted value vector

Definition at line 771 of file Language.cpp.

Member Data Documentation

const bool oETCS::DF::CVariable::m_bConditionalIterator
private

flag for variable being a conditional iterator

Definition at line 289 of file Language.h.

Referenced by Calculate().

::std::vector< oETCS::DF::CBitFlow* > oETCS::DF::CVariable::m_BitValues

vector of pointers to bit flows to storages

Definition at line 305 of file Language.h.

Referenced by Calculate(), oETCS::UT::CFunctionBlock::setUp(), and oETCS::UT::CLanguage::setUp().

double oETCS::DF::CVariable::m_dFactor
private

scalar factor

Is multiplied with any numerical result of the value calculation

Definition at line 282 of file Language.h.

Referenced by Calculate().

const UNIT_T oETCS::DF::CVariable::m_eUnit

unit of variable value

Definition at line 246 of file Language.h.

Referenced by Calculate().

unsigned int oETCS::DF::CVariable::m_iIterated
private

iteration factor

Defines how many times a variable object is iterated.

Definition at line 273 of file Language.h.

Referenced by Calculate(), and GetSize().

const unsigned int oETCS::DF::CVariable::m_iResolution

fixed resolution of a variable

Definition at line 239 of file Language.h.

Referenced by Calculate().

::std::vector< CVariable* > oETCS::DF::CVariable::m_IteratedVariables

vector with pointers to all variables which are iterated by this instance

Definition at line 319 of file Language.h.

Referenced by Calculate(), and oETCS::UT::CLanguage::setUp().

const long oETCS::DF::CVariable::m_lConditionalValue
private

conditional value used, if conditional operator

Definition at line 296 of file Language.h.

Referenced by Calculate().

const unsigned long oETCS::DF::CVariable::m_lSize

size of the variable in bit

Definition at line 253 of file Language.h.

Referenced by Calculate(), and GetSize().

::std::vector< CVariable* > oETCS::DF::CVariable::m_ScaledVariables

vector with pointers to allvariable objecst which are scaled by this instance

Definition at line 312 of file Language.h.

Referenced by Calculate(), and oETCS::UT::CLanguage::setUp().

::std::vector< oETCS::DF::VARIABLE_VALUE_T > oETCS::DF::CVariable::m_Value
private

vector as bit storages for the value of a variable

Index 0 (m_Value[0]) is the LSB.

Definition at line 264 of file Language.h.

Referenced by Calculate().

const ::std::map< oETCS::DF::VARIABLE_VALUE_VECTOR_T, CVariable* > oETCS::DF::CVariable::m_ValueMap
private

optional map of certain byte values to predefined variables

Definition at line 328 of file Language.h.

Referenced by Calculate().


The documentation for this class was generated from the following files:

Copyright (C) 2010-2012 Johannes Feuser (feuser@uni-bremen.de)
The openETCS library 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 3 of the License, or any later version.
The openETCS library 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 the openETCS library. If not, see "http://www.gnu.org/licenses/.