From ddebe3bbad7fac9e47527aa576bdd355fee80593 Mon Sep 17 00:00:00 2001 From: liushijiu6699 Date: Wed, 19 May 2021 17:08:02 +0800 Subject: [PATCH] seperate common data define Change-Id: Ia5ba7f9e658904efedfc599cf851570a730698eb --- interfaces/kits/ai_callback.h | 31 ++++--------------- interfaces/kits/ai_retcode.h | 30 +++++++++--------- interfaces/kits/cv/ai_image.h | 2 -- .../kits/cv/card_rectification/cr_callback.h | 15 ++++----- .../kits/cv/card_rectification/cr_constants.h | 12 +++---- .../kits/cv/card_rectification/cr_sdk.h | 26 +++++++--------- .../aie_client_reliability_test.cpp | 20 ++++++------ 7 files changed, 57 insertions(+), 79 deletions(-) diff --git a/interfaces/kits/ai_callback.h b/interfaces/kits/ai_callback.h index 1a9c372..46ed02a 100644 --- a/interfaces/kits/ai_callback.h +++ b/interfaces/kits/ai_callback.h @@ -13,27 +13,8 @@ * limitations under the License. */ -/** - * @addtogroup cr_sdk - * @{ - * - * @brief Defines the development tool functions, constants, and error codes for card rectification (CR). - * - * @since 1.0 - * @version 1.0 - */ - -/** - * @file cr_callback.h - * - * @brief Defines the callback for processing errors and prediction results of card rectification. - * - * @since 1.0 - * @version 1.0 - */ - -#ifndef CR_CALLBACK_H -#define CR_CALLBACK_H +#ifndef AI_CALLBACK_H +#define AI_CALLBACK_H namespace OHOS { namespace AI { @@ -43,7 +24,7 @@ public: /** * @brief Defines the destructor for the callback. * - * @since 1.0 + * @since 2.2 * @version 1.0 */ virtual ~ICallback() = default; @@ -53,7 +34,7 @@ public: * * @param result Indicates the prediction result. * - * @since 1.0 + * @since 2.2 * @version 1.0 */ virtual void OnDetectedResult(const int resultCode, const T &result) = 0; @@ -61,5 +42,5 @@ public: } // namespace AI } // namespace OHOS -#endif // CR_CALLBACK_H -/** @} */ \ No newline at end of file +#endif // AI_CALLBACK_H +/** @} */ diff --git a/interfaces/kits/ai_retcode.h b/interfaces/kits/ai_retcode.h index 974afcb..53faa30 100755 --- a/interfaces/kits/ai_retcode.h +++ b/interfaces/kits/ai_retcode.h @@ -16,20 +16,22 @@ #ifndef AI_RETCODE_H #define AI_RETCODE_H +/** + * Error code used to communicate between plugin SDK and apps. + */ typedef enum { - AI_RETCODE_SUCCESS = 0, - AI_RETCODE_FAILURE = -1 + AI_RETCODE_SUCCESS = 0, /** Return code for an operation success */ + AI_RETCODE_FAILURE = -1, /** Return code for an operation failure */ + + AI_RETCODE_INIT_ERROR = 1001, /** Return code for an initialization error */ + AI_RETCODE_NULL_PARAM = 1002, /** Return code for a null parameter error */ + AI_RETCODE_DUPLICATE_INIT_ERROR = 1004, /** Return code for a duplicate initialization error */ + + AI_RETCODE_SERIALIZATION_ERROR = 2001, /** Return code for a serialization error */ + AI_RETCODE_UNSERIALIZATION_ERROR = 2002, /** Return code for a deserialization error */ + + AI_RETCODE_PLUGIN_EXECUTION_ERROR = 3001, /** Return code for a plugin execution error */ + AI_RETCODE_PLUGIN_SESSION_ERROR = 3002, /** Return code for a plugin session error */ } AiRetCode; -typedef enum { - PLUGIN_RETCODE_FAILURE = -1, /** Return code for an operation failure */ - PLUGIN_RETCODE_SUCCESS = 0, /** Return code for an operation success */ - PLUGIN_RETCODE_INIT_ERROR = 1001, /** Return code for an initialization error */ - PLUGIN_RETCODE_NULL_PARAM = 1002, /** Return code for a null parameter error */ - PLUGIN_RETCODE_DUPLICATE_INIT_ERROR = 1004, /** Return code for a duplicate initialization error */ - PLUGIN_RETCODE_SERIALIZATION_ERROR = 2001, /** Return code for a serialization error */ - PLUGIN_RETCODE_UNSERIALIZATION_ERROR = 2002, /** Return code for a deserialization error */ - PLUGIN_RETCODE_PLUGIN_EXECUTION_ERROR = 3001, /** Return code for a plugin execution error */ - PLUGIN_RETCODE_PLUGIN_SESSION_ERROR = 3002, /** Return code for a plugin session error */ -} PluginRetCode; -#endif // AI_RETCODE_H \ No newline at end of file +#endif // AI_RETCODE_H diff --git a/interfaces/kits/cv/ai_image.h b/interfaces/kits/cv/ai_image.h index 9d7cdbc..1cdb7d2 100644 --- a/interfaces/kits/cv/ai_image.h +++ b/interfaces/kits/cv/ai_image.h @@ -18,8 +18,6 @@ #include #include -#include -#include namespace OHOS { namespace AI { diff --git a/interfaces/kits/cv/card_rectification/cr_callback.h b/interfaces/kits/cv/card_rectification/cr_callback.h index 4eb6635..02c13a9 100644 --- a/interfaces/kits/cv/card_rectification/cr_callback.h +++ b/interfaces/kits/cv/card_rectification/cr_callback.h @@ -19,7 +19,7 @@ * * @brief Defines the development tool functions, constants, and error codes for card rectification (CR). * - * @since 1.0 + * @since 2.2 * @version 1.0 */ @@ -28,7 +28,7 @@ * * @brief Defines the callback for processing errors and prediction results of card rectification. * - * @since 1.0 + * @since 2.2 * @version 1.0 */ @@ -36,17 +36,18 @@ #define CR_CALLBACK_H #include "cr_constants.h" -#include "cr_retcode.h" +#include "kits/ai_retcode.h" +#include "kits/ai_callback.h" namespace OHOS { namespace AI { template<> -class ICallback { +class ICallback { public: /** * @brief Defines the destructor for the callback. * - * @since 1.0 + * @since 2.2 * @version 1.0 */ virtual ~ICallback() = default; @@ -56,7 +57,7 @@ public: * * @param result Indicates the prediction result. * - * @since 1.0 + * @since 2.2 * @version 1.0 */ virtual void OnDetectedResult(const int resultCode, const RectifyCardOutput &result) = 0; @@ -65,4 +66,4 @@ public: } // namespace OHOS #endif // CR_CALLBACK_H -/** @} */ \ No newline at end of file +/** @} */ diff --git a/interfaces/kits/cv/card_rectification/cr_constants.h b/interfaces/kits/cv/card_rectification/cr_constants.h index 2379bb4..1c841e1 100644 --- a/interfaces/kits/cv/card_rectification/cr_constants.h +++ b/interfaces/kits/cv/card_rectification/cr_constants.h @@ -19,7 +19,7 @@ * * @brief Defines the development tool functions, constants and error codes for card rectification (CR). * - * @since 1.0 + * @since 2.2 * @version 1.0 */ @@ -28,17 +28,15 @@ * * @brief Defines the constants and, input and output formats for calling the card rectification plugin. * - * @since 1.0 + * @since 2.2 * @version 1.0 */ #ifndef CR_CONSTANTS_H #define CR_CONSTANTS_H -#include "cv/ai_image.h" +#include "kits/cv/ai_image.h" -#include -#include #include #include @@ -49,7 +47,7 @@ namespace AI { * * it must match related_sessions in services/common/protocol/plugin_config/plugin_config_ini/cv_card_rectification.ini * - * @since 1.0 + * @since 2.2 * @version 1.0 */ const long long ALGORITHM_TYPE_VERSION_CR = 20001001; @@ -70,4 +68,4 @@ typedef struct { } // namespace OHOS #endif // CR_CONSTANTS_H -/** @} */ \ No newline at end of file +/** @} */ diff --git a/interfaces/kits/cv/card_rectification/cr_sdk.h b/interfaces/kits/cv/card_rectification/cr_sdk.h index 1ae1512..fd709ea 100644 --- a/interfaces/kits/cv/card_rectification/cr_sdk.h +++ b/interfaces/kits/cv/card_rectification/cr_sdk.h @@ -19,7 +19,7 @@ * * @brief Defines the development tool functions, constants, and error codes for card rectification (CR). * - * @since 1.0 + * @since 2.2 * @version 1.0 */ @@ -28,15 +28,13 @@ * * @brief Defines the development tool functions for card rectification. * - * @since 1.0 + * @since 2.2 * @version 1.0 */ #ifndef CR_SDK_H #define CR_SDK_H -#include - #include "cr_callback.h" #include "cr_constants.h" @@ -52,9 +50,9 @@ public: * @brief Establishes a connection from the development tool to the AI server. * * @return Returns {@link CR_RETCODE_SUCCESS} if the operation is successful; - * returns a non-zero error code defined by {@link CrRetCode} otherwise. + * returns a non-zero error code defined by {@link PluginRetCode} otherwise. * - * @since 1.0 + * @since 2.2 * @version 1.0 */ int32_t Prepare(); @@ -65,9 +63,9 @@ public: * @param [in] input Indicates the input image. * @param [out] output Indicates the result. * @return Returns {@link CR_RETCODE_SUCCESS} if the operation is successful; - * returns a non-zero error code defined by {@link CrRetCode} otherwise. + * returns a non-zero error code defined by {@link PluginRetCode} otherwise. * - * @since 1.0 + * @since 2.2 * @version 1.0 */ int32_t RectifyCardSync(const RectifyCardInput &input, RectifyCardOutput &output); @@ -78,20 +76,20 @@ public: * @param [in] input Indicates the input image. * @param [in] callback Indicates the specified callback. * @return Returns {@link CR_RETCODE_SUCCESS} if the operation is successful; - * returns a non-zero error code defined by {@link CrRetCode} otherwise. + * returns a non-zero error code defined by {@link PluginRetCode} otherwise. * - * @since 1.0 + * @since 2.2 * @version 1.0 */ - int32_t RectifyCardAsync(const RectifyCardInput &input, const ICallback &callback); + int32_t RectifyCardAsync(const RectifyCardInput &input, const ICallback &callback); /** * @brief Destroys the loaded model and related resources. * * @return Returns {@link CR_RETCODE_SUCCESS} if the operation is successful; - * returns a non-zero error code defined by {@link CrRetCode} otherwise. + * returns a non-zero error code defined by {@link PluginRetCode} otherwise. * - * @since 1.0 + * @since 2.2 * @version 1.0 */ int32_t Release(); @@ -100,4 +98,4 @@ public: } // namespace OHOS #endif // CR_SDK_H -/** @} */ \ No newline at end of file +/** @} */ diff --git a/test/performance/reliability/aie_client/aie_client_reliability_test.cpp b/test/performance/reliability/aie_client/aie_client_reliability_test.cpp index 06ef328..392eb10 100644 --- a/test/performance/reliability/aie_client/aie_client_reliability_test.cpp +++ b/test/performance/reliability/aie_client/aie_client_reliability_test.cpp @@ -131,23 +131,23 @@ HWTEST_F(AieClientReliabilityTest, AieClientSyncReliabilityTest001, TestSize.Lev ServiceDeadCb cb; int resultCode = AieClientInit(configInfo, clientInfo, algoInfo, &cb); - EXPECT_EQ(resultCode, AI_RETCODE_SUCCESS); + EXPECT_EQ(resultCode, RETCODE_SUCCESS); DataInfo outputInfo; resultCode = AieClientPrepare(clientInfo, algoInfo, inputInfo, outputInfo, nullptr); FreeDataInfo(outputInfo); - EXPECT_EQ(resultCode, AI_RETCODE_SUCCESS); + EXPECT_EQ(resultCode, RETCODE_SUCCESS); resultCode = AieClientSyncProcess(clientInfo, algoInfo, inputInfo, outputInfo); FreeDataInfo(outputInfo); - EXPECT_EQ(resultCode, AI_RETCODE_SUCCESS); + EXPECT_EQ(resultCode, RETCODE_SUCCESS); resultCode = AieClientRelease(clientInfo, algoInfo, inputInfo); - EXPECT_EQ(resultCode, AI_RETCODE_SUCCESS); + EXPECT_EQ(resultCode, RETCODE_SUCCESS); resultCode = AieClientDestroy(clientInfo); - EXPECT_EQ(resultCode, AI_RETCODE_SUCCESS); + EXPECT_EQ(resultCode, RETCODE_SUCCESS); time_t currentTime = GetCurTimeSec(); if ((currentTime - asyncStart) >= TIME_TEST) { @@ -203,24 +203,24 @@ HWTEST_F(AieClientReliabilityTest, AieClientAsyncReliabilityTest001, TestSize.Le ServiceDeadCb cb; int resultCode = AieClientInit(configInfo, clientInfo, algoInfo, &cb); - EXPECT_EQ(resultCode, AI_RETCODE_SUCCESS); + EXPECT_EQ(resultCode, RETCODE_SUCCESS); ClientCallback callback; DataInfo outputInfo; resultCode = AieClientPrepare(clientInfo, algoInfo, inputInfo, outputInfo, &callback); FreeDataInfo(outputInfo); - EXPECT_EQ(resultCode, AI_RETCODE_SUCCESS); + EXPECT_EQ(resultCode, RETCODE_SUCCESS); resultCode = AieClientAsyncProcess(clientInfo, algoInfo, inputInfo); - EXPECT_EQ(resultCode, AI_RETCODE_SUCCESS); + EXPECT_EQ(resultCode, RETCODE_SUCCESS); StepSleepMs(500); resultCode = AieClientRelease(clientInfo, algoInfo, inputInfo); - EXPECT_EQ(resultCode, AI_RETCODE_SUCCESS); + EXPECT_EQ(resultCode, RETCODE_SUCCESS); resultCode = AieClientDestroy(clientInfo); - EXPECT_EQ(resultCode, AI_RETCODE_SUCCESS); + EXPECT_EQ(resultCode, RETCODE_SUCCESS); time_t currentTime = GetCurTimeSec(); if ((currentTime - asyncStart) >= TIME_TEST) {