adam-markovics commented on a change in pull request #1198:
URL: https://github.com/apache/nifi-minifi-cpp/pull/1198#discussion_r727790479
##########
File path: extensions/sensors/SensorBase.cpp
##########
@@ -51,11 +51,15 @@ void SensorBase::initialize() {
}
void SensorBase::onSchedule(const std::shared_ptr<core::ProcessContext>&
/*context*/, const std::shared_ptr<core::ProcessSessionFactory>&
/*sessionFactory*/) {
- imu = std::unique_ptr<RTIMU>(RTIMU::createIMU(&settings));
- if (imu) {
- imu->IMUInit();
- imu->setGyroEnable(true);
- imu->setAccelEnable(true);
+ // Deferred instantiation of RTIMUSettings, because it can create a file
"RTIMULib.ini" in the working directory.
+ // SensorBase is instantiated when creating the manifest.
+ settings_ = std::make_unique<RTIMUSettings>();
Review comment:
The file is not created if the processor is not scheduled. Creating the
manifest calls the constructor, but does not schedule the processor. I don't
think it is possible to avoid file creation if the processor is actually used.
##########
File path: extensions/sensors/SensorBase.cpp
##########
@@ -51,11 +51,15 @@ void SensorBase::initialize() {
}
void SensorBase::onSchedule(const std::shared_ptr<core::ProcessContext>&
/*context*/, const std::shared_ptr<core::ProcessSessionFactory>&
/*sessionFactory*/) {
- imu = std::unique_ptr<RTIMU>(RTIMU::createIMU(&settings));
- if (imu) {
- imu->IMUInit();
- imu->setGyroEnable(true);
- imu->setAccelEnable(true);
+ // Deferred instantiation of RTIMUSettings, because it can create a file
"RTIMULib.ini" in the working directory.
+ // SensorBase is instantiated when creating the manifest.
+ settings_ = std::make_unique<RTIMUSettings>();
Review comment:
There is another constructor for RTIMUSettings, where we can specify a
directory where the settings file will be created. This could be preferred if
we can agree on where to put it. Definitely not in the current working
directory.
`RTIMUSettings(const char *settingsDirectory, const char *productType);`
##########
File path: extensions/sensors/SensorBase.cpp
##########
@@ -51,11 +51,15 @@ void SensorBase::initialize() {
}
void SensorBase::onSchedule(const std::shared_ptr<core::ProcessContext>&
/*context*/, const std::shared_ptr<core::ProcessSessionFactory>&
/*sessionFactory*/) {
- imu = std::unique_ptr<RTIMU>(RTIMU::createIMU(&settings));
- if (imu) {
- imu->IMUInit();
- imu->setGyroEnable(true);
- imu->setAccelEnable(true);
+ // Deferred instantiation of RTIMUSettings, because it can create a file
"RTIMULib.ini" in the working directory.
+ // SensorBase is instantiated when creating the manifest.
+ settings_ = std::make_unique<RTIMUSettings>();
Review comment:
Gábor said he tried it on main. I'm not sure why you didn't see it,
perhaps there are some other conditions. I tried it with just the same CMake
options as the ones for Ubuntu 20.04 from ci.yml. Also you could try running
ManifestTests:
`ctest -R ManifestTests`
After this, git should notice there is a new untracked file.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]