Skip to content

Commit

Permalink
add functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Simplxss committed Nov 29, 2023
1 parent fcd9109 commit 87afb2d
Show file tree
Hide file tree
Showing 16 changed files with 168 additions and 110 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ endif()

option(MDF_BUILD_SHARED_LIB "Build shared library." ON)
option(MDF_BUILD_SHARED_LIB_NET "Build shared library with .NET." ON)
option(MDF_BUILD_SHARED_LIB_EXAMPLE "Build MdfLibrary Example." OFF)
option(MDF_BUILD_SHARED_LIB_EXAMPLE "Build MdfLibrary Example." ON)
option(MDF_BUILD_DOC "Build documentation. Requires Doxygen and Release mode." OFF)
option(MDF_BUILD_TOOL "Build tools like the MDF Viewer. Requires WxWidgets." OFF)
if(MDF_BUILD_TOOL AND VCPKG)
Expand Down
3 changes: 1 addition & 2 deletions include/mdflibrary/CanMessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@ class CanMessage {
bool GetExtendedId() const { return CanMessageGetExtendedId(can); };
uint8_t GetDlc() const { return CanMessageGetDlc(can); };
void SetDlc(uint8_t dlc) { CanMessageSetDlc(can, dlc); };

uint32_t GetDataLength() const { return CanMessageGetDataLength(can); };
void SetDataLength(uint32_t dataLength) {
CanMessageSetDataLength(can, dataLength);
};
std::vector<uint8_t> GetDataBytes() const {
size_t count = CanMessageGetDataBytes(can, nullptr);
if (count <= 0) return std::vector<uint8_t>();
if (count <= 0) return {};
auto dataList = std::vector<uint8_t>(count);
CanMessageGetDataBytes(can, dataList.data());
return dataList;
Expand Down
10 changes: 8 additions & 2 deletions include/mdflibrary/MdfAttachment.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
* SPDX-License-Identifier: MIT
*/
#pragma once
#include <string>
#include <stdexcept>
#include <string>

#include "MdfExport.h"
#include "MdfMetaData.h"

using namespace MdfLibrary::ExportFunctions;

Expand Down Expand Up @@ -66,5 +66,11 @@ class MdfAttachment {
void SetFileType(const char* type) {
MdfAttachmentSetFileType(attachment, type);
}
const MdfMetaData GetMetaData() const {
return MdfAttachmentGetMetaData(attachment);
}
MdfMetaData CreateMetaData() {
return MdfAttachmentCreateMetaData(attachment);
}
};
} // namespace MdfLibrary
43 changes: 32 additions & 11 deletions include/mdflibrary/MdfChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ class MdfChannel {
}
uint32_t GetFlags() const { return MdfChannelGetFlags(channel); }
void SetFlags(uint32_t flags) { MdfChannelSetFlags(channel, flags); }
size_t GetDataBytes() const { return MdfChannelGetDataBytes(channel); }
void SetDataBytes(size_t bytes) { MdfChannelSetDataBytes(channel, bytes); }
uint64_t GetDataBytes() const { return MdfChannelGetDataBytes(channel); }
void SetDataBytes(uint64_t bytes) { MdfChannelSetDataBytes(channel, bytes); }
bool IsPrecisionUsed() { return MdfChannelIsPrecisionUsed(channel); }
uint8_t GetPrecision() const { return MdfChannelGetPrecision(channel); }
bool IsRangeUsed() { return MdfChannelIsRangeUsed(channel); }
Expand All @@ -96,23 +96,44 @@ class MdfChannel {
MdfChannelSetExtLimit(channel, min, max);
}
double GetSamplingRate() const { return MdfChannelGetSamplingRate(channel); }
uint64_t GetVlsdRecordId() const {
return MdfChannelGetVlsdRecordId(channel);
}
void SetVlsdRecordId(uint64_t record_id) {
MdfChannelSetVlsdRecordId(channel, record_id);
}
uint32_t GetBitCount() const { return MdfChannelGetBitCount(channel); }
void SetBitCount(uint32_t bits) { MdfChannelSetBitCount(channel, bits); }
uint16_t GetBitOffset() const { return MdfChannelGetBitOffset(channel); }
void SetBitOffset(uint16_t bits) { MdfChannelSetBitOffset(channel, bits); }
const MdfMetaData GetMetaData() const {
return MdfMetaData(MdfChannelGetMetaData(channel));
return MdfChannelGetMetaData(channel);
}
const MdfSourceInformation GetSourceInformation() const {
return MdfSourceInformation(MdfChannelGetSourceInformation(channel));
return MdfChannelGetSourceInformation(channel);
}
const MdfChannelConversion GetChannelConversion() const {
return MdfChannelConversion(MdfChannelGetChannelConversion(channel));
}
MdfMetaData CreateMetaData() {
return MdfMetaData(MdfChannelCreateMetaData(channel));
}
return MdfChannelGetChannelConversion(channel);
}
std::vector<MdfChannel> GetChannelCompositions() {
size_t count = MdfChannelGetChannelCompositions(channel, nullptr);
if (count <= 0) return {};
auto pChannels = new mdf::IChannel*[count];
MdfChannelGetChannelCompositions(channel, pChannels);
std::vector<MdfChannel> channelss;
for (size_t i = 0; i < count; i++) channelss.push_back(pChannels[i]);
delete[] pChannels;
return channelss;
}
MdfMetaData CreateMetaData() { return MdfChannelCreateMetaData(channel); }
MdfSourceInformation CreateSourceInformation() {
return MdfSourceInformation(MdfChannelCreateSourceInformation(channel));
return MdfChannelCreateSourceInformation(channel);
}
MdfChannelConversion CreateChannelConversion() {
return MdfChannelConversion(MdfChannelCreateChannelConversion(channel));
return MdfChannelCreateChannelConversion(channel);
}
MdfChannel CreateChannelComposition() {
return MdfChannelCreateChannelComposition(channel);
}
void SetChannelValue(const int64_t value, bool valid = true) {
MdfChannelSetChannelValueAsSigned(channel, value, valid);
Expand Down
32 changes: 29 additions & 3 deletions include/mdflibrary/MdfChannelConversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#pragma once
#include <string>

#include "MdfExport.h"
#include "MdfMetadata.h"

Check failure on line 8 in include/mdflibrary/MdfChannelConversion.h

View workflow job for this annotation

GitHub Actions / run on ubuntu-latest(x64)

MdfMetadata.h: No such file or directory

using namespace MdfLibrary::ExportFunctions;

Expand Down Expand Up @@ -82,10 +82,36 @@ class MdfChannelConversion {
}
uint16_t GetFlags() const { return MdfChannelConversionGetFlags(conversion); }
const MdfChannelConversion GetInverse() const {
return MdfChannelConversion(MdfChannelConversionGetInverse(conversion));
return MdfChannelConversionGetInverse(conversion);
}
const MdfMetaData GetMetadata() const {
return MdfChannelConversionGetMetaData(conversion);
}
std::string GetReference(uint16_t index) const {
size_t size = MdfChannelConversionGetReference(conversion, index, nullptr);
char* str = new char[size + 1];
MdfChannelConversionGetReference(conversion, index, str);
std::string s(str, size);
delete str;
return s;
}
void SetReference(uint16_t index, const char* ref) {
MdfChannelConversionSetReference(conversion, index, ref);
}
double GetParameter(uint16_t index) const {
return MdfChannelConversionGetParameterAsDouble(conversion, index);
}
uint64_t GetParameterUint(uint16_t index) const {
return MdfChannelConversionGetParameterAsUInt64(conversion, index);
}
void SetParameter(uint16_t index, double param) {
MdfChannelConversionSetParameterAsDouble(conversion, index, param);
}
void SetParameter(uint16_t index, uint64_t param) {
MdfChannelConversionSetParameterAsUInt64(conversion, index, param);
}
MdfChannelConversion CreateInverse() {
return MdfChannelConversion(MdfChannelConversionCreateInverse(conversion));
return MdfChannelConversionCreateInverse(conversion);
}
};
} // namespace MdfLibrary
22 changes: 8 additions & 14 deletions include/mdflibrary/MdfChannelGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,34 +56,28 @@ class MdfChannelGroup {
MdfChannelGroupSetPathSeparator(group, sep);
}
const MdfMetaData GetMetaData() const {
return MdfMetaData(MdfChannelGroupGetMetaData(group));
return MdfChannelGroupGetMetaData(group);
}
std::vector<MdfChannel> GetChannels() const {
size_t count = MdfChannelGroupGetChannels(group, nullptr);
if (count <= 0) return std::vector<MdfChannel>();
if (count <= 0) return {};
auto pChannels = new mdf::IChannel*[count];
MdfChannelGroupGetChannels(group, pChannels);
std::vector<MdfChannel> channels;
for (size_t i = 0; i < count; i++)
channels.push_back(MdfChannel(pChannels[i]));
for (size_t i = 0; i < count; i++) channels.push_back(pChannels[i]);
delete[] pChannels;
return channels;
}
const MdfSourceInformation GetSourceInformation() const {
return MdfSourceInformation(MdfChannelGroupGetSourceInformation(group));
return MdfChannelGroupGetSourceInformation(group);
}
const MdfChannel GetXChannel(MdfChannel ref_channel) {
return MdfChannel(
MdfChannelGroupGetXChannel(group, ref_channel.GetChannel()));
}
MdfMetaData CreateMetaData() {
return MdfMetaData(MdfChannelGroupCreateMetaData(group));
}
MdfChannel CreateChannel() {
return MdfChannel(MdfChannelGroupCreateChannel(group));
return MdfChannelGroupGetXChannel(group, ref_channel.GetChannel());
}
MdfMetaData CreateMetaData() { return MdfChannelGroupCreateMetaData(group); }
MdfChannel CreateChannel() { return MdfChannelGroupCreateChannel(group); }
MdfSourceInformation CreateSourceInformation() {
return MdfSourceInformation(MdfChannelGroupCreateSourceInformation(group));
return MdfChannelGroupCreateSourceInformation(group);
}
};
} // namespace MdfLibrary
11 changes: 6 additions & 5 deletions include/mdflibrary/MdfChannelObserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@ class MdfChannelObserver {
size_t size;
MdfChannelObserverGetChannelValueAsString(observer, sample, nullptr, size);
char* str = new char[++size];
bool valid = MdfChannelObserverGetChannelValueAsString(observer, sample, str, size);
bool valid =
MdfChannelObserverGetChannelValueAsString(observer, sample, str, size);
value.assign(str, size);
delete str;
return valid;
Expand All @@ -98,7 +99,8 @@ class MdfChannelObserver {
size_t size;
MdfChannelObserverGetEngValueAsString(observer, sample, nullptr, size);
char* str = new char[++size];
bool valid = MdfChannelObserverGetEngValueAsString(observer, sample, str, size);
bool valid =
MdfChannelObserverGetEngValueAsString(observer, sample, str, size);
value.assign(str, size);
delete str;
return valid;
Expand All @@ -116,13 +118,12 @@ std::vector<MdfChannelObserver> MdfCreateChannelObserverForChannelGroup(
MdfDataGroup data_group, MdfChannelGroup channel_group) {
size_t count =
MdfChannelGroupGetChannels(channel_group.GetChannelGroup(), nullptr);
if (count <= 0) return std::vector<MdfChannelObserver>();
if (count <= 0) return {};
auto pObservers = new mdf::IChannelObserver*[count];
MdfChannelObserverCreateForChannelGroup(
data_group.GetDataGroup(), channel_group.GetChannelGroup(), pObservers);
std::vector<MdfChannelObserver> observers;
for (size_t i = 0; i < count; i++)
observers.push_back(MdfChannelObserver(pObservers[i]));
for (size_t i = 0; i < count; i++) observers.push_back(pObservers[i]);
delete[] pObservers;
return observers;
}
Expand Down
13 changes: 5 additions & 8 deletions include/mdflibrary/MdfDataGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ class MdfDataGroup {
}
uint8_t GetRecordIdSize() const { return MdfDataGroupGetRecordIdSize(group); }
const MdfMetaData GetMetaData() const {
return MdfMetaData(MdfDataGroupGetMetaData(group));
return MdfDataGroupGetMetaData(group);
}
std::vector<MdfChannelGroup> GetChannelGroups() const {
size_t count = MdfDataGroupGetChannelGroups(group, nullptr);
if (count <= 0) return std::vector<MdfChannelGroup>();
if (count <= 0) return {};
auto pGroups = new mdf::IChannelGroup*[count];
MdfDataGroupGetChannelGroups(group, pGroups);
std::vector<MdfChannelGroup> groups;
Expand All @@ -45,15 +45,12 @@ class MdfDataGroup {
return groups;
}
bool IsRead() { return MdfDataGroupIsRead(group); }
MdfMetaData CreateMetaData() {
return MdfMetaData(MdfDataGroupCreateMetaData(group));
}
MdfMetaData CreateMetaData() { return MdfDataGroupCreateMetaData(group); }
MdfChannelGroup CreateChannelGroup() {
return MdfChannelGroup(MdfDataGroupCreateChannelGroup(group));
return MdfDataGroupCreateChannelGroup(group);
}
const MdfChannelGroup FindParentChannelGroup(MdfChannel channel) {
return MdfChannelGroup(
MdfDataGroupFindParentChannelGroup(group, channel.GetChannel()));
return MdfDataGroupFindParentChannelGroup(group, channel.GetChannel());
}
void ResetSample() { MdfDataGroupResetSample(group); }
};
Expand Down
15 changes: 5 additions & 10 deletions include/mdflibrary/MdfEvent.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,35 +62,30 @@ class MdfEvent {
void SetSyncValue(int64_t value) { MdfEventSetSyncValue(event, value); }
void SetSyncFactor(double factor) { MdfEventSetSyncFactor(event, factor); }
const MdfEvent GetParentEvent() const {
return MdfEvent(MdfEventGetParentEvent(event));
return MdfEventGetParentEvent(event);
}
void SetParentEvent(MdfEvent parent) {
MdfEventSetParentEvent(event, parent.event);
}
const MdfEvent GetRangeEvent() const {
return MdfEvent(MdfEventGetRangeEvent(event));
}
const MdfEvent GetRangeEvent() const { return MdfEventGetRangeEvent(event); }
void SetRangeEvent(MdfEvent range) {
MdfEventSetRangeEvent(event, range.event);
}
std::vector<MdfAttachment> GetAttachments() const {
size_t count = MdfEventGetAttachments(event, nullptr);
if (count <= 0) return std::vector<MdfAttachment>();
if (count <= 0) return {};
auto pAttachments = new const mdf::IAttachment*[count];
MdfEventGetAttachments(event, pAttachments);
std::vector<MdfAttachment> attachments;
for (size_t i = 0; i < count; i++)
attachments.push_back(MdfAttachment(pAttachments[i]));
for (size_t i = 0; i < count; i++) attachments.push_back(pAttachments[i]);
delete[] pAttachments;
return attachments;
}
double GetPreTrig() const { return MdfEventGetPreTrig(event); }
void SetPreTrig(double time) { MdfEventSetPreTrig(event, time); }
double GetPostTrig() const { return MdfEventGetPostTrig(event); }
void SetPostTrig(double time) { MdfEventSetPostTrig(event, time); }
const MdfMetaData GetMetaData() const {
return MdfMetaData(MdfEventGetMetaData(event));
}
const MdfMetaData GetMetaData() const { return MdfEventGetMetaData(event); }
void AddAttachment(MdfAttachment attachment) {
MdfEventAddAttachment(event, attachment.GetAttachment());
}
Expand Down
19 changes: 12 additions & 7 deletions include/mdflibrary/MdfExport.h
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,6 @@ EXPORTFEATUREFUNC(mdf::ISourceInformation*, CreateSourceInformation);
#define EXPORTFEATUREFUNC(ReturnType, FuncName, ...) \
EXPORT(ReturnType, MdfChannel, FuncName, mdf::IChannel* channel, \
##__VA_ARGS__)

EXPORTFEATUREFUNC(int64_t, GetIndex);
EXPORTFEATUREFUNC(size_t, GetName, char* name);
EXPORTFEATUREFUNC(void, SetName, const char* name);
Expand Down Expand Up @@ -588,10 +587,10 @@ EXPORTFEATUREFUNC(const mdf::IMetaData*, GetMetaData);
EXPORTFEATUREFUNC(const mdf::ISourceInformation*, GetSourceInformation);
EXPORTFEATUREFUNC(const mdf::IChannelConversion*, GetChannelConversion);
EXPORTFEATUREFUNC(size_t, GetChannelCompositions, mdf::IChannel* pChannels[]);
EXPORTFEATUREFUNC(mdf::IMetaData*, CreateMetaData);
EXPORTFEATUREFUNC(mdf::ISourceInformation*, CreateSourceInformation);
EXPORTFEATUREFUNC(mdf::IChannelConversion*, CreateChannelConversion);
EXPORTFEATUREFUNC(mdf::IChannel*, CreateChannelCompositions);
EXPORTFEATUREFUNC(mdf::IMetaData*, CreateMetaData);
EXPORTFEATUREFUNC(mdf::IChannel*, CreateChannelComposition);
EXPORTFEATUREFUNC(void, SetChannelValueAsSigned, const int64_t value,
bool valid = true);
EXPORTFEATUREFUNC(void, SetChannelValueAsUnSigned, const uint64_t value,
Expand Down Expand Up @@ -625,14 +624,18 @@ EXPORTFEATUREFUNC(double, GetRangeMin);
EXPORTFEATUREFUNC(double, GetRangeMax);
EXPORTFEATUREFUNC(void, SetRange, double min, double max);
EXPORTFEATUREFUNC(uint16_t, GetFlags);
EXPORTFEATUREFUNC(void, SetReference, int64_t index, const char* text);
EXPORTFEATUREFUNC(size_t, GetReference, uint16_t index, char* reference);
EXPORTFEATUREFUNC(void, SetReference, uint16_t index, const char* reference);
EXPORTFEATUREFUNC(const mdf::IChannelConversion*, GetInverse);
EXPORTFEATUREFUNC(const mdf::IMetaData*, GetMetaData);
EXPORTFEATUREFUNC(size_t, GetFormula, char* formula);
EXPORTFEATUREFUNC(void, SetFormula, const char* formula);
EXPORTFEATUREFUNC(double, GetParameter, int index);
EXPORTFEATUREFUNC(void, SetParameter, int index, double parameter);
EXPORTFEATUREFUNC(uint64_t, GetParameterUInt, int index);
EXPORTFEATUREFUNC(double, GetNofParameters, uint16_t index);
EXPORTFEATUREFUNC(double, GetParameterAsDouble, uint16_t index);
EXPORTFEATUREFUNC(void, SetParameterAsDouble, uint16_t index, double parameter);
EXPORTFEATUREFUNC(uint64_t, GetParameterAsUInt64, uint16_t index);
EXPORTFEATUREFUNC(void, SetParameterAsUInt64, uint16_t index,
uint64_t parameter);
EXPORTFEATUREFUNC(mdf::IChannelConversion*, CreateInverse);
EXPORTFEATUREFUNC(mdf::IMetaData*, CreateMetaData);
#undef EXPORTFEATUREFUNC
Expand Down Expand Up @@ -871,6 +874,8 @@ EXPORTFEATUREFUNC(uint8_t, GetBitPosition);
EXPORTFEATUREFUNC(void, SetBitPosition, const uint8_t position);
EXPORTFEATUREFUNC(CanErrorType, GetErrorType);
EXPORTFEATUREFUNC(void, SetErrorType, const CanErrorType type);
#undef EXPORTFEATUREFUNC
#pragma endregion
} // namespace MdfLibrary::ExportFunctions
}

Expand Down
Loading

0 comments on commit 87afb2d

Please sign in to comment.