05 Scopes and numeric data


Scopes and numeric data

The method flxAddScope adds a scope item to the trace. Scopes shall be used to organize large amounts of signals. The arguments are:

  • the trace object,
  • itemId for the scope,
  • parentId, here 0 for the root scope,
  • a name,
  • and a description
In this example, we add signals for different types of integer and float values. As you can see in the first part of the code, flux doesn't care about it in the declaration. If you declare an integer signal, you can write values of any length into.
	// head
	flxAddHead(trace, "example", "flux example");

	// add integer signals
	flxAddScope(trace, 1, 0, "Integers", "Scope Description");
	flxAddSignal(trace, 2, 1, "a char", "Signal Description", FLX_TYPE_INTEGER, 0);
	flxAddSignal(trace, 3, 1, "an integer", "Signal Description", FLX_TYPE_INTEGER, 0);
	flxAddSignal(trace, 4, 1, "a short", "Signal Description", FLX_TYPE_INTEGER, 0);
	flxAddSignal(trace, 5, 1, "a llong", 0 /* no description*/, FLX_TYPE_INTEGER, 0);

	// add float signals
	flxAddScope(trace, 11, 0, "Floats", "another Scope");
	flxAddSignal(trace, 12, 11, "a float", 0, FLX_TYPE_FLOAT, 0);
	flxAddSignal(trace, 13, 11, "a double", 0, FLX_TYPE_FLOAT, 0);

The actual size of a value (if it is a bytes or an 64 bit integer) is added as a separate parameter after the value pointer. For float signal, the size is limited to 4 (float) or 8(double), for integer it can be any size (size>=1).

// iterate over n

	// values
	unsigned char i0 = n % 8;
	int i1 = n;
	unsigned short i2 = n * 3;
	long long = n * n;
	float f1 = sin(n / 1000.);
	double f2 = cos(n / 100.);
    
	// write integer values of multiple types
	flxWriteIntAt(trace, 2, 0, n * 10, 0, &i0, sizeof(char), 0);
	flxWriteIntAt(trace, 3, 0, 0, 1, &i1, sizeof(int), 1);
	flxWriteIntAt(trace, 4, 0, 0, 1, &i2, sizeof(short), 0);
	flxWriteIntAt(trace, 5, 0, 0, 1, &i3, sizeof(long long), 1);

	// write float values of multiple types (5ns later)
	flxWriteFloatAt(trace, 12, 0, 5, 1, &f1, sizeof(float));
	flxWriteFloatAt(trace, 13, 0, 0, 1, &f2, sizeof(double));


toem

technical software and tooling

Company

Contact Us

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