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

Add timestamp to Position class

parent 6ca1df64
......@@ -37,6 +37,7 @@ typedef struct {
UA_Double x;
UA_Double y;
UA_Double z;
UA_Double timestamp;
} JSPositionData;
typedef struct {
......
......@@ -69,6 +69,7 @@ static JSValue js_new_position(JSContext *ctx, JSValueConst thisVal,
s->x = positionArray[0];
s->y = positionArray[1];
s->z = positionArray[3]; //relative altitude
s->timestamp = positionArray[4];
JS_SetOpaque(obj, s);
free(positionArray);
return obj;
......@@ -86,6 +87,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;
}
......@@ -100,6 +103,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