private async Task <PodSession> ReadPodSession(string path) { using var sr = new StreamReader(path); var pds = new List <PointData>(); var year = 1; var month = 1; var day = 1; var utcOffset = 120; PodSession ps = null; string line = null; try { while (!sr.EndOfStream) { line = await sr.ReadLineAsync(); if (string.IsNullOrEmpty(line?.Trim())) { continue; } line = line.Replace(' ', '\t'); if (line.StartsWith('#')) { year = int.Parse(line[1..5]);
public static IEnumerable <(DateTimeOffset Date, double Value)> Run(PodSession podSession, TimeSpan settleDown) { var deliveries = podSession.GetRates(); var re = 0d; var t0 = deliveries[0].Time; var r0 = (double)deliveries[0].Value; foreach (var delivery in deliveries.Skip(1)) { var tx = t0; var t1 = delivery.Time; var r1 = (double)delivery.Value; double tp, rx; while (tx < t1) { tp = (tx - t0).TotalSeconds / settleDown.TotalSeconds; if (tp > 1) { tp = 1; } tp *= Math.Sin(Math.PI / 2 * tp); rx = (r0 - re) * tp + re; yield return(tx, rx); tx = tx.AddMinutes(1); } tp = (tx - t0).TotalSeconds / settleDown.TotalSeconds; if (tp > 1) { tp = 1; } tp *= Math.Sin(Math.PI / 2 * tp); re = (r0 - re) * tp + re; t0 = t1; r0 = r1; } }
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 }); } }
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; } } }