Esempio n. 1
0
        private void putTruckOnMap(playBackRow row)
        {
            gMapControl1.Position = new PointLatLng(row.Lat, row.Lon);
            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);
        }
Esempio n. 2
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;
        }