Exemplo n.º 1
0
        private void Removed(CpDeviceReprogramList aList, CpDeviceReprogrammable aDevice)
        {
            CpDeviceFacDef device = null;

            lock (iLock)
            {
                if (iDisposed)
                {
                    return;
                }

                foreach (CpDeviceFacDef d in iDeviceFacDefList)
                {
                    if (d.MacAddress == aDevice.MacAddress)
                    {
                        UserLog.WriteLine(DateTime.Now + ": CpDeviceUpdateList: DeviceUpdateable-             MacAddress{" + aDevice.MacAddress + "}");

                        device = d;
                        iDeviceFacDefList.Remove(d);
                        break;
                    }
                }
            }

            if (device != null)
            {
                if (iRemoved != null)
                {
                    iRemoved(this, device);
                }

                device.Dispose();
            }
        }
Exemplo n.º 2
0
        private void Added(CpDeviceReprogramList aList, CpDeviceReprogrammable aDevice)
        {
            CpDeviceFacDef device = null;

            lock (iLock)
            {
                if (iDisposed)
                {
                    return;
                }

                UserLog.WriteLine(DateTime.Now + ": CpDeviceUpdateList: DeviceUpdateable+             MacAddress{" + aDevice.MacAddress + "}");

                device = new CpDeviceFacDef(aDevice, iAdapterAddress, iUpdateListener);
                iDeviceFacDefList.Add(device);

                aDevice.Changed += HandleChanged;
            }

            if (device != null)
            {
                if (iAdded != null)
                {
                    iAdded(this, device);
                }
            }
        }
Exemplo n.º 3
0
        private void HandleChanged(object sender, EventArgs e)
        {
            CpDeviceReprogrammable device        = sender as CpDeviceReprogrammable;
            CpDeviceFacDef         removedDevice = null;
            CpDeviceFacDef         addedDevice   = null;

            lock (iLock)
            {
                foreach (CpDeviceFacDef d in iDeviceFacDefList)
                {
                    if (d.MacAddress == device.MacAddress)
                    {
                        if (d.Status == CpDeviceReprogrammable.EStatus.eOff && !d.Updating)
                        {
                            UserLog.WriteLine(DateTime.Now + ": CpDeviceUpdateList: DeviceUpdateable-             MacAddress{" + device.MacAddress + "}");

                            removedDevice = d;
                            iDeviceFacDefList.Remove(removedDevice);
                            break;
                        }
                        else
                        {
                            return;
                        }
                    }
                }

                if (removedDevice == null && device.Status != CpDeviceReprogrammable.EStatus.eOff)
                {
                    UserLog.WriteLine(DateTime.Now + ": CpDeviceUpdateList: DeviceUpdateable+             MacAddress{" + device.MacAddress + "}");

                    addedDevice = new CpDeviceFacDef(device, iAdapterAddress, iUpdateListener);
                    iDeviceFacDefList.Add(addedDevice);
                }
            }

            if (removedDevice != null)
            {
                if (iRemoved != null)
                {
                    iRemoved(this, removedDevice);
                }

                removedDevice.Dispose();
            }

            if (addedDevice != null)
            {
                if (iAdded != null)
                {
                    iAdded(this, addedDevice);
                }
            }
        }