Пример #1
0
 private void PollInvoke()
 {
     iActionPollStop = new Semaphore(0, 1);
     System.Timers.Timer timer = new System.Timers.Timer();
     timer.Elapsed  += TimerElapsed;
     timer.AutoReset = false;
     for (int i = 0; i < iDeviceList.Count; i++)
     {
         CpDevice device      = iDeviceList[i];
         uint     countBefore = iActionCount;
         Console.Write("Device " + device.Udn());
         iConnMgr            = new CpProxyUpnpOrgConnectionManager1(device);
         iActionPollStopTime = DateTime.Now.AddMilliseconds(kDevicePollMs);
         timer.Interval      = kDevicePollMs;
         timer.Enabled       = false;
         timer.Enabled       = true;
         for (int j = 0; j < 4; j++)
         {
             iConnMgr.BeginGetProtocolInfo(GetProtocolInfoComplete);
         }
         iActionPollStop.WaitOne();
         Console.Write("    " + (iActionCount - countBefore) + "\n");
         iConnMgr.Dispose();
         iExpectedSink = null;
     }
 }
Пример #2
0
 private void PollSubscribe()
 {
     iSubscriptionSem = new Semaphore(0, 1);
     for (int i = 0; i < iDeviceList.Count; i++)
     {
         CpDevice device = iDeviceList[i];
         string   udn    = device.Udn();
         if (udn == "896659847466-a4badbeaacbc-737837" ||
             udn == "541d0cb5-3b34-4264-8ff0-d8653acf6425")
         {
             continue;
         }
         uint countBefore = iSubscriptionCount;
         Console.Write("Device " + device.Udn());
         CpProxyUpnpOrgConnectionManager1 connMgr = new CpProxyUpnpOrgConnectionManager1(device);
         connMgr.SetPropertyChanged(PropertyChanged);
         DateTime startTime = DateTime.Now;
         while (true)
         {
             connMgr.Subscribe();
             iSubscriptionSem.WaitOne((int)(2 * kDevicePollMs));
             connMgr.Unsubscribe();
             DateTime now = DateTime.Now;
             if (now.Subtract(startTime).TotalSeconds > kDevicePollSecs)
             {
                 break;
             }
             iSubscriptionCount++;
         }
         Console.Write("    " + (iSubscriptionCount - countBefore) + "\n");
         connMgr.Dispose();
     }
 }
Пример #3
0
 private void DeviceAdded(CpDeviceList aList, CpDevice aDevice)
 {
     lock (this)
     {
         PrintDeviceInfo("Added", aDevice);
         aDevice.AddRef();
         iDeviceList.Add(aDevice);
     }
 }
Пример #4
0
 private void DeviceAdded(CpDeviceList aList, CpDevice aDevice)
 {
     lock (this)
     {
         if (aDevice.Udn() == DeviceBasic.gDeviceName)
         {
             aDevice.AddRef();
             iDeviceList.Add(aDevice);
         }
     }
 }
Пример #5
0
        protected static void Removed(IntPtr aPtr, uint aHandle)
        {
            CpDevice     device = new CpDevice(aHandle);
            GCHandle     gch    = GCHandle.FromIntPtr(aPtr);
            CpDeviceList list   = (CpDeviceList)gch.Target;

            if (list.iRemoved != null)
            {
                list.iRemoved(list, device);
            }
        }
Пример #6
0
        private void PrintDeviceInfo(string aPrologue, CpDevice aDevice)
        {
            string location;

            aDevice.GetAttribute("Upnp.Location", out location);
            string friendlyName;

            aDevice.GetAttribute("Upnp.FriendlyName", out friendlyName);
            Console.Write(aPrologue +
                          "\n    udn = " + aDevice.Udn() +
                          "\n    location = " + location +
                          "\n    name = " + friendlyName + "\n");
        }
Пример #7
0
 private void DeviceRemoved(CpDeviceList aList, CpDevice aDevice)
 {
     lock (this)
     {
         string udn   = aDevice.Udn();
         int    count = iDeviceList.Count;
         for (int i = 0; i < count; i++)
         {
             if (iDeviceList[i].Udn() == udn)
             {
                 iDeviceList.RemoveAt(i);
                 iDeviceList[i].RemoveRef();
             }
         }
     }
 }
