Пример #1
0
    def test_func_desc_manual(self):
        # Example taken from hardCodedServer (cf. Schmidt and Li, 2009c)
        animals = TypeDescription("animals", nuc_length=20, uc_length=28)
        self.assertEqual(animals.nuc_length, 20)
        self.assertEqual(animals.uc_length, 28)
        animals.add_field(name=u'LION',
                          field_type='RFCTYPE_CHAR',
                          nuc_length=5,
                          uc_length=10,
                          nuc_offset=0,
                          uc_offset=0)
        animals.add_field(name=u'ELEPHANT',
                          field_type='RFCTYPE_FLOAT',
                          nuc_length=8,
                          uc_length=8,
                          decimals=16,
                          nuc_offset=8,
                          uc_offset=16)
        animals.add_field(name=u'ZEBRA',
                          field_type='RFCTYPE_INT',
                          nuc_length=4,
                          uc_length=4,
                          nuc_offset=16,
                          uc_offset=24)

        i_dont_exist = FunctionDescription(u"I_DONT_EXIST")
        i_dont_exist.add_parameter(name=u"DOG",
                                   parameter_type="RFCTYPE_INT",
                                   direction="RFC_IMPORT",
                                   nuc_length=4,
                                   uc_length=4)
        i_dont_exist.add_parameter(name=u"CAT",
                                   parameter_type="RFCTYPE_CHAR",
                                   direction="RFC_IMPORT",
                                   nuc_length=5,
                                   uc_length=10)
        i_dont_exist.add_parameter(name=u"ZOO",
                                   parameter_type="RFCTYPE_STRUCTURE",
                                   direction="RFC_IMPORT",
                                   nuc_length=20,
                                   uc_length=28,
                                   type_description=animals)
        i_dont_exist.add_parameter(name=u"BIRD",
                                   parameter_type="RFCTYPE_FLOAT",
                                   direction="RFC_IMPORT",
                                   nuc_length=8,
                                   uc_length=8,
                                   decimals=16)

        self.assertEqual(len(i_dont_exist.parameters), 4)
        self.assertEqual(i_dont_exist.name, u"I_DONT_EXIST")
Пример #2
0
    def test_func_desc_manual(self):
        # Example taken from hardCodedServer (cf. Schmidt and Li, 2009c)
        animals = TypeDescription("animals", nuc_length=20, uc_length=28)
        self.assertEqual(animals.nuc_length,20)
        self.assertEqual(animals.uc_length,28)
        animals.add_field(name=u'LION', field_type='RFCTYPE_CHAR', nuc_length=5, uc_length=10, nuc_offset=0, uc_offset=0)
        animals.add_field(name=u'ELEPHANT', field_type='RFCTYPE_FLOAT', nuc_length=8, uc_length=8, decimals=16, nuc_offset=8, uc_offset=16)
        animals.add_field(name=u'ZEBRA', field_type='RFCTYPE_INT', nuc_length=4, uc_length=4, nuc_offset=16, uc_offset=24)

        i_dont_exist = FunctionDescription(u"I_DONT_EXIST")
        i_dont_exist.add_parameter(name=u"DOG", parameter_type="RFCTYPE_INT",
            direction="RFC_IMPORT", nuc_length=4, uc_length=4)
        i_dont_exist.add_parameter(name=u"CAT", parameter_type="RFCTYPE_CHAR",
            direction="RFC_IMPORT", nuc_length=5, uc_length=10)
        i_dont_exist.add_parameter(name=u"ZOO", parameter_type="RFCTYPE_STRUCTURE",
            direction="RFC_IMPORT", nuc_length=20, uc_length=28, type_description=animals)
        i_dont_exist.add_parameter(name=u"BIRD", parameter_type="RFCTYPE_FLOAT",
            direction="RFC_IMPORT", nuc_length=8, uc_length=8, decimals=16)

        self.assertEqual(len(i_dont_exist.parameters), 4)
        self.assertEqual(i_dont_exist.name, u"I_DONT_EXIST")
