private void AddIsotope() { IsotopeChannelNumber n = new IsotopeChannelNumber(); IsotopeChannelNumbers.Add(n); DoseCalibrator.IsotopeChannelNumbers.Add(n); }
public CapintecSettingsProvider() : base() { OpenPortCommand = new RelayCommand(openPort); WriteToPortCommand = new RelayCommand(WriteToPort); ReadActivityCommand = new RelayCommand(ReadActivity); AddIsotopeCommand = new RelayCommand(AddIsotope); SaveChannelsCommand = new RelayCommand(SaveChannels); string [] portName = SerialPort.GetPortNames(); foreach (string s in portName) { Output = Output + s + System.Environment.NewLine; } DoseCalibrator = DesktopApplication.MainViewModel.DoseCalibrator as CapintecDoseCalibrator; foreach (var c in DoseCalibrator.IsotopeChannelNumbers) { IsotopeChannelNumbers.Add(c); } _availableIsotopes = Platform.Retriever.RetrieveItems(typeof(Isotope), new List <RetrievalCriteria>()); }
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"); } }