Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2022-02-17 20:21:13 +0300
committerDavid Crocker <dcrocker@eschertech.com>2022-02-17 20:21:13 +0300
commitd928e99b525858bffe6d1aa8970fcd70d4cecd6c (patch)
tree0d8d41bdbb26ddde130afd6447708bfe2d03d6e1 /src
parent5d254801ead587ce0e987db6d80b0eda2fb97fd1 (diff)
Added OM field boards[].closedLoop
Diffstat (limited to 'src')
-rw-r--r--src/CAN/ExpansionManager.cpp26
-rw-r--r--src/CAN/ExpansionManager.h14
-rw-r--r--src/ClosedLoop/ClosedLoop.cpp13
3 files changed, 40 insertions, 13 deletions
diff --git a/src/CAN/ExpansionManager.cpp b/src/CAN/ExpansionManager.cpp
index 9952e5b2..60ca48af 100644
--- a/src/CAN/ExpansionManager.cpp
+++ b/src/CAN/ExpansionManager.cpp
@@ -29,6 +29,7 @@ constexpr ObjectModelTableEntry ExpansionManager::objectModelTable[] =
// 0. boards[] members
{ "accelerometer", OBJECT_MODEL_FUNC_IF(self->FindIndexedBoard(context.GetLastIndex()).hasAccelerometer, self, 4), ObjectModelEntryFlags::none },
{ "canAddress", OBJECT_MODEL_FUNC((int32_t)(&(self->FindIndexedBoard(context.GetLastIndex())) - self->boards)), ObjectModelEntryFlags::none },
+ { "closedLoop", OBJECT_MODEL_FUNC_IF(self->FindIndexedBoard(context.GetLastIndex()).hasClosedLoop, self, 5), ObjectModelEntryFlags::none },
{ "firmwareDate", OBJECT_MODEL_FUNC(self->FindIndexedBoard(context.GetLastIndex()).typeName, ExpansionDetail::firmwareDate), ObjectModelEntryFlags::none },
{ "firmwareFileName", OBJECT_MODEL_FUNC(self->FindIndexedBoard(context.GetLastIndex()).typeName, ExpansionDetail::firmwareFileName), ObjectModelEntryFlags::none },
{ "firmwareVersion", OBJECT_MODEL_FUNC(self->FindIndexedBoard(context.GetLastIndex()).typeName, ExpansionDetail::firmwareVersion), ObjectModelEntryFlags::none },
@@ -59,16 +60,21 @@ constexpr ObjectModelTableEntry ExpansionManager::objectModelTable[] =
// 4. accelerometer members
{ "points", OBJECT_MODEL_FUNC((int32_t)self->FindIndexedBoard(context.GetLastIndex()).accelerometerLastRunDataPoints), ObjectModelEntryFlags::none },
{ "runs", OBJECT_MODEL_FUNC((int32_t)self->FindIndexedBoard(context.GetLastIndex()).accelerometerRuns), ObjectModelEntryFlags::none },
+
+ // 5. closedLoop members
+ { "points", OBJECT_MODEL_FUNC((int32_t)self->FindIndexedBoard(context.GetLastIndex()).closedLoopLastRunDataPoints), ObjectModelEntryFlags::none },
+ { "runs", OBJECT_MODEL_FUNC((int32_t)self->FindIndexedBoard(context.GetLastIndex()).closedLoopRuns), ObjectModelEntryFlags::none },
};
constexpr uint8_t ExpansionManager::objectModelTableDescriptor[] =
{
- 5, // number of sections
- 12, // section 0: boards[]
+ 6, // number of sections
+ 13, // section 0: boards[]
3, // section 1: mcuTemp
3, // section 2: vIn
3, // section 3: v12
- 2 // section 4: accelerometer
+ 2, // section 4: accelerometer
+ 2 // section 5: closed loop
};
DEFINE_GET_OBJECT_MODEL_TABLE(ExpansionManager)
@@ -76,8 +82,10 @@ DEFINE_GET_OBJECT_MODEL_TABLE(ExpansionManager)
#endif
ExpansionBoardData::ExpansionBoardData() noexcept
- : typeName(nullptr), hasMcuTemp(false), hasVin(false), hasV12(false), hasAccelerometer(false),
- accelerometerRuns(0), accelerometerLastRunDataPoints(0),
+ : typeName(nullptr),
+ accelerometerLastRunDataPoints(0), closedLoopLastRunDataPoints(0),
+ accelerometerRuns(0), closedLoopRuns(0),
+ hasMcuTemp(false), hasVin(false), hasV12(false), hasAccelerometer(false),
state(BoardState::unknown), numDrivers(0)
{
}
@@ -209,6 +217,7 @@ void ExpansionManager::ProcessBoardStatusReport(const CanMessageBuffer *buf) noe
board.mcuTemp = msg.values[index++];
}
board.hasAccelerometer = msg.hasAccelerometer;
+ board.hasClosedLoop = msg.hasClosedLoop;
}
// Return a pointer to the expansion board, if it is present
@@ -290,6 +299,13 @@ void ExpansionManager::AddAccelerometerRun(CanAddress address, unsigned int numD
reprap.BoardsUpdated();
}
+void ExpansionManager::AddClosedLoopRun(CanAddress address, unsigned int numDataPoints) noexcept
+{
+ boards[address].closedLoopLastRunDataPoints = numDataPoints;
+ ++boards[address].closedLoopRuns;
+ reprap.BoardsUpdated();
+}
+
GCodeResult ExpansionManager::ResetRemote(uint32_t boardAddress, GCodeBuffer& gb, const StringRef& reply) THROWS(GCodeException)
{
CanInterface::CheckCanAddress(boardAddress, gb);
diff --git a/src/CAN/ExpansionManager.h b/src/CAN/ExpansionManager.h
index edc2fdd1..a2046274 100644
--- a/src/CAN/ExpansionManager.h
+++ b/src/CAN/ExpansionManager.h
@@ -24,16 +24,19 @@ struct ExpansionBoardData
{
ExpansionBoardData() noexcept;
- const char *typeName;
- UniqueId uniqueId;
+ const char *_ecv_array typeName;
MinCurMax mcuTemp, vin, v12;
+ uint32_t accelerometerLastRunDataPoints;
+ uint32_t closedLoopLastRunDataPoints;
+ UniqueId uniqueId;
+ uint16_t accelerometerRuns;
+ uint16_t closedLoopRuns;
uint16_t hasMcuTemp : 1,
hasVin : 1,
hasV12 : 1,
hasAccelerometer : 1,
- spare : 12;
- uint16_t accelerometerRuns;
- uint16_t accelerometerLastRunDataPoints;
+ hasClosedLoop : 1,
+ spare : 11;
BoardState state;
uint8_t numDrivers;
};
@@ -56,6 +59,7 @@ public:
void UpdateFinished(CanAddress address) noexcept;
void UpdateFailed(CanAddress address) noexcept;
void AddAccelerometerRun(CanAddress address, unsigned int numDataPoints) noexcept;
+ void AddClosedLoopRun(CanAddress address, unsigned int numDataPoints) noexcept;
bool IsFlashing() const noexcept { return numBoardsFlashing != 0; }
void EmergencyStop() noexcept;
diff --git a/src/ClosedLoop/ClosedLoop.cpp b/src/ClosedLoop/ClosedLoop.cpp
index 40bbd96b..00f6c229 100644
--- a/src/ClosedLoop/ClosedLoop.cpp
+++ b/src/ClosedLoop/ClosedLoop.cpp
@@ -69,6 +69,7 @@ static void CloseDataCollectionFile() noexcept
closedLoopFile->Truncate(); // truncate the file in case we didn't write all the preallocated space
closedLoopFile->Close();
closedLoopFile = nullptr;
+ reprap.GetExpansion().AddClosedLoopRun(expectedRemoteBoardAddress, expectedRemoteSampleNumber);
}
// Handle M569.5 - Collect closed loop data
@@ -143,7 +144,15 @@ GCodeResult ClosedLoop::StartDataCollection(DriverId driverId, GCodeBuffer& gb,
String<MaxFilenameLength> closedLoopFileName;
MassStorage::CombineName(closedLoopFileName.GetRef(), "0:/sys/closed-loop/", tempFilename.c_str());
- OpenDataCollectionFile(closedLoopFileName, preallocSize);
+ if (!OpenDataCollectionFile(closedLoopFileName, preallocSize))
+ {
+ reply.copy("failed to create data collection file");
+ return GCodeResult::error;
+ }
+
+ // Set up the expected CAN address and next point number before we do anything that might call CloseDataFile
+ expectedRemoteSampleNumber = 0;
+ expectedRemoteBoardAddress = deviceRequested.boardAddress;
// If no samples have been requested, return with an info message
if (numSamplesRequested == 0)
@@ -154,8 +163,6 @@ GCodeResult ClosedLoop::StartDataCollection(DriverId driverId, GCodeBuffer& gb,
}
// Set up & start the CAN data transfer
- expectedRemoteSampleNumber = 0;
- expectedRemoteBoardAddress = deviceRequested.boardAddress;
const GCodeResult rslt = CanInterface::StartClosedLoopDataCollection(deviceRequested, filterRequested, numSamplesRequested, rateRequested, movementRequested, modeRequested, gb, reply);
if (rslt > GCodeResult::warning)
{