public static int CalcC(CSVTableParser matrixC, Estimates data)
        {
            using (var l = new Logger("CalcC")) {
                if (
                    (data.CurrentC == 0) &&
                    (data.TargetC == 0)
                    )
                    return 0;
                foreach (var row in matrixC.Rows) {
                    if ((double) (row.Cell["CMin"]) <= data.CurrentC && data.CurrentC < (double) (row.Cell["CMax"])) {
                        l.msg("C item found --- CMin {0}; CMax {1}", row.Cell["CMin"], row.Cell["CMax"]);

                        var differenceC = data.TargetC - data.CurrentC;
                        if (differenceC < 0) {
                            differenceC = Math.Abs(differenceC);
                            var oxygenOnCarbon = (int) (row.Cell["OxygenOnCarbon"]);
                            const double carbonConsumption = 0.01;
                            double correctionOxy = (oxygenOnCarbon/carbonConsumption)*differenceC;
                            l.msg("Correction Oxygen C = {0}", correctionOxy);
                            return (int) Math.Round(correctionOxy);
                        }
                        else
                            return 0;
                    }
                }
            }
            return 0;
        }
        public static int CalcT(CSVTableParser matrixT, Estimates data)
        {
            if (matrixT.Rows == null) {
                InstantLogger.err("matrixT.Rows == null");
                return 0;
            }
            using (var l = new Logger("CalcT")) {
                if ((data.CurrentT == 0)
                    || (data.TargetT == 0)
                    || (data.TargetTuMin == 0)
                    || (data.TargetTuMax == 0)
                    || (data.CurrentC == 0)
                    )
                    return 0;
                foreach (var row in matrixT.Rows) {
                    if ((double) (row.Cell["CMin"]) <= data.CurrentC && data.CurrentC < (double) (row.Cell["CMax"])) {
                        l.msg("T item found --- CMin {0}; CMax {1}", row.Cell["CMin"], row.Cell["CMax"]);

                        //var differenceT = data.TargetT - data.CurrentT;
                        double differenceT = (double)(((data.TargetT + (data.TargetT - data.TargetTuMin)) * 0.5) - data.CurrentT); // до середины между целевым и минимальным целевым
                        if (differenceT > 0)
                        {
                            var oxygenOnHeating = (int)(row.Cell["OxygenOnHeating"]);
                            var heating = (int)(row.Cell["Heating"]);
                            double correctionOxy = (double)((((double)oxygenOnHeating) / ((double)heating)) * differenceT);
                            l.msg("Correction Oxygen T = {0}", correctionOxy);
                            return (int)Math.Round(correctionOxy);
                        }
                        else {
                            l.msg("recomend end blow? code:-3");
                            return -3; // рекомендуется закончить продувку

                        }
                    }
                }
            }
            return 0;
        }
 public static void Reset()
 {
     Data = new Estimates();
     IsFiered = false;
     //SidB = Guid.NewGuid();
     SidB = new Guid();
     AutomaticStop = false;
     CurrentOxygen = 0;
     CorrectionOxyT = 0;
     CorrectionOxyC = 0;
     CorrectionDoloms = 0.0;
     EndBlowingOxygen = int.MaxValue;
     BlowStopSignalPushed = false;
     StopBlowFlagRelease();
     //EndMeteringAccept();
     IsUncorrectMetering = false;
     IsActualOxygen = false;
     IsAfterMetering = false;
     MeteringOxygen = 0;
     StartedCRecalc = false;
     StopedCRecalc = true;
     #if IS_DBFLEX
     ReqScheme(CurrentScheme);
     #endif
 }
        public static double CalcNewCarbon(CSVTableParser matrixC, Estimates data, int OxyAfterMetering)
        {
            using (var l = new Logger("CalcC")) {
                if (data.CurrentC == 0) return 0;

                foreach (var row in matrixC.Rows) {
                    if ((double) (row.Cell["CMin"]) <= data.CurrentC && data.CurrentC < (double) (row.Cell["CMax"])) {
                        l.msg("C item found --- CMin {0}; CMax {1}", row.Cell["CMin"], row.Cell["CMax"]);

                        var oxygenOnCarbon = (int) (row.Cell["OxygenOnCarbon"]);
                        return data.CurrentC - ((OxyAfterMetering/oxygenOnCarbon)*0.01);
                    }
                }
            }
            return 0;
        }