diff options
author | David Crocker <dcrocker@eschertech.com> | 2022-01-20 00:46:01 +0300 |
---|---|---|
committer | David Crocker <dcrocker@eschertech.com> | 2022-01-20 00:46:01 +0300 |
commit | 9421a5b5d6dfbfffac94add25918a0b4e45212a5 (patch) | |
tree | 0ad69b70b003f8e620fcedcadaae8147a8ca52aa /src | |
parent | 25288e366c948905116ba99366a2097b895e214d (diff) |
Added OM field state.thisInput
Diffstat (limited to 'src')
-rw-r--r-- | src/GCodes/GCodeBuffer/ExpressionParser.cpp | 2 | ||||
-rw-r--r-- | src/GCodes/GCodes.cpp | 2 | ||||
-rw-r--r-- | src/GCodes/GCodes2.cpp | 2 | ||||
-rw-r--r-- | src/Networking/HttpResponder.cpp | 2 | ||||
-rw-r--r-- | src/ObjectModel/ObjectModel.cpp | 12 | ||||
-rw-r--r-- | src/ObjectModel/ObjectModel.h | 8 | ||||
-rw-r--r-- | src/Platform/RepRap.cpp | 7 | ||||
-rw-r--r-- | src/Platform/RepRap.h | 2 |
8 files changed, 20 insertions, 17 deletions
diff --git a/src/GCodes/GCodeBuffer/ExpressionParser.cpp b/src/GCodes/GCodeBuffer/ExpressionParser.cpp index 5ceb9e67..09315121 100644 --- a/src/GCodes/GCodeBuffer/ExpressionParser.cpp +++ b/src/GCodes/GCodeBuffer/ExpressionParser.cpp @@ -894,7 +894,7 @@ void ExpressionParser::ParseIdentifierExpression(ExpressionValue& rslt, bool eva } String<MaxVariableNameLength> id; - ObjectExplorationContext context(applyLengthOperator, applyExists, gb.GetLineNumber(), GetColumn()); + ObjectExplorationContext context(&gb, applyLengthOperator, applyExists, gb.GetLineNumber(), GetColumn()); // Loop parsing identifiers and index expressions // When we come across an index expression, evaluate it, add it to the context, and place a marker in the identifier string. diff --git a/src/GCodes/GCodes.cpp b/src/GCodes/GCodes.cpp index 3f069954..6561e1a8 100644 --- a/src/GCodes/GCodes.cpp +++ b/src/GCodes/GCodes.cpp @@ -4531,7 +4531,7 @@ void GCodes::CheckReportDue(GCodeBuffer& gb, const StringRef& reply) const noexc // Send a standard status response for PanelDue OutputBuffer * const statusBuf = (lastAuxStatusReportType == ObjectModelAuxStatusReportType) // PanelDueFirmware v3.2 or later, using M409 to retrieve object model - ? reprap.GetModelResponse("", "d99fi") + ? reprap.GetModelResponse(&gb, "", "d99fi") : GenerateJsonStatusResponse(lastAuxStatusReportType, -1, ResponseSource::AUX); // older PanelDueFirmware using M408 if (statusBuf != nullptr) { diff --git a/src/GCodes/GCodes2.cpp b/src/GCodes/GCodes2.cpp index a36ac792..c674f54d 100644 --- a/src/GCodes/GCodes2.cpp +++ b/src/GCodes/GCodes2.cpp @@ -2889,7 +2889,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeEx { lastAuxStatusReportType = ObjectModelAuxStatusReportType; } - outBuf = reprap.GetModelResponse(key.c_str(), flags.c_str()); + outBuf = reprap.GetModelResponse(&gb, key.c_str(), flags.c_str()); if (outBuf == nullptr) { OutputBuffer::ReleaseAll(outBuf); diff --git a/src/Networking/HttpResponder.cpp b/src/Networking/HttpResponder.cpp index ddbdcb25..45530116 100644 --- a/src/Networking/HttpResponder.cpp +++ b/src/Networking/HttpResponder.cpp @@ -638,7 +638,7 @@ bool HttpResponder::GetJsonResponse(const char* request, OutputBuffer *&response OutputBuffer::ReleaseAll(response); const char *const filterVal = GetKeyValue("key"); const char *const flagsVal = GetKeyValue("flags"); - response = reprap.GetModelResponse(filterVal, flagsVal); + response = reprap.GetModelResponse(nullptr, filterVal, flagsVal); } #endif else if (StringEqualsIgnoreCase(request, "config")) diff --git a/src/ObjectModel/ObjectModel.cpp b/src/ObjectModel/ObjectModel.cpp index 4d3f7ef5..aa9fec68 100644 --- a/src/ObjectModel/ObjectModel.cpp +++ b/src/ObjectModel/ObjectModel.cpp @@ -305,9 +305,9 @@ ObjectModel::ObjectModel() noexcept // ObjectExplorationContext members // Constructor used when reporting the OM as JSON -ObjectExplorationContext::ObjectExplorationContext(bool wal, const char *reportFlags, unsigned int initialMaxDepth, size_t initialBufferOffset) noexcept +ObjectExplorationContext::ObjectExplorationContext(const GCodeBuffer *_ecv_null gbp, 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), + line(-1), column(-1), gb(gbp), shortForm(false), wantArrayLength(wal), wantExists(false), includeNonLive(true), includeImportant(false), includeNulls(false), excludeVerbose(true), excludeObsolete(true), @@ -364,9 +364,9 @@ ObjectExplorationContext::ObjectExplorationContext(bool wal, const char *reportF } // Constructor when evaluating expressions -ObjectExplorationContext::ObjectExplorationContext(bool wal, bool wex, int p_line, int p_col) noexcept +ObjectExplorationContext::ObjectExplorationContext(const GCodeBuffer *_ecv_null gbp, 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), + line(p_line), column(p_col), gb(gbp), shortForm(false), wantArrayLength(wal), wantExists(wex), includeNonLive(true), includeImportant(false), includeNulls(false), excludeVerbose(false), excludeObsolete(false), @@ -496,10 +496,10 @@ void ObjectModel::ReportAsJson(OutputBuffer* buf, ObjectExplorationContext& cont } // Construct a JSON representation of those parts of the object model requested by the user. This version is called on the root of the tree. -void ObjectModel::ReportAsJson(OutputBuffer *buf, const char *_ecv_array filter, const char *_ecv_array reportFlags, bool wantArrayLength) const THROWS(GCodeException) +void ObjectModel::ReportAsJson(const GCodeBuffer *_ecv_null gb, OutputBuffer *buf, const char *_ecv_array filter, const char *_ecv_array reportFlags, bool wantArrayLength) const THROWS(GCodeException) { const unsigned int defaultMaxDepth = (wantArrayLength) ? 99 : (filter[0] == 0) ? 1 : 99; - ObjectExplorationContext context(wantArrayLength, reportFlags, defaultMaxDepth, buf->Length()); + ObjectExplorationContext context(gb, wantArrayLength, reportFlags, defaultMaxDepth, buf->Length()); ReportAsJson(buf, context, nullptr, 0, filter); if (context.GetNextElement() >= 0) { diff --git a/src/ObjectModel/ObjectModel.h b/src/ObjectModel/ObjectModel.h index 7dad7944..bcf77791 100644 --- a/src/ObjectModel/ObjectModel.h +++ b/src/ObjectModel/ObjectModel.h @@ -219,11 +219,12 @@ class ObjectExplorationContext { public: // Constructor used when reporting the OM as JSON - ObjectExplorationContext(bool wal, const char *reportFlags, unsigned int initialMaxDepth, size_t initialBufferOffset) noexcept; + ObjectExplorationContext(const GCodeBuffer *_ecv_null gbp, bool wal, const char *reportFlags, unsigned int initialMaxDepth, size_t initialBufferOffset) noexcept; // Constructor used when evaluating expressions - ObjectExplorationContext(bool wal, bool wex, int p_line, int p_col) noexcept; + ObjectExplorationContext(const GCodeBuffer *_ecv_null gbp, bool wal, bool wex, int p_line, int p_col) noexcept; + const GCodeBuffer *_ecv_null GetGCodeBuffer() const noexcept { return gb; } void SetMaxDepth(unsigned int d) noexcept { maxDepth = d; } bool IncreaseDepth() noexcept { if (currentDepth < maxDepth) { ++currentDepth; return true; } return false; } void DecreaseDepth() noexcept { --currentDepth; } @@ -267,6 +268,7 @@ private: int32_t indices[MaxIndices]; int line; int column; + const GCodeBuffer *_ecv_null gb; unsigned int shortForm : 1, wantArrayLength : 1, wantExists : 1, @@ -297,7 +299,7 @@ public: virtual ~ObjectModel() { } // Construct a JSON representation of those parts of the object model requested by the user. This version is called only on the root of the tree. - void ReportAsJson(OutputBuffer *buf, const char *_ecv_array filter, const char *_ecv_array reportFlags, bool wantArrayLength) const THROWS(GCodeException); + void ReportAsJson(const GCodeBuffer *_ecv_null gb, OutputBuffer *buf, const char *_ecv_array filter, const char *_ecv_array reportFlags, bool wantArrayLength) const THROWS(GCodeException); // Get the value of an object via the table ExpressionValue GetObjectValueUsingTableNumber(ObjectExplorationContext& context, const ObjectModelClassDescriptor * null classDescriptor, const char *_ecv_array idString, uint8_t tableNumber) const THROWS(GCodeException); diff --git a/src/Platform/RepRap.cpp b/src/Platform/RepRap.cpp index 87c50f83..20c8d05d 100644 --- a/src/Platform/RepRap.cpp +++ b/src/Platform/RepRap.cpp @@ -351,6 +351,7 @@ constexpr ObjectModelTableEntry RepRap::objectModelTable[] = { "previousTool", OBJECT_MODEL_FUNC((int32_t)self->previousToolNumber), ObjectModelEntryFlags::live }, { "restorePoints", OBJECT_MODEL_FUNC_NOSELF(&restorePointsArrayDescriptor), ObjectModelEntryFlags::none }, { "status", OBJECT_MODEL_FUNC(self->GetStatusString()), ObjectModelEntryFlags::live }, + { "thisInput", OBJECT_MODEL_FUNC_IF_NOSELF(context.GetGCodeBuffer() != nullptr, (int32_t)context.GetGCodeBuffer()->GetChannel().ToBaseType()), ObjectModelEntryFlags::none }, { "time", OBJECT_MODEL_FUNC(DateTime(self->platform->GetDateTime())), ObjectModelEntryFlags::live }, { "upTime", OBJECT_MODEL_FUNC_NOSELF((int32_t)((context.GetStartMillis()/1000u) & 0x7FFFFFFF)), ObjectModelEntryFlags::live }, @@ -406,7 +407,7 @@ constexpr uint8_t RepRap::objectModelTableDescriptor[] = 0, // directories #endif 25, // limits - 19 + HAS_VOLTAGE_MONITOR + SUPPORT_LASER, // state + 20 + HAS_VOLTAGE_MONITOR + SUPPORT_LASER, // state 2, // state.beep 6, // state.messageBox 12 + HAS_NETWORKING + SUPPORT_SCANNER + @@ -2498,7 +2499,7 @@ void RepRap::AppendStringArray(OutputBuffer *buf, const char *name, size_t numVa // Return a query into the object model, or return nullptr if no buffer available // We append a newline to help PanelDue resync after receiving corrupt or incomplete data. DWC ignores it. -OutputBuffer *RepRap::GetModelResponse(const char *key, const char *flags) const THROWS(GCodeException) +OutputBuffer *RepRap::GetModelResponse(const GCodeBuffer *_ecv_null gb, const char *key, const char *flags) const THROWS(GCodeException) { OutputBuffer *outBuf; if (OutputBuffer::Allocate(outBuf)) @@ -2516,7 +2517,7 @@ OutputBuffer *RepRap::GetModelResponse(const char *key, const char *flags) const try { - reprap.ReportAsJson(outBuf, key, flags, wantArrayLength); + reprap.ReportAsJson(gb, outBuf, key, flags, wantArrayLength); outBuf->cat("}\n"); if (outBuf->HadOverflow()) { diff --git a/src/Platform/RepRap.h b/src/Platform/RepRap.h index 5c060c82..ca3c4cba 100644 --- a/src/Platform/RepRap.h +++ b/src/Platform/RepRap.h @@ -154,7 +154,7 @@ public: GCodeResult GetFileInfoResponse(const char *filename, OutputBuffer *&response, bool quitEarly) noexcept; #if SUPPORT_OBJECT_MODEL - OutputBuffer *GetModelResponse(const char *key, const char *flags) const THROWS(GCodeException); + OutputBuffer *GetModelResponse(const GCodeBuffer *_ecv_null gb, const char *key, const char *flags) const THROWS(GCodeException); #endif void Beep(unsigned int freq, unsigned int ms) noexcept; |