diff options
author | David Crocker <dcrocker@eschertech.com> | 2021-12-11 18:58:29 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2021-12-11 18:58:29 +0300 |
commit | ed0e7929e05f96c431397495e332f190f72b5915 (patch) | |
tree | 029573d68262786249b66f7cbe7a5cbd9d571872 /src/FilamentMonitors | |
parent | 289d2f286a3fdf084c325d4db87f8075c154df6a (diff) |
Added most of the event handling code
Diffstat (limited to 'src/FilamentMonitors')
-rw-r--r-- | src/FilamentMonitors/FilamentMonitor.cpp | 63 | ||||
-rw-r--r-- | src/FilamentMonitors/FilamentMonitor.h | 1 |
2 files changed, 28 insertions, 36 deletions
diff --git a/src/FilamentMonitors/FilamentMonitor.cpp b/src/FilamentMonitors/FilamentMonitor.cpp index 95e68357..9cf6b686 100644 --- a/src/FilamentMonitors/FilamentMonitor.cpp +++ b/src/FilamentMonitors/FilamentMonitor.cpp @@ -12,6 +12,7 @@ #include "PulsedFilamentMonitor.h" #include <Platform/RepRap.h> #include <Platform/Platform.h> +#include <Platform/Event.h> #include <GCodes/GCodeBuffer/GCodeBuffer.h> #include <Movement/Move.h> #include <PrintMonitor/PrintMonitor.h> @@ -53,7 +54,7 @@ size_t FilamentMonitor::GetNumMonitorsToReport() noexcept FilamentMonitor::FilamentMonitor(unsigned int drv, unsigned int monitorType, DriverId did) noexcept : driveNumber(drv), type(monitorType), driverId(did), lastStatus(FilamentSensorStatus::noDataReceived) #if SUPPORT_CAN_EXPANSION - , hasRemote(false) + , lastRemoteStatus(FilamentSensorStatus::noDataReceived), hasRemote(false) #endif { } @@ -298,7 +299,6 @@ bool FilamentMonitor::IsValid(size_t extruderNumber) const noexcept fromIsr = false; locIsrMillis = 0; } - GCodes& gCodes = reprap.GetGCodes(); if (gCodes.IsReallyPrinting() && !gCodes.IsSimulating()) { @@ -309,28 +309,35 @@ bool FilamentMonitor::IsValid(size_t extruderNumber) const noexcept { fst = fs.Clear(); } - - if (fst != fs.lastStatus) - { + } +#if SUPPORT_CAN_EXPANSION + else + { + fst = fs.lastRemoteStatus; + } +#endif + if (fst != fs.lastStatus) + { #if SUPPORT_REMOTE_COMMANDS - statusChanged = true; + statusChanged = true; #endif - fs.lastStatus = fst; - if (fst != FilamentSensorStatus::ok + fs.lastStatus = fst; + if (fst != FilamentSensorStatus::ok #if SUPPORT_REMOTE_COMMANDS - && !CanInterface::InExpansionMode() + && !CanInterface::InExpansionMode() #endif - ) + ) + { + const size_t extruder = LogicalDriveToExtruder(fs.driveNumber); + if (reprap.Debug(moduleFilamentSensors)) + { + debugPrintf("Filament error: extruder %u reports %s\n", extruder, fst.ToString()); + } + else { - const size_t extruder = LogicalDriveToExtruder(fs.driveNumber); - if (reprap.Debug(moduleFilamentSensors)) - { - debugPrintf("Filament error: extruder %u reports %s\n", extruder, fst.ToString()); - } - else - { - gCodes.FilamentError(extruder, fst); - } + va_list dummy; + Event::AddEvent(EventType::filament_error, (uint16_t)fst.ToBaseType(), extruder, CanInterface::GetCanAddress(), "", dummy); +// gCodes.FilamentError(extruder, fst); } } } @@ -367,23 +374,7 @@ bool FilamentMonitor::IsValid(size_t extruderNumber) const noexcept FilamentMonitor& fs = *filamentSensors[extruder]; if (fs.driverId.boardAddress == src && fs.driverId.localDriver < msg.numMonitorsReported) { - const FilamentSensorStatus fstat(msg.data[fs.driverId.localDriver].status); - fs.lastStatus = fstat; - GCodes& gCodes = reprap.GetGCodes(); - if (gCodes.IsReallyPrinting() && !gCodes.IsSimulating()) - { - if (fstat != FilamentSensorStatus::ok) - { - if (reprap.Debug(moduleFilamentSensors)) - { - debugPrintf("Filament error: extruder %u reports %s\n", extruder, fstat.ToString()); - } - else - { - gCodes.FilamentError(extruder, fstat); - } - } - } + fs.lastRemoteStatus = FilamentSensorStatus(msg.data[fs.driverId.localDriver].status); } } } diff --git a/src/FilamentMonitors/FilamentMonitor.h b/src/FilamentMonitors/FilamentMonitor.h index af7d6bea..4f0cc406 100644 --- a/src/FilamentMonitors/FilamentMonitor.h +++ b/src/FilamentMonitors/FilamentMonitor.h @@ -164,6 +164,7 @@ private: bool haveIsrStepsCommanded; FilamentSensorStatus lastStatus; #if SUPPORT_CAN_EXPANSION + FilamentSensorStatus lastRemoteStatus; bool hasRemote; #endif }; |