public double ReadActivity() { if (Port.IsOpen) { Port.Write("$CR1H#"); string output = Port.ReadLine(); string checkSum = output.Substring(output.Length - 1); CapintecUnit unit = (CapintecUnit)Convert.ToInt16(output.Substring(output.Length - 2, 1)); double reading = Convert.ToDouble(output.Substring(13, 6)); if (unit == CapintecUnit.GBq) { reading = reading * 1000; } return(reading); } else { throw new Exception("Port is not open"); } }
public double ReadActivity(Isotope isotope) { if (isotope == null) { return(ReadActivity()); } if (Port.IsOpen) { Port.Write("$CR1H#"); string output = Port.ReadLine(); string checkSum = output.Substring(output.Length - 1); CapintecUnit unit = (CapintecUnit)Convert.ToInt16(output.Substring(output.Length - 2, 1)); string channel = output.Substring(5, 8); channel = channel.Trim(); if (IsotopeChannelNumbers.Where(x => x.IsotopeString == channel).Any() == false) { throw new Exception("Incorrect dose calibrator channel"); } else { if (IsotopeChannelNumbers.Where(x => x.IsotopeString == channel).First().Isotope.ID != isotope.ID) { throw new Exception("Incorrect dose calibrator channel"); } } double reading = Convert.ToDouble(output.Substring(13, 6)); if (unit == CapintecUnit.GBq) { reading = reading * 1000; } return(reading); } else { throw new Exception("Port is not open"); } }