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 { ...@@ -37,6 +37,7 @@ typedef struct {
UA_Double x; UA_Double x;
UA_Double y; UA_Double y;
UA_Double z; UA_Double z;
UA_Double timestamp;
} JSPositionData; } JSPositionData;
typedef struct { typedef struct {
......
...@@ -69,6 +69,7 @@ static JSValue js_new_position(JSContext *ctx, JSValueConst thisVal, ...@@ -69,6 +69,7 @@ static JSValue js_new_position(JSContext *ctx, JSValueConst thisVal,
s->x = positionArray[0]; s->x = positionArray[0];
s->y = positionArray[1]; s->y = positionArray[1];
s->z = positionArray[3]; //relative altitude s->z = positionArray[3]; //relative altitude
s->timestamp = positionArray[4];
JS_SetOpaque(obj, s); JS_SetOpaque(obj, s);
free(positionArray); free(positionArray);
return obj; return obj;
...@@ -86,6 +87,8 @@ static JSValue js_position_get(JSContext *ctx, JSValueConst thisVal, int magic) ...@@ -86,6 +87,8 @@ static JSValue js_position_get(JSContext *ctx, JSValueConst thisVal, int magic)
return JS_NewFloat64(ctx, s->y); return JS_NewFloat64(ctx, s->y);
case 2: case 2:
return JS_NewFloat64(ctx, s->z); return JS_NewFloat64(ctx, s->z);
case 3:
return JS_NewFloat64(ctx, s->timestamp);
default: default:
return JS_EXCEPTION; return JS_EXCEPTION;
} }
...@@ -100,6 +103,7 @@ static const JSCFunctionListEntry js_position_proto_funcs[] = { ...@@ -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("x", js_position_get, NULL, 0),
JS_CGETSET_MAGIC_DEF("y", js_position_get, NULL, 1), JS_CGETSET_MAGIC_DEF("y", js_position_get, NULL, 1),
JS_CGETSET_MAGIC_DEF("z", js_position_get, NULL, 2), JS_CGETSET_MAGIC_DEF("z", js_position_get, NULL, 2),
JS_CGETSET_MAGIC_DEF("timestamp", js_position_get, NULL, 3),
}; };
// Drone class functions // 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