Ejemplo n.º 1
0
        private void  LoadDeployments()
        {
            deployment = null;
            PicesSipperDeploymentList deployments = mainWinConn.SipperDeploymentLoad(cruiseName, stationName);

            if (deployments == null)
            {
                return;
            }
            DeploymentField.Items.Clear();
            deployment = null;
            foreach (PicesSipperDeployment d in  deployments)
            {
                DeploymentField.Items.Add(d);
                if (d.DeploymentNum.Equals(deploymentNum, StringComparison.InvariantCultureIgnoreCase))
                {
                    deployment = d;
                }
            }
            if (deployment == null)
            {
                deploymentNum = "";
            }
            else
            {
                DeploymentField.SelectedItem = deployment;
            }
        }
Ejemplo n.º 2
0
        private void  PopulatDeploymentsToPlot()
        {
            DeploymentsToPlot.Items.Clear();
            PicesSipperDeploymentList deployments = mainWinConn.SipperDeploymentLoad(cruiseName, "");

            if (deployments == null)
            {
                return;
            }

            stations = mainWinConn.SipperStationLoad(cruiseName);

            cruiseAdjGpsToActTime = new TimeSpan(0, 0, 0);
            long adjGpsToActTime = 0;

            foreach (PicesSipperDeployment deployment in deployments)
            {
                long deploymentAdjGpsToAct = deployment.SyncTimeStampGPS.ToFileTimeUtc() - deployment.SyncTimeStampActual.ToFileTimeUtc();
                if (deploymentAdjGpsToAct != adjGpsToActTime)
                {
                    adjGpsToActTime       = deploymentAdjGpsToAct;
                    cruiseAdjGpsToActTime = deployment.SyncTimeStampActual - deployment.SyncTimeStampGPS;
                }

                DeploymentsToPlot.Items.Add(deployment, true);
            }
        }
Ejemplo n.º 3
0
        private void  LoadDeploymentDetails()
        {
            nextDeploymentNum = "A";
            this.Nodes.Clear();
            PicesSipperDeploymentList deplomyents = dbConn.SipperDeploymentLoad(station.CruiseName, station.StationName);

            if (deplomyents == null)
            {
                return;
            }
            String lastDeplymentNum = "";

            foreach (PicesSipperDeployment deployment in deplomyents)
            {
                this.Nodes.Add(new TreeNodeDeployment(dbConn, deployment));
                if (deployment.DeploymentNum.Length > 0)
                {
                    lastDeplymentNum = deployment.DeploymentNum;
                }
            }

            if (lastDeplymentNum.Length > 0)
            {
                if ((lastDeplymentNum[0] >= 'A') && (lastDeplymentNum[0] < 'Z'))
                {
                    Char x = lastDeplymentNum[0];
                    x++;
                    nextDeploymentNum = x.ToString();
                }
            }
        } /* LoadDeploymentDetails */
Ejemplo n.º 4
0
        private PicesSipperDeploymentList  CurrentlySelectedDeployments()
        {
            PicesSipperDeploymentList deployments = new PicesSipperDeploymentList();

            foreach (Object so in DeploymentsToPlot.CheckedItems)
            {
                deployments.Add((PicesSipperDeployment)so);
            }

            return(deployments);
        }
Ejemplo n.º 5
0
        private PicesSipperDeployment  CurrentlySelectedDeployment()
        {
            PicesSipperDeploymentList deployments = CurrentlySelectedDeployments();

            if ((deployments == null) || (deployments.Count < 1))
            {
                return(null);
            }
            else
            {
                return(deployments[0]);
            }
        }
Ejemplo n.º 6
0
        private void  PopulatDeploymentsToPlot()
        {
            DeploymentsToPlot.Items.Clear();
            PicesSipperDeploymentList deployments = mainWinConn.SipperDeploymentLoad(cruise, "");

            if (deployments == null)
            {
                return;
            }
            foreach (PicesSipperDeployment deployment in deployments)
            {
                DeploymentsToPlot.Items.Add(deployment, true);
            }
        }
Ejemplo n.º 7
0
        } /* UpdateChartAreas */

        private void  SchedulePlotRequests()
        {
            PicesSipperDeploymentList deploymentsRequested = CurrentlySelectedDeployments();

            if (deploymentsRequested == null)
            {
                deploymentsRequested = new PicesSipperDeploymentList();
            }

            plotRequests = new List <PlotRequest> ();

            foreach (PicesSipperDeployment deployment in  deploymentsRequested)
            {
                plotRequests.Add(new PlotRequest(deployment));
            }
        } /* SchedulePlotRequests */
