Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for nasa/fprime#2823 #73

Merged
merged 3 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 20 additions & 12 deletions Components/Led/test/int/led_integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,28 @@ def test_blinking(fprime_test_api):
"""Test that LED component can respond to ground commands"""

# Send command to enable blinking, then assert expected events are emitted
blink_start_evr = fprime_test_api.get_event_pred("led.SetBlinkingState", ["ON"])
led_on_evr = fprime_test_api.get_event_pred("led.LedState", ["ON"])
led_off_evr = fprime_test_api.get_event_pred("led.LedState", ["OFF"])
blink_start_evr = fprime_test_api.get_event_pred(
"LedBlinker.led.SetBlinkingState", ["ON"]
)
led_on_evr = fprime_test_api.get_event_pred("LedBlinker.led.LedState", ["ON"])
led_off_evr = fprime_test_api.get_event_pred("LedBlinker.led.LedState", ["OFF"])

fprime_test_api.send_and_assert_event(
"led.BLINKING_ON_OFF",
"LedBlinker.led.BLINKING_ON_OFF",
args=["ON"],
events=[blink_start_evr, led_on_evr, led_off_evr, led_on_evr],
timeout=5,
)

# Assert that blink command sets blinking state on
blink_state_on_tlm = fprime_test_api.get_telemetry_pred("led.BlinkingState", "ON")
blink_state_on_tlm = fprime_test_api.get_telemetry_pred(
"LedBlinker.led.BlinkingState", "ON"
)
fprime_test_api.assert_telemetry(blink_state_on_tlm)

# Assert that the LedTransitions channel increments
results = fprime_test_api.assert_telemetry_count(
predicates.greater_than(2), "led.LedTransitions", timeout=4
predicates.greater_than(2), "LedBlinker.led.LedTransitions", timeout=4
)
ascending = True
prev = None
Expand All @@ -33,27 +37,31 @@ def test_blinking(fprime_test_api):
if not res.get_val() > prev.get_val():
ascending = False
fprime_test_api.log(
f"led.LedTransitions not in ascending order: First ({prev.get_val()}) Second ({res.get_val()})"
f"LedBlinker.led.LedTransitions not in ascending order: First ({prev.get_val()}) Second ({res.get_val()})"
)
prev = res
assert fprime_test_api.test_assert(
ascending, "Expected all led.LedTransitions updates to ascend.", True
ascending, "Expected all LedBlinker.led.LedTransitions updates to ascend.", True
)

# Send command to stop blinking, then assert blinking stops
blink_stop_evr = fprime_test_api.get_event_pred("led.SetBlinkingState", ["OFF"])
blink_stop_evr = fprime_test_api.get_event_pred(
"LedBlinker.led.SetBlinkingState", ["OFF"]
)
fprime_test_api.send_and_assert_event(
"led.BLINKING_ON_OFF", args=["OFF"], events=[blink_stop_evr]
"LedBlinker.led.BLINKING_ON_OFF", args=["OFF"], events=[blink_stop_evr]
)
time.sleep(1) # Wait one second to let any in-progress telemetry be sent
# Save reference to current telemetry history so we can search against future telemetry
telem_after_blink_off = fprime_test_api.telemetry_history.size()
time.sleep(2) # Wait to receive telemetry after stopping blinking
# Assert that blinking has stopped and that LedTransitions is no longer updating
fprime_test_api.assert_telemetry_count(
0, "led.LedTransitions", start=telem_after_blink_off
0, "LedBlinker.led.LedTransitions", start=telem_after_blink_off
)