Пример #8
0
        private void InvokeSync()
        {
            // trivial validation of the sync wrappers to all APIs
            // single sync call to whichever device happens to be first in our list
            if (iDeviceList.Count == 0)
            {
                Console.Write("No devices found, so nothing to test\n");
                return;
            }
            CpDevice device = iDeviceList[0];

            Console.Write("\n\nSync call to device " + device.Udn() + "\n");
            CpProxyUpnpOrgConnectionManager1 connMgr = new CpProxyUpnpOrgConnectionManager1(device);
            string source;
            string sink;

            connMgr.SyncGetProtocolInfo(out source, out sink);
            Console.Write("source is " + source + "\nsink is " + sink + "\n");
            connMgr.Dispose();
        }
Пример #9
0
 public CpProxyLinnCoUkDebug2(CpDevice aDevice)
 {
     iHandle = CpProxyLinnCoUkDebug2Create(aDevice.Handle());
     iGch    = GCHandle.Alloc(this);
 }
Пример #10
0
 public CpProxyLinnCoUkConfiguration1(CpDevice aDevice)
 {
     iHandle = CpProxyLinnCoUkConfiguration1Create(aDevice.Handle());
     iGch    = GCHandle.Alloc(this);
 }
Пример #11
0
 public CpProxyLinnCoUkVolkano1(CpDevice aDevice)
 {
     iHandle = CpProxyLinnCoUkVolkano1Create(aDevice.Handle());
     iGch    = GCHandle.Alloc(this);
 }
Пример #12
0
 public CpProxyLinnCoUkComponent1(CpDevice aDevice)
 {
     iHandle = CpProxyLinnCoUkComponent1Create(aDevice.Handle());
     iGch    = GCHandle.Alloc(this);
 }
Пример #13
0
 public CpProxyUpnpOrgDimming1(CpDevice aDevice)
 {
     iHandle = CpProxyUpnpOrgDimming1Create(aDevice.Handle());
     iGch    = GCHandle.Alloc(this);
 }
Пример #14
0
 public CpProxyLinnCoUkDiagnostics1(CpDevice aDevice)
 {
     iHandle = CpProxyLinnCoUkDiagnostics1Create(aDevice.Handle());
     iGch    = GCHandle.Alloc(this);
 }
Пример #15
0
 public CpProxyUpnpOrgContentDirectory2(CpDevice aDevice)
 {
     iHandle = CpProxyUpnpOrgContentDirectory2Create(aDevice.Handle());
     iGch    = GCHandle.Alloc(this);
 }
 public CpProxyUpnpOrgConnectionManager1(CpDevice aDevice)
 {
     iHandle = CpProxyUpnpOrgConnectionManager1Create(aDevice.Handle());
     iGch    = GCHandle.Alloc(this);
 }
Пример #17
0
 public CpProxyZappOrgTestDimmableLight1(CpDevice aDevice)
 {
     iHandle = CpProxyZappOrgTestDimmableLight1Create(aDevice.Handle());
     iGch    = GCHandle.Alloc(this);
 }
 public CpProxyUpnpOrgScheduledRecording1(CpDevice aDevice)
 {
     iHandle = CpProxyUpnpOrgScheduledRecording1Create(aDevice.Handle());
     iGch    = GCHandle.Alloc(this);
 }
Пример #19
0
 public CpProxyLinnCoUkMediaTime1(CpDevice aDevice)
 {
     iHandle = CpProxyLinnCoUkMediaTime1Create(aDevice.Handle());
     iGch    = GCHandle.Alloc(this);
 }
Пример #20
0
 public CpProxyUpnpOrgSwitchPower1(CpDevice aDevice)
 {
     iHandle = CpProxyUpnpOrgSwitchPower1Create(aDevice.Handle());
     iGch    = GCHandle.Alloc(this);
 }
Пример #21
0
 public CpProxyZappOrgTestBasic1(CpDevice aDevice)
 {
     iHandle = CpProxyZappOrgTestBasic1Create(aDevice.Handle());
     iGch    = GCHandle.Alloc(this);
 }
Пример #22
0
 public CpProxyLinnCoUkPreamp4(CpDevice aDevice)
 {
     iHandle = CpProxyLinnCoUkPreamp4Create(aDevice.Handle());
     iGch    = GCHandle.Alloc(this);
 }
Пример #23
0
 public CpProxyUpnpOrgAVTransport1(CpDevice aDevice)
 {
     iHandle = CpProxyUpnpOrgAVTransport1Create(aDevice.Handle());
     iGch    = GCHandle.Alloc(this);
 }