Exemplo n.º 1
0
        private void cboBeats_SelectedIndexChanged(object sender, EventArgs e)
        {
            SQLCode sql = new SQLCode();

            if (cboBeats.Text.ToUpper() != "SELECT")
            {
                string where = "AND Beat = '" + cboBeats.Text + "'";
                cboCallsigns.Items.Clear();
                cboTrucks.Items.Clear();
                cboDrivers.Items.Clear();
                List <string> callSigns = sql.getData(startDateTime, endDateTime, "CALLSIGNS", where);
                List <string> trucks    = sql.getData(startDateTime, endDateTime, "TRUCKS", where);
                List <string> drivers   = sql.getData(startDateTime, endDateTime, "DRIVERS", where);
                foreach (string s in callSigns)
                {
                    cboCallsigns.Items.Add(s);
                }
                foreach (string s in trucks)
                {
                    cboTrucks.Items.Add(s);
                }
                foreach (string s in drivers)
                {
                    cboDrivers.Items.Add(s);
                }
                cboCallsigns.SelectedIndex = 0;
                cboTrucks.SelectedIndex    = 0;
                cboDrivers.SelectedIndex   = 0;
            }
            else
            {
                string where = "NA";
                cboCallsigns.Items.Clear();
                cboTrucks.Items.Clear();
                cboDrivers.Items.Clear();
                List <string> callSigns = sql.getData(startDateTime, endDateTime, "CALLSIGNS", where);
                List <string> trucks    = sql.getData(startDateTime, endDateTime, "TRUCKS", where);
                List <string> drivers   = sql.getData(startDateTime, endDateTime, "DRIVERS", where);
                foreach (string s in callSigns)
                {
                    cboCallsigns.Items.Add(s);
                }
                foreach (string s in trucks)
                {
                    cboTrucks.Items.Add(s);
                }
                foreach (string s in drivers)
                {
                    cboDrivers.Items.Add(s);
                }
                cboCallsigns.SelectedIndex = 0;
                cboTrucks.SelectedIndex    = 0;
                cboDrivers.SelectedIndex   = 0;
            }
        }
