Exemplo n.º 1
0
        public static List <DayProfile> CreateDayProfiles(this XmlFactory builder, HanAdapterExampleConfig hanConfiguration)
        {
            var dayProfiles = new List <DayProfile>();

            foreach (DayProfileConfig config in hanConfiguration.XmlConfig.DayProfiles)
            {
                var dayProfile      = new DayProfile();
                var dayTimeProfiles = new List <DayTimeProfile>();

                dayProfile.DayId = config.DayId;

                foreach (DayTimeProfileConfig dayTimeConfig in config.DayTimeProfiles)
                {
                    var time = dayTimeConfig.Start;

                    while (time <= dayTimeConfig.End)
                    {
                        var dayTimeProfile = new DayTimeProfile();
                        dayTimeProfile.StartTime.Hour   = (byte)time.Hour;
                        dayTimeProfile.StartTime.Minute = (byte)time.Minute;
                        dayTimeProfile.TariffNumber     = dayTimeConfig.TariffNumber;
                        time = time.AddSeconds(900);
                        dayTimeProfiles.Add(dayTimeProfile);
                    }
                }

                dayProfile.DayTimeProfiles = dayTimeProfiles;
                dayProfiles.Add(dayProfile);
            }

            return(dayProfiles);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates the LogEntries for the xml data file.
        /// </summary>
        /// <param name="builder">The calling XmlBuilder Object </param>
        /// <param name="hanConfiguration"></param>
        /// <returns></returns>
        public static List <LogEntry> CreateLogs(this XmlFactory builder, HanAdapterExampleConfig hanConfiguration)
        {
            var logs      = new List <LogEntry>();
            var messages  = hanConfiguration.XmlConfig.PossibleLogMessages;
            var logCount  = GetRandomNumber(hanConfiguration.XmlConfig.MinLogCount, hanConfiguration.XmlConfig.MaxLogCount);
            var timestamp = hanConfiguration.Start;

            for (int index = 0; index < logCount; index++)
            {
                logs.Add(new LogEntry()
                {
                    RecordNumber = (uint)index + 1,
                    LogEvent     = new LogEvent()
                    {
                        Level     = (Level)GetRandomNumber(1, 4),
                        Outcome   = (Outcome)GetRandomNumber(0, 1),
                        Text      = messages[GetRandomNumber(0, messages.Count - 1)],
                        Timestamp = (DateTime)timestamp?.SetRandomTimestamp(new TimeSpan(0, 15, 0))
                    }
                });

                timestamp = logs.LastOrDefault().LogEvent.Timestamp;
            }

            return(logs);
        }
Exemplo n.º 3
0
        public static List <SpecialDayProfile> CreateSpecialDayProfiles(this XmlFactory builder, HanAdapterExampleConfig hanConfiguration)
        {
            var specialDayProfiles = new List <SpecialDayProfile>();

            var specialDayProfileSets = GetSpecialDayProfileSets(hanConfiguration);

            var billingPeriod = hanConfiguration.BillingPeriod.SetBillingPeriod((DateTime)hanConfiguration.Start, (DateTime)hanConfiguration.End);

            foreach ((List <int> allowedDayIds, List <int> tariffNumbers, ObisId obisCode)set in specialDayProfileSets)
            {
                var dayIds = set.allowedDayIds;
                var date   = billingPeriod.Begin;

                while (date < billingPeriod.End)
                {
                    var specialDayProfile = new SpecialDayProfile
                    {
                        SpecialDayDate = new DayVarType
                        {
                            Year       = (ushort)date.Year,
                            Month      = (byte)date.Month,
                            DayOfMonth = (byte)date.Day
                        }
                    };

                    var index = GetRandomNumber(0, dayIds.Count - 1);
                    specialDayProfile.DayId = (ushort)dayIds[index];
                    date = date.AddDays(1);
                    specialDayProfiles.Add(specialDayProfile);
                }
            }

            specialDayProfiles.OrderBy(spd => spd.SpecialDayDate.GetDate());
            return(specialDayProfiles);
        }
Exemplo n.º 4
0
        public static List <MeterReading> CreateMeterReadings(this XmlFactory builder, HanAdapterExampleConfig hanConfiguration)
        {
            var meterReadings     = new List <MeterReading>();
            var billingPeriod     = hanConfiguration.BillingPeriod.SetBillingPeriod((DateTime)hanConfiguration.Start, (DateTime)hanConfiguration.End);
            var originalValueList = new List <MeterReading>();
            var taf2Data          = new List <Taf2Data>();

            foreach (MeterReadingConfig meterReadingConfig in hanConfiguration.XmlConfig.MeterReadingConfigs)
            {
                var mr = new MeterReading();


                mr.InitMeterReading(meterReadingConfig);

                if (meterReadingConfig.IsOML)
                {
                    mr.ReadingType.QualifiedLogicalName = BuildQualifiedLogicalName(mr.Meters[0].MeterId, mr.ReadingType.ObisCode);
                    mr.OriginalValueList(hanConfiguration, meterReadingConfig, taf2Data);
                    originalValueList.Add(mr);
                }
                else
                {
                    mr.ReadingType.QualifiedLogicalName = BuildQualifiedLogicalName(hanConfiguration.XmlConfig.TariffId, mr.ReadingType.ObisCode);
                    switch (hanConfiguration.Contract.TafId)
                    {
                    case TafId.Taf1:
                        mr.Taf1RegisterMeterReading(mr.GetAssociatedOriginalValueList(originalValueList), billingPeriod, meterReadingConfig);
                        break;

                    case TafId.Taf2:
                        mr.Taf2RegisterMeterReading(mr.GetAssociatedOriginalValueList(originalValueList), billingPeriod, meterReadingConfig, taf2Data);
                        break;

                    default:
                        throw new InvalidOperationException($"for the specified Tafid {hanConfiguration.Contract.TafId} a derived register should not be created.");
                    }
                }

                meterReadings.Add(mr);
            }
            return(meterReadings);
        }