F007 Arrays

Array are similar to structures with the difference that all members have the same type. Supported types are integer, float, text (no c-language support) and event.

Data types

  IntegerArray FloatArray EventArray TextArray  
Java
  • int[]
  • long[]
  • BigInteger[]
  • float[]
  • double[]
  • BigDecimal[]
  • int[]
  • String[]
 
c
  • void*
  • any size

+ size, count and signed parameter

  • float*
  • double*

+ size and count parameter

  • int*

+ count parameter

   
Python
  • list of int,long
  • list of float
  • list of int
  • list of string
 
TypeScript
  • array of number
  • array of number
  • array of number
  • array of string
 
JavaScript
  • array of number
  • array of number
  • array of number
  • array of string
 

 

Writing array data

To create an array, the following steps need to be done:

  1. Create a signal of type TYPE_INTEGER_ARRAY, TYPE_FLOAT_ARRAY, TYPE_TEXT_ARRAY or TYPE_EVENT_ARRAY with a signal descriptor declaring a dimension (dim).
  2. Optionally use flxWriteArrayDef/writeArrayDef to put member information into the trace.
  3. Use flxWriteXXXArrayAt/writeXXXArrayAt writes the array into the trace.

 

The parameters for flxWriteXXXArraytAt/writeXXXArrayAt are:

  • 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 array value,
  • and the dynamicSize parameter, that need to be set to true if the array size changes.