# Assert that blink command sets blinking state off
blink_state_off_tlm = fprime_test_api.get_telemetry_pred("led.BlinkingState", "OFF")
blink_state_off_tlm = fprime_test_api.get_telemetry_pred(
"LedBlinker.led.BlinkingState", "OFF"
)
fprime_test_api.assert_telemetry(blink_state_off_tlm, timeout=2)
24 changes: 12 additions & 12 deletions LedBlinker/Top/LedBlinkerTopology.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ enum TopologyConstants {

// Ping entries are autocoded, however; this code is not properly exported. Thus, it is copied here.
Svc::Health::PingEntry pingEntries[] = {
{PingEntries::blockDrv::WARN, PingEntries::blockDrv::FATAL, "blockDrv"},
{PingEntries::tlmSend::WARN, PingEntries::tlmSend::FATAL, "chanTlm"},
{PingEntries::cmdDisp::WARN, PingEntries::cmdDisp::FATAL, "cmdDisp"},
{PingEntries::cmdSeq::WARN, PingEntries::cmdSeq::FATAL, "cmdSeq"},
{PingEntries::eventLogger::WARN, PingEntries::eventLogger::FATAL, "eventLogger"},
{PingEntries::fileDownlink::WARN, PingEntries::fileDownlink::FATAL, "fileDownlink"},
{PingEntries::fileManager::WARN, PingEntries::fileManager::FATAL, "fileManager"},
{PingEntries::fileUplink::WARN, PingEntries::fileUplink::FATAL, "fileUplink"},
{PingEntries::prmDb::WARN, PingEntries::prmDb::FATAL, "prmDb"},
{PingEntries::rateGroup1::WARN, PingEntries::rateGroup1::FATAL, "rateGroup1"},
{PingEntries::rateGroup2::WARN, PingEntries::rateGroup2::FATAL, "rateGroup2"},
{PingEntries::rateGroup3::WARN, PingEntries::rateGroup3::FATAL, "rateGroup3"},
{PingEntries::LedBlinker_blockDrv::WARN, PingEntries::LedBlinker_blockDrv::FATAL, "blockDrv"},
{PingEntries::LedBlinker_tlmSend::WARN, PingEntries::LedBlinker_tlmSend::FATAL, "chanTlm"},
{PingEntries::LedBlinker_cmdDisp::WARN, PingEntries::LedBlinker_cmdDisp::FATAL, "cmdDisp"},
{PingEntries::LedBlinker_cmdSeq::WARN, PingEntries::LedBlinker_cmdSeq::FATAL, "cmdSeq"},
{PingEntries::LedBlinker_eventLogger::WARN, PingEntries::LedBlinker_eventLogger::FATAL, "eventLogger"},
{PingEntries::LedBlinker_fileDownlink::WARN, PingEntries::LedBlinker_fileDownlink::FATAL, "fileDownlink"},
{PingEntries::LedBlinker_fileManager::WARN, PingEntries::LedBlinker_fileManager::FATAL, "fileManager"},
{PingEntries::LedBlinker_fileUplink::WARN, PingEntries::LedBlinker_fileUplink::FATAL, "fileUplink"},
{PingEntries::LedBlinker_prmDb::WARN, PingEntries::LedBlinker_prmDb::FATAL, "prmDb"},
{PingEntries::LedBlinker_rateGroup1::WARN, PingEntries::LedBlinker_rateGroup1::FATAL, "rateGroup1"},
{PingEntries::LedBlinker_rateGroup2::WARN, PingEntries::LedBlinker_rateGroup2::FATAL, "rateGroup2"},
{PingEntries::LedBlinker_rateGroup3::WARN, PingEntries::LedBlinker_rateGroup3::FATAL, "rateGroup3"},
};

/**
Expand Down
24 changes: 12 additions & 12 deletions LedBlinker/Top/LedBlinkerTopologyDefs.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,40 +49,40 @@ struct TopologyState {
* ```
*/
namespace PingEntries {
namespace blockDrv {
namespace LedBlinker_blockDrv {
enum { WARN = 3, FATAL = 5 };
}
namespace tlmSend {
namespace LedBlinker_tlmSend {
enum { WARN = 3, FATAL = 5 };
}
namespace cmdDisp {
namespace LedBlinker_cmdDisp {
enum { WARN = 3, FATAL = 5 };
}
namespace cmdSeq {
namespace LedBlinker_cmdSeq {
enum { WARN = 3, FATAL = 5 };
}
namespace eventLogger {
namespace LedBlinker_eventLogger {
enum { WARN = 3, FATAL = 5 };
}
namespace fileDownlink {
namespace LedBlinker_fileDownlink {
enum { WARN = 3, FATAL = 5 };
}
namespace fileManager {
namespace LedBlinker_fileManager {
enum { WARN = 3, FATAL = 5 };
}
namespace fileUplink {
namespace LedBlinker_fileUplink {
enum { WARN = 3, FATAL = 5 };
}
namespace prmDb {
namespace LedBlinker_prmDb {
enum { WARN = 3, FATAL = 5 };
}
namespace rateGroup1 {
namespace LedBlinker_rateGroup1 {
enum { WARN = 3, FATAL = 5 };
}
namespace rateGroup2 {
namespace LedBlinker_rateGroup2 {
enum { WARN = 3, FATAL = 5 };
}
namespace rateGroup3 {
namespace LedBlinker_rateGroup3 {
enum { WARN = 3, FATAL = 5 };
}
} // namespace PingEntries
Expand Down