payload.py 1.66 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
# User code: This file will not be overwritten by TASTE.

import micropython
from taste import * # import all ASN types

def payload_startup():
    # Write your initialization code here,
    # but do not make any call to a required interface.
    # It's recommended to lock the heap once initialisation is done, but
    # note that without the heap some Python operations are not possible.
    micropython.heap_lock()

def payload_PI_TC_Seq_NATIVE(IN_a: asn1SccMySeq, OUT_b: asn1SccMySeq):
    print('TC_Seq_NATIVE')
    print('    IN_a:', IN_a)
    OUT_b.val.input_data = IN_a.input_data + 10
    OUT_b.val.output_data = IN_a.output_data + 10
    OUT_b.val.validity = 1 - IN_a.validity

def payload_PI_TC_Seq_UPER(IN_a: asn1SccMySeq, OUT_b: asn1SccMySeq):
    print('TC_Seq_UPER')
    print('    IN_a:', IN_a)
    OUT_b.val.input_data = IN_a.input_data + 10
    OUT_b.val.output_data = IN_a.output_data + 10
    OUT_b.val.validity = 1 - IN_a.validity

def payload_PI_TC_OctStr_NATIVE(IN_a: asn1SccMyOctStr, OUT_b: asn1SccMyOctStr):
    print('TC_OctStr_NATIVE')
    print('    IN_a:', IN_a)
    for i in range(len(IN_a)):
        OUT_b.val[i] = IN_a[i] + 1

def payload_PI_TC_SeqOf_NATIVE(IN_a: asn1SccMySeqOf, OUT_b: asn1SccMySeqOf):
    print('TC_SeqOf_NATIVE')
    print('    IN_a:', IN_a)
    for i in range(len(IN_a)):
        OUT_b.val[i] = IN_a[i] + 1

def payload_PI_TC_Choice_NATIVE(IN_a: asn1SccMyChoice, OUT_b: asn1SccMyChoice):
    print('TC_Choice_NATIVE')
    print('    IN_a:', IN_a)
    if hasattr(IN_a, 'a'):
        IN_a.a = 1 - IN_a.a
    else:
        IN_a.b.input_data += 10
        IN_a.b.output_data += 10
        IN_a.b.validity = 1 - IN_a.b.validity
    OUT_b.val = IN_a