예제 #1
0
        } /* SaveConfiguration */

        private bool AreParametersValid()
        {
            ValidateTrainingModel();
            if (!trainingModelValid)
            {
                return(false);
            }

            trainingLevel   = PicesKKStr.StrToUint(TrainingLevel.Text);
            predictionLevel = PicesKKStr.StrToUint(PredictionLevel.Text);

            if ((trainingLevel < 1) || (trainingLevel > maxLevel))
            {
                MessageBox.Show("Invalid Training Level Specified, must be between[1 - " + maxLevel.ToString() + "]");
                return(false);
            }

            if ((predictionLevel < 1) || (predictionLevel > trainingLevel))
            {
                MessageBox.Show("Invalid Prediction Level Specified, must be between[1 - " + trainingLevel.ToString() + "]");
                return(false);
            }

            if (!Directory.Exists(GroundTruth.Text))
            {
                MessageBox.Show("Ground Truth Directory is not valid");
                return(false);
            }

            return(true);
        } /* AreParametersValid */
예제 #2
0
        } /* PopulateScreen */

        private bool  ChangesMade()
        {
            float  newScanRate = PicesKKStr.StrToFloat(ScanRate.Text);
            float  newDepth    = PicesKKStr.StrToFloat(Depth.Text);
            String newDepthStr = newDepth.ToString("#,##0.00");
            String oldDepthStr = sipperFile.Depth.ToString("#,##0.00");

            char extractionStatus        = ExtractionStatusCodeFromStr(ExtractionStatus.Text);
            uint extractionScanLineStart = PicesKKStr.StrToUint(ExtractionScanLineStart.Text);
            uint extractionScanLineEnd   = PicesKKStr.StrToUint(ExtractionScanLineEnd.Text);

            bool changesMade = (sipperFile.SipperFileName != SipperFileName.Text) ||
                               (sipperFile.Description != Description.Text) ||
                               (sipperFile.ScanRate != newScanRate) ||
                               (oldDepthStr != newDepthStr) ||
                               (sipperFile.Sp0 != SerialPort0.Text) ||
                               (sipperFile.Sp1 != SerialPort1.Text) ||
                               (sipperFile.Sp2 != SerialPort2.Text) ||
                               (sipperFile.Sp3 != SerialPort3.Text) ||
                               (sipperFile.CtdExt0 != CTDExt0.Text) ||
                               (sipperFile.CtdExt1 != CTDExt1.Text) ||
                               (sipperFile.CtdExt2 != CTDExt2.Text) ||
                               (sipperFile.CtdExt3 != CTDExt3.Text) ||
                               (sipperFile.DateTimeStart != DateTimeStart.Value) ||
                               (sipperFile.Latitude != latitude) ||
                               (sipperFile.Longitude != longitude) ||
                               (sipperFile.ExtractionStatus != extractionStatus) ||
                               (sipperFile.ExtractionScanLineStart != extractionScanLineStart) ||
                               (sipperFile.ExtractionScanLineEnd != extractionScanLineEnd);

            return(changesMade);
        } /* ChangesMade */
예제 #3
0
        } /* WriteLine */

        private void  ParseTabDelStr(string s,
                                     int[]     fieldIndexes,
                                     ref bool valid
                                     )
        {
            valid = true;

            ctdDate = new DateTime(1, 1, 1, 0, 0, 0);

            string[] fields = s.Split('\t');

            if (fields.Length != fieldIndexes.Length)
            {
                valid = false;
                return;
            }

            int x = 0;

            for (x = 0; x < fields.Length; x++)
            {
                string field      = fields[x];
                float  floatValue = PicesKKStr.StrToFloat(field);
                int    fieldIndex = fieldIndexes[x];

                if (fieldIndex < numDataFields)
                {
                    data[fieldIndex] = floatValue;
                    continue;
                }

                switch (fieldIndex)
                {
                case  LatitudeIndex:        latitude = PicesKKStr.StrToDouble(field); break;

                case  LongitudeIndex:       longitude = PicesKKStr.StrToDouble(field); break;

                case  DateIndex:            time = PicesKKStr.StrToDateTime(field); break;

                case  ActiveBatteryIndex:   activeBattery = PicesKKStr.StrToInt(field); break;

                case  BatteryStatusesIndex: batteryStatuses = field.Trim();                        break;

                case  CTD_DateIndex:        ctdDate = PicesKKStr.StrToDateTime(field); break;

                case  ScanLineIndex:        scanLine = PicesKKStr.StrToInt(field); break;

                case  ByteOffseIndex:       byteOffset = PicesKKStr.StrToUInt64(field); break;

                case  CropLeftIndex:        cropLeft = (UInt16)PicesKKStr.StrToUint(field); break;

                case  CropRightIndex:       cropRight = (UInt16)PicesKKStr.StrToUint(field); break;

                case  ActiveColumnsIndex:   activeColumns = (UInt16)PicesKKStr.StrToUint(field); break;
                }
            }
        } /* ParseTabDelStr */
