smalltalk
/
osmo-st-gsm
Archived
1
0
Fork 0
This repository has been archived on 2022-02-17. You can view files and clone it, but cannot push or open issues or pull requests.
osmo-st-gsm/Messages.st

58 lines
1.1 KiB
Smalltalk
Raw Normal View History

"General IE based message handling"
Object subclass: IEMessage [
<category: 'osmo-messages'>
| ies type |
IEMessage class >> initWith: type [
<category: 'creation'>
^ (self new)
type: type;
yourself
]
type: aType [
<category: 'creation'>
type := aType.
]
addIe: aIe [
<category: 'creation'>
self ies add: aIe.
]
ies [
<category: 'access'>
ies isNil ifTrue: [
ies := OrderedCollection new.
].
^ ies
]
writeOn: aMsg [
<category: 'creation'>
aMsg putByte: type.
self ies do: [:each | each writeOn: aMsg ]
]
]
Object subclass: BCD [
<category: 'osmo-message'>
<comment: 'Class to deal with Binary Coded Decimals'>
BCD class >> encode: aNumber [
<category: 'access'>
| col num |
col := OrderedCollection new.
num := aNumber.
1 to: 3 do: [:each |
col add: num \\ 10.
num := num // 10.
].
^ col reverse asByteArray
]
]