public DeviceCategoryViewModel(IEnumerable <DeviceInfo> childDevices, DeviceCategory deviceCategory)
     : this(childDevices)
 {
     DeviceCategory = deviceCategory;
     Caption        = DeviceCategoryToString(deviceCategory);
     Icon           = GetDeviceCategoryIcon(deviceCategory);
 }
        public void DeviceCategoryPickerTestRealDevices()
        {
            Random               r   = new Random(5);
            DeviceSelection      ds  = new DeviceSelection("ds", 1, string.Empty, string.Empty, Guid.NewGuid().ToStrGuid());
            DeviceCategoryPicker dcp = new DeviceCategoryPicker(r, ds);
            ObservableCollection <RealDevice> allDevices = new ObservableCollection <RealDevice>();
            DeviceCategory dc = new DeviceCategory("dc", -1, "bla", false, allDevices, Guid.NewGuid().ToStrGuid());
            RealDevice     rd = new RealDevice("bla", 0, string.Empty, dc, "desc", false, true, string.Empty, Guid.NewGuid().ToStrGuid(), -1);

            allDevices.Add(rd);
            Location loc = new Location("bla", -1, string.Empty, Guid.NewGuid().ToStrGuid());
            List <IAssignableDevice> devices = new List <IAssignableDevice>
            {
                rd
            };
            ObservableCollection <DeviceAction> deviceActions = new ObservableCollection <DeviceAction>();

            Logger.Info("put in a rd, get back the same rd");
            RealDevice result = dcp.GetOrPickDevice(rd, loc, EnergyIntensityType.EnergyIntensive, devices, deviceActions);

            rd.Should().Be(result);
            // put in an dc with one rd, get the rd 1
            Logger.Info("put in a rd, get back null, since the rd is already there as hhdevloc");
            RealDevice result2 = dcp.GetOrPickDevice(dc, loc, EnergyIntensityType.EnergyIntensive, devices,
                                                     deviceActions);

            result2.Should().BeNull();
        }
 public void DeleteDeviceCategory(DeviceCategory entity)
 {
     if (entity != null)
     {
         repository.Delete(entity);
     }
 }
        public async Task <IEnumerable <DeviceCategory> > ListAllCategoriesAsync()
        {
            List <DeviceCategory> categories = new List <DeviceCategory>();

            try
            {
                var token = ADALAuthentication.Instance.AuthResult.AccessToken;
                graphClient = new HttpClient();
                graphClient.DefaultRequestHeaders.Add("Authorization", token);

                var result = await graphClient.GetStringAsync("https://graph.microsoft.com/v1.0/deviceManagement/deviceCategories");

                JToken jtokenResult = JsonConvert.DeserializeObject <JToken>(result);
                JArray JsonValues   = jtokenResult["value"] as JArray;

                // Add the "Unassigned" category
                categories.Add(new DeviceCategory()
                {
                    Id = Guid.Empty.ToString(), DisplayName = "Unassigned"
                });
                foreach (var item in JsonValues)
                {
                    DeviceCategory cat = new DeviceCategory();
                    cat.DisplayName = item["displayName"].Value <string>();
                    cat.Id          = item["id"].Value <string>();
                    categories.Add(cat);
                }
            }
            catch { }
            return(categories);
        }
 public DeviceCategoryPickerPresenter([NotNull] Simulator sim, [CanBeNull] DeviceCategory selectedItem,
                                      [NotNull] DeviceCategoryPicker deviceCategoryPicker)
 {
     _sim                  = sim;
     _selectedItem         = selectedItem;
     _deviceCategoryPicker = deviceCategoryPicker;
 }
        //public DeviceCategory GetByStdId(int? id)
        //{
        //    var student = repository.GetByStdId(id);
        //    return student;
        //}

        public void InsertDeviceCategory(DeviceCategory entity)
        {
            if (entity != null)
            {
                repository.Insert(entity);
            }
        }
        // To protect from overposting attacks, enable the specific properties you want to bind to, for
        // more details, see https://aka.ms/RazorPagesCRUD.
        public async Task <IActionResult> OnPostAsync(string[] selectedCategories)
        {
            var newDevice = new Device();

            if (selectedCategories != null)
            {
                newDevice.DeviceCategories = new List <DeviceCategory>();
                foreach (var cat in selectedCategories)
                {
                    var catToAdd = new DeviceCategory
                    {
                        CategoryID = int.Parse(cat)
                    };
                    newDevice.DeviceCategories.Add(catToAdd);
                }
            }
            if (await TryUpdateModelAsync <Device>(newDevice, "Device",
                                                   i => i.Name, i => i.Manufacturer,
                                                   i => i.Price, i => i.ReleaseDate, i => i.SellerID))
            {
                _context.Device.Add(newDevice);
                await _context.SaveChangesAsync();

                return(RedirectToPage("./Index"));
            }
            PopulateAssignedCategoryData(_context, newDevice);
            return(Page());
        }
