// *** Файл h/ucp6x.hpp ***
/*
* EMI Protocol
*/
/*!
* \file
* \brief PDU для UCP60-серии.
*/
#if !defined( EMI_PDU_1_UCP6X_HPP )
#define EMI_PDU_1_UCP6X_HPP
#include <emi_pdu_1/h/common.hpp>
namespace emi_pdu_1 {
namespace ucp6x {
#if 0 /* RuCodeGen::Embedded::begin */
require 'emi_pdu_1/pdu_generator'
pdu_class :operation_t do |pdu|
pdu.decl_file :script_relative => 'ucp6x.operation.hpp.inl'
pdu.impl_file :script_relative => '../ucp6x.operation.cpp.inl'
pdu.field :OAdC, num_char( 1, 16 ), :presence => :mandatory
pdu.field :OTON, num_char( 1 )
pdu.field :ONPI, num_char( 1 )
pdu.field :STYP, num_char( 1 ), :presence => :mandatory
pdu.field :PWD, hex_char( 16 ), :presence => :mandatory
pdu.field :NPWD, hex_char( 16 )
pdu.field :VERS, num_char( 4, 4 ), :presence => :mandatory,
:default_value => '"0100"'
pdu.field :LAdC, num_char( 1, 16 )
pdu.field :LTON, any_char( 1 )
pdu.field :LNPI, any_char( 1 )
pdu.field :OPID, num_char( 1, 2 )
pdu.field :RES1, num_char( 1, 128 )
end
pdu_class :positive_result_t do |pdu|
pdu.decl_file :script_relative => 'ucp6x.positive_result.hpp.inl'
pdu.impl_file :script_relative => '../ucp6x.positive_result.cpp.inl'
pdu.field :ACK, any_char( 1 ), :presence => :mandatory,
:default_value => 'ack_value'
pdu.field :SM, any_char( 128 )
end
pdu_class :negative_result_t do |pdu|
pdu.decl_file :script_relative => 'ucp6x.negative_result.hpp.inl'
pdu.impl_file :script_relative => '../ucp6x.negative_result.cpp.inl'
pdu.field :NAcK, any_char( 1 ), :presence => :mandatory,
:default_value => 'nack_value'
pdu.field :EC, left_padded_uint( 2 ), :presence => :mandatory
pdu.field :SM, any_char( 128 )
end
#endif /* RuCodeGen::Embedded::end */
#include "ucp6x.operation.hpp.inl"
#include "ucp6x.positive_result.hpp.inl"
#include "ucp6x.negative_result.hpp.inl"
/*!
* \brief Тип ответа на UCP60 PDU.
*/
typedef general_response_t<
positive_result_t,
negative_result_t >
response_t;
} /* namespace ucp6x */
} /* namespace emi_pdu_1 */
#endif
// *** Файл ucp6x.cpp ***
/*
* EMI Protocol
*/
/*!
* \file
* \brief PDU для UCP60-серии.
*/
#include <emi_pdu_1/h/ucp6x.hpp>
#include <cpp_util_2/hex_dumps/h/string_dumper.hpp>
namespace emi_pdu_1 {
namespace ucp6x {
#include "ucp6x.operation.cpp.inl"
#include "ucp6x.positive_result.cpp.inl"
#include "ucp6x.negative_result.cpp.inl"
} /* namespace ucp6x */
} /* namespace emi_pdu_1 */
// *** Файл ucp6x.operation.hpp.inl ***
class operation_t
: public fields_bunch_t
{
public :
operation_t();
virtual ~operation_t();
/*!
* \name Реализация интерфейса fields_bunch.
* \{
*/
virtual void
encode( oess_1::io::ostream_t & to ) const;
virtual void
decode( const unclassified_fields_t & fields );
virtual void
debug_dump( std::ostream & to ) const;
/*!
* \}
*/
/*!
* \name Методы доступа к открытым полям.
* \{
*/
//! Установлено ли значение OAdC.
bool
is_OAdC_defined() const;
//! Сброс значения OAdC.
void
drop_OAdC();
//! Получение значения OAdC.
/*!
* \throw ex_t если значение не установлено.
*/
const std::string &
query_OAdC() const;
//! Получение значения OAdC если оно определено,
//! или значения по умолчанию в противном случае.
std::string
fetch_OAdC( const std::string & default_value ) const;
//! Установка значения OAdC.
void
set_OAdC( const std::string & v );
//! Установлено ли значение OTON.
bool
is_OTON_defined() const;
//! Сброс значения OTON.
void
drop_OTON();
//! Получение значения OTON.
/*!
* \throw ex_t если значение не установлено.
*/
const std::string &
query_OTON() const;
//! Получение значения OTON если оно определено,
//! или значения по умолчанию в противном случае.
std::string
fetch_OTON( const std::string & default_value ) const;
//! Установка значения OTON.
void
set_OTON( const std::string & v );
//! Установлено ли значение ONPI.
bool
is_ONPI_defined() const;
//! Сброс значения ONPI.
void
drop_ONPI();
//! Получение значения ONPI.
/*!
* \throw ex_t если значение не установлено.
*/
const std::string &
query_ONPI() const;
//! Получение значения ONPI если оно определено,
//! или значения по умолчанию в противном случае.
std::string
fetch_ONPI( const std::string & default_value ) const;
//! Установка значения ONPI.
void
set_ONPI( const std::string & v );
//! Установлено ли значение STYP.
bool
is_STYP_defined() const;
//! Сброс значения STYP.
void
drop_STYP();
//! Получение значения STYP.
/*!
* \throw ex_t если значение не установлено.
*/
const std::string &
query_STYP() const;
//! Получение значения STYP если оно определено,
//! или значения по умолчанию в противном случае.
std::string
fetch_STYP( const std::string & default_value ) const;
//! Установка значения STYP.
void
set_STYP( const std::string & v );
//! Установлено ли значение PWD.
bool
is_PWD_defined() const;
//! Сброс значения PWD.
void
drop_PWD();
//! Получение значения PWD.
/*!
* \throw ex_t если значение не установлено.
*/
const std::string &
query_PWD() const;
//! Получение значения PWD если оно определено,
//! или значения по умолчанию в противном случае.
std::string
fetch_PWD( const std::string & default_value ) const;
//! Установка значения PWD.
void
set_PWD( const std::string & v );
//! Установлено ли значение NPWD.
bool
is_NPWD_defined() const;
//! Сброс значения NPWD.
void
drop_NPWD();
//! Получение значения NPWD.
/*!
* \throw ex_t если значение не установлено.
*/
const std::string &
query_NPWD() const;
//! Получение значения NPWD если оно определено,
//! или значения по умолчанию в противном случае.
std::string
fetch_NPWD( const std::string & default_value ) const;
//! Установка значения NPWD.
void
set_NPWD( const std::string & v );
//! Установлено ли значение VERS.
bool
is_VERS_defined() const;
//! Сброс значения VERS.
void
drop_VERS();
//! Получение значения VERS.
/*!
* \throw ex_t если значение не установлено.
*/
const std::string &
query_VERS() const;
//! Получение значения VERS если оно определено,
//! или значения по умолчанию в противном случае.
std::string
fetch_VERS( const std::string & default_value ) const;
//! Установка значения VERS.
void
set_VERS( const std::string & v );
//! Установлено ли значение LAdC.
bool
is_LAdC_defined() const;
//! Сброс значения LAdC.
void
drop_LAdC();
//! Получение значения LAdC.
/*!
* \throw ex_t если значение не установлено.
*/
const std::string &
query_LAdC() const;
//! Получение значения LAdC если оно определено,
//! или значения по умолчанию в противном случае.
std::string
fetch_LAdC( const std::string & default_value ) const;
//! Установка значения LAdC.
void
set_LAdC( const std::string & v );
//! Установлено ли значение LTON.
bool
is_LTON_defined() const;
//! Сброс значения LTON.
void
drop_LTON();
//! Получение значения LTON.
/*!
* \throw ex_t если значение не установлено.
*/
const std::string &
query_LTON() const;
//! Получение значения LTON если оно определено,
//! или значения по умолчанию в противном случае.
std::string
fetch_LTON( const std::string & default_value ) const;
//! Установка значения LTON.
void
set_LTON( const std::string & v );
//! Установлено ли значение LNPI.
bool
is_LNPI_defined() const;
//! Сброс значения LNPI.
void
drop_LNPI();
//! Получение значения LNPI.
/*!
* \throw ex_t если значение не установлено.
*/
const std::string &
query_LNPI() const;
//! Получение значения LNPI если оно определено,
//! или значения по умолчанию в противном случае.
std::string
fetch_LNPI( const std::string & default_value ) const;
//! Установка значения LNPI.
void
set_LNPI( const std::string & v );
//! Установлено ли значение OPID.
bool
is_OPID_defined() const;
//! Сброс значения OPID.
void
drop_OPID();
//! Получение значения OPID.
/*!
* \throw ex_t если значение не установлено.
*/
const std::string &
query_OPID() const;
//! Получение значения OPID если оно определено,
//! или значения по умолчанию в противном случае.
std::string
fetch_OPID( const std::string & default_value ) const;
//! Установка значения OPID.
void
set_OPID( const std::string & v );
//! Установлено ли значение RES1.
bool
is_RES1_defined() const;
//! Сброс значения RES1.
void
drop_RES1();
//! Получение значения RES1.
/*!
* \throw ex_t если значение не установлено.
*/
const std::string &
query_RES1() const;
//! Получение значения RES1 если оно определено,
//! или значения по умолчанию в противном случае.
std::string
fetch_RES1( const std::string & default_value ) const;
//! Установка значения RES1.
void
set_RES1( const std::string & v );
/*!
* \}
*/
protected :
/*!
* \name Методы доступа к защищенным полям.
* \{
*/
/*!
* \}
*/
protected :
/*!
* \name Поля PDU.
* \{
*/
//! Поле OAdC.
field_value_templ_t<
std::string,
mandatory_field_t,
num_char_format_t< 1, 16 > >
m_OAdC;
//! Поле OTON.
field_value_templ_t<
std::string,
optional_field_t,
num_char_format_t< 1, 1 > >
m_OTON;
//! Поле ONPI.
field_value_templ_t<
std::string,
optional_field_t,
num_char_format_t< 1, 1 > >
m_ONPI;
//! Поле STYP.
field_value_templ_t<
std::string,
mandatory_field_t,
num_char_format_t< 1, 1 > >
m_STYP;
//! Поле PWD.
field_value_templ_t<
std::string,
mandatory_field_t,
hex_char_format_t< 16 > >
m_PWD;
//! Поле NPWD.
field_value_templ_t<
std::string,
optional_field_t,
hex_char_format_t< 16 > >
m_NPWD;
//! Поле VERS.
field_value_templ_t<
std::string,
mandatory_field_t,
num_char_format_t< 4, 4 > >
m_VERS;
//! Поле LAdC.
field_value_templ_t<
std::string,
optional_field_t,
num_char_format_t< 1, 16 > >
m_LAdC;
//! Поле LTON.
field_value_templ_t<
std::string,
optional_field_t,
any_char_format_t< 1 > >
m_LTON;
//! Поле LNPI.
field_value_templ_t<
std::string,
optional_field_t,
any_char_format_t< 1 > >
m_LNPI;
//! Поле OPID.
field_value_templ_t<
std::string,
optional_field_t,
num_char_format_t< 1, 2 > >
m_OPID;
//! Поле RES1.
field_value_templ_t<
std::string,
optional_field_t,
num_char_format_t< 1, 128 > >
m_RES1;
/*!
* \}
*/
};
// *** Файл ucp6x.operation.cpp.inl
operation_t::operation_t()
: m_OAdC( "OAdC" )
, m_OTON( "OTON" )
, m_ONPI( "ONPI" )
, m_STYP( "STYP" )
, m_PWD( "PWD" )
, m_NPWD( "NPWD" )
, m_VERS( "VERS", "0100" )
, m_LAdC( "LAdC" )
, m_LTON( "LTON" )
, m_LNPI( "LNPI" )
, m_OPID( "OPID" )
, m_RES1( "RES1" )
{}
operation_t::~operation_t()
{}
void
operation_t::encode( oess_1::io::ostream_t & to ) const
{
m_OAdC.encode( to ); to << fields_separator;
m_OTON.encode( to ); to << fields_separator;
m_ONPI.encode( to ); to << fields_separator;
m_STYP.encode( to ); to << fields_separator;
m_PWD.encode( to ); to << fields_separator;
m_NPWD.encode( to ); to << fields_separator;
m_VERS.encode( to ); to << fields_separator;
m_LAdC.encode( to ); to << fields_separator;
m_LTON.encode( to ); to << fields_separator;
m_LNPI.encode( to ); to << fields_separator;
m_OPID.encode( to ); to << fields_separator;
m_RES1.encode( to ); to << fields_separator;
}
void
operation_t::decode( const unclassified_fields_t & fields )
{
if( 12 != fields.fields_count() )
throw ex_t( "operation_t: pdu field count mismatch; "
"expected count: 12; actual count: " +
cpp_util_2::slexcast( fields.fields_count() ) );
m_OAdC.decode(
fields.data() + fields.field_at( 0 ).offset(),
fields.field_at( 0 ).length() );
m_OTON.decode(
fields.data() + fields.field_at( 1 ).offset(),
fields.field_at( 1 ).length() );
m_ONPI.decode(
fields.data() + fields.field_at( 2 ).offset(),
fields.field_at( 2 ).length() );
m_STYP.decode(
fields.data() + fields.field_at( 3 ).offset(),
fields.field_at( 3 ).length() );
m_PWD.decode(
fields.data() + fields.field_at( 4 ).offset(),
fields.field_at( 4 ).length() );
m_NPWD.decode(
fields.data() + fields.field_at( 5 ).offset(),
fields.field_at( 5 ).length() );
m_VERS.decode(
fields.data() + fields.field_at( 6 ).offset(),
fields.field_at( 6 ).length() );
m_LAdC.decode(
fields.data() + fields.field_at( 7 ).offset(),
fields.field_at( 7 ).length() );
m_LTON.decode(
fields.data() + fields.field_at( 8 ).offset(),
fields.field_at( 8 ).length() );
m_LNPI.decode(
fields.data() + fields.field_at( 9 ).offset(),
fields.field_at( 9 ).length() );
m_OPID.decode(
fields.data() + fields.field_at( 10 ).offset(),
fields.field_at( 10 ).length() );
m_RES1.decode(
fields.data() + fields.field_at( 11 ).offset(),
fields.field_at( 11 ).length() );
}
void
operation_t::debug_dump( std::ostream & to ) const
{
to << m_OAdC.field_name() << '=';
if( m_OAdC.is_defined() )
to << '"' << cpp_util_2::hex_dumps::hex_escaped_string_dumper( m_OAdC.value() ) << "\"/";
else
to << '/';
to << m_OTON.field_name() << '=';
if( m_OTON.is_defined() )
to << '"' << cpp_util_2::hex_dumps::hex_escaped_string_dumper( m_OTON.value() ) << "\"/";
else
to << '/';
to << m_ONPI.field_name() << '=';
if( m_ONPI.is_defined() )
to << '"' << cpp_util_2::hex_dumps::hex_escaped_string_dumper( m_ONPI.value() ) << "\"/";
else
to << '/';
to << m_STYP.field_name() << '=';
if( m_STYP.is_defined() )
to << '"' << cpp_util_2::hex_dumps::hex_escaped_string_dumper( m_STYP.value() ) << "\"/";
else
to << '/';
to << m_PWD.field_name() << '=';
if( m_PWD.is_defined() )
to << '"' << cpp_util_2::hex_dumps::hex_escaped_string_dumper( m_PWD.value() ) << "\"/";
else
to << '/';
to << m_NPWD.field_name() << '=';
if( m_NPWD.is_defined() )
to << '"' << cpp_util_2::hex_dumps::hex_escaped_string_dumper( m_NPWD.value() ) << "\"/";
else
to << '/';
to << m_VERS.field_name() << '=';
if( m_VERS.is_defined() )
to << '"' << cpp_util_2::hex_dumps::hex_escaped_string_dumper( m_VERS.value() ) << "\"/";
else
to << '/';
to << m_LAdC.field_name() << '=';
if( m_LAdC.is_defined() )
to << '"' << cpp_util_2::hex_dumps::hex_escaped_string_dumper( m_LAdC.value() ) << "\"/";
else
to << '/';
to << m_LTON.field_name() << '=';
if( m_LTON.is_defined() )
to << '"' << cpp_util_2::hex_dumps::hex_escaped_string_dumper( m_LTON.value() ) << "\"/";
else
to << '/';
to << m_LNPI.field_name() << '=';
if( m_LNPI.is_defined() )
to << '"' << cpp_util_2::hex_dumps::hex_escaped_string_dumper( m_LNPI.value() ) << "\"/";
else
to << '/';
to << m_OPID.field_name() << '=';
if( m_OPID.is_defined() )
to << '"' << cpp_util_2::hex_dumps::hex_escaped_string_dumper( m_OPID.value() ) << "\"/";
else
to << '/';
to << m_RES1.field_name() << '=';
if( m_RES1.is_defined() )
to << '"' << cpp_util_2::hex_dumps::hex_escaped_string_dumper( m_RES1.value() ) << "\"/";
else
to << '/';
}
bool
operation_t::is_OAdC_defined() const
{
return m_OAdC.is_defined();
}
void
operation_t::drop_OAdC()
{
m_OAdC.drop();
}
const std::string &
operation_t::query_OAdC() const
{
return m_OAdC.value();
}
std::string
operation_t::fetch_OAdC( const std::string & default_value ) const
{
if( m_OAdC.is_defined() )
return m_OAdC.value();
else
return default_value;
}
void
operation_t::set_OAdC( const std::string & v )
{
m_OAdC.set( v );
}
bool
operation_t::is_OTON_defined() const
{
return m_OTON.is_defined();
}
void
operation_t::drop_OTON()
{
m_OTON.drop();
}
const std::string &
operation_t::query_OTON() const
{
return m_OTON.value();
}
std::string
operation_t::fetch_OTON( const std::string & default_value ) const
{
if( m_OTON.is_defined() )
return m_OTON.value();
else
return default_value;
}
void
operation_t::set_OTON( const std::string & v )
{
m_OTON.set( v );
}
bool
operation_t::is_ONPI_defined() const
{
return m_ONPI.is_defined();
}
void
operation_t::drop_ONPI()
{
m_ONPI.drop();
}
const std::string &
operation_t::query_ONPI() const
{
return m_ONPI.value();
}
std::string
operation_t::fetch_ONPI( const std::string & default_value ) const
{
if( m_ONPI.is_defined() )
return m_ONPI.value();
else
return default_value;
}
void
operation_t::set_ONPI( const std::string & v )
{
m_ONPI.set( v );
}
bool
operation_t::is_STYP_defined() const
{
return m_STYP.is_defined();
}
void
operation_t::drop_STYP()
{
m_STYP.drop();
}
const std::string &
operation_t::query_STYP() const
{
return m_STYP.value();
}
std::string
operation_t::fetch_STYP( const std::string & default_value ) const
{
if( m_STYP.is_defined() )
return m_STYP.value();
else
return default_value;
}
void
operation_t::set_STYP( const std::string & v )
{
m_STYP.set( v );
}
bool
operation_t::is_PWD_defined() const
{
return m_PWD.is_defined();
}
void
operation_t::drop_PWD()
{
m_PWD.drop();
}
const std::string &
operation_t::query_PWD() const
{
return m_PWD.value();
}
std::string
operation_t::fetch_PWD( const std::string & default_value ) const
{
if( m_PWD.is_defined() )
return m_PWD.value();
else
return default_value;
}
void
operation_t::set_PWD( const std::string & v )
{
m_PWD.set( v );
}
bool
operation_t::is_NPWD_defined() const
{
return m_NPWD.is_defined();
}
void
operation_t::drop_NPWD()
{
m_NPWD.drop();
}
const std::string &
operation_t::query_NPWD() const
{
return m_NPWD.value();
}
std::string
operation_t::fetch_NPWD( const std::string & default_value ) const
{
if( m_NPWD.is_defined() )
return m_NPWD.value();
else
return default_value;
}
void
operation_t::set_NPWD( const std::string & v )
{
m_NPWD.set( v );
}
bool
operation_t::is_VERS_defined() const
{
return m_VERS.is_defined();
}
void
operation_t::drop_VERS()
{
m_VERS.drop();
}
const std::string &
operation_t::query_VERS() const
{
return m_VERS.value();
}
std::string
operation_t::fetch_VERS( const std::string & default_value ) const
{
if( m_VERS.is_defined() )
return m_VERS.value();
else
return default_value;
}
void
operation_t::set_VERS( const std::string & v )
{
m_VERS.set( v );
}
bool
operation_t::is_LAdC_defined() const
{
return m_LAdC.is_defined();
}
void
operation_t::drop_LAdC()
{
m_LAdC.drop();
}
const std::string &
operation_t::query_LAdC() const
{
return m_LAdC.value();
}
std::string
operation_t::fetch_LAdC( const std::string & default_value ) const
{
if( m_LAdC.is_defined() )
return m_LAdC.value();
else
return default_value;
}
void
operation_t::set_LAdC( const std::string & v )
{
m_LAdC.set( v );
}
bool
operation_t::is_LTON_defined() const
{
return m_LTON.is_defined();
}
void
operation_t::drop_LTON()
{
m_LTON.drop();
}
const std::string &
operation_t::query_LTON() const
{
return m_LTON.value();
}
std::string
operation_t::fetch_LTON( const std::string & default_value ) const
{
if( m_LTON.is_defined() )
return m_LTON.value();
else
return default_value;
}
void
operation_t::set_LTON( const std::string & v )
{
m_LTON.set( v );
}
bool
operation_t::is_LNPI_defined() const
{
return m_LNPI.is_defined();
}
void
operation_t::drop_LNPI()
{
m_LNPI.drop();
}
const std::string &
operation_t::query_LNPI() const
{
return m_LNPI.value();
}
std::string
operation_t::fetch_LNPI( const std::string & default_value ) const
{
if( m_LNPI.is_defined() )
return m_LNPI.value();
else
return default_value;
}
void
operation_t::set_LNPI( const std::string & v )
{
m_LNPI.set( v );
}
bool
operation_t::is_OPID_defined() const
{
return m_OPID.is_defined();
}
void
operation_t::drop_OPID()
{
m_OPID.drop();
}
const std::string &
operation_t::query_OPID() const
{
return m_OPID.value();
}
std::string
operation_t::fetch_OPID( const std::string & default_value ) const
{
if( m_OPID.is_defined() )
return m_OPID.value();
else
return default_value;
}
void
operation_t::set_OPID( const std::string & v )
{
m_OPID.set( v );
}
bool
operation_t::is_RES1_defined() const
{
return m_RES1.is_defined();
}
void
operation_t::drop_RES1()
{
m_RES1.drop();
}
const std::string &
operation_t::query_RES1() const
{
return m_RES1.value();
}
std::string
operation_t::fetch_RES1( const std::string & default_value ) const
{
if( m_RES1.is_defined() )
return m_RES1.value();
else
return default_value;
}
void
operation_t::set_RES1( const std::string & v )
{
m_RES1.set( v );
}