Esempio n. 1
0
        public async Task <SerializerSession> GetPumpSessionAsync(SerializerSession session, CancellationToken cancelToken)
        {
            this.Session   = session;
            _configuration = session.MinimedConfiguration();

            List <Func <Task> > tasks = new List <Func <Task> >();

            tasks.Add(() => StartPumpTimeAsync(cancelToken));
            tasks.Add(() => StartCollectPumpDataAsync(cancelToken));
            tasks.Add(() => StartDeviceChar(cancelToken));
            //tasks.Add(() => StartGetSetting(AstmSendMessageType.DEVICE_STRING_REQUEST, cancelToken));
            tasks.Add(() => StartGetSetting(AstmSendMessageType.READ_BOLUS_WIZARD_BG_TARGETS_REQUEST, cancelToken));
            tasks.Add(() => StartGetSetting(AstmSendMessageType.READ_BOLUS_WIZARD_CARB_RATIOS_REQUEST, cancelToken));
            tasks.Add(() => StartGetSetting(AstmSendMessageType.READ_BOLUS_WIZARD_SENSITIVITY_FACTORS_REQUEST, cancelToken));
            tasks.Add(() => StartBasalPatternAsync(cancelToken));


            if (_configuration.IncludeHistory)
            {
                tasks.Add(() => StartReadHistory(cancelToken));
            }

            if (_configuration.IncludePumpSettings)
            {
                //tasks.Add(() => StartGetSetting(AstmSendMessageType.Read_Preset_Boluses_Request, cancelToken));
                //tasks.Add(() => StartGetSetting(AstmSendMessageType.Read_Preset_Temp_Basals_Request, cancelToken));
                //tasks.Add(() => StartGetSetting(AstmSendMessageType.Read_Timed_Notifications_Request, cancelToken));
                //tasks.Add(() => StartGetSetting(AstmSendMessageType.Read_Low_Glucose_Sensor_Settings_Request, cancelToken));
                //tasks.Add(() => StartGetSetting(AstmSendMessageType.Read_High_Glucose_Sensor_Settings_Request, cancelToken));
            }



            return(await CallPumpWithActions(tasks, cancelToken));
        }
Esempio n. 2
0
        public async Task StartCommunication(IDevice device, SerializerSession session, CancellationToken cancelToken)
        {
            int periode = 0;

            _cancelToken = cancelToken;
            Session      = session;
            _device      = device;

            if (TimeoutSeconds == 0)
            {
                TimeoutSeconds = session.MinimedConfiguration().TimeoutSeconds;
                //Logger.LogInformation($"Timeout in Seconds: {TimeoutSeconds}");
            }


            if (_device.IsConnected)
            {
                var lists = this.GetRequestBytes();

                StartTimer();
                _device.DoneReceived = false;
                Log(lists);
                _device.SendBytes(lists);

                //foreach (var item in lists)
                //{
                //    var newarr = item.ToArray<byte>();
                //    Log(newarr);
                //    _device.SendBytes(newarr);

                //}

                if (this.ExpectedResponses.Count > 0)
                {
                    //wait for all responses or timeout for whole block.
                    while (this._running && _device.IsConnected)
                    {
                        periode += delay;
                        Task.Delay(delay).Wait();
                        if ((TimeoutSeconds * 1000) <= periode)
                        {
                            CommunicationError("Error: timeout");
                            return;
                        }
                    }
                }
                StopTimer();
            }
        }