protected void apcRaw_ControlClicked(object sender, EventArgs e)
    {
        apcRaw.LazyLoad = false;
        int idx = mfbAccordionProxyExtender.IndexForProxyID(apcRaw.ID);

        mfbAccordionProxyExtender.SetJavascriptForControl(apcRaw, true, idx);
        AccordionCtrl.SelectedIndex = idx;

        TelemetryDataTable tdt = TelemetryData;

        // see if we need to hide the "Position" column
        bool fHasPositionColumn = false;

        foreach (DataColumn dc in tdt.Columns)
        {
            if (dc.ColumnName.CompareOrdinalIgnoreCase(KnownColumnNames.POS) == 0)
            {
                fHasPositionColumn = true;
            }
        }
        if (!fHasPositionColumn)
        {
            gvData.Columns.RemoveAt(1);
        }

        gvData.DataSource = tdt;
        gvData.DataBind();
    }
示例#2
0
    protected void UpdateChart()
    {
        TelemetryDataTable tdt = TelemetryData;

        if (tdt == null)
        {
            return;
        }

        UpdateChart(tdt, gcData, DataForFlight, PathLatLongArrayID, cmbXAxis.SelectedItem, cmbYAxis1.SelectedItem, cmbYAxis2.SelectedItem, out decimal max, out decimal min, out decimal max2, out decimal min2);

        // Clear out the grid.
        gvData.DataSource = null;
        gvData.DataBind();
        apcRaw.LazyLoad = true;

        int idx = mfbAccordionProxyExtender.IndexForProxyID(apcRaw.ID);

        mfbAccordionProxyExtender.SetJavascriptForControl(apcRaw, idx == AccordionCtrl.SelectedIndex, idx);

        lblMaxY.Text  = max > decimal.MinValue && !String.IsNullOrEmpty(gcData.YLabel) ? String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.ChartMaxX, gcData.YLabel, max) : string.Empty;
        lblMinY.Text  = min < decimal.MaxValue && !String.IsNullOrEmpty(gcData.YLabel) ? String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.ChartMinX, gcData.YLabel, min) : string.Empty;
        lblMaxY2.Text = max2 > decimal.MinValue && !String.IsNullOrEmpty(gcData.Y2Label) ? String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.ChartMaxX, gcData.Y2Label, max2) : string.Empty;
        lblMinY2.Text = min2 < decimal.MaxValue && !String.IsNullOrEmpty(gcData.Y2Label) ? String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.ChartMinX, gcData.Y2Label, min2) : string.Empty;
    }
        protected void UpdateChart(FlightData fd)
        {
            if (fd == null)
            {
                return;
            }
            TelemetryDataTable tdt = DataTableForFlightData(fd);

            if (tdt == null)
            {
                return;
            }

            double y1Scale = TryParse(rblConvert1.SelectedValue, 1.0);
            double y2Scale = TryParse(rblConvert2.SelectedValue, 1.0);

            UpdateChart(tdt, gcData, fd.HasLatLongInfo, PathLatLongArrayID, cmbXAxis.SelectedItem, cmbYAxis1.SelectedItem, cmbYAxis2.SelectedItem, y1Scale, y2Scale, out double max, out double min, out double max2, out double min2);
            DataPointCount = gcData.YVals.Count;

            bool HasCrop = GetCropRange(CurrentFlight, out int _, out int _);

            btnResetCrop.Visible      = HasCrop;
            pnlRange.Visible          = mhsClip.Enabled = btnCrop.Visible = !HasCrop;
            lblDefaultCropStatus.Text = HasCrop ? Resources.FlightData.TelemetryCropIsApplied : Resources.FlightData.TelemetryCropNoCrop;

            // Clear out the grid.
            gvData.DataSource = null;
            gvData.DataBind();
            apcRaw.LazyLoad = true;

            int idx = mfbAccordionProxyExtender.IndexForProxyID(apcRaw.ID);

            mfbAccordionProxyExtender.SetJavascriptForControl(apcRaw, idx == AccordionCtrl.SelectedIndex, idx);

            lblMaxY.Text  = max > double.MinValue && !String.IsNullOrEmpty(gcData.YLabel) ? String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.ChartMaxX, gcData.YLabel, max) : string.Empty;
            lblMinY.Text  = min < double.MaxValue && !String.IsNullOrEmpty(gcData.YLabel) ? String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.ChartMinX, gcData.YLabel, min) : string.Empty;
            lblMaxY2.Text = max2 > double.MinValue && !String.IsNullOrEmpty(gcData.Y2Label) ? String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.ChartMaxX, gcData.Y2Label, max2) : string.Empty;
            lblMinY2.Text = min2 < double.MaxValue && !String.IsNullOrEmpty(gcData.Y2Label) ? String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.ChartMinX, gcData.Y2Label, min2) : string.Empty;
        }
    protected void UpdateChart()
    {
        decimal max  = decimal.MinValue;
        decimal min  = decimal.MaxValue;
        decimal max2 = decimal.MinValue;
        decimal min2 = decimal.MaxValue;

        TelemetryDataTable tdt = TelemetryData;

        if (tdt == null)
        {
            return;
        }

        gcData.XLabel  = (cmbXAxis.SelectedItem == null) ? "" : cmbXAxis.SelectedItem.Text;
        gcData.YLabel  = (cmbYAxis1.SelectedItem == null) ? "" : cmbYAxis1.SelectedItem.Text;
        gcData.Y2Label = (cmbYAxis2.SelectedIndex == 0 || cmbYAxis2 == null) ? "" : cmbYAxis2.SelectedItem.Text;

        gcData.Clear();

        gcData.XDataType  = gcData.GoogleTypeFromKnownColumnType(KnownColumn.GetKnownColumn(cmbXAxis.SelectedValue).Type);
        gcData.YDataType  = gcData.GoogleTypeFromKnownColumnType(KnownColumn.GetKnownColumn(cmbYAxis1.SelectedValue).Type);
        gcData.Y2DataType = gcData.GoogleTypeFromKnownColumnType(KnownColumn.GetKnownColumn(cmbYAxis2.SelectedValue).Type);

        if (cmbYAxis1.SelectedItem == null || cmbYAxis2.SelectedItem == null)
        {
            gcData.Visible = false;
            return;
        }

        if (m_fd.HasLatLongInfo)
        {
            gcData.ClickHandlerJS = String.Format(CultureInfo.InvariantCulture, "dropPin({0}[selectedItem.row], xvalue + ': ' + ((selectedItem.column == 1) ? '{1}' : '{2}') + ' = ' + value);", PathLatLongArrayID, cmbYAxis1.SelectedItem.Text, cmbYAxis2.SelectedItem.Text);
        }

        foreach (DataRow dr in tdt.Rows)
        {
            gcData.XVals.Add(dr[cmbXAxis.SelectedValue]);

            if (!String.IsNullOrEmpty(cmbYAxis1.SelectedValue))
            {
                object o = dr[cmbYAxis1.SelectedValue];
                gcData.YVals.Add(o);
                if (gcData.YDataType == Controls_GoogleChart.GoogleColumnDataType.number)
                {
                    decimal d = Convert.ToDecimal(o, CultureInfo.InvariantCulture);
                    max = Math.Max(max, d);
                    min = Math.Min(min, d);
                }
            }
            if (cmbYAxis2.SelectedValue.Length > 0 && cmbYAxis2.SelectedValue != cmbYAxis1.SelectedValue)
            {
                object o = dr[cmbYAxis2.SelectedValue];
                gcData.Y2Vals.Add(o);
                if (gcData.Y2DataType == Controls_GoogleChart.GoogleColumnDataType.number)
                {
                    decimal d = Convert.ToDecimal(o, CultureInfo.InvariantCulture);
                    max2 = Math.Max(max2, d);
                    min2 = Math.Min(min2, d);
                }
            }
        }
        gcData.TickSpacing = 1; // Math.Max(1, m_fd.Data.Rows.Count / 20);

        // Clear out the grid.
        gvData.DataSource = null;
        gvData.DataBind();
        apcRaw.LazyLoad = true;

        int idx = mfbAccordionProxyExtender.IndexForProxyID(apcRaw.ID);

        mfbAccordionProxyExtender.SetJavascriptForControl(apcRaw, idx == AccordionCtrl.SelectedIndex, idx);

        lblMaxY.Text  = max > decimal.MinValue && !String.IsNullOrEmpty(gcData.YLabel) ? String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.ChartMaxX, gcData.YLabel, max) : string.Empty;
        lblMinY.Text  = min < decimal.MaxValue && !String.IsNullOrEmpty(gcData.YLabel) ? String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.ChartMinX, gcData.YLabel, min) : string.Empty;
        lblMaxY2.Text = max2 > decimal.MinValue && !String.IsNullOrEmpty(gcData.Y2Label) ? String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.ChartMaxX, gcData.Y2Label, max2) : string.Empty;
        lblMinY2.Text = min2 < decimal.MaxValue && !String.IsNullOrEmpty(gcData.Y2Label) ? String.Format(CultureInfo.CurrentCulture, Resources.LocalizedText.ChartMinX, gcData.Y2Label, min2) : string.Empty;
    }
