Renaming class and resources AccelerometerSample -> MovesenseExercise

master
denes 6 years ago
parent 90254c6d18
commit fa3a52a200

@ -1,11 +1,11 @@
#include "AccelerometerSampleService.h" #include "MovesenseExerciseService.h"
#include "movesense.h" #include "movesense.h"
MOVESENSE_APPLICATION_STACKSIZE(1024) MOVESENSE_APPLICATION_STACKSIZE(1024)
MOVESENSE_PROVIDERS_BEGIN(1) MOVESENSE_PROVIDERS_BEGIN(1)
MOVESENSE_PROVIDER_DEF(AccelerometerSampleService) MOVESENSE_PROVIDER_DEF(MovesenseExerciseService)
MOVESENSE_PROVIDERS_END(1) MOVESENSE_PROVIDERS_END(1)
@ -34,7 +34,7 @@ DEBUGSERVICE_BUFFER_SIZE(6, 120); // 6 lines, 120 characters total
DEBUG_EEPROM_MEMORY_AREA(false, 0, 0) DEBUG_EEPROM_MEMORY_AREA(false, 0, 0)
LOGBOOK_MEMORY_AREA(0, 384 * 1024); LOGBOOK_MEMORY_AREA(0, 384 * 1024);
APPINFO_NAME("Sample Accelerometer"); APPINFO_NAME("Movesense Exercise");
APPINFO_VERSION("1.1.0"); APPINFO_VERSION("1.1.0");
APPINFO_COMPANY("Movesense"); APPINFO_COMPANY("Movesense");

