public MainForm(string[] args) { // // Required for Windows Form Designer support // InitializeComponent(); foreach (string parm in args) { if (parm.ToUpper().StartsWith("/CACHE:")) { DText p = new DText(); p.ATTRMARK = ":"; p[0] = parm; try { CacheTime = int.Parse(p[2]); } catch (Exception) { } } else if (parm.ToUpper() == "/DEBUG") { OpenSource.Utilities.EventLogger.Enabled = true; OpenSource.Utilities.EventLogger.ShowAll = true; OpenSource.Utilities.InstanceTracker.Display(); } else if (parm.ToUpper().StartsWith("/PORT:")) { DText p = new DText(); p.ATTRMARK = ":"; p[0] = parm; try { PortNum = int.Parse(p[2]); } catch (Exception) { } } } upnpLightDevice = UPnPDevice.CreateRootDevice(CacheTime, 1, "web\\"); upnpLightDevice.Icon = iconImageList.Images[0]; upnpLightDevice.HasPresentation = true; upnpLightDevice.PresentationURL = "/"; upnpLightDevice.FriendlyName = this.Text + " (" + System.Windows.Forms.SystemInformation.ComputerName + ")"; upnpLightDevice.Manufacturer = "OpenSource"; upnpLightDevice.ManufacturerURL = "http://opentools.homeip.net"; upnpLightDevice.ModelName = "Network Light Bulb"; upnpLightDevice.ModelDescription = "Software Emulated Light Bulb"; upnpLightDevice.ModelURL = new Uri("http://opentools.homeip.net"); upnpLightDevice.ModelNumber = "XPC-L1"; upnpLightDevice.StandardDeviceType = "DimmableLight"; upnpLightDevice.UniqueDeviceName = System.Guid.NewGuid().ToString(); // Switch Power upnpLightService = new UPnPService(1, "SwitchPower.0001", "SwitchPower", true, this); upnpLightService.AddMethod("SetTarget"); upnpLightService.AddMethod("GetTarget"); upnpLightService.AddMethod("GetStatus"); UPnPStateVariable upnpStatusVar = new UPnPStateVariable("Status", typeof(bool), true); upnpStatusVar.AddAssociation("GetStatus", "ResultStatus"); upnpStatusVar.Value = false; upnpLightService.AddStateVariable(upnpStatusVar); UPnPStateVariable upnpTargetVar = new UPnPStateVariable("Target", typeof(bool), false); upnpTargetVar.AddAssociation("SetTarget", "newTargetValue"); upnpTargetVar.AddAssociation("GetTarget", "newTargetValue"); upnpTargetVar.Value = false; upnpLightService.AddStateVariable(upnpTargetVar); // Dimmable device upnpDimmerService = new UPnPService(1, "Dimming.0001", "Dimming", true, this); upnpDimmerService.AddMethod("SetLoadLevelTarget"); upnpDimmerService.AddMethod("GetLoadLevelTarget"); upnpDimmerService.AddMethod("GetLoadLevelStatus"); upnpDimmerService.AddMethod("GetMinLevel"); UPnPStateVariable upnpLevelTargetVar = new UPnPStateVariable("LoadLevelTarget", typeof(byte), false); upnpLevelTargetVar.AddAssociation("SetLoadLevelTarget", "NewLoadLevelTarget"); upnpLevelTargetVar.AddAssociation("GetLoadLevelTarget", "NewLoadLevelTarget"); upnpLevelTargetVar.Value = (byte)100; upnpLevelTargetVar.SetRange((byte)0, (byte)100, null); upnpDimmerService.AddStateVariable(upnpLevelTargetVar); UPnPStateVariable upnpLevelStatusVar = new UPnPStateVariable("LoadLevelStatus", typeof(byte), true); upnpLevelStatusVar.AddAssociation("GetLoadLevelStatus", "RetLoadLevelStatus"); upnpLevelStatusVar.Value = (byte)100; upnpLevelStatusVar.SetRange((byte)0, (byte)100, null); upnpDimmerService.AddStateVariable(upnpLevelStatusVar); UPnPStateVariable upnpMinLevelVar = new UPnPStateVariable("MinLevel", typeof(byte), false); upnpMinLevelVar.AddAssociation("GetMinLevel", "MinLevel"); upnpMinLevelVar.Value = (byte)0; upnpDimmerService.AddStateVariable(upnpMinLevelVar); // Add Services upnpLightDevice.AddService(upnpLightService); upnpLightDevice.AddService(upnpDimmerService); }