-
Notifications
You must be signed in to change notification settings - Fork 46
Command 1A Insulin Schedule
Several important messages include the "1A" command, which gives an insulin schedule on 30 minute intervals. This page describes how that command is constructed.
For example, consider this command:
...1a0e9891474a01008101384000040004160e... (TB 0.40 U/h for 0.5h)
1a 0e 9891474a 01 0081 01 3840 0004 0004 16 0e...
This command is parsed as:
- Mtype (1 byte):
1a
: This specifies the command type. - Length (1 byte):
0e
: The length of this command. (I.e. number of bytes following the length.) - Nonce (4 bytes):
9891474a
- TableNum (1 byte):
01
(Basal Schedule = 0, Temp Basal = 1, Bolus = 2) - Checksum (2 bytes):
0081
- Duration (1 byte):
01
(in 30 minute units) - FieldA (2 bytes):
3840
- UnitRate (2 bytes):
0004
(U/h in increments of 0.1) - UnitRateSchedule (0+ words):
0004
0
=1x (no. of repeats)0
= 0 (or 8 When it iterates using 1x/2x)04
=4x (of 0.05U) makes 1x1x4x0.05U = 0.2U in 0.5h for this 1 schedule, which can be repeated after each other. - Next command. Command $1A is followed (in the same message) by another command:
- $17 Bolus Extra for bolus
- $16 Temp Basal for temp basal
- $13 Basal Schedule for basal schedule
You can see in the above command that the single UnitRateSchedule word value of 0004
specifies 0.2U in 0.5h which is a 0.4 U/h TB for 0.5h.
Also, "UnitRate" specifies 0.4 U/h and the "Duration" specifies 0.5h if this interpretation is correct.
This command generates a insulin schedule table, which is the number of 0.05U insulin steps for every 30 minutes. Each element describes an interval between 30 minutes to 8 hours long at same hourly rate. A bit is used to indicate if an extra 0.05U step is applied at alternate half hours to effectively give an hourly basal rate resolution of 0.05 U/h.
For example, consider the temp basal test example below:
... 1a0efc0fdf2b01008d083840 0001 7801 ... (TB 0.15U/h for 4.0h)
The UnitRateSchedule word is 7 8 01
. Where 7
is a number (N),
8
is a boolean (H) indicating that an an extra step is added for the second half hour of each hour,
and 01
the the step size (S). In this example, N = 7, H = 1, and S = 1.
A value N indicates N+1 entries in the schedule. (I.e. 0 is a single entry and it increases from there.) So in this case we have 8 entries. S is the number of 0.05U steps. Finally, H indicates alternating values are increased by 1 to provide an extra 0.05U step to effectively provide an extra 0.05 U/h.
Thus the generated table for a 7801
UnitSchedule word has the following 8 entries:
1: 01 x 0.05U for 0.5h = 0.05U
2: 02 x 0.05U for 0.5h = 0.10U
3: 01 x 0.05U for 0.5h = 0.05U
4: 02 x 0.05U for 0.5h = 0.10U
5: 01 x 0.05U for 0.5h = 0.05U
6: 02 x 0.05U for 0.5h = 0.10U
7: 01 x 0.05U for 0.5h = 0.05U
8: 02 x 0.05U for 0.5h = 0.10U
0.60U total over 4.0h
As you can see, this works out to the desired 0.15 U/h over this 4.0 hour interval.
Start of confusing paragraph, delete?: At first the idea was that the schedule allows a rate of 0.05U/h even though the unit step size is 0.1U/h. It does this by creating a schedule that alternates between 0 and 0.1 every 30 minutes. But when testing it to other basal presets I could not use the 0.1 0.5hr + 0.2 0.2hr method to get to 0.75 U/h for example. It did work with 0.05 as a step size and using the 8 byte as a +1 to the given step size. End of confusion
More schedule examples can be found here:
The basal schedule contains multiple consecutive UnitRateSchedule words. There is a minimum of 3 words for a 24-hour basal pattern as each word can only describe up to an 8-hour interval. The first word specifies the basal rate starting at midnight and subsequent words describes the basal rate for the next consecutive time interval for up to 8 hours until a total of 24 hours are described. To build a schedule that has the same basal rate for longer than 8 hours, UnitRateSchedule words specifying the same basal rate are concatenated as in this example:
1a 14 b415a62e 00 0203 07 3728 0001 7801 f00a f00a 700a 13 1440
0.15 U/h from 0:00-04:00 (7801
) and 1.0 U/h from 04:00-24:00 (f00a f00a 700a
)
Note that the Basal Schedule will have TableNum of 0, at least 3 UnitRateSchedule words needed to describe 24 hours of basal rates, and will always be followed with a Next Command of $13 which is not yet understood. If is very unclear how to interpret the so called "Duration" (7 in this example) and "UnitRate" (0001 in this example) fields for the Basal Schedule.
1a 0e fc0fdf2b 01 008d 08 3840 0001 7801 ...
The checksum is the byte sum of the bytes in time, fieldA, and UnitRate in the command, along with the bytes in the schedule generated from UnitRateSchedule.
In the example above, the checksum is $008d. The field bytes that get summed are $08 38 40 00 01. The schedule bytes for $7801 UnitRateSchedule word are 01 02 01 02 01 02 01 02. You can verify that these bytes sum to $8d (=141 decimal) shown in python below:
hex_data = '08384000010102010201020102'
b = bytearray.fromhex(hex_data)
checksum = sum((b))
print(checksum) # 141
print(hex(checksum)) # 0x8d
FieldA The meaning of FieldA is currently unknown. 14400 is 24*60*10, which suggests this is related to minutes in a day. Perhaps this value is 10 days in minutes? This value must be <= $3840 (decimal 14400). It's unclear why the command contains UnitRate, since this is redundant with the UnitRateSchedule. This value must be <= $384 (decimal 900). In the examples, it matches the lower value from UnitRateSchedule. It looks like FieldA is always $3840 when changing basal rates, but uses $10xUnitRate when bolussing.
The TableNum field can have the value 0, 1, or 2. It specifies which internal table holds the schedule. Table 1 is for a rate schedule, Table 2 is for bolus, while Table 0 appears to be for set basal preset pattern.
The second block of test data below provides % increase commands. For example:
...1a 10 0796a885 01 00a5 04 1688 0000 1000 1801 1614... +5% 1.5h
Note that the length is $10, corresponding to the two UnitSchedule values "1000 1801". This generates the schedule "00 00 01 02" using the above algorithm, although it's not too clear what this represents.
More analysis will be needed to determine how the % schedules work. There's nothing obvious distinguishing % schedule commands from other basal schedules; it could just be the user interface.
Duration One puzzle is the Duration field which matches the number of schedule entries, but it doesn't match the time interval in the text. The above example has a time period of 4 and a 4-entry schedule, but says "1.5h". It seems more obvious when using the command in combination with bolus + temp, then you can say: 3x30min=1,5h + 1 duration for instant bolus.
The FieldA values vary according to the percentage, but not in any obvious way.
An example bolus schedule:
...1a 0e fcc35735 02 006d 01 0060 0006 0006 170d... 0.30U
The TableNum is $02 for a bolus, different from the previous commands.
The Duration is $01, which indicates a half hour.
The UnitRate and UnitSchedule are in units of 0.05U, e.g. $6 corresponds to 0.30U. This is probably actually a unit of 0.1U/h (as for the rate), expressed over half an hour. I.e. a 0.30U bolus is 0.60U/h within the next 30 minutes.
FieldA is $10 * the UnitRate.
Note that in the same message the command following a bolus schedule is $17 (instead of $16 with temp basal and $13 with program basal).
1f08ced2bb1f08ced220201a0eea2d0a3b01007d01384000020002160e40000014055d4a31 1f08ced29d800014055d4a8080d5a9 0.20U/h 0.5h
1f08ced2b31f08ced210201a0e5947ac4801007d01384000020002160e40000019044aa2ee 1f08ced295000019044aa20000aab5 0.25U/h 0.5h
1f08ced0b31f08ced020201a0eb253639201007d01384000020002160e40000019044aa252 0.25U/h 0.5h [This looks wrong; the data indicates rate of 0.2U]
1f08ced0be1f08ced038201a0e5e891a9a01007d01384000020002160e40000019044aa205 0.25U/h 0.5h [Looks wrong too]
1f08ced0a61f08ced008201a0e93fe524d01008301384000050005160e4000003202255118 0.50U/h 0.5h
1f08ced0b11f08ced020201a0e3fa53f5501007901384000000000160e7c0000006b49d287 0.0/Off 0.5h
1f08ced0bc1f08ced038201a0e8877e69d01008d013840000a000a160e400000640112a8d6 1.00U/h 0.5h
1f08ced0ba1f08ced038201a0e1316396e01008101384000040004160e4000002802aea564 0.40U/h 0.5h
1f08ced0a51f08ced010201a0ea248b61001007f01384000030003160e4000001e03938758 0.30U/h 0.5h
1f08ced0b01f08ced028201a0e9f7270810100a101384000140014160e400000c800895460 2.00U/h 0.5h
1f08ced0bb1f08ced000201a0ec7ed05da0100a101384000140014160e400000c80089545f 2.00U/h 0.5h
1f08ced0a61f08ced018201a0e759588120100b602384000141014160e400001900089546f 2.00U/h 1.0h
1f08ced0ae1f08ced028201a0e87e8d03a0100cb03384000142014160e400002580089542c 2.00U/h 1.5h
1f08ced0b91f08ced000201a0ebb1a5b4e010098023840000a100a160e400000c80112a88b 1.00U/h 1.0h
1f08ced0a41f08ced018201a0e63cf4d8f01007e04384000003800160e4000001415752a00 0.05U/h 2.0h
1f08ced0aa1f08ced028201a0e4e2c271701007f05384000004800160e4000001915752a62 0.05U/h 2.5h
1f08ced0a21f08ced018201a0e9ab753c701008106384000005800160e4000001e15752ae3 0.05U/h 3.0h
1f08ced0aa1f08ced028201a0eeff8e4e001008707384000016001160e400000460aba95c7 0.10U/h 3.5h
1f08ced0b81f08ced008201a0efc0fdf2b01008d08384000017801160e4000007807270e24 0.15U/h 4.0h
1f08ced0b71f08ced020281a10b09f0eed0101180223f000010002000016144000000e0291 +5% 0.5h
1f08ced0bf1f08ced030281a10200ea0800100ef0222c800010002000016144000000e02f5 +10% 0.5h
1f08ced0a71f08ced000281a10e37fe8730100ae02218800010002000016144000000f037a +25% 0.5h
1f08ced0af1f08ced010281a10b76cd97101008702206000010003000116144000001200b0 +50% 0.5h
1f08ced0a41f08ced018201a0e2c33683701007b02384000001800160e4000000a15752ae5 +5% 1.0h
1f08ced0bf1f08ced010201a0e33045d4301007b02384000001800160e4000000a15752a7b +5% 1.0h
1f08ced0b41f08ced038281a100796a8850100a504168800001000180116144000000d00fa +5% 1.5h
9214200302001301001000010001170d40000a00030d40 000000000000006f 0.05U
0311712302002501002000020002170d40001400030d40 00000000000001cb 0.10U
464be60d02003701003000030003170d40001e00030d40 000000000000838b 0.15U
6c5412e102004901004000040004170d40002800030d40 000000000000834c 0.20U
8ef824bb02005b01005000050005170d40003200030d40 00000000000080ad 0.25U
fcc3573502006d01006000060006170d40003c00030d40 000000000000831c 0.30U
f4f0bfed02007f01007000070007170d40004600030d40 000000000000819e 0.35U
7cfd364202009101008000080008170d40005000030d40 0000000000000338 0.40U
1335474a0200a301009000090009170d40005a00030d40 0000000000000271 0.45U
84a6fb7f0200b50100a0000a000a170d40006400030d40 000000000000839d 0.50U
d9d7fb3f02011e0101e0001e001e170d40012c00030d40 000000000000009d 1.50U