} /* 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 */
private void ValidateLongitude() { errorProvider1.SetError(Longitude, null); double longitude = PicesKKStr.StrToLongitude(Longitude.Text); Longitude.Text = PicesKKStr.LongitudeToStr(longitude); }
private void ValidateIncrements() { errorProvider1.SetError(Increments, ""); if (saveByClass) { return; } char[] delimeters = { ' ', '\n', '\r' }; String[] fields = Increments.Text.Split(delimeters); if (fields.Length < 1) { errorsFound = true; errorProvider1.SetError(Increments, "No Increment specified."); } int temp = PicesKKStr.StrToInt(fields[0]); if ((temp < 1) || (temp > 100)) { errorsFound = true; errorProvider1.SetError(Increments, "Valid Increment range is (1 - 100)."); } increments = temp; }
private void BandPassButton_Click(object sender, EventArgs e) { lowerBound = PicesKKStr.StrToFloat(LowerBound.Text) / 100.0f; upperBound = PicesKKStr.StrToFloat(UpperBound.Text) / 100.0f; if (lowerBound < 0.0f) { lowerBound = 0.0f; } else if (lowerBound > 1.0f) { lowerBound = 1.0f; } if (upperBound < 0.0f) { upperBound = 0.0f; } else if (upperBound > 1.0f) { upperBound = 1.0f; } if (lowerBound > upperBound) { lowerBound = upperBound; } LowerBound.Text = ((float)(lowerBound * 100.0f)).ToString("##0"); UpperBound.Text = ((float)(upperBound * 100.0f)).ToString("##0"); AddOperation(PicesRaster.OperationType.BandPass); }
private void ValidateMaxProbability() { if (maxProbabilityBeingValidated) { return; } maxProbabilityBeingValidated = true; int maxLowerLimit = minProbability + 1; int zed = PicesKKStr.StrToInt(MaxProbability.Text); if ((zed < maxLowerLimit) || (zed > 100)) { MessageBox.Show("Maximum probability must be in range of [" + maxLowerLimit.ToString() + " - 100]", "Max Probability"); MaxProbability.Text = maxProbability.ToString(); } else { if (zed != maxProbability) { maxProbability = zed; PopulateProbabilityComboBoxes(); } } maxProbabilityBeingValidated = false; } /* ValidateMaxProbability */
private void ValidateMinProbability() { if (minProbabilityBeingValidated) { return; } minProbabilityBeingValidated = true; int minUpperLimit = maxProbability - 1; int zed = PicesKKStr.StrToInt(MinProbability.Text); if ((zed < 0) || (zed > minUpperLimit)) { MessageBox.Show("Minimum probability must be in range of [0 - " + minUpperLimit.ToString() + "]", "Min Probability"); MinProbability.Text = minProbability.ToString(); } else { if (zed != minProbability) { minProbability = zed; PopulateProbabilityComboBoxes(); } } minProbabilityBeingValidated = false; } /* ValidateMinProbability */
} /* 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 */
} /* ExtractionStatusCodeFromStr */ private void PopulateScreen() { SipperFileName.Text = sipperFile.SipperFileName; Description.Text = sipperFile.Description; Latitude.Text = PicesKKStr.LatitudeToStr(sipperFile.Latitude); Longitude.Text = PicesKKStr.LongitudeToStr(sipperFile.Longitude); DateTimeStart.Value = sipperFile.DateTimeStart; ScanRate.Text = sipperFile.ScanRate.ToString("###,##0.00"); Depth.Text = sipperFile.Depth.ToString("#,##0.00"); SerialPort0.Text = sipperFile.Sp0; SerialPort1.Text = sipperFile.Sp1; SerialPort2.Text = sipperFile.Sp2; SerialPort3.Text = sipperFile.Sp3; CTDExt0.Text = sipperFile.CtdExt0; CTDExt1.Text = sipperFile.CtdExt1; CTDExt2.Text = sipperFile.CtdExt2; CTDExt3.Text = sipperFile.CtdExt3; ExtractionStatus.Text = ExtractionStatusCodeToStr((char)sipperFile.ExtractionStatus); ExtractionScanLineStart.Text = sipperFile.ExtractionScanLineStart.ToString("###,###,##0"); ExtractionScanLineEnd.Text = sipperFile.ExtractionScanLineEnd.ToString("###,###,##0"); } /* PopulateScreen */
public SipperTimeStamp(string timeStr) { hour = 0; minute = 0; second = 0; string[] fields = timeStr.Split(':'); if (fields.Length != 3) { return; } hour = PicesKKStr.StrToByte(fields[0]); if ((hour < 0) || (hour > 24)) { hour = 0; return; } minute = PicesKKStr.StrToByte(fields[1]); if ((minute < 0) || (minute > 60)) { minute = 0; return; } second = PicesKKStr.StrToByte(fields[2]); if ((second < 0) || (second > 60)) { second = 0; return; } }
private void LoadImageDepthStats(PicesDataBase threadConn, String cruiseName, String stationName, String deploymentNum, ref List <ImagesDepthStats> downCast, ref List <ImagesDepthStats> upCast ) { String sqlStr = "call ImagesStatsByUpAndDownCast("; sqlStr += "\"" + cruiseName + "\"" + ", "; sqlStr += "\"" + stationName + "\"" + ", "; sqlStr += "\"" + deploymentNum + "\"" + ", "; if (mlClass == null) { sqlStr += "\"\", "; } else { sqlStr = "\"" + mlClass.Name + "\"" + ", "; } sqlStr += "1.0);"; downCast = null; upCast = null; String[] cols = { "UpCast", "BucketIdx", "BucketDepth", "ImageCount", "TotalPixelCount" }; String[][] results = threadConn.QueryStatement(sqlStr, cols); if (results == null) { RunLogAddMsg("Error Retrieving Images Cout Statistics."); RunLogAddMsg(threadConn.LastErrorDesc()); return; } downCast = new List <ImagesDepthStats> (); upCast = new List <ImagesDepthStats> (); foreach (String[] row in results) { bool goingUp = (row[0] == "1"); int bucketIdx = PicesKKStr.StrToInt(row[1]); float bucketDepth = PicesKKStr.StrToFloat(row[2]); int imageCount = PicesKKStr.StrToInt(row[3]); int totalPixelCount = PicesKKStr.StrToInt(row[4]); ImagesDepthStats stats = new ImagesDepthStats(goingUp, bucketIdx, bucketDepth, imageCount, totalPixelCount); if (!goingUp) { downCast.Add(stats); } else { upCast.Add(stats); } } return; } /* LoadImageDepthStats */
} /* PopulateScreen */ private void PopulateStationFromScreen() { station.StationName = StationName.Text; station.Description = Description.Text; station.Latitude = PicesKKStr.StrToLatitude(Latitude.Text); station.Longitude = PicesKKStr.StrToLongitude(Longitude.Text); station.DateTimeStart = DateTimeStart.Value; } /* PopulateStationFromScreen*/
} /* 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 */
} /* ValidateTrainingDataPercentage */ private void ValidateTrainingMaxImagesPerClass() { errorProvider1.SetError(TrainingMaxImagesPerClass, null); trainingDataMaxImagesPerClass = PicesKKStr.StrToInt(TrainingMaxImagesPerClass.Text); if (trainingDataMaxImagesPerClass < 0) { errorsFound = true; errorProvider1.SetError(TrainingMaxImagesPerClass, "Max Images Per Directory can not be negative."); } }
private bool ChangesMade() { bool changesMade = (StationName.Text != station.StationName) || (Description.Text != station.Description) || (PicesKKStr.StrToLatitude(Latitude.Text) != station.Latitude) || (PicesKKStr.StrToLongitude(Longitude.Text) != station.Longitude) || (DateTimeStart.Value != station.DateTimeStart); return(changesMade); }
private void SizeOptions_SelectedOptionChanged() { string selOptStr = SizeOptions.SelectedOption; if (selOptStr.EndsWith("%")) { selOptStr = selOptStr.Substring(0, selOptStr.Length - 1); sizeRatio = PicesKKStr.StrToFloat(selOptStr) / 100.0f; RePaintImage(); } }
private void PopulateScreen() { CruiseName.Text = deployment.CruiseName; StationName.Text = deployment.StationName; DeploymentNum.Text = deployment.DeploymentNum; if (addingNewDeployment) { DeploymentNum.ReadOnly = false; DeploymentNum.TabStop = true; } else { DeploymentNum.ReadOnly = true; DeploymentNum.TabStop = false; } Description.Text = deployment.Description; Latitude.Text = PicesKKStr.LatitudeToStr(deployment.Latitude); Longitude.Text = PicesKKStr.LongitudeToStr(deployment.Longitude); String s = deployment.ChamberWidth.ToString(ChamberWidth.Mask); s = s.PadLeft(ChamberWidth.Mask.Length); ChamberWidth.Text = s; DateTimeStart.Value = deployment.DateTimeStart; DateTimeEnd.Value = deployment.DateTimeEnd; SyncTimeStampActual.Value = deployment.SyncTimeStampActual; SyncTimeStampCTD.Value = deployment.SyncTimeStampCTD; SyncTimeStampGPS.Value = deployment.SyncTimeStampGPS; if (deletingDeployment) { StationName.ReadOnly = false; Description.ReadOnly = false; Latitude.ReadOnly = false; Longitude.ReadOnly = false; ChamberWidth.Enabled = false; DateTimeStart.Enabled = false; DateTimeEnd.Enabled = false; SyncTimeStampActual.Enabled = false; SyncTimeStampCTD.Enabled = false; SyncTimeStampGPS.Enabled = false; UpdateButton.Text = "Delete"; } PopulateSipperFiles(); if (!allowUpdates) { UpdateButton.Enabled = false; AddSipperFileButton.Enabled = false; } } /* PopulateScreen */
private void PopulateDeploymentFromScreen() { deployment.DeploymentNum = DeploymentNum.Text; deployment.Description = Description.Text; deployment.Latitude = PicesKKStr.StrToLatitude(Latitude.Text); deployment.Longitude = PicesKKStr.StrToLongitude(Longitude.Text); deployment.ChamberWidth = PicesKKStr.StrToFloat(ChamberWidth.Text); deployment.DateTimeStart = DateTimeStart.Value; deployment.DateTimeEnd = DateTimeEnd.Value; deployment.SyncTimeStampActual = SyncTimeStampActual.Value; deployment.SyncTimeStampCTD = SyncTimeStampCTD.Value; deployment.SyncTimeStampGPS = SyncTimeStampGPS.Value; } /* PopulateDeploymentFromScreen*/
} /* ValidateDepthIncrement*/ private void ValidateHowManyToHarvest() { howManyToHarvest = PicesKKStr.StrToInt(HowManyToHarvest.Text); if (howManyToHarvest < 10) { errorProvider1.SetError(HowManyToHarvest, "You must select at least 10 images to harvest."); validationErrorFound = true; return; } errorProvider1.SetError(HowManyToHarvest, ""); HowManyToHarvest.Text = howManyToHarvest.ToString(); } /* ValidateHowManyToHarvest */
} /* ValidateDestinationDirectory */ private void ValidateIncludeSampleImagesNumPerClass() { errorProvider1.SetError(IncludeSampleImagesNumPerClass, ""); if (IncludeSampleImages.Checked) { includeSampleImagesNumPerClass = PicesKKStr.StrToInt(IncludeSampleImagesNumPerClass.Text); if (includeSampleImagesNumPerClass < 1) { errorsFound = true; errorProvider1.SetError(IncludeSampleImagesNumPerClass, "Must be greater than zero."); return; } } }
} /* ParseSyncFreqField */ private float ParseExposureField(string s) { float exposureTime = 0.0f; int x = s.IndexOf("uSec"); if (x > 0) { s = s.Substring(0, x).Trim(); exposureTime = PicesKKStr.StrToFloat(s); } return(exposureTime); } /* ParseExposureField */
} /* LoadValidCTDExtrnlPorts */ private void ValidateScanRate() { errorProvider1.SetError(ScanRate, null); float newScanRate = PicesKKStr.StrToFloat(ScanRate.Text); if (newScanRate < 0.0f) { errorProvider1.SetError(ScanRate, "ScanRate must be greater than 0.0"); validationErrorsFound = true; return; } ScanRate.Text = newScanRate.ToString("###,##0.00"); }
private void ValidateDepth() { errorProvider1.SetError(Depth, null); float newDepth = PicesKKStr.StrToFloat(Depth.Text); if (newDepth < 0.0f) { errorProvider1.SetError(ScanRate, "Depth must be greater than 0.0"); validationErrorsFound = true; return; } Depth.Text = newDepth.ToString("###,##0.00"); }
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; } }
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; }
} /* MakePredictions */ private void GetZoomFactor() { float origZoomFactor = zoomFactor; bool divideBy100 = false; String s = ZoomFactor.Text; if (s[s.Length - 1] == '%') { s = s.Substring(0, s.Length - 1); divideBy100 = true; } zoomFactor = PicesKKStr.StrToFloat(s); if (zoomFactor <= 0.0f) { zoomFactor = origZoomFactor; divideBy100 = false; } if (divideBy100) { zoomFactor = zoomFactor / 100.0f; } if (zoomFactor <= 0.0f) { zoomFactor = 1.0f; } int largestDim = Math.Max(raster.Height, raster.Width); int zoomedLargestDim = (int)((float)largestDim * zoomFactor + 0.5f); if (zoomedLargestDim > 4096) { zoomFactor = 4096.0f / (float)(zoomedLargestDim + 1); } int smallestDim = Math.Min(raster.Height, raster.Width); int zoomedSmalestDim = (int)((float)smallestDim * zoomFactor + 0.5f); if (zoomedSmalestDim < 3) { zoomFactor = 3.0f / (float)(zoomedSmalestDim + 1); } ZoomFactor.Text = zoomFactor.ToString("##0.0%"); } /* GetZoomFactor */
private void ValidateChamberWidth() { errorProvider1.SetError(ChamberWidth, null); float chamberWidth = PicesKKStr.StrToFloat(ChamberWidth.Text); if (chamberWidth < 0.001) { validationErrorsFound = true; errorProvider1.SetError(ChamberWidth, "Chamber Width of 1mm of less is unreasonable."); } else if (chamberWidth >= 1.0000) { validationErrorsFound = true; errorProvider1.SetError(ChamberWidth, "Chamber Width a Meter or greater is not reasonable."); } }
private bool ChangesMade() { float chamberWidthT = PicesKKStr.StrToFloat(ChamberWidth.Text); bool changesMade = (DeploymentNum.Text != deployment.DeploymentNum) || (Description.Text != deployment.Description) || (PicesKKStr.StrToLatitude(Latitude.Text) != deployment.Latitude) || (PicesKKStr.StrToLongitude(Longitude.Text) != deployment.Longitude) || (chamberWidthT != deployment.ChamberWidth) || (SyncTimeStampActual.Value != deployment.SyncTimeStampActual) || (SyncTimeStampCTD.Value != deployment.SyncTimeStampCTD) || (SyncTimeStampGPS.Value != deployment.SyncTimeStampGPS) || (DateTimeStart.Value != deployment.DateTimeStart) || (DateTimeEnd.Value != deployment.DateTimeEnd); return(changesMade); }
private void ValidateValidationDataPercentage() { errorProvider1.SetError(ValidaionDataPercentage, null); float zed = validationDataPercentage = PicesKKStr.StrToFloat(ValidaionDataPercentage.Text); if ((zed < 0.0f) || (zed > 100.0f)) { errorProvider1.SetError(ValidaionDataPercentage, "Validation Data Percentage must be between 1.0 and 100.0"); errorsFound = true; } else { validationDataPercentage = zed; testDataPercentage = 100.0f - (trainingDataPercentage + validationDataPercentage); } UpdatePercentageFields(); }
} /* ReadHardDrive */ private void ReadSerialPort(string s) { s = s.Trim(); int serialPortNum = PicesKKStr.StrToInt(s); if ((serialPortNum < 0) || (serialPortNum >= serialPortBuffers.Length)) { WriteToSocket("Invalid Serial Port[" + serialPortNum + "]\n"); WriteToTextWindow("Invalid Serial Port[" + serialPortNum + "]\n"); } else { SerialPortBuffer sp = serialPortBuffers[serialPortNum]; if (sp == null) { WriteToSocket("Invalid Serial Port[" + serialPortNum + "]\n"); WriteToTextWindow("Invalid Serial Port[" + serialPortNum + "]\n"); } else { int amtDataAvailable = sp.SpaceUsed(); int x = 0; string textLine = ""; for (x = 0; x < amtDataAvailable; x++) { char ch = sp.ReadChar(); textLine += ch.ToString(); } WriteToSocket(textLine); WriteToTextWindow(textLine); if (sp.SpaceUsed() > 0) { WriteToSocket("** WARNING ** Buffer not emptied."); WriteToTextWindow("** WARNING ** Buffer not emptied."); } } } } /* ReadSerialPort */
private void BinarizeTHButton_Click(object sender, EventArgs e) { thLowerBound = (uint)PicesKKStr.StrToInt(ThLowerBound.Text); thUpperBound = (uint)PicesKKStr.StrToInt(ThUpperBound.Text); thLowerBound = Math.Max(0, thLowerBound); thUpperBound = Math.Min(255, thUpperBound); if (thLowerBound > thUpperBound) { thLowerBound = thUpperBound - 1; } ThLowerBound.Text = thLowerBound.ToString("##0"); ThUpperBound.Text = thUpperBound.ToString("##0"); AddOperation(PicesRaster.OperationType.BinarizeTH); }