示例#5
0
    protected static void UpdateChart(TelemetryDataTable tdt, Controls_GoogleChart gcData, FlightData fd, string PathLatLongArrayID, ListItem xAxis, ListItem yAxis1, ListItem yAxis2, out decimal max, out decimal min, out decimal max2, out decimal min2)
    {
        max  = decimal.MinValue;
        min  = decimal.MaxValue;
        max2 = decimal.MinValue;
        min2 = decimal.MaxValue;

        if (tdt == null)
        {
            return;
        }

        if (gcData == null)
        {
            throw new ArgumentNullException(nameof(gcData));
        }

        if (yAxis1 == null || yAxis2 == null || xAxis == null)
        {
            gcData.Visible = false;
            return;
        }

        gcData.XLabel  = xAxis.Text;
        gcData.YLabel  = yAxis1.Text;
        gcData.Y2Label = yAxis2.Text;

        gcData.Clear();

        gcData.XDataType  = GoogleChart.GoogleTypeFromKnownColumnType(KnownColumn.GetKnownColumn(xAxis.Value).Type);
        gcData.YDataType  = GoogleChart.GoogleTypeFromKnownColumnType(KnownColumn.GetKnownColumn(yAxis1.Value).Type);
        gcData.Y2DataType = GoogleChart.GoogleTypeFromKnownColumnType(KnownColumn.GetKnownColumn(yAxis2.Value).Type);

        if (fd == null)
        {
            throw new ArgumentNullException(nameof(fd));
        }

        if (fd.HasLatLongInfo)
        {
            gcData.ClickHandlerJS = String.Format(CultureInfo.InvariantCulture, "dropPin({0}[selectedItem.row], xvalue + ': ' + ((selectedItem.column == 1) ? '{1}' : '{2}') + ' = ' + value);", PathLatLongArrayID, yAxis1, yAxis2);
        }

        foreach (DataRow dr in tdt.Rows)
        {
            gcData.XVals.Add(dr[xAxis.Value]);

            if (!String.IsNullOrEmpty(yAxis1.Value))
            {
                object o = dr[yAxis1.Value];
                gcData.YVals.Add(o);
                if (gcData.YDataType == GoogleColumnDataType.number)
                {
                    decimal d = Convert.ToDecimal(o, CultureInfo.InvariantCulture);
                    max = Math.Max(max, d);
                    min = Math.Min(min, d);
                }
            }
            if (yAxis2.Value.Length > 0 && yAxis2 != yAxis1)
            {
                object o = dr[yAxis2.Value];
                gcData.Y2Vals.Add(o);
                if (gcData.Y2DataType == GoogleColumnDataType.number)
                {
                    decimal d = Convert.ToDecimal(o, CultureInfo.InvariantCulture);
                    max2 = Math.Max(max2, d);
                    min2 = Math.Min(min2, d);
                }
            }
        }
        gcData.TickSpacing = 1; // Math.Max(1, m_fd.Data.Rows.Count / 20);
    }
