07 Structured data


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.  The following types are supported:

  • FLX_STRUCTTYPE_TEXT : Textual data
  • FLX_STRUCTTYPE_ENUM : Enumeration data - corresponds to global enumeration type
  • FLX_STRUCTTYPE_INTEGER : Any size integer
  • FLX_STRUCTTYPE_FLOAT : Float or double values
  • FLX_STRUCTTYPE_BINARY : Binary data
  • FLX_STRUCTTYPE_LOCAL_ENUM : Enumeration data - corresponds to member enumeration type
  • FLX_STRUCTTYPE_MERGE_ENUM :
  • FLX_STRUCTTYPE_MOD_HIDDEN : This flag may be used to describe a member as 'hidden'.
	// add struct signals
	flxAddScope(trace, 1, 0, "Other", "Scope Description");
	flxAddSignal(trace, 2, 1, "Simple Struct", "desc", FLX_TYPE_STRUCT, 0);

	// open
	flxOpen(trace, 0, "ns", 0, 0);

	// write member defs for signal 2 (struct)
	struct flxMemberValueStruct members[4];
	flxInitMember(members + 0, 0, "m0", FLX_STRUCTTYPE_ENUM, 0);
	flxInitMember(members + 1, 1, "m1", FLX_STRUCTTYPE_INTEGER, "default<df=hex>");
	flxInitMember(members + 2, 2, "m2", FLX_STRUCTTYPE_FLOAT, 0);
	flxInitMember(members + 3, 3, "m3", FLX_STRUCTTYPE_TEXT, 0);
	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);

The c struct flxMemberValueStruct is used to send either the declarative information (using the function flxWriteMemberDefs) as well the sample data (with the function flxWriteMembersAt).
Before triggering flxWriteMembersAt, you need to set the value of each member. This is done with flxSetMember(flxMemberValue member, void* value, flxuint size, flxuint option, flxbool valid). The option parameter is type specific and currently only used for the integer type as sign flag.

 

// iterate over n

	// values
	int eVal = n & 1;
	double fVal = cos(n / 100.);
	char tVal[32];
    sprintf(tVal, "val: %f", fVal);

	// 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, n * 10, 0, members, 4);

toem

technical software and tooling

Company

Contact Us

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