Exemplo n.º 8
0
        public void GetCalcManagerModularHousehold03Test()
        {
            using (var wd = new WorkingDir(Utili.GetCurrentMethodAndClass()))
            {
                using (var db = new DatabaseSetup(Utili.GetCurrentMethodAndClass()))
                {
                    Config.IsInUnitTesting = true;
                    var sim = new Simulator(db.ConnectionString);
                    sim.MyGeneralConfig.ApplyOptionDefault(OutputFileDefault.ReasonableWithChartsAndPDF);
                    DeviceCategory light = null;
                    foreach (var deviceCategory in sim.DeviceCategories.MyItems)
                    {
                        deviceCategory.RefreshSubDevices();
                        if (deviceCategory.Name.Contains("Light"))
                        {
                            light = deviceCategory;
                        }
                    }
                    if (light != null)
                    {
                        Logger.Info(light.SubDevices.Count.ToString(CultureInfo.CurrentCulture));
                    }
                    sim.MyGeneralConfig.ApplyOptionDefault(OutputFileDefault.NoFiles);
                    sim.MyGeneralConfig.Enable(CalcOption.TotalsPerLoadtype);
                    sim.MyGeneralConfig.Enable(CalcOption.TotalsPerDevice);
                    sim.MyGeneralConfig.Enable(CalcOption.MakePDF);
                    sim.MyGeneralConfig.Enable(CalcOption.HouseholdContents);
                    sim.Should().NotBeNull();
                    var cmf = new CalcManagerFactory();
                    ModularHousehold chs3 = null;
                    foreach (var modularHousehold in sim.ModularHouseholds.MyItems)
                    {
                        if (modularHousehold.Name.StartsWith("CHS01", StringComparison.Ordinal))
                        {
                            chs3 = modularHousehold;
                        }
                    }
                    if (chs3 == null)
                    {
                        throw new LPGException("Could not find the household CHS01");
                    }
                    Logger.Info(chs3.ToString());
                    CalculationProfiler   calculationProfiler = new CalculationProfiler();
                    CalcStartParameterSet csps = new CalcStartParameterSet(sim.GeographicLocations[0],
                                                                           sim.TemperatureProfiles[0], chs3, EnergyIntensityType.Random, false,
                                                                           null, LoadTypePriority.Mandatory, null, null, null, sim.MyGeneralConfig.AllEnabledOptions(),
                                                                           new DateTime(2015, 1, 15), new DateTime(2015, 1, 18), new TimeSpan(0, 1, 0), ";", -1, new TimeSpan(0, 1, 0), false, false, false, 3, 3,
                                                                           calculationProfiler, wd.WorkingDirectory, false);

                    var cm = cmf.GetCalcManager(sim, csps, false);

                    cm.Run(ReportCancelFunc);
                    cm.Dispose();
                    db.Cleanup();
                }
                wd.CleanUp();
            }
        }
        public IActionResult PutDeviceCategory([FromRoute] Guid guid, [FromBody] DeviceCategory deviceCategory)
        {
            if (guid != deviceCategory.DeviceCategoryId)
            {
                return(BadRequest());
            }

            return(Ok(deviceCategoryService.Upsert(deviceCategory, User)));
        }