Ejemplo n.º 8
0
        } /* UpdateChartAreas */

        private void  SchedulePlotRequests()
        {
            //String  plotAction = PlotAction.SelectedText;

            PicesSipperDeploymentList deploymentsRequested = CurrentlySelectedDeployments();

            if (deploymentsRequested == null)
            {
                deploymentsRequested = new PicesSipperDeploymentList();
            }

            plotRequests = new List <PlotRequest> ();

            foreach (PicesSipperDeployment deployment in  deploymentsRequested)
            {
                plotRequests.Add(new PlotRequest(deployment, Color.Black));
            }
        } /* SchedulePlotRequests */
Ejemplo n.º 9
0
        } /* PopulateStationFromScreen*/

        private void  LoadDeploymentDetails()
        {
            if (addingNewStation)
            {
                return;
            }
            Deployments.Nodes.Clear();
            PicesSipperDeploymentList deplomyents = DbConn().SipperDeploymentLoad(station.CruiseName, station.StationName);

            if (deplomyents == null)
            {
                return;
            }
            foreach (PicesSipperDeployment deployment in deplomyents)
            {
                Deployments.Nodes.Add(new TreeNodeDeployment(DbConn(), deployment));
            }
        } /* LoadDeploymentDetails */
Ejemplo n.º 10
0
        } /* AddStationsToChart */

        private void  UpdateChartAreas()
        {
            goalie.StartBlock();

            double minX = double.MaxValue;
            double maxX = double.MinValue;
            double minY = double.MaxValue;
            double maxY = double.MinValue;

            DateTime minGpsDateTime = DateTime.MaxValue;
            DateTime maxGpsDateTime = DateTime.MinValue;

            timeInterval = (int)TimeInterval.Value;
            //String  plotAction = PlotAction.SelectedText;

            PicesSipperDeploymentList selectedDeployments = CurrentlySelectedDeployments();

            String titleLine = "Station: " + stationName;

            titleLine += "  Time-Interval: " + timeInterval;

            ProfileChart.Titles.Clear();
            ProfileChart.Titles.Add(new Title(titleLine, Docking.Top, titleFont, Color.Black));

            if (series.Count < 1)
            {
                ProfileChart.Series.Clear();
                goalie.EndBlock();
                return;
            }

            ChartArea ca = ProfileChart.ChartAreas[0];

            ca.AxisX.TitleFont = axisTitleFont;
            ca.AxisY.TitleFont = axisTitleFont;

            ProfileChart.Series.Clear();

            // First we will plot cruise level series;  that is series that are not ties to a specific deployment.
            foreach (DataSeriesToPlot dstp in series)
            {
                if (dstp.deployment == null)
                {
                    AddSeriesToChart(dstp, ref minX, ref maxX, ref minY, ref maxY, ref minGpsDateTime, ref maxGpsDateTime);
                }
            }

            PicesSipperStationList stationsToPlot = new PicesSipperStationList();
            Dictionary <String, PicesSipperStation> stationsPlotted = new Dictionary <string, PicesSipperStation> ();

            // Second we plot series that is specific to a deployment.
            foreach (DataSeriesToPlot dstp in series)
            {
                PicesSipperDeployment d = dstp.deployment;
                AddSeriesToChart(dstp, ref minX, ref maxX, ref minY, ref maxY, ref minGpsDateTime, ref maxGpsDateTime);

                if (!stationsPlotted.ContainsKey(d.StationName))
                {
                    PicesSipperStation stationToPlot = mainWinConn.SipperStationLoad(d.CruiseName, d.StationName);
                    stationsPlotted.Add(d.StationName, stationToPlot);
                    stationsToPlot.Add(stationToPlot);
                }
            }

            // Third we add stations that were not in one of the specified deployments but awe in the area of the deployments.
            // Find other stations in plot area.
            // Degrees/Kilo-Meter = 1/111  There are 111 Km/Degree of latitude

            double paddingKms    = (double)PaddingKms.Value;
            double latPadding    = paddingKms * (1.0 / 111.0); // Will add 5km's of padding to latitude.
            double degreesToRads = Math.PI / 180.0;
            double kmsPerDegLong = 111.6 * Math.Cos((minY + maxY) / 2.0 * degreesToRads);
            double longPadding   = paddingKms * (1.0 / (kmsPerDegLong));

            //
            PicesSipperStationList stationsInRange =
                mainWinConn.SipperStationsLoadByGpsRange(minY - latPadding, maxY + latPadding, minX - longPadding, maxX + longPadding);

            if (stationsInRange != null)
            {
                foreach (PicesSipperStation stationToPlot in stationsInRange)
                {
                    if (!stationsPlotted.ContainsKey(stationToPlot.StationName))
                    {
                        stationsPlotted.Add(stationToPlot.StationName, stationToPlot);
                        stationsToPlot.Add(stationToPlot);
                    }
                }
            }

            // Forth We add the stations to the Plot.
            AddStationsToChart(stationsToPlot, ref minX, ref maxX, ref minY, ref maxY);

            double latitudeMid = (maxY + minY) / 2.0;

            float plotAreaHeight = ProfileChart.ChartAreas[0].InnerPlotPosition.Height;
            float plotAreaWidth  = ProfileChart.ChartAreas[0].InnerPlotPosition.Width;

            double yRangeDegs = maxY - minY;
            double xRangeDegs = maxX - minX;

            double yRangeKms = yRangeDegs * 111.0;

            double longKmsPerDeg = 111.6 * Math.Cos(latitudeMid * degToRad);

            double xRangeKms = xRangeDegs * longKmsPerDeg;

            double yDensity = yRangeKms / plotAreaHeight;
            double xDenisty = xRangeKms / plotAreaWidth;

            if (xDenisty > yDensity)
            {
                double newYRangeKms = xDenisty * plotAreaHeight;
                double newYRageDegs = newYRangeKms / 111.0;

                double deltaYRange = newYRageDegs - yRangeDegs;
                minY = minY - deltaYRange / 2.0;
                maxY = maxY + deltaYRange / 2.0;
            }
            else
            {
                double newXRangeKms  = yDensity * plotAreaWidth;
                double newXRangeDegs = newXRangeKms / longKmsPerDeg;

                double deltaXRange = newXRangeDegs - xRangeDegs;
                minX = minX - (deltaXRange / 2.0);
                maxX = maxX + (deltaXRange / 2.0);
            }

            {
                // X Axis Custom Labels
                ca.AxisX.CustomLabels.Clear();
                double delta = (maxX - minX) / 5.0;

                char   d    = (char)176;
                string dStr = d.ToString();

                double fromPos = minX;
                for (int xx = 0; xx < 5; ++xx)
                {
                    double      toPos     = fromPos + delta;
                    double      midPos    = (toPos + fromPos) / 2.0;
                    double      midPosAbs = Math.Abs(midPos);
                    double      degs      = Math.Floor(midPosAbs);
                    double      mins      = (midPosAbs - degs) * 60.0;
                    string      s         = degs.ToString() + dStr + ":" + mins.ToString("00.00") + "'" + ((midPos < 0.0) ? "W" : "E");
                    CustomLabel cl        = new CustomLabel(fromPos, toPos, s, 0, LabelMarkStyle.LineSideMark, GridTickTypes.Gridline);
                    ca.AxisX.CustomLabels.Add(cl);
                    fromPos = toPos;
                }
                ca.AxisX.LabelStyle.Font = axisLabelFont;
            }


            {
                // Y Axis Custom Labels
                ca.AxisY.CustomLabels.Clear();
                double delta = (maxY - minY) / 5.0;

                char   d    = (char)176;
                string dStr = d.ToString();

                double fromPos = minY;
                for (int xx = 0; xx < 5; ++xx)
                {
                    double      toPos     = fromPos + delta;
                    double      midPos    = (toPos + fromPos) / 2.0;
                    double      midPosAbs = Math.Abs(midPos);
                    double      degs      = Math.Floor(midPosAbs);
                    double      mins      = (midPosAbs - degs) * 60.0;
                    string      s         = degs.ToString() + dStr + ":" + mins.ToString("00.00") + "'" + ((midPos < 0.0) ? "S" : "N");
                    CustomLabel cl        = new CustomLabel(fromPos, toPos, s, 0, LabelMarkStyle.LineSideMark, GridTickTypes.Gridline);
                    ca.AxisY.CustomLabels.Add(cl);
                    fromPos = toPos;
                }
                ca.AxisY.LabelStyle.Font = axisLabelFont;
            }


            ca.AxisX.Minimum = minX;
            ca.AxisX.Maximum = maxX;
            ca.AxisY.Minimum = minY;
            ca.AxisY.Maximum = maxY;

            ProfileChart.ChartAreas[0].RecalculateAxesScale();

            goalie.EndBlock();
        } /* UpdateChartAreas */
