From 534abcd330a82c5ab0c66ef0778a6c43008dee7e Mon Sep 17 00:00:00 2001 From: Vibhor Mahajan Date: Tue, 11 Apr 2023 14:01:19 +0530 Subject: [PATCH] src/lw_aifw: Add missing AIFW source files framework/src/lw_aifw: Add files missed in previous commit: c340cfed5ef189f0114ee75291e841ea985d0479 --- framework/src/lw_aifw/AICSVArrayReader.cpp | 2 +- framework/src/lw_aifw/AICSVDataSource.cpp | 5 +- framework/src/lw_aifw/AICSVFileReader.cpp | 2 +- framework/src/lw_aifw/AICSVReader.cpp | 2 +- framework/src/lw_aifw/AIServiceCore.cpp | 2 + .../src/lw_aifw/include/AICSVArrayReader.h | 45 ++++++++++++++ .../src/lw_aifw/include/AICSVFileReader.h | 62 +++++++++++++++++++ framework/src/lw_aifw/include/AICSVReader.h | 40 ++++++++++++ 8 files changed, 155 insertions(+), 5 deletions(-) create mode 100644 framework/src/lw_aifw/include/AICSVArrayReader.h create mode 100644 framework/src/lw_aifw/include/AICSVFileReader.h create mode 100644 framework/src/lw_aifw/include/AICSVReader.h diff --git a/framework/src/lw_aifw/AICSVArrayReader.cpp b/framework/src/lw_aifw/AICSVArrayReader.cpp index 19fd9ffef8..7fe03386de 100644 --- a/framework/src/lw_aifw/AICSVArrayReader.cpp +++ b/framework/src/lw_aifw/AICSVArrayReader.cpp @@ -17,7 +17,7 @@ ****************************************************************************/ #include "lw_aifw/lw_aifw_log.h" -#include "lw_aifw/AICSVArrayReader.h" +#include "include/AICSVArrayReader.h" namespace lw_aifw { diff --git a/framework/src/lw_aifw/AICSVDataSource.cpp b/framework/src/lw_aifw/AICSVDataSource.cpp index d54bd7dd68..83e1515870 100644 --- a/framework/src/lw_aifw/AICSVDataSource.cpp +++ b/framework/src/lw_aifw/AICSVDataSource.cpp @@ -18,8 +18,9 @@ #include "lw_aifw/AICSVDataSource.h" #include "lw_aifw/lw_aifw_log.h" -#include "lw_aifw/AICSVFileReader.h" -#include "lw_aifw/AICSVArrayReader.h" +#include "include/AICSVReader.h" +#include "include/AICSVFileReader.h" +#include "include/AICSVArrayReader.h" namespace lw_aifw { diff --git a/framework/src/lw_aifw/AICSVFileReader.cpp b/framework/src/lw_aifw/AICSVFileReader.cpp index 0b2c74274d..e2033cf83f 100644 --- a/framework/src/lw_aifw/AICSVFileReader.cpp +++ b/framework/src/lw_aifw/AICSVFileReader.cpp @@ -17,7 +17,7 @@ ****************************************************************************/ #include "lw_aifw/lw_aifw_log.h" -#include "lw_aifw/AICSVFileReader.h" +#include "include/AICSVFileReader.h" //#define CSVREADER_DEBUG 1 namespace lw_aifw { diff --git a/framework/src/lw_aifw/AICSVReader.cpp b/framework/src/lw_aifw/AICSVReader.cpp index 0d978e810f..db4b56c224 100644 --- a/framework/src/lw_aifw/AICSVReader.cpp +++ b/framework/src/lw_aifw/AICSVReader.cpp @@ -16,7 +16,7 @@ * ****************************************************************************/ -#include "lw_aifw/AICSVReader.h" +#include "include/AICSVReader.h" #include namespace lw_aifw { diff --git a/framework/src/lw_aifw/AIServiceCore.cpp b/framework/src/lw_aifw/AIServiceCore.cpp index 9281024a3d..39a053821f 100644 --- a/framework/src/lw_aifw/AIServiceCore.cpp +++ b/framework/src/lw_aifw/AIServiceCore.cpp @@ -22,6 +22,8 @@ #include #include "lw_aifw/lw_aifw_log.h" #include "lw_aifw/AIServiceCore.h" +#include "include/AIDataBuffer.h" +#include "include/AIModel.h" #ifndef CONFIG_LW_AIFW_MODEL_MEM_POOL_SIZE #define LW_AIFW_MODEL_MEM_POOL_SIZE 4096 diff --git a/framework/src/lw_aifw/include/AICSVArrayReader.h b/framework/src/lw_aifw/include/AICSVArrayReader.h new file mode 100644 index 0000000000..9ee4e4ed46 --- /dev/null +++ b/framework/src/lw_aifw/include/AICSVArrayReader.h @@ -0,0 +1,45 @@ +/**************************************************************************** + * + * Copyright 2023 Samsung Electronics All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the License. + * + ****************************************************************************/ + +#pragma once +#include +#include +#include "lw_aifw/lw_aifw_result.h" +#include "AICSVReader.h" + +namespace lw_aifw { + + class AICSVArrayReader : public AICSVReader { + private: + char *m_Header; + uint16_t m_SensorLength; + float *m_DataValues; + int m_SensorCount; + uint16_t m_RowCount; + uint16_t m_RowOffset; + LW_AIFW_RESULT read(float *&values, uint16_t &numberofValues); + public: + AICSVArrayReader(float *datavalues, uint16_t sensorCount, uint16_t rowCount); + ~AICSVArrayReader(); + LW_AIFW_RESULT init(void); + LW_AIFW_RESULT getSourceData(void); + uint16_t getSensorCount(void) const; + }; + +} /* lw_aifw */ + diff --git a/framework/src/lw_aifw/include/AICSVFileReader.h b/framework/src/lw_aifw/include/AICSVFileReader.h new file mode 100644 index 0000000000..e8a16f1b91 --- /dev/null +++ b/framework/src/lw_aifw/include/AICSVFileReader.h @@ -0,0 +1,62 @@ +/**************************************************************************** + * + * Copyright 2023 Samsung Electronics All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the License. + * + ****************************************************************************/ + +#ifdef CONFIG_LW_AIFW_READ_FROM_FS + +#pragma once +#include +#include +#include +#include +#include "lw_aifw/lw_aifw_result.h" +#include "AICSVReader.h" + +#define LINESIZE 256 +#define MAX_FIELDS 30 +#define MAX_PARAMSIZE 32 + +namespace lw_aifw { + + class AICSVFileReader: public AICSVReader { + private: + const char *mFileName; + char mLine[LINESIZE + 1]; + char mParams[MAX_FIELDS + 1][MAX_PARAMSIZE + 1]; + int mLineNumber; + int mTotalColumns; + FILE *mFile; + fpos_t mPosition; + char *skipSpace(char *ptr); + char *copyParam(char *src, char *dest); + char *findParam(char *ptr); + char *getParam(unsigned int field); + int getCurrentLineNo(void); + char *getLine(void); + LW_AIFW_RESULT readLine(void); + int parseCSVLine(char *ptr); + public: + AICSVFileReader(const char *filename); + ~AICSVFileReader(); + LW_AIFW_RESULT init(void); + int getTotalColumns(void); + LW_AIFW_RESULT getSourceData(void); + }; + +} /* lw_aifw */ + +#endif /* CONFIG_LW_AIFW_READ_FROM_FS */ diff --git a/framework/src/lw_aifw/include/AICSVReader.h b/framework/src/lw_aifw/include/AICSVReader.h new file mode 100644 index 0000000000..e1469dc744 --- /dev/null +++ b/framework/src/lw_aifw/include/AICSVReader.h @@ -0,0 +1,40 @@ +/**************************************************************************** + * + * Copyright 2023 Samsung Electronics All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, + * either express or implied. See the License for the specific + * language governing permissions and limitations under the License. + * + ****************************************************************************/ + +#pragma once + +#include +#include "lw_aifw/lw_aifw_result.h" + +namespace lw_aifw { + typedef void (*rawDataCollectedListener)(LW_AIFW_RESULT result, float *data, uint16_t dataCount, void *args); + + class AICSVReader { + protected: + rawDataCollectedListener mRawDataCollectedListener; + /* ToDo: plan to use std::function & remove mRawDataCollectedCBArgs */ + void *mRawDataCollectedCBArgs; + public: + AICSVReader(); + virtual ~AICSVReader(); + virtual void setRawDataCollectedListener(rawDataCollectedListener listener, void *calbackFuncArgs); + virtual LW_AIFW_RESULT init(void) = 0; + virtual LW_AIFW_RESULT getSourceData(void) = 0; + }; + +} /* lw_aifw */