Exemplo n.º 10
0
        private static string DeviceCategoryToString(DeviceCategory deviceCategory)
        {
            if (Tx.TryGetText($"DeviceManager:Categories.{deviceCategory}", out var text))
            {
                return(text);
            }

            return(deviceCategory.ToString());
        }
Exemplo n.º 11
0
        public DeviceCategory CreateTestDeviceCategory()
        {
            var newDeviceCategory = new DeviceCategory {
                DeviceCategoryName = TestDeviceCategoryName
            };

            DeviceCategoryService.Insert(newDeviceCategory);
            newDeviceCategory = DeviceCategoryService.Search(TestDeviceCategoryName).First();
            return(newDeviceCategory);
        }
Exemplo n.º 12
0
        public int category([FromBody] DeviceCategory dc)
        {
            var obj = _context.DeviceCategory.FirstOrDefault(x => x.DeviceType == dc.DeviceType);

            if (obj == null)
            {
                _context.DeviceCategory.Add(dc);
                _context.SaveChanges();
            }
            return(_context.DeviceCategory.FirstOrDefault(x => x.DeviceType == dc.DeviceType).CategoryId);
        }
 public DeviceSelectionItem([CanBeNull] int?pID, [CanBeNull] int?deviceSelectionID, [CanBeNull] DeviceCategory deviceCategory,
                            [CanBeNull] RealDevice device,
                            [NotNull] string connectionString, [NotNull] string name, StrGuid guid)
     : base(name, TableName, connectionString, guid)
 {
     ID = pID;
     _deviceCategory    = deviceCategory;
     _device            = device;
     _deviceSelectionID = deviceSelectionID;
     TypeDescription    = "Device Selection Item";
 }
Exemplo n.º 14
0
        public Result PostDeviceCategory([FromBody] DeviceCategory deviceCategory)
        {
            deviceCategory.CreateUserId   = Request.GetIdentityInformation();
            deviceCategory.MarkedDateTime = DateTime.Now;
            ServerConfig.DeviceDb.Execute(
                "INSERT INTO device_category (`Id`, `CreateUserId`, `MarkedDateTime`, `MarkedDelete`, `ModifyId`, `CategoryName`, `Description`) " +
                "VALUES (@Id, @CreateUserId, @MarkedDateTime, @MarkedDelete, @ModifyId, @CategoryName, @Description);",
                deviceCategory);

            return(Result.GenError <Result>(Error.Success));
        }
Exemplo n.º 15
0
        private OnOffDevice getOnOffDevice(HmdService.TemplateDevice d, DeviceCategory deviceCategory)
        {
            var useOpenClose = d._DeviceAction.Count(a => a.Nom == "OPEN") > 0;

            return(new OnOffDevice(useOpenClose)
            {
                Id = d._ID,
                Name = d._Name,
                NumericValue = this.getValue(d._Value),
                DeviceCategory = deviceCategory
            });
        }
Exemplo n.º 16
0
 private NumericDevice getDimDevice(HmdService.TemplateDevice d, DeviceCategory deviceCategory)
 {
     return(new NumericDevice()
     {
         Id = d._ID,
         Name = d._Name,
         NumericValue = this.getValue(d._Value),
         DeviceCategory = deviceCategory,
         DeviceType = DeviceType.Dim,
         DisplayType = DisplayType.Percentage
     });
 }
Exemplo n.º 17
0
        private async Task AddNewProductConfig(DeviceCategory category, string connectedAnimationId)
        {
            var vm     = ViewModel;
            var device = category.DefaultDevice.Clone();

            device.Caption += " " + _productConfigCounter.ToString();
            _productConfigCounter++;
            var configVM = new ProductConfigurationViewModel(vm.OverlayProvider, device);
            await configVM.SetProductImageSourceAsync(category.ThumbnailPath);

            vm.AddNavMenuItem(configVM);
            _ = NavigateWithTransition(typeof(ProductConfigurationPage), configVM);
        }