Exemplo n.º 2
0
        private void btnPlayback_Click(object sender, EventArgs e)
        {
            btnPlayback.BackColor     = System.Drawing.Color.Red;
            btnPlayback.Enabled       = false;
            btnStopPlayback.BackColor = System.Drawing.Color.LightGreen;
            btnStopPlayback.Enabled   = true;
            SQLCode sql = new SQLCode();

            mustStop = false;
            gMapControl1.Overlays.Clear();
            if (startDateTime == Convert.ToDateTime("1/1/0001") || endDateTime == Convert.ToDateTime("1/1/0001"))
            {
                MessageBox.Show("Missing Date/Time information, preload data first");
                return;
            }

            if (string.IsNullOrEmpty(cboTrucks.Text))
            {
                MessageBox.Show("Please select a truck first");
                return;
            }
            bool check = true;

            if (cboTrucks.Text.ToUpper() != "SELECT" && check == true)
            {
                sql.loadTruckPlaybackData(cboTrucks.Text, startDateTime, endDateTime);
                check = false;
            }

            if (cboCallsigns.Text.ToUpper() != "SELECT" && check == true)
            {
                sql.loadCallSignPlayback(cboCallsigns.Text, startDateTime, endDateTime);
                check = false;
            }

            if (cboDrivers.Text.ToUpper() != "SELECT" && check == true)
            {
                sql.loadDriverPlayback(cboDrivers.Text, startDateTime, endDateTime);
                check = false;
            }

            if (cboContractors.Text.ToUpper() != "SELECT" && check == true)
            {
                sql.loadContractorPlayback(cboContractors.Text, startDateTime, endDateTime);
                check = false;
            }

            if (cboBeats.Text.ToUpper() != "SELECT" && check == true)
            {
                sql.loadBeatPlayback(cboBeats.Text, startDateTime, endDateTime);
                check = false;
            }

            //find max speed in range
            int maxSpeed = 0;

            foreach (playBackRow row in globalData.playbackData)
            {
                if (row.Speed > maxSpeed)
                {
                    maxSpeed = row.Speed;
                }
            }
            chartControl1.Series.Clear();
            DevExpress.XtraCharts.Series series    = new DevExpress.XtraCharts.Series("Speed Over Time", DevExpress.XtraCharts.ViewType.Line);
            DevExpress.XtraCharts.Series barSeries = new DevExpress.XtraCharts.Series("Max Speed", DevExpress.XtraCharts.ViewType.Bar);

            string beatNumber = "NOBEAT";

            foreach (playBackRow row in globalData.playbackData)
            {
                if (row.Beat != "NOBEAT")
                {
                    beatNumber = row.Beat;
                    break;
                }
            }
            drawBeats(beatNumber);
            drawDrops(beatNumber);
            //Add Data to the chart
            foreach (playBackRow row in globalData.playbackData)
            {
                string st     = string.Empty;
                string hour   = row.timeStamp.Hour.ToString();
                string minute = row.timeStamp.Minute.ToString();
                string second = row.timeStamp.Second.ToString();
                while (hour.Length < 2)
                {
                    hour = "0" + hour;
                }
                while (minute.Length < 2)
                {
                    minute = "0" + minute;
                }
                while (second.Length < 2)
                {
                    second = "0" + second;
                }
                st = hour + "." + minute + "." + second;
                series.Points.Add(new DevExpress.XtraCharts.SeriesPoint(st, row.Speed));
                DevExpress.XtraCharts.SeriesPoint barPoint = new DevExpress.XtraCharts.SeriesPoint(st, maxSpeed);
                barPoint.Tag = row.Status;
                barSeries.Points.Add(barPoint);
            }
            chartControl1.Series.Add(barSeries);
            chartControl1.Series.Add(series);

            gvData.DataSource = globalData.playbackData;
            gvData.RefreshDataSource();
            try
            {
                List <statusData> status = sql.getStatusData(cboTrucks.Text, startDateTime, endDateTime);
                gvStatusData.DataSource = status;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            int pbSpeed = 1;

            if (!string.IsNullOrEmpty(cboPlaybackSpeed.Text))
            {
                string selSpeed = cboPlaybackSpeed.Text;
                pbSpeed = Convert.ToInt32(selSpeed.Replace("x", ""));
            }

            tmrPlayback.Interval = 10000 / pbSpeed; //defaults at updating every 10 seconds
            tmrPlayback.Start();
        }
Exemplo n.º 3
0
        private void btnLoadData_Click(object sender, EventArgs e)
        {
            btnLoadData.Enabled       = false;
            btnLoadData.BackColor     = System.Drawing.Color.Red;
            btnPlayback.BackColor     = System.Drawing.Color.Red;
            btnStopPlayback.BackColor = System.Drawing.Color.Red;
            btnPlayback.Enabled       = false;
            btnStopPlayback.Enabled   = false;
            Cursor = Cursors.WaitCursor;
            SQLCode sql     = new SQLCode();
            bool    chkTime = checkTimeRange();

            if (!chkTime)
            {
                return;
            }
            try {
                if (startDateTime == Convert.ToDateTime("1/1/0001") || endDateTime == Convert.ToDateTime("1/1/0001"))
                {
                    MessageBox.Show("Missing Date/Time information, preload data first");
                    return;
                }

                if (string.IsNullOrEmpty(cboTrucks.Text))
                {
                    MessageBox.Show("Please select a truck first");
                    return;
                }
                bool check = true;
                if (cboTrucks.Text.ToUpper() != "SELECT" && check == true)
                {
                    sql.loadTruckPlaybackData(cboTrucks.Text, startDateTime, endDateTime);
                    check = false;
                }

                if (cboCallsigns.Text.ToUpper() != "SELECT" && check == true)
                {
                    sql.loadCallSignPlayback(cboCallsigns.Text, startDateTime, endDateTime);
                    check = false;
                }

                if (cboDrivers.Text.ToUpper() != "SELECT" && check == true)
                {
                    sql.loadDriverPlayback(cboDrivers.Text, startDateTime, endDateTime);
                    check = false;
                }

                /*  Can't run a query by contractor or beat since that would return multiple trucks
                 * Multiple truck completely bone up the graph */
                if (cboContractors.Text.ToUpper() != "SELECT" && check == true)
                {
                    /*
                     * sql.loadContractorPlayback(cboContractors.Text, startDateTime, endDateTime);
                     * check = false;
                     * */
                    MessageBox.Show("This functionality has been disabled");
                    return;
                }

                if (cboBeats.Text.ToUpper() != "SELECT" && check == true)
                {
                    /*
                     * sql.loadBeatPlayback(cboBeats.Text, startDateTime, endDateTime);
                     * check = false;
                     * */
                    MessageBox.Show("This functionality has been disabled");
                    return;
                }

                gMapControl1.Overlays.Clear();
                if (globalData.playbackData.Count > 0)
                {
                    string beatNumber = "NOBEAT";
                    foreach (playBackRow row in globalData.playbackData)
                    {
                        if (row.Beat != "NOBEAT")
                        {
                            beatNumber = row.Beat;
                            break;
                        }
                    }
                    drawBeats(beatNumber);
                    drawDrops(beatNumber);
                    gMapControl1.Position = new PointLatLng(globalData.playbackData[0].Lat, globalData.playbackData[0].Lon);
                    //chart data
                    chartControl1.Series.Clear();
                    //find max speed in range
                    int maxSpeed = 0;
                    foreach (playBackRow row in globalData.playbackData)
                    {
                        if (row.Speed > maxSpeed)
                        {
                            maxSpeed = row.Speed;
                        }
                    }
                    if (maxSpeed == 0)
                    {
                        maxSpeed = 1;
                    }
                    DevExpress.XtraCharts.Series series    = new DevExpress.XtraCharts.Series("Speed Over Time", DevExpress.XtraCharts.ViewType.Line);
                    DevExpress.XtraCharts.Series barSeries = new DevExpress.XtraCharts.Series("Max Speed", DevExpress.XtraCharts.ViewType.Bar);
                    //Add Data to the chart
                    foreach (playBackRow row in globalData.playbackData)
                    {
                        string st     = string.Empty;
                        string hour   = row.timeStamp.Hour.ToString();
                        string minute = row.timeStamp.Minute.ToString();
                        string second = row.timeStamp.Second.ToString();
                        while (hour.Length < 2)
                        {
                            hour = "0" + hour;
                        }
                        while (minute.Length < 2)
                        {
                            minute = "0" + minute;
                        }
                        while (second.Length < 2)
                        {
                            second = "0" + second;
                        }
                        st = hour + "." + minute + "." + second;
                        series.Points.Add(new DevExpress.XtraCharts.SeriesPoint(st, row.Speed));
                        DevExpress.XtraCharts.SeriesPoint barPoint = new DevExpress.XtraCharts.SeriesPoint(st, maxSpeed);
                        barPoint.Tag = row.Status;

                        //barPoint.DateTimeArgument = row.timeStamp;
                        barPoint.ToolTipHint = row.Status;
                        barSeries.Points.Add(barPoint);

                        //add map data
                        GMapOverlay overlay = new GMapOverlay(row.timeStamp.ToString());
                        //Image markerImage = Image.FromFile(currentDirectory + geticonName(row.Status));
                        Image markerImage = getImage(row.Status);
                        markerImage = rotateImageByAngle(markerImage, row.Heading);
                        GMapCustomImageMarker marker = new GMapCustomImageMarker(markerImage, new PointLatLng(row.Lat, row.Lon));

                        marker.Size        = Size.Add(new System.Drawing.Size(markerImage.Height - 4, markerImage.Width - 4), new System.Drawing.Size(10, 10));
                        marker.ToolTipText = "Truck Number: " + row.TruckNumber + "|TimeStamp: " + row.timeStamp.ToString() + Environment.NewLine + "Click for more data";

                        overlay.Markers.Add(marker);
                        gMapControl1.Overlays.Add(overlay);
                    }
                    gMapControl1.Refresh();
                    //barSeries.ToolTipHintDataMember = barSeries.Tag.ToString();
                    chartControl1.Series.Add(barSeries);

                    chartControl1.Series.Add(series);


                    //map data
                    gvData.DataSource = globalData.playbackData;
                    gvData.RefreshDataSource();
                }
            }
            catch (Exception ex) {
                MessageBox.Show(ex.Message);
            }


            try
            {
                List <statusData> status = sql.getStatusData(cboTrucks.Text, startDateTime, endDateTime);
                gvStatusData.DataSource = status;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
            btnLoadData.Enabled       = true;
            btnLoadData.BackColor     = System.Drawing.Color.LightGreen;
            btnPlayback.BackColor     = System.Drawing.Color.LightGreen;
            btnStopPlayback.BackColor = System.Drawing.Color.Red;
            btnPlayback.Enabled       = true;
            btnStopPlayback.Enabled   = false;
            btnExportData.BackColor   = System.Drawing.Color.LightGreen;
            btnExportData.Enabled     = true;
            Cursor = Cursors.Arrow;
        }
Exemplo n.º 4
0
        private void btnPreLoad_Click(object sender, EventArgs e)
        {
            /*
             * string startTime = string.Empty;
             * string endTime = string.Empty;
             * string startDate = string.Empty;
             * string endDate = string.Empty;
             *
             * if (tEndTime.Text != "hh:mm:ss" && tEndTime.Text != "hh:mm:ss")
             * {
             *  startTime = tStartTime.Text;
             *  endTime = tEndTime.Text;
             * }
             * else
             * {
             *  MessageBox.Show("Invalid time");
             *  return;
             * }
             * if (string.IsNullOrEmpty(dStartDate.Text) || string.IsNullOrEmpty(dEndDate.Text))
             * {
             *  MessageBox.Show("Invalid date");
             *  return;
             * }
             * try
             * {
             *  startDateTime = Convert.ToDateTime(dStartDate.Text + " " + startTime);
             *  endDateTime = Convert.ToDateTime(dEndDate.Text + " " + endTime);
             * }
             * catch (Exception ex)
             * {
             *  MessageBox.Show(ex.Message);
             *  return;
             * }
             *
             * TimeSpan ts = endDateTime - startDateTime;
             * if (ts.TotalHours > 12)
             * {
             *  MessageBox.Show("Time range must not be more than 12 hours");
             *  return;
             * }
             */

            bool chkTime = checkTimeRange();

            if (!chkTime)
            {
                return;
            }
            Cursor             = Cursors.WaitCursor;
            btnPreLoad.Enabled = false;
            try
            {
                SQLCode sql = new SQLCode();

                List <string> trucks    = sql.getData(startDateTime, endDateTime, "TRUCKS");
                List <string> drivers   = sql.getData(startDateTime, endDateTime, "DRIVERS");
                List <string> callsigns = sql.getData(startDateTime, endDateTime, "CALLSIGNS");
                //List<string> beats = sql.getData(startDateTime, endDateTime, "BEATS");
                //List<string> contractors = sql.getData(startDateTime, endDateTime, "CONTRACTORS");

                //cboContractors.Items.Clear();
                //cboBeats.Items.Clear();
                cboCallsigns.Items.Clear();
                cboTrucks.Items.Clear();
                cboDrivers.Items.Clear();

                /*
                 * foreach (string s in contractors)
                 * { cboContractors.Items.Add(s); }
                 * foreach (string s in beats)
                 * { cboBeats.Items.Add(s); }
                 * */
                foreach (string s in callsigns)
                {
                    cboCallsigns.Items.Add(s);
                }
                foreach (string s in trucks)
                {
                    cboTrucks.Items.Add(s);
                }
                foreach (string s in drivers)
                {
                    cboDrivers.Items.Add(s);
                }
                //cboBeats.SelectedIndex = 0;
                cboCallsigns.SelectedIndex = 0;
                cboTrucks.SelectedIndex    = 0;
                cboDrivers.SelectedIndex   = 0;
                //cboContractors.SelectedIndex = 0;
            }
            catch (TimeoutException tx)
            {
                MessageBox.Show("The System has timed out trying to load your requested date, please select a smaller date/time range", "Error");
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            Cursor                    = Cursors.Arrow;
            btnPreLoad.Enabled        = true;
            btnLoadData.Enabled       = true;
            btnPlayback.BackColor     = System.Drawing.Color.Red;
            btnStopPlayback.BackColor = System.Drawing.Color.Red;
            btnPlayback.Enabled       = false;
            btnStopPlayback.Enabled   = false;
            btnLoadData.BackColor     = System.Drawing.Color.LightGreen;
            btnExportData.BackColor   = System.Drawing.Color.Red;
            btnExportData.Enabled     = false;
        }