1
0
Fork 0

node reporting

This commit is contained in:
Kevin Matz 2023-05-21 13:46:35 -04:00
parent 840f42d8dc
commit 68ced05c57
2 changed files with 40 additions and 1 deletions

View File

@ -39,6 +39,9 @@ Device::Device(Style style)
, diagnostic_reporting_threshold(DpCritial)
, _shortName("OpenLCP Device")
, _longName("Generic OpenLCP Art-Net Device")
, _report_code(RcPowerOk)
, _poll_reply_count(0)
, _report_text("initialized")
{
}
@ -51,6 +54,11 @@ void Device::receive(ACN::PDU::Stream buffer)
{
auto packet = std::make_shared<Packet>();
packet->iStream(buffer);
if (buffer->fail() || buffer->bad())
{
_report_code = RcParseFail;
_report_text = "unable to read packet";
}
receive(packet);
}
@ -161,6 +169,18 @@ void Device::send(const std::shared_ptr<Packet> packet, const ipAddress &address
}
/**
* @brief Device::setStatus
* @param status
* @param text
*/
void Device::setReport(const NodeReport status, const std::string &text)
{
_report_code = status;
_report_text = text.substr(Node_Report_Length-8-1); // less required chars and null terminator
}
/**
* @brief Device::rxArtPoll
* @param packet
@ -399,7 +419,7 @@ void Device::txArtPollReply()
// reply->status = ;
reply->short_name = _shortName;
reply->long_name = _longName;
// reply->report() = ;
reply->set_report(_report_code, _poll_reply_count, _report_text);
// reply->num_ports = ;
// reply->port_types = ;
// reply->good_input = ;
@ -416,6 +436,11 @@ void Device::txArtPollReply()
auto packet = std::make_shared<ArtPollReply>(reply);
send(packet, broadcastIp());
// reset report components
_report_code = RcPowerOk;
_poll_reply_count++;
_report_text = "nominal";
}
@ -492,6 +517,11 @@ std::string Device::shortName() const
void Device::setShortName(const std::string &newShortName)
{
_shortName = newShortName.substr(0, Short_Name_Length-1); // leave room for null terminator
_report_code = RcShNameOk;
if (newShortName.length() == _shortName.length())
_report_text = "short name accepted";
else
_report_text = "short name truncated";
}
@ -512,6 +542,11 @@ std::string Device::longName() const
void Device::setLongName(const std::string &newLongName)
{
_longName = newLongName.substr(0, Long_Name_Length-1); // leave room for null terminator
_report_code = RcLoNameOk;
if (newLongName.length() == _longName.length())
_report_text = "long name accepted";
else
_report_text = "long name truncated";
}
} // namespace ARTNET

View File

@ -59,6 +59,7 @@ protected:
Priority diagnostic_reporting_threshold; //!< lowest priority dignostic message to send
void send(const std::shared_ptr<Packet> packet, const ipAddress &) const;
void setReport(const NodeReport, const std::string &);
void rxArtPoll(std::shared_ptr<ArtPoll>);
virtual void rxArtPollReply(std::shared_ptr<ArtPollReply>);
@ -94,6 +95,9 @@ private:
std::string _shortName;
std::string _longName;
NodeReport _report_code;
uint _poll_reply_count;
std::string _report_text;
};
} // namespace ARTNET