Skip to content

Commit f6385dd

Browse files
committed
Updates to fix a few bugs in G-Code generation. Fixed graphic bug in execution screen
1 parent 65b4a4c commit f6385dd

File tree

3 files changed

+35
-20
lines changed

3 files changed

+35
-20
lines changed

PrusaMK4S/Handlers/GCodeHandler.cs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,8 +374,10 @@ public async Task<byte[]> CreatePrintIteration(int iteration)
374374
if(AdjustedFileData is null)
375375
await Init();
376376

377-
if(iteration == 1)
378-
return AdjustedFileData!;
377+
if(iteration == 1 && AdjustedFileData is not null)
378+
{
379+
return AdjustedFileData;
380+
}
379381

380382
else
381383
{
@@ -531,6 +533,7 @@ private async Task<byte[]> GenerateFirstPrintData()
531533

532534
var startup_gcode = stringData.Take(ModificationStartIndex).ToList();
533535
var shifted_startup = ShiftInitialPurgeLine(startup_gcode);
536+
shifted_startup = UpdateBedLeveling(shifted_startup, 0);
534537

535538
var modifiedData = shifted_startup
536539
.Concat(stringData
@@ -560,7 +563,10 @@ private List<string> ShiftInitialPurgeLine(List<string> gcode)
560563
}
561564

562565
else if(line.StartsWith("G") && shouldEdit)
563-
updatedGcode.Add(ApplyPurgeXOffset(line.Split(), 200));
566+
{
567+
var updatedLine = ApplyPurgeXOffset(line.Split(), 200);
568+
updatedGcode.Add(updatedLine);
569+
}
564570

565571
else
566572
updatedGcode.Add(line);

PrusaMK4S/PrusaMK4s.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,20 @@ public async Task<MK4SRequestResponse> MoveToLastPrint(int z, int dwell, int xOf
172172
var calculated_y = LatestGCodeHandler.GetPrintBedHeight() - (Math.Abs(LatestGCodeHandler.LatestYShift) + (itemHeight / 2)) + yOffset;
173173
var calculated_x = LatestGCodeHandler.LatestXShift + (itemWidth / 2) + xOffset;
174174

175-
var moveResponse = await MovePrinter((int)calculated_x, (int)calculated_y, z, dwell);
176-
177-
//This delay allows for the print heads potential travel time
178-
await Task.Delay(TimeSpan.FromSeconds(3));
175+
try
176+
{
177+
var moveResponse = await MovePrinter((int)calculated_x, (int)calculated_y, z, dwell);
179178

180-
return moveResponse;
179+
//This delay allows for the print heads potential travel time
180+
await Task.Delay(TimeSpan.FromSeconds(3));
181+
182+
return moveResponse;
183+
}
184+
185+
catch(Exception e)
186+
{
187+
return new MK4SRequestResponse { Success = false, ErrorString = $"Move Printer Method Failed! {e.Message}" };
188+
}
181189
}
182190

183191
catch(Exception ex)

UI/Pages/Automation/Execution.razor

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,19 @@
199199
<RadzenSwitch id="smart_calculate_switch" @bind-Value="@ViewModel!.SmartPrintCalculation" Change="@ViewModel!.SetSmartExperimentsToRun"/>
200200
</div>
201201

202+
@if (ViewModel!.CurrentStopCondition is not null)
203+
{
204+
<div class="border border-1 rounded-2 p-2">
205+
<div class="d-flex flex-column">
206+
<div>
207+
Condition: @GenerateStopConditionDisplayName()
208+
</div>
209+
<div>@ViewModel!.CurrentStopCondition.Description</div>
210+
<div>Campaign will re-plan every @ViewModel!.DesiredReplanRate.ToString() experiment(s)</div>
211+
</div>
212+
</div>
213+
}
214+
202215
@if(!ViewModel!.SmartPrintCalculation)
203216
{
204217
<div class="d-flex flex-column">
@@ -225,18 +238,6 @@
225238
<input type="number" class="form-control" @bind="ViewModel!.ExperimentsToRun" disabled/>
226239
</div>
227240
}
228-
@if (ViewModel!.CurrentStopCondition is not null)
229-
{
230-
<div class="border border-1 rounded-2 p-2">
231-
<div class="d-flex flex-column">
232-
<div>
233-
Condition: @GenerateStopConditionDisplayName()
234-
</div>
235-
<div>@ViewModel!.CurrentStopCondition.Description</div>
236-
<div>Campaign will re-plan every @ViewModel!.DesiredReplanRate.ToString() experiment(s)</div>
237-
</div>
238-
</div>
239-
}
240241

241242
<div class="d-flex flex-column padded-item">
242243
<h6>Re-Planning Rate</h6>

0 commit comments

Comments
 (0)