Пример #1
0
        public static CpDeviceVolkano Create(CpDevice aDevice, DeviceVolkanoHandler aHandler)
        {
            string value;

            if (aDevice.GetAttribute("Upnp.Service.av-openhome-org.Product", out value))
            {
                return(new CpDeviceMain(aDevice, aHandler));
            }

            return(new CpDeviceFallback(aDevice, aHandler));
        }
Пример #2
0
 public CpDeviceFallback(CpDevice aDevice, DeviceVolkanoHandler aHandler)
     : base(aDevice, aHandler)
 {
     try
     {
         OnSubscribed();
     }
     catch
     {
         aDevice.RemoveRef();
     }
 }
Пример #3
0
        public CpDeviceMain(CpDevice aDevice, DeviceVolkanoHandler aHandler)
            : base(aDevice, aHandler)
        {
            try
            {
                iLock = new object();

                iProductService = new CpProxyAvOpenhomeOrgProduct1(aDevice);
                iProductService.SetPropertyInitialEvent(InitialEvent);
                iProductService.SetPropertyProductRoomChanged(ProductRoomChanged);
                iProductService.SetPropertyProductNameChanged(ProductNameChanged);
                iProductService.SetPropertyProductImageUriChanged(ProductImageUriChanged);
                iProductService.Subscribe();
            }
            catch
            {
                aDevice.RemoveRef();
            }
        }
Пример #4
0
        public CpDeviceVolkano(CpDevice aDevice, DeviceVolkanoHandler aHandler)
        {
            try
            {
                iHandler = aHandler;
                iDevice  = aDevice;
                iDevice.AddRef();

                iLock = new object();

                iVolkanoService = new CpProxyLinnCoUkVolkano1(iDevice);

                iModel = "Unknown";

                string xml;
                if (iDevice.GetAttribute("Upnp.DeviceXml", out xml))
                {
                    XmlNameTable        table   = new NameTable();
                    XmlNamespaceManager manager = new XmlNamespaceManager(table);
                    manager.AddNamespace("ns", "urn:schemas-upnp-org:device-1-0");

                    XmlDocument doc = new XmlDocument(manager.NameTable);
                    doc.LoadXml(xml);

                    XmlNode node = doc.SelectSingleNode("/ns:root/ns:device/ns:modelName", manager);
                    if (node != null && node.FirstChild != null)
                    {
                        iModel = node.FirstChild.InnerText;
                        if (iModel.StartsWith("Reprogram-"))
                        {
                            string[] split = iModel.Split(new char[] { '-' }, 2);
                            if (split.Length == 2)
                            {
                                iModel = split[1];
                            }
                        }
                    }
                }

                iVolkanoService.SyncMacAddress(out iMacAddress);
                iVolkanoService.SyncSoftwareVersion(out iSoftwareVersion);
                iVolkanoService.SyncProductId(out iProductNumber);

                iPcbNumberList = new List <string>();

                uint count;
                iVolkanoService.SyncMaxBoards(out count);

                for (uint i = 0; i < count; ++i)
                {
                    string number;
                    iVolkanoService.SyncBoardType(i, out number);
                    iPcbNumberList.Add(Convert.ToUInt32(number.Substring(0, 8), 16).ToString());
                }
            }
            catch
            {
                aDevice.RemoveRef();
                throw;
            }
        }