@ -1,4 +1,4 @@
#include "AccelerometerSampleService.h" #include "MovesenseExerciseService.h"
#include "app-resources/resources.h" #include "app-resources/resources.h"
#include "common/core/debug.h" #include "common/core/debug.h"
#include "meas_acc/resources.h" #include "meas_acc/resources.h"
@ -7,16 +7,16 @@
#include <float.h> #include <float.h>
#include <math.h> #include <math.h>
const char* const AccelerometerSampleService::LAUNCHABLE_NAME = "SampleA"; const char* const MovesenseExerciseService::LAUNCHABLE_NAME = "SampleA";
#define SAMPLE_RATE 13 #define SAMPLE_RATE 13
static const whiteboard::ExecutionContextId sExecutionContextId = static const whiteboard::ExecutionContextId sExecutionContextId =
WB_RES::LOCAL::SAMPLE_ACCELEROMETER_DATA::EXECUTION_CONTEXT; WB_RES::LOCAL::EXERCISE_SUMVECTOR_DENES::EXECUTION_CONTEXT;
static const whiteboard::LocalResourceId sProviderResources[] = { static const whiteboard::LocalResourceId sProviderResources[] = {
WB_RES::LOCAL::SAMPLE_ACCELEROMETER_DATA::LID, WB_RES::LOCAL::EXERCISE_SUMVECTOR_DENES::LID,
}; };
AccelerometerSampleService::AccelerometerSampleService() MovesenseExerciseService::MovesenseExerciseService()
: ResourceClient(WBDEBUG_NAME(__FUNCTION__), sExecutionContextId), : ResourceClient(WBDEBUG_NAME(__FUNCTION__), sExecutionContextId),
ResourceProvider(WBDEBUG_NAME(__FUNCTION__), sExecutionContextId), ResourceProvider(WBDEBUG_NAME(__FUNCTION__), sExecutionContextId),
LaunchableModule(LAUNCHABLE_NAME, sExecutionContextId), LaunchableModule(LAUNCHABLE_NAME, sExecutionContextId),
@ -24,11 +24,11 @@ AccelerometerSampleService::AccelerometerSampleService()
{ {
} }
AccelerometerSampleService::~AccelerometerSampleService() MovesenseExerciseService::~MovesenseExerciseService()
{ {
} }
bool AccelerometerSampleService::initModule() bool MovesenseExerciseService::initModule()
{ {
if (registerProviderResources(sProviderResources) != whiteboard::HTTP_CODE_OK) if (registerProviderResources(sProviderResources) != whiteboard::HTTP_CODE_OK)
{ {
@ -39,34 +39,34 @@ bool AccelerometerSampleService::initModule()
return true; return true;
} }
void AccelerometerSampleService::deinitModule() void MovesenseExerciseService::deinitModule()
{ {
unregisterProviderResources(sProviderResources); unregisterProviderResources(sProviderResources);
mModuleState = WB_RES::ModuleStateValues::UNINITIALIZED; mModuleState = WB_RES::ModuleStateValues::UNINITIALIZED;
} }
/** @see whiteboard::ILaunchableModule::startModule */ /** @see whiteboard::ILaunchableModule::startModule */
bool AccelerometerSampleService::startModule() bool MovesenseExerciseService::startModule()
{ {
mModuleState = WB_RES::ModuleStateValues::STARTED; mModuleState = WB_RES::ModuleStateValues::STARTED;
return true; return true;
} }
void AccelerometerSampleService::onUnsubscribeResult(whiteboard::RequestId requestId, void MovesenseExerciseService::onUnsubscribeResult(whiteboard::RequestId requestId,
whiteboard::ResourceId resourceId, whiteboard::ResourceId resourceId,
whiteboard::Result resultCode, whiteboard::Result resultCode,
const whiteboard::Value& rResultData) const whiteboard::Value& rResultData)
{ {
DEBUGLOG("AccelerometerSampleService::onUnsubscribeResult() called."); DEBUGLOG("MovesenseExerciseService::onUnsubscribeResult() called.");
} }
void AccelerometerSampleService::onSubscribeResult(whiteboard::RequestId requestId, void MovesenseExerciseService::onSubscribeResult(whiteboard::RequestId requestId,
whiteboard::ResourceId resourceId, whiteboard::ResourceId resourceId,
whiteboard::Result resultCode, whiteboard::Result resultCode,
const whiteboard::Value& rResultData) const whiteboard::Value& rResultData)
{ {
DEBUGLOG("AccelerometerSampleService::onSubscribeResult() called. resourceId: %u, result: %d", resourceId.localResourceId, (uint32_t)resultCode); DEBUGLOG("MovesenseExerciseService::onSubscribeResult() called. resourceId: %u, result: %d", resourceId.localResourceId, (uint32_t)resultCode);
whiteboard::Request relatedIncomingRequest; whiteboard::Request relatedIncomingRequest;
bool relatedRequestFound = mOngoingRequests.get(requestId, relatedIncomingRequest); bool relatedRequestFound = mOngoingRequests.get(requestId, relatedIncomingRequest);
@ -77,14 +77,14 @@ void AccelerometerSampleService::onSubscribeResult(whiteboard::RequestId request
} }
} }
whiteboard::Result AccelerometerSampleService::startRunning(whiteboard::RequestId& remoteRequestId) whiteboard::Result MovesenseExerciseService::startRunning(whiteboard::RequestId& remoteRequestId)
{ {
if (isRunning) if (isRunning)
{ {
return whiteboard::HTTP_CODE_OK; return whiteboard::HTTP_CODE_OK;
} }
DEBUGLOG("AccelerometerSampleService::startRunning()"); DEBUGLOG("MovesenseExerciseService::startRunning()");
// Reset max acceleration members // Reset max acceleration members
mMaxAccelerationSq = FLT_MIN; mMaxAccelerationSq = FLT_MIN;
@ -108,20 +108,20 @@ whiteboard::Result AccelerometerSampleService::startRunning(whiteboard::RequestI
return whiteboard::HTTP_CODE_OK; return whiteboard::HTTP_CODE_OK;
} }
whiteboard::Result AccelerometerSampleService::stopRunning() whiteboard::Result MovesenseExerciseService::stopRunning()
{ {
if (!isRunning) if (!isRunning)
{ {
return whiteboard::HTTP_CODE_OK; return whiteboard::HTTP_CODE_OK;
} }
if (isResourceSubscribed(WB_RES::LOCAL::SAMPLE_ACCELEROMETER_DATA::ID) == wb::HTTP_CODE_OK) if (isResourceSubscribed(WB_RES::LOCAL::EXERCISE_SUMVECTOR_DENES::ID) == wb::HTTP_CODE_OK)
{ {
DEBUGLOG("AccelerometerSampleService::stopRunning() skipping. Subscribers still exist."); DEBUGLOG("MovesenseExerciseService::stopRunning() skipping. Subscribers still exist.");
return whiteboard::HTTP_CODE_OK; return whiteboard::HTTP_CODE_OK;
} }
DEBUGLOG("AccelerometerSampleService::stopRunning()"); DEBUGLOG("MovesenseExerciseService::stopRunning()");
// Unsubscribe the LinearAcceleration resource, when unsubscribe is done, we get callback // Unsubscribe the LinearAcceleration resource, when unsubscribe is done, we get callback
wb::Result result = asyncUnsubscribe(mMeasAccResourceId, NULL); wb::Result result = asyncUnsubscribe(mMeasAccResourceId, NULL);
@ -136,7 +136,7 @@ whiteboard::Result AccelerometerSampleService::stopRunning()
} }
// This callback is called when the resource we have subscribed notifies us // This callback is called when the resource we have subscribed notifies us
void AccelerometerSampleService::onNotify(whiteboard::ResourceId resourceId, const whiteboard::Value& value, void MovesenseExerciseService::onNotify(whiteboard::ResourceId resourceId, const whiteboard::Value& value,
const whiteboard::ParameterList& parameters) const whiteboard::ParameterList& parameters)
{ {
DEBUGLOG("onNotify() called."); DEBUGLOG("onNotify() called.");
@ -185,7 +185,7 @@ void AccelerometerSampleService::onNotify(whiteboard::ResourceId resourceId, con
mMaxAccelerationSq = FLT_MIN; mMaxAccelerationSq = FLT_MIN;
// and update our WB resource. This causes notification to be fired to our subscribers // and update our WB resource. This causes notification to be fired to our subscribers
updateResource(WB_RES::LOCAL::SAMPLE_ACCELEROMETER_DATA(), updateResource(WB_RES::LOCAL::EXERCISE_SUMVECTOR_DENES(),
ResponseOptions::Empty, sampleDataValue); ResponseOptions::Empty, sampleDataValue);
} }
} }
@ -193,12 +193,12 @@ void AccelerometerSampleService::onNotify(whiteboard::ResourceId resourceId, con
} }
} }
void AccelerometerSampleService::onSubscribe(const whiteboard::Request& request, void MovesenseExerciseService::onSubscribe(const whiteboard::Request& request,
const whiteboard::ParameterList& parameters) const whiteboard::ParameterList& parameters)
{ {
switch (request.getResourceConstId()) switch (request.getResourceConstId())
{ {
case WB_RES::LOCAL::SAMPLE_ACCELEROMETER_DATA::ID: case WB_RES::LOCAL::EXERCISE_SUMVECTOR_DENES::ID:
{ {
// Someone subscribed to our service. Start collecting data and notifying when our service changes state (every 10 seconds) // Someone subscribed to our service. Start collecting data and notifying when our service changes state (every 10 seconds)
whiteboard::RequestId remoteRequestId; whiteboard::RequestId remoteRequestId;
@ -223,12 +223,12 @@ void AccelerometerSampleService::onSubscribe(const whiteboard::Request& request,
} }
} }
void AccelerometerSampleService::onUnsubscribe(const whiteboard::Request& request, void MovesenseExerciseService::onUnsubscribe(const whiteboard::Request& request,
const whiteboard::ParameterList& parameters) const whiteboard::ParameterList& parameters)
{ {
switch (request.getResourceConstId()) switch (request.getResourceConstId())
{ {
case WB_RES::LOCAL::SAMPLE_ACCELEROMETER_DATA::ID: case WB_RES::LOCAL::EXERCISE_SUMVECTOR_DENES::ID:
stopRunning(); stopRunning();
returnResult(request, wb::HTTP_CODE_OK); returnResult(request, wb::HTTP_CODE_OK);
break; break;
@ -239,14 +239,14 @@ void AccelerometerSampleService::onUnsubscribe(const whiteboard::Request& reques
} }
} }
void AccelerometerSampleService::onRemoteWhiteboardDisconnected(whiteboard::WhiteboardId whiteboardId) void MovesenseExerciseService::onRemoteWhiteboardDisconnected(whiteboard::WhiteboardId whiteboardId)
{ {
DEBUGLOG("AccelerometerSampleService::onRemoteWhiteboardDisconnected()"); DEBUGLOG("MovesenseExerciseService::onRemoteWhiteboardDisconnected()");
stopRunning(); stopRunning();
} }
void AccelerometerSampleService::onClientUnavailable(whiteboard::ClientId clientId) void MovesenseExerciseService::onClientUnavailable(whiteboard::ClientId clientId)
{ {
DEBUGLOG("AccelerometerSampleService::onClientUnavailable()"); DEBUGLOG("MovesenseExerciseService::onClientUnavailable()");
stopRunning(); stopRunning();
} }

@ -7,16 +7,16 @@
#include "wb-resources/resources.h" #include "wb-resources/resources.h"
class AccelerometerSampleService FINAL : private whiteboard::ResourceClient, class MovesenseExerciseService FINAL : private whiteboard::ResourceClient,
private whiteboard::ResourceProvider, private whiteboard::ResourceProvider,
public whiteboard::LaunchableModule public whiteboard::LaunchableModule
{ {
public: public:
/** Name of this class. Used in StartupProvider list. */ /** Name of this class. Used in StartupProvider list. */
static const char* const LAUNCHABLE_NAME; static const char* const LAUNCHABLE_NAME;
AccelerometerSampleService(); MovesenseExerciseService();
~AccelerometerSampleService(); ~MovesenseExerciseService();
private: private:
/** @see whiteboard::ILaunchableModule::initModule */ /** @see whiteboard::ILaunchableModule::initModule */

@ -21,6 +21,6 @@ executionContexts:
apis: apis:
AccelerometerSample.*: MovesenseExercise.*:
apiId: 100 apiId: 100
defaultExecutionContext: meas defaultExecutionContext: meas

@ -5,9 +5,9 @@ swagger: '2.0'
# Document metadata # Document metadata
info: info:
version: "0.0.0" version: "0.0.0"
title: Movesense Accelerometer sample app API title: Movesense Exercise app API
description: | description: |
This file defines API for Movesense Accelerometer Sample service This file defines API for Movesense Exercise service
See http://movesense.com for more information. See http://movesense.com for more information.
termsOfService: http://suunto.com/wbapi/terms/ termsOfService: http://suunto.com/wbapi/terms/
@ -17,7 +17,7 @@ info:
# Paths # Paths
paths: paths:
/Sample/Accelerometer/Data/Subscription: /Exercise/Sumvector/Denes/Subscription:
post: post:
description: | description: |
Subscribe to periodic Data values. Subscribe to periodic Data values.
Loading…
Cancel
Save