예제 #1
0
        private void Change_Fuel(object sender, SelectionChangedEventArgs e)
        {
            object selectedFuelName = cmbFuel.SelectedValue;
            Fuel   selectedFuel     = lFuels.Find(item => item.getName() == (string)selectedFuelName);

            txtFuelC.Text = selectedFuel.getC().ToString();
            txtFuelP.Text = selectedFuel.getP().ToString();
            txtFuelV.Text = selectedFuel.getV().ToString();

            object selectedCoolantName = cmbCoolant.SelectedValue;

            if (selectedCoolantName != null)
            {
                Coolant selectedCoolant = lCoolants.Find(item => item.getName() == (string)selectedCoolantName);
                txtCoolantA.Text = selectedCoolant.getA().ToString();
                // txtCoolantF.Text = selectedCoolant.getF().ToString();
                txtCoolantT.Text = selectedCoolant.getT().ToString();
            }

            //Holding a*Ft
            if ((string)selectedCoolantName == "Вода" && (string)selectedFuelName == "Диоксид урана")
            {
                txtCoolantA.Text = "6.014";
            }
            else
            {
                txtCoolantA.Text = "0";
            }
        }
예제 #2
0
 public Reactor(string name, string W, Fuel fuel, Coolant coolant, float alphaFt, float t0)
 {
     this.name    = name;
     this.W       = W;
     this.fuel    = fuel;
     this.coolant = coolant;
     this.alphaFt = alphaFt;
     this.t0      = t0;
 }
예제 #3
0
        private void Change_Coolant(object sender, SelectionChangedEventArgs e)
        {
            object  selectedCoolantName = cmbCoolant.SelectedValue;
            Coolant selectedCoolant     = lCoolants.Find(item => item.getName() == (string)selectedCoolantName);

            txtCoolantС.Text = selectedCoolant.getC().ToString();
            txtCoolantP.Text = selectedCoolant.getP().ToString();
            txtCoolantV.Text = selectedCoolant.getV().ToString();

            object selectedFuelName = cmbFuel.SelectedValue;

            if (selectedFuelName != null)
            {
                txtCoolantA.Text = selectedCoolant.getA().ToString();
                txtCoolantF.Text = selectedCoolant.getF().ToString();
                txtCoolantT.Text = selectedCoolant.getT().ToString();
            }
        }
예제 #4
0
        public MainWindow()
        {
            InitializeComponent();

            lFuels = new List <Fuel>();
            Fuel dioxUr = new Fuel("Диоксид урана", 318, 10960, 7.026f);

            lFuels.Add(dioxUr);
            lFuels.Add(new Fuel("Металлический уран", 113, 18700, 0));
            lFuels.Add(new Fuel("Торий", 200, 11780, 0));

            lCoolants = new List <Coolant>();
            Coolant water   = new Coolant("Вода", 5670, 620, 18, 1240, 4850, 0.68f);
            Coolant natrium = new Coolant("Натрий", 1220, 780, 1.11f, 0, 0, 0);

            lCoolants.Add(water);
            lCoolants.Add(new Coolant("Тяжёлая вода", 4208, 682, 0, 0, 0, 0));
            lCoolants.Add(new Coolant("Свинец", 127.5f, 7800, 0, 0, 0, 0));
            lCoolants.Add(natrium);

            reactors = new List <Reactor>();

            reactors.Add(new Reactor("РБМК-1000", "3200", dioxUr, water, 6.014f, 0.68f));
            Fuel dioxUr1 = new Fuel("Диоксид урана", 318, 10960, 2.46f);

            reactors.Add(new Reactor("БН-600", "1500", dioxUr1, natrium, 1.049f, 0.11f));

            foreach (Fuel itemFuels in lFuels)
            {
                cmbFuel.Items.Add(itemFuels.getName());
            }

            foreach (Coolant itemCoolants in lCoolants)
            {
                cmbCoolant.Items.Add(itemCoolants.getName());
            }

            foreach (Reactor reactor in reactors)
            {
                cmbReactor.Items.Add(reactor.GetName());
            }
        }
