示例#1
0
        private void HandleChanged(object sender, EventArgs e)
        {
            CpDeviceReprogrammable device        = sender as CpDeviceReprogrammable;
            CpDeviceUpdate         removedDevice = null;
            CpDeviceUpdate         addedDevice   = null;

            Firmware firmware = CheckForSoftwareUpdate(device);

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

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

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

                    addedDevice = new CpDeviceUpdate(device, firmware, iCache, iAdapterAddress, iUpdateListener);
                    iDeviceUpdateList.Add(addedDevice);
                }
            }

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

                removedDevice.Dispose();
            }

            if (addedDevice != null)
            {
                if (iAdded != null)
                {
                    iAdded(this, addedDevice);
                }
            }
        }
示例#2
0
        //private void Removed(CpDeviceReprogramList aList, CpDeviceReprogrammable aDevice)
        private void Removed(object sender, CpDeviceReprogramListRepeater.CpDeviceReprogrammableEventArgs e)
        {
            CpDeviceReprogrammable aDevice = e.Device;
            CpDeviceUpdate         device  = null;

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

                foreach (CpDeviceReprogrammable d in iPendingList)
                {
                    if (d.Udn == aDevice.Udn)
                    {
                        iPendingList.Remove(d);

                        aDevice.Changed -= HandleChanged;

                        break;
                    }
                }

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

                        device = d;

                        iDeviceUpdateList.Remove(d);

                        break;
                    }
                }
            }

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

                device.Dispose();
            }
        }