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 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 */
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); }
} /* 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 */
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 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*/
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"); }
} /* 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"); }
} /* 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 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(); }
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."); } }
} /* ParseRawFreqAndVoltsInDec */ private void UpdateExternalVoldtageField(String extCode, String amtField ) { float amt = PicesKKStr.StrToFloat(amtField); switch (extCode) { case "CDM": cdomFluorescenceSensor = amt; break; case "FLO": fluorescenceSensor = amt; break; case "OXG": oxygenSensor = amt; break; case "TRN": transmisivitySensor = amt; break; case "TUR": turbiditySensor = amt; break; } } /* UpdateExternalVoldtageField */
override public void ParseTxtLine(string txtLine) { // We will be expecting 5 fields; // <Current battery> <\t> <Bat 0 Voltage> <\t> .... <\t> <Bat-3 Voltage> <\t> "Battery Statuses" // // ex "4, 21.55, 21.57, 0.47, 24.62, DDLL" string[] fields = txtLine.Split(','); if (fields.Length < (numOfBatteries + 1)) { return; } if (fields[0].Length != 1) { return; } char ch = fields[0][0]; if ((ch != '1') && (ch != '2') && (ch != '3') && (ch != '4')) { return; } int activeBatery = PicesKKStr.StrToInt(fields[0]); int x; for (x = 1; x <= numOfBatteries; x++) { batteryLevels[x] = PicesKKStr.StrToFloat(fields[x]); } string batteryStatusStr = ""; if (fields.Length > (numOfBatteries + 1)) { batteryStatusStr = fields[numOfBatteries + 1]; } Manager().CurrentDataRow( ).UpdateSipperBatteries(activeBatery, batteryLevels, batteryStatusStr); } /* ParseTxtLine */
} /* ParseLine */ private float ParseSyncFreqField(string s) { float scanRate = 0.0f; int x = s.IndexOf('('); if (x > 0) { s = s.Substring(x + 1); x = s.IndexOf(')'); if (x > 0) { s = s.Substring(0, x); scanRate = PicesKKStr.StrToFloat(s); } } return(scanRate); } /* ParseSyncFreqField */
} /* EnableControlsStartButtonPressed */ private void ValidateDepthIncrement() { if (!weight) { DepthIncrement.Text = ""; DepthIncrement.Enabled = false; return; } char[] delimiters = { ' ', '\n', '\r', '\t' }; String[] fields = DepthIncrement.Text.Split(delimiters); if (fields.Length < 1) { errorProvider1.SetError(DepthIncrement, "Need to provide increment in meters; > 0.5"); validationErrorFound = true; return; } float temp = PicesKKStr.StrToFloat(fields[0]); if (temp < 0.5f) { errorProvider1.SetError(DepthIncrement, "Need to provide increment in meters; > 0.5"); validationErrorFound = true; return; } if (temp > 100.0f) { errorProvider1.SetError(DepthIncrement, "Maximum increment is 100.0 meters."); validationErrorFound = true; return; } errorProvider1.SetError(DepthIncrement, ""); DepthIncrement.Text = temp.ToString("##0.0") + " " + "Meters"; depthIncrement = temp; } /* ValidateDepthIncrement*/
} /* 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 */
} /* SplitUpIntoTokensStrings */ override public void ParseTxtLine(string txtLine) { string[] fields = SplitUpIntoTokensStrings(txtLine); if (fields.Length != 4) { return; } string fieldName = ""; string fieldValue = ""; int fieldNum = 0; while (fieldNum < fields.Length) { fieldName = fields[fieldNum].ToLower(); fieldNum++; if (fieldNum < fields.Length) { fieldValue = fields[fieldNum]; fieldNum++; } else { fieldValue = ""; } if (fieldName == "r") { roll = PicesKKStr.StrToFloat(fieldValue); } else if (fieldName == "p") { pitch = PicesKKStr.StrToFloat(fieldValue); } } Manager().CurrentDataRow().UpdatePitchAndRoll(pitch, roll); } /* ParseTxtLine */
} /* ValidateSipperFiles */ private void ValidateMinimumDepth() { errorProvider1.SetError(MinimumDepth, ""); float temp = PicesKKStr.StrToFloat(MinimumDepth.Text); if (temp < 0.0f) { errorProvider1.SetError(MinimumDepth, "Minimum Depth can not be less than 0.0"); validationErrorFound = true; return; } if (temp > 13000.0) { errorProvider1.SetError(MinimumDepth, "Minimum Depth[" + temp.ToString("n") + "] is to Large, can not exceed 13,000 meters"); validationErrorFound = true; return; } minimumDepth = temp; MinimumDepth.Text = minimumDepth.ToString("##,##0.00"); }
private void LoadConfigurationFile() { System.IO.StreamReader i = null; try { i = new System.IO.StreamReader(configFileName); } catch (Exception) { i = null; } if (i == null) { return; } int savedWidth = 0; int savedHeight = 0; bool screenWasMaximized = false; String nextLine = null; while (true) { try { nextLine = i.ReadLine(); } catch (Exception) { break; } if (nextLine == null) { break; } nextLine = nextLine.Trim(); if ((nextLine.Length < 3) || (nextLine.Substring(0, 2) == "//")) { continue; } String[] fields = nextLine.Split('\t'); if (fields.Length < 2) { continue; } String fieldName = fields[0]; String fieldValue = fields[1]; switch (fieldName) { case "WidthLast": savedWidth = PicesKKStr.StrToInt(fieldValue); break; case "HeightLast": savedHeight = PicesKKStr.StrToInt(fieldValue); break; case "Maximized": screenWasMaximized = (fieldValue.ToUpper() == "YES"); break; case "TimeInterval": case "DepthIncr": depthIncrement = (int)PicesKKStr.StrToFloat(fieldValue); if (depthIncrement > 0) { DepthIncr.Value = (decimal)depthIncrement; } break; } } i.Close(); if (savedWidth > Screen.PrimaryScreen.Bounds.Width) { savedWidth = Screen.PrimaryScreen.Bounds.Width; } if (savedHeight > Screen.PrimaryScreen.Bounds.Height) { savedHeight = Screen.PrimaryScreen.Bounds.Height; } if (screenWasMaximized) { //savedWidth = Screen.PrimaryScreen.Bounds.Width; //savedHeight = savedHeight = Screen.PrimaryScreen.Bounds.Height; this.WindowState = FormWindowState.Maximized; } else { Height = Math.Max(savedHeight, MinimumSize.Height); Width = Math.Max(savedWidth, MinimumSize.Width); } OnResizeEnd(new EventArgs()); } /* LoadConfigurationFile */
} /* 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 */
} /* UpdateExternalVoldtageField */ /* * Temp Conduc Pres Ext0 Ext1 Ext2 Ext3 Salin Sound Date Time Density Volts * 27.2807, 0.00004, 0.161, 0.0000, 0.0000, 0.0000, 0.0000, 0.0127, 1502.622, 01 Jan 2009, 21:49:00, -3.5531, 11.8 * 27.2806, 0.00004, 0.161, 0.0000, 0.0000, 0.0000, 0.0000, 0.0127, 1502.622, 01 Jan 2009, 21:49:00, -3.5531, 11.7 * 27.2804, 0.00005, 0.163, 0.0000, 0.0000, 0.0000, 0.0000, * 27.2673, 0.00004, 0.168, 0.0000, 0.0000, 0.0000, 0.0000, 0.0127, 1502.589, 01 Jan 2009, 21:50:15, -3.5494, 11.8 * 22.6653, 0.00004, 0.186, 4.8936, 0.0001, 3.6778, 4.9422, 0.0110, 1490.267, 31 Dec 2008, 08:48:56, -2.3730, 12.3 * 22.6650, 0.00004, 0.186, 4.8956, 0.0000, 3.6778, 4.9447, 0.0110, 1490.267, 31 Dec 2008, 08:48:57, -2.3729, 12.3 * 21.2358, 0.00005, 0.127, 4.4267, 3.0283, 2.9500, 4.9417, 0.0104, 1486.104, 02 Jan 2011, 13:12:44, -2.0497, 11.8 * * 21.2359, 0.00006, 0.135, 4.4265, 3.0284, 2.9513, 4.9428, 0.0104, 1486.104, 02 Jan 2011, 13:12:44, -2.0497, 11.9 * 21.2359, 0.00006, 0.130, 4.4263, 3.0285, 2.9508, 4.9432, 0.0104, 1486.104, 02 Jan 2011, 13:12:44, -2.0497, 11.9 * 21.2361, 0.00006, 0.133, 4.4265, 3.0287, 2.9514, 4.9451, 0.0104, 1486.105, 02 Jan 2011, 13:12:45, -2.0497, 11.9 * 21.2363, 0.00005, 0.129, 4.4262, 3.0286, 2.9511, 4.9443, 0.0104, 1486.105, 02 Jan 2011, 13:12:45, -2.0498, 11.8 * 21.2363, 0.00006, 0.131, 4.4261, 3.0290, 2.9508, 4.9437, 0.0104, 1486.105, 02 Jan 2011, 13:12:45, -2.0498, 11.8 * * Raw data from Panama Cruise. Dec-2008 thru Jan-2009; * We got a surprise, When all 4 external inputs are enabled in CTD, there is not cr/lf at end of line. * * 28.4069, 5.48627, 17.249, 4.2988, 3.3123, 0.0967, 0.0816, 33.7479, 1541.195, 30 Oct 2007, 21:52:42, 21.3204, 9.9 * */ private void ParseEngineeringUnitsInDec(string txtLine) { string[] fields = txtLine.Split(','); if (fields.Length < 10) { // We have an un-complete text line; no point trying to decode it. return; } else if (fields.Length > 13) { return; } int numExternalVoltages = 0; if (processSoundVelocity) { numExternalVoltages = fields.Length - 9; } else { numExternalVoltages = fields.Length - 8; } if (numExternalVoltages > 4) { numExternalVoltages = 4; } int fieldNum = 0; temperature = PicesKKStr.StrToFloat(fields[fieldNum++]); conductivity = PicesKKStr.StrToFloat(fields[fieldNum++]); pressure = PicesKKStr.StrToFloat(fields[fieldNum++]); int numExternalProcessed = 0; if ((!String.IsNullOrEmpty(ext0Code)) && (numExternalProcessed < numExternalVoltages)) { UpdateExternalVoldtageField(ext0Code, fields[fieldNum++]); numExternalProcessed++; } if ((!String.IsNullOrEmpty(ext1Code)) && (numExternalProcessed < numExternalVoltages)) { UpdateExternalVoldtageField(ext1Code, fields[fieldNum++]); numExternalProcessed++; } if ((!String.IsNullOrEmpty(ext2Code)) && (numExternalProcessed < numExternalVoltages)) { UpdateExternalVoldtageField(ext2Code, fields[fieldNum++]); numExternalProcessed++; } if ((!String.IsNullOrEmpty(ext3Code)) && (numExternalProcessed < numExternalVoltages)) { UpdateExternalVoldtageField(ext3Code, fields[fieldNum++]); numExternalProcessed++; } while (numExternalProcessed < numExternalVoltages) { fieldNum++; numExternalProcessed++; } salinity = PicesKKStr.StrToFloat(fields[fieldNum++]); soundVelocity = PicesKKStr.StrToFloat(fields[fieldNum++]); dateTime = StrToDateTime(fields[fieldNum++] + fields[fieldNum++], "dd MMM yyyy HH':'mm':'ss"); density = PicesKKStr.StrToFloat(fields[fieldNum++]); batteryVoltage = PicesKKStr.StrToFloat(fields[fieldNum++]); if ((temperature < -1.0f) || (temperature > 50.0f) || (pressure < -0.5f) || (pressure > 10000.0f) || (oxygenSensor <= 0.0f) // kak 2010-05-05 Sine we no longer have Oxygen Sensor need to set to zero ) { oxygen = 0.0f; } else { oxygen = DissolvedOxygenConcentration(oxygenSensor, temperature, salinity, pressure); } CalcFluorescence(); CalcCdomFluorescence(); CalcTurbidity(); CalcTransmisivity(); double latitude = Manager().Latitude(); if (latitude < 1.0) { // Set to latitude of Panama Cruises first station. latitude = 29 + (30.0 / 60.0); // 2010-05-05 For gulf trip will use 29.5 degrees. // latitude = 11 + (59.7 /60.0); // 11 degrees 59.7 minutes were used for Panama Trip. } // The following calculations for depth comes from: // SBE Application Note No. 69, Page 1. July 2002 // references UNESCO Technical Papers in Marine Science No. 44. // gravity = (m/sec^2) double degToRad = 1.0 / 57.29578; double x = Math.Pow(Math.Sin(latitude * degToRad), 2.0); double gravity = 9.780318 * (1.0 + (5.2788e-3 + 2.36e-5 * x) * x) + 1.092e-6 * pressure; double p = (double)pressure; depth = (float)(((((-1.82e-15 * p + 2.279e-10) * p - 2.2512e-5) * p + 9.72659) * p) / gravity); } /* ParseEngineeringUnitsInDec */
} /* SetSizeStatistic */ private void LoadConfigurationFile() { System.IO.StreamReader i = null; try { i = new System.IO.StreamReader(configFileName); } catch (Exception) { i = null; } if (i == null) { return; } int savedWidth = 0; int savedHeight = 0; bool screenWasMaximized = false; String nextLine = null; while (true) { try { nextLine = i.ReadLine(); } catch (Exception) { break; } if (nextLine == null) { break; } nextLine = nextLine.Trim(); if ((nextLine.Length < 3) || (nextLine.Substring(0, 2) == "//")) { continue; } String[] fields = nextLine.Split('\t'); if (fields.Length < 2) { continue; } String fieldName = fields[0]; String fieldValue = fields[1]; switch (fieldName) { case "WidthLast": savedWidth = PicesKKStr.StrToInt(fieldValue); break; case "HeightLast": savedHeight = PicesKKStr.StrToInt(fieldValue); break; case "Maximized": screenWasMaximized = (fieldValue.ToUpper() == "YES"); break; case "ClassToPlot": ClassToPlot.Text = fieldValue; break; case "IncludeSubClasses": IncludeSubClasses.Checked = PicesKKStr.StrToBool(fieldValue); break; case "SizeStatistic": SetSizeStatistic(fieldValue); break; case "InitialSize": float initialSize = PicesKKStr.StrToFloat(fieldValue); if ((initialSize <= 0.0) || (initialSize >= 100.0f)) { initialSize = 0.10f; } InitialSizeField.Value = (decimal)initialSize; break; case "MaxSize": float maxSize = PicesKKStr.StrToFloat(fieldValue); if ((maxSize <= 0.0) || (maxSize < (float)InitialSizeField.Value)) { maxSize = Math.Max(1000.0f, (float)InitialSizeField.Value); } MaxSizeField.Value = (decimal)maxSize; break; case "GrowthRate": float growthRate = PicesKKStr.StrToFloat(fieldValue); if (growthRate <= 1.0f) { growthRate = 1.1f; } GrowthRateField.Value = (decimal)growthRate; break; case "LastSaveDirectory": char[] whiteSpaceChars = { '\n', '\r', '\t', ' ' }; lastSaveDirectory = fieldValue.Trim(whiteSpaceChars); break; } } i.Close(); if (savedWidth > Screen.PrimaryScreen.Bounds.Width) { savedWidth = Screen.PrimaryScreen.Bounds.Width; } if (savedHeight > Screen.PrimaryScreen.Bounds.Height) { savedHeight = Screen.PrimaryScreen.Bounds.Height; } if (screenWasMaximized) { //savedWidth = Screen.PrimaryScreen.Bounds.Width; //savedHeight = savedHeight = Screen.PrimaryScreen.Bounds.Height; this.WindowState = FormWindowState.Maximized; } else { Height = Math.Max(savedHeight, MinimumSize.Height); Width = Math.Max(savedWidth, MinimumSize.Width); } if (SizeStatisticField.SelectedItem == null) { SizeStatisticField.SelectedItem = SizeStatisticField.Items[0]; } OnResizeEnd(new EventArgs()); } /* LoadConfigurationFile */