-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'bugfix/issue_341_import_export' into 'main'
Add new subcommands 'app' and 'device' under import and export subcommands See merge request syntron/support/csr/ifm3d/ifm3d!414
- Loading branch information
Showing
14 changed files
with
498 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
modules/tools/include/ifm3d/tools/legacy/export_application_app.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// -*- c++ -*- | ||
/* | ||
* Copyright 2018-present ifm electronic, gmbh | ||
* Copyright 2017 Love Park Robotics, LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef IFM3D_TOOLS_EXPORT_APPLICATION_APP_H | ||
#define IFM3D_TOOLS_EXPORT_APPLICATION_APP_H | ||
|
||
#include <string> | ||
#include <ifm3d/tools/command.hpp> | ||
#include <ifm3d/tools/main_command.hpp> | ||
|
||
namespace ifm3d | ||
{ | ||
/** | ||
* Concrete implementation of the `export app` subcommand to the `ifm3d` | ||
* command-line utility. | ||
*/ | ||
class ExportApplicationApp : public Command | ||
{ | ||
public: | ||
~ExportApplicationApp(); | ||
virtual void Execute(CLI::App* app) override; | ||
virtual CLI::App* CreateCommand(CLI::App* parent) override; | ||
|
||
int application_index{0}; | ||
std::string output_file{"-"}; | ||
|
||
}; // end: class ExportApplicationApp | ||
|
||
} // end: namespace ifm3d | ||
|
||
#endif // IFM3D_TOOLS_EXPORT_APPLICATION_APP_H |
38 changes: 38 additions & 0 deletions
38
modules/tools/include/ifm3d/tools/legacy/export_device_app.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// -*- c++ -*- | ||
/* | ||
* Copyright 2018-present ifm electronic, gmbh | ||
* Copyright 2017 Love Park Robotics, LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef IFM3D_TOOLS_EXPORT_DEVICE_APP_H | ||
#define IFM3D_TOOLS_EXPORT_DEVICE_APP_H | ||
|
||
#include <string> | ||
#include <ifm3d/tools/command.hpp> | ||
#include <ifm3d/tools/main_command.hpp> | ||
|
||
namespace ifm3d | ||
{ | ||
/** | ||
* Concrete implementation of the `export device` subcommand to the `ifm3d` | ||
* command-line utility. | ||
* | ||
* `export` provides compatibility with Vision Assistant - it can produce | ||
* exported applications/configurations that can be consumed by Vision | ||
* Assistant. | ||
*/ | ||
class ExportDeviceApp : public Command | ||
{ | ||
public: | ||
~ExportDeviceApp(); | ||
virtual void Execute(CLI::App* app) override; | ||
virtual CLI::App* CreateCommand(CLI::App* parent) override; | ||
|
||
std::string output_file{"-"}; | ||
|
||
}; // end: class ExportDeviceApp | ||
|
||
} // end: namespace ifm3d | ||
|
||
#endif // IFM3D_TOOLS_EXPORT_DEVICE_APP_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
modules/tools/include/ifm3d/tools/legacy/import_application_app.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// -*- c++ -*- | ||
/* | ||
* Copyright 2018-present ifm electronic, gmbh | ||
* Copyright 2017 Love Park Robotics, LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef IFM3D_TOOLS_IMPORT_APPLICATION_APP_H | ||
#define IFM3D_TOOLS_IMPORT_APPLICATION_APP_H | ||
|
||
#include <string> | ||
#include <ifm3d/tools/command.hpp> | ||
#include <ifm3d/tools/main_command.hpp> | ||
|
||
namespace ifm3d | ||
{ | ||
/** | ||
* Concrete implementation of the `import app` subcommand to the `ifm3d` | ||
* command-line utility. | ||
*/ | ||
class ImportApplicationApp : public Command | ||
{ | ||
public: | ||
~ImportApplicationApp(); | ||
virtual void Execute(CLI::App* app) override; | ||
virtual CLI::App* CreateCommand(CLI::App* parent) override; | ||
|
||
std::string input_file{"-"}; | ||
|
||
}; // end: class ImportApplicationApp | ||
} // end: namespace ifm3d | ||
|
||
#endif // IFM3D_TOOLS_IMPORT_APPLICATION_APP_H |
36 changes: 36 additions & 0 deletions
36
modules/tools/include/ifm3d/tools/legacy/import_device_app.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// -*- c++ -*- | ||
/* | ||
* Copyright 2018-present ifm electronic, gmbh | ||
* Copyright 2017 Love Park Robotics, LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#ifndef IFM3D_TOOLS_IMPORT_DEVICE_APP_H | ||
#define IFM3D_TOOLS_IMPORT_DEVICE_APP_H | ||
|
||
#include <string> | ||
#include <ifm3d/tools/command.hpp> | ||
#include <ifm3d/tools/main_command.hpp> | ||
|
||
namespace ifm3d | ||
{ | ||
/** | ||
* Concrete implementation of the `import device` subcommand to the `ifm3d` | ||
* command-line utility. | ||
*/ | ||
class ImportDeviceApp : public Command | ||
{ | ||
public: | ||
~ImportDeviceApp(); | ||
virtual void Execute(CLI::App* app) override; | ||
virtual CLI::App* CreateCommand(CLI::App* parent) override; | ||
|
||
std::string input_file{"-"}; | ||
bool no_global_config; | ||
bool no_network_config; | ||
bool no_app_config; | ||
|
||
}; // end: class ImportDeviceApp | ||
} // end: namespace ifm3d | ||
|
||
#endif // IFM3D_TOOLS_IMPORT_DEVICE_APP_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
modules/tools/src/libifm3d_tools/legacy/export_application_app.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Copyright 2018-present ifm electronic, gmbh | ||
* Copyright 2017 Love Park Robotics, LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <ifm3d/tools/legacy/export_application_app.h> | ||
#include <cstdint> | ||
#include <fstream> | ||
#include <iostream> | ||
#include <string> | ||
#include <vector> | ||
#include <ifm3d/device.h> | ||
|
||
ifm3d::ExportApplicationApp::~ExportApplicationApp() {} | ||
|
||
void | ||
ifm3d::ExportApplicationApp::Execute(CLI::App* app) | ||
{ | ||
auto device = Parent<MainCommand>()->GetDevice(); | ||
|
||
std::vector<std::uint8_t> bytes; | ||
|
||
if (Parent<ifm3d::O3D3XX>()) | ||
{ | ||
bytes = | ||
std::static_pointer_cast<ifm3d::LegacyDevice>(device)->ExportIFMApp( | ||
this->application_index); | ||
} | ||
else | ||
{ | ||
bytes = | ||
std::static_pointer_cast<ifm3d::LegacyDevice>(device)->ExportIFMApp(1); | ||
} | ||
|
||
if (this->output_file == "-") | ||
{ | ||
std::cout.write(reinterpret_cast<char*>(bytes.data()), bytes.size()); | ||
} | ||
else | ||
{ | ||
std::ofstream(this->output_file, std::ios::binary) | ||
.write(reinterpret_cast<char*>(bytes.data()), bytes.size()); | ||
} | ||
} | ||
|
||
CLI::App* | ||
ifm3d::ExportApplicationApp::CreateCommand(CLI::App* parent) | ||
{ | ||
CLI::App* command = | ||
parent | ||
->add_subcommand("app", | ||
"Export an application that is compatible with ifm " | ||
"Vision Assistant's export format (*.o3d3xxapp).") | ||
->require_subcommand(0, 0); | ||
|
||
if (Parent<ifm3d::O3D3XX>()) | ||
{ | ||
command | ||
->add_option("--index", | ||
this->application_index, | ||
"The index of an application to export") | ||
->default_val(0) | ||
->required(); | ||
} | ||
|
||
command | ||
->add_option( | ||
"--file", | ||
this->output_file, | ||
"Output file, defaults to `stdout' (good for piping to other tools)") | ||
->default_val("-"); | ||
|
||
return command; | ||
} |
56 changes: 56 additions & 0 deletions
56
modules/tools/src/libifm3d_tools/legacy/export_device_app.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright 2018-present ifm electronic, gmbh | ||
* Copyright 2017 Love Park Robotics, LLC | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <ifm3d/tools/legacy/export_device_app.h> | ||
#include <cstdint> | ||
#include <fstream> | ||
#include <iostream> | ||
#include <string> | ||
#include <vector> | ||
#include <ifm3d/device.h> | ||
|
||
ifm3d::ExportDeviceApp::~ExportDeviceApp() {} | ||
|
||
void | ||
ifm3d::ExportDeviceApp::Execute(CLI::App* app) | ||
{ | ||
auto device = Parent<MainCommand>()->GetDevice(); | ||
|
||
std::vector<std::uint8_t> bytes; | ||
|
||
bytes = | ||
std::static_pointer_cast<ifm3d::LegacyDevice>(device)->ExportIFMConfig(); | ||
|
||
if (this->output_file == "-") | ||
{ | ||
std::cout.write(reinterpret_cast<char*>(bytes.data()), bytes.size()); | ||
} | ||
else | ||
{ | ||
std::ofstream(this->output_file, std::ios::binary) | ||
.write(reinterpret_cast<char*>(bytes.data()), bytes.size()); | ||
} | ||
} | ||
|
||
CLI::App* | ||
ifm3d::ExportDeviceApp::CreateCommand(CLI::App* parent) | ||
{ | ||
CLI::App* command = | ||
parent | ||
->add_subcommand("device", | ||
"Export a device configuration that is compatible with " | ||
"ifm Vision Assistant's export format. (*.o3d3xxcfg)") | ||
->require_subcommand(0, 0); | ||
|
||
command | ||
->add_option( | ||
"--file", | ||
this->output_file, | ||
"Output file, defaults to `stdout' (good for piping to other tools)") | ||
->default_val("-"); | ||
|
||
return command; | ||
} |
Oops, something went wrong.