2022-11-02 22:43:14 +01:00
|
|
|
/**
|
|
|
|
|
* @file
|
|
|
|
|
*
|
|
|
|
|
* @author Mamadou Babaei <mamadou@senseglove.com>
|
|
|
|
|
*
|
|
|
|
|
* @section LICENSE
|
|
|
|
|
*
|
|
|
|
|
* (The MIT License)
|
|
|
|
|
*
|
|
|
|
|
* Copyright (c) 2020 - 2022 SenseGlove
|
|
|
|
|
*
|
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
|
*
|
|
|
|
|
* The above copyright notice and this permission notice shall be included in all
|
|
|
|
|
* copies or substantial portions of the Software.
|
|
|
|
|
*
|
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
|
|
|
* SOFTWARE.
|
|
|
|
|
*
|
|
|
|
|
* @section DESCRIPTION
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "SGCore/SGDeviceModel.h"
|
|
|
|
|
|
|
|
|
|
#include "Runtime/Launch/Resources/Version.h"
|
|
|
|
|
|
|
|
|
|
#include "SGCoreImpl/SGExportedFunctions.h"
|
|
|
|
|
#include "SGInterop/SGIC_FSGDeviceModelImpl.h"
|
|
|
|
|
#include "SGInterop/SGIC_FString.h"
|
|
|
|
|
#include "SGInterop/SGIC_TArray_bool.h"
|
|
|
|
|
|
|
|
|
|
struct USGDeviceModel::FImpl
|
|
|
|
|
{
|
|
|
|
|
/************************
|
|
|
|
|
* Member variables
|
|
|
|
|
************************/
|
|
|
|
|
|
|
|
|
|
FSGDeviceModelImpl DeviceModelImpl;
|
|
|
|
|
|
|
|
|
|
/************************
|
|
|
|
|
* Owner object
|
|
|
|
|
************************/
|
|
|
|
|
|
|
|
|
|
USGDeviceModel* Owner;
|
|
|
|
|
|
|
|
|
|
/************************
|
|
|
|
|
* Constructor / Destructor
|
|
|
|
|
************************/
|
|
|
|
|
|
|
|
|
|
explicit FImpl(USGDeviceModel* InOwner);
|
|
|
|
|
~FImpl();
|
|
|
|
|
|
|
|
|
|
/************************
|
|
|
|
|
* Default copy constructor & copy assignment operator
|
|
|
|
|
************************/
|
|
|
|
|
|
|
|
|
|
FImpl(const FImpl& Rhs) = default;
|
|
|
|
|
FImpl& operator=(const FImpl& Rhs) = default;
|
|
|
|
|
|
|
|
|
|
/************************
|
|
|
|
|
* Methods
|
|
|
|
|
************************/
|
|
|
|
|
|
|
|
|
|
void SyncUProperties();
|
|
|
|
|
void SyncImplObject();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
USGDeviceModel* USGDeviceModel::NewDeviceModel(UObject* Outer, const FSGDeviceModelImpl& DeviceModelImpl)
|
|
|
|
|
{
|
|
|
|
|
USGDeviceModel* Instance = NewObject<USGDeviceModel>(Outer);
|
|
|
|
|
Instance->SetDeviceModelImpl(DeviceModelImpl);
|
|
|
|
|
return Instance;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
USGDeviceModel* USGDeviceModel::NewDeviceModel(UObject* Outer)
|
|
|
|
|
{
|
|
|
|
|
FSGIC_FSGDeviceModelImpl OutDeviceModelImplContainer;
|
|
|
|
|
SGCoreImpl_FSGDeviceModelImpl_ctor(&OutDeviceModelImplContainer);
|
|
|
|
|
|
|
|
|
|
return NewDeviceModel(Outer, MoveTemp(OutDeviceModelImplContainer.DeviceModelImpl));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
USGDeviceModel* USGDeviceModel::NewDeviceModel(
|
|
|
|
|
UObject* Outer,
|
|
|
|
|
const FString& Id, const FString& HardwareVersion, const int32 FirmwareVersion, const int32 SubFirmwareVersion)
|
|
|
|
|
{
|
|
|
|
|
FSGIC_FSGDeviceModelImpl OutDeviceModelImplContainer;
|
|
|
|
|
FSGIC_FString IdContainer{Id};
|
|
|
|
|
FSGIC_FString HardwareVersionContainer{HardwareVersion};
|
|
|
|
|
SGCoreImpl_FSGDeviceModelImpl_ctor_Id_HardwareVersion_FirmwareVersion_SubFirmwareVersion(
|
|
|
|
|
&OutDeviceModelImplContainer, &IdContainer, &HardwareVersionContainer, FirmwareVersion, SubFirmwareVersion);
|
|
|
|
|
|
|
|
|
|
return NewDeviceModel(Outer, MoveTemp(OutDeviceModelImplContainer.DeviceModelImpl));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TArray<bool> USGDeviceModel::ParseFunctions(const int32 Value, const int32 Size)
|
|
|
|
|
{
|
|
|
|
|
FSGIC_TArray_bool OutParseFunctionsContainer;
|
|
|
|
|
SGCoreImpl_FSGDeviceModelImpl_ParseFunctions(&OutParseFunctionsContainer, Value, Size);
|
|
|
|
|
return MoveTemp(OutParseFunctionsContainer.Array);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void USGDeviceModel::ParseFirmware(const FString& RawFirmware, int32& OutMainVersion, int32& OutSubVersion)
|
|
|
|
|
{
|
|
|
|
|
FSGIC_FString RawFirmwareContainer{RawFirmware};
|
|
|
|
|
SGCoreImpl_FSGDeviceModelImpl_ParseFirmware(&RawFirmwareContainer, &OutMainVersion, &OutSubVersion);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
USGDeviceModel::USGDeviceModel()
|
|
|
|
|
:
|
2022-11-24 00:49:18 +01:00
|
|
|
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 )
|
2022-11-02 22:43:14 +01:00
|
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
|
|
|
|
#else
|
|
|
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}))
|
2022-11-24 00:49:18 +01:00
|
|
|
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */
|
2022-11-02 22:43:14 +01:00
|
|
|
{
|
|
|
|
|
FSGIC_FSGDeviceModelImpl OutDeviceModelImplContainer;
|
|
|
|
|
SGCoreImpl_FSGDeviceModelImpl_ctor(&OutDeviceModelImplContainer);
|
|
|
|
|
|
|
|
|
|
Pimpl->DeviceModelImpl = MoveTemp(OutDeviceModelImplContainer.DeviceModelImpl);
|
|
|
|
|
Pimpl->SyncUProperties();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
USGDeviceModel::USGDeviceModel(const FString& Id, const FString& HardwareVersion,
|
|
|
|
|
const int32 FirmwareVersion, const int32 SubFirmwareVersion)
|
|
|
|
|
:
|
2022-11-24 00:49:18 +01:00
|
|
|
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 )
|
2022-11-02 22:43:14 +01:00
|
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
|
|
|
|
#else
|
|
|
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}))
|
2022-11-24 00:49:18 +01:00
|
|
|
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */
|
2022-11-02 22:43:14 +01:00
|
|
|
{
|
|
|
|
|
FSGIC_FSGDeviceModelImpl OutDeviceModelImplContainer;
|
|
|
|
|
FSGIC_FString IdContainer{Id};
|
|
|
|
|
FSGIC_FString HardwareVersionContainer{HardwareVersion};
|
|
|
|
|
SGCoreImpl_FSGDeviceModelImpl_ctor_Id_HardwareVersion_FirmwareVersion_SubFirmwareVersion(
|
|
|
|
|
&OutDeviceModelImplContainer, &IdContainer, &HardwareVersionContainer, FirmwareVersion, SubFirmwareVersion);
|
|
|
|
|
|
|
|
|
|
Pimpl->DeviceModelImpl = MoveTemp(OutDeviceModelImplContainer.DeviceModelImpl);
|
|
|
|
|
Pimpl->SyncUProperties();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
USGDeviceModel::USGDeviceModel(const FSGDeviceModelImpl& DeviceModelImpl)
|
|
|
|
|
:
|
2022-11-24 00:49:18 +01:00
|
|
|
#if ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 )
|
2022-11-02 22:43:14 +01:00
|
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}, PimplDeleter))
|
|
|
|
|
#else
|
|
|
|
|
Pimpl(TUniquePtr<FImpl, FImplDeleter>(new FImpl{this}))
|
2022-11-24 00:49:18 +01:00
|
|
|
#endif /* ENGINE_MAJOR_VERSION == 5 || ( ENGINE_MAJOR_VERSION == 4 && ENGINE_MINOR_VERSION > 24 ) */
|
2022-11-02 22:43:14 +01:00
|
|
|
{
|
|
|
|
|
SetDeviceModelImpl(DeviceModelImpl);
|
|
|
|
|
Pimpl->SyncUProperties();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
USGDeviceModel::~USGDeviceModel() = default;
|
|
|
|
|
|
|
|
|
|
void USGDeviceModel::SetDeviceModelImpl(const FSGDeviceModelImpl& DeviceModelImpl)
|
|
|
|
|
{
|
|
|
|
|
FSGIC_FSGDeviceModelImpl OutDeviceModelContainer;
|
|
|
|
|
FSGIC_FSGDeviceModelImpl RhsContainer{DeviceModelImpl};
|
|
|
|
|
SGCoreImpl_FSGDeviceModelImpl_ctor_copy(&OutDeviceModelContainer, &RhsContainer);
|
|
|
|
|
Pimpl->DeviceModelImpl = MoveTemp(OutDeviceModelContainer.DeviceModelImpl);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const FSGDeviceModelImpl& USGDeviceModel::ToDeviceModelImpl() const
|
|
|
|
|
{
|
|
|
|
|
Pimpl->SyncImplObject();
|
|
|
|
|
return Pimpl->DeviceModelImpl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FSGDeviceModelImpl& USGDeviceModel::ToDeviceModelImpl()
|
|
|
|
|
{
|
|
|
|
|
Pimpl->SyncImplObject();
|
|
|
|
|
return Pimpl->DeviceModelImpl;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FString USGDeviceModel::GetDeviceId() const
|
|
|
|
|
{
|
|
|
|
|
FSGIC_FSGDeviceModelImpl InstanceContainer{ToDeviceModelImpl()};
|
|
|
|
|
FSGIC_FString OutIdContainer;
|
|
|
|
|
SGCoreImpl_FSGDeviceModelImpl_GetDeviceId(&InstanceContainer, &OutIdContainer);
|
|
|
|
|
return MoveTemp(OutIdContainer.String);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FString USGDeviceModel::GetHardwareVersion() const
|
|
|
|
|
{
|
|
|
|
|
FSGIC_FSGDeviceModelImpl InstanceContainer{ToDeviceModelImpl()};
|
|
|
|
|
FSGIC_FString OutVersionContainer;
|
|
|
|
|
SGCoreImpl_FSGDeviceModelImpl_GetHardwareVersion(&InstanceContainer, &OutVersionContainer);
|
|
|
|
|
return MoveTemp(OutVersionContainer.String);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32 USGDeviceModel::GetFirmwareVersion() const
|
|
|
|
|
{
|
|
|
|
|
FSGIC_FSGDeviceModelImpl InstanceContainer{ToDeviceModelImpl()};
|
|
|
|
|
return SGCoreImpl_FSGDeviceModelImpl_GetFirmwareVersion(&InstanceContainer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int32 USGDeviceModel::GetSubFirmwareVersion() const
|
|
|
|
|
{
|
|
|
|
|
FSGIC_FSGDeviceModelImpl InstanceContainer{ToDeviceModelImpl()};
|
|
|
|
|
return SGCoreImpl_FSGDeviceModelImpl_GetSubFirmwareVersion(&InstanceContainer);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
USGDeviceModel::FImpl::FImpl(USGDeviceModel* InOwner)
|
|
|
|
|
: Owner(InOwner)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
USGDeviceModel::FImpl::~FImpl() = default;
|
|
|
|
|
|
|
|
|
|
void USGDeviceModel::FImplDeleter::operator()(const FImpl* P) const
|
|
|
|
|
{
|
|
|
|
|
delete P;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void USGDeviceModel::FImpl::SyncUProperties()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void USGDeviceModel::FImpl::SyncImplObject()
|
|
|
|
|
{
|
|
|
|
|
}
|