예제 #5
0
        //private-----------------------------------------------------------------
        private MetaData parseMastercamAPT(Queue <string> lines)
        {
            string   line;
            Indirv   current_indirv   = new Indirv();
            Point    current_position = new Point(0.0, 0.0, 0.0);
            int      current_tool     = -1;
            MetaData metadata         = new MetaData();

            while (!lines.Peek().Contains("FINI"))//data parsing
            {
                if (lines.Peek().Contains("$$Machine Group-"))
                {
                    MachineGroup mg = new MachineGroup();
                    mg.ID = Convert.ToInt32(lines.Peek().Substring("$$Machine Group-".Length));

                    while (!lines.Peek().Contains("FINI") || (lines.Peek().Contains("$$Machine Group-") && (Convert.ToInt32(lines.Peek().Substring("$$Machine Group-".Length)) == mg.ID)))
                    {
                        lines.Dequeue();
                        ToolpathGroup tpg = new ToolpathGroup();
                        tpg.ID++;

                        while (!lines.Peek().Contains("$$Machine Group-") && !lines.Peek().Contains("FINI"))
                        {
                            line = lines.Dequeue();
                            if (line.Contains("PARTNO/"))
                            {
                                metadata.PartNo = line.Substring("PARTNO/".Length);
                                continue;
                            }

                            if (line.Contains("UNITS/"))
                            {
                                metadata.Units = line.Substring("UNITS/".Length);
                                metadata.Units = metadata.Units.Replace(" ", string.Empty);
                                continue;
                            }

                            if (line.Contains("MULTAX/"))
                            {
                                metadata.Multax = line.Substring("MULTAX/".Length);
                                metadata.Multax = metadata.Multax.Replace(" ", string.Empty);
                                continue;
                            }

                            //if (line.Contains("MACHIN/"))
                            //{
                            //    string[] substrings = Regex.Split(line.Substring("MACHIN/".Length), ",");
                            //    metadata.Machin = substrings[0].Replace(" ", string.Empty);
                            //    continue;
                            //}

                            if (line.Contains("CUTTER/"))
                            {
                                Cutter   tool       = new Cutter();
                                string[] substrings = Regex.Split(line.Substring("CUTTER/".Length), ",");
                                tool.Diameter = Convert.ToDouble(substrings[0].Replace(" ", string.Empty));
                                //tpg.tpgtool.length = Convert.ToDouble(substrings[1].Replace(" ", string.Empty));

                                line      = lines.Dequeue();
                                tool.Name = line.Substring("TPRINT/".Length);

                                line = lines.Dequeue();
                                string[] substrings2 = Regex.Split(line.Substring("LOAD/".Length), ",");
                                current_tool = tpg.Tool = tool.ID = Convert.ToInt32(substrings2[1].Replace(" ", string.Empty).Replace(".", string.Empty));

                                if (!metadata.CutterTools.ContainsKey(tool.ID))
                                {
                                    metadata.CutterTools.Add(tool.ID, tool);
                                }

                                continue;
                            }

                            if (line.Contains("RAPID"))
                            {
                                tpg.MachiningData.Add(new Rapid());
                                continue;
                            }

                            if (line.Contains("GOTO/"))
                            {
                                GoTo gotoxyz = new GoTo();
                                gotoxyz.parseGoto(line);
                                tpg.MachiningData.Add(gotoxyz);
                                current_position = gotoxyz.point;
                                continue;
                            }

                            if (line.Contains("INDIRV/"))
                            {
                                Indirv indirv = new Indirv();
                                indirv.parseIndirv(line);
                                tpg.MachiningData.Add(indirv);
                                current_indirv = indirv;
                                continue;
                            }

                            if (line.Contains("CIRCLE/"))
                            {
                                Circle circle = new Circle();
                                circle.parseCircle(current_indirv, current_position, line, lines.Dequeue(), lines.Dequeue());
                                tpg.MachiningData.Add(circle);
                                current_position = circle.endpoint;
                                continue;
                            }

                            if (line.Contains("FEDRAT/"))
                            {
                                Feedrate fedrat = new Feedrate();
                                fedrat.parseFedrat(line);
                                tpg.MachiningData.Add(fedrat);
                                continue;
                            }

                            if (line.Contains("SPINDL/"))
                            {
                                SpindleSpeed spindle = new SpindleSpeed();
                                spindle.parseSpindleSpeed(line);
                                tpg.MachiningData.Add(spindle);
                                continue;
                            }

                            if (line.Contains("COOLNT/"))
                            {
                                Coolant coolant = new Coolant();
                                coolant.parseCoolant(line);
                                tpg.MachiningData.Add(coolant);
                                continue;
                            }
                        }
                        if (tpg.Tool == -1)
                        {
                            tpg.Tool = current_tool;
                        }

                        mg.Operations.Add(tpg);     //add toolpath to list
                    }
                    metadata.MachineGroups.Add(mg); //add current machine group to list
                }
                else
                {
                    lines.Dequeue();
                }
            }
            lines.Dequeue();
            return(metadata);
        }
