public void GetProgramCommentInfo(LaserSimulater laser, string ncPath, ProgramDetailDto info, bool bmp, string bmpPath, int bmpWidth, int bmpHeight) { string str = ""; GetProgramString(ncPath, ref str); GetInfo(info, str); List <PreProgramBlock> preBlocks = new List <PreProgramBlock>(); ProgramBlockPreDecompile(str, info, preBlocks); List <ProgramBlock> pBlocks = new List <ProgramBlock>(); ProgramBlockDecompile(preBlocks, pBlocks); List <DrawBlock> dBlocks = new List <DrawBlock>(); ProgramInfoAnalysis(laser, info, pBlocks, dBlocks); if (bmp == true) { var thumbnail = new LaserProgramThumbnai(bmpWidth, bmpHeight, Color.FromArgb(0xFF, 0x00, 0xD8, 0xFF), (float)0.05, Color.Yellow, (float)0.05, Color.FromArgb(0xFF, 0x28, 0x26, 0x20)); thumbnail.DrawXYThumbnai(dBlocks, info.Max_X + 20, info.Max_Y + 20, bmpPath); } }
private void ProgramInfoAnalysis(LaserSimulater laser, ProgramDetailDto info, List <ProgramBlock> pBlocks, List <DrawBlock> dBlocks) { int total_pericing_count = 0; double total_cutting_length = 0; double total_cycletime = 0; double?max_x = null, max_y = null, min_x = null, min_y = null; foreach (var block in pBlocks) { var tempInfo = block.Info; dBlocks.Add(tempInfo.DrawBlockInfo); laser.FeedSpeed = (int)block.F_Adr.Value; total_cycletime += laser.GetFeedTime(tempInfo.CuttingLength); total_cutting_length += tempInfo.CuttingLength; total_pericing_count += tempInfo.PiercingCount; total_cycletime += tempInfo.DirectTime / 1000.0; if (tempInfo.Max_X.HasValue) { max_x = max_x.HasValue ? Math.Max(max_x.Value, tempInfo.Max_X.Value) : tempInfo.Max_X.Value; } if (tempInfo.Max_Y.HasValue) { max_y = max_y.HasValue ? Math.Max(max_y.Value, tempInfo.Max_Y.Value) : tempInfo.Max_Y.Value; } if (tempInfo.Min_X.HasValue) { min_x = min_x.HasValue ? Math.Min(min_x.Value, tempInfo.Min_X.Value) : tempInfo.Min_X.Value; } if (tempInfo.Min_Y.HasValue) { min_y = min_y.HasValue ? Math.Min(min_y.Value, tempInfo.Min_Y.Value) : tempInfo.Min_Y.Value; } } info.CuttingTime = total_cycletime; info.CuttingDistance = total_cutting_length; info.PiercingCount = total_pericing_count; info.UsedPlateSize = $"X最小:{min_x.Value},X最大:{max_x.Value},Y最小:{min_y.Value},Y最大:{max_y.Value}"; info.Max_X = max_x.Value; info.Max_Y = max_y.Value; info.Min_X = min_x.Value; info.Min_Y = min_y.Value; info.UsedPlateSize_W = max_x.Value; info.UsedPlateSize_H = max_y.Value; }
public ProgramResolveResultDto ProgramResolve(ProgramResovleDto resovleDto) { LaserProgramHelper helper = new LaserProgramHelper(); LaserSimulater laser = new LaserSimulater(48, 1000, 96, 12000); ProgramDetailDto info = new ProgramDetailDto(); helper.GetProgramCommentInfo(laser, resovleDto.FilePath, info, false, "", 0, 0); return(new ProgramResolveResultDto() { ConnectId = resovleDto.ConnectId, Id = "ProgramResolve", Data = info, ImagePath = "", BmpName = "", }); }