Exemplo n.º 18
0
 public override int GetHashCode()
 {
     unchecked {
         var hashCode = _hashCode;
         hashCode = (hashCode * 397) ^ FullKey.GetHashCode();
         hashCode = (hashCode * 397) ^ (LoadtypeGuid != null ? LoadtypeGuid.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ DeviceCategory.GetHashCode();
         hashCode = (hashCode * 397) ^ LocationGuid.GetHashCode();
         hashCode = (hashCode * 397) ^ DeviceGuid.GetHashCode();
         hashCode = (hashCode * 397) ^ HouseholdKey.GetHashCode();
         hashCode = (hashCode * 397) ^ (int)ThisDeviceType;
         return(hashCode);
     }
 }
Exemplo n.º 19
0
 public DeviceCategoryPresenter(
     [NotNull] ApplicationPresenter applicationPresenter,
     [NotNull] DeviceCategoryView view, [NotNull] DeviceCategory deviceCategory)
     : base(view, "ThisDeviceCategory.Name", deviceCategory, applicationPresenter)
 {
     _deviceCategory = deviceCategory;
     _dcp            = new DeviceCategoryPickerPresenter(Sim, _deviceCategory,
                                                         view.DeviceCategoryPicker1);
     view.DeviceCategoryPicker1.DataContext = _dcp;
     _selectedParentCategory = _deviceCategory.ParentCategory;
     _deviceCategory.RefreshSubDevices();
     _usedIns = new ObservableCollection <UsedIn>();
     RefreshUsedIn();
 }
        public void CreateNewDeviceCategoryWithUpsertTest()
        {
            var newDeviceCategory = new DeviceCategory {
                DeviceCategoryName = "New Upsert Test Device Category"
            };

            DeviceCategoryService.Upsert(newDeviceCategory, TestUserPrincipal);
            var foundDeviceCategories = DeviceCategoryService.Search("New Upsert Test Device Category").ToList();

            Assert.AreEqual(1, foundDeviceCategories.Count);
            Assert.AreEqual(foundDeviceCategories.First().DeviceCategoryName, newDeviceCategory.DeviceCategoryName);

            DeviceCategoryService.DeleteByGuid(foundDeviceCategories.First().DeviceCategoryId);
        }
        public void IsAffordanceAvailableTestCheckDeviceActionGroupInDeviceActionGroup()
        {
            // Location: device action group
            // affordance: device Action Group
            Config.IsInUnitTesting = true;
            var col           = new ColorRGB(255, 0, 0);
            var deviceActions = new ObservableCollection <DeviceAction>();
            var aff           = new Affordance("bla", null, null, false, PermittedGender.All, 1, col, string.Empty, null,
                                               string.Empty, string.Empty,
                                               true, true, 0, 100, false, ActionAfterInterruption.GoBackToOld, false, Guid.NewGuid().ToStrGuid(), BodilyActivityLevel.Low);
            var rd1 = new RealDevice("rd1", 1, string.Empty, null, string.Empty, false, false, string.Empty, Guid.NewGuid().ToStrGuid());

            var dg = new DeviceActionGroup("group", string.Empty, string.Empty, Guid.NewGuid().ToStrGuid());
            var da = new DeviceAction("device action 1", null, "blub", string.Empty, dg, rd1, Guid.NewGuid().ToStrGuid());

            deviceActions.Add(da);
            var devices = new ObservableCollection <RealDevice>
            {
                rd1
            };
            // check if it works with a device category that has the device
            var dc1 = new DeviceCategory("dc1", 0, string.Empty, false, devices, Guid.NewGuid().ToStrGuid(), null, true);

            rd1.DeviceCategory = dc1;
            dc1.RefreshSubDevices();
            (dc1.SubDevices.Count).Should().Be(1);
            var connectionString = string.Empty;
            var lt = new VLoadType("lt", string.Empty, "bla", "blub", 1, 1, new TimeSpan(0, 1, 0), 1, connectionString,
                                   LoadTypePriority.Mandatory, true, Guid.NewGuid().ToStrGuid());
            var tbp = new TimeBasedProfile("name", 1, connectionString, TimeProfileType.Absolute, "data source", Guid.NewGuid().ToStrGuid());

            aff.AffordanceDevices.Add(new AffordanceDevice(dg, tbp, null, 0, null,
                                                           new ObservableCollection <RealDevice>(),
                                                           new ObservableCollection <DeviceCategory>(), "name", lt, string.Empty, 1, Guid.NewGuid().ToStrGuid()));
            var allDevices3 = new List <IAssignableDevice>
            {
                dg
            };

            if (da.DeviceActionGroup == null)
            {
                throw new LPGException("device action group was null");
            }
            var relevantDeviceActionGroup = da.DeviceActionGroup.GetDeviceActions(deviceActions);

            (relevantDeviceActionGroup.Count).Should().Be(1);
            (aff.IsAffordanceAvailable(allDevices3, deviceActions)).Should().BeTrue();
        }
        private void FindMissingDevice([NotNull] DeviceCategory category, [NotNull][ItemNotNull] List <DeviceAction> actionsInGroup,
                                       [NotNull] DeviceActionGroup deviceActionGroup, [NotNull] Simulator sim)
        {
            if (!PerformCleanupChecks)
            {
                return;
            }
            foreach (var device in category.SubDevicesWithoutRefresh)
            {
                var action = actionsInGroup.FirstOrDefault(a => a.Device == device);

                if (action == null)
                {
                    DeviceAction a;
                    Logger.Get().SafeExecuteWithWait(() => {
                        a = device.MakeDeviceAction(sim);
                        a.DeviceActionGroup = deviceActionGroup;
                        var other           = actionsInGroup.FirstOrDefault();
                        if (other != null)
                        {
                            foreach (var profile in other.Profiles)
                            {
                                if (profile.Timeprofile == null)
                                {
                                    throw  new LPGException("Time Profile was null");
                                }
                                if (profile.VLoadType == null)
                                {
                                    throw new LPGException("LoadType was null");
                                }
                                a.AddDeviceProfile(profile.Timeprofile, profile.TimeOffset, profile.VLoadType,
                                                   profile.Multiplier);
                            }
                        }
                        a.SaveToDB();
                    });
                    throw new DataIntegrityException(
                              "A device action group always needs to have all the devices in a device category." +
                              "The device action group " + Environment.NewLine + deviceActionGroup +
                              Environment.NewLine + " is missing at least one device. This device is " + Environment.NewLine + device.Name +
                              Environment.NewLine + " from the device category " + Environment.NewLine + device.DeviceCategory?.Name + Environment.NewLine + Environment.NewLine +
                              "A new device action was created for it. Please check if everything is correct and adjust as needed.",
                              deviceActionGroup);
                }
            }
        }
 public void LoadFromDatabaseTest()
 {
     using (var db = new DatabaseSetup(Utili.GetCurrentMethodAndClass()))
     {
         var deviceCategories = new ObservableCollection <DeviceCategory>();
         var realDevices      = new ObservableCollection <RealDevice>();
         DeviceCategory.LoadFromDatabase(deviceCategories, out var dcnone, db.ConnectionString, realDevices, false);
         deviceCategories.Count.Should().BeGreaterThan(0);
         db.ClearTable(DeviceCategory.TableName);
         var dc = new DeviceCategory("hallo", dcnone.IntID, db.ConnectionString, false, realDevices,
                                     Guid.NewGuid().ToStrGuid());
         dc.SaveToDB();
         deviceCategories.Clear();
         DeviceCategory.LoadFromDatabase(deviceCategories, out _, db.ConnectionString, realDevices, false);
         (2).Should().Be(deviceCategories.Count);
         db.Cleanup();
     }
 }
        public void InsertDeviceCategoryWithNameThatIsSoftDeletedTest()
        {
            TestDeviceCategory.IsDeleted = true;
            DeviceCategoryService.Update(TestDeviceCategory);

            var newDeviceCategory = new DeviceCategory()
            {
                DeviceCategoryName = TestDeviceCategoryName
            };

            DeviceCategoryService.Upsert(newDeviceCategory, TestUserPrincipal);

            var foundDeviceCategories = DeviceCategoryService.Search(TestDeviceCategoryName).ToList();

            Assert.AreEqual(1, foundDeviceCategories.Count);
            Assert.AreEqual(foundDeviceCategories.First().DeviceCategoryName, TestDeviceCategory.DeviceCategoryName);
            Assert.IsFalse(foundDeviceCategories.First().IsDeleted);
        }
Exemplo n.º 25
0
        public void CompleteAffordanceCreatorTest()
        {
            using (DatabaseSetup db = new DatabaseSetup(Utili.GetCurrentMethodAndClass()))
            {
                Simulator        sim       = new Simulator(db.ConnectionString);
                VLoadType        lt        = sim.LoadTypes[0];
                DeviceCategory   dc        = sim.DeviceCategories[1];
                TimeBasedProfile tp        = sim.Timeprofiles[1];
                Location         loc       = sim.Locations[0];
                TraitTag         tag       = sim.TraitTags[0];
                TimeLimit        timeLimit = sim.TimeLimits[0];

                CompleteAffordanceAdd.CreateItems(sim, "aff", "Entertainment / desire", "device", "trait", lt, dc, tp, 1,
                                                  10, 1, 99, loc, tag, "traitclass", timeLimit, "affcategory", null, false, "newLocation");
                SimIntegrityChecker.Run(sim);
                db.Cleanup();
            }
        }
Exemplo n.º 26
0
        public Result PutDeviceCategory([FromRoute] int id, [FromBody] DeviceCategory deviceCategory)
        {
            var cnt =
                ServerConfig.DeviceDb.Query <int>("SELECT COUNT(1) FROM `device_category` WHERE Id = @id AND `MarkedDelete` = 0;", new { id }).FirstOrDefault();

            if (cnt == 0)
            {
                return(Result.GenError <Result>(Error.DeviceCategoryNotExist));
            }

            deviceCategory.Id             = id;
            deviceCategory.CreateUserId   = Request.GetIdentityInformation();
            deviceCategory.MarkedDateTime = DateTime.Now;
            ServerConfig.DeviceDb.Execute(
                "UPDATE device_category SET `CreateUserId` = @CreateUserId, `MarkedDateTime` = @MarkedDateTime, `MarkedDelete` = @MarkedDelete, " +
                "`ModifyId` = @ModifyId, `CategoryName` = @CategoryName, `Description` = @Description WHERE `Id` = @Id;", deviceCategory);

            return(Result.GenError <Result>(Error.Success));
        }
Exemplo n.º 27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Group"/> class.
        /// </summary>
        /// <param name="category">The category of devices contained in this group.</param>
        public Group(DeviceCategory category)
            : this()
        {
            switch (category)
            {
            case DeviceCategory.Energy:
                this.Name = "Énergie";
                break;

            case DeviceCategory.Light:
                this.Name = "Lampes";
                break;

            case DeviceCategory.Meteo:
                this.Name = "Météo";
                break;

            case DeviceCategory.Multimedia:
                this.Name = "Multimédia";
                break;

            case DeviceCategory.Switch:
                this.Name = "Interrupteurs";
                break;

            case DeviceCategory.Flap:
                this.Name = "Volets";
                break;

            case DeviceCategory.Contact:
                this.Name = "Contacteurs";
                break;

            case DeviceCategory.Dectect:
                this.Name = "Détecteurs";
                break;

            default:
                this.Name = "Autre";
                break;
            }
        }
Exemplo n.º 28
0
        public void GetAllNameTest()
        {
            using (var db = new DatabaseSetup(Utili.GetCurrentMethodAndClass()))
            {
                var deviceCategories = new ObservableCollection <DeviceCategory>();

                var realDevices = new ObservableCollection <RealDevice>();
                DeviceCategory.LoadFromDatabase(deviceCategories, out _, db.ConnectionString, realDevices, false);
                var s = string.Empty;
                foreach (var deviceCategory in deviceCategories)
                {
                    if (deviceCategory.IsRootCategory)
                    {
                        s += deviceCategory.GetAllName(1) + Environment.NewLine;
                    }
                }
                Logger.Info(s);
                db.Cleanup();
            }
        }
Exemplo n.º 29
0
        public async Task InitializeData(IContextActionProvider contextActionProvider, string dataPath)
        {
            StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(dataPath));

            string dataString = await FileIO.ReadTextAsync(file);

            JsonObject rootObject = JsonObject.Parse(dataString);

            _rooms            = Room.ParseRoomList(rootObject["Rooms"].GetArray());
            _presets          = Preset.ParsePresetList(rootObject["Presets"].GetArray());
            _deviceCategories = DeviceCategory.ParseDeviceCategoryList(rootObject["DeviceCategories"].GetArray(), _stringProvider, contextActionProvider);
            _devices          = Device.ParseDeviceList(rootObject["Devices"].GetArray(), _stringProvider, contextActionProvider, _rooms, _deviceCategories);
            _products         = Product.ParseProductList(rootObject["Products"].GetArray(), _deviceCategories);

            SortDevices();

            foreach (var room in _rooms)
            {
                room.RoomSelected += Room_RoomSelected;
            }
        }
