F006 Structured data

Signals of type structure can transport a set of values (members) with each change. This member set may vary from sample to sample.

Struct Types

  • STRUCT_TYPE_UNKNOWN : Unknoen type
  • STRUCT_TYPE_TEXT : Textual data
  • STRUCT_TYPE_GLOBAL_ENUM : Enumeration data - corresponds to global enumeration type
  • STRUCT_TYPE_INTEGER : Any size integer
  • STRUCT_TYPE_FLOAT : Float or double values
  • STRUCT_TYPE_BINARY : Binary data
  • STRUCT_TYPE_LOCAL_ENUM : Enumeration data - corresponds to member enumeration type
  • STRUCT_TYPE_MERGE_ENUM : Merges members into a text representation
  • STRUCT_TYPE_STRUCT : Sub-structuree
  • STRUCT_TYPE_ENUM_ARRAY : Enumeration array
  • STRUCT_TYPE_INTEGER_ARRAY : Integer array
  • STRUCT_TYPE_FLOAT_ARRAY : Float array
  • STRUCT_TYPE_TEXT_ARRAY : Text array
  • FLX_STRUCTTYPE_MOD_HIDDEN : This flag may be used to describe a member as 'hidden'.

Writing struct signals

To create a struct signal, the following steps need to be done:

  1. Create a signal of type struct.
  2. Create the struct members
  3. Use flxWriteMemberDefs/writeMemberDefs to put the member information into the trace.
  4. Set the value of the member.
  5. Use flxWriteMembersAt/writeMembersAt writes all members of a struct into the trace.

The method of creating and initializing the members differs between c-language and the object-oriented variants.

c-language member creation

The c struct flxMemberValue is used to send either the declarative information (using the function flxWriteMemberDefs) as well the sample data (with the function flxWriteMembersAt). The steps to create a struct signal are:

  • Create an array of type flxMemberValue
  • Use the flxInitMember function to init the members (give it a name and type).
  • flxWriteMemberDefs puts the member information into the trace.
  • The function flxSetMember sets the value of the member.
  • flxWriteMembersAt writes all members of a struct into the trace.

The arguments of flxInitMember are:

  • the member struct,
  • the memberId (0..N) to identify the member,
  • name of the member,
  • the memberType,
  • and a memberDescriptor.

Object-Oriented member creation

The class Flx.MemberValue is used to send either the declarative information (using the method writeMemberDefs) as well the sample data (with the method writeMembersAt). The steps to create a struct signal are:

  • Create a member array using the createMembers methond (you might create the array manually).
  • Use the createMember function to create and init each member (give it a name and type).
  • flxWriteMemberDefs puts the member information into the trace.
  • The method MemberValue.setValue sets the value of the member.
  • writeMembersAt writes all members of a struct into the trace.

The arguments of createMember are:

  • the memberId (0..N) to identify the member,
  • name of the member,
  • the memberType,
  • and a memberDescriptor.

Finally write the members