Ejemplo n.º 11
0
        } /* AddStationsToChart */

        private void  UpdateChartAreas()
        {
            goalie.StartBlock();

            double minX = double.MaxValue;
            double maxX = double.MinValue;
            double minY = double.MaxValue;
            double maxY = double.MinValue;

            DateTime minGpsDateTime = DateTime.MaxValue;
            DateTime maxGpsDateTime = DateTime.MinValue;

            timeInterval = (int)TimeInterval.Value;
            //String  plotAction = PlotAction.SelectedText;

            PicesSipperDeploymentList selectedDeployments = CurrentlySelectedDeployments();

            String titleLine = "Cruise: " + cruiseName;

            titleLine += "  Time-Interval: " + timeInterval;

            ProfileChart.Titles.Clear();
            ProfileChart.Titles.Add(titleLine);

            if (series.Count < 1)
            {
                ProfileChart.Series.Clear();
                goalie.EndBlock();
                return;
            }

            ChartArea ca = ProfileChart.ChartAreas[0];
            //ca.AxisY.Title = "Latitude";

            //ca.AxisX.Title = "Longitude";
            Font f = new Font(ca.AxisX.TitleFont.FontFamily, 10);

            ca.AxisX.TitleFont = f;
            f = new Font(ca.AxisY.TitleFont.FontFamily, 10);
            ca.AxisY.TitleFont = f;

            ProfileChart.Series.Clear();

            // First we will plot cruise level series;  that is series that are not ties to a specific deployment.
            foreach (DataSeriesToPlot dstp in series)
            {
                if (dstp.deployment == null)
                {
                    AddSeriesToChart(dstp, ref minX, ref maxX, ref minY, ref maxY, ref minGpsDateTime, ref maxGpsDateTime);
                }
            }

            Dictionary <String, PicesSipperStation> stationsPlotted = new Dictionary <string, PicesSipperStation> ();
            PicesSipperDeploymentList deploymentsPlotted            = new PicesSipperDeploymentList();

            // Second we plot series that is specific to a deployment.
            foreach (DataSeriesToPlot dstp in series)
            {
                if (dstp.deployment != null)
                {
                    String stationName = dstp.deployment.StationName;
                    AddSeriesToChart(dstp, ref minX, ref maxX, ref minY, ref maxY, ref minGpsDateTime, ref maxGpsDateTime);
                    deploymentsPlotted.Add(dstp.deployment);
                }
            }

            String[] stationNamesToPlot           = deploymentsPlotted.ExtractStationNames();
            PicesSipperStationList stationsToPlot = new PicesSipperStationList();

            foreach (String stationName in stationNamesToPlot)
            {
                PicesSipperStation stationToPlot = stations.LookUpByStationName(stationName);
                if (stationToPlot != null)
                {
                    stationsToPlot.Add(stationToPlot);
                    stationsPlotted.Add(stationToPlot.StationName, stationToPlot);
                }
            }

            // Third we add stations that were not in one of the specified deployments but awe in the area of the deployments.
            // Find other stations in plot area.
            // Degrees/Kilo-Meter = 1/111  There are 111 Km/Degree of latitude

            double paddingKms    = (double)PaddingKms.Value;
            double latPadding    = paddingKms * (1.0 / 111.0); // Will add 5km's of padding to latitude.
            double degreesToRads = Math.PI / 180.0;
            double kmsPerDegLong = 111.6 * Math.Cos((minY + maxY) / 2.0 * degreesToRads);
            double longPadding   = paddingKms * (1.0 / (kmsPerDegLong));

            PicesSipperStationList stationsInRange =
                mainWinConn.SipperStationsLoadByGpsRange(minY - latPadding, maxY + latPadding, minX - longPadding, maxX + longPadding);

            if (stationsInRange != null)
            {
                foreach (PicesSipperStation stationToPlot in stationsInRange)
                {
                    if (!stationsPlotted.ContainsKey(stationToPlot.StationName))
                    {
                        stationsPlotted.Add(stationToPlot.StationName, stationToPlot);
                        stationsToPlot.Add(stationToPlot);
                    }
                }
            }

            AddStationsToChart(stationsToPlot, ref minX, ref maxX, ref minY, ref maxY);

            double latitudeMid = (maxY + minY) / 2.0;

            float plotAreaHeight = ProfileChart.Height;
            float plotAreaWidth  = ProfileChart.Width;

            double xRange    = maxX - minX;
            double yRange    = maxY - minY;
            double xRangeAdj = xRange * Math.Cos(latitudeMid * degToRad);

            double yDensity = yRange / plotAreaHeight;
            double xDenisty = xRangeAdj / plotAreaWidth;

            if (xDenisty > yDensity)
            {
                yRange = xDenisty * plotAreaHeight;
                double leftOver = yRange - (maxY - minY);
                minY = minY - leftOver / 2.0;
                maxY = maxY + leftOver / 2.0;
            }
            else
            {
                xRangeAdj = yDensity * plotAreaWidth;
                xRange    = xRangeAdj / Math.Cos(latitudeMid * degToRad);
                double leftOver = xRange - (maxX - minX);
                minX = minX - leftOver / 2.0;
                maxX = maxX + leftOver / 2.0;
            }

            ca.AxisX.Minimum = minX;
            ca.AxisX.Maximum = maxX;
            ca.AxisY.Minimum = minY;
            ca.AxisY.Maximum = maxY;

            ProfileChart.ChartAreas[0].RecalculateAxesScale();

            goalie.EndBlock();
        } /* UpdateChartAreas */
