Skip to content

Commit 5424e2e

Browse files
authored
Merge pull request #118 from nasa-jpl/kwehage-interp-csp
Add interpolation for CSP commands
2 parents b48af43 + d53b7b1 commit 5424e2e

File tree

111 files changed

+1021
-383
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+1021
-383
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
cmake_minimum_required (VERSION 3.11)
22
project(fastcat
33
DESCRIPTION "C++ EtherCAT Device Command & Control Library"
4-
VERSION 0.12.11
4+
VERSION 0.13.0
55
LANGUAGES C CXX
66
)
77

@@ -43,6 +43,7 @@ endif()
4343

4444
# @TODO(kwehage,abrinkma) Clean up missing-field-initializers warnings
4545
add_definitions(
46+
-Werror=all
4647
-Wall
4748
-Wextra
4849
-Wno-missing-field-initializers

src/device_base.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
fastcat::DeviceBase::~DeviceBase() {}
1010

1111
void fastcat::DeviceBase::RegisterCmdQueue(
12-
std::shared_ptr<std::queue<DeviceCmd>> cmd_queue)
12+
std::shared_ptr<fastcat::ThreadSafeQueue<DeviceCmd>> cmd_queue)
1313
{
1414
cmd_queue_ = cmd_queue;
1515
}
@@ -25,7 +25,11 @@ void fastcat::DeviceBase::SetLoopPeriod(double loop_period)
2525
loop_period_ = loop_period;
2626
}
2727

28-
void fastcat::DeviceBase::SetTime(double time) { state_->time = time; }
28+
void fastcat::DeviceBase::SetTime(double time, double monotonic_time)
29+
{
30+
state_->time = time;
31+
state_->monotonic_time = monotonic_time;
32+
}
2933

3034
bool fastcat::DeviceBase::Write(fastcat::DeviceCmd& /* cmd */)
3135
{

src/device_base.h

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <yaml-cpp/yaml.h>
1313

1414
#include "fastcat/types.h"
15+
#include "fastcat/thread_safe_queue.h"
1516

1617
namespace fastcat
1718
{
@@ -20,36 +21,44 @@ class DeviceBase
2021
public:
2122
virtual ~DeviceBase();
2223
// Pure virtual methods
23-
virtual bool ConfigFromYaml(YAML::Node node) = 0;
24-
virtual bool Read() = 0;
24+
virtual bool ConfigFromYaml(const YAML::Node& node) = 0;
25+
virtual bool Read() = 0;
2526

2627
// Non-pure virtual methods with default implementation
2728
virtual FaultType Process();
2829
virtual bool Write(DeviceCmd& cmd);
2930
virtual void Fault();
3031
virtual void Reset();
32+
virtual void SetInitializationTime(double time_sec, double monotonic_time_sec)
33+
{
34+
initialization_time_sec_ = time_sec;
35+
monotonic_initialization_time_sec_ = monotonic_time_sec;
36+
}
3137

3238
// non-virtual methods
33-
void RegisterCmdQueue(std::shared_ptr<std::queue<DeviceCmd>> cmd_queue);
39+
void RegisterCmdQueue(std::shared_ptr<ThreadSafeQueue<DeviceCmd>> cmd_queue);
3440
std::string GetName();
3541
std::shared_ptr<DeviceState> GetState();
3642

37-
void SetTime(double time);
43+
void SetTime(double time, double monotonic_time);
3844
void SetLoopPeriod(double loop_period);
3945

4046
std::vector<Signal> signals_;
4147

4248
protected:
43-
std::string name_; ///< unique device name
44-
double loop_period_ = 0.0; ///< only some devices need
49+
std::string name_; ///< unique device name
50+
51+
double loop_period_ = 0.0; ///< only some devices need
52+
double initialization_time_sec_ = -1; ///< only some devices need
53+
double monotonic_initialization_time_sec_ = -1; ///< only some devices need
4554

4655
/// device-level fault, manager also has fault status flag
4756
bool device_fault_active_ = false;
4857

4958
std::shared_ptr<DeviceState> state_; ///< Fastcat state data
5059

5160
/// for intra-device commands
52-
std::shared_ptr<std::queue<DeviceCmd>> cmd_queue_;
61+
std::shared_ptr<ThreadSafeQueue<DeviceCmd>> cmd_queue_;
5362
};
5463

5564
} // namespace fastcat

src/fastcat_devices/commander.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Commander : public DeviceBase
1414
{
1515
public:
1616
Commander();
17-
bool ConfigFromYaml(YAML::Node node) override;
17+
bool ConfigFromYaml(const YAML::Node& node) override;
1818
bool Read() override;
1919
bool Write(DeviceCmd& cmd) override;
2020
void Fault() override;

src/fastcat_devices/conditional.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fastcat::Conditional::Conditional()
4141
state_->type = CONDITIONAL_STATE;
4242
}
4343

44-
bool fastcat::Conditional::ConfigFromYaml(YAML::Node node)
44+
bool fastcat::Conditional::ConfigFromYaml(const YAML::Node& node)
4545
{
4646
if (!ParseVal(node, "name", name_)) {
4747
return false;

src/fastcat_devices/conditional.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Conditional : public DeviceBase
2626
{
2727
public:
2828
Conditional();
29-
bool ConfigFromYaml(YAML::Node node) override;
29+
bool ConfigFromYaml(const YAML::Node& node) override;
3030
bool Read() override;
3131

3232
protected:

src/fastcat_devices/faulter.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fastcat::Faulter::Faulter()
1515
state_->type = FAULTER_STATE;
1616
}
1717

18-
bool fastcat::Faulter::ConfigFromYaml(YAML::Node node)
18+
bool fastcat::Faulter::ConfigFromYaml(const YAML::Node& node)
1919
{
2020
if (!ParseVal(node, "name", name_)) {
2121
return false;

src/fastcat_devices/faulter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Faulter : public DeviceBase
2424
* device.
2525
* @return True if configuration completes without error; false otherwise.
2626
*/
27-
bool ConfigFromYaml(YAML::Node node) override;
27+
bool ConfigFromYaml(const YAML::Node& node) override;
2828
/**
2929
* @brief Updates device state.
3030
* @return True if device state is read without error; false otherwise.

src/fastcat_devices/filter.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ fastcat::Filter::Filter()
101101
state_->type = FILTER_STATE;
102102
}
103103

104-
bool fastcat::Filter::ConfigFromYaml(YAML::Node node)
104+
bool fastcat::Filter::ConfigFromYaml(const YAML::Node& node)
105105
{
106106
if (!ParseVal(node, "name", name_)) {
107107
return false;

src/fastcat_devices/filter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class Filter : public DeviceBase
4343
{
4444
public:
4545
Filter();
46-
bool ConfigFromYaml(YAML::Node node) override;
46+
bool ConfigFromYaml(const YAML::Node& node) override;
4747
bool Read() override;
4848

4949
protected:

0 commit comments

Comments
 (0)