# NewGamePhysics.Devices.AwareGeigerCounter Class Reference

Class to interface the AWARE electronics RM-60, RM-70 and RM-80 serial geiger counters. More...

List of all members.

## 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.

## Detailed Description

Class to interface the AWARE electronics RM-60, RM-70 and RM-80 serial geiger counters.

Definition at line 24 of file AwareGeigerCounter.cs.

## Constructor & Destructor Documentation

NewGamePhysics.Devices.AwareGeigerCounter.AwareGeigerCounter | ( | string | portReference | ) |

Initialize an AWARE geiger counter.

Parameters:

  | 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         }

## Member Function Documentation

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.

    00110         {
    00111             if (this.serialPort != null)
    00112             {
    00113                 this.serialPortHandle = (IntPtr)0;
    00114                 this.serialPort.PinChanged -= new SerialPinChangedEventHandler(PinChanged);
    00115                 this.serialPort.Close();
    00116                 this.serialPort.Dispose();
    00117                 this.serialPort = null;
    00118             }
    00119         }

## Property Documentation

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.

The documentation for this class was generated from the following file:

- C:/Users/Andreas Schiffler/Desktop/SVN/NewGamePhysics/NewGamePhysics/Devices/AwareGeigerCounter.cs