Exemplo n.º 30
0
        public void GetCalcManagerModularHouseholdTest()
        {
            using (var wd = new WorkingDir(Utili.GetCurrentMethodAndClass()))
            {
                using (var db = new DatabaseSetup(Utili.GetCurrentMethodAndClass()))
                {
                    var            sim   = new Simulator(db.ConnectionString);
                    DeviceCategory light = null;
                    foreach (var deviceCategory in sim.DeviceCategories.MyItems)
                    {
                        deviceCategory.RefreshSubDevices();
                        if (deviceCategory.Name.Contains("Light"))
                        {
                            light = deviceCategory;
                        }
                    }
                    if (light != null)
                    {
                        Logger.Info("Light devices:" + light.SubDevices.Count);
                    }
                    sim.MyGeneralConfig.ApplyOptionDefault(OutputFileDefault.NoFiles);
                    sim.MyGeneralConfig.Enable(CalcOption.OverallSum);
                    sim.Should().NotBeNull();

                    var cmf = new CalcManagerFactory();
                    CalculationProfiler   calculationProfiler = new CalculationProfiler();
                    CalcStartParameterSet csps = new CalcStartParameterSet(sim.GeographicLocations[0],
                                                                           sim.TemperatureProfiles[0], sim.ModularHouseholds[0], EnergyIntensityType.Random, false,
                                                                           null, LoadTypePriority.Mandatory, null, null, null, sim.MyGeneralConfig.AllEnabledOptions(),
                                                                           new DateTime(2015, 1, 15), new DateTime(2015, 1, 18), new TimeSpan(0, 1, 0), ";", -1, new TimeSpan(0, 1, 0), false, false, false, 3, 3,
                                                                           calculationProfiler, wd.WorkingDirectory, false);

                    var cm = cmf.GetCalcManager(sim, csps, false);

                    cm.Run(ReportCancelFunc);
                    db.Cleanup();
                }
                wd.CleanUp();
            }
        }
