I coded the first version of an Artificial Pancreas System in C# in October of 2011 while working for the University of California Santa Barbara (UCSB) and the Sansum Diabetic Research Institute.
Concept
Connect a Continuous Glucose
Monitor (GCM) device with an Insulin Pump in a feedback control loop.

(A simplified version was developed after this "proof of concept" prototype.
A lot of logging was incorporated so we would have a detailed record of what the program did.)

This Windows Forms application I wrote includes:

Communication with external Devices and External Controller Program
The program communicated with two external devices, one emulating
and insulin pump, the other emulating a Continuous Glucose Meter (CGM)
device.
Port Sniffer
On the first day I wasn’t getting any reply from the external device.
I double checked all the settings: baud rate, stop bits, no flow control,
etc. Still no reply. Downloaded some Port Sniffer software to see what
was going on. Port Sniffer was able to communicate with the device, but
C# program still would not. I took a snapshot of what was being
sent by the C# program and compared that to what was being sent by the
Port Sniffer. Discovered C# was using Xon/Xoff flow control even though I
specified "none". Switched to using DTR flow control (which the device
ignored) and it started working fine.
Obfuscator
We had to obfuscate the final executable so I spent a couple days researching and testing
over a dozen different obfusactor programs. I finally settled on a good
one which didn’t cost much. I recommend Obfusasm at http://www.devextras.com/
which did an excellent job.
Feedback Control Algorithm
I majored in Signals and Systems and my master’s thesis was on feedback
control systems. My father’s
PhD dissertation
was on feedback control
systems. My father was a control systems engineer, and he wrote:
A Control Systems Engineer Looks At Controlling Type I Diabetes (.pdf file).
I did this as a tribute to my
father, who was a type 1 diabetic for 53 years.
CRC Checksums
CRC Checksums are used when transferring data over noisy channels. CRC Checksums detect
all single and double bit errors, all errors involving an odd number of bits,
all burst errors of length 16 or less, 99.997% of 17-bit error bursts, and
99.998% of 18-bit and longer bursts.
See
Peterson, W.W., and D.T. Brown.: "Cyclic Codes for Error Detection".
Proc. IRE, vol. 49, pp. 228-235, Jan. 1961.
1 Idea and photo from http://www.instructables.com/id/Make-a-battery-substitute-power-connector/