diff options
author | David Crocker <dcrocker@eschertech.com> | 2020-03-10 15:33:52 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2020-03-10 15:33:52 +0300 |
commit | 24f99490aa2be4fb14f7aeee454ede55e3dfb919 (patch) | |
tree | 4c1d18f73679fea7748e34d6d59acc70fd77fbcb | |
parent | 5de9c86f303c680a41f4e7692014226b47ccf181 (diff) |
Implemented seqs.directories, seqs.heat, seqs.inputs, seqs.job
-rw-r--r-- | src/GPIO/GpioPorts.cpp | 43 | ||||
-rw-r--r-- | src/Heating/Heat.cpp | 9 | ||||
-rw-r--r-- | src/Heating/Heater.cpp | 44 | ||||
-rw-r--r-- | src/Platform.cpp | 1 | ||||
-rw-r--r-- | src/PrintMonitor.cpp | 16 | ||||
-rw-r--r-- | src/RepRap.h | 4 |
6 files changed, 83 insertions, 34 deletions
diff --git a/src/GPIO/GpioPorts.cpp b/src/GPIO/GpioPorts.cpp index 7c9cafba..708ae893 100644 --- a/src/GPIO/GpioPorts.cpp +++ b/src/GPIO/GpioPorts.cpp @@ -85,12 +85,14 @@ GCodeResult GpInputPort::Configure(uint32_t gpinNumber, GCodeBuffer &gb, const S port.Release(); currentState = false; + GCodeResult rslt; + #if SUPPORT_CAN_EXPANSION const CanAddress newBoard = IoPort::RemoveBoardAddress(pinName.GetRef()); if (newBoard != CanId::MasterAddress) { handle.Set(RemoteInputHandle::typeGpIn, gpinNumber, 0); - const GCodeResult rslt = CanInterface::CreateHandle(newBoard, handle, pinName.c_str(), 0, MinimumGpinReportInterval, currentState, reply); + rslt = CanInterface::CreateHandle(newBoard, handle, pinName.c_str(), 0, MinimumGpinReportInterval, currentState, reply); if (rslt == GCodeResult::ok) { boardAddress = newBoard; @@ -99,14 +101,22 @@ GCodeResult GpInputPort::Configure(uint32_t gpinNumber, GCodeBuffer &gb, const S { currentState = false; } - return rslt; } + else #endif - if (!port.AssignPort(pinName.c_str(), reply, PinUsedBy::gpin, PinAccess::read)) { - return GCodeResult::error; + if (port.AssignPort(pinName.c_str(), reply, PinUsedBy::gpin, PinAccess::read)) + { + currentState = port.Read(); + } + else + { + rslt = GCodeResult::error; + } } - currentState = port.Read(); + + reprap.InputsUpdated(); + return rslt; } else { @@ -168,6 +178,8 @@ GCodeResult GpOutputPort::Configure(uint32_t gpioNumber, bool isServo, GCodeBuff freq = (isServo) ? ServoRefreshFrequency : DefaultPinWritePwmFreq; } + GCodeResult rslt; + #if SUPPORT_CAN_EXPANSION boardAddress = IoPort::RemoveBoardAddress(pinName.GetRef()); if (boardAddress != CanId::MasterAddress) @@ -177,14 +189,25 @@ GCodeResult GpOutputPort::Configure(uint32_t gpioNumber, bool isServo, GCodeBuff cons.AddUParam('Q', freq); cons.AddUParam('S', (isServo) ? 1 : 0); cons.AddStringParam('C', pinName.c_str()); - return cons.SendAndGetResponse(CanMessageType::m950Gpio, boardAddress, reply); + rslt = cons.SendAndGetResponse(CanMessageType::m950Gpio, boardAddress, reply); } + else #endif - if (!port.AssignPort(pinName.c_str(), reply, PinUsedBy::gpout, (isServo) ? PinAccess::servo : PinAccess::pwm)) { - return GCodeResult::error; + if (port.AssignPort(pinName.c_str(), reply, PinUsedBy::gpout, (isServo) ? PinAccess::servo : PinAccess::pwm)) + { + rslt = GCodeResult::ok; + port.SetFrequency(freq); + } + else + { + rslt = GCodeResult::error; + } } - port.SetFrequency(freq); + + // GPOut pins are not yet in the object model + // reprap.OutputsUpdated(); + return rslt; } else if (seenFreq) { @@ -194,10 +217,12 @@ GCodeResult GpOutputPort::Configure(uint32_t gpioNumber, bool isServo, GCodeBuff CanMessageGenericConstructor cons(M950GpioParams); cons.AddUParam('P', gpioNumber); cons.AddUParam('Q', freq); + // reprap.OutputsUpdated(); return cons.SendAndGetResponse(CanMessageType::m950Gpio, boardAddress, reply); } #endif port.SetFrequency(freq); + // reprap.OutputsUpdated(); } else { diff --git a/src/Heating/Heat.cpp b/src/Heating/Heat.cpp index 3f18a26f..0f4a6a80 100644 --- a/src/Heating/Heat.cpp +++ b/src/Heating/Heat.cpp @@ -173,6 +173,7 @@ GCodeResult Heat::SetPidParameters(unsigned int heater, GCodeBuffer& gb, const S if (seen) { h->SetM301PidParameters(pp); + reprap.HeatUpdated(); } else if (!model.UsePid()) { @@ -480,6 +481,7 @@ GCodeResult Heat::ConfigureHeater(size_t heater, GCodeBuffer& gb, const StringRe Heater *oldHeater = nullptr; std::swap(oldHeater, heaters[heater]); delete oldHeater; + reprap.HeatUpdated(); return GCodeResult::ok; } @@ -512,6 +514,7 @@ GCodeResult Heat::ConfigureHeater(size_t heater, GCodeBuffer& gb, const StringRe { delete newHeater; } + reprap.HeatUpdated(); return rslt; } @@ -530,7 +533,9 @@ GCodeResult Heat::ConfigureHeater(size_t heater, GCodeBuffer& gb, const StringRe if (gb.Seen('Q')) { - return h->SetPwmFrequency(gb.GetPwmFrequency(), reply); + const GCodeResult rslt = h->SetPwmFrequency(gb.GetPwmFrequency(), reply); + reprap.HeatUpdated(); + return rslt; } return h->ReportDetails(reply); @@ -593,6 +598,7 @@ void Heat::SetBedHeater(size_t index, int heater) noexcept h->SetDefaultMonitors(); } } + reprap.HeatUpdated(); } bool Heat::IsBedHeater(int heater) const noexcept @@ -622,6 +628,7 @@ void Heat::SetChamberHeater(size_t index, int heater) noexcept { h->SetDefaultMonitors(); } + reprap.HeatUpdated(); } bool Heat::IsChamberHeater(int heater) const noexcept diff --git a/src/Heating/Heater.cpp b/src/Heating/Heater.cpp index dcb4b180..5e509801 100644 --- a/src/Heating/Heater.cpp +++ b/src/Heating/Heater.cpp @@ -154,41 +154,47 @@ GCodeResult Heater::SetOrReportModel(unsigned int heater, GCodeBuffer& gb, const // Set the process model returning true if successful GCodeResult Heater::SetModel(float gain, float tc, float td, float maxPwm, float voltage, bool usePid, bool inverted, const StringRef& reply) noexcept { - const bool rslt = model.SetParameters(gain, tc, td, maxPwm, GetHighestTemperatureLimit(), voltage, usePid, inverted); - if (rslt) + GCodeResult rslt; + if (model.SetParameters(gain, tc, td, maxPwm, GetHighestTemperatureLimit(), voltage, usePid, inverted)) { if (model.IsEnabled()) { - const GCodeResult rslt = UpdateModel(reply); - if (rslt != GCodeResult::ok) + rslt = UpdateModel(reply); + if (rslt == GCodeResult::ok) { - return rslt; - } - const float predictedMaxTemp = gain + NormalAmbientTemperature; - const float noWarnTemp = (GetHighestTemperatureLimit() - NormalAmbientTemperature) * 1.5 + 50.0; // allow 50% extra power plus enough for an extra 50C - if (predictedMaxTemp > noWarnTemp) - { - reply.printf("heater %u appears to be over-powered. If left on at full power, its temperature is predicted to reach %dC.\n", - GetHeaterNumber(), (int)predictedMaxTemp); - return GCodeResult::warning; + const float predictedMaxTemp = gain + NormalAmbientTemperature; + const float noWarnTemp = (GetHighestTemperatureLimit() - NormalAmbientTemperature) * 1.5 + 50.0; // allow 50% extra power plus enough for an extra 50C + if (predictedMaxTemp > noWarnTemp) + { + reply.printf("heater %u appears to be over-powered. If left on at full power, its temperature is predicted to reach %dC.\n", + GetHeaterNumber(), (int)predictedMaxTemp); + rslt = GCodeResult::warning; + } } } else { ResetHeater(); + rslt = GCodeResult::ok; } - return GCodeResult::ok; + } + else + { + reply.copy("bad model parameters"); + rslt = GCodeResult::error; } - reply.copy("bad model parameters"); - return GCodeResult::error; + reprap.HeatUpdated(); + return rslt; } GCodeResult Heater::SetFaultDetectionParameters(float pMaxTempExcursion, float pMaxFaultTime, const StringRef& reply) noexcept { maxTempExcursion = pMaxTempExcursion; maxHeatingFaultTime = pMaxFaultTime; - return UpdateFaultDetectionParameters(reply); + const GCodeResult rslt = UpdateFaultDetectionParameters(reply); + reprap.HeatUpdated(); + return rslt; } GCodeResult Heater::ConfigureMonitor(GCodeBuffer &gb, const StringRef &reply) THROWS(GCodeException) @@ -221,7 +227,9 @@ GCodeResult Heater::ConfigureMonitor(GCodeBuffer &gb, const StringRef &reply) TH if (seenSensor || seenLimit || seenAction || seenCondition) { monitors[index].Set(monitoringSensor, limit, action, trigger); - return UpdateHeaterMonitors(reply); + const GCodeResult rslt = UpdateHeaterMonitors(reply); + reprap.HeatUpdated(); + return rslt; } // Else we are reporting on one or all of the monitors diff --git a/src/Platform.cpp b/src/Platform.cpp index a01931e5..6f9b23e4 100644 --- a/src/Platform.cpp +++ b/src/Platform.cpp @@ -3755,6 +3755,7 @@ GCodeResult Platform::SetSysDir(const char* dir, const StringRef& reply) noexcep const char *nsd2 = nsd; std::swap(sysDir, nsd2); delete nsd2; + reprap.DirectoriesUpdated(); return GCodeResult::ok; } diff --git a/src/PrintMonitor.cpp b/src/PrintMonitor.cpp index 18a1018e..5c911b27 100644 --- a/src/PrintMonitor.cpp +++ b/src/PrintMonitor.cpp @@ -56,19 +56,19 @@ constexpr ObjectModelTableEntry PrintMonitor::objectModelTable[] = // Within each group, these entries must be in alphabetical order // 0. PrintMonitor members { "duration", OBJECT_MODEL_FUNC_IF(self->IsPrinting(), self->GetPrintDuration(), 1), ObjectModelEntryFlags::live }, - { "extrudedRaw", OBJECT_MODEL_FUNC_NOSELF(&extrudedRawArrayDescriptor), ObjectModelEntryFlags::none }, + { "extrudedRaw", OBJECT_MODEL_FUNC_NOSELF(&extrudedRawArrayDescriptor), ObjectModelEntryFlags::live }, { "file", OBJECT_MODEL_FUNC(self, 1), ObjectModelEntryFlags::none }, { "filePosition", OBJECT_MODEL_FUNC_NOSELF(reprap.GetGCodes().GetFilePosition(), 0), ObjectModelEntryFlags::live }, { "lastFileName", OBJECT_MODEL_FUNC_IF(!self->filenameBeingPrinted.IsEmpty(), self->filenameBeingPrinted.c_str()), ObjectModelEntryFlags::none }, // TODO Add enum about the last file print here (to replace lastFileAborted, lastFileCancelled, lastFileSimulated) { "layer", OBJECT_MODEL_FUNC_IF(self->IsPrinting(), (int32_t)self->currentLayer), ObjectModelEntryFlags::none }, { "layerTime", OBJECT_MODEL_FUNC_IF(self->IsPrinting(), self->GetCurrentLayerTime(), 1), ObjectModelEntryFlags::none }, - { "timesLeft", OBJECT_MODEL_FUNC(self, 2), ObjectModelEntryFlags::none }, + { "timesLeft", OBJECT_MODEL_FUNC(self, 2), ObjectModelEntryFlags::live }, { "warmUpDuration", OBJECT_MODEL_FUNC_IF(self->IsPrinting(), self->GetWarmUpDuration(), 1), ObjectModelEntryFlags::none }, // 1. ParsedFileInfo members { "filament", OBJECT_MODEL_FUNC_NOSELF(&filamentArrayDescriptor), ObjectModelEntryFlags::none }, - { "fileName", OBJECT_MODEL_FUNC_IF(self->IsPrinting(), &self->filenameBeingPrinted), ObjectModelEntryFlags::none }, + { "fileName", OBJECT_MODEL_FUNC_IF(self->IsPrinting(), &self->filenameBeingPrinted), ObjectModelEntryFlags::none }, { "firstLayerHeight", OBJECT_MODEL_FUNC(self->printingFileInfo.firstLayerHeight, 2), ObjectModelEntryFlags::none }, { "generatedBy", OBJECT_MODEL_FUNC_IF(!self->printingFileInfo.generatedBy.IsEmpty(), self->printingFileInfo.generatedBy.c_str()), ObjectModelEntryFlags::none }, { "height", OBJECT_MODEL_FUNC(self->printingFileInfo.objectHeight, 2), ObjectModelEntryFlags::none }, @@ -80,9 +80,9 @@ constexpr ObjectModelTableEntry PrintMonitor::objectModelTable[] = { "size", OBJECT_MODEL_FUNC((int32_t)self->printingFileInfo.fileSize), /* note, using int32_t limits us to 2Gb */ ObjectModelEntryFlags::none }, // 2. TimesLeft members - { "filament", OBJECT_MODEL_FUNC(self->EstimateTimeLeftAsExpression(filamentBased)), ObjectModelEntryFlags::none }, - { "file", OBJECT_MODEL_FUNC(self->EstimateTimeLeftAsExpression(fileBased)), ObjectModelEntryFlags::none }, - { "layer", OBJECT_MODEL_FUNC(self->EstimateTimeLeftAsExpression(layerBased)), ObjectModelEntryFlags::none }, + { "filament", OBJECT_MODEL_FUNC(self->EstimateTimeLeftAsExpression(filamentBased)), ObjectModelEntryFlags::live }, + { "file", OBJECT_MODEL_FUNC(self->EstimateTimeLeftAsExpression(fileBased)), ObjectModelEntryFlags::live }, + { "layer", OBJECT_MODEL_FUNC(self->EstimateTimeLeftAsExpression(layerBased)), ObjectModelEntryFlags::live }, }; constexpr uint8_t PrintMonitor::objectModelTableDescriptor[] = { 3, 9, 11, 3 }; @@ -125,6 +125,7 @@ void PrintMonitor::SetPrintingFileInfo(const char *filename, GCodeFileInfo &info filenameBeingPrinted.copy(filename); printingFileInfo = info; printingFileParsed = true; + reprap.JobUpdated(); } void PrintMonitor::Spin() noexcept @@ -220,6 +221,7 @@ void PrintMonitor::Spin() noexcept lastLayerZ = currentZ; lastLayerChangeTime = GetPrintDuration(); + reprap.JobUpdated(); } } // Else check for following layer changes @@ -233,6 +235,7 @@ void PrintMonitor::Spin() noexcept ? printingFileInfo.firstLayerHeight + (currentLayer - 1) * printingFileInfo.layerHeight : currentZ; lastLayerChangeTime = GetPrintDuration(); + reprap.JobUpdated(); } } } @@ -357,6 +360,7 @@ void PrintMonitor::StoppedPrint() noexcept firstLayerDuration = firstLayerFilament = firstLayerProgress = 0.0; layerEstimatedTimeLeft = printStartTime = warmUpDuration = 0.0; lastLayerChangeTime = lastLayerFilament = lastLayerZ = 0.0; + reprap.JobUpdated(); } float PrintMonitor::FractionOfFilePrinted() const noexcept diff --git a/src/RepRap.h b/src/RepRap.h index bcc151ad..f08b1219 100644 --- a/src/RepRap.h +++ b/src/RepRap.h @@ -182,7 +182,11 @@ public: void KickHeatTaskWatchdog() noexcept { heatTaskIdleTicks = 0; } void BoardsUpdated() noexcept { ++boardsSeq; } + void DirectoriesUpdated() noexcept { ++directoriesSeq; } void FansUpdated() noexcept { ++fansSeq; } + void HeatUpdated() noexcept { ++heatSeq; } + void InputsUpdated() noexcept { ++inputsSeq; } + void JobUpdated() noexcept { ++jobSeq; } void ToolsUpdated() noexcept { ++toolsSeq; } protected: |