Beispiel #1
0
 private static void UnregisterForInputEvents(p.Device device,
                                              p.AnalogInputChangedEventHandler analogInputChangedEventHandler,
                                              p.DigitalInputChangedEventHandler digitalInputChangedEventHandler,
                                              p.I2CDataReceivedEventHandler i2cDataReceivedEventHandler)
 {
     if (device == null)
     {
         return;
     }
     if (analogInputChangedEventHandler != null)
     {
         try
         {
             device.AnalogInputChanged -= analogInputChangedEventHandler;
         }
         catch (RemotingException)
         {
         }
     }
     if (digitalInputChangedEventHandler != null)
     {
         try
         {
             device.DigitalInputChanged -= digitalInputChangedEventHandler;
         }
         catch (RemotingException)
         {
         }
     }
     if (i2cDataReceivedEventHandler != null)
     {
         try
         {
             device.I2CDataReceived -= i2cDataReceivedEventHandler;
         }
         catch (RemotingException)
         {
         }
     }
 }
Beispiel #2
0
        private static void RegisterForInputEvents(p.Device device,
                                                   p.AnalogInputChangedEventHandler analogInputChangedEventHandler,
                                                   p.DigitalInputChangedEventHandler digitalInputChangedEventHandler,
                                                   p.I2CDataReceivedEventHandler i2cDataReceivedEventHandler)
        {
            if (device == null)
            {
                return;
            }

            if (analogInputChangedEventHandler != null)
            {
                device.AnalogInputChanged += analogInputChangedEventHandler;
            }
            if (digitalInputChangedEventHandler != null)
            {
                device.DigitalInputChanged += digitalInputChangedEventHandler;
            }
            if (i2cDataReceivedEventHandler != null)
            {
                device.I2CDataReceived += i2cDataReceivedEventHandler;
            }
        }
Beispiel #3
0
 private void CreateInputEventHandlers()
 {
     _analogInputChangedEventHandler  = device_AnalogInputChanged;
     _digitalInputChangedEventHandler = device_DigitalInputChanged;
     _i2cDataReceivedEventHandler     = device_I2CDataReceived;
 }
Beispiel #4
0
 private void AbandonInputEventHandlers()
 {
     _analogInputChangedEventHandler  = null;
     _digitalInputChangedEventHandler = null;
     _i2cDataReceivedEventHandler     = null;
 }