To finally write the members to the trace, use  flxWriteMembersAt/writeMembersAt:

  • the trace object (c-language only),
  • itemId of the signal,
  • the tag flag (samples can have a tag, e.g. error),
  • domain position,
  • isRelative flag (1: relative, 0:absolute),
  • the member array.
  • Java

            // add struct signals
            trace.addScope( 1, 0, "Struct", "Scope Description");
            trace.addSignal( 2, 1, "Simple Struct", "desc", Flx.TYPE_STRUCT, null);
    
            // init struct members
            Flx.MemberValue[] members = trace.createMembers(4);
            members[0] = trace.createMember(0, "m0", Flx.STRUCT_TYPE_GLOBAL_ENUM, null);
            members[1] = trace.createMember(1, "m1", Flx.STRUCT_TYPE_INTEGER, "default");
            members[2] = trace.createMember(2, "m2", Flx.STRUCT_TYPE_FLOAT, null);
            members[3] = trace.createMember(3, "m3", Flx.STRUCT_TYPE_TEXT, null);
            
            // open
    
            // write member defs for signal 2 (struct)
            trace.writeMemberDefs(2, members);
            
            // write enum defs for signal 2 (struct)
            trace.writeEnumDef(2, Flx.ENUM_GLOBAL, "Yes", 1);
            trace.writeEnumDef(2, Flx.ENUM_GLOBAL, "No", 0);
            
            ...
    
            // values
            eVal = n & 1;
            fVal = (n / 100.);
            tVal = "val: " +  String.valueOf(n % 100);
          
            // fill struct members and write
            members[0].setValue(eVal);
            members[1].setValue(n);
            members[2].setValue(fVal);
            members[3].setValue(tVal);
            trace.writeMembersAt(2, 0, current , false, members);
  • C/C++

    		// add struct signals
    		flxAddScope(trace, 1, 0, "Struct", "Scope Description");
    		flxAddSignal(trace, 2, 1, "Simple Struct", "desc", FLX_TYPE_STRUCT, 0);
    
    		// init struct members
    		struct flxMemberValueStruct members[4];
    		flxInitMember(members + 0, 0, "m0", FLX_STRUCT_TYPE_GLOBAL_ENUM, 0);
    		flxInitMember(members + 1, 1, "m1", FLX_STRUCT_TYPE_INTEGER, "default");
    		flxInitMember(members + 2, 2, "m2", FLX_STRUCT_TYPE_FLOAT, 0);
    		flxInitMember(members + 3, 3, "m3", FLX_STRUCT_TYPE_TEXT, 0);
    
    		// open
    
    		// write member defs for signal 2 (struct)
    		flxWriteMemberDefs(trace, 2, members, 4);
    
    		// write enum defs for signal 2 (struct)
    		flxWriteEnumDef(trace, 2, FLX_ENUM_GLOBAL, "Yes", 1);
    		flxWriteEnumDef(trace, 2, FLX_ENUM_GLOBAL, "No", 0);
    
    		...
    
    		// values
    		eVal = n & 1;
    		fVal = (n / 100.);
    		int iVal = (n % 100);
    		sprintf(tVal, "val: %i", iVal);
    
    		// fill struct members and write
    		flxSetMember(members + 0, &eVal, sizeof(int), 0, 1);
    		flxSetMember(members + 1, &n, sizeof(int), 0, 1);
    		flxSetMember(members + 2, &fVal, sizeof(double), 0, 1);
    		flxSetMember(members + 3, (void*) tVal, strlen(tVal), 0, 1);
    		flxWriteMembersAt(trace, 2, 0, current, 0, members, 4);
  • Python

            # add struct signals
            trace.addScope( 1, 0, "Struct", "Scope Description");
            trace.addSignal( 2, 1, "Simple Struct", "desc", Flx.TYPE_STRUCT, None);
    
            # init struct members
            members = trace.createMembers(4);
            members[0] = trace.createMember(0, "m0", Flx.STRUCT_TYPE_GLOBAL_ENUM, None);
            members[1] = trace.createMember(1, "m1", Flx.STRUCT_TYPE_INTEGER, "default");
            members[2] = trace.createMember(2, "m2", Flx.STRUCT_TYPE_FLOAT, None);
            members[3] = trace.createMember(3, "m3", Flx.STRUCT_TYPE_TEXT, None);
            
            # open
    
            # write member defs for signal 2 (struct)
            trace.writeMemberDefs(2, members);
            
            # write enum defs for signal 2 (struct)
            trace.writeEnumDef(2, Flx.ENUM_GLOBAL, "Yes", 1);
            trace.writeEnumDef(2, Flx.ENUM_GLOBAL, "No", 0);
            
            ...
    
            # values
            eVal = n & 1;
            fVal = (n / 100.);
            tVal = "val: " +  str(n % 100);
          
            # fill struct members and write
            members[0].setValue(eVal);
            members[1].setValue(n);
            members[2].setValue(fVal);
            members[3].setValue(tVal);
            trace.writeMembersAt(2, 0, current , False, members);
            
  • TypeScript

     		// add struct signals           
            trace.addScope(1, 0, "Struct", "Scope Description");
            trace.addSignal(2, 1, "Simple Struct", "desc", Flx.TYPE_STRUCT, null);
            
            // init struct members
            let members : Flx.MemberValue[] = trace.createMembers(4);
            members[0] = trace.createMember(0, "m0", Flx.STRUCT_TYPE_GLOBAL_ENUM, null);
            members[1] = trace.createMember(1, "m1", Flx.STRUCT_TYPE_INTEGER, "default");
            members[2] = trace.createMember(2, "m2", Flx.STRUCT_TYPE_FLOAT, null);
            members[3] = trace.createMember(3, "m3", Flx.STRUCT_TYPE_TEXT, null);
            
            // open
            
            // write member defs for signal 2 (struct)
            trace.writeMemberDefs(2, members);
            
            // write enum defs for signal 2 (struct)
            trace.writeEnumDef(2, Flx.ENUM_GLOBAL, "Yes", 1);
            trace.writeEnumDef(2, Flx.ENUM_GLOBAL, "No", 0);
    
    		...
    		
    		// values
            eVal = n & 1;
            fVal = (n / 100.0);
            tVal = "val: " + /* valueOf */new String(n % 100).toString();
            
            // fill struct members and write
            members[0].setValue(eVal);
            members[1].setValue(n);
            members[2].setValue(fVal);
            members[3].setValue(tVal);
            trace.writeMembersAt(2, 0, current, false, members);    
  • JavaScript

            // add struct signals  
            trace.addScope(1, 0, "Struct", "Scope Description");
            trace.addSignal(2, 1, "Simple Struct", "desc", Flx.TYPE_STRUCT, null);
            
            // init struct members
            let members = trace.createMembers(4);
            members[0] = trace.createMember(0, "m0", Flx.STRUCT_TYPE_GLOBAL_ENUM, null);
            members[1] = trace.createMember(1, "m1", Flx.STRUCT_TYPE_INTEGER, "default");
            members[2] = trace.createMember(2, "m2", Flx.STRUCT_TYPE_FLOAT, null);
            members[3] = trace.createMember(3, "m3", Flx.STRUCT_TYPE_TEXT, null);
            
            // open
    
            // write member defs for signal 2 (struct)
            trace.writeMemberDefs(2, members);
            
            // write enum defs for signal 2 (struct)
            trace.writeEnumDef(2, Flx.ENUM_GLOBAL, "Yes", 1);
            trace.writeEnumDef(2, Flx.ENUM_GLOBAL, "No", 0);
    
    		...
    		
    		// values
            current = n * 10;
            eVal = n & 1;
            fVal = (n / 100.0);
            tVal = "val: " + /* valueOf */ new String(n % 100).toString();
            
            // fill struct members and write        
            members[0].setValue(eVal);
            members[1].setValue(n);
            members[2].setValue(fVal);
            members[3].setValue(tVal);
            trace.writeMembersAt(2, 0, current, false, members);    
toem

technical software and tooling

Company

Contact Us

This email address is being protected from spambots. You need JavaScript enabled to view it.