예제 #4
0
        private void  ValidateExtractionScanLineEnd()
        {
            uint extractionScanLineStart = PicesKKStr.StrToUint(ExtractionScanLineStart.Text);
            uint extractionScanLineEnd   = PicesKKStr.StrToUint(ExtractionScanLineEnd.Text);

            ExtractionScanLineStart.Text = extractionScanLineStart.ToString("###,###,##0");
            ExtractionScanLineEnd.Text   = extractionScanLineEnd.ToString("###,###,##0");

            if ((extractionScanLineEnd > 0) && (extractionScanLineEnd < extractionScanLineStart))
            {
                errorProvider1.SetError(ExtractionScanLineEnd, "End Scan-line must be greater than start scan-line or '0'.");
                validationErrorsFound = true;
                return;
            }
        }
예제 #5
0
        public SipperDateStamp(string dateStr)
        {
            dayOfWeek = 1;
            day       = 1;
            month     = 1;
            year      = 8;

            bool validDate = true;

            // Expect string in format of  'mm/dd/yy'
            string[] fields = dateStr.Split('/');
            if (fields.Length != 3)
            {
                return;
            }

            month = PicesKKStr.StrToByte(fields[0]);
            if ((month < 1) || (month > 12))
            {
                validDate = false;
            }

            day = PicesKKStr.StrToByte(fields[1]);
            if ((day < 1) || (day > 31))
            {
                validDate = false;
            }

            uint xxx = PicesKKStr.StrToUint(fields[2]);

            if (xxx > 2000)
            {
                xxx = xxx - 2000;
                if (xxx < 100)
                {
                    year = (byte)xxx;
                }
            }
            if (!validDate)
            {
                DateTime dt = DateTime.Now;
                month = 1;
                day   = 1;
                year  = 1;
            }

            return;
        }
예제 #6
0
        private void SipperFileDialog_Load(object sender, EventArgs e)
        {
            allowUpdates = PicesSipperVariables.AllowUpdates();

            if (runLog == null)
            {
                runLog = new PicesRunLog();
            }

            LoadValidCTDExtrnlPorts();

            String[]   fieldNames = { "NumScanLines", "DateTimeStart", "NumImages" };
            String[][] results    = DbConn().QueryStatement("call SipperFilesCalcStats(\"" + sipperFile.SipperFileName + "\")",
                                                            fieldNames
                                                            );

            if ((results == null) || (results.Length < 1))
            {
                return;
            }

            uint numScanLines = PicesKKStr.StrToUint(results[0][0]);
            uint numImages    = PicesKKStr.StrToUint(results[0][2]);

            if (numScanLines > 0)
            {
                ScanLines.Text = numScanLines.ToString("###,###,##0");
            }

            if (numImages > 0)
            {
                NumImages.Text = numImages.ToString("###,###,##0");
            }

            latitude  = sipperFile.Latitude;
            longitude = sipperFile.Longitude;

            PopulateScreen();
        } /* SipperFileDialog_Load */
