Commit 81cb4c40 authored by Jérome Perrin's avatar Jérome Perrin

Merge remote-tracking branch 'nexedi/master' into zope4py2

parents 81b1ff45 d8b91190
/*global console*/
/*global BABYLON, console*/
/*jslint nomen: true, indent: 2, maxlen: 80, white: true */
/**************************** DRONE LOG FOLLOWER ******************************/
var DroneLogAPI = /** @class */ (function () {
"use strict";
var TOP_SPEED = 250; //so fast that it virtually "teleports" to target
//** CONSTRUCTOR
function DroneLogAPI(gameManager, drone_info, flight_parameters, id) {
this._gameManager = gameManager;
......@@ -15,7 +16,13 @@ var DroneLogAPI = /** @class */ (function () {
/*
** Function called at start phase of the drone, just before onStart AI script
*/
DroneLogAPI.prototype.internal_start = function () {
DroneLogAPI.prototype.internal_start = function (drone) {
drone._minAcceleration = -1;
drone._maxAcceleration = 1;
drone._minSpeed = TOP_SPEED;
drone._maxSpeed = TOP_SPEED;
drone._acceleration = 10;
drone._speed = TOP_SPEED;
function getLogEntries(log) {
var i, line_list = log.split('\n'), log_entry_list = [], log_entry,
log_header_found;
......@@ -69,22 +76,43 @@ var DroneLogAPI = /** @class */ (function () {
this._flight_parameters.converted_log_point_list = converted_log_point_list;
};
/*
** Function called on every drone update, right before onUpdate AI script
*/
DroneLogAPI.prototype.internal_update = function (context, delta_time) {
var updateSpeed;
context._speed += context._acceleration * delta_time / 1000;
if (context._speed > context._maxSpeed) {
context._speed = context._maxSpeed;
}
if (context._speed < -context._maxSpeed) {
context._speed = -context._maxSpeed;
}
updateSpeed = context._speed * delta_time / 1000;
if (context._direction.x !== 0 ||
context._direction.y !== 0 ||
context._direction.z !== 0) {
context._controlMesh.position.addInPlace(new BABYLON.Vector3(
context._direction.x * updateSpeed,
context._direction.y * updateSpeed,
context._direction.z * updateSpeed));
}
context._controlMesh.computeWorldMatrix(true);
context._mesh.computeWorldMatrix(true);
};
/*
** Function called on every drone update, right after onUpdate AI script
*/
DroneLogAPI.prototype.internal_update = function () {
DroneLogAPI.prototype.internal_post_update = function (drone) {
return;
};
DroneLogAPI.prototype.internal_setTargetCoordinates =
function (drone, x, y, z) {
var coordinates = this.processCoordinates(x, y, z);
function (drone, coordinates) {
coordinates.x -= drone._controlMesh.position.x;
coordinates.y -= drone._controlMesh.position.z;
coordinates.z -= drone._controlMesh.position.y;
drone.setDirection(coordinates.x, coordinates.y, coordinates.z);
drone.setAcceleration(drone._maxAcceleration);
return;
};
DroneLogAPI.prototype.sendMsg = function (msg, to) {
return;
};
......@@ -96,6 +124,16 @@ var DroneLogAPI = /** @class */ (function () {
return this._gameManager.gameParameter[name];
}
};
DroneLogAPI.prototype.setStartingPosition = function (drone, x, y, z) {
if (!drone._canPlay) {
if (z <= 0.05) {
z = 0.05;
}
drone._controlMesh.position = new BABYLON.Vector3(x, z, y);
}
drone._controlMesh.computeWorldMatrix(true);
drone._mesh.computeWorldMatrix(true);
};
DroneLogAPI.prototype.processCoordinates = function (x, y, z) {
if(isNaN(x) || isNaN(y) || isNaN(z)){
throw new Error('Target coordinates must be numbers');
......@@ -126,12 +164,11 @@ var DroneLogAPI = /** @class */ (function () {
'me.setTargetCoordinates(me.checkpoint_list[0][0], ' +
'me.checkpoint_list[0][1], me.checkpoint_list[0][2]);' +
'me.last_checkpoint_reached = -1;' +
'me.setAcceleration(10);' +
'};' +
'me.onUpdate = function(timestamp) {' +
'var next_checkpoint = me.checkpoint_list' +
'[me.last_checkpoint_reached+1];' +
'if (distance([me.position.x, me.position.y], next_checkpoint) < 12) {' +
'if (distance([me.position.x, me.position.y], next_checkpoint) < 10) {' +
'me.going = false;' +
'var log_elapsed = next_checkpoint[3] - me.initTimestamp,' +
'time_elapsed = new Date() - me.startTime;' +
......@@ -165,30 +202,6 @@ var DroneLogAPI = /** @class */ (function () {
z: z
};
};
DroneLogAPI.prototype.set_loiter_mode = function (radius, drone) {
return;
};
DroneLogAPI.prototype.setAltitude = function (altitude, drone) {
return;
};
DroneLogAPI.prototype.getMaxSpeed = function () {
return 3000;
};
DroneLogAPI.prototype.getInitialAltitude = function () {
return 0;
};
DroneLogAPI.prototype.getAltitudeAbs = function () {
return 0;
};
DroneLogAPI.prototype.getMinHeight = function () {
return 0;
};
DroneLogAPI.prototype.getMaxHeight = function () {
return 220;
};
DroneLogAPI.prototype.triggerParachute = function (drone) {
return;
};
DroneLogAPI.prototype.getFlightParameters = function () {
return this._flight_parameters;
};
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1004.33468.24270.48913</string> </value>
<value> <string>1006.4961.7659.53043</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1669196851.18</float>
<float>1675263473.08</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -75,7 +75,7 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_erp5_page_drone_simulator_droneaaailefixe.js</string> </value>
<value> <string>gadget_erp5_page_drone_simulator_logic.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
......@@ -85,7 +85,7 @@
</item>
<item>
<key> <string>id</string> </key>
<value> <string>drone_simulator_droneaaailefixe_js</string> </value>
<value> <string>drone_simulator_logic_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
......@@ -105,7 +105,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Drone A Aile Fixe (API)</string> </value>
<value> <string>Drone Logic</string> </value>
</item>
<item>
<key> <string>version</string> </key>
......@@ -144,12 +144,6 @@
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>processing_status_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
......@@ -197,7 +191,7 @@
</tuple>
<state>
<tuple>
<float>1664807682.76</float>
<float>1674834569.27</float>
<string>UTC</string>
</tuple>
</state>
......@@ -246,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1004.62583.63891.22220</string> </value>
<value> <string>1006.2016.60568.40294</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,72 +260,7 @@
</tuple>
<state>
<tuple>
<float>1670856495.99</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_processing_state</string> </key>
<value> <string>empty</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>0.0.0.0</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="DateTime" module="DateTime.DateTime"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<tuple>
<float>1664807031.69</float>
<float>1675086932.85</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -144,12 +144,6 @@
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>processing_status_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
......@@ -197,7 +191,7 @@
</tuple>
<state>
<tuple>
<float>1662477480.35</float>
<float>1674834569.27</float>
<string>UTC</string>
</tuple>
</state>
......@@ -246,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1004.32349.9544.44100</string> </value>
<value> <string>1006.2016.60568.40294</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,72 +260,7 @@
</tuple>
<state>
<tuple>
<float>1670852474.69</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_processing_state</string> </key>
<value> <string>empty</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>0.0.0.0</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="_reconstructor" module="copy_reg"/>
</klass>
<tuple>
<global name="DateTime" module="DateTime.DateTime"/>
<global name="object" module="__builtin__"/>
<none/>
</tuple>
<state>
<tuple>
<float>1662477378.07</float>
<float>1675086932.85</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -13,7 +13,7 @@
HEIGHT = 340,
LOGIC_FILE_LIST = [
'gadget_erp5_page_drone_simulator_logic.js',
'gadget_erp5_page_drone_simulator_droneaaailefixe.js',
'gadget_erp5_page_drone_simulator_fixedwingdrone.js',
'gadget_erp5_page_drone_simulator_dronelogfollower.js'
];
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1005.1310.34623.11861</string> </value>
<value> <string>1005.28725.31731.34065</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1671112620.77</float>
<float>1672757496.65</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1005.37533.1915.8379</string> </value>
<value> <string>1006.17791.59880.25668</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1673286304.13</float>
<float>1676033282.59</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -6,7 +6,7 @@ url_list = [
"gadget_erp5_page_drone_simulator_log_page.js",
"gadget_erp5_panel_drone_simulator.html",
"gadget_erp5_panel_drone_simulator.js",
"gadget_erp5_page_drone_simulator_droneaaailefixe.js",
"gadget_erp5_page_drone_simulator_fixedwingdrone.js",
"gadget_erp5_page_drone_simulator_dronelogfollower.js",
"drone.png",
"gadget_officejs_drone_simulator.json",
......
......@@ -52,10 +52,16 @@ function mainToWorker(evt) {
})
.push(function () {
return postMessage({'type': 'updated'});
}, function (error) {
console.log("ERROR:", error);
return postMessage({'type': 'error', 'error': error});
});
case 'event':
handleEvent(evt.data);
break;
return new RSVP.Queue(handleEvent(evt.data))
.push(undefined, function (error) {
console.log("ERROR:", error);
return postMessage({'type': 'error', 'error': error});
});
default:
throw new Error('Unsupported message ' + JSON.stringify(evt.data));
}
......
......@@ -246,7 +246,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>1004.22590.57904.22954</string> </value>
<value> <string>1005.41422.8371.11861</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -266,7 +266,7 @@
</tuple>
<state>
<tuple>
<float>1671113075.12</float>
<float>1674224630.4</float>
<string>UTC</string>
</tuple>
</state>
......
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