40 if (pStateMachine != 0)
43 pStateMachine->AddLanguage(
this);
66 m_iResolution(iResolution),
72 m_bConditionalIterator(bIsConditional),
73 m_lConditionalValue(lConditonalValue),
76 m_IteratedVariables(0),
102 char cRawCharacter(0);
107 double dDoubleOutput(0.0);
108 const unsigned int NUMBER_BITS(
m_Value.size());
112 ::std::vector< ::oETCS::DF::VARIABLE_VALUE_VECTOR_T > ArrayValue(
m_iIterated);
114 ::std::vector< double > DoubleOutputs(
m_iIterated, 0.0);
115 ::std::vector< ::std::string > StringOutputs(
m_iIterated,
"" );
116 ::std::string RawString(
"");
141 #ifdef __OETCS_DF_LANGUAGE_DEBUG_OUTPUT__
143 ::std::cout <<
"CVariable::Calculate<<() bits after value map: ";
146 ::std::cout << *lb <<
"," << ::std::flush;
149 ::std::cout << ::std::endl;
150 #endif // __OETCS_DF_LANGUAGE_DEBUG_OUTPUT__
158 if (NUMBER_BITS > (
sizeof (
long long) * 8))
161 ::std::cerr <<
"In file " << __FILE__ <<
" at line " << __LINE__ <<
": size of value bit stack is bigger as system long long integer (" << (
sizeof (
long long) * 8) <<
"), rest will be ignored " << ::std::endl;
166 for (x = 0; x < NUMBER_BITS && x < (
sizeof (
long long) * 8); x++)
169 lRawInteger += (
long long)(
m_Value[x] << (NUMBER_BITS - 1 - x));
173 #ifdef __OETCS_DF_LANGUAGE_DEBUG_OUTPUT__
175 ::std::cout <<
"CVariable::Calculate() raw integer value: " << lRawInteger <<
" number bits: " << NUMBER_BITS << ::std::endl;
184 case ::oETCS::DF::CVariable::SECONDS:
185 case ::oETCS::DF::CVariable::METERS:
188 dDoubleOutput = lRawInteger;
202 (**Storage) = LocalStorage;
212 case ::oETCS::DF::CVariable::INTEGER:
225 (**Storage) = LocalStorage;
235 case ::oETCS::DF::CVariable::KILO_METERS_PER_HOUR:
238 dDoubleOutput = lRawInteger;
252 (**Storage) = LocalStorage;
262 case ::oETCS::DF::CVariable::CENTI_METERS:
265 dDoubleOutput = lRawInteger;
279 (**Storage) = LocalStorage;
289 case ::oETCS::DF::CVariable::PER_MILL:
292 dDoubleOutput = lRawInteger;
306 (**Storage) = LocalStorage;
322 for (x = 0; x < (
m_Value.size() / 8); x++)
325 for (y = 0; y < 8; y++)
328 cRawCharacter += (
m_Value[y + x * 8] << (7 - y));
333 RawString += cRawCharacter;
348 (**Storage) = LocalStorage;
360 for (x = 0; x < NUMBER_ITERATED; x++)
388 for (x = 0; x < NUMBER_SCALED; x++)
405 ArrayValue[x].push_back(
m_Value[y + x * m_lSize]);
413 ArrayValue[x] =
m_ValueMap.find(ArrayValue[x])->second->m_Value;
423 if (
m_lSize > (
sizeof(
long) * 8))
426 ::std::cerr <<
"In file " << __FILE__ <<
" at line " << __LINE__ <<
": size of value stack is bigger as system integer, rest will be ignored " << ::std::endl;
434 for (y = 0; y <
m_lSize && y < (
sizeof(long) * 8); y++)
437 RawIntegers[x] += long(ArrayValue[x][y] << (
m_lSize - 1 - y));
450 case ::oETCS::DF::CVariable::SECONDS:
451 case ::oETCS::DF::CVariable::METERS:
472 (**Storage) = LocalStorage;
482 case ::oETCS::DF::CVariable::INTEGER:
496 ::std::cerr <<
"In file " << __FILE__ <<
" at line " << __LINE__ <<
": integer array input type not (yet) defined " << ::std::endl;
504 case ::oETCS::DF::CVariable::KILO_METERS_PER_HOUR:
525 (**Storage) = LocalStorage;
535 case ::oETCS::DF::CVariable::CENTI_METERS:
556 (**Storage) = LocalStorage;
566 case ::oETCS::DF::CVariable::PER_MILL:
587 (**Storage) = LocalStorage;
603 for (y = 0; y < (
m_Value.size() / 8); y++)
606 for (z = 0; z < 8; z++)
609 cRawCharacter += char(
m_Value[z + y * 8] << (7 - z));
614 StringOutputs[x] += cRawCharacter;
627 ::std::cerr <<
"In file " << __FILE__ <<
" at line " << __LINE__ <<
": string array input type not (yet) defined " << ::std::endl;
646 (**Storage)->Calculate();
651 catch (const ::oETCS::DF::Error::CException&)
687 m_Value.resize(Value.length());
690 for (x = 0; x < Value.length(); x++)
693 m_Value[x] = Value[x];
706 ::std::vector< bool >::const_iterator Left(Bits.begin());
707 ::std::vector< bool >::const_iterator Right(Bits.begin());
712 if ((m_lSize * m_iIterated) > Bits.size())
720 Right += (m_lSize * m_iIterated);
723 m_Value = ::std::vector< bool >(Left, Right);
725 #ifdef __OETCS_DF_LANGUAGE_DEBUG_OUTPUT__
727 ::std::cout <<
"CVariable::operator<<() bits used: ";
728 for (decltype (m_Value.begin()) lb = m_Value.begin(); lb != m_Value.end(); lb++)
730 ::std::cout << *lb <<
"," << ::std::flush;
733 ::std::cout <<
" # bits: "<< m_Value.size() << ::std::endl;
749 if (not m_BitValues.empty() && m_BitValues[0]->operator ->() !=
nullptr)
752 Bits = (*m_BitValues[0])->GetBitVector(m_lSize);
776 ::oETCS::DF::VARIABLE_VALUE_VECTOR_T::iterator vv;
777 ::std::stringstream Conversion;
778 decltype (Value.begin()) v;
779 long long llValue(0);
784 const unsigned char* pByte(0);
785 bool bConverted(
false);
790 if (not Value.empty())
800 Conversion << Value.substr(1, Value.size() - 1);
803 bConverted = (Conversion >> dValue);
820 ValueVector.resize(8 *
sizeof (llValue));
823 vv = ValueVector.begin();
826 pByte =
reinterpret_cast< const unsigned char*
>(&llValue) +
sizeof (llValue) - 1;
829 for (x = 0; x <
sizeof (llValue); x++)
832 for (y = 0; y < 8; y++)
835 *vv = ((1 << (7 - y)) & (*pByte)) == 0 ?
false :
true;
853 Conversion << Value.substr(1, Value.size() - 1);
856 bConverted = (Conversion >> llValue);
867 ValueVector.resize(8 *
sizeof (llValue));
870 vv = ValueVector.begin();
873 pByte =
reinterpret_cast< const unsigned char*
>(&llValue) +
sizeof (llValue) - 1;
876 for (x = 0; x <
sizeof (llValue); x++)
879 for (y = 0; y < 8; y++)
882 *vv = ((1 << (7 - y)) & (*pByte));
900 ValueVector.resize((Value.size() - 1) * 8);
903 for (v = Value.begin() + 1, vv = ValueVector.begin(); v != Value.end() && vv != ValueVector.end(); v++, vv + 8)
906 for (x = 0; x < 8; x++)
909 *(vv + x) = ((*v) & (1 << x)) == 0 ? 0 : 1;
923 ValueVector.resize(Value.size());
926 for (v = Value.begin(), vv = ValueVector.begin(); v != Value.end() && vv != ValueVector.end(); v++, vv++)
929 *vv = (*v ==
'0' ?
false :
true);
941 return (ValueVector);
953 m_Variables(Variables)
979 unsigned long lSize(0);
980 const unsigned int NUMBER_VARIABLES(
m_Variables.size());
984 for (x = 0; x < NUMBER_VARIABLES; x++)
1003 unsigned char cID(0);
1005 const unsigned int NUMBER_VARIABLES(m_Variables.size());
1006 ::std::vector< bool >::iterator Left(Bits.begin());
1007 ::std::vector< bool >::iterator Right(Bits.begin());
1012 if ((
sizeof (m_cID) * 8) > Bits.size())
1021 Right +=
sizeof (m_cID) * 8;
1024 for (x = 0; x < (
sizeof (m_cID) * 8); x++)
1027 cID += (Bits[x]) << ((
sizeof (m_cID) * 8) - 1 - x);
1031 #ifdef __OETCS_DF_LANGUAGE_DEBUG_OUTPUT__
1033 ::std::cout <<
"CPacket::operator<<() found ID: " << int(cID) <<
" while ID of this packet " << int(m_cID) << ::std::endl;
1039 #ifdef __OETCS_DF_LANGUAGE_DEBUG_OUTPUT__
1041 ::std::cout <<
"CPacket::operator<<() found matching ID: " << int(m_cID) << ::std::endl;
1045 for (x = 0; x < NUMBER_VARIABLES; x++)
1048 if (Bits.size() < m_Variables[x]->GetSize())
1058 Right = Left + m_Variables[x]->GetSize();
1061 (*m_Variables[x]) << ::std::vector< bool >(Left, Right);
1064 m_Variables[x]->Calculate();
1067 Bits.erase(Left, Right);
1070 Left = Bits.begin();
1073 catch (const ::oETCS::DF::Error::CException&)
1103 decltype (m_Variables.begin()) x(0);
1104 ::std::vector< bool > LocalBits(0);
1112 for (x = m_Variables.begin(); x != m_Variables.end(); x++)
1118 Bits.insert(Bits.end(), LocalBits.begin(), LocalBits.end());
1161 unsigned long lSize(0);
1162 const unsigned int NUMBER_PACKETS(
m_Packets.size());
1163 const unsigned int NUMBER_HEADER(
m_Header.size());
1168 for (x = 0; x < NUMBER_HEADER; x++)
1176 for (x = 0; x < NUMBER_PACKETS; x++)
1196 const unsigned int NUMBER_VARIABLES_HEADER(m_Header.size());
1197 const unsigned int NUMBER_PACKETS(m_Packets.size());
1198 ::std::vector< bool > LocalBits(Bits);
1199 ::std::vector< bool >::iterator Left(LocalBits.begin());
1200 ::std::vector< bool >::iterator Right(LocalBits.begin());
1201 ::std::vector< unsigned char > FoundPacketIDs(0);
1206 #ifdef __OETCS_DF_LANGUAGE_DEBUG_OUTPUT__
1208 ::std::cout <<
"CTelegram::operator<<() bits before header: ";
1209 for (decltype (LocalBits.begin()) lb = LocalBits.begin(); lb != LocalBits.end(); lb++)
1211 ::std::cout << *lb <<
"," << ::std::flush;
1214 ::std::cout <<
" # bits: "<< LocalBits.size() << ::std::endl;
1215 #endif // __OETCS_DF_LANGUAGE_DEBUG_OUTPUT__
1219 for (x = 0; x < NUMBER_VARIABLES_HEADER; x++)
1224 Right = Left + m_Header[x]->GetSize();
1227 if (Right == LocalBits.end())
1235 (*m_Header[x]) << ::std::vector< bool >(Left, Right);
1242 m_Header[x]->Calculate();
1245 catch (const ::oETCS::DF::Error::CException&)
1255 LocalBits.erase(LocalBits.begin(), Right);
1258 #ifdef __OETCS_DF_LANGUAGE_DEBUG_OUTPUT__
1260 ::std::cout <<
"CTelegram::operator<<() bits after header: ";
1261 for (decltype (LocalBits.begin()) lb = LocalBits.begin(); lb != LocalBits.end(); lb++)
1263 ::std::cout << *lb <<
"," << ::std::flush;
1266 ::std::cout <<
" # bits: "<< LocalBits.size() << ::std::endl;
1271 for (x = 0; x < NUMBER_PACKETS; x++)
1276 (*m_Packets[x]) << LocalBits;
1279 FoundPacketIDs.push_back(m_Packets[x]->m_cID);
1282 #ifdef __OETCS_DF_LANGUAGE_DEBUG_OUTPUT__
1284 ::std::cout <<
"CTelegram::operator<<() bits after packet: ";
1285 for (decltype (LocalBits.begin()) lb = LocalBits.begin(); lb != LocalBits.end(); lb++)
1287 ::std::cout << *lb <<
"," << ::std::flush;
1290 ::std::cout <<
" # bits: "<< LocalBits.size() << ::std::endl;
1291 #endif // __OETCS_DF_LANGUAGE_DEBUG_OUTPUT__
1294 catch (const ::oETCS::DF::Error::CInput&)
1299 catch (const ::oETCS::DF::Error::CException&)
1311 if (!LocalBits.empty())
1319 return (FoundPacketIDs);
1330 decltype (m_Header.begin()) x(0);
1331 decltype (m_Packets.begin()) y(0);
1332 ::std::vector< bool > LocalBits(0);
1340 for (x = m_Header.begin(); x != m_Header.end(); x++)
1346 Bits.insert(Bits.begin(), LocalBits.begin(), LocalBits.end());
1351 for (y = m_Packets.begin(); y != m_Packets.end(); y++)
1357 Bits.insert(Bits.begin(), LocalBits.begin(), LocalBits.end());