SML Types

2008 Oct 04


SML Files Type Codes Function Descriptors

SML Files

SML files can be:

SMB binary files are made up of a series of fields each of which is host computer independent.

It is assumed all bytes are 8 bits long.

There is a 10 byte header:

[8] MAGIC = 0xFEEDDEEF, 0xDEEFFEED
[1] ENDIANNESS = LITTLE_ENDIAN(0) or BIG_ENDIAN(1)
[1] VERSION = 0

Types and Codes

Value(s) follow type code/tag.
Tag Code Meaning
reserved0 0 null terminated string of ASCII bytes
void 1 no value
ptr1 to 2 value is a type code, followed by the int1 pointer
ptr2 to 3 value is a type code, followed by the int2 pointer
ptr4 to 4 value is a type code, followed by the int4 pointer
ptr8 to 8 value is a type code, followed by the int8 pointer
string 9 null terminated string of ASCII bytes
unicode 10 unicode string
uchar
uint1
11 unsigned byte
char
int1
12 signed byte
uint2 13 unsigned 2 byte integer
int2 14 signed 2 byte integer
uint4 15 unsigned 4 byte integer
int4 16 signed 4 byte integer
uint8 17 unsigned 8 byte integer
int8 18 signed 8 byte integer
uint_n 19 unsigned variable (as needed) length integer
int_n 20 signed variable (as needed) length integer
float4 21 single precision 4 byte IEEE floating point
float8 22 double precision 8 byte IEEE floating point
float_n 23 variable precision IEEE floating point (to be specified later)
date1 24 date and time as follows:
year int3 1999 is 1999, 0 is 1 B.C., -1 is 2 B.C.
month uchar 0..11
day uchar 1..31
hour uchar 0..23
min uchar 0..59
sec uchar 0..59
date2 25 date and time as follows:
year int3 1999 is 1999, 0 is 1 B.C., -1 is 2 B.C.
month uchar 0..11
day uchar 1..31
hour uchar 0..23
min uchar 0..59
sec uchar 0..59
fraction of sec uint4 0..2^32-1
array1 26 uchar1 specifying array size, followed by type code, followed by array of values
array2 27 uchar2 specifying array size, followed by type code, followed by array of values
array4 28 uchar4 specifying array size, followed by type code, followed by array of values
array8 29 uchar8 specifying array size, followed by type code, followed by array of values
record1 30 uchar1 specifying number of fields, each field is a type code value pair
record2 31 uchar2 specifying number of fields, each field is a type code value pair
record4 32 uchar4 specifying number of fields, each field is a type code value pair
record8 33 uchar8 specifying number of fields, each field is a type code value pair
file 34 single_file : an embedded file, in the form of:
1. name : a null terminated string
2. length : an uint8 file length
3. file data : length bytes
file_n 35 multi_file : multiple embedded files,
consisting of an uint2 value specifying the number of packed files,
followed by a single_file field for each of the packed files
func 36 function descriptor
reserved255 255 null terminated string of ASCII bytes

Function Descriptors

3.1  Wave Generator
The Wave Generator file specific data consists of two parts:
* Overall Descriptor
* Segment Descriptor(s)
3.1.1  Overall Descriptor
The Overall Descriptor has 3 fields in the following order:
1. Mode : is of type char, and has one of two values 'V' for voltage or 'I' for current
2. Source_Impedeance : has two sub fields, in the order
Real : of type float8
Imaginary : of type float8
3. Segment_Count : of type integer4, 
specifies the number of Segment Descriptors which follow
A wave consists of a sequence of Segments, each of which is defined by a Segment Descriptor. The wave is generated over time, one segment after another. When the last segment in the file has been reached, the wave continues as specified by the last state of the last segment. See below on what this means for different kinds of segments.
There must be at least one segment in a wave file, or else a fatal error is given. Each segment changes in value relative to the previous segment. The first segment always starts with a relative intensity or amplitude of 0.0 and at a relative time of 0.0. Any subsequent segments are relative in amplitude and duration to the ending of the previous segment.
3.1.2  Segment Descriptor
Each Segment Descriptor has 3 parts in the following order:
1. Duration_Type : a field of type char, and has one of 3 values
'C' : constant
'P' : periodic
'F' : finite
2. Source_Impedeance : has two sub fields, in the order
Real : of type float8
Imaginary : of type float8
3. Definition : depends on the value of Duration_Type (see below)
Note that if the Duration_Type is constant, 'C', or periodic. 'P', no further segments in the file will be processed. A warning message will be given if there is any data after a segment of either of these two durations (constant or periodic). A fatal error results if more segments were specified in the Segment_Count of the Overall Descriptor after encountering a constant or periodic segment. Any number of segments (including 0) of finite duration (up to the limit of type integer4) can exist before a segment which is constant or periodic.

3.2.1  Definition for a Constant Segment
Consists of a single field of type float8, which is the constant D.C. amplitude, in volts or amperes according to the Mode in the Overall Descriptor, relative to the amplitude at the end of the Duration of the previous segment. If this is the first segment then the previous amplitude is implicitly 0.0. The wave continues with the resulting amplitude indefinitely in time.
3.2.2  Definition for a Periodic Segment
Consists of 2 parts, a field of type integer4, which must be of value >0, which defines the number of sub-segments in the periodic wave. This field is followed by that many finite Definitions (see section 3.2.3).
Note that the ending value of a periodic signal must be the same intensity as its initial value, or else it is a fatal error. It may also be required that the slope of the wave at the start and end of the Duration for this period are the same (this is to be decided).
The wave repeats periodically in time, starting again with the first sub-segment after the last sub-segment. The period of the wave is the sum of the durations of the sub-segments.
3.2.3  Definition for a Finite Segment
Has a first field of type float8, name Segment_Duration, which is the duration of the segment in seconds, and must have a value greater than 0.0. Has a second field of type integer2, called math_type, which defines the mathematical nature of this segment. The math_type field is followed by a number of additional fields which depend on the value of the math_type. This is described in the following table, where T represents the value of Segment_Duration. The symbol N, is of type integer4, and represents the value of the first parameter when its defines the number of remaining parameters. Other parameters are in bold-italics and appear in the equation in the order they appear in the file (after N if it exists). The symbol t represents relative time for the segment and runs linearly from 0??t??T.

math_type value
meaning
number and type of parameters
equation for relative amplitude change
0
constant
0
0.0
1
step
1 float8
A
2
linear
1 float8
A*t/T
3
quadratic
2 float8
A1*t+A2*t2
4
polynomial
1 integer4
+ N float8

5


2005-2008