private static void KeyCallback(Window window, Keys key, int scanCode, InputState state, ModifierKeys mods)
        {
            if (key == GLFW.Keys.W && state == GLFW.InputState.Press)
            {
                // load following minute's observations
                VerticeData.VerticeSlice   = DataSelector.FetchNewerRecords(VerticeData.NormalizedReports, DataSelector.currentAP);
                VerticeData.SquareVertices = DataTransform.GenerateQuads(VerticeData.VerticeSlice, DisplayManager.ViewportWidth, DisplayManager.ViewportHeight);
            }
            else if (key == GLFW.Keys.S && state == GLFW.InputState.Press)
            {
                // load preceeding minute
                VerticeData.VerticeSlice   = DataSelector.FetchOlderRecords(VerticeData.NormalizedReports, DataSelector.currentAP);
                VerticeData.SquareVertices = DataTransform.GenerateQuads(VerticeData.VerticeSlice, DisplayManager.ViewportWidth, DisplayManager.ViewportHeight);
            }
            else if (key == GLFW.Keys.A && state == GLFW.InputState.Press)
            {
                // load previous AP's data
                DataSelector.currentAP = DataSelector.currentAP - 1;
                if (DataSelector.currentAP < 0)
                {
                    DataSelector.currentAP = VerticeData.NumberOfAPs - 1;
                }
                VerticeData.VerticeSlice   = DataSelector.FetchOlderRecords(VerticeData.NormalizedReports, DataSelector.currentAP);
                VerticeData.SquareVertices = DataTransform.GenerateQuads(VerticeData.VerticeSlice, DisplayManager.ViewportWidth, DisplayManager.ViewportHeight);
            }
            else if (key == GLFW.Keys.D && state == GLFW.InputState.Press)
            {
                // load next AP's data
                DataSelector.currentAP = DataSelector.currentAP + 1;
                if (DataSelector.currentAP > VerticeData.NumberOfAPs - 1)
                {
                    DataSelector.currentAP = 0;
                }
                VerticeData.VerticeSlice   = DataSelector.FetchOlderRecords(VerticeData.NormalizedReports, DataSelector.currentAP);
                VerticeData.SquareVertices = DataTransform.GenerateQuads(VerticeData.VerticeSlice, DisplayManager.ViewportWidth, DisplayManager.ViewportHeight);
            }
            else if (key == GLFW.Keys.R && state == GLFW.InputState.Press)
            {
                // pull fresh observation data from the DB
                DataSelector.InitData(myWidth, myHeight);

                VerticeData.VerticeSlice   = DataSelector.FetchOlderRecords(VerticeData.NormalizedReports, DataSelector.currentAP);
                VerticeData.SquareVertices = DataTransform.GenerateQuads(VerticeData.VerticeSlice, DisplayManager.ViewportWidth, DisplayManager.ViewportHeight);
            }
            else if (key == GLFW.Keys.Escape && state == GLFW.InputState.Press)
            {
                // die
                Running = false;
            }
        }
Ejemplo n.º 2
0
        static public bool InitData(int width, int height)
        {
            string[] apMacs = DBConnection.RetrieveAPs();

            if (apMacs[0] == "none")
            {
                VerticeData.NumberOfAPs = 0;
            }
            else
            {
                VerticeData.NumberOfAPs = apMacs.Length;
            }

            DataSelector.currentAP = 0;

            List <List <string> > observationReports = new List <List <string> >();

            for (int i = 0; i < apMacs.Length; i++)
            {
                observationReports.Add(DBConnection.RetrieveReports(apMacs[i]));
            }

            if (observationReports.Count < 1)
            {
                return(false);
            }

            DataSelector.currentRecord = new List <List <int> >();
            for (int x = 0; x < observationReports.Count; x++)
            {
                DataSelector.currentRecord.Add(new List <int> {
                    0
                });
            }

            float SCALE = 2.0f;

            VerticeData.NormalizedReports = DataTransform.NormalizeCoordinates(observationReports, width / SCALE, height / SCALE);

            VerticeData.VerticeSlice = DataSelector.FetchNewerRecords(VerticeData.NormalizedReports, DataSelector.currentAP);

            VerticeData.SquareVertices = DataTransform.GenerateQuads(VerticeData.VerticeSlice, width, height);

            return(true);
        }