예제 #6
0
        public void WriteSTEPNC(MetaData metadata, string outname)
        {
            STEPNCLib.AptStepMaker stnc = new STEPNCLib.AptStepMaker();

            stnc.NewProjectWithCCandWP(metadata.PartNo, 1, "Main Workplan");//make new project

            if (metadata.Units == "IN" || metadata.Units == "Inches")
            {
                stnc.Inches();
            }
            else
            {
                stnc.Millimeters();
            }

            if (metadata.Multax == "ON")
            {
                stnc.MultaxOn();
            }

            Cutter[] tools = new Cutter[metadata.CutterTools.Keys.Count];
            metadata.CutterTools.Values.CopyTo(tools, 0);

            for (int i = 0; i < tools.Length; i++)//define all tools
            {
                stnc.DefineTool(tools[i].Diameter, tools[i].Diameter / 2, 10.0, 10.0, 1.0, 0.0, 45.0);
            }

            foreach (MachineGroup machineGroup in metadata.MachineGroups)
            {
                stnc.NestWorkplan("Machine Group-" + machineGroup.ID.ToString());

                foreach (ToolpathGroup toolpahtGroup in machineGroup.Operations)
                {
                    stnc.LoadTool(toolpahtGroup.Tool);//load tool associated with the current operation
                    stnc.Workingstep("WS-" + toolpahtGroup.ID.ToString());

                    foreach (MachiningData mchData in toolpahtGroup.MachiningData)
                    {
                        if (mchData is Rapid)
                        {
                            stnc.Rapid();
                        }
                        if (mchData is GoTo)
                        {
                            GoTo temp = mchData as GoTo;
                            stnc.GoToXYZ("point", temp.point.X, temp.point.Y, temp.point.Z);
                        }
                        if (mchData is Circle)
                        {
                            Circle temp = mchData as Circle;
                            stnc.ArcXYPlane("arc", temp.endpoint.X, temp.endpoint.Y, temp.endpoint.Z, temp.center.X, temp.center.Y, temp.center.Z, temp.radius, temp.direction);
                        }
                        if (mchData is Feedrate)
                        {
                            Feedrate temp = mchData as Feedrate;
                            stnc.Feedrate(temp.Fedrat);
                        }
                        if (mchData is SpindleSpeed)
                        {
                            SpindleSpeed temp = mchData as SpindleSpeed;
                            stnc.SpindleSpeed(temp.Spindlespeed);
                        }
                        if (mchData is Coolant)
                        {
                            Coolant temp = mchData as Coolant;
                            if (temp.activation)
                            {
                                stnc.CoolantOn();
                            }
                            else
                            {
                                stnc.CoolantOff();
                            }
                        }
                    }
                }
                stnc.EndWorkplan();
            }
            stnc.SaveAsP21(outname);
            return;
        }