示例#6
0
        public override bool Parse(string szData)
        {
            StringBuilder      sbErr = new StringBuilder();
            TelemetryDataTable m_dt  = ParsedData;

            m_dt.Clear();
            Boolean fResult = true;

            string flightData = FixedFlightData(szData);

            using (MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(flightData)))
            {
                using (CSVReader csvr = new CSVReader(ms))
                {
                    try
                    {
                        string[] rgszHeader = null;

                        // Find the first row that looks like columns.
                        try
                        {
                            do
                            {
                                rgszHeader = csvr.GetCSVLine(true);
                            } while (rgszHeader != null && (rgszHeader.Length < 2 || rgszHeader[0].StartsWith("#", StringComparison.OrdinalIgnoreCase) || rgszHeader[0].Contains("Date (yyyy-mm-dd)")));
                        }
                        catch (CSVReaderInvalidCSVException ex)
                        {
                            throw new MyFlightbookException(ex.Message);
                        }

                        if (rgszHeader == null) // no valid CSV header found
                        {
                            sbErr.Append(Resources.FlightData.errNoCSVHeaderRowFound);
                            return(false);
                        }

                        CSVParsingContext pc = new CSVParsingContext();
                        SetUpContextFromHeaderRow(pc, rgszHeader);

                        string[] rgszRow = null;
                        int      iRow    = 0;

                        while ((rgszRow = csvr.GetCSVLine()) != null)
                        {
                            iRow++;

                            try
                            {
                                m_dt.Rows.Add(ParseCSVRow(pc, FixRowHack(rgszRow, rgszHeader), iRow));
                            }
                            catch (MyFlightbookException ex)
                            {
                                sbErr.Append(String.Format(CultureInfo.CurrentCulture, Resources.FlightData.errInRow, iRow, ex.Message));
                                fResult = false;
                            }
                            catch (System.FormatException ex)
                            {
                                sbErr.Append(String.Format(CultureInfo.CurrentCulture, Resources.FlightData.errInRow, iRow, ex.Message));
                                fResult = false;
                            }
                        }

                        // Go back and put the derived speeds in.
                        if (pc.fDeriveSpeed)
                        {
                            Position.DeriveSpeed(pc.SamplesList);
                            for (int i = 0; i < m_dt.Rows.Count && i < pc.SamplesList.Count; i++)
                            {
                                if (pc.SamplesList[i].HasSpeed)
                                {
                                    m_dt.Rows[i][KnownColumnNames.DERIVEDSPEED] = pc.SamplesList[i].Speed;
                                }
                            }
                        }
                    }
                    catch (MyFlightbookException ex)
                    {
                        sbErr.Append(String.Format(CultureInfo.CurrentCulture, Resources.FlightData.errGeneric, ex.Message));
                        fResult = false;
                    }
                    catch (System.Data.DuplicateNameException ex)
                    {
                        sbErr.Append(String.Format(CultureInfo.CurrentCulture, Resources.FlightData.errGeneric, ex.Message));
                        fResult = false;
                    }
                    finally
                    {
                    }
                }
            }

            ErrorString = sbErr.ToString();

            return(fResult);
        }
    /// <summary>
    /// Loads the data for the specified flight, parsing the CSV file, and thus initializing m_fd.  This is cached, so it's OK to call multiple times.
    /// </summary>
    /// <param name="idFlight">ID of the flight with data to load</param>
    protected void LoadData(LogbookEntry le)
    {
        if (le == null)
        {
            throw new ArgumentNullException("le");
        }
        string szCacheKey = KeyCacheData(le.FlightID);

        TelemetryDataTable dt = (TelemetryDataTable)Session[szCacheKey];

        if (dt != null)
        {
            m_fd.Data = dt;
        }

        if (m_fd.NeedsComputing)
        {
            if (!m_fd.ParseFlightData(le.FlightData) && (lblErr.Text = m_fd.ErrorString.Replace("\r\n", "<br />")).Length > 0)
            {
                pnlErrors.Visible = true;
            }

            if (m_fd.Data != null)
            {
                Session[szCacheKey] = m_fd.Data; // cache the results.

                // now set up the chart
                cmbXAxis.Items.Clear();
                cmbYAxis1.Items.Clear();
                cmbYAxis2.Items.Clear();
                cmbYAxis2.Items.Add(new ListItem(Resources.FlightData.GraphNoData, ""));
                cmbYAxis2.SelectedIndex = 0;

                foreach (DataColumn dc in m_fd.Data.Columns)
                {
                    KnownColumn kc = KnownColumn.GetKnownColumn(dc.Caption);

                    if (kc.Type.CanGraph())
                    {
                        cmbXAxis.Items.Add(new ListItem(kc.FriendlyName, kc.Column));
                    }
                    if (kc.Type == KnownColumnTypes.ctDec || kc.Type == KnownColumnTypes.ctFloat || kc.Type == KnownColumnTypes.ctInt)
                    {
                        cmbYAxis1.Items.Add(new ListItem(kc.FriendlyName, kc.Column));
                        cmbYAxis2.Items.Add(new ListItem(kc.FriendlyName, kc.Column));
                    }
                }

                // Select a date or time column for the X axis if possible; if not, select "SAMPLES"
                if (cmbXAxis.Items.Count > 0)
                {
                    if (m_fd.Data.Columns["DATE"] != null)
                    {
                        cmbXAxis.SelectedValue = "DATE";
                    }
                    else if (m_fd.Data.Columns["TIME"] != null)
                    {
                        cmbXAxis.SelectedValue = "TIME";
                    }
                    else if (m_fd.Data.Columns["SAMPLE"] != null)
                    {
                        cmbXAxis.SelectedValue = "SAMPLE";
                    }
                    else
                    {
                        cmbXAxis.SelectedIndex = 0;
                    }
                }

                // if there is something numeric for the Y axis, select it.  Otherwise, default to the first item.
                if (cmbYAxis1.Items.Count > 0)
                {
                    cmbYAxis1.SelectedIndex = 0;
                }

                foreach (ListItem li in cmbYAxis1.Items)
                {
                    KnownColumn kc = KnownColumn.GetKnownColumn(li.Value);
                    if (kc.Type != KnownColumnTypes.ctDateTime && kc.Type != KnownColumnTypes.ctLatLong && kc.Column != "SAMPLE")
                    {
                        cmbYAxis1.SelectedValue = kc.Column;
                        break;
                    }
                }
            }
        }
    }
        protected static void SetUpChart(TelemetryDataTable data, DropDownList cmbXAxis, DropDownList cmbYAxis1, DropDownList cmbYAxis2)
        {
            if (cmbXAxis == null)
            {
                throw new ArgumentNullException(nameof(cmbXAxis));
            }
            if (cmbYAxis1 == null)
            {
                throw new ArgumentNullException(nameof(cmbYAxis1));
            }
            if (cmbYAxis2 == null)
            {
                throw new ArgumentNullException(nameof(cmbYAxis2));
            }
            if (data == null)
            {
                return;
            }

            // now set up the chart
            cmbXAxis.Items.Clear();
            cmbYAxis1.Items.Clear();
            cmbYAxis2.Items.Clear();
            cmbYAxis2.Items.Add(new ListItem(Resources.FlightData.GraphNoData, ""));
            cmbYAxis2.SelectedIndex = 0;

            foreach (DataColumn dc in data.Columns)
            {
                KnownColumn kc = KnownColumn.GetKnownColumn(dc.Caption);

                if (kc.Type.CanGraph())
                {
                    cmbXAxis.Items.Add(new ListItem(kc.FriendlyName, kc.Column));
                }
                if (kc.Type == KnownColumnTypes.ctDec || kc.Type == KnownColumnTypes.ctFloat || kc.Type == KnownColumnTypes.ctInt)
                {
                    cmbYAxis1.Items.Add(new ListItem(kc.FriendlyName, kc.Column));
                    cmbYAxis2.Items.Add(new ListItem(kc.FriendlyName, kc.Column));
                }
            }

            // Select a date or time column for the X axis if possible; if not, select "SAMPLES"
            if (cmbXAxis.Items.Count > 0)
            {
                if (data.Columns["DATE"] != null)
                {
                    cmbXAxis.SelectedValue = "DATE";
                }
                else if (data.Columns["TIME"] != null)
                {
                    cmbXAxis.SelectedValue = "TIME";
                }
                else if (data.Columns["SAMPLE"] != null)
                {
                    cmbXAxis.SelectedValue = "SAMPLE";
                }
                else
                {
                    cmbXAxis.SelectedIndex = 0;
                }
            }

            // if there is something numeric for the Y axis, select it.  Otherwise, default to the first item.
            if (cmbYAxis1.Items.Count > 0)
            {
                cmbYAxis1.SelectedIndex = 0;
            }

            foreach (ListItem li in cmbYAxis1.Items)
            {
                KnownColumn kc = KnownColumn.GetKnownColumn(li.Value);
                if (kc.Type != KnownColumnTypes.ctDateTime && kc.Type != KnownColumnTypes.ctLatLong && kc.Column != "SAMPLE")
                {
                    cmbYAxis1.SelectedValue = kc.Column;
                    break;
                }
            }
        }