Skip to content

Commit

Permalink
src/lw_aifw: Add missing AIFW source files
Browse files Browse the repository at this point in the history
framework/src/lw_aifw: Add files missed in previous commit: c340cfe
  • Loading branch information
vibhor-m authored and Taejun-Kwon committed Apr 11, 2023
1 parent c340cfe commit 534abcd
Show file tree
Hide file tree
Showing 8 changed files with 155 additions and 5 deletions.
2 changes: 1 addition & 1 deletion framework/src/lw_aifw/AICSVArrayReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
****************************************************************************/

#include "lw_aifw/lw_aifw_log.h"
#include "lw_aifw/AICSVArrayReader.h"
#include "include/AICSVArrayReader.h"

namespace lw_aifw {

Expand Down
5 changes: 3 additions & 2 deletions framework/src/lw_aifw/AICSVDataSource.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
2 changes: 1 addition & 1 deletion framework/src/lw_aifw/AICSVFileReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion framework/src/lw_aifw/AICSVReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*
****************************************************************************/

#include "lw_aifw/AICSVReader.h"
#include "include/AICSVReader.h"
#include <stdio.h>

namespace lw_aifw {
Expand Down
2 changes: 2 additions & 0 deletions framework/src/lw_aifw/AIServiceCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#include <errno.h>
#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
Expand Down
45 changes: 45 additions & 0 deletions framework/src/lw_aifw/include/AICSVArrayReader.h
Original file line number Diff line number Diff line change
@@ -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 <stdint.h>
#include <stdio.h>
#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 */

62 changes: 62 additions & 0 deletions framework/src/lw_aifw/include/AICSVFileReader.h
Original file line number Diff line number Diff line change
@@ -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 <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <errno.h>
#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 */
40 changes: 40 additions & 0 deletions framework/src/lw_aifw/include/AICSVReader.h
Original file line number Diff line number Diff line change
@@ -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 <stdint.h>
#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 */

0 comments on commit 534abcd

Please sign in to comment.