Exemple #1
0
        private String breathingCurve_GetCommand()
        {
            //obtains the XML command from UI config.
            breathingCurve_Calculate();
            VentilatorConfig conf = new VentilatorConfig();

            conf.tA = Convert.ToInt32(numTA.Value);
            conf.tB = Convert.ToInt32(numTB.Value);
            conf.tC = Convert.ToInt32(numTC.Value);
            conf.tD = Convert.ToInt32(numTD.Value);
            conf.tE = Convert.ToInt32(numTE.Value);
            conf.tF = Convert.ToInt32(numTF.Value);
            conf.LA = Convert.ToInt32(numLA.Value);
            conf.LB = Convert.ToInt32(numLB.Value);
            conf.LC = Convert.ToInt32(numLC.Value);
            conf.LD = Convert.ToInt32(numLD.Value);
            conf.md = selectedMode;
            conf.sp = Convert.ToInt32(numSP.Value);

            String printableASCII = breathingCurve_GetPrintableASCII(conf);
            String str            = "";

            str = "<FromPC DB br='" + printableASCII + "' tA='" + conf.tA.ToString() + "' tB='" + conf.tB.ToString() + "' tC='" + conf.tC.ToString() + "' tD='" + conf.tD.ToString() + "' tE='" + conf.tE.ToString() + "' tF='" + conf.tF.ToString() + "' LA='" + conf.LA.ToString() + "' LB='" + conf.LB.ToString() + "' LC='" + conf.LC.ToString() + "' LD='" + conf.LD.ToString() + "' sp='" + conf.sp.ToString() + "' md='" + selectedMode.ToString() + "' go='go'/>\r\n";
            return(str);
        }
Exemple #2
0
        private String breathingCurve_GetPrintableASCII(VentilatorConfig conf)
        {
            String str = "";
            double min = (-1) * conf.LA;
            double max = conf.LB;

            for (int t = 0; t < 100; t++)
            {
                double val = ((127 - 32) / Math.Abs(max - min)) * breathingCurve[t] + 32;
                val = Math.Floor(val);
                scaledBreathingCurve[t] = Convert.ToInt32(val);
                scaledBreathingCurve[t] = sat(32, 127, scaledBreathingCurve[t]);
                str = str + Convert.ToChar(scaledBreathingCurve[t]);
            }
            return(str);
        }
Exemple #3
0
        private void breathingCurve_Calculate()
        {
            //recalculate the global breathingCurve array.
            var conf = new VentilatorConfig();

            for (int t = 0; t < 100; t++)
            {
                double val = 0 * RectFn(0, conf.tA, t) +
                             (-1) * conf.LA * RectFn(conf.tA, conf.tB, t) * Math.Sin(Math.PI * (t - conf.tA) / (conf.tB - conf.tA)) +
                             conf.LB * RectFn(conf.tB, conf.tC, t) * (1 - Math.Exp(-(t - conf.tB))) +
                             conf.LC * RectFn(conf.tC, conf.tD, t) +
                             conf.LC * RectFn(conf.tD, conf.tE, t) * (Math.Exp(-(t - conf.tD))) +
                             conf.LD;
                val = Math.Floor(val);
                breathingCurve[t] = Convert.ToInt32(val);
            }
        }