예제 #1
0
        public static void Main(string[] args)
        {
            InitParams initParams = new InitParams
            {
                MsearchTimeSecs           = 1,
                UseLoopbackNetworkAdapter = true
            };

            using (Library lib = Library.Create(initParams))
            {
                SubnetList     subnetList = new SubnetList();
                NetworkAdapter nif        = subnetList.SubnetAt(0);
                uint           subnet     = nif.Subnet();
                subnetList.Dispose();
                lib.StartCombined(subnet);

                Console.Write("TestCpDeviceDvCs - starting\n");
                DeviceBasic device   = new DeviceBasic();
                CpDeviceDv  cpDevice = new CpDeviceDv(device.Device());
                TestBasicCp cp       = new TestBasicCp(cpDevice);
                cp.TestActions();
                cp.TestSubscriptions();
                cpDevice.RemoveRef();
                device.Dispose();
                Console.Write("TestCpDeviceDvCs - completed\n");
            }
        }
예제 #2
0
파일: Model.cs 프로젝트: daviddw/oss-public
        public AdapterList(uint aSubnet)
        {
            using(SubnetList subnets = new SubnetList())
            {
                bool found = false;

                uint count = subnets.Size();

                iSubnets = new List<uint>();
                iAdapters = new List<string>();

                for(uint i = 0; i < count; ++i)
                {
                    NetworkAdapter adapter = subnets.SubnetAt(i);

                    iSubnets.Add(adapter.Subnet());
                    iAdapters.Add(adapter.Name());

                    if(!found)
                    {
                        if(adapter.Subnet() == aSubnet)
                        {
                            found = true;
                            iCurrent = i;
                            iAdapter = adapter;
                            iAdapter.AddRef("Konfig-Adapter-List");
                        }
                    }
                }

                if(!found)
                {
                    if(aSubnet == 0 || !found)
                    {
                        // uninitialised or not found

                        if(count > 0)
                        {
                            iCurrent = 0;
                            iAdapter = subnets.SubnetAt(0);
                            iAdapter.AddRef("Konfig-Adapter-List");
                        }
                    }

                    if (aSubnet != 0)
                    {
                        iSubnets.Add(aSubnet);
                        iAdapters.Add("Network not present");
                    }
                }
            }
        }
예제 #3
0
        public Runner()
        {
            iInitParams = new InitParams();
            iInitParams.DvUpnpWebServerPort           = 0;
            iInitParams.LogOutput                     = new MessageListener(Log);
            iInitParams.SubnetListChangedListener     = new ChangedListener(SubnetListChanged);
            iInitParams.SubnetAddedListener           = new NetworkAdapterListener(SubnetAdded);
            iInitParams.SubnetRemovedListener         = new NetworkAdapterListener(SubnetRemoved);
            iInitParams.NetworkAdapterChangedListener = new NetworkAdapterListener(NetworkAdapterChanged);
            iLibrary = Library.Create(iInitParams);
            Library.SetDebugLevel(Library.DebugLevel.Trace);
            SubnetList     subnetList = new SubnetList();
            NetworkAdapter nif        = subnetList.SubnetAt(0);
            uint           subnet     = nif.Subnet();

            subnetList.Dispose();
            iLibrary.StartCombined(subnet);
        }
예제 #4
0
        public static void Main(string[] args)
        {
            InitParams initParams = new InitParams
            {
                MsearchTimeSecs           = 1,
                UseLoopbackNetworkAdapter = true,
                DvUpnpWebServerPort       = 0
            };

            using (Library lib = Library.Create(initParams))
            {
                SubnetList     subnetList = new SubnetList();
                NetworkAdapter nif        = subnetList.SubnetAt(0);
                uint           subnet     = nif.Subnet();
                subnetList.Dispose();
                lib.StartCombined(subnet);
                new Runner();
            }
        }