Exemplo n.º 31
0
 private bool TvsAsDesktop(DeviceCategory category)
 {
     return options.CategorizeTvsAsDesktops && category == DeviceCategory.Tv;
 }
Exemplo n.º 32
0
 private bool TabletAsDesktop(DeviceCategory category)
 {
     return options.CategorizeTabletsAsDesktops && category == DeviceCategory.Tablet;
 }
Exemplo n.º 33
0
 private OnOffDevice getOnOffDevice(HmdService.TemplateDevice d, DeviceCategory deviceCategory)
 {
     var useOpenClose = d._DeviceAction.Count(a => a.Nom == "OPEN") > 0;
     return new OnOffDevice(useOpenClose)
     {
         Id = d._ID,
         Name = d._Name,
         NumericValue = this.getValue(d._Value),
         DeviceCategory = deviceCategory
     };
 }
Exemplo n.º 34
0
 private NumericDevice getDimDevice(HmdService.TemplateDevice d, DeviceCategory deviceCategory)
 {
     return new NumericDevice()
     {
         Id = d._ID,
         Name = d._Name,
         NumericValue = this.getValue(d._Value),
         DeviceCategory = deviceCategory,
         DeviceType = DeviceType.Dim,
         DisplayType = DisplayType.Percentage
     };
 }
Exemplo n.º 35
0
 public DeviceInformation(DeviceCategory category)
 {
     Category = category;
 }