The c-language variant uses a pointer to an array and required the additional parameters:

  • size: Size of each member. (not in flxWriteEventArrayAt as fixed to int size)
  • count: No of array members
  • signd : 1 if value is a signed integer (flxWriteIntArrayAt only)
  • Java

            // add array signals
            trace.addScope( 1, 0, "Arrays", "Scope Description");
            trace.addSignal( 2, 1, "array of integers", "2/4 elements", Flx.TYPE_INTEGER_ARRAY, "default<dim=4>");
            trace.addSignal( 3, 1, "array of floats", "2 elements", Flx.TYPE_FLOAT_ARRAY, "default<dim=2>");
            trace.addSignal( 4, 1, "array of enums", "8 elements", Flx.TYPE_EVENT_ARRAY, "default<dim=8>");
            
            // open
    
            // write array defs for arrays (may be omitted)
            trace.writeArrayDef( 2, 0, "x", "");
            trace.writeArrayDef( 2, 1, "y", "");
            trace.writeArrayDef( 2, 2, "z", "");
            trace.writeArrayDef( 2, 3, "-", "");
            trace.writeArrayDef( 3, 0, "x", null);
            trace.writeArrayDef( 3, 1, "y", null);
            trace.writeArrayDef( 4, 0, "state", null);
            trace.writeArrayDef( 4, 1, "done", null);
            
            // write enums for for signal 4  (enum array)
            trace.writeEnumDef( 4, Flx.ENUM_MEMBER_0 + 0, "Yes", 1);
            trace.writeEnumDef( 4, Flx.ENUM_MEMBER_0 + 0, "No", 0);
            trace.writeEnumDef( 4, Flx.ENUM_MEMBER_0 + 1, "Low", 1);
            trace.writeEnumDef( 4, Flx.ENUM_MEMBER_0 + 1, "High", 0);
          
            ...
            
            // integer array of multiple size
            if ((n % 2) == 0) {
                iaVal2[0] = (n % 16) | 0x10000;
                iaVal2[1] = (n % 1024) | 0x10000;
                trace.writeIntArrayAt( 2, 0, current , false, iaVal2, true);
            }
            else {
                iaVal4[0] = (n % 16) | 0x1000;
                iaVal4[1] = (n % 1024) | 0x1000;
                iaVal4[2] = (n % 256) | 0x1000;
                iaVal4[3] = (n % 4) | 0x1000;
                trace.writeIntArrayAt( 2, 0, current , false, iaVal4, true);                   
            }
            
            // float array
            faVal[0] = (n / 1000.);
            faVal[1] = (n / 100.);
            trace.writeFloatArrayAt( 3, 0, 0, true, faVal, false);
    
            // event array
            eaVal[0] = n % 2;
            eaVal[1] = (n + 1) % 2;
            eaVal[2] = n % 4;
            eaVal[3] = (n + 1) % 4;
            eaVal[4] = n % 6;
            eaVal[5] = (n + 1) % 6;
            eaVal[6] = n % 8;
            eaVal[7] = (n + 1) % 8;
            trace.writeEventArrayAt( 4, 0, 0, true, eaVal, false);
    
            
  • C/C++

    		// add array signals
    		flxAddScope(trace, 1, 0, "Arrays", "Scope Description");
    		flxAddSignal(trace, 2, 1, "array of integers", "2/4 elements", FLX_TYPE_INTEGER_ARRAY, "default<dim=4>");
    		flxAddSignal(trace, 3, 1, "array of floats", "2 elements", FLX_TYPE_FLOAT_ARRAY, "default<dim=2>");
    		flxAddSignal(trace, 4, 1, "array of enums", "8 elements", FLX_TYPE_EVENT_ARRAY, "default<dim=8>");
    
    		// open
    
    		// write array defs for arrays (may be omitted)
    		flxWriteArrayDef(trace, 2, 0, "x", "");
    		flxWriteArrayDef(trace, 2, 1, "y", "");
    		flxWriteArrayDef(trace, 2, 2, "z", "");
    		flxWriteArrayDef(trace, 2, 3, "-", "");
    		flxWriteArrayDef(trace, 3, 0, "x", 0);
    		flxWriteArrayDef(trace, 3, 1, "y", 0);
    		flxWriteArrayDef(trace, 4, 0, "state", 0);
    		flxWriteArrayDef(trace, 4, 1, "done", 0);
    
    		// write enums for for signal 4  (enum array)
    		flxWriteEnumDef(trace, 4, FLX_ENUM_MEMBER_0 + 0, "Yes", 1);
    		flxWriteEnumDef(trace, 4, FLX_ENUM_MEMBER_0 + 0, "No", 0);
    		flxWriteEnumDef(trace, 4, FLX_ENUM_MEMBER_0 + 1, "Low", 1);
    		flxWriteEnumDef(trace, 4, FLX_ENUM_MEMBER_0 + 1, "High", 0);
    
    		...
    	
    		// integer array of multiple size
    		if ((n % 2) == 0) {
    			iaVal2[0] = (n % 16) | 0x10000;
    			iaVal2[1] = (n % 1024) | 0x10000;
    			flxWriteIntArrayAt(trace, 2, 0, current, 0, iaVal2, sizeof(int), 0, 2, 1);
    		} else {
    			iaVal4[0] = (n % 16) | 0x1000;
    			iaVal4[1] = (n % 1024) | 0x1000;
    			iaVal4[2] = (n % 256) | 0x1000;
    			iaVal4[3] = (n % 4) | 0x1000;
    			flxWriteIntArrayAt(trace, 2, 0, current, 0, iaVal4, sizeof(int), 0, 4, 1);
    		}
    
    		// float array
    		faVal[0] = (n / 1000.);
    		faVal[1] = (n / 100.);
    		flxWriteFloatArrayAt(trace, 3, 0, 0, 1, faVal, sizeof(double), 2, 0);
    
    		// event array
    		eaVal[0] = n % 2;
    		eaVal[1] = (n + 1) % 2;
    		eaVal[2] = n % 4;
    		eaVal[3] = (n + 1) % 4;
    		eaVal[4] = n % 6;
    		eaVal[5] = (n + 1) % 6;
    		eaVal[6] = n % 8;
    		eaVal[7] = (n + 1) % 8;
    		flxWriteEventArrayAt(trace, 4, 0, 0, 1, eaVal, 8, 0);
    
    
  • Python

            # add array signals
            trace.addScope( 1, 0, "Arrays", "Scope Description");
            trace.addSignal( 2, 1, "array of integers", "2/4 elements", Flx.TYPE_INTEGER_ARRAY, "default<dim=4>");
            trace.addSignal( 3, 1, "array of floats", "2 elements", Flx.TYPE_FLOAT_ARRAY, "default<dim=2>");
            trace.addSignal( 4, 1, "array of enums", "8 elements", Flx.TYPE_EVENT_ARRAY, "default<dim=8>");
            
            # open
    
            # write array defs for arrays (may be omitted)
            trace.writeArrayDef( 2, 0, "x", "");
            trace.writeArrayDef( 2, 1, "y", "");
            trace.writeArrayDef( 2, 2, "z", "");
            trace.writeArrayDef( 2, 3, "-", "");
            trace.writeArrayDef( 3, 0, "x", None);
            trace.writeArrayDef( 3, 1, "y", None);
            trace.writeArrayDef( 4, 0, "state", None);
            trace.writeArrayDef( 4, 1, "done", None);
            
            # write enums for for signal 4  (enum array)
            trace.writeEnumDef( 4, Flx.ENUM_MEMBER_0 + 0, "Yes", 1);
            trace.writeEnumDef( 4, Flx.ENUM_MEMBER_0 + 0, "No", 0);
            trace.writeEnumDef( 4, Flx.ENUM_MEMBER_0 + 1, "Low", 1);
            trace.writeEnumDef( 4, Flx.ENUM_MEMBER_0 + 1, "High", 0);
    
            ...
    
            # integer array of multiple size
            if ((n % 2) == 0) :
                iaVal2[0] = (n % 16) | 0x10000;
                iaVal2[1] = (n % 1024) | 0x10000;
                trace.writeIntArrayAt( 2, 0, current , False, iaVal2, True);
            
            else :
                iaVal4[0] = (n % 16) | 0x1000;
                iaVal4[1] = (n % 1024) | 0x1000;
                iaVal4[2] = (n % 256) | 0x1000;
                iaVal4[3] = (n % 4) | 0x1000;
                trace.writeIntArrayAt( 2, 0, current , False, iaVal4, True);                   
            
            
            # array
            faVal[0] = (n / 1000.);
            faVal[1] = (n / 100.);
            trace.writeFloatArrayAt( 3, 0, 0, True, faVal, False);
    
            # event array
            eaVal[0] = n % 2;
            eaVal[1] = (n + 1) % 2;
            eaVal[2] = n % 4;
            eaVal[3] = (n + 1) % 4;
            eaVal[4] = n % 6;
            eaVal[5] = (n + 1) % 6;
            eaVal[6] = n % 8;
            eaVal[7] = (n + 1) % 8;
            trace.writeEventArrayAt( 4, 0, 0, True, eaVal, False);
    
  • TypeScript

            // add array signals            
            trace.addScope(1, 0, "Arrays", "Scope Description");
            trace.addSignal(2, 1, "array of integers", "2/4 elements", Flx.TYPE_INTEGER_ARRAY, "default<dim=4>");
            trace.addSignal(3, 1, "array of floats", "2 elements", Flx.TYPE_FLOAT_ARRAY, "default<dim=2>");
            trace.addSignal(4, 1, "array of enums", "8 elements", Flx.TYPE_EVENT_ARRAY, "default<dim=8>");
    
            // open
    
            // write array defs for arrays (may be omitted)
            trace.writeArrayDef(2, 0, "x", "");
            trace.writeArrayDef(2, 1, "y", "");
            trace.writeArrayDef(2, 2, "z", "");
            trace.writeArrayDef(2, 3, "-", "");
            trace.writeArrayDef(3, 0, "x", null);
            trace.writeArrayDef(3, 1, "y", null);
            trace.writeArrayDef(4, 0, "state", null);
            trace.writeArrayDef(4, 1, "done", null);
            
            // write enums for for signal 4  (enum array)        
            trace.writeEnumDef(4, Flx.ENUM_MEMBER_0 + 0, "Yes", 1);
            trace.writeEnumDef(4, Flx.ENUM_MEMBER_0 + 0, "No", 0);
            trace.writeEnumDef(4, Flx.ENUM_MEMBER_0 + 1, "Low", 1);
            trace.writeEnumDef(4, Flx.ENUM_MEMBER_0 + 1, "High", 0);
    
            ...
            
            // integer array of multiple size
            if ((n % 2) === 0){
                iaVal2[0] = (n % 16) | 65536;
                iaVal2[1] = (n % 1024) | 65536;
                trace.writeIntArrayAt(2, 0, current, false, iaVal2, true);
            } else {
                iaVal4[0] = (n % 16) | 4096;
                iaVal4[1] = (n % 1024) | 4096;
                iaVal4[2] = (n % 256) | 4096;
                iaVal4[3] = (n % 4) | 4096;
                trace.writeIntArrayAt(2, 0, current, false, iaVal4, true);
            }
    
            // float array 
            faVal[0] = (n / 1000.0);
            faVal[1] = (n / 100.0);
            trace.writeFloatArrayAt(3, 0, 0, true, faVal, false);
    
            // event array
            eaVal[0] = n % 2;
            eaVal[1] = (n + 1) % 2;
            eaVal[2] = n % 4;
            eaVal[3] = (n + 1) % 4;
            eaVal[4] = n % 6;
            eaVal[5] = (n + 1) % 6;
            eaVal[6] = n % 8;
            eaVal[7] = (n + 1) % 8;
            trace.writeEventArrayAt(4, 0, 0, true, eaVal, false);
     
  • JavaScript

            // add array signals                        
            trace.addScope(1, 0, "Arrays", "Scope Description");
            trace.addSignal(2, 1, "array of integers", "2 elements", Flx.TYPE_INTEGER_ARRAY, "default<dim=4>");
            trace.addSignal(3, 1, "array of floats", "2 elements", Flx.TYPE_FLOAT_ARRAY, "default<dim=2>");
            trace.addSignal(4, 1, "array of enums", "8 elements", Flx.TYPE_EVENT_ARRAY, "default<dim=8>");
    
            // open
    
            // write array defs for arrays (may be omitted)
            trace.writeArrayDef(2, 0, "x", "");
            trace.writeArrayDef(2, 1, "y", "");
            trace.writeArrayDef(2, 2, "z", "");
            trace.writeArrayDef(2, 3, "-", "");
            trace.writeArrayDef(3, 0, "x", null);
            trace.writeArrayDef(3, 1, "y", null);
            trace.writeArrayDef(4, 0, "state", null);
            trace.writeArrayDef(4, 1, "done", null);
            
            // write enums for for signal 4  (enum array)        
            trace.writeEnumDef(4, Flx.ENUM_MEMBER_0 + 0, "Yes", 1);
            trace.writeEnumDef(4, Flx.ENUM_MEMBER_0 + 0, "No", 0);
            trace.writeEnumDef(4, Flx.ENUM_MEMBER_0 + 1, "Low", 1);
            trace.writeEnumDef(4, Flx.ENUM_MEMBER_0 + 1, "High", 0);
    
            ...
            
            // integer array of multiple size
            if ((n % 2) === 0) {
                iaVal2[0] = (n % 16) | 65536;
                iaVal2[1] = (n % 1024) | 65536;
                trace.writeIntArrayAt(2, 0, current, false, iaVal2, true);
            }
            else {
                iaVal4[0] = (n % 16) | 4096;
                iaVal4[1] = (n % 1024) | 4096;
                iaVal4[2] = (n % 256) | 4096;
                iaVal4[3] = (n % 4) | 4096;
                trace.writeIntArrayAt(2, 0, current, false, iaVal4, true);
            }
    
            // float array 
            faVal[0] = (n / 1000.0);
            faVal[1] = (n / 100.0);
            trace.writeFloatArrayAt(3, 0, 0, true, faVal, false);
            
            // event array
            eaVal[0] = n % 2;
            eaVal[1] = (n + 1) % 2;
            eaVal[2] = n % 4;
            eaVal[3] = (n + 1) % 4;
            eaVal[4] = n % 6;
            eaVal[5] = (n + 1) % 6;
            eaVal[6] = n % 8;
            eaVal[7] = (n + 1) % 8;
            trace.writeEventArrayAt(4, 0, 0, true, eaVal, false);
        
toem

technical software and tooling

Company

Contact Us

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