Class to interface the AWARE electronics RM-60, RM-70 and RM-80 serial geiger counters. More...
Public Member Functions | |
| AwareGeigerCounter (string portReference) | |
| Initialize an AWARE geiger counter. | |
| void | Dispose () |
| Dispose of the AwareGeigerCounter object by removing event handler and closing port. | |
Properties | |
| GeigerCounterEvent | EventHandler [set] |
| Sets the event handler which is called for each detection event. | |
Class to interface the AWARE electronics RM-60, RM-70 and RM-80 serial geiger counters.
Definition at line 24 of file AwareGeigerCounter.cs.
| NewGamePhysics.Devices.AwareGeigerCounter.AwareGeigerCounter | ( | string | portReference | ) |
Initialize an AWARE geiger counter.
| portReference | The name of the serial port to connect to (i.e. COM1) or a number to use as index to available ports (i.e. 2 = second available port). |
Definition at line 57 of file AwareGeigerCounter.cs.
00058 { 00059 if (string.IsNullOrEmpty(portReference)) 00060 { 00061 throw new ArgumentNullException( 00062 "portReference", 00063 "The port reference cannot be null or empty"); 00064 } 00065 00066 string[] portNames = System.IO.Ports.SerialPort.GetPortNames(); 00067 string portName; 00068 00069 if ((portNames == null) || (portNames.Length == 0)) 00070 { 00071 throw new ApplicationException( 00072 "No serial ports are available on this system"); 00073 } 00074 00075 if (!Array.Exists(portNames, s => s.ToUpper().Contains(portReference.ToUpper()))) 00076 { 00077 try 00078 { 00079 int portIndex = Convert.ToInt32(portReference); 00080 00081 if ((portIndex < 1) || (portIndex > portNames.Length)) 00082 { 00083 SerialPortInfo(portNames); 00084 throw new ArgumentOutOfRangeException( 00085 "portIndex", 00086 "The port index must be in the range 1 to " + portNames.Length); 00087 } 00088 00089 portName = portNames[portIndex - 1]; 00090 } 00091 catch (Exception) 00092 { 00093 SerialPortInfo(portNames); 00094 throw; 00095 } 00096 } 00097 else 00098 { 00099 portName = portReference; 00100 } 00101 00102 this.InitializePort(portName); 00103 }
| void NewGamePhysics.Devices.AwareGeigerCounter.Dispose | ( | ) |
Dispose of the AwareGeigerCounter object by removing event handler and closing port.
Definition at line 109 of file AwareGeigerCounter.cs.
GeigerCounterEvent NewGamePhysics.Devices.AwareGeigerCounter.EventHandler [set] |
Sets the event handler which is called for each detection event.
Definition at line 134 of file AwareGeigerCounter.cs.
1.6.2