Skip to content

Commit

Permalink
Added total threat count (from cycling radar) to the summary data.
Browse files Browse the repository at this point in the history
  • Loading branch information
msimms committed Dec 31, 2023
1 parent ce04a98 commit f01afb9
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 0 deletions.
9 changes: 9 additions & 0 deletions Activities/Activity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ Activity::Activity()
m_mostRecentSensorReading.time = 0;
m_mostRecentSensorReading.type = SENSOR_TYPE_UNKNOWN;
m_threatCount = (uint64_t)-1;
m_totalThreatCount = 0;
}

Activity::~Activity()
Expand Down Expand Up @@ -243,6 +244,7 @@ bool Activity::ProcessRadarReading(const SensorReading& reading)
if (reading.reading.count(ACTIVITY_ATTRIBUTE_THREAT_COUNT) > 0)
{
m_threatCount = reading.reading.at(ACTIVITY_ATTRIBUTE_THREAT_COUNT);
m_totalThreatCount += m_threatCount;
}
}
catch (...)
Expand Down Expand Up @@ -442,6 +444,13 @@ ActivityAttributeType Activity::QueryActivityAttribute(const std::string& attrib
result.measureType = MEASURE_COUNT;
result.valid = m_threatCount != (uint64_t)-1;
}
else if (attributeName.compare(ACTIVITY_ATTRIBUTE_TOTAL_THREAT_COUNT) == 0)
{
result.value.intVal = m_totalThreatCount;
result.valueType = TYPE_INTEGER;
result.measureType = MEASURE_COUNT;
result.valid = true;
}
else
{
result.valueType = TYPE_NOT_SET;
Expand Down
1 change: 1 addition & 0 deletions Activities/Activity.h
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ class Activity
SensorReading m_lastAccelReading; // the oldest accelerometer reading received
SensorReading m_mostRecentSensorReading; // the youngest sensor reading received
uint64_t m_threatCount; // threat count, from a radar unit, -1 for not set
uint64_t m_totalThreatCount; // sum of all threat counts, from a radar unit, -1 for not set
};

#endif
1 change: 1 addition & 0 deletions Activities/ActivityAttribute.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,6 @@
#define ACTIVITY_ATTRIBUTE_TOTAL_ASCENT "Total Ascent" //
#define ACTIVITY_ATTRIBUTE_SWIM_STROKES "Swim Strokes" // the number of swim strokes taken
#define ACTIVITY_ATTRIBUTE_THREAT_COUNT "Threat Count" // threat count (as from a rear-facing radar unit)
#define ACTIVITY_ATTRIBUTE_TOTAL_THREAT_COUNT "Total Threat Count" // sum of all threat counts (as from a rear-facing radar unit)

#endif
1 change: 1 addition & 0 deletions Activities/MovingActivity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1487,6 +1487,7 @@ void MovingActivity::BuildSummaryAttributeList(std::vector<std::string>& attribu
attributes.push_back(ACTIVITY_ATTRIBUTE_STARTING_LONGITUDE);
attributes.push_back(ACTIVITY_ATTRIBUTE_BIGGEST_CLIMB);
attributes.push_back(ACTIVITY_ATTRIBUTE_TOTAL_ASCENT);
attributes.push_back(ACTIVITY_ATTRIBUTE_TOTAL_THREAT_COUNT);
attributes.push_back(ACTIVITY_ATTRIBUTE_NUM_LAPS);
Activity::BuildSummaryAttributeList(attributes);
}
Expand Down

0 comments on commit f01afb9

Please sign in to comment.