-
Notifications
You must be signed in to change notification settings - Fork 0
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
Add temporary ducer implementation #1
Merged
Merged
Changes from all commits
Commits
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
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,8 +1,16 @@ | ||
#ifndef FILL_TELEMETRY_READER_H_ | ||
#define FILL_TELEMETRY_READER_H_ | ||
|
||
#include "protos/telemetry.pb.h" | ||
#include "sensors/sensor.h" | ||
|
||
using telemetry::Telemetry; | ||
|
||
class TelemetryReader { | ||
public: | ||
public: | ||
TelemetryReader(Sensor& sensor) : sensor_(sensor) {} | ||
Telemetry read(); | ||
}; | ||
private: | ||
Sensor& sensor_; | ||
}; | ||
#endif |
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,13 +1,20 @@ | ||
#include "telemetry_reader.h" | ||
#include "sensors/mock_sensor.h" | ||
|
||
#include "gtest/gtest.h" | ||
#include <gmock/gmock.h> | ||
#include <gtest/gtest.h> | ||
|
||
namespace { | ||
|
||
using ::testing::Return; | ||
|
||
TEST(TelemetryReaderTest, BasicTest) { | ||
TelemetryReader reader; | ||
float test_val = 3.14; | ||
MockSensor sensor; | ||
EXPECT_CALL(sensor, Read()).Times(1).WillOnce(Return(test_val)); | ||
TelemetryReader reader(sensor); | ||
Telemetry telem = reader.read(); | ||
EXPECT_EQ(telem.temp(), "It works!"); | ||
EXPECT_EQ(telem.temp(), test_val); | ||
} | ||
|
||
} //namespace |
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
cc_library( | ||
name = "sensor", | ||
hdrs = ["sensor.h"], | ||
deps = [], | ||
visibility = [ | ||
"//fill:__subpackages__", | ||
"//ground:__subpackages__", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "ducer", | ||
srcs = ["ducer.cc"], | ||
hdrs = ["ducer.h"], | ||
deps = [":sensor"], | ||
visibility = [ | ||
"//fill:__subpackages__", | ||
"//ground:__subpackages__", | ||
], | ||
) | ||
|
||
cc_library( | ||
name = "mock_sensor", | ||
hdrs = ["mock_sensor.h"], | ||
deps = [ | ||
":sensor", | ||
"@googletest//:gtest_main", | ||
], | ||
visibility = [ | ||
"//fill:__subpackages__", | ||
"//ground:__subpackages__", | ||
], | ||
) |
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,7 @@ | ||
#include "ducer.h" | ||
|
||
float Ducer::Read() { | ||
float reading = 3.14; | ||
cache_.push_back(reading); | ||
return reading; | ||
} |
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,6 @@ | ||
#include "sensor.h" | ||
|
||
class Ducer : public Sensor { | ||
public: | ||
float Read(); | ||
}; |
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,12 @@ | ||
#ifndef SENSORS_MOCK_SENSOR_H_ | ||
#define SENSORS_MOCK_SENSOR_H_ | ||
|
||
#include "sensor.h" | ||
|
||
#include <gmock/gmock.h> // Brings in gMock. | ||
|
||
class MockSensor : public Sensor { | ||
public: | ||
MOCK_METHOD(float, Read, (), (override)); | ||
}; | ||
#endif |
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,14 @@ | ||
#ifndef SENSORS_SENSOR_H_ | ||
#define SENSORS_SENSOR_H_ | ||
|
||
#include <vector> | ||
|
||
class Sensor { | ||
public: | ||
virtual ~Sensor() {} | ||
virtual float Read() = 0; | ||
protected: | ||
// cache for rolling averages | ||
std::vector<float> cache_; | ||
}; | ||
#endif |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At some point, we should probably distinguish (in name) between fill station telemetry and rocket telemetry