Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
librelaxisloader
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Klemm, Carl Philipp
librelaxisloader
Commits
b57329d0
Commit
b57329d0
authored
9 months ago
by
Carl Philipp Klemm
Browse files
Options
Downloads
Patches
Plain Diff
Make metadata handling more conveniant
parent
6de8af37
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
relaxisloader.c
+84
-0
84 additions, 0 deletions
relaxisloader.c
relaxisloader/relaxisloader.h
+44
-0
44 additions, 0 deletions
relaxisloader/relaxisloader.h
with
128 additions
and
0 deletions
relaxisloader.c
+
84
−
0
View file @
b57329d0
...
...
@@ -250,6 +250,90 @@ static struct rlx_datapoint* rlx_get_datapoints(struct rlxfile* file, int id, si
return
out
;
}
const
char
*
rlx_metadata_get_key
(
enum
rlx_metadata_field
field
)
{
switch
(
field
)
{
case
RLX_FIELD_TEMPERATURE
:
return
"Temperature"
;
case
RLX_FIELD_DC_VOLTAGE
:
return
"DCVoltage"
;
case
RLX_FIELD_AC_VOLTAGE
:
return
"ACVoltage"
;
case
RLX_FIELD_CURRENT
:
return
"Current"
;
case
RLX_FIELD_TIME
:
return
"Time"
;
case
RLX_FIELD_HARMONIC
:
return
"Harmonic"
;
case
RLX_FIELD_CONCENTRATION
:
return
"Concentration"
;
case
RLX_FIELD_FREE_VARIABLE_ONE
:
return
"FreeVariable"
;
case
RLX_FIELD_FREE_VARIABLE_TWO
:
return
"FreeVariable2"
;
case
RLX_FIELD_AREA
:
return
"Area"
;
case
RLX_FIELD_THICKNESS
:
return
"Thickness"
;
case
RLX_FIELD_SOC
:
return
"SOC"
;
case
RLX_FIELD_SOH
:
return
"SOH"
;
case
RLX_FIELD_PRESSURE
:
return
"Pressure"
;
case
RLX_FIELD_UNKOWN
:
default:
return
"Unkown"
;
}
}
enum
rlx_metadata_field
rlx_metadata_get_enum
(
const
char
*
key
)
{
if
(
strcmp
(
key
,
rlx_metadata_get_key
(
RLX_FIELD_TEMPERATURE
))
==
0
)
return
RLX_FIELD_TEMPERATURE
;
else
if
(
strcmp
(
key
,
rlx_metadata_get_key
(
RLX_FIELD_DC_VOLTAGE
))
==
0
)
return
RLX_FIELD_DC_VOLTAGE
;
else
if
(
strcmp
(
key
,
rlx_metadata_get_key
(
RLX_FIELD_AC_VOLTAGE
))
==
0
)
return
RLX_FIELD_AC_VOLTAGE
;
else
if
(
strcmp
(
key
,
rlx_metadata_get_key
(
RLX_FIELD_CURRENT
))
==
0
)
return
RLX_FIELD_CURRENT
;
else
if
(
strcmp
(
key
,
rlx_metadata_get_key
(
RLX_FIELD_TIME
))
==
0
)
return
RLX_FIELD_TIME
;
else
if
(
strcmp
(
key
,
rlx_metadata_get_key
(
RLX_FIELD_HARMONIC
))
==
0
)
return
RLX_FIELD_HARMONIC
;
else
if
(
strcmp
(
key
,
rlx_metadata_get_key
(
RLX_FIELD_CONCENTRATION
))
==
0
)
return
RLX_FIELD_CONCENTRATION
;
else
if
(
strcmp
(
key
,
rlx_metadata_get_key
(
RLX_FIELD_FREE_VARIABLE_ONE
))
==
0
)
return
RLX_FIELD_FREE_VARIABLE_ONE
;
else
if
(
strcmp
(
key
,
rlx_metadata_get_key
(
RLX_FIELD_FREE_VARIABLE_TWO
))
==
0
)
return
RLX_FIELD_FREE_VARIABLE_TWO
;
else
if
(
strcmp
(
key
,
rlx_metadata_get_key
(
RLX_FIELD_AREA
))
==
0
)
return
RLX_FIELD_AREA
;
else
if
(
strcmp
(
key
,
rlx_metadata_get_key
(
RLX_FIELD_THICKNESS
))
==
0
)
return
RLX_FIELD_THICKNESS
;
else
if
(
strcmp
(
key
,
rlx_metadata_get_key
(
RLX_FIELD_SOC
))
==
0
)
return
RLX_FIELD_SOC
;
else
if
(
strcmp
(
key
,
rlx_metadata_get_key
(
RLX_FIELD_SOH
))
==
0
)
return
RLX_FIELD_SOH
;
else
if
(
strcmp
(
key
,
rlx_metadata_get_key
(
RLX_FIELD_PRESSURE
))
==
0
)
return
RLX_FIELD_PRESSURE
;
else
if
(
strcmp
(
key
,
rlx_metadata_get_key
(
RLX_FIELD_PRESSURE
))
==
0
)
return
RLX_FIELD_PRESSURE
;
return
RLX_FIELD_UNKOWN
;
}
struct
rlx_metadata
*
rlx_metadata_get
(
struct
rlx_spectra
*
spectra
,
const
char
*
key
)
{
for
(
size_t
i
=
0
;
i
<
spectra
->
metadata_count
;
++
i
)
{
if
(
strcmp
(
spectra
->
metadata
[
i
].
key
,
key
)
==
0
)
return
spectra
->
metadata
+
i
;
}
return
NULL
;
}
static
struct
rlx_metadata
*
rlx_get_metadata
(
struct
rlxfile
*
file
,
int
id
,
size_t
*
length
)
{
char
**
table
;
...
...
This diff is collapsed.
Click to expand it.
relaxisloader/relaxisloader.h
+
44
−
0
View file @
b57329d0
...
...
@@ -101,6 +101,25 @@ enum rlx_field_type
RLX_FIELD_TYPE_DOUBLE
};
enum
rlx_metadata_field
{
RLX_FIELD_TEMPERATURE
,
RLX_FIELD_DC_VOLTAGE
,
RLX_FIELD_AC_VOLTAGE
,
RLX_FIELD_CURRENT
,
RLX_FIELD_TIME
,
RLX_FIELD_HARMONIC
,
RLX_FIELD_CONCENTRATION
,
RLX_FIELD_FREE_VARIABLE_ONE
,
RLX_FIELD_FREE_VARIABLE_TWO
,
RLX_FIELD_AREA
,
RLX_FIELD_THICKNESS
,
RLX_FIELD_SOC
,
RLX_FIELD_SOH
,
RLX_FIELD_PRESSURE
,
RLX_FIELD_UNKOWN
,
};
struct
rlx_metadata
{
char
*
key
;
char
*
str
;
...
...
@@ -115,6 +134,22 @@ struct rlx_metadata {
*/
void
rlx_metadata_free
(
struct
rlx_metadata
*
metadata
);
/**
* @brief Gets the key string corrisponding to a field enum.
*
* @param field the enum of the field to get the key to
* @return A string with the key corrisponding to the enum. Owned by librelaxisloader do not free.
*/
const
char
*
rlx_metadata_get_key
(
enum
rlx_metadata_field
field
);
/**
* @brief Gets the field enum corrisponding to the key string.
*
* @param key the key string.
* @return the enum corrisponding to the key.
*/
enum
rlx_metadata_field
rlx_metadata_get_enum
(
const
char
*
key
);
/**
* @brief This struct is used to house an EIS spectra and associated meta-data.
**/
...
...
@@ -155,6 +190,15 @@ void rlx_spectra_free(struct rlx_spectra* spectra);
*/
void
rlx_spectra_free_array
(
struct
rlx_spectra
**
spectra_array
);
/**
* @brief Finds a key-value pair in a spectra
*
* @param spectra the spectra.
* @param key the key to search for.
* @return A pointer to the metadatas struct corrisponding to the key or NULL if the array dose not contain the key. Owned by the spectra.
*/
struct
rlx_metadata
*
rlx_metadata_get
(
struct
rlx_spectra
*
spectra
,
const
char
*
key
);
struct
rlx_fitparam
{
int
spectra_id
;
int
p_index
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment