} /* PaintCurrentRow */

        private void  DrawDepthChart()
        {
            DrawAxisLabelsDepth();

            int historyNumOfRows = 0;

            lock (history)
            {
                historyNumOfRows = history.Count;
            }
            int y;

            for (y = 0; y < historyNumOfRows; y++)
            {
                InstrumentData dataRow = (InstrumentData)(history[y]);
                float          depth   = dataRow.Depth();
                if (depth < depthTop)
                {
                    continue;
                }

                if (depth > depthBot)
                {
                    continue;
                }

                int row = CalcRowForDepth(depth);
                PlotOneDataRow(dataRow, row);
            }
        }
Exemple #2
0
        public ImageEditor(string _fileName,
                           int _height,
                           int _width,
                           byte[][]        _raster,// Will take ownership of '_raster'
                           InstrumentData _instrumentData
                           )
        {
            InitializeComponent();

            fileName       = _fileName;
            instrumentData = _instrumentData;
            raster         = _raster;
            height         = _height;
            width          = _width;

            imageFileName = _fileName;;

            BuildColorValues();

            SizeOptions.SelectedOption = "100%";

            image = BuildBitmapFromRasterData(raster);

            pictureBox1.Height = image.Height;
            pictureBox1.Width  = image.Width;
            pictureBox1.Image  = image;

            ImagePanel.AutoScroll = true;
            //ImagePanel.SetStyle   (ControlStyles.ResizeRedraw, false);
            ImagePanel.AutoScroll        = true;
            ImagePanel.AutoScrollMinSize = image.Size;
            ImagePanel.Invalidate();

            MakePredictions();
        }
Exemple #3
0
        } /* ParseTabDelStr */

        public bool Equals(InstrumentData o)
        {
            if (o == null)
            {
                return(false);
            }

            int x;

            for (x = 0; x < data.Length; x++)
            {
                if (data[x] != o.data[x])
                {
                    return(false);
                }
            }

            if ((longitude == o.longitude) &&
                (latitude == o.latitude) &&
                (time == o.time) &&
                (activeBattery == o.activeBattery) &&
                (batteryStatuses.Equals(o.batteryStatuses)) &&
                (ctdDate == o.ctdDate) &&
                (cropLeft == o.cropLeft) &&
                (cropRight == o.cropRight) &&
                (activeColumns == o.activeColumns)
                )
            {
                return(true);
            }
            else
            {
                return(false);
            }
        } /* Equals */
Exemple #4
0
        } /* GetByTimeGreaterOrEqual */

        public void  Save(string _fileName)
        {
            StreamWriter w = null;

            try
            {
                w = new StreamWriter(_fileName);
            }
            catch (Exception e)
            {
                MessageBox.Show("Exception Opening File[" + _fileName + "]  [" + e.ToString() + "]");
                return;
            }

            w.WriteLine("// Instrument Data Log");
            w.WriteLine("// DateTime" + "\t" + DateTime.Now.ToString());
            w.WriteLine("// Entries" + "\t" + Count);

            InstrumentData.WriteFieldList(w);

            for (int x = 0; x < this.Count; x++)
            {
                InstrumentData r = (InstrumentData)(this)[x];
                r.WriteLine(w, fieldIndexes);
            }

            w.Close();
        } /* Save */
Exemple #5
0
        } /* Dispose */

        public virtual int  Add(InstrumentData row)
        {
            if (writer != null)
            {
                row.WriteLine(writer, fieldIndexes);
            }

            float d = row.Depth();

            if (d < depthMin)
            {
                depthMin = d;
            }

            if (d > depthMax)
            {
                depthMax = d;
            }

            if (row.Time.CompareTo(timeMin) < 0)
            {
                timeMin = row.Time;
            }

            if (row.Time.CompareTo(timeMax) > 0)
            {
                timeMax = row.Time;
            }

            return(base.Add(row));
        }
Exemple #6
0
        public ImageEditor(PicesRaster _raster)
        {
            InitializeComponent();

            //raster         = (byte[][])_raster.BuildRasterArray ();
            raster        = _raster.BuildRasterArray2();
            imageFileName = _raster.FileName;

            instrumentData = null;
            height         = _raster.Height;
            width          = _raster.Width;

            _raster = null;

            BuildColorValues();

            SizeOptions.SelectedOption = "100%";

            image = BuildBitmapFromRasterData(raster);

            pictureBox1.Height = image.Height;
            pictureBox1.Width  = image.Width;
            pictureBox1.Image  = image;

            ImagePanel.AutoScroll = true;
            //ImagePanel.SetStyle   (ControlStyles.ResizeRedraw, false);
            ImagePanel.AutoScroll        = true;
            ImagePanel.AutoScrollMinSize = image.Size;
            ImagePanel.Invalidate();

            MakePredictions();
        }
Exemple #7
0
        } /* SetCurCollumn */

        public void  PlotDataRow(InstrumentData dr)
        {
            SetCurCollumn(dr.Time);
            float[] data = dr.Data();

            int x;

            for (x = 0; x < 6; x++)
            {
                int y = fieldIdxs[x];
                if (plotDataSeries[y])
                {
                    float dataValue = data[y];
                    int   row       = (int)(((dataValue - minValues[y]) * this.rowScaleFactors[y]) + 0.5);
                    if (row < 0)
                    {
                        row = 0;
                    }

                    else if (row >= plotBotRow)
                    {
                        row = plotBotRow;
                    }

                    if (curCol < 0)
                    {
                        curCol = 0;
                    }


                    plotDC.FillRectangle(plotBrushes[x], curCol, row, 2, 2);
                    plotBufferDC.FillRectangle(plotBrushes[x], curCol, row, 2, 2);
                }
            }
        } /* PlotDataItem */
        } /* DrawAxisLabelsDepth */

        private void PlotOneDataRow(InstrumentData r,
                                    int row
                                    )
        {
            int seriesIdx;

            //g.FillRectangle (new SolidBrush (chartPanel.BackColor), 1, row, chartWidth - 2, this.chartRowWidth);

            float[] data = r.Data();

            for (seriesIdx = 0; seriesIdx < maxNumDataSets; seriesIdx++)
            {
                if (!seriesToPlot[seriesIdx])
                {
                    continue;
                }

                int dataIdx = fieldIdxs[plottingAxisIdx, seriesIdx];

                int   col = chartFirstCol;
                float d   = data[dataIdx];

                if (d == float.NaN)
                {
                    col = chartLastCol;
                }

                else if (d < minValues[dataIdx])
                {
                    col = chartFirstCol;
                }

                else if (d > maxValues[dataIdx])
                {
                    col = chartLastCol;
                }

                else
                {
                    col = chartFirstCol + (int)((d - minValues[dataIdx]) * colFactors[dataIdx] + 0.5f);
                }

                if (col < chartFirstCol)
                {
                    col = chartFirstCol;
                }

                else if (col > chartLastCol)
                {
                    col = chartLastCol;
                }

                plotDC.FillRectangle(seriesBrushes[seriesIdx], col, row, chartColWidth, chartRowWidth);
                plotBufferDC.FillRectangle(seriesBrushes[seriesIdx], col, row, chartColWidth, chartRowWidth);
            }
        } /* PlotOneDataRow */
        /// <summary>
        /// Using supplied 'Raster' data it will call each currently active model and return there predictions.
        /// </summary>
        /// <param name="raster">Raster of image to predict. .</param>
        /// <param name="instrumentData">Instrument data that was recorded with the 'raster' .</param>
        /// <param name="imageFileName">Name of the image file.</param>
        /// <param name="model1Predictions">The model1 predictions.</param>
        /// <param name="model2Predictions">The model2 predictions.</param>
        /// <param name="runLog">The run log.</param>
        public static void  MakePredictions(PicesRaster raster,
                                            InstrumentData instrumentData,
                                            String imageFileName,
                                            ref PicesPredictionList model1Predictions,
                                            ref PicesPredictionList model2Predictions,
                                            PicesRunLog runLog
                                            )
        {
            model1Predictions = null;
            model2Predictions = null;
            if (!ModelsAreAvailable())
            {
                return;
            }

            ParsedImageFileName pifn = PicesFeatureVector.ParseImageFileName(imageFileName);
            String sipperFileName    = pifn.sipperFileName;
            uint   scanLineNum       = pifn.scanLineNum;

            PicesFeatureVector fv = new PicesFeatureVector(raster, imageFileName, null, runLog);

            if (instrumentData != null)
            {
                fv.AddInstrumentData(instrumentData.Depth(),
                                     instrumentData.Salinity(),
                                     instrumentData.Oxygen(),
                                     instrumentData.Fluorescence()
                                     );
            }
            else
            {
                PicesDataBase       dbConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(runLog);
                PicesInstrumentData pid    = dbConn.InstrumentDataGetByScanLine(sipperFileName, scanLineNum);
                if (pid != null)
                {
                    fv.AddInstrumentData(pid);
                }
                pid = null;
                dbConn.Close();
                dbConn = null;
            }

            if (model1 != null)
            {
                model1Predictions = model1.PredictProbabilities(fv);
            }

            if (model2 != null)
            {
                model2Predictions = model2.PredictProbabilities(fv);
            }

            fv = null;

            return;
        } /* MakePredictions */
Exemple #10
0
        private void  RecalcColScaleFactors()
        {
            // Calculate rowScaleFactors
            int x;

            for (x = 0; x < InstrumentData.NumDataFields(); x++)
            {
                rowScaleFactors[x] = plotHeight / (maxValues[x] - minValues[x]);
            }
        } /* RecalcRowScaleValues */
Exemple #11
0
        private void  InitializeVariables()
        {
            int x = 0;

            string[] dataLabels = new string[InstrumentData.NumDataFields()];
            for (x = 0; x < InstrumentData.NumDataFields(); x++)
            {
                dataLabels[x] = InstrumentData.FieldName(x);
            }

            minValues       = new float[InstrumentData.NumDataFields()];
            maxValues       = new float[InstrumentData.NumDataFields()];
            plotDataSeries  = new bool [InstrumentData.NumDataFields()];
            rowScaleFactors = new float[InstrumentData.NumDataFields()];
            plotBrushes     = new SolidBrush[numDataSeries];
            fieldIdxs       = new int  [numDataSeries];

            plottedSeries    = new DataSeries[numDataSeries];
            plottedSeries[0] = dataSeries0;
            plottedSeries[1] = dataSeries1;
            plottedSeries[2] = dataSeries2;
            plottedSeries[3] = dataSeries3;
            plottedSeries[4] = dataSeries4;
            plottedSeries[5] = dataSeries5;


            SuspendAllControls();

            for (x = 0; x < numDataSeries; x++)
            {
                plottedSeries[x].SetDataLabels(dataLabels);
                plottedSeries[x].SetSelectedDataLabel(x);
                plottedSeries[x].MinMaxCalcRequest += ReCalcMinMaxForSpecificPlottedSeries;
                fieldIdxs[x]   = x;
                plotBrushes[x] = new SolidBrush(plottedSeries[x].PlotColor);
            }

            chartParms = new TimePlotParameters(chartPanel, fieldIdxs, minValues, maxValues, rowScaleFactors, plotDataSeries, plotBrushes, plottedSeries);

            DateTime startingLeftTime = DateTime.Now;

            lock (history)
            {
                if (history.Count > 0)
                {
                    startingLeftTime = history.TimeMax();
                }
            }

            chartParms.SetNewTimeLeft(startingLeftTime);

            UpdateTimeDomainScrollingRanges();

            ResumeAllControls();
        } /* InitializeVariables */
Exemple #12
0
        public InstrumentData  CurrentDataRow()
        {
            if (Count == 0)
            {
                if (emptyDataRow == null)
                {
                    emptyDataRow = new InstrumentData();
                }
                return(emptyDataRow);
            }

            return((InstrumentData)((this)[Count - 1]));
        } /* CurrentDataRow */
Exemple #13
0
        private void   SelectTimeInstant(int pixelCol)
        {
            if (selectedHistory != null)
            {
                ClearSelectedVerticalLine();
            }

            selectedDateTime = chartParms.ComputeDateTimeFromPixelCol(pixelCol);
            selectedHistory  = history.FindClosestEntryByTime(selectedDateTime);
            SetToHistoryMode();
            DrawSelectedVerticalLine();
            UpdateDataSeriesValues(selectedHistory);
        } /* SelectTimeInstant */
Exemple #14
0
        } /* UpdateTimePlot */

        private void  PaintEntirePlotArea()
        {
            chartParms.ClearPlotArea();

            DateTime timeLeft  = chartParms.TimeLeft();
            DateTime timeRight = chartParms.TimeRight();

            int rowsInHistory = 0;

            lock (history)
            {
                rowsInHistory = history.Count;
            }

            int row = 0;

            // lets skip past all the old history.
            while (row < rowsInHistory)
            {
                InstrumentData dr = (InstrumentData)history[row];
                if (dr.Time.CompareTo(timeRight) > 0)
                {
                    break;
                }
                row++;
            }

            while (row < rowsInHistory)
            {
                InstrumentData dr = (InstrumentData)history[row];
                if (dr.Time.CompareTo(timeLeft) > 0)
                {
                    // We are past the left side of the plot
                    break;
                }

                DrawSingleDataRow(dr);

                leftMostDataRow = dr;
                row++;
            }

            if (selectedHistory != null)
            {
                DrawSelectedVerticalLine();
            }
        } /* PaintEntirePlotArea */
Exemple #15
0
        } /* DrawSelectedVerticalLine */

        private void  UpdateDataSeriesValues(InstrumentData dr)
        {
            int dsIDX = 0;

            if (dr == null)
            {
                return;
            }

            float[] data = dr.Data();

            for (dsIDX = 0; dsIDX < numDataSeries; dsIDX++)
            {
                DataSeries ds = plottedSeries[dsIDX];
                ds.Data = data[fieldIdxs[dsIDX]];
            }
        } /* UpdateDataSeriesValues */
Exemple #16
0
        private void  SetToLiveMode()
        {
            selectedHistory    = null;
            LiveOrHistory.Text = "History";
            liveUpdate         = true;

            DateTime t = DateTime.Now;

            lock (history)
            {
                t = history.TimeMax();
            }

            chartParms.SetNewTimeLeft(t);
            RePlotData();
            UpdateTimeDomainScrollingRanges();
        }
Exemple #17
0
        } /* CurrentDataRow */

        public void   CalcMinMaxValues(DateTime startTime, DateTime endTime)
        {
            minValues = new float[InstrumentData.NumDataFields()];
            maxValues = new float[InstrumentData.NumDataFields()];
            int x = 0;

            if (Count < 1)
            {
                for (x = 0; x < minValues.Length; x++)
                {
                    minValues[x] = -10;
                    maxValues[x] = 10;
                }

                return;
            }

            for (x = 0; x < minValues.Length; x++)
            {
                minValues[x] = 999999.99f;
                maxValues[x] = -999999.99f;
            }

            foreach (InstrumentData r in this)
            {
                if ((r.Time.CompareTo(startTime) < 0) || (r.Time.CompareTo(endTime) > 0))
                {
                    continue;
                }

                float[] data = r.Data();
                for (x = 0; x < minValues.Length; x++)
                {
                    if (data[x] < minValues[x])
                    {
                        minValues[x] = data[x];
                    }

                    if (data[x] > maxValues[x])
                    {
                        maxValues[x] = data[x];
                    }
                }
            }
        } /* CalcMinMaxValues */
        } /* PaintChart */

        public void  PaintCurrentRow(InstrumentData curRow)
        {
            float depth = curRow.Depth();

            if (depth < depthTop)
            {
                return;
            }

            if (depth > depthBot)
            {
                return;
            }

            int row = CalcRowForDepth(depth);

            PlotOneDataRow(curRow, row);
        } /* PaintCurrentRow */
Exemple #19
0
        public ImageEditor(String _fileName)
        {
            InitializeComponent();

            imageFileName = _fileName;

            PicesRaster pr = null;

            try
            {
                pr = new PicesRaster(_fileName);
            }
            catch (Exception e)
            {
                pr = null;
                throw new Exception("ImageEditor", e);
            }

            raster         = pr.BuildRasterArray2();
            fileName       = _fileName;
            instrumentData = null;
            height         = pr.Height;
            width          = pr.Width;

            pr = null;

            BuildColorValues();

            SizeOptions.SelectedOption = "100%";

            image = BuildBitmapFromRasterData(raster);

            pictureBox1.Height = image.Height;
            pictureBox1.Width  = image.Width;
            pictureBox1.Image  = image;

            ImagePanel.AutoScroll = true;
            //ImagePanel.SetStyle   (ControlStyles.ResizeRedraw, false);
            ImagePanel.AutoScroll        = true;
            ImagePanel.AutoScrollMinSize = image.Size;
            ImagePanel.Invalidate();

            MakePredictions();
        }
Exemple #20
0
        } /* SortByTime */

        public InstrumentData  FindClosestEntryByTime(DateTime date)
        {
            if (Count < 1)
            {
                return(null);
            }

            InstrumentData nearestData = null;

            int x = 0;

            for (x = 0; x < Count; x++)
            {
                InstrumentData id = (InstrumentData)(this[x]);
                if (id.Time.CompareTo(date) >= 0)
                {
                    nearestData = id;
                    break;
                }
            }

            if (nearestData == null)
            {
                return((InstrumentData)(this[Count - 1]));
            }

            if (x == 0)
            {
                return(nearestData);
            }

            TimeSpan ts1 = nearestData.Time - date;
            TimeSpan ts2 = date - ((InstrumentData)(this[x - 1])).Time;

            if (ts1.Seconds < ts2.Seconds)
            {
                return(nearestData);
            }
            else
            {
                return((InstrumentData)(this[x - 1]));
            }
        } /* FindClosestEntryByTime */
Exemple #21
0
        } /* LoadFromDataFile */

        private void  OpenForWriteInstrumentDataFile()
        {
            if (writer != null)
            {
                writer.Close();
                writer = null;
            }

            writer = new StreamWriter(fileName,
                                      true // true = append.
                                      );

            writer.WriteLine("//");
            writer.WriteLine("//");
            writer.WriteLine("//");
            writer.WriteLine("//Starting SIPPER Interface " + DateTime.Now.ToString());
            writer.WriteLine("//");
            InstrumentData.WriteFieldList(writer);
            writer.Flush();
        }
Exemple #22
0
        } /* Equals */

        public bool  BatteryDataChanged(InstrumentData o)
        {
            if (o == null)
            {
                return(false);
            }

            if ((activeBattery == o.activeBattery) &&
                (batteryStatuses.Equals(o.batteryStatuses)) &&
                (data[Bat1LevelIndex] == o.data[Bat1LevelIndex]) &&
                (data[Bat2LevelIndex] == o.data[Bat2LevelIndex]) &&
                (data[Bat3LevelIndex] == o.data[Bat3LevelIndex]) &&
                (data[Bat4LevelIndex] == o.data[Bat4LevelIndex])
                )
            {
                return(false);
            }
            else
            {
                return(true);
            }
        } /* BatteryDataChanged */
        public void  Dispose()
        {
            if (reporters != null)
            {
                for (int x = 0; x < reporters.Length; x++)
                {
                    if (reporters[x] != null)
                    {
                        reporters[x].Dispose();
                        reporters[x] = null;
                    }
                }
            }

            currentDataRow = null;
            reporters      = null;

            if (dataLogger != null)
            {
                dataLogger.Dispose();
                dataLogger = null;
            }
        } /* Dispose */
        private void  BuildDataFieldList()
        {
            int origWindowHeight        = this.Height;
            int origDataFieldListHeight = DataFieldList.Height;

            int origWindowWidth        = this.Width;
            int origDataFieldListWidth = DataFieldList.Width;

            foreach (String fn in dataFieldNames)
            {
                DataFieldList.Items.Add(fn);
            }
            DataFieldList.SelectedItem = selectedDataField;

            int totalHeightNeeded = InstrumentData.NumOfFields() * DataFieldList.ItemHeight + 30;

            DataFieldList.Height = totalHeightNeeded;

            int newWindowHeight = DataFieldList.Height + (origWindowHeight - origDataFieldListHeight);
            int newWindowWidth  = DataFieldList.Width + (origWindowWidth - origDataFieldListWidth);

            this.Height = newWindowHeight;
            this.Width  = newWindowWidth;
        } /* BuildDataFieldList */
Exemple #25
0
        public InstrumentData(InstrumentData r)
        {
            int x;

            data = new float[r.data.Length];
            for (x = 0; x < r.data.Length; x++)
            {
                data[x] = r.data[x];
            }

            activeBattery   = r.activeBattery;
            byteOffset      = r.byteOffset;
            latitude        = r.latitude;
            longitude       = r.longitude;
            scanLine        = r.scanLine;
            time            = r.time;
            updatedFlag     = r.updatedFlag;
            batteryStatuses = r.batteryStatuses;
            ctdDate         = r.ctdDate;

            cropLeft      = r.cropLeft;
            cropRight     = r.cropRight;
            activeColumns = (UInt16)(1 + cropLeft - cropRight);
        }
Exemple #26
0
        } /* LoadConfigurationPlottedDataSeries */

        private void  LoadConfigurationDataRow(string[] fields)
        {
            string label    = "";
            int    labelIdx = -1;
            float  min      = 0.0f;
            float  max      = 0.0f;
            bool   plotData = false;

            bool errorsFound = false;

            int fieldNum = 0;

            if (fields[0].ToLower() == "instrumentdata")
            {
                fieldNum = 1;
            }

            while (fieldNum < fields.Length)
            {
                string fieldName = fields[fieldNum].ToLower();
                fieldNum++;

                string fieldValue = "";
                if (fieldNum < fields.Length)
                {
                    fieldValue = fields[fieldNum];
                    fieldNum++;
                }

                if (fieldName == "label")
                {
                    label    = fieldValue;
                    labelIdx = InstrumentData.GetFieldNameIndex(label);
                }

                else if ((fieldName == "min") || (fieldName == "minimum"))
                {
                    min = PicesKKStr.StrToFloat(fieldValue);
                }

                else if ((fieldName == "max") || (fieldName == "maximum"))
                {
                    max = PicesKKStr.StrToFloat(fieldValue);
                }

                else if (fieldName == "plotdata")
                {
                    plotData = PicesKKStr.StrToBool(fieldValue);
                }
            }

            if ((labelIdx < 0) || (labelIdx >= InstrumentData.NumDataFields()))
            {
                errorsFound = true;
            }

            if (min > max)
            {
                errorsFound = true;
            }


            if (!errorsFound)
            {
                minValues [labelIdx]     = min;
                maxValues [labelIdx]     = max;
                plotDataSeries[labelIdx] = plotData;
            }
        } /* LoadConfigurationDataRow */
Exemple #27
0
        } /* DisableAllControls */

        private void  SaveConfiguration()
        {
            StreamWriter w = null;

            try
            {
                w = new StreamWriter(timePlotConfigFileName);
            }
            catch (Exception e)
            {
                MessageBox.Show("Exception Writing DataWindow configuration.  [" + e.ToString() + "]");
                return;
            }

            int x;

            w.WriteLine("// TimePlotWindow  Configuration");
            w.WriteLine("// DateTime" + "\t" + DateTime.Now.ToString());
            w.WriteLine("//");
            w.WriteLine("TimeRange" + "\t" + chartParms.TimeRange);

            w.WriteLine("// The following [" + InstrumentData.NumDataFields() + "]  rows represent the min/max values of each DataField from InstrumentData.");

            for (x = 0; x < InstrumentData.NumDataFields(); x++)
            {
                w.WriteLine("InstrumentData" + "\t" +
                            "Label" + "\t" + InstrumentData.FieldName(x) + "\t" +
                            "Min" + "\t" + minValues[x] + "\t" +
                            "Max" + "\t" + maxValues[x] + "\t" +
                            "PlotData" + "\t" + plotDataSeries[x] + "\t"
                            );
            }

            w.WriteLine("//");
            w.WriteLine("//");
            w.WriteLine("// The following [" + numDataSeries + "] rows list contents of the dataSeries to be plotted.");

            for (x = 0; x < plottedSeries.Length; x++)
            {
                w.Write("PlottedDataSeries" + "\t" +
                        "PlotDataSeriesIdx" + "\t" + x.ToString() + "\t" +
                        "SelectedLabel" + "\t" + plottedSeries[x].SelectedLabel + "\t"
                        );

                Color c = plottedSeries[x].PlotColor;

                if (c.IsKnownColor)
                {
                    w.Write("PlotColor" + "\t" + c.Name);
                }
                else
                {
                    w.Write("PlotColorAlpha" + "\t" + c.A + "\t" +
                            "PlotColorRed" + "\t" + c.R + "\t" +
                            "PlotColorGreen" + "\t" + c.G + "\t" +
                            "PlotColorBlue" + "\t" + c.B
                            );
                }

                w.WriteLine();
            }

            w.WriteLine("//");
            w.WriteLine("//");
            w.WriteLine("//  End Of File.");

            w.Close();

            return;
        } /* SaveConfiguration */
Exemple #28
0
        } /* LoadConfigurationDataRow */

        private void  DrawSingleDataRow(InstrumentData dr)
        {
            chartParms.PlotDataRow(dr);
        } /* DrawSingleDataRowOnSpecifiedCol */
