Backup:save file function.
This commit is contained in:
parent
e7659d197d
commit
d8f7e2c076
|
@ -4,8 +4,9 @@ set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${MIDDLEWARE_S
|
||||||
set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${MIDDLEWARE_SOURCE_PATH}/McuManager/include")
|
set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${MIDDLEWARE_SOURCE_PATH}/McuManager/include")
|
||||||
set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${MIDDLEWARE_SOURCE_PATH}/AppManager/include")
|
set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${MIDDLEWARE_SOURCE_PATH}/AppManager/include")
|
||||||
set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${MIDDLEWARE_SOURCE_PATH}/MediaManager/include")
|
set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${MIDDLEWARE_SOURCE_PATH}/MediaManager/include")
|
||||||
|
set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${MIDDLEWARE_SOURCE_PATH}/FilesManager/include")
|
||||||
set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${UTILS_SOURCE_PATH}/StatusCode/include")
|
set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${UTILS_SOURCE_PATH}/StatusCode/include")
|
||||||
set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${UTILS_SOURCE_PATH}/Log/include")
|
set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${UTILS_SOURCE_PATH}/Log/include")
|
||||||
set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${HAL_SOURCE_PATH}/include")
|
set(HUNTTING_MAIN_INCLUDE_PATH "${HUNTTING_MAIN_INCLUDE_PATH};${HAL_SOURCE_PATH}/include")
|
||||||
|
|
||||||
set(HUNTTING_LINK_LIB McuManager MissionManager StateMachine AppManager StatusCode Log Hal pthread dl)
|
set(HUNTTING_LINK_LIB McuManager MissionManager StateMachine AppManager FilesManager StatusCode Log Hal pthread dl)
|
|
@ -14,6 +14,7 @@
|
||||||
*/
|
*/
|
||||||
#include "MainThread.h"
|
#include "MainThread.h"
|
||||||
#include "IAppManager.h"
|
#include "IAppManager.h"
|
||||||
|
#include "IFilesManager.h"
|
||||||
#include "IHalCpp.h"
|
#include "IHalCpp.h"
|
||||||
#include "ILog.h"
|
#include "ILog.h"
|
||||||
#include "IMcuManager.h"
|
#include "IMcuManager.h"
|
||||||
|
@ -80,6 +81,7 @@ StatusCode MainThread::CreateAllModules(void)
|
||||||
{
|
{
|
||||||
CreateHalCppModule();
|
CreateHalCppModule();
|
||||||
CreateMcuManager();
|
CreateMcuManager();
|
||||||
|
CreateFilesManagerModule();
|
||||||
CreateMissionManagerModule();
|
CreateMissionManagerModule();
|
||||||
CreateStateMachine();
|
CreateStateMachine();
|
||||||
CreateAppManagerModule();
|
CreateAppManagerModule();
|
||||||
|
@ -92,6 +94,7 @@ void MainThread::DestoryAllModules(void)
|
||||||
DestroyAppManagerModule();
|
DestroyAppManagerModule();
|
||||||
DestroyStateMachine();
|
DestroyStateMachine();
|
||||||
DestroyMissionManagerModule();
|
DestroyMissionManagerModule();
|
||||||
|
DestroyFilesManagerModule();
|
||||||
DestroyMcuManager();
|
DestroyMcuManager();
|
||||||
DestroyHalCppModule();
|
DestroyHalCppModule();
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,6 +12,8 @@ include_directories(
|
||||||
${MIDDLEWARE_SOURCE_PATH}/StateMachine/include
|
${MIDDLEWARE_SOURCE_PATH}/StateMachine/include
|
||||||
${MIDDLEWARE_SOURCE_PATH}/AppManager/include
|
${MIDDLEWARE_SOURCE_PATH}/AppManager/include
|
||||||
${MIDDLEWARE_SOURCE_PATH}/MediaManager/include
|
${MIDDLEWARE_SOURCE_PATH}/MediaManager/include
|
||||||
|
${MIDDLEWARE_SOURCE_PATH}/FilesManager/include
|
||||||
|
${MIDDLEWARE_SOURCE_PATH}/StorageManager/include
|
||||||
${MIDDLEWARE_SOURCE_PATH}/McuManager/include
|
${MIDDLEWARE_SOURCE_PATH}/McuManager/include
|
||||||
${MIDDLEWARE_SOURCE_PATH}/McuAskBase/include
|
${MIDDLEWARE_SOURCE_PATH}/McuAskBase/include
|
||||||
)
|
)
|
||||||
|
@ -24,7 +26,7 @@ aux_source_directory(./src SRC_FILES)
|
||||||
set(TARGET_NAME MissionManager)
|
set(TARGET_NAME MissionManager)
|
||||||
add_library(${TARGET_NAME} STATIC ${SRC_FILES})
|
add_library(${TARGET_NAME} STATIC ${SRC_FILES})
|
||||||
|
|
||||||
target_link_libraries(${TARGET_NAME} McuAskBase StateMachine MediaManager StatusCode Log)
|
target_link_libraries(${TARGET_NAME} McuAskBase StateMachine MediaManager StorageManager StatusCode Log)
|
||||||
|
|
||||||
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
|
if ("${COMPILE_IMPROVE_SUPPORT}" MATCHES "true")
|
||||||
add_custom_target(
|
add_custom_target(
|
||||||
|
|
|
@ -68,6 +68,7 @@ std::shared_ptr<State> MissionManagerMakePtr::CreateMissionState(const IpcMissio
|
||||||
std::shared_ptr<State> MissionManagerMakePtr::CreateStorageHandleState(void)
|
std::shared_ptr<State> MissionManagerMakePtr::CreateStorageHandleState(void)
|
||||||
{
|
{
|
||||||
std::shared_ptr<State> state = std::make_shared<StorageHandleState>();
|
std::shared_ptr<State> state = std::make_shared<StorageHandleState>();
|
||||||
|
std::dynamic_pointer_cast<StorageHandleState>(state)->Init();
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
std::shared_ptr<State> MissionManagerMakePtr::CreateSdCardHandleState(void)
|
std::shared_ptr<State> MissionManagerMakePtr::CreateSdCardHandleState(void)
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
#include "SdCardHandleState.h"
|
#include "SdCardHandleState.h"
|
||||||
|
#include "IFilesManager.h"
|
||||||
#include "ILog.h"
|
#include "ILog.h"
|
||||||
#include "IMediaManager.h"
|
#include "IMediaManager.h"
|
||||||
#include "MissionStateMachine.h"
|
#include "MissionStateMachine.h"
|
||||||
|
@ -42,6 +43,8 @@ bool SdCardHandleState::MediaReportHandle(VStateMachineData *msg)
|
||||||
LogError("nullptr pointer.\n");
|
LogError("nullptr pointer.\n");
|
||||||
return NOT_EXECUTED;
|
return NOT_EXECUTED;
|
||||||
}
|
}
|
||||||
LogInfo(" MediaReportHandle, file = %s, path = %s.\n", data->mData.mFileName.c_str(), data->mData.mFilePath.c_str());
|
LogInfo("file = %s, path = %s.\n", data->mData.mFileName.c_str(), data->mData.mFilePath.c_str());
|
||||||
|
SaveFileInfo saveFileInfo(data->mData.mFileName);
|
||||||
|
IFilesManager::GetInstance()->SaveFile(saveFileInfo);
|
||||||
return EXECUTED;
|
return EXECUTED;
|
||||||
}
|
}
|
|
@ -32,3 +32,14 @@ bool StorageHandleState::ExecuteStateMsg(VStateMachineData *msg)
|
||||||
{
|
{
|
||||||
return DataProcessing::EventHandle(msg);
|
return DataProcessing::EventHandle(msg);
|
||||||
}
|
}
|
||||||
|
void StorageHandleState::Init(void)
|
||||||
|
{
|
||||||
|
std::shared_ptr<VStorageMoniter> monitor = shared_from_this();
|
||||||
|
IStorageManager::GetInstance()->SetMonitor(monitor);
|
||||||
|
}
|
||||||
|
void StorageHandleState::UnInit(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
void StorageHandleState::ReportEvent(const StorageEvent &event)
|
||||||
|
{
|
||||||
|
}
|
|
@ -17,7 +17,11 @@
|
||||||
#include "DataProcessing.h"
|
#include "DataProcessing.h"
|
||||||
#include "IMediaManager.h"
|
#include "IMediaManager.h"
|
||||||
#include "IStateMachine.h"
|
#include "IStateMachine.h"
|
||||||
class StorageHandleState : public State, public DataProcessing, public std::enable_shared_from_this<StorageHandleState>
|
#include "IStorageManager.h"
|
||||||
|
class StorageHandleState : public State,
|
||||||
|
public DataProcessing,
|
||||||
|
public VStorageMoniter,
|
||||||
|
public std::enable_shared_from_this<StorageHandleState>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
StorageHandleState();
|
StorageHandleState();
|
||||||
|
@ -25,5 +29,10 @@ public:
|
||||||
void GoInState() override;
|
void GoInState() override;
|
||||||
void GoOutState() override;
|
void GoOutState() override;
|
||||||
bool ExecuteStateMsg(VStateMachineData *msg) override;
|
bool ExecuteStateMsg(VStateMachineData *msg) override;
|
||||||
|
void Init(void);
|
||||||
|
void UnInit(void);
|
||||||
|
|
||||||
|
private: // About VStorageMoniter
|
||||||
|
void ReportEvent(const StorageEvent &event) override;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
13
doc/doxygen_user_guide.md
Normal file
13
doc/doxygen_user_guide.md
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
# 1. Linux嵌入式项目使用Doxygen生成API文档
|
||||||
|
|
||||||
|
## 1.1 Doxygen简介
|
||||||
|
|
||||||
|
  Doxygen是一个开源的文档生成工具,可以用来生成项目源代码的API文档。
|
||||||
|
|
||||||
|
## 1.2 Doxygen安装
|
||||||
|
|
||||||
|
  Doxygen安装非常简单,直接在官网下载最新版本即可。
|
||||||
|
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
|
@ -6,7 +6,7 @@ set(LIBRARY_OUTPUT_PATH ${LIBS_OUTPUT_PATH})
|
||||||
include_directories(
|
include_directories(
|
||||||
./src
|
./src
|
||||||
./include
|
./include
|
||||||
# ${MIDDLEWARE_SOURCE_PATH}/McuAskBase/include
|
${MIDDLEWARE_SOURCE_PATH}/StorageManager/include
|
||||||
${UTILS_SOURCE_PATH}/StatusCode/include
|
${UTILS_SOURCE_PATH}/StatusCode/include
|
||||||
${UTILS_SOURCE_PATH}/Log/include
|
${UTILS_SOURCE_PATH}/Log/include
|
||||||
# ${UTILS_SOURCE_PATH}/McuProtocol/include
|
# ${UTILS_SOURCE_PATH}/McuProtocol/include
|
||||||
|
|
|
@ -3,3 +3,26 @@
|
||||||
## 1.1. 概述
|
## 1.1. 概述
|
||||||
|
|
||||||
  IPC产品的文件管理模块。抓拍的图片或者视频的保存/删除/查询等操作通过该模块实现。
|
  IPC产品的文件管理模块。抓拍的图片或者视频的保存/删除/查询等操作通过该模块实现。
|
||||||
|
|
||||||
|
## 1.2. 文件夹管理
|
||||||
|
|
||||||
|
```
|
||||||
|
DCIM/ // 根目录
|
||||||
|
├── picture // 图片目录
|
||||||
|
│ └── 2024 // 年份记录
|
||||||
|
│ ├── 01 // 月份记录
|
||||||
|
│ │ └── xxx.jpg
|
||||||
|
│ └── 02
|
||||||
|
└── video // 视频目录
|
||||||
|
└── 2024 // 年份记录
|
||||||
|
└── 01 // 月份记录
|
||||||
|
└── xxx.MP4
|
||||||
|
```
|
||||||
|
|
||||||
|
## 1.3. 文件命名规则
|
||||||
|
|
||||||
|
**文件类型**
|
||||||
|
|
||||||
|
1. PIR抓拍;
|
||||||
|
2. 定时抓拍;
|
||||||
|
3. 手动抓拍;
|
|
@ -16,11 +16,21 @@
|
||||||
#define I_FILES_MANAGER_H
|
#define I_FILES_MANAGER_H
|
||||||
#include "StatusCode.h"
|
#include "StatusCode.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
typedef struct save_file_info
|
||||||
|
{
|
||||||
|
save_file_info(const std::string &fileName);
|
||||||
|
const std::string mFileName;
|
||||||
|
} SaveFileInfo;
|
||||||
|
bool CreateFilesManagerModule(void);
|
||||||
|
bool DestroyFilesManagerModule(void);
|
||||||
class IFilesManager
|
class IFilesManager
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
IFilesManager() = default;
|
IFilesManager() = default;
|
||||||
virtual ~IFilesManager() = default;
|
virtual ~IFilesManager() = default;
|
||||||
static std::shared_ptr<IFilesManager> &GetInstance(std::shared_ptr<IFilesManager> *impl = nullptr);
|
static std::shared_ptr<IFilesManager> &GetInstance(std::shared_ptr<IFilesManager> *impl = nullptr);
|
||||||
|
virtual StatusCode Init(void);
|
||||||
|
virtual StatusCode UnInit(void);
|
||||||
|
virtual StatusCode SaveFile(const SaveFileInfo &fileInfo);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
29
middleware/FilesManager/src/FilesManagerImpl.cpp
Normal file
29
middleware/FilesManager/src/FilesManagerImpl.cpp
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023 Fancy Code.
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#include "FilesManagerImpl.h"
|
||||||
|
#include "IStorageManager.h"
|
||||||
|
StatusCode FilesManagerImpl::Init(void)
|
||||||
|
{
|
||||||
|
return CreateStatusCode(STATUS_CODE_OK);
|
||||||
|
}
|
||||||
|
StatusCode FilesManagerImpl::UnInit(void)
|
||||||
|
{
|
||||||
|
return CreateStatusCode(STATUS_CODE_OK);
|
||||||
|
}
|
||||||
|
StatusCode FilesManagerImpl::SaveFile(const SaveFileInfo &fileInfo)
|
||||||
|
{
|
||||||
|
IStorageManager::GetInstance()->SaveFile(fileInfo.mFileName, "/DCIM/picture/2024/04/28/test.jpg");
|
||||||
|
return CreateStatusCode(STATUS_CODE_OK);
|
||||||
|
}
|
28
middleware/FilesManager/src/FilesManagerImpl.h
Normal file
28
middleware/FilesManager/src/FilesManagerImpl.h
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023 Fancy Code.
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#ifndef FILES_MANAGER_IMPL_H
|
||||||
|
#define FILES_MANAGER_IMPL_H
|
||||||
|
#include "IFilesManager.h"
|
||||||
|
#include <map>
|
||||||
|
class FilesManagerImpl : public IFilesManager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FilesManagerImpl() = default;
|
||||||
|
virtual ~FilesManagerImpl() = default;
|
||||||
|
StatusCode Init(void) override;
|
||||||
|
StatusCode UnInit(void) override;
|
||||||
|
StatusCode SaveFile(const SaveFileInfo &fileInfo) override;
|
||||||
|
};
|
||||||
|
#endif
|
54
middleware/FilesManager/src/FilesManagerMakePtr.cpp
Normal file
54
middleware/FilesManager/src/FilesManagerMakePtr.cpp
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023 Fancy Code.
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#include "FilesManagerMakePtr.h"
|
||||||
|
#include "ILog.h"
|
||||||
|
#include "FilesManagerImpl.h"
|
||||||
|
bool CreateFilesManagerModule(void)
|
||||||
|
{
|
||||||
|
auto instance = std::make_shared<IFilesManager>();
|
||||||
|
StatusCode code = FilesManagerMakePtr::GetInstance()->CreateFilesManagerModule(instance);
|
||||||
|
if (IsCodeOK(code)) {
|
||||||
|
LogInfo("CreateFilesManagerModule is ok.\n");
|
||||||
|
IFilesManager::GetInstance(&instance);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
bool DestroyFilesManagerModule(void)
|
||||||
|
{
|
||||||
|
auto instance = std::make_shared<IFilesManager>();
|
||||||
|
IFilesManager::GetInstance(&instance);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
std::shared_ptr<FilesManagerMakePtr> &FilesManagerMakePtr::GetInstance(std::shared_ptr<FilesManagerMakePtr> *impl)
|
||||||
|
{
|
||||||
|
static auto instance = std::make_shared<FilesManagerMakePtr>();
|
||||||
|
if (impl) {
|
||||||
|
if (instance.use_count() == 1) {
|
||||||
|
LogInfo("Instance changed succeed.\n");
|
||||||
|
instance = *impl;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
LogError("Can't changing the instance becase of using by some one.\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
const StatusCode FilesManagerMakePtr::CreateFilesManagerModule(std::shared_ptr<IFilesManager> &impl)
|
||||||
|
{
|
||||||
|
auto tmp = std::make_shared<FilesManagerImpl>();
|
||||||
|
impl = tmp;
|
||||||
|
return CreateStatusCode(STATUS_CODE_OK);
|
||||||
|
}
|
28
middleware/FilesManager/src/FilesManagerMakePtr.h
Normal file
28
middleware/FilesManager/src/FilesManagerMakePtr.h
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023 Fancy Code.
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#ifndef FILES_MANAGER_MAKE_PTR_H
|
||||||
|
#define FILES_MANAGER_MAKE_PTR_H
|
||||||
|
#include "IFilesManager.h"
|
||||||
|
#include "StatusCode.h"
|
||||||
|
#include <memory>
|
||||||
|
class FilesManagerMakePtr
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FilesManagerMakePtr() = default;
|
||||||
|
virtual ~FilesManagerMakePtr() = default;
|
||||||
|
static std::shared_ptr<FilesManagerMakePtr> &GetInstance(std::shared_ptr<FilesManagerMakePtr> *impl = nullptr);
|
||||||
|
virtual const StatusCode CreateFilesManagerModule(std::shared_ptr<IFilesManager> &impl);
|
||||||
|
};
|
||||||
|
#endif // !FILES_MANAGER_MAKE_PTR_H
|
|
@ -14,6 +14,9 @@
|
||||||
*/
|
*/
|
||||||
#include "IFilesManager.h"
|
#include "IFilesManager.h"
|
||||||
#include "ILog.h"
|
#include "ILog.h"
|
||||||
|
save_file_info::save_file_info(const std::string &fileName) : mFileName(fileName)
|
||||||
|
{
|
||||||
|
}
|
||||||
std::shared_ptr<IFilesManager> &IFilesManager::GetInstance(std::shared_ptr<IFilesManager> *impl)
|
std::shared_ptr<IFilesManager> &IFilesManager::GetInstance(std::shared_ptr<IFilesManager> *impl)
|
||||||
{
|
{
|
||||||
static auto instance = std::make_shared<IFilesManager>();
|
static auto instance = std::make_shared<IFilesManager>();
|
||||||
|
@ -28,3 +31,15 @@ std::shared_ptr<IFilesManager> &IFilesManager::GetInstance(std::shared_ptr<IFile
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
StatusCode IFilesManager::Init(void)
|
||||||
|
{
|
||||||
|
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||||
|
}
|
||||||
|
StatusCode IFilesManager::UnInit(void)
|
||||||
|
{
|
||||||
|
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||||
|
}
|
||||||
|
StatusCode IFilesManager::SaveFile(const SaveFileInfo &fileInfo)
|
||||||
|
{
|
||||||
|
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||||
|
}
|
|
@ -38,8 +38,8 @@ typedef struct media_report_event
|
||||||
media_report_event(const std::string &fileName, const std::string &filePath, const MediaTaskType &eventType,
|
media_report_event(const std::string &fileName, const std::string &filePath, const MediaTaskType &eventType,
|
||||||
const MediaChannel &mediaChannedl);
|
const MediaChannel &mediaChannedl);
|
||||||
const std::string mFileName;
|
const std::string mFileName;
|
||||||
const std::string mFilePath;
|
const std::string mFilePath; // TODO: delete
|
||||||
const MediaTaskType mEventType;
|
const MediaTaskType mEventType; // TODO: delete
|
||||||
const MediaChannel mMediaChannedl;
|
const MediaChannel mMediaChannedl;
|
||||||
} MediaReportEvent;
|
} MediaReportEvent;
|
||||||
class MediaTaskResponse
|
class MediaTaskResponse
|
||||||
|
|
|
@ -7,6 +7,7 @@ include_directories(
|
||||||
./src
|
./src
|
||||||
./include
|
./include
|
||||||
${MIDDLEWARE_SOURCE_PATH}/McuAskBase/include
|
${MIDDLEWARE_SOURCE_PATH}/McuAskBase/include
|
||||||
|
${HAL_SOURCE_PATH}/include
|
||||||
${UTILS_SOURCE_PATH}/StatusCode/include
|
${UTILS_SOURCE_PATH}/StatusCode/include
|
||||||
${UTILS_SOURCE_PATH}/Log/include
|
${UTILS_SOURCE_PATH}/Log/include
|
||||||
${UTILS_SOURCE_PATH}/McuProtocol/include
|
${UTILS_SOURCE_PATH}/McuProtocol/include
|
||||||
|
|
|
@ -40,6 +40,7 @@ public:
|
||||||
static std::shared_ptr<IStorageManager> &GetInstance(std::shared_ptr<IStorageManager> *impl = nullptr);
|
static std::shared_ptr<IStorageManager> &GetInstance(std::shared_ptr<IStorageManager> *impl = nullptr);
|
||||||
virtual StatusCode Init(void);
|
virtual StatusCode Init(void);
|
||||||
virtual StatusCode UnInit(void);
|
virtual StatusCode UnInit(void);
|
||||||
virtual StatusCode SaveFile(const std::string &path, const std::string &content);
|
virtual StatusCode SetMonitor(std::shared_ptr<VStorageMoniter> &monitor);
|
||||||
|
virtual StatusCode SaveFile(const std::string &sourceFile, const std::string &savePaht);
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
15
middleware/StorageManager/src/EmmcHandle.cpp
Normal file
15
middleware/StorageManager/src/EmmcHandle.cpp
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023 Fancy Code.
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#include "EmmcHandle.h"
|
25
middleware/StorageManager/src/EmmcHandle.h
Normal file
25
middleware/StorageManager/src/EmmcHandle.h
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023 Fancy Code.
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#ifndef EMMC_HANDLE_H
|
||||||
|
#define EMMC_HANDLE_H
|
||||||
|
#include "StatusCode.h"
|
||||||
|
#include "StorageBase.h"
|
||||||
|
class EmmcHandle : virtual public StorageBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
EmmcHandle() = default;
|
||||||
|
virtual ~EmmcHandle() = default;
|
||||||
|
};
|
||||||
|
#endif
|
|
@ -39,3 +39,12 @@ StatusCode IStorageManager::UnInit(void)
|
||||||
{
|
{
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||||
}
|
}
|
||||||
|
StatusCode IStorageManager::SetMonitor(std::shared_ptr<VStorageMoniter> &monitor)
|
||||||
|
{
|
||||||
|
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||||
|
}
|
||||||
|
StatusCode IStorageManager::SaveFile(const std::string &sourceFile, const std::string &savePaht)
|
||||||
|
{
|
||||||
|
LogInfo("SaveFile: %s to %s\n", sourceFile.c_str(), savePaht.c_str());
|
||||||
|
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
||||||
|
}
|
35
middleware/StorageManager/src/SdCardHandle.cpp
Normal file
35
middleware/StorageManager/src/SdCardHandle.cpp
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023 Fancy Code.
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#include "SdCardHandle.h"
|
||||||
|
#include "ILog.h"
|
||||||
|
void SdCardHandle::Init(void)
|
||||||
|
{
|
||||||
|
IHalCpp::GetInstance()->GetSdCardHal(mSdCardHal);
|
||||||
|
if (nullptr == mSdCardHal) {
|
||||||
|
LogWarning("SdCardHal is nullptr.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
std::shared_ptr<VSdCardHalMonitor> sdMonitor =
|
||||||
|
std::dynamic_pointer_cast<VSdCardHalMonitor>(StorageBase::shared_from_this());
|
||||||
|
if (nullptr == sdMonitor) {
|
||||||
|
LogWarning("sdMonitor is nullptr.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
mSdCardHal->SetSdCardMonitor(sdMonitor);
|
||||||
|
}
|
||||||
|
void SdCardHandle::UnInit(void)
|
||||||
|
{
|
||||||
|
mSdCardHal.reset();
|
||||||
|
}
|
32
middleware/StorageManager/src/SdCardHandle.h
Normal file
32
middleware/StorageManager/src/SdCardHandle.h
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023 Fancy Code.
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#ifndef SD_CARD_HANDLE_H
|
||||||
|
#define SD_CARD_HANDLE_H
|
||||||
|
#include "IHalCpp.h"
|
||||||
|
#include "StatusCode.h"
|
||||||
|
#include "StorageBase.h"
|
||||||
|
#include <memory>
|
||||||
|
class SdCardHandle : public VSdCardHalMonitor, virtual public StorageBase
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
SdCardHandle() = default;
|
||||||
|
virtual ~SdCardHandle() = default;
|
||||||
|
void Init(void);
|
||||||
|
void UnInit(void);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::shared_ptr<VSdCardHal> mSdCardHal;
|
||||||
|
};
|
||||||
|
#endif
|
15
middleware/StorageManager/src/StorageBase.cpp
Normal file
15
middleware/StorageManager/src/StorageBase.cpp
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023 Fancy Code.
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#include "StorageBase.h"
|
28
middleware/StorageManager/src/StorageBase.h
Normal file
28
middleware/StorageManager/src/StorageBase.h
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
/*
|
||||||
|
* Copyright (c) 2023 Fancy Code.
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#ifndef STORAGE_BASE_H
|
||||||
|
#define STORAGE_BASE_H
|
||||||
|
#include "IStorageManager.h"
|
||||||
|
#include <memory>
|
||||||
|
class StorageBase : public std::enable_shared_from_this<StorageBase>
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
StorageBase() = default;
|
||||||
|
virtual ~StorageBase() = default;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
std::weak_ptr<VStorageMoniter> mStorageMonitor;
|
||||||
|
};
|
||||||
|
#endif
|
|
@ -15,9 +15,23 @@
|
||||||
#include "StorageManagerImpl.h"
|
#include "StorageManagerImpl.h"
|
||||||
StatusCode StorageManagerImpl::Init(void)
|
StatusCode StorageManagerImpl::Init(void)
|
||||||
{
|
{
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
SdCardHandle::Init();
|
||||||
|
return CreateStatusCode(STATUS_CODE_OK);
|
||||||
}
|
}
|
||||||
StatusCode StorageManagerImpl::UnInit(void)
|
StatusCode StorageManagerImpl::UnInit(void)
|
||||||
{
|
{
|
||||||
return CreateStatusCode(STATUS_CODE_VIRTUAL_FUNCTION);
|
SdCardHandle::UnInit();
|
||||||
|
return CreateStatusCode(STATUS_CODE_OK);
|
||||||
|
}
|
||||||
|
StatusCode StorageManagerImpl::SetMonitor(std::shared_ptr<VStorageMoniter> &monitor)
|
||||||
|
{
|
||||||
|
mStorageMonitor = monitor;
|
||||||
|
return CreateStatusCode(STATUS_CODE_OK);
|
||||||
|
}
|
||||||
|
StatusCode StorageManagerImpl::SaveFile(const std::string &sourceFile, const std::string &savePaht)
|
||||||
|
{
|
||||||
|
constexpr int CMD_BUF_SIZE = 128;
|
||||||
|
char cmd[CMD_BUF_SIZE] = {0};
|
||||||
|
snprintf(cmd, CMD_BUF_SIZE, "cp %s %s", sourceFile.c_str(), savePaht.c_str());
|
||||||
|
return CreateStatusCode(STATUS_CODE_OK);
|
||||||
}
|
}
|
|
@ -14,14 +14,18 @@
|
||||||
*/
|
*/
|
||||||
#ifndef STORAGE_MANAGER_IMPL_H
|
#ifndef STORAGE_MANAGER_IMPL_H
|
||||||
#define STORAGE_MANAGER_IMPL_H
|
#define STORAGE_MANAGER_IMPL_H
|
||||||
|
#include "EmmcHandle.h"
|
||||||
#include "IStorageManager.h"
|
#include "IStorageManager.h"
|
||||||
|
#include "SdCardHandle.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
class StorageManagerImpl : public IStorageManager, public std::enable_shared_from_this<StorageManagerImpl>
|
class StorageManagerImpl : public IStorageManager, public SdCardHandle, public EmmcHandle
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
StorageManagerImpl() = default;
|
StorageManagerImpl() = default;
|
||||||
virtual ~StorageManagerImpl() = default;
|
virtual ~StorageManagerImpl() = default;
|
||||||
StatusCode Init(void) override;
|
StatusCode Init(void) override;
|
||||||
StatusCode UnInit(void) override;
|
StatusCode UnInit(void) override;
|
||||||
|
StatusCode SetMonitor(std::shared_ptr<VStorageMoniter> &monitor) override;
|
||||||
|
StatusCode SaveFile(const std::string &sourceFile, const std::string &savePaht) override;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
Loading…
Reference in New Issue
Block a user