-
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
24 changed files
with
593 additions
and
59 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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
set(examples | ||
psu | ||
bps | ||
) | ||
|
||
foreach(example ${examples}) | ||
|
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,25 @@ | ||
#include <pza/core/client.hxx> | ||
#include <pza/core/core.hxx> | ||
#include <pza/devices/bps.hxx> | ||
|
||
int main(void) | ||
{ | ||
pza::core::set_log_level(pza::core::log_level::debug); | ||
|
||
pza::client::ptr cli = std::make_shared<pza::client>("localhost", 1883); | ||
|
||
if (cli->connect() == -1) { | ||
return -1; | ||
} | ||
|
||
pza::bps::ptr bps = std::make_shared<pza::bps>("default", "MY BPS 1"); | ||
|
||
cli->register_device(bps); | ||
|
||
bps->channel[0]->volts; | ||
|
||
while (1) | ||
; | ||
|
||
return 0; | ||
} |
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
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 +1,47 @@ | ||
#include "device.hxx" | ||
#include "device.hxx" | ||
#include <pza/core/client.hxx> | ||
|
||
using namespace pza; | ||
|
||
device::device(const std::string group, const std::string name) | ||
: _name(name), | ||
_group(group), | ||
_base_topic("pza/" + group + "/" + name), | ||
_device_topic(_base_topic + "/device") | ||
{ | ||
|
||
} | ||
|
||
void device::reset() | ||
{ | ||
_state = state::orphan; | ||
_model = ""; | ||
_manufacturer = ""; | ||
} | ||
|
||
int device::_set_identity(const std::string &payload) | ||
{ | ||
std::string family; | ||
|
||
if (json::get_string(payload, "identity", "model", _model) == -1) { | ||
spdlog::error("Device does not have a model"); | ||
return -1; | ||
} | ||
|
||
if (json::get_string(payload, "identity", "manufacturer", _manufacturer) == -1) { | ||
spdlog::error("Device does not have a manufacturer"); | ||
return -1; | ||
} | ||
|
||
if (json::get_string(payload, "identity", "family", family) == -1) { | ||
spdlog::error("Device does not have a family"); | ||
return -1; | ||
} | ||
|
||
if (family != get_family()) { | ||
spdlog::error("Device is not compatible {} != {}", family, get_family()); | ||
return -1; | ||
} | ||
|
||
return 0; | ||
} |
Oops, something went wrong.