예제 #7
0
        } /* PopulateScreen */

        private void  UpdateFromScreen()
        {
            sipperFile.SipperFileName = SipperFileName.Text;
            sipperFile.Description    = Description.Text;
            sipperFile.Latitude       = PicesKKStr.StrToLatitude(Latitude.Text);
            sipperFile.Longitude      = PicesKKStr.StrToLongitude(Longitude.Text);
            sipperFile.DateTimeStart  = DateTimeStart.Value;
            sipperFile.ScanRate       = PicesKKStr.StrToFloat(ScanRate.Text);
            sipperFile.Depth          = PicesKKStr.StrToFloat(Depth.Text);
            sipperFile.Sp0            = SerialPort0.Text;
            sipperFile.Sp1            = SerialPort1.Text;
            sipperFile.Sp2            = SerialPort2.Text;
            sipperFile.Sp3            = SerialPort3.Text;
            sipperFile.CtdExt0        = CTDExt0.Text;
            sipperFile.CtdExt1        = CTDExt1.Text;
            sipperFile.CtdExt2        = CTDExt2.Text;
            sipperFile.CtdExt3        = CTDExt3.Text;

            sipperFile.ExtractionStatus        = (sbyte)ExtractionStatusCodeFromStr(ExtractionStatus.Text);
            sipperFile.ExtractionScanLineStart = PicesKKStr.StrToUint(ExtractionScanLineStart.Text);
            sipperFile.ExtractionScanLineEnd   = PicesKKStr.StrToUint(ExtractionScanLineEnd.Text);
        } /* PopulateScreen */
예제 #8
0
        private void ReTallyButton_Click(object sender, EventArgs e)
        {
            uint zed = PicesKKStr.StrToUint(PredictionLevel.Text);

            if (zed < 1)
            {
                predLevel = 1;
            }

            else if (zed > trainLevel)
            {
                predLevel = trainLevel;
            }

            else
            {
                predLevel = zed;
            }

            PredictionLevel.Text = predLevel.ToString();

            ReCalcMatrix();
        }
예제 #9
0
 private void PredictionLevel_SelectionChangeCommitted(object sender, EventArgs e)
 {
     PredictionLevel.Text = (PredictionLevel.Items [PredictionLevel.SelectedIndex]).ToString();
     predictionLevel      = PicesKKStr.StrToUint(PredictionLevel.Text);
     InitializeTrainAndPredLevelFields();
 }
예제 #10
0
        private void  LoadConfiguraionData()
        {
            StreamReader f = null;

            try
            {
                f = new StreamReader(configFileName);
            }
            catch (Exception)
            {
                return;
            }

            string txtLine = f.ReadLine();

            while (txtLine != null)
            {
                if (txtLine.Substring(0, 2) != "//")
                {
                    String[] fields = txtLine.Split('\t');
                    if (fields.Length > 1)
                    {
                        string rowType = fields[0].ToLower().Trim();


                        if (rowType == "crossvalidation")
                        {
                            crossValidation         = ((fields[1] == "Y") || (fields[1] == "T"));
                            CrossValidation.Checked = crossValidation;
                        }


                        if (rowType == "trainingmodelselected")
                        {
                            if (fields.Length >= 2)
                            {
                                TrainingModelSelected.Text = fields[1];
                                trainingModelName          = fields[1];
                            }
                        }

                        else if (rowType == "groundtruth")
                        {
                            if (fields.Length >= 2)
                            {
                                GroundTruth.Text = fields[1];
                            }
                        }

                        else if (rowType == "traininglevel")
                        {
                            if (fields.Length >= 2)
                            {
                                trainingLevel      = PicesKKStr.StrToUint(fields[1]);
                                TrainingLevel.Text = trainingLevel.ToString();
                            }
                        }

                        else if (rowType == "predictionlevel")
                        {
                            if (fields.Length >= 2)
                            {
                                predictionLevel      = PicesKKStr.StrToUint(fields[1]);
                                PredictionLevel.Text = trainingLevel.ToString();
                            }
                        }

                        else if (rowType == "endoffile")
                        {
                            break;
                        }
                    }
                }

                txtLine = f.ReadLine();
            }

            ValidateTrainingModel();
            InitializeTrainAndPredLevelFields();

            f.Close();
        } /* LoadConfiguraionData */