예제 #5
0
        public WindowMain()
        {
            InitializeComponent();
            bool instantiated;

            iInstanceMutex = new Mutex(false, "ViewerMutex", out instantiated);
            if (!instantiated)
            {
                MessageBox.Show("Another instance of Viewer is already running. Please close all other instances and try again.", "Viewer is already running", MessageBoxButton.OK, MessageBoxImage.Warning);
                Application.Current.Shutdown();
            }

            iDebugLevels = new SortedList <string, DebugLevelItem>();
            UInt32 debugLevel;

            iDebugLevels.Add("Store", new DebugLevelItem("Store", debugLevel            = 1));
            iDebugLevels.Add("Flash", new DebugLevelItem("Flash", debugLevel           *= 2));
            iDebugLevels.Add("Common", new DebugLevelItem("Common", debugLevel         *= 2));
            iDebugLevels.Add("Boot", new DebugLevelItem("Boot", debugLevel             *= 2));
            iDebugLevels.Add("Thread", new DebugLevelItem("Thread", debugLevel         *= 2));
            iDebugLevels.Add("Bsp", new DebugLevelItem("Bsp", debugLevel               *= 2));
            iDebugLevels.Add("Network", new DebugLevelItem("Network", debugLevel       *= 2));
            iDebugLevels.Add("Event", new DebugLevelItem("Event", debugLevel           *= 2));
            iDebugLevels.Add("SysLib", new DebugLevelItem("SysLib", debugLevel         *= 2));
            iDebugLevels.Add("UpnpDevice", new DebugLevelItem("UpnpDevice", debugLevel *= 2));
            iDebugLevels.Add("Sdp", new DebugLevelItem("Sdp", debugLevel               *= 2));
            iDebugLevels.Add("Ess", new DebugLevelItem("Ess", debugLevel               *= 2));
            iDebugLevels.Add("Power", new DebugLevelItem("Power", debugLevel           *= 2));
            iDebugLevels.Add("Http", new DebugLevelItem("Http", debugLevel             *= 2));
            iDebugLevels.Add("Upnp", new DebugLevelItem("Upnp", debugLevel             *= 2));
            iDebugLevels.Add("Preamp", new DebugLevelItem("Preamp", debugLevel         *= 2));
            iDebugLevels.Add("Logical", new DebugLevelItem("Logical", debugLevel       *= 2));
            iDebugLevels.Add("Viewer", new DebugLevelItem("Viewer", debugLevel         *= 2));
            iDebugLevels.Add("Ui", new DebugLevelItem("Ui", debugLevel               *= 2));
            iDebugLevels.Add("Isr", new DebugLevelItem("Isr", debugLevel             *= 2));
            iDebugLevels.Add("Core", new DebugLevelItem("Core", debugLevel           *= 2));
            iDebugLevels.Add("Media", new DebugLevelItem("Media", debugLevel         *= 2));
            iDebugLevels.Add("Dac", new DebugLevelItem("Dac", debugLevel             *= 2));
            iDebugLevels.Add("Products", new DebugLevelItem("Products", debugLevel   *= 2));
            iDebugLevels.Add("Mechanism", new DebugLevelItem("Mechanism", debugLevel *= 2));
            iDebugLevels.Add("Bonjour", new DebugLevelItem("Bonjour", debugLevel     *= 2));
            iDebugLevels.Add("Ssdp", new DebugLevelItem("Ssdp", debugLevel           *= 2));
            iDebugLevels.Add("Queue", new DebugLevelItem("Queue", debugLevel         *= 2));
            iDebugLevels.Add("Codec", new DebugLevelItem("Codec", debugLevel         *= 4)); //skipping deprecated option here.
            iDebugLevels.Add("Control", new DebugLevelItem("Control", debugLevel     *= 2));
            iDebugLevels.Add("Verbose", new DebugLevelItem("Verbose", debugLevel     *= 2));
            foreach (DebugLevelItem i in iDebugLevels.Values)
            {
                i.PropertyChanged += EventDebugLevelChanged;
            }
            listBoxDebugLevel.ItemsSource = iDebugLevels.Values;
            DisableDebugLevels();
            this.DataContext = this;

            iInitParams = new InitParams();
            iLibrary    = new Library();
            iLibrary.Initialise(ref iInitParams);
            iLibrary.StartCp();
            iSubnetList = new SubnetList(iInitParams, Dispatcher, iLibrary);
            iDeviceList = new DeviceListUpnp("linn.co.uk", "Volkano", 1, this.Dispatcher);

            comboBoxSubnets.ItemsSource       = iSubnetList;
            comboBoxSubnets.SelectionChanged += EventSubnetSelectionChanged;

            iActivityLightTimer.Interval  = iActivityLightTimerTimeout;
            iActivityLightTimer.Elapsed  += EventActivityLightTimerExpired;
            iActivityLightTimer.AutoReset = false;

            iDelayMutexReleaseTimer.Interval  = iDelayMutexReleaseTimerTimeout;
            iDelayMutexReleaseTimer.Elapsed  += EventDelayMutexReleaseTimerExpired;
            iDelayMutexReleaseTimer.AutoReset = false;

            iRetryConnectTimer.Interval  = iRetryConnectTimerTimeout;
            iRetryConnectTimer.Elapsed  += EventRetryConnectTimerExpired;
            iRetryConnectTimer.AutoReset = true;

            MainWindow.Closing += new CancelEventHandler(this.EventWindowMainClosing);

            iViewerManager = new ViewerManager();
            iViewerManager.ViewerOutputAvailable += EventViewerOutputAvailable;
            iViewerManager.ConnectionAccepted    += EventConnectionAccepted;
            iViewerManager.ConnectionClosed      += EventConnectionClosed;
            iViewerManager.ConnectionRefused     += EventConnectionRefused;
            iViewerManager.ServicesAvailable     += EventServicesAvailable;
            iViewerManager.ServicesUnavailable   += EventServicesUnavailable;

            terminal.MaxVisibleLinesCountChanged += EventMaxVisibleLinesCountChanged;

            if (!Directory.Exists(iAppDataDir))
            {
                Directory.CreateDirectory(iAppDataDir);
            }

            iMainLogFile     = iAppDataDir + "\\Viewer-log.txt";
            iMainLogFileCopy = iAppDataDir + "\\Viewer-log-copy.txt";
            iTempLogFile     = iAppDataDir + "\\Viewer-log-Temp.txt";
            iSettingsFile    = iAppDataDir + "\\Viewer-Settings.txt";

            //Wipe the log file clean.
            if (!File.Exists(iMainLogFile))
            {
                iLogFileMutex.WaitOne();
                File.WriteAllText(iMainLogFile, "", new System.Text.UTF8Encoding());
                iLogFileMutex.ReleaseMutex();
            }

            if (File.Exists(iSettingsFile))
            {
                try
                {
                    iUserSettings = UserSettings.ReadSettingsFromFile(iSettingsFile);
                }
                catch (InvalidOperationException)
                {
                    iUserSettings = new UserSettings();
                    AppendToMainWindow("Settings file is corrupt, deleting...");
                    File.WriteAllText(iSettingsFile, "", new System.Text.UTF8Encoding());
                }
                catch (FileFormatException)
                {
                    iUserSettings = new UserSettings();
                    AppendToMainWindow("Settings file is corrupt, deleting...");
                    File.WriteAllText(iSettingsFile, "", new System.Text.UTF8Encoding());
                }
            }
            else
            {
                iUserSettings = new UserSettings();
            }
            if (iUserSettings.SelectedSubnet >= iSubnetList.length)
            {
                iUserSettings.SelectedSubnet = iSubnetList.length - 1;
            }
            comboBoxSubnets.SelectedIndex = iUserSettings.SelectedSubnet;
            iLibrary.SetCurrentSubnet(((Subnet)comboBoxSubnets.SelectedItem).Handle);
            if (!iUserSettings.UglyName.Equals(""))
            {
                selectDeviceButton.Content = iUserSettings.UglyName;
            }
            Connect(iUserSettings.UglyName);
        }
