コード例 #1
0
ファイル: InsulinModel1.cs プロジェクト: winemug/NightFlux
        public IEnumerable <(DateTimeOffset From, DateTimeOffset To, double Value)> Run(PodSession podSession, TimeSpan prolongation)
        {
            FastCompartment           = 0d;
            SlowCompartment           = 0d;
            Circulation               = 0d;
            DisassociationCompartment = 0d;

            var list = podSession.GetDeliveries();
            var t0   = list[0].Time;
            var d0   = list[0].Delivered;

            foreach (var delivery in podSession.GetDeliveries().Skip(1))
            {
                if (t0 != delivery.Time)
                {
                    foreach (var frame in ExecuteFrames(t0, delivery.Time, d0))
                    {
                        yield return(frame);
                    }
                    t0 = delivery.Time;
                    d0 = delivery.Delivered - d0;
                }
            }
        }
コード例 #2
0
        public async Task ImportOmniCorePodSession(PodSession podSession)
        {
            var transaction = await Connection.BeginTransactionAsync();

            var id = await Connection.ExecuteScalarAsync <int?>(
                "SELECT id FROM oc_site WHERE name = @A",
                new
            {
                A = podSession.Name,
            }, transaction);

            if (id != null)
            {
                await Connection.ExecuteAsync("DELETE FROM oc_infusion WHERE site_id = @A", new { A = id.Value }, transaction);

                await Connection.ExecuteAsync("DELETE FROM oc_site WHERE id = @A", new { A = id.Value }, transaction);
            }

            await Connection.ExecuteAsync("INSERT INTO oc_site(name,hormone,units,start,stop) VALUES(@A,@B,@C,@D,@E)",
                                          new
            {
                A = podSession.Name,
                B = (int)podSession.Hormone,
                C = podSession.Dilution,
                D = podSession.Activated.ToUnixTimeMilliseconds(),
                E = podSession.Deactivated.ToUnixTimeMilliseconds()
            }, transaction);

            id = await Connection.ExecuteScalarAsync <int>("SELECT last_insert_rowid();");

            await transaction.CommitAsync();

            foreach (var delivery in podSession.GetDeliveries())
            {
                await ImportEntity(new InfusionDelivery()
                {
                    Delivered = delivery.Delivered, Time = delivery.Time, SiteId = id.Value
                });
            }
        }