1
0
Fork 0
mirror of https://git.rwth-aachen.de/acs/public/villas/node/ synced 2025-03-09 00:00:00 +01:00

sample: remove obsolete id member

This commit is contained in:
Steffen Vogel 2018-05-08 08:51:24 +02:00
parent 18096feb49
commit b18c776a5c
10 changed files with 10 additions and 58 deletions

View file

@ -48,7 +48,6 @@
.type = MSG_TYPE_DATA, \
.length = len, \
.sequence = seq, \
.id = 0 \
}
/** The timestamp of a message in struct timespec format */
@ -75,7 +74,7 @@ struct msg
#error Invalid byte-order
#endif
uint8_t id; /**< An id which identifies the source of this sample. */
uint8_t resv2; /**< An id which identifies the source of this sample. */
uint16_t length; /**< The number of values in msg::data[]. */
uint32_t sequence; /**< The sequence number is incremented by one for consecutive messages. */

View file

@ -70,7 +70,6 @@ struct mapping_entry {
enum header_type {
MAPPING_HDR_LENGTH,
MAPPING_HDR_SEQUENCE,
MAPPING_HDR_ID,
MAPPING_HDR_FORMAT
} id;
} hdr;

View file

@ -78,7 +78,6 @@ struct sample {
int capacity; /**< The number of values in sample::values for which memory is reserved. */
int flags; /**< Flags are used to store binary properties of a sample. */
int id; /**< The id field is usually the same as sample::source::id */
struct node *source; /**< The node from which this sample originates. */
atomic_int refcnt; /**< Reference counter. */

View file

@ -82,7 +82,6 @@ int msg_to_sample(struct msg *msg, struct sample *smp)
smp->flags = SAMPLE_HAS_ORIGIN | SAMPLE_HAS_SEQUENCE | SAMPLE_HAS_VALUES | SAMPLE_HAS_ID;
smp->length = MIN(msg->length, smp->capacity);
smp->sequence = msg->sequence;
smp->id = msg->id;
smp->ts.origin = MSG_TS(msg);
smp->format = 0;
@ -102,7 +101,6 @@ int msg_from_sample(struct msg *msg, struct sample *smp)
msg->ts.sec = smp->ts.origin.tv_sec;
msg->ts.nsec = smp->ts.origin.tv_nsec;
msg->id = smp->id;
for (int i = 0; i < smp->length; i++) {
switch (sample_get_data_format(smp, i)) {

View file

@ -50,11 +50,6 @@ int protobuf_sprint(char *buf, size_t len, size_t *wbytes, struct sample *smps[]
pb_smp->sequence = smp->sequence;
}
if (smp->flags & SAMPLE_HAS_ID) {
pb_smp->has_id = 1;
pb_smp->id = smp->id;
}
if (smp->flags & SAMPLE_HAS_ORIGIN) {
pb_smp->timestamp = alloc(sizeof(Villas__Node__Timestamp));
villas__node__timestamp__init(pb_smp->timestamp);
@ -121,11 +116,6 @@ int protobuf_sscan(char *buf, size_t len, size_t *rbytes, struct sample *smps[],
smp->sequence = pb_smp->sequence;
}
if (pb_smp->has_id) {
smp->flags |= SAMPLE_HAS_ID;
smp->id = pb_smp->id;
}
if (pb_smp->timestamp) {
smp->flags |= SAMPLE_HAS_ORIGIN;
smp->ts.origin.tv_sec = pb_smp->timestamp->sec;

View file

@ -248,7 +248,7 @@ const ProtobufCEnumDescriptor villas__node__sample__type__descriptor =
NULL,NULL,NULL,NULL /* reserved[1234] */
};
static const Villas__Node__Sample__Type villas__node__sample__type__default_value = VILLAS__NODE__SAMPLE__TYPE__DATA;
static const ProtobufCFieldDescriptor villas__node__sample__field_descriptors[5] =
static const ProtobufCFieldDescriptor villas__node__sample__field_descriptors[4] =
{
{
"type",
@ -274,18 +274,6 @@ static const ProtobufCFieldDescriptor villas__node__sample__field_descriptors[5]
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"id",
3,
PROTOBUF_C_LABEL_OPTIONAL,
PROTOBUF_C_TYPE_UINT32,
offsetof(Villas__Node__Sample, has_id),
offsetof(Villas__Node__Sample, id),
NULL,
NULL,
0, /* flags */
0,NULL,NULL /* reserved1,reserved2, etc */
},
{
"timestamp",
4,
@ -312,16 +300,16 @@ static const ProtobufCFieldDescriptor villas__node__sample__field_descriptors[5]
},
};
static const unsigned villas__node__sample__field_indices_by_name[] = {
2, /* field[2] = id */
1, /* field[1] = sequence */
3, /* field[3] = timestamp */
2, /* field[2] = timestamp */
0, /* field[0] = type */
4, /* field[4] = values */
3, /* field[3] = values */
};
static const ProtobufCIntRange villas__node__sample__number_ranges[1 + 1] =
static const ProtobufCIntRange villas__node__sample__number_ranges[2 + 1] =
{
{ 1, 0 },
{ 0, 5 }
{ 4, 2 },
{ 0, 4 }
};
const ProtobufCMessageDescriptor villas__node__sample__descriptor =
{
@ -331,10 +319,10 @@ const ProtobufCMessageDescriptor villas__node__sample__descriptor =
"Villas__Node__Sample",
"villas.node",
sizeof(Villas__Node__Sample),
5,
4,
villas__node__sample__field_descriptors,
villas__node__sample__field_indices_by_name,
1, villas__node__sample__number_ranges,
2, villas__node__sample__number_ranges,
(ProtobufCMessageInit) villas__node__sample__init,
NULL,NULL,NULL /* reserved[123] */
};

View file

@ -61,18 +61,13 @@ struct _Villas__Node__Sample
*/
protobuf_c_boolean has_sequence;
uint32_t sequence;
/*
* An id which identifies the source of this sample.
*/
protobuf_c_boolean has_id;
uint32_t id;
Villas__Node__Timestamp *timestamp;
size_t n_values;
Villas__Node__Value **values;
};
#define VILLAS__NODE__SAMPLE__INIT \
{ PROTOBUF_C_MESSAGE_INIT (&villas__node__sample__descriptor) \
, VILLAS__NODE__SAMPLE__TYPE__DATA, 0,0, 0,0, NULL, 0,NULL }
, VILLAS__NODE__SAMPLE__TYPE__DATA, 0,0, NULL, 0,NULL }
struct _Villas__Node__Timestamp

View file

@ -38,7 +38,6 @@ message Sample {
required Type type = 1 [default = DATA];
optional uint32 sequence = 2; // The sequence number is incremented by one for consecutive messages.
optional uint32 id = 3; // An id which identifies the source of this sample.
optional Timestamp timestamp = 4;
repeated Value values = 5;
}

View file

@ -107,8 +107,6 @@ int mapping_parse_str(struct mapping_entry *me, const char *str, struct list *no
me->hdr.id = MAPPING_HDR_SEQUENCE;
else if (!strcmp(field, "length"))
me->hdr.id = MAPPING_HDR_LENGTH;
else if (!strcmp(field, "id"))
me->hdr.id = MAPPING_HDR_ID;
else if (!strcmp(field, "format"))
me->hdr.id = MAPPING_HDR_FORMAT;
else
@ -306,9 +304,6 @@ int mapping_update(struct mapping_entry *me, struct sample *remapped, struct sam
case MAPPING_HDR_SEQUENCE:
remapped->data[off++].i = original->sequence;
break;
case MAPPING_HDR_ID:
remapped->data[off++].i = original->id;
break;
case MAPPING_HDR_FORMAT:
remapped->data[off++].i = original->format;
break;
@ -344,7 +339,6 @@ int mapping_remap(struct list *m, struct sample *remapped, struct sample *origin
remapped->sequence = original->sequence;
remapped->source = original->source;
remapped->ts = original->ts;
remapped->id = original->id;
for (size_t i = 0; i < list_length(m); i++) {
struct mapping_entry *me = (struct mapping_entry *) list_at(m, i);

View file

@ -132,7 +132,6 @@ int sample_copy(struct sample *dst, struct sample *src)
dst->sequence = src->sequence;
dst->format = src->format;
dst->source = src->source;
dst->id = src->id;
dst->flags = src->flags;
dst->ts = src->ts;
@ -209,14 +208,6 @@ int sample_cmp(struct sample *a, struct sample *b, double epsilon, int flags)
}
}
/* Compare ID */
if (flags & SAMPLE_HAS_SOURCE) {
if (a->id != b->id) {
printf("id: %d != %d\n", a->id, b->id);
return 7;
}
}
/* Compare data */
if (flags & SAMPLE_HAS_VALUES) {
if (a->length != b->length) {