diff options
author | David Crocker <dcrocker@eschertech.com> | 2021-12-10 12:37:55 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2021-12-10 12:37:55 +0300 |
commit | e2955f3209e417a3b71d42542c481250a03ce9c7 (patch) | |
tree | eb706c71a0b8a553100226771896ec91aa44508a | |
parent | cc12d7eb9d2db88b9139ae64c68656ef220c0fd1 (diff) |
Added 'important' flag in object model; support Duet 2 SBC in ATE
Added an "important" flag to the object model field flags and the object
model query flags, as part of a fix for PaneDue and M291 S3 messages
commanded from macro files
In the Duet 2 SBC build, initialise the PanelDue port by default, for
the ATE
-rw-r--r-- | src/ObjectModel/ObjectModel.cpp | 32 | ||||
-rw-r--r-- | src/ObjectModel/ObjectModel.h | 27 | ||||
-rw-r--r-- | src/Platform/RepRap.cpp | 21 |
3 files changed, 50 insertions, 30 deletions
diff --git a/src/ObjectModel/ObjectModel.cpp b/src/ObjectModel/ObjectModel.cpp index 5e7010f8..db00a77c 100644 --- a/src/ObjectModel/ObjectModel.cpp +++ b/src/ObjectModel/ObjectModel.cpp @@ -308,7 +308,10 @@ ObjectModel::ObjectModel() noexcept ObjectExplorationContext::ObjectExplorationContext(bool wal, const char *reportFlags, unsigned int initialMaxDepth, size_t initialBufferOffset) noexcept : startMillis(millis()), initialBufOffset(initialBufferOffset), maxDepth(initialMaxDepth), currentDepth(0), startElement(0), nextElement(-1), numIndicesProvided(0), numIndicesCounted(0), line(-1), column(-1), - shortForm(false), onlyLive(false), includeVerbose(false), wantArrayLength(wal), includeNulls(false), includeObsolete(false), obsoleteFieldQueried(false), wantExists(false) + shortForm(false), wantArrayLength(wal), wantExists(false), + includeNonLive(true), includeImportant(false), includeNulls(false), + excludeVerbose(true), excludeObsolete(true), + obsoleteFieldQueried(false) { while (true) { @@ -317,19 +320,22 @@ ObjectExplorationContext::ObjectExplorationContext(bool wal, const char *reportF case '\0': return; case 'v': - includeVerbose = true; + excludeVerbose = false; break; case 's': shortForm = true; break; case 'f': - onlyLive = true; + includeNonLive = false; + break; + case 'i': + includeImportant = true; break; case 'n': includeNulls = true; break; case 'o': - includeObsolete = true; + excludeObsolete = false; break; case 'd': maxDepth = 0; @@ -361,7 +367,10 @@ ObjectExplorationContext::ObjectExplorationContext(bool wal, const char *reportF ObjectExplorationContext::ObjectExplorationContext(bool wal, bool wex, int p_line, int p_col) noexcept : startMillis(millis()), initialBufOffset(0), maxDepth(99), currentDepth(0), startElement(0), nextElement(-1), numIndicesProvided(0), numIndicesCounted(0), line(p_line), column(p_col), - shortForm(false), onlyLive(false), includeVerbose(true), wantArrayLength(wal), includeNulls(false), includeObsolete(true), obsoleteFieldQueried(false), wantExists(wex) + shortForm(false), wantArrayLength(wal), wantExists(wex), + includeNonLive(true), includeImportant(false), includeNulls(false), + excludeVerbose(false), excludeObsolete(false), + obsoleteFieldQueried(false) { } @@ -385,9 +394,12 @@ int32_t ObjectExplorationContext::GetLastIndex() const THROWS(GCodeException) bool ObjectExplorationContext::ShouldReport(const ObjectModelEntryFlags f) const noexcept { - return (!onlyLive || ((uint8_t)f & (uint8_t)ObjectModelEntryFlags::live) != 0) - && (includeVerbose || ((uint8_t)f & (uint8_t)ObjectModelEntryFlags::verbose) == 0) - && (includeObsolete || ((uint8_t)f & (uint8_t)ObjectModelEntryFlags::obsolete) == 0); + const bool wanted = includeNonLive + || ((uint8_t)f & (uint8_t)ObjectModelEntryFlags::live) != 0 + || (includeImportant && ((uint8_t)f & (uint8_t)ObjectModelEntryFlags::important) != 0); + return wanted + && (!excludeVerbose || ((uint8_t)f & (uint8_t)ObjectModelEntryFlags::verbose) == 0) + && (!excludeObsolete || ((uint8_t)f & (uint8_t)ObjectModelEntryFlags::obsolete) == 0); } GCodeException ObjectExplorationContext::ConstructParseException(const char *msg) const noexcept @@ -895,7 +907,9 @@ bool ObjectModelTableEntry::ReportAsJson(OutputBuffer* buf, ObjectExplorationCon { const char * nextElement = ObjectModel::GetNextElement(filter); const ExpressionValue val = func(self, context); - if (val.GetType() != TypeCode::None || context.ShouldIncludeNulls()) + // We include nulls if either the "include nulls" flag is set or the "include important" flag is set and the field is flagged important. + // The latter is so that field state.messageBox gets reported to PanelDue even if null when the "important" flag is set, so that PanelDue knows when a message has been cleared. + if (val.GetType() != TypeCode::None || context.ShouldIncludeNulls() || (context.ShouldIncludeImportant() && ((uint8_t)flags & (uint8_t)ObjectModelEntryFlags::important))) { if (*filter == 0) { diff --git a/src/ObjectModel/ObjectModel.h b/src/ObjectModel/ObjectModel.h index 3fbc9bc5..b756ecb0 100644 --- a/src/ObjectModel/ObjectModel.h +++ b/src/ObjectModel/ObjectModel.h @@ -206,15 +206,12 @@ struct ExpressionValue enum class ObjectModelEntryFlags : uint8_t { // none, live and verbose are alternatives occupying the bottom 2 bits - none = 0, // nothing special - live = 1, // fast changing data, included in common status response - verbose = 2, // omit reporting this value by default - - // canAlter can be or'ed in - canAlter = 4, // we can alter this value - liveCanAlter = 5, // we can alter this value - - obsolete = 8 // entry is deprecated and should not be used any more + none = 0, // nothing special + live = 1, // fast changing data, included in common status response + important = 2, // important when it is present, so include in unsolicited responses to PanelDue + liveOrImportantMask = 3, // mask to select values flagged as either live or important + verbose = 4, // omit reporting this value by default + obsolete = 8 // entry is deprecated and should not be used any more }; // Context passed to object model functions @@ -245,6 +242,7 @@ public: bool WantArrayLength() const noexcept { return wantArrayLength; } bool WantExists() const noexcept { return wantExists; } bool ShouldIncludeNulls() const noexcept { return includeNulls; } + bool ShouldIncludeImportant() const noexcept { return includeImportant; } uint64_t GetStartMillis() const { return startMillis; } size_t GetInitialBufferOffset() const noexcept { return initialBufOffset; } @@ -270,13 +268,14 @@ private: int line; int column; unsigned int shortForm : 1, - onlyLive : 1, - includeVerbose : 1, wantArrayLength : 1, + wantExists : 1, + includeNonLive : 1, + includeImportant : 1, includeNulls : 1, - includeObsolete : 1, - obsoleteFieldQueried : 1, - wantExists : 1; + excludeVerbose : 1, + excludeObsolete : 1, + obsoleteFieldQueried : 1; }; // Entry to describe an array of objects or values. These must be brace-initializable into flash memory. diff --git a/src/Platform/RepRap.cpp b/src/Platform/RepRap.cpp index 86317c53..f36b10fd 100644 --- a/src/Platform/RepRap.cpp +++ b/src/Platform/RepRap.cpp @@ -341,7 +341,7 @@ constexpr ObjectModelTableEntry RepRap::objectModelTable[] = { "logLevel", OBJECT_MODEL_FUNC(self->platform->GetLogLevel()), ObjectModelEntryFlags::none }, { "machineMode", OBJECT_MODEL_FUNC(self->gCodes->GetMachineModeString()), ObjectModelEntryFlags::none }, { "macroRestarted", OBJECT_MODEL_FUNC(self->gCodes->GetMacroRestarted()), ObjectModelEntryFlags::none }, - { "messageBox", OBJECT_MODEL_FUNC_IF(self->mbox.active, self, 5), ObjectModelEntryFlags::none }, + { "messageBox", OBJECT_MODEL_FUNC_IF(self->mbox.active, self, 5), ObjectModelEntryFlags::important }, { "msUpTime", OBJECT_MODEL_FUNC_NOSELF((int32_t)(context.GetStartMillis() % 1000u)), ObjectModelEntryFlags::live }, { "nextTool", OBJECT_MODEL_FUNC((int32_t)self->gCodes->GetNewToolNumber()), ObjectModelEntryFlags::live }, #if HAS_VOLTAGE_MONITOR @@ -358,12 +358,12 @@ constexpr ObjectModelTableEntry RepRap::objectModelTable[] = { "frequency", OBJECT_MODEL_FUNC((int32_t)self->beepFrequency), ObjectModelEntryFlags::none }, // 5. MachineModel.state.messageBox (FIXME acquire MutexLocker when accessing the following) - { "axisControls", OBJECT_MODEL_FUNC((int32_t)self->mbox.controls.GetRaw()), ObjectModelEntryFlags::none }, - { "message", OBJECT_MODEL_FUNC(self->mbox.message.c_str()), ObjectModelEntryFlags::none }, - { "mode", OBJECT_MODEL_FUNC((int32_t)self->mbox.mode), ObjectModelEntryFlags::none }, - { "seq", OBJECT_MODEL_FUNC((int32_t)self->mbox.seq), ObjectModelEntryFlags::none }, - { "timeout", OBJECT_MODEL_FUNC((int32_t)self->mbox.timeout), ObjectModelEntryFlags::none }, - { "title", OBJECT_MODEL_FUNC(self->mbox.title.c_str()), ObjectModelEntryFlags::none }, + { "axisControls", OBJECT_MODEL_FUNC((int32_t)self->mbox.controls.GetRaw()), ObjectModelEntryFlags::important }, + { "message", OBJECT_MODEL_FUNC(self->mbox.message.c_str()), ObjectModelEntryFlags::important }, + { "mode", OBJECT_MODEL_FUNC((int32_t)self->mbox.mode), ObjectModelEntryFlags::important }, + { "seq", OBJECT_MODEL_FUNC((int32_t)self->mbox.seq), ObjectModelEntryFlags::important }, + { "timeout", OBJECT_MODEL_FUNC((int32_t)self->mbox.timeout), ObjectModelEntryFlags::important }, + { "title", OBJECT_MODEL_FUNC(self->mbox.title.c_str()), ObjectModelEntryFlags::important }, // 6. MachineModel.seqs { "boards", OBJECT_MODEL_FUNC((int32_t)self->boardsSeq), ObjectModelEntryFlags::live }, @@ -627,6 +627,13 @@ void RepRap::Init() noexcept sbcInterface->Init(); # endif } +#elif defined(DUET_NG) + // It's the SBC build of Duet 2 firmware. Enable the PanelDue port so that the ATE can test it. + platform->SetBaudRate(1, 57600); + platform->SetCommsProperties(1, 1); + gCodes->SetAux0CommsProperties(1); + platform->SetAuxRaw(0, false); + platform->EnableAux(0); #endif #if HAS_SBC_INTERFACE |