![]() |
![]() |
![]() |
![]() |
![]() |
Appendix A: Formats for ASCII
The ASCII encoding function, ASCII_ENCODE, encodes the SDL signal parameters and variables as ASCII characters before adding into the buffer. The output into the buffer is illustrated with a number of examples.
Braces { } are used for most data types and show where the data types start and stop. Signal parameters start and stop with braces.
For more information about data types see Using SDL Data Types.
Array, CArray
Array is used to define a fixed number of elements.
Array takes two generator parameters, an index sort and a component sort.
newtype A1 Array(b, Integer) endnewtype;dcl Var_Array A1;task Var_Array := (. 3 .);Bag
Bag is almost the same as Powerset. The only difference is that Bag contains the same value several times. Bag can be used as an abstraction of other data types.
Bag takes one generator parameter, the item sort.
newtype B1 Bag(Integer) endnewtype;dcl Var_Bag B1;task Var_Bag := (. 7, 4, 7 .);Output to the buffer: {2:7,1:4}
Example 448 : Using Bag (old-style SDL operator code generation)
newtype B1 Bag(Integer) endnewtype;dcl Var_Bag B1;task Var_Bag := Incl(7, Incl(4, Incl(7, Empty)));Output to the buffer: {2:7,1:4}
Bit
Bit can only take two values, 0 and 1.
dcl Var_Bit Bit;task Var_Bit := 1;Bit_String
Bit_String is used to represent a sequence of bits.
Example 450 : Using Bit_String
dcl Var_Bit Bit_String;task Var_Bit := Mkstring(I20(1101));Boolean
Boolean can only take two values, False and True.
dcl Var_Boolean Boolean;task Var_Boolean := TRUE;If Var_Boolean is set to FALSE, the output to the buffer will be F.
Character
Character is used to represent the ASCII characters.
dcl Var_Character Character;task Var_Character := `M'CharStar, PId, UnionC, Userdef, VoidStar, VoidStarStar
The user has to define encoding/decoding procedures for these types, see Appendix B: User defined ASCII encoding and decoding. If no encoding/decoding procedure is defined, then there will be no output to buffer.
For threaded integrations, the PId value will be encoded/decoded by coding the memory address as an integer.
CharString, IA5String, NumericString, PrintableString, VisibleString
These string types are used to represent sequences of characters.
Example 453 : Using Charstring
dcl Var_Charstring Charstring;task Var_Charstring := `Hello world'Output to the buffer: `Hello world'
Choice, Union
Choice represents the ASN.1 concept CHOICE and can also be seen as a C union with an implicit tag field.
newtype C Choicec1 Character;c2 Boolean;endnewtype;dcl Var_Choice C;task Var_Choice := c2:true;Output to the buffer: {1,T}, where 1 is an implicit tag.
Duration, Time
Time is used to denote `a point in time' and Duration is used to denote `a time interval'.
A value of sort Time represents a point of time in the real world. The Time unit is usually 1 second.
dcl Var_Time Time;task Var_Time := 1;Output to the buffer: {1,0}. The first field is seconds and the second field is nano-seconds.
Enum
Enum contains only the values enumerated in a sort.
newtype E /*Enum*/literals e1, e2, e3;endnewtype;dcl Var_Enum E;task Var_Enum := e2;Float
Float is equivalent to float in C.
dcl Var_Float Float;task Var_Float := 3.14159;Output to the buffer: 3.1415901e0 (always 7 decimals)
GPowerset, Object_Identifier, String
GPowerset is used as an abstraction of other data types. GPowerset takes one generator parameter, the item sort.
Object_Identifier is a sequence of Natural values.
String can be used to build lists of items of the same type. String has two generator parameters, the component sort and the name of an empty string.
newtype GP Powerset(Integer) endnewtype;dcl Var_GPowerset GP;task Var_GPowerset := Incl(7, Incl(4, Empty));Object_Identifier and String are used in the same way as GPowerset.
Inherits, Syntype
Syntype and Inherits create a new type, that has the same properties as an existing type, by inheriting the type or make a syntype of the type.
syntype newinteger = Integer endsyntype;dcl Var_Newinteger newinteger;task Var_Newinteger := 2Integer, LongInt, ShortInt, UnsignedInt, UnsignedLongInt, UnsignedShortInt, Natural
Integer is used to represent mathematical integers.
Natural is a syntype of Integer.
dcl Var_Integer Integer;task Var_Integer := 1Null
The sort Null only contains one value, Null.
dcl Var_Null Null;task Var_Null := Null;Octet
Octet is used to represent eight-bit values.
dcl Var_Octet Octet;task Var_Octet := I20(12);Octet_String
Octet_String represents a sequence of Octet values.
Octet_String always contains an equal number of characters, since every octet takes two characters.
Example 463 : Using Octet_String
dcl Var_OctetString Octet_String;task Var_OctetString := Mkstring(I20(12));ORef, Own, Ref
ORef, Own and Ref are used to define pointer types.
newtype R Ref(r1) endnewtype;dcl Var_Ref R;task Var_Ref := (. (. 1, 2, `Telelogic' .) .);Output to the buffer: {{1,2,'Telelogic'}}
Powerset
Powerset takes one generator parameter, the item sort, and implements a powerset over that sort. Powerset can be used as an abstraction of other data types.
newtype P Powerset(p1) endnewtype;dcl Var_Powerset P;task Var_Powerset := (. 4, 3 .);Output to the buffer: `00110000000000000000000000000000'
The bits are an equal multiple of sizeof(unsigned long).
Example 466 : Using Powerset (old-style SDL operator code generation)
newtype P Powerset(p1) endnewtype;dcl Var_Powerset P;task Var_Powerset := Incl(4, Incl(3, Empty));Output to the buffer: `00110000000000000000000000000000'
The bits are an equal multiple of sizeof(unsigned long).
Real
Real is used to represent the mathematical real values.
dcl Var_Real Real;task Var_Real := 1.0;Output to the buffer: 1.0000000000000e0 (always 13 decimals)
SignalId
SignalId is used to describe the signal ID.
SignalId is a sequence with characters.
dcl Var_SignalId SignalId;task Var_SignalId := `Sig1';Struct
Struct can be used to make an aggregate of data that belong together.
newtype S structs1 integer;s2 integer;s3 charstring;endnewtype;dcl Var_Struct S;task Var_Struct := (. 1, 2, `Telelogic' .);
http://www.ibm.com/rational |
![]() |
![]() |
![]() |
![]() |