Stop waiting for temperatures to be reached, optionally just in the file(s) being printed
| 1202 | |
| 1203 | // Stop waiting for temperatures to be reached, optionally just in the file(s) being printed |
| 1204 | void GCodes::CancelWaitForTemperatures(bool onlyInPrintFiles) noexcept |
| 1205 | { |
| 1206 | for (GCodeBuffer *_ecv_null gb : gcodeSources) |
| 1207 | { |
| 1208 | if (gb != nullptr && gb->IsWaitingForTemperatures() && (!onlyInPrintFiles || (gb->IsFileChannel() && (!gb->IsDoingFileMacro() || gb->LatestMachineState().CanRestartMacro())))) |
| 1209 | { |
| 1210 | gb->CancelWaitForTemperatures(); |
| 1211 | } |
| 1212 | } |
| 1213 | } |
| 1214 | |
| 1215 | #if HAS_VOLTAGE_MONITOR || HAS_STALL_DETECT |
| 1216 | |
| 1217 | // Do an emergency pause following loss of power or a motor stall returning true if successful, false if needs to be retried |
| 1218 | bool GCodes::DoEmergencyPause() noexcept |
| 1219 | { |
| 1220 | if (!AutoPauseGCode()->IsCompletelyIdle()) |
| 1221 | { |
| 1222 | return false; // we can't pause if the auto pause thread is busy already |
| 1223 | } |
| 1224 | |
| 1225 | // Save the resume info, stop movement immediately and run the low voltage pause script to lift the nozzle etc. |
| 1226 | GrabMovement(*AutoPauseGCode()); |
| 1227 | |
| 1228 | for (MovementState& ms : moveStates) |
| 1229 | { |
| 1230 | // When we use RTOS there is a possible race condition in the following, because we might try to pause when a waiting move has just been added |
| 1231 | // but before the gcode buffer has been re-initialised ready for the next command. So start a critical section. |
| 1232 | TaskCriticalSectionLocker lock; |
| 1233 | |
| 1234 | const bool movesSkipped = reprap.GetMove().LowPowerOrStallPause(ms); |
| 1235 | if (movesSkipped) |
| 1236 | { |
| 1237 | // The LowPowerOrStallPause call has filled in the restore point with machine coordinates |
| 1238 | ToolOffsetInverseTransform(ms, ms.GetPauseRestorePoint().moveCoords, ms.currentUserPosition); // transform the returned coordinates to user coordinates |
| 1239 | ms.ClearMove(); |
| 1240 | } |
| 1241 | else if (ms.segmentsLeft != 0 && ms.filePos != noFilePosition) |
| 1242 | { |
| 1243 | // We were not able to skip any moves, however we can skip the remaining segments of this current move |
| 1244 | ToolOffsetInverseTransform(ms, ms.initialCoords, ms.currentUserPosition); |
| 1245 | ms.GetPauseRestorePoint().originalFeedRate = ms.originalFeedRate; |
| 1246 | ms.GetPauseRestorePoint().virtualExtruderPosition = ms.moveStartVirtualExtruderPosition; |
| 1247 | ms.GetPauseRestorePoint().filePos = ms.filePos; |
| 1248 | ms.GetPauseRestorePoint().proportionDone = ms.GetProportionDone(); |
| 1249 | ms.GetPauseRestorePoint().initialUserC0 = ms.initialUserC0; |
| 1250 | ms.GetPauseRestorePoint().initialUserC1 = ms.initialUserC1; |
| 1251 | #if SUPPORT_LASER || SUPPORT_IOBITS |
| 1252 | ms.GetPauseRestorePoint().laserPwmOrIoBits = ms.laserPwmOrIoBits; |
| 1253 | #endif |
| 1254 | ms.ClearMove(); |
| 1255 | } |
| 1256 | else |
| 1257 | { |
| 1258 | // We were not able to skip any moves, and if there is a move waiting then we can't skip that one either |
| 1259 | ms.GetPauseRestorePoint().originalFeedRate = FileGCode()->LatestMachineState().feedRate; |
| 1260 | ms.GetPauseRestorePoint().virtualExtruderPosition = ms.latestVirtualExtruderPosition; |
| 1261 |
no test coverage detected