Exemple #29
0
        } /* LoadConfiguration */

        private void  LoadConfigurationPlottedDataSeries(string[] fields)
        {
            int    idx            = -1;
            string label          = "";
            int    labelIdx       = -1;
            bool   plot           = false;
            Color  plotColor      = Color.Black;
            int    plotColorAlpha = 255;
            int    plotColorRed   = 0;
            int    plotColorGreen = 0;
            int    plotColorBlue  = 0;
            bool   plotColorKnown = false;

            bool errorsFound = false;

            int fieldNum = 0;

            if (fields[0].ToLower() == "plotteddataseries")
            {
                fieldNum = 1;
            }

            while (fieldNum < fields.Length)
            {
                string fieldName = fields[fieldNum].ToLower();
                fieldNum++;

                string fieldValue = "";
                if (fieldNum < fields.Length)
                {
                    fieldValue = fields[fieldNum];
                    fieldNum++;
                }

                if (fieldName == "plotdataseriesidx")
                {
                    idx = PicesKKStr.StrToInt(fieldValue);
                }

                else if ((fieldName == "label") || (fieldName == "selectedlabel"))
                {
                    label    = fieldValue;
                    labelIdx = InstrumentData.GetFieldNameIndex(label);
                }

                else if (fieldName == "plot")
                {
                    plot = PicesKKStr.StrToBool(fieldValue);
                }

                else if ((fieldName == "plotcoloralpha") || (fieldName == "alpha"))
                {
                    plotColorAlpha = PicesKKStr.StrToInt(fieldValue);
                    plotColorKnown = false;
                }

                else if ((fieldName == "plotcolorred") || (fieldName == "red"))
                {
                    plotColorRed   = PicesKKStr.StrToInt(fieldValue);
                    plotColorKnown = false;
                }

                else if ((fieldName == "plotcolorgreen") || (fieldName == "green"))
                {
                    plotColorGreen = PicesKKStr.StrToInt(fieldValue);
                    plotColorKnown = false;
                }

                else if ((fieldName == "plotcolorblue") || (fieldName == "blue"))
                {
                    plotColorBlue  = PicesKKStr.StrToInt(fieldValue);
                    plotColorKnown = false;
                }

                else if (fieldName == "plotcolor")
                {
                    plotColorKnown = true;
                    plotColor      = Color.FromName(fieldValue);
                    plotColorAlpha = plotColor.A;
                    plotColorRed   = plotColor.R;
                    plotColorGreen = plotColor.G;
                    plotColorBlue  = plotColor.B;
                }
            }


            if ((idx < 0) || (idx > numDataSeries))
            {
                errorsFound = true;
            }

            if (labelIdx < 0)
            {
                errorsFound = true;
            }

            if (!errorsFound)
            {
                fieldIdxs[idx] = labelIdx;

                if ((plotColorRed == 0) && (plotColorGreen == 0) && (plotColorBlue == 0))
                {
                    plotColor = plottedSeries[idx].PlotColor;
                }
                else if (!plotColorKnown)
                {
                    plotColor = Color.FromArgb(plotColorAlpha, plotColorRed, plotColorGreen, plotColorBlue);
                }

                plottedSeries[idx].SuspendLayout();
                plottedSeries[idx].Enabled = false;
                plottedSeries[idx].SetParameters(labelIdx, plot, plotColor);
                plottedSeries[idx].Enabled = true;
                plottedSeries[idx].ResumeLayout();

                plotBrushes[idx] = new SolidBrush(plotColor);
            }
        } /* LoadConfigurationPlottedDataSeries */
Exemple #30
0
        } /* UpdateDataSeriesValues */

        private void  UpdateTimePlot()
        {
            // This function gets called by the timer;  we are to update the
            // plot area with any new data that has arrived.

            if (lastHistoryRowDisplayed < 0)
            {
                lastHistoryRowDisplayed = 0;
            }

            int lastRowInHistory = -1;

            lock  (history)
            {
                lastRowInHistory = history.Count - 1;
            }

            if (lastHistoryRowDisplayed > lastRowInHistory)
            {
                // History must have been cleared.  We have to reset 'lastHistoryRowDisplayed'
                lastHistoryRowDisplayed = lastRowInHistory;
            }


            if (lastHistoryRowDisplayed >= lastRowInHistory)
            {
                return;
            }


            // Make sure that the last row in 'history' is visible in plot
            // area as currently defined by 'timeLeft' and 'timeRight'.

            // Compute instantaneous Delta-Depth


            InstrumentData lastHistRow = (InstrumentData)(history[lastRowInHistory]);

            int colThatWillDisplayOn = chartParms.ComputeColFromTime(lastHistRow.Time);

            if (colThatWillDisplayOn < -15)
            {
                DateTime dt = lastHistRow.Time;
                if (dt.Year >= 2006)
                {
                    chartParms.SetNewTimeLeft(dt);
                    RePlotData();
                }
            }
            else
            {
                chartParms.MakeTimeVisible(((InstrumentData)(history[lastRowInHistory])).Time);
            }

            while (lastHistoryRowDisplayed < lastRowInHistory)
            {
                lastHistoryRowDisplayed++;
                leftMostDataRow = (InstrumentData)history[lastHistoryRowDisplayed];
                DrawSingleDataRow(leftMostDataRow);
            }

            if (selectedHistory == null)
            {
                UpdateDataSeriesValues(leftMostDataRow);
            }
            else
            {
                UpdateDataSeriesValues(selectedHistory);
            }
        } /* UpdateTimePlot */