Example #1
0
        public PlayerState(String player_name)
        {
            this.player_name = player_name;
            signal           = new ManualResetEvent(false);
            state_lock       = new object();
            pt = new PerformanceTest(player_name);
            sensorId_sensorData = new Dictionary <int, SensorData>();
            foreach (var sensor_id in MetaData.PLAYER_MAP[player_name])
            {
                sensorId_sensorData.Add(sensor_id, QueryHelpers.getDefaultSensorDataWithSensorID(sensor_id));
            }
            currentRunningState = new CurrentRunningState(-1, -1, -1);
            aggRunning_full     = new AggregateRunningData();
            aggRunning_1min     = new TimeWindow <CurrentRunningData, AggregateRunningData>
                                      (60 * MetaData.SECOND_TO_PICO, "ts_start", new AggregateRunningData(), QueryHelpers.updateAggregateRunningData);
            aggRunning_5min = new TimeWindow <CurrentRunningData, AggregateRunningData>
                                  (5 * 60 * MetaData.SECOND_TO_PICO, "ts_start", new AggregateRunningData(), QueryHelpers.updateAggregateRunningData);
            aggRunning_20min = new TimeWindow <CurrentRunningData, AggregateRunningData>
                                   (20 * 60 * MetaData.SECOND_TO_PICO, "ts_start", new AggregateRunningData(), QueryHelpers.updateAggregateRunningData);

            heatmap_full  = new HeatmapState(player_name);
            heatmap_1min  = new HeatmapState(player_name, 1 * 60);
            heatmap_5min  = new HeatmapState(player_name, 5 * 60);
            heatmap_10min = new HeatmapState(player_name, 10 * 60);
        }
Example #2
0
        public static CurrentRunningData updateCurrentRunningData(CurrentRunningState state, PlayerData player)
        {
            CurrentRunningData currentRunning = null;

            if (state.prev_ts != -1 && player.ts != -1)
            {
                double avgSpeed = -1;
                //picoseconds
                var timespan = player.ts - state.prev_ts;
                //distance travelled in mm
                var dist = QueryHelpers.returnDistance(state.prev_pos_x, state.prev_pos_y, player.pos_x, player.pos_y);
                //distnace travelled in km
                var dist_km = dist / 1000000;
                //Average speed in Km/hr
                if (timespan != 0)
                {
                    avgSpeed = (dist / timespan) * 3.6 * 1000000000;
                }
                currentRunning = new CurrentRunningData()
                {
                    player_id = player.player_name,
                    ts_start  = state.prev_ts,
                    ts_stop   = player.ts,
                    distance  = dist_km,
                    speed     = avgSpeed,
                    intensity = QueryHelpers.returnRunningIntensity(avgSpeed)
                };
            }
            state.prev_ts    = player.ts;
            state.prev_pos_x = player.pos_x;
            state.prev_pos_y = player.pos_y;
            return(currentRunning);
        }