-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
45 changed files
with
1,428 additions
and
1,202 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
BasedOnStyle: LLVM | ||
IndentWidth: 8 | ||
TabWidth: 8 | ||
UseTab: Always | ||
BreakBeforeBraces: Linux | ||
AllowShortIfStatementsOnASingleLine: false | ||
AllowShortFunctionsOnASingleLine: false | ||
AllowShortLoopsOnASingleLine: false | ||
AllowShortBlocksOnASingleLine: false | ||
IndentCaseLabels: false | ||
ColumnLimit: 80 | ||
AccessModifierOffset: -8 | ||
NamespaceIndentation: None | ||
PointerAlignment: Right | ||
AlignTrailingComments: true | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
FixNamespaceComments: false | ||
AlignAfterOpenBracket: Align |
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,11 @@ | ||
--- | ||
Checks: | ||
clang-diagnostic-*, | ||
clang-analyzer-*, | ||
cppcoreguidelines-*, | ||
modernize-*, | ||
-modernize-use-trailing-return-type, | ||
-cppcoreguidelines-non-private-member-variables-in-classes | ||
WarningsAsErrors: '*' | ||
HeaderFilterRegex: '.*' | ||
--- |
Binary file not shown.
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 was deleted.
Oops, something went wrong.
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,19 @@ | ||
find_program(CLANG_FORMAT "clang-format") | ||
|
||
file(GLOB_RECURSE ALL_SOURCE_FILES | ||
${CMAKE_SOURCE_DIR}/source/*.cxx | ||
${CMAKE_SOURCE_DIR}/source/*.hxx | ||
${CMAKE_SOURCE_DIR}/include/*.hxx | ||
${CMAKE_SOURCE_DIR}/examples/*.cxx | ||
${CMAKE_SOURCE_DIR}/examples/*.hxx | ||
) | ||
|
||
add_custom_target(format | ||
COMMAND ${CLANG_FORMAT} --style=file -i ${ALL_SOURCE_FILES} | ||
COMMENT "Running clang-format on all source files" | ||
) | ||
|
||
add_custom_target(format-check | ||
COMMAND ${CLANG_FORMAT} --style=file -output-replacements-xml ${ALL_SOURCE_FILES} | grep \"<replacement \" && echo \"check-format failed. Run cmake --build <build> format\" && exit 1 || exit 0 | ||
COMMENT "Checking code format" | ||
) |
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,4 @@ | ||
find_program(CLANG_TIDY_EXECUTABLE clang-tidy REQUIRED) | ||
|
||
set(CMAKE_CXX_CLANG_TIDY ${CLANG_TIDY_EXECUTABLE}) | ||
set(CMAKE_C_CLANG_TIDY ${CLANG_TIDY_EXECUTABLE}) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,54 +1,56 @@ | ||
#include <pza/core/core.hxx> | ||
#include <pza/core/client.hxx> | ||
#include <pza/interfaces/voltmeter.hxx> | ||
#include <pza/core/core.hxx> | ||
#include <pza/interfaces/ammeter.hxx> | ||
#include <pza/interfaces/bps_chan_ctrl.hxx> | ||
#include <pza/interfaces/voltmeter.hxx> | ||
|
||
static const std::string addr = "localhost"; | ||
static const unsigned int port = 1883; | ||
|
||
int main(void) | ||
int main() | ||
{ | ||
spdlog::info("pza version: {}", pza::core::get_version()); | ||
spdlog::info("pza version hash: {}", pza::core::get_version_githash()); | ||
pza::core::set_log_level(pza::core::log_level::debug); | ||
|
||
pza::client::s_ptr cli = std::make_shared<pza::client>("localhost", 1883); | ||
|
||
if (cli->connect() < 0) | ||
return -1; | ||
|
||
if (cli->register_devices() < 0) | ||
return -1; | ||
|
||
auto vm = cli->get_interface<pza::itf::voltmeter>("default", "Panduza_FakeBps", "channel", 0, "vm"); | ||
if (!vm) { | ||
spdlog::error("voltmeter not found"); | ||
return -1; | ||
} | ||
|
||
auto ctrl = cli->get_interface<pza::itf::bps_chan_ctrl>("default", "Panduza_FakeBps", "channel", 0, "ctrl"); | ||
if (!ctrl) { | ||
spdlog::error("ctrl not found"); | ||
return -1; | ||
} | ||
|
||
auto am = cli->get_interface<pza::itf::ammeter>("default", "Panduza_FakeBps", "channel", 0, "am"); | ||
if (!am) { | ||
spdlog::error("ammeter not found"); | ||
return -1; | ||
} | ||
|
||
ctrl->set_enable(true); | ||
ctrl->set_voltage(3.3); | ||
ctrl->set_current(0.1); | ||
|
||
vm->register_measure_callback([&]() { | ||
spdlog::info("voltage: {}", vm->get_measure()); | ||
}); | ||
|
||
am->register_measure_callback([&]() { | ||
spdlog::info("current: {}", am->get_measure()); | ||
}); | ||
|
||
while (1) | ||
; | ||
return 0; | ||
pza::core::set_log_level(pza::core::log_level::debug); | ||
|
||
pza::client::s_ptr cli = std::make_shared<pza::client>(addr, port); | ||
|
||
if (cli->connect() < 0) | ||
return -1; | ||
|
||
if (cli->register_devices() < 0) | ||
return -1; | ||
|
||
auto vm = cli->get_interface<pza::itf::voltmeter>( | ||
"default", "Panduza_FakeBps", "channel", 0, "vm"); | ||
if (!vm) { | ||
spdlog::error("voltmeter not found"); | ||
return -1; | ||
} | ||
|
||
auto ctrl = cli->get_interface<pza::itf::bps_chan_ctrl>( | ||
"default", "Panduza_FakeBps", "channel", 0, "ctrl"); | ||
if (!ctrl) { | ||
spdlog::error("ctrl not found"); | ||
return -1; | ||
} | ||
|
||
auto am = cli->get_interface<pza::itf::ammeter>( | ||
"default", "Panduza_FakeBps", "channel", 0, "am"); | ||
if (!am) { | ||
spdlog::error("ammeter not found"); | ||
return -1; | ||
} | ||
|
||
ctrl->set_enable(true); | ||
ctrl->set_voltage(3.3); | ||
ctrl->set_current(0.1); | ||
|
||
vm->register_measure_callback( | ||
[&]() { spdlog::info("voltage: {}", vm->get_measure()); }); | ||
|
||
am->register_measure_callback( | ||
[&]() { spdlog::info("current: {}", am->get_measure()); }); | ||
|
||
while (true) | ||
; | ||
return 0; | ||
} |
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
Oops, something went wrong.