Ejemplo n.º 12
0
        } /* StartTheBackGroundProcedure */

        private void  BackGroundProcess()
        {
            backGroundRunning = true;

            PicesDataBase.ThreadInit();


            OSservices.CreateDirectoryPath(reportFileDir);

            DateTime n           = DateTime.Now;
            String   logFileName = OSservices.AddSlash(PicesSipperVariables.TempDirectory()) + "InstrumentDataByDeployment_Log_" +
                                   n.Year.ToString("0000") + "-" + n.Month.ToString("00") + "-" + n.Day.ToString("00") + "_" +
                                   n.Hour.ToString("00") + "-" + n.Minute.ToString("00") + "-" + n.Hour.ToString("00") +
                                   ".txt";

            backGroundLog = new PicesRunLog(logFileName);
            PicesDataBase threadConn = PicesDataBase.GetGlobalDatabaseManagerNewInstance(backGroundLog);

            RunLogAddMsg("Cruise           [" + cruiseName + "]" + "\n");
            RunLogAddMsg("Station          [" + stationName + "]" + "\n");
            RunLogAddMsg("Deployment       [" + deploymentNum + "]" + "\n");
            RunLogAddMsg("Start Date/Time  [" + DateTime.Now.ToString("yyyy-MMM-dd HH:mm:ss") + "]" + "\n");
            RunLogAddMsg("Active DataBase  [" + threadConn.Server.Description + "]" + "\n");

            PicesSipperDeploymentList deployments = null;

            if (!String.IsNullOrEmpty(deploymentNum))
            {
                PicesSipperDeployment d = threadConn.SipperDeploymentLoad(cruiseName, stationName, deploymentNum);
                if (d != null)
                {
                    deployments = new PicesSipperDeploymentList();
                    deployments.Add(d);
                }
            }
            else
            {
                deployments = threadConn.SipperDeploymentLoad(cruiseName, stationName);
            }

            if (deployments == null)
            {
                RunLogAddMsg("\n\nNo Deployments for Specified Criteria!\n\n");
                return;
            }

            int reportNum = 0;

            foreach (PicesSipperDeployment d in deployments)
            {
                if (cancelBackGround)
                {
                    break;
                }

                reportNum++;

                RunLogAddMsg("Generating Report " + reportNum.ToString() + " of " + deployments.Count.ToString());

                SummarizeInstrumentDataForADeployment(threadConn, d.CruiseName, d.StationName, d.DeploymentNum);
            }

            threadConn.Close();
            threadConn = null;
            GC.Collect();

            PicesDataBase.ThreadEnd();

            backGroundRunning = false;
        } /* BackGroundProcess */