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.
IntegerArray | FloatArray | EventArray | TextArray | ||
Java |
|
|
|
|
|
c |
+ size, count and signed parameter |
+ size and count parameter |
+ count parameter |
||
Python |
|
|
|
|
|
TypeScript |
|
|
|
|
|
JavaScript |
|
|
|
|
To create an array, the following steps need to be done:
The parameters for flxWriteXXXArraytAt/writeXXXArrayAt are:
The c-language variant uses a pointer to an array and required the additional parameters:
// 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);
// 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);
# 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);
// 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);
// 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);