Пример #3
0
def get_standard_func():
    t_header = TypeDescription("ZHBREWSHEADER", nuc_length=90, uc_length=180)
    t_header.add_field(name=u'TYPE',
                       field_type='RFCTYPE_CHAR',
                       nuc_offset=0,
                       uc_offset=0,
                       nuc_length=30,
                       uc_length=60)
    t_header.add_field(name=u'VALUE',
                       field_type='RFCTYPE_CHAR',
                       nuc_offset=0,
                       uc_offset=0,
                       nuc_length=60,
                       uc_length=120)

    zhbr_ews_async = FunctionDescription("ZHBR_EWS_ASYNC")
    zhbr_ews_async.add_parameter(name=u'E_FAIL_MSG',
                                 parameter_type='RFCTYPE_CHAR',
                                 direction='RFC_EXPORT',
                                 nuc_length=1,
                                 uc_length=2)
    zhbr_ews_async.add_parameter(name=u'I_EWS_ID',
                                 parameter_type='RFCTYPE_CHAR',
                                 optional=True,
                                 direction='RFC_IMPORT',
                                 nuc_length=18,
                                 uc_length=24)
    zhbr_ews_async.add_parameter(name=u'I_STATUS',
                                 parameter_type='RFCTYPE_CHAR',
                                 optional=True,
                                 direction='RFC_IMPORT',
                                 nuc_length=1,
                                 uc_length=2)
    zhbr_ews_async.add_parameter(name=u'I_TIMESTAMP',
                                 parameter_type='RFCTYPE_BCD',
                                 optional=True,
                                 direction='RFC_IMPORT',
                                 nuc_length=8,
                                 uc_length=8)
    zhbr_ews_async.add_parameter(name=u'I_RISK_INFO',
                                 parameter_type='RFCTYPE_STRING',
                                 optional=True,
                                 direction='RFC_IMPORT',
                                 nuc_length=0,
                                 uc_length=0)
    zhbr_ews_async.add_parameter(name=u'T_HEADER',
                                 parameter_type='RFCTYPE_TABLE',
                                 optional=True,
                                 direction='RFC_TABLES',
                                 nuc_length=90,
                                 uc_length=180,
                                 type_description=t_header)
    zhbr_ews_async.add_parameter(name=u'T_TABLE',
                                 parameter_type='RFCTYPE_TABLE',
                                 optional=True,
                                 direction='RFC_TABLES',
                                 nuc_length=256,
                                 uc_length=512)
    return zhbr_ews_async
Пример #4
0
from pyrfc import FunctionDescription, TypeDescription

animals = TypeDescription("ANIMALS", nuc_length=20, uc_length=28)
animals.add_field(name=u"LION", field_type="RFCTYPE_CHAR", nuc_length=5, uc_length=10, nuc_offset=0, uc_offset=0)
animals.add_field(
    name=u"ELEPHANT", field_type="RFCTYPE_FLOAT", decimals=16, nuc_length=8, uc_length=8, nuc_offset=8, uc_offset=16
)
animals.add_field(name=u"ZEBRA", field_type="RFCTYPE_INT", nuc_length=4, uc_length=4, nuc_offset=16, uc_offset=24)

func_desc = FunctionDescription("I_DONT_EXIST")
func_desc.add_parameter(name=u"DOC", field_type="RFCTYPE_INT", direction="RFC_IMPORT", nuc_length=4, uc_length=4)
func_desc.add_parameter(name=u"CAT", field_type="RFCTYPE_CHAR", direction="RFC_IMPORT", nuc_length=5, uc_length=10)
func_desc.add_parameter(
    name=u"ZOO",
    field_type="RFCTYPE_STRUCTURE",
    direction="RFC_IMPORT",
    nuc_length=20,
    uc_length=28,
    type_description=animals,
)
func_desc.add_parameter(
    name=u"BIRD", field_type="RFCTYPE_FLOAT", direction="RFC_IMPORT", nuc_length=8, uc_length=8, decimals=16
)
func_desc.add_parameter(name=u"COW", field_type="RFCTYPE_CHAR", direction="RFC_EXPORT", nuc_length=3, uc_length=6)
func_desc.add_parameter(
    name=u"STABLE",
    field_type="RFCTYPE_STRUCTURE",
    direction="RFC_EXPORT",
    nuc_length=20,
    uc_length=28,
    type_description=animals,
    uc_offset=16,
)
animals.add_field(
    name=u"ZEBRA",
    field_type="RFCTYPE_INT",
    nuc_length=4,
    uc_length=4,
    nuc_offset=16,
    uc_offset=24,
)

func_desc = FunctionDescription("I_DONT_EXIST")
func_desc.add_parameter(
    name=u"DOC",
    field_type="RFCTYPE_INT",
    direction="RFC_IMPORT",
    nuc_length=4,
    uc_length=4,
)
func_desc.add_parameter(
    name=u"CAT",
    field_type="RFCTYPE_CHAR",
    direction="RFC_IMPORT",
    nuc_length=5,
    uc_length=10,
)
func_desc.add_parameter(
    name=u"ZOO",
    field_type="RFCTYPE_STRUCTURE",
    direction="RFC_IMPORT",
    nuc_length=20,
Пример #6
0
    nuc_length=8,
    uc_length=8,
    nuc_offset=8,
    uc_offset=16,
)
animals.add_field(name=u'ZEBRA',
                  field_type='RFCTYPE_INT',
                  nuc_length=4,
                  uc_length=4,
                  nuc_offset=16,
                  uc_offset=24)

func_desc = FunctionDescription("I_DONT_EXIST")
func_desc.add_parameter(name=u'DOC',
                        field_type='RFCTYPE_INT',
                        direction='RFC_IMPORT',
                        nuc_length=4,
                        uc_length=4)
func_desc.add_parameter(name=u'CAT',
                        field_type='RFCTYPE_CHAR',
                        direction='RFC_IMPORT',
                        nuc_length=5,
                        uc_length=10)
func_desc.add_parameter(name=u'ZOO',
                        field_type='RFCTYPE_STRUCTURE',
                        direction='RFC_IMPORT',
                        nuc_length=20,
                        uc_length=28,
                        type_description=animals)
func_desc.add_parameter(name=u'BIRD',
                        field_type='RFCTYPE_FLOAT',