Commit ea0066f2 authored by Léo-Paul Géneau's avatar Léo-Paul Géneau 👾

Add timestamp to Position class

parent 0102bab3
......@@ -37,6 +37,7 @@ typedef struct {
UA_Double x;
UA_Double y;
UA_Double z;
UA_Double timestamp;
} JSPositionData;
typedef struct {
......
......@@ -71,6 +71,7 @@ static JSValue js_new_position(JSContext *ctx, JSValueConst thisVal,
s->x = positionArray[0];
s->y = positionArray[1];
s->z = positionArray[3];
s->timestamp = positionArray[4];
JS_SetOpaque(obj, s);
free(positionArray);
return obj;
......@@ -88,6 +89,8 @@ static JSValue js_position_get(JSContext *ctx, JSValueConst thisVal, int magic)
return JS_NewFloat64(ctx, s->y);
case 2:
return JS_NewFloat64(ctx, s->z);
case 3:
return JS_NewFloat64(ctx, s->timestamp);
default:
return JS_EXCEPTION;
}
......@@ -102,6 +105,7 @@ static const JSCFunctionListEntry js_position_proto_funcs[] = {
JS_CGETSET_MAGIC_DEF("x", js_position_get, NULL, 0),
JS_CGETSET_MAGIC_DEF("y", js_position_get, NULL, 1),
JS_CGETSET_MAGIC_DEF("z", js_position_get, NULL, 2),
JS_CGETSET_MAGIC_DEF("timestamp", js_position_get, NULL, 3),
};
// Drone class functions
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment