COMP 3004 Specification
From the Team Optimus Prime presentation (expires December 4, 2010):
Field Types
The field types and intended purpose are defined in this section. It can be noted that if necessary, the protocol can be reworked to include sending image data as binary strings in predetermined formats. For our implementation, we assume a fixed set of icons with varying “styles” for distinction (color, size, etc).
Int – 4 bytes
Long – 8 bytes
Point – 2 Integers in succession (co-ordinates)
Date – Integer in Unix date format
Byte – 1 byte, usually for toggling bits
String – n bytes, null terminated, preceded by a length field
Array – set of one to n (1..n) objects of a given type, stored object after object, always preceded by a length field
Typical Bit Flags
There are several typical bit patterns that are outlined in the following section. These patterns should remain consistent across systems for compatibility reasons. The use of bit flags makes messages much more compact and easy to maintain.
ObjectType
- 0x01 – Supply
- 0x02 – Disease
- 0x03 – User
- 0x04 – Shipment
RequestType
- 0x01 – Supply
- 0x02 – Disease
- 0x03 – Combination of Supply and Disease
AttributeType
- 0x01 – Integer
- 0x02 – Point
- 0x03 – Date
- 0x04 – Byte
- 0x05 – String
Status
- 0x01 – Success
- 0x02 – Failure
- 0x03 – Warning
Mode
- 0x01 – View
- 0x02 – Create
- 0x03 – Close
- 0x04 – Send
- 0x05 – Receive
Icon
- 0x00 – 0xFF – Icon Index
UserType
- 0x01 – Medical Clerk
- 0x02 – Medical Administrator
- 0x03 – System Administrator
PacketType
- 0x01 – CreateObjectRequest
- 0x02 – CreateObjectReply
- 0x03 – UpdateObjectRequest
- 0x04 – UpdateObjectReply
- 0x05 – RequestObjectRequest
- 0x06 – RequestObjectReply
- 0x07 –RequestShipmentRequest
- 0x08 – RequestShipmentReply
- 0x09 – FilterDataRequest
- 0x0A – FilterDataResponse
- 0x0B – UserLoginRequest
- 0x0C – UserLoginReply
CreateObject – Request
- PacketType – byte
- PacketLength – long
- ObjectType – byte
- AttributesCount – int
- Attributes – array
o AttributeNameLength – int
o AttributeName – string
o AttributeType – byte
o AttributeValueLength – int
o AttributeValue – string
CreateObject – Reply
- PacketType – byte
- PacketLength – long
- Status – byte
UpdateObject – Request
- PacketType – byte
- PacketLength – long
- RequestType – byte
- ObjectLocationLength – int
- ObjectLocation – string
- ObjectCount – int
UpdateObject – Reply
- PacketType – byte
- PacketLength – long
- Status – byte
RequestObject – Request
- PacketType – byte
- PacketLength – long
- RequestType – byte
- TopLeft – Point
- BottomRight – point
RequestObject – Reply
- PacketType – byte
- PacketLength – long
- DiseasesCount – int
- Diseases – Array
o NameLength – int
o Name – string
o Epicenter – point
o Count – int
o Icon – int
- SuppliesCount – int
- Supplies – Array
o NameLength – int
o Name – string
o Epicenter – point
o Count – int
o Icon – int
RequestShipments – Request
- PacketType – byte
- PacketLength – long
- Mode – byte
RequestShipments – Reply
- PacketType – byte
- PacketLength – long
- ShipmentListCount – int
- ShipmentList – Array
o ShipmentState – byte
o ShipmentOriginLength – int
o ShipmentOrigin – string
o ShipmentDestinationLength – int
o ShipmentDestination – string
o ShipmentContentsLength – int
o ShipmentContents – Array
o ItemNameLength – int
o ItemName – string
o ItemCount – int
FilterData – Request
- PacketType – byte
- PacketLength – long
- RequestType – byte
- TopLeft – point
- BottomRight – point
- StartDate – date
- EndDate – date
FilterData – Response
- PacketType – byte
- PacketLength – long
- DiseasesCount – int
- Diseases – Array
o NameLength – int
o Name – string
o Epicenter – point
o Count – int
o Icon – byte
- SuppliesCount – int
- Supplies – Array
o NameLength – int
o Name – string
o Epicenter – point
o Count – int
o Icon – byte
UserLogin – Request
- PacketType – byte
- PacketLength – long
- Mode – byte
- UsernameLength – Short
- Username – string
- PasswordLength – Short
- Password – string
UserLogin – Response
- PacketType – byte
- PacketLength – long
- Status – byte
- UserType – byte