2010-11-17 15:56:10 +00:00
|
|
|
"General IE based message handling"
|
2010-11-17 09:26:28 +00:00
|
|
|
Object subclass: IEMessage [
|
2010-11-19 08:02:26 +00:00
|
|
|
<category: 'osmo-messages'>
|
2010-11-17 09:26:28 +00:00
|
|
|
| ies type |
|
|
|
|
|
|
|
|
IEMessage class >> initWith: type [
|
2010-11-19 08:02:26 +00:00
|
|
|
<category: 'creation'>
|
2010-11-17 09:26:28 +00:00
|
|
|
^ (self new)
|
|
|
|
type: type;
|
|
|
|
yourself
|
|
|
|
]
|
|
|
|
|
|
|
|
type: aType [
|
2010-11-19 08:02:26 +00:00
|
|
|
<category: 'creation'>
|
2010-11-17 09:26:28 +00:00
|
|
|
type := aType.
|
|
|
|
]
|
|
|
|
|
|
|
|
addIe: aIe [
|
2010-11-19 08:02:26 +00:00
|
|
|
<category: 'creation'>
|
2010-11-17 09:26:28 +00:00
|
|
|
self ies add: aIe.
|
|
|
|
]
|
|
|
|
|
|
|
|
ies [
|
2010-11-19 08:02:26 +00:00
|
|
|
<category: 'access'>
|
2010-11-17 09:26:28 +00:00
|
|
|
ies isNil ifTrue: [
|
|
|
|
ies := OrderedCollection new.
|
|
|
|
].
|
|
|
|
|
|
|
|
^ ies
|
|
|
|
]
|
|
|
|
|
|
|
|
storeOn: aMsg [
|
2010-11-19 08:02:26 +00:00
|
|
|
<category: 'creation'>
|
2010-11-17 09:26:28 +00:00
|
|
|
aMsg putByte: type.
|
|
|
|
|
|
|
|
self ies do: [:each | each storeOn: aMsg ]
|
|
|
|
]
|
|
|
|
]
|
|
|
|
|
2010-11-19 18:12:44 +00:00
|
|
|
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
|
|
|
|
]
|
|
|
|
]
|
2010-11-17 09:26:28 +00:00
|
|
|
|