Пример #1
0
 /// <summary> Fires the <c>OnDeviceDetached</c> event. </summary>
 /// <param name="Device"> The Input/Output device object. </param>
 /// <seealso cref="wclWeDoIo"/>
 protected virtual void DoDeviceDetached(wclWeDoIo Device)
 {
     if (OnDeviceDetached != null)
     {
         OnDeviceDetached(this, Device);
     }
 }
Пример #2
0
        private void HubDeviceAttached(Object Sender, wclWeDoIo Device)
        {
            // Make sure device is not attached yet.
            foreach (wclWeDoIo Io in FDevices)
            {
                if (Io.ConnectionId == Device.ConnectionId)
                {
                    return;
                }
            }

            FDevices.Add(Device);
            DoDeviceAttached(Device);
        }
Пример #3
0
 /// <summary> This method called internally by the <see cref="wclWeDoHub"/>
 ///   to notify about characteristic changes. A derived class may override this method
 ///   to check for required characteristic changes. </summary>
 /// <param name="Handle"> The characteristic handle. </param>
 /// <param name="Value"> The new characteristic value. </param>
 internal override void CharacteristicChanged(UInt16 Handle, Byte[] Value)
 {
     // Process data only if it presents.
     if (Value != null && Value.Length > 0)
     {
         // Button pressed?
         if (FButtonStateChar != null && Handle == FButtonStateChar.Value.Handle)
         {
             DoButtonStateChanged(Value[0] == 1);
         }
         // Low voltage?
         if (FLowVoltageAlertChar != null && Handle == FLowVoltageAlertChar.Value.Handle)
         {
             DoLowVoltageAlert(Value[0] == 1);
         }
         // High current!
         if (FHighCurrentAleartChar != null && Handle == FHighCurrentAleartChar.Value.Handle)
         {
             DoHightCurrentAlert(Value[0] == 1);
         }
         // Low signal
         if (FLowSignalChar != null && Handle == FLowSignalChar.Value.Handle)
         {
             DoLowSignalAlert(Value[0] == 1);
         }
         // IO attached/detached
         if (FIoAttachedChar != null && Handle == FIoAttachedChar.Value.Handle)
         {
             if (Value.Length >= 2)
             {
                 if (Value[1] == 1)
                 {
                     // Attached
                     wclWeDoIo Io = wclWeDoIo.Attach(Hub, Value);
                     if (Io != null)
                     {
                         DoDeviceAttached(Io);
                     }
                 }
                 else
                 {
                     // Detached.
                     DoDeviceDetached(Value[0]);
                 }
             }
         }
     }
 }
Пример #4
0
        private void HubDeviceDetached(Object Sender, Byte ConnectionId)
        {
            wclWeDoIo Io = null;

            // Make sure device was attached.
            for (Int32 i = 0; i < FDevices.Count; i++)
            {
                if (FDevices[i].ConnectionId == ConnectionId)
                {
                    Io = FDevices[i];
                    break;
                }
            }

            if (Io != null)
            {
                Io.Detach();
                DoDeviceDetached(Io);
                FDevices.Remove(Io);
            }
        }