Beispiel #1
0
        /// <summary>
        /// Adds a new set of virtual modules to the system.
        /// </summary>
        /// <returns>ProgramHelper.</returns>
        /// <param name="domain">Domain.</param>
        /// <param name="type">Type.</param>
        /// <param name="widget">Empty string or the path of the widget to be associated to the virtual module.</param>
        /// <param name="startAddress">Start address (numeric).</param>
        /// <param name="endAddress">End address (numeric).</param>
        public ProgramHelper AddVirtualModules(
            string domain,
            string type,
            string widget,
            int startAddress,
            int endAddress
        )
        {
            for (int x = startAddress; x <= endAddress; x++)
            {

                VirtualModule virtualModule = null;
                try
                {
                    virtualModule = homegenie.VirtualModules.Find(rm => rm.ParentId == myProgramId.ToString() && rm.Domain == domain && rm.Address == x.ToString());
                }
                catch
                {
                }
                //
                if (virtualModule == null)
                {
                    virtualModule = new VirtualModule() {
                        ParentId = myProgramId.ToString(),
                        Domain = domain,
                        Address = x.ToString(),
                        DeviceType = (MIG.ModuleTypes)Enum.Parse(
                            typeof(MIG.ModuleTypes),
                            type
                        )
                    };
                    virtualModule.Properties.Add(new ModuleParameter() {
                        Name = Properties.WidgetDisplayModule,
                        Value = widget
                    });
                    homegenie.VirtualModules.Add(virtualModule);
                }
                else
                {
                    virtualModule.Domain = domain;
                    if (virtualModule.DeviceType == MIG.ModuleTypes.Generic)
                        virtualModule.DeviceType = (MIG.ModuleTypes)Enum.Parse(typeof(MIG.ModuleTypes), type);
                    Utility.ModuleParameterSet(virtualModule, Properties.WidgetDisplayModule, widget);
                }
                // update real module device type and widget
                Module module = homegenie.Modules.Find(o => o.Domain == virtualModule.Domain && o.Address == virtualModule.Address);
                if (module != null)
                {
                    if (module.DeviceType == MIG.ModuleTypes.Generic)
                        module.DeviceType = virtualModule.DeviceType;
                    Utility.ModuleParameterSet(module, Properties.WidgetDisplayModule, widget);
                }

            }
            homegenie.modules_RefreshVirtualModules();
            homegenie.modules_Sort();
            return this;
        }
Beispiel #2
0
 /// <summary>
 /// Set the widget that will be used for displaying this program data in the UI Control page.
 /// </summary>
 /// <returns>ProgramHelper.</returns>
 /// <param name="widget">The widget path.</param>
 public ProgramHelper UseWidget(string widget)
 {
     var program = homegenie.ProgramManager.Programs.Find(p => p.Address == myProgramId);
     var module = homegenie.VirtualModules.Find(rm => rm.ParentId == myProgramId.ToString() && rm.Domain == myProgramDomain && rm.Address == myProgramId.ToString());
     //
     if (module == null)
     {
         module = new VirtualModule() {
             ParentId = myProgramId.ToString(),
             Domain = myProgramDomain,
             Address = myProgramId.ToString(),
             Name = (program != null ? program.Name : ""),
             DeviceType = MIG.ModuleTypes.Program
         };
         homegenie.VirtualModules.Add(module);
     }
     //
     module.Name = (program != null ? program.Name : "");
     module.Domain = myProgramDomain;
     Utility.ModuleParameterSet(module, Properties.WidgetDisplayModule, widget);
     //
     RelocateProgramModule();
     homegenie.modules_RefreshVirtualModules();
     homegenie.modules_Sort();
     //
     return this;
 }
Beispiel #3
0
 public ProgramHelper AddVirtualModule(string domain, string address, string type, string widget)
 {
     VirtualModule virtualModule = null;
     try { virtualModule = homegenie.VirtualModules.Find(rm => rm.ParentId == myProgramId.ToString() && rm.Address == address); }
     catch { }
     //
     if (virtualModule == null)
     {
         virtualModule = new VirtualModule() { ParentId = myProgramId.ToString(), Domain = domain, Address = address, DeviceType = (Module.DeviceTypes)Enum.Parse(typeof(Module.DeviceTypes), type) };
         virtualModule.Properties.Add(new ModuleParameter() { Name = Properties.WIDGET_DISPLAYMODULE, Value = widget });
         homegenie.VirtualModules.Add(virtualModule);
     }
     else
     {
         virtualModule.Domain = domain;
         virtualModule.DeviceType = (Module.DeviceTypes)Enum.Parse(typeof(Module.DeviceTypes), type);
         Utility.ModuleParameterSet(virtualModule, Properties.WIDGET_DISPLAYMODULE, widget);
     }
     // update real module device type and widget
     Module module = homegenie.Modules.Find(o => o.Domain == virtualModule.Domain && o.Address == virtualModule.Address);
     if (module != null)
     {
         module.DeviceType = virtualModule.DeviceType;
         Utility.ModuleParameterSet(module, Properties.WIDGET_DISPLAYMODULE, widget);
     }
     //
     homegenie.modules_RefreshVirtualModules();
     homegenie.modules_Sort();
     return this;
 }