Signals of type structure can transport a set of values (members) with each change. This member set may vary from sample to sample.
To create a struct signal, the following steps need to be done:
The method of creating and initializing the members differs between c-language and the object-oriented variants.
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:
The arguments of flxInitMember are:
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:
The arguments of createMember are:
To finally write the members to the trace, use flxWriteMembersAt/writeMembersAt:
// 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);
// 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);
# 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);
// 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);
// 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);