예제 #6
0
        public static void Main(string[] aArgs)
        {
            Console.WriteLine("TestPerformanceCpCs - starting");
            InitParams initParams = new InitParams();

            using (Library lib = Library.Create(initParams))
            {
                SubnetList     subnetList = new SubnetList();
                NetworkAdapter nif        = subnetList.SubnetAt(0);
                uint           subnet     = nif.Subnet();
                subnetList.Dispose();
                var       deviceListFactory = new CpUpnpDeviceListFactory(lib.StartCp(subnet));
                CpDevice  device            = null;
                Semaphore sem        = new Semaphore(0, 1);
                var       deviceList = deviceListFactory.CreateListServiceType("openhome.org", "TestBasic", 1,
                                                                               (aDeviceList, aDevice) =>
                {
                    if (device != null)
                    {
                        throw new Exception("Found more than one device.  Giving up as test results will probably be invalid.");
                    }
                    device = aDevice;
                    device.AddRef();
                    sem.Release();
                },
                                                                               (aDeviceList, aDevice) =>
                {
                    throw new Exception("ERROR: Device removed while test is running.");
                });
                sem.WaitOne();

                // actions
                Console.WriteLine("");
                int[] threadCounts = { 1, 2, 4 };
                foreach (int threadCount in threadCounts)
                {
                    List <Thread> threads = new List <Thread>();
                    for (int i = 0; i < threadCount; i++)
                    {
                        threads.Add(new Thread(ActionThread));
                    }
                    ThreadArgs threadArgs = new ThreadArgs(device, kTestDurationMs);
                    for (int i = 0; i < threadCount; i++)
                    {
                        threads[i].Start(threadArgs);
                    }
                    for (int i = 0; i < threadCount; i++)
                    {
                        threads[i].Join();
                    }
                    Console.WriteLine("Invoked {0} actions in {1}ms using {2} threads", threadArgs.Count, kTestDurationMs, threadCount);
                }

                // subscriptions
                Thread     thread = new Thread(SubscriptionThread);
                ThreadArgs args   = new ThreadArgs(device, kTestDurationMs);
                thread.Start(args);
                thread.Join();
                Console.WriteLine("\nCompleted {0} subscriptions in {1}ms\n", args.Count, kTestDurationMs);

                device.RemoveRef();
                deviceList.Dispose();
                Console.WriteLine("\nTests complete.  Press 'q' to exit.");
                while (Console.ReadKey(true).KeyChar != 'q')
                {
                    ;
                }
            }
        }