-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
auto-generate connect ports option. Fixes #934 #1786
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
127 changes: 127 additions & 0 deletions
127
Autocoders/Python/src/fprime_ac/generators/templates/test/test_helpers.tmpl
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,127 @@ | ||
// ====================================================================== | ||
// \title $name/test/ut/TesterHelpers.cpp | ||
// \author Auto-generated | ||
// \brief cpp file for ${name} component test harness base class | ||
// | ||
// NOTE: this file was automatically generated | ||
// | ||
// ====================================================================== | ||
\#include "Tester.hpp" | ||
|
||
#if $namespace_list != None | ||
#for $namespace in $namespace_list | ||
namespace ${namespace} { | ||
#end for | ||
#end if | ||
// ---------------------------------------------------------------------- | ||
// Helper methods | ||
// ---------------------------------------------------------------------- | ||
|
||
void Tester :: | ||
connectPorts() | ||
{ | ||
|
||
#for $instance, $type, $sync, $priority, $full, $role, $max_num in $typed_input_ports: | ||
// $instance | ||
#if $max_num == 1 or $max_num == "1": | ||
this->connect_to_${instance}( | ||
0, | ||
this->component.get_${instance}_InputPort(0) | ||
); | ||
#else | ||
#set LT = "<" | ||
for (NATIVE_INT_TYPE i = 0; i $LT $max_num; ++i) { | ||
this->connect_to_${instance}( | ||
i, | ||
this->component.get_${instance}_InputPort(i) | ||
); | ||
} | ||
#end if | ||
|
||
#end for | ||
#for $instance, $type, $sync, $priority, $role, $max_num in $typed_output_ports: | ||
// $instance | ||
#if $max_num == 1 or $max_num == "1": | ||
this->component.set_${instance}_OutputPort( | ||
0, | ||
this->get_from_${instance}(0) | ||
); | ||
#else | ||
#set LT = "<" | ||
for (NATIVE_INT_TYPE i = 0; i $LT $max_num; ++i) { | ||
this->component.set_${instance}_OutputPort( | ||
i, | ||
this->get_from_${instance}(i) | ||
); | ||
} | ||
#end if | ||
|
||
#end for | ||
|
||
#if len($serial_output_ports) > 0: | ||
// ---------------------------------------------------------------------- | ||
// Connect serial output ports | ||
// ---------------------------------------------------------------------- | ||
#for $instance, $sync, $priority, $max_num in $serial_output_ports: | ||
#if $max_num == 1 or $max_num == "1": | ||
this->component.set_${instance}_OutputPort( | ||
0, | ||
this->get_from_${instance}(0) | ||
); | ||
#else | ||
#set LT = "<" | ||
for (NATIVE_INT_TYPE i = 0; i $LT $max_num; ++i) { | ||
this->component.set_${instance}_OutputPort( | ||
i, | ||
this->get_from_${instance}(i) | ||
); | ||
} | ||
#end if | ||
|
||
#end for | ||
#end if | ||
|
||
#if len($serial_input_ports) > 0: | ||
// ---------------------------------------------------------------------- | ||
// Connect serial input ports | ||
// ---------------------------------------------------------------------- | ||
#for $instance, $sync, $priority, $full, $max_num in $serial_input_ports: | ||
// $instance | ||
#if $max_num == 1 or $max_num == "1": | ||
this->connect_to_${instance}( | ||
0, | ||
this->component.get_${instance}_InputPort(0) | ||
); | ||
#else | ||
#set LT = "<" | ||
for (NATIVE_INT_TYPE i = 0; i $LT $max_num; ++i) { | ||
this->connect_to_${instance}( | ||
i, | ||
this->component.get_${instance}_InputPort(i) | ||
); | ||
} | ||
#end if | ||
|
||
#end for | ||
#end if | ||
|
||
} | ||
|
||
void Tester :: | ||
initComponents() | ||
{ | ||
this->init(); | ||
this->component.init( | ||
#if $kind == "passive" | ||
Tester::TEST_INSTANCE_ID | ||
#else | ||
Tester::TEST_INSTANCE_QUEUE_DEPTH, Tester::TEST_INSTANCE_ID | ||
#end if | ||
); | ||
} | ||
|
||
#if $namespace_list != None | ||
#for $namespace in $reversed($namespace_list) | ||
} // end namespace $namespace | ||
#end for | ||
#end if |
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
47 changes: 47 additions & 0 deletions
47
Autocoders/Python/src/fprime_ac/generators/visitors/TestImplCppHelpersVisitor.py
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,47 @@ | ||
# =============================================================================== | ||
# NAME: TestImplCppHelpersVisitor.py | ||
# | ||
# DESCRIPTION: A visitor class for generating test implementation cpp files. | ||
# | ||
# AUTHOR: lestarch | ||
# DATE CREATED: November 28, 2022 | ||
# | ||
# Copyright 2015, California Institute of Technology. | ||
# ALL RIGHTS RESERVED. U.S. Government Sponsorship acknowledged. | ||
# =============================================================================== | ||
import sys | ||
|
||
from fprime_ac.generators.visitors import TestImplVisitorBase | ||
|
||
try: | ||
from fprime_ac.generators.templates.test import test_helpers | ||
except ImportError: | ||
print("ERROR: must generate python templates first.") | ||
sys.exit(-1) | ||
|
||
|
||
class TestImplCppHelpersVisitor(TestImplVisitorBase.TestImplVisitorBase): | ||
""" | ||
A visitor class for generating test implementation cpp files. | ||
""" | ||
|
||
def __init__(self): | ||
super().__init__() | ||
self.initBase("TestImplCpp") | ||
|
||
def emitPortParams(self, params): | ||
return self.emitPortParamsCpp(8, params) | ||
|
||
def emitNonPortParams(self, params): | ||
return self.emitNonPortParamsCpp(8, params) | ||
|
||
def initFilesVisit(self, obj): | ||
self.openFile("TesterHelpers.cpp") | ||
|
||
def startSourceFilesVisit(self, obj): | ||
c = test_helpers.test_helpers() | ||
self.init(obj, c) | ||
self.initTestImpl(obj, c) | ||
c.emit_port_params = self.emitPortParams | ||
c.emit_non_port_params = self.emitNonPortParams | ||
self._writeTmpl(c, "startSourceFilesVisit") |
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check notice
Code scanning / CodeQL
Use of a print statement at module level