public void CalcAffordanceDtoLoggerTest()
        {
            using (WorkingDir wd = new WorkingDir(Utili.GetCurrentMethodAndClass()))
            {
                CalcAffordanceDtoLogger ael    = new CalcAffordanceDtoLogger(wd.SqlResultLoggingService);
                HouseholdKey            key    = new HouseholdKey("hhkey");
                List <IDataSaverBase>   savers = new List <IDataSaverBase>
                {
                    ael
                };
                InputDataLogger idl = new InputDataLogger(savers.ToArray());
                //CalcLoadTypeDto cldto = new CalcLoadTypeDto("loadtype", 1, "kw", "kwh", 1, true, "guid");
                CalcProfileDto cpd = new CalcProfileDto("name", 1, ProfileType.Absolute, "source", Guid.NewGuid().ToStrGuid());
                AvailabilityDataReferenceDto adrd  = new AvailabilityDataReferenceDto("blub", "availguid".ToStrGuid());
                CalcAffordanceDto            cadto = new CalcAffordanceDto("blub", 1, cpd, "locname", "locguid".ToStrGuid(), true, new List <CalcDesireDto>(),
                                                                           1, 100, PermittedGender.All, true, 1, 1, 1, 1, "affcat", false, false, new List <CalcAffordanceVariableOpDto>(),
                                                                           new List <VariableRequirementDto>(), ActionAfterInterruption.GoBackToOld,
                                                                           "timelimitname", 100, true, "srctrait", "guid".ToStrGuid(), adrd, key, BodilyActivityLevel.Low);

                cadto.AddDeviceTuple("devname", "deviguid".ToStrGuid(), cpd, "calcloadtypename", "loadtypeguid".ToStrGuid(), 1, new TimeSpan(0, 1, 0), 1, 1);
                List <IHouseholdKey> aes = new List <IHouseholdKey>
                {
                    cadto
                };
                idl.SaveList(aes);
                var res = ael.Load(key);
                var s1  = JsonConvert.SerializeObject(aes, Formatting.Indented);
                var s2  = JsonConvert.SerializeObject(res, Formatting.Indented);
                s1.Should().Be(s2);
                wd.CleanUp();
            }
        }
Esempio n. 2
0
        public static CalcProfileDto GetCalcProfileDto([NotNull] TimeBasedProfile tp)
        {
            var cp = new CalcProfileDto(tp.Name, tp.IntID, (ProfileType)tp.TimeProfileType,
                                        tp.DataSource, Guid.NewGuid().ToStrGuid());

            foreach (var timeDataPoint in tp.ObservableDatapoints)
            {
                cp.AddNewTimepoint(timeDataPoint.Time, timeDataPoint.Value);
            }
            return(cp);
        }
        public static CalcProfile MakeCalcProfile([NotNull] CalcProfileDto cpd, [NotNull] CalcParameters calcParameters)
        {
            CalcProfile cp = new CalcProfile(cpd.Name, cpd.Guid, calcParameters.InternalStepsize,
                                             cpd.ProfileType, cpd.DataSource);

            foreach (var dp in cpd.Datapoints)
            {
                cp.AddNewTimepoint(dp.Time, dp.Value);
            }
            cp.ConvertToTimesteps();
            return(cp);
        }