예제 #7
0
        static void Main(string[] args)
        {

            var coords = new MapCoordinates();
            var mapBuilder = new ValueMapBuilder(coords);
            var targetAfr = new TargerAfrMap();
            var analyser = new AfrAnalyser(targetAfr);
            var display = new MapShower(coords);
            var logReader = new LogReader();
            var veTableCorrector = new VeTableCorrector(coords);
            //var widebandDelayCalculator = new WidebandDelayCalculator(coords);

            var veTableReader = new VeTableReader();

            var veTableBytes = File.ReadAllBytes(@"C:\Dev\repos\moje\DET3-FIT-analyzer\Samples\tables\VETable_07_10.bin");
            var veTable = veTableReader.ReadTable(veTableBytes);

            var logBytes = File.ReadAllBytes(@"C:\Dev\repos\moje\DET3-FIT-analyzer\Samples\log_2016710_2339.dlg");
            IEnumerable<LogLine> log = logReader.ReadLog(logBytes);
            var logBytes2 = File.ReadAllBytes(@"C:\Dev\repos\moje\DET3-FIT-analyzer\Samples\log_2016710_2340.dlg");
            IEnumerable<LogLine> log2 = logReader.ReadLog(logBytes);
            //var logBytes3 = File.ReadAllBytes(@"C:\Dev\repos\moje\DET3-FIT-analyzer\Samples\log_2016528_1814_CESTA_zpet.dlg");
            //IEnumerable<LogLine> log3 = logReader.ReadLog(logBytes);

            log = log.Concat(log2);

            var logArray = log.ToArray();
            var map = mapBuilder.BuildMap(logArray);

            //var widebandDelay = widebandDelayCalculator.CalculateAfrDelay(logArray);

            var analysed = analyser.GetCorrection(map);
            float[,] finalCorrection;
            var correctedVeTable = veTableCorrector.TuneVeTable(analysed, veTable, out finalCorrection);

            var maxBoost = log.OrderByDescending(l => l.Map.Value).First();
            Console.WriteLine("Max boost: {0}kpa @ {1}rpm", maxBoost.Map.Value, maxBoost.Rpm.Value);

            var maxClt = log.Max(l => l.Coolant.Value);
            Console.WriteLine("Max clt: {0}° C", maxClt);

            var maxIat = log.Max(l => l.Iat.Value);
            Console.WriteLine("Max IAT: {0}° C", maxIat);

            Console.WriteLine("Count");
            display.ShowAfrMap(analysed, ProjectedAfrCorrection.AfrCorrectionMethod.Count);

            //Console.WriteLine("AvgWidebandDelay");
            //display.ShowAfrTarget(widebandDelay);

            //Console.WriteLine("AvgKpa");
            //display.ShowAfrMap(analysed, ProjectedAfrCorrection.AfrCorrectionMethod.AvgKpa);

            //Console.WriteLine("AvgRpm");
            //display.ShowAfrMap(analysed, ProjectedAfrCorrection.AfrCorrectionMethod.AvgRpm);

            Console.WriteLine("AfrTarget");
            display.ShowAfrTarget(TargerAfrMap.AfrTargetMap);

            Console.WriteLine("AvgAfr");
            display.ShowAfrMap(analysed, ProjectedAfrCorrection.AfrCorrectionMethod.AvgAfr);

            Console.WriteLine("AfrDiffAbsolute");
            display.ShowAfrMap(analysed, ProjectedAfrCorrection.AfrCorrectionMethod.AfrDiffAbsolute);

            Console.WriteLine("AfrPercentDiff");
            display.ShowAfrMap(analysed, ProjectedAfrCorrection.AfrCorrectionMethod.AfrDiffPercent);

            Console.WriteLine("NboCorrection");
            display.ShowAfrMap(analysed, ProjectedAfrCorrection.AfrCorrectionMethod.NboCorrection);

            Console.WriteLine("VE table - delta");
            display.ShowVeMap(finalCorrection, ProjectedAfrCorrection.AfrCorrectionMethod.AfrDiffPercent);

            Console.WriteLine("VE table - original");
            display.ShowVeMap(veTable);

            //Console.WriteLine("VE table - corrected");
            //display.ShowVeMap(correctedVeTable);

            var bytes = veTableReader.GetBytes(correctedVeTable);

            Console.WriteLine("VE table - corrected, rounded");
            display.ShowVeMap(veTableReader.ReadTable(bytes));

            
            File.WriteAllBytes(@"C:\Dev\repos\moje\DET3-FIT-analyzer\Samples\tables\VETable_corrected.bin", bytes);

            return;

            var startBytes = logBytes.Take(12).ToArray();

            var timeInSeconds = 100;
            var howManyLines = (samplesPerSec * timeInSeconds);

            var firstLine = logBytes.Skip(12 + 40 * 10).Take(40).ToArray();
            var hex = BitConverter.ToString(firstLine);
            Console.WriteLine(hex);
            Console.WriteLine(Encoding.ASCII.GetChars(firstLine, 0, lineLength));

            var value = BitConverter.ToInt16(firstLine, 0);
            Console.WriteLine(value);

            var result = startBytes;

            var tps = new Tps { Value = 98 };
            var mapVal = new Map { Value = 180};

            //Temps are really rought
            var iat = new Iat { Value = 42f };
            var coolant = new Coolant { Value = 80f };
            var afrCorr = new AfrCorrection() { Value = 15 };

            var afrWideband = new AfrWideband { Value = 16f };
            var accEnr = new AccEnr() { Value = 0 };

            var rpm = BitConverter.GetBytes(1500);

            for (var line = 0; line < howManyLines; line += 1)
            {
                afrWideband.Value = 10 + line * 4 / 1000;
                rpm = BitConverter.GetBytes(line*4);
                try
                {
                    mapVal.Value = line/10;
                    
                }
                catch (Exception)
                {
                    mapVal.Value = 100;
                }
                
                firstLine[LogReader.Index["Tps"]] = tps.Bytes;
                firstLine[LogReader.Index["Map"]] = mapVal.Bytes;
                firstLine[LogReader.Index["Iat"]] = iat.Bytes;
                firstLine[LogReader.Index["Coolant"]] = coolant.Bytes;
                firstLine[LogReader.Index["AfrCorrection"]] = afrCorr.Bytes;
                firstLine[LogReader.Index["AfrWideband"]] = afrWideband.Bytes;
                firstLine[LogReader.Index["AccEnr"]] = accEnr.Bytes;

                //RPM
                firstLine[10] = rpm[0];
                firstLine[11] = rpm[1];


            //    var bits = new BitArray(8);
            //    bits[0] = true;
            //    bits[1] = true;
            //    bits[2] = true;
            //    bits[3] = true;
            //    bits[4] = true;
            //    bits[5] = true;
            //    bits[6] = true;
            //    bits[7] = true;

            //    byte[] newBytes = new byte[1];
            //    bits.CopyTo(newBytes, 0);

            //firstLine[1] = (byte)line;
            //    firstLine[4] = (byte)line;
            //    firstLine[5] = (byte)line;
            //    firstLine[6] = (byte)line;
            //    firstLine[7] = (byte)line;
            //    firstLine[5] = (byte)line;
            //    firstLine[12] = (byte)line;
            //    firstLine[13] = (byte)line;
            //    firstLine[15] = (byte)line;
            //    firstLine[20] = (byte)line;
                result = result.Concat(firstLine).ToArray();
            }

            File.WriteAllBytes(@"C:\Dev\repos\moje\DET3-FIT-analyzer\Samples\log_mine.dlg", result);
        }