コード例 #1
0
 private static void SetStatusWord(IntervalReading ir, MeterReadingConfig config)
 {
     if (config.UsedStatus == "FNN")
     {
         ir.StatusFNN = new StatusFNN(GetStatusFNN());
     }
     else if (config.UsedStatus == "PTB")
     {
         ir.StatusPTB = (StatusPTB)GetRandomNumber(0, 4);
     }
 }
コード例 #2
0
        private static void InitMeterReading(this MeterReading meterReading, MeterReadingConfig meterReadingConfig)
        {
            meterReading.Meters.Add(new Meter()
            {
                MeterId = meterReadingConfig.MeterId
            });
            meterReading.MeterReadingId = meterReadingConfig.MeterReadingId;

            meterReading.ReadingType = new ReadingType()
            {
                MeterReading         = meterReading,
                PowerOfTenMultiplier = (PowerOfTenMultiplier)meterReadingConfig.PowerOfTenMultiplier,
                Uom      = (Uom)meterReadingConfig.Uom,
                Scaler   = (short)meterReadingConfig.Scaler,
                ObisCode = meterReadingConfig.ObisCode
            };
        }
コード例 #3
0
        private static void Taf1RegisterMeterReading(this MeterReading meterReading, MeterReading oml, BillingPeriod billingPeriod, MeterReadingConfig meterReadingConfig)
        {
            var intervalBlock  = InitIntervalBlockWithInterval(billingPeriod.Begin, (DateTime)billingPeriod.End);
            var period         = meterReadingConfig.Taf1PeriodInMonth;
            var requiredValues = GetRequiredIntervalReadingsFromOML(oml, billingPeriod.Begin, (DateTime)billingPeriod.End);

            var timestamp = billingPeriod.Begin.AddMonths(period);
            var initValue = requiredValues.FirstOrDefault(val => val.TimePeriod.Start == billingPeriod.Begin).Value;
            var value     = GetNextValue(initValue, requiredValues, timestamp, (DateTime)billingPeriod.End);

            while (timestamp <= billingPeriod.End)
            {
                var ir = new IntervalReading()
                {
                    TimePeriod = new Interval()
                    {
                        Duration = 0,
                        Start    = timestamp
                    },
                    Value = value
                };

                SetStatusWord(ir, meterReadingConfig);
                ir.IntervalBlock = intervalBlock;
                intervalBlock.IntervalReadings.Add(ir);
                timestamp = timestamp.AddMonths(period);
                value     = GetNextValue(initValue, requiredValues, timestamp, (DateTime)billingPeriod.End);
            }

            intervalBlock.MeterReading = meterReading;
            meterReading.IntervalBlocks.Add(intervalBlock);
        }
コード例 #4
0
        private static void Taf2RegisterMeterReading(this MeterReading meterReading, MeterReading oml, BillingPeriod billingPeriod, MeterReadingConfig meterReadingConfig, List <Taf2Data> taf2Data)
        {
            var intervalBlock  = InitIntervalBlockWithInterval(billingPeriod.Begin, (DateTime)billingPeriod.End);
            var ObisCode       = new ObisId(oml.ReadingType.ObisCode);
            var taf2           = taf2Data.FirstOrDefault(t => t.ObisID.ToHexString() == ObisCode.ToHexString());
            var requiredValues = GetRequiredIntervalReadingsFromOML(oml, billingPeriod.Begin, (DateTime)billingPeriod.End);

            int value = 0;

            if (new ObisId(meterReading.ReadingType.ObisCode).E == 0)
            {
                foreach ((DateTime timestamp, int tariff, int value)item in taf2.Data)
                {
                    if (item.timestamp >= billingPeriod.Begin && item.timestamp <= (DateTime)billingPeriod.End)
                    {
                        value = value + item.value;
                    }
                }
            }
            else
            {
                foreach ((DateTime timestamp, int tariff, int value)item in taf2.Data)
                {
                    if (item.timestamp >= billingPeriod.Begin && item.timestamp <= (DateTime)billingPeriod.End && item.tariff == meterReadingConfig.Taf2TariffStage)
                    {
                        value = value + item.value;
                    }
                }
            }

            var ir = new IntervalReading()
            {
                TimePeriod = new Interval()
                {
                    Duration = (uint)(billingPeriod.End - billingPeriod.Begin)?.TotalSeconds,
                    Start    = billingPeriod.Begin
                },
                Value = value
            };

            SetStatusWord(ir, meterReadingConfig);
            ir.IntervalBlock = intervalBlock;
            intervalBlock.IntervalReadings.Add(ir);
            intervalBlock.MeterReading = meterReading;
            meterReading.IntervalBlocks.Add(intervalBlock);
        }
コード例 #5
0
        private static void OriginalValueList(this MeterReading meterReading, HanAdapterExampleConfig hanConfiguration, MeterReadingConfig meterReadingConfig, List <Taf2Data> taf2Data)
        {
            var intervalBlock = InitIntervalBlockWithInterval((DateTime)hanConfiguration.Start, (DateTime)hanConfiguration.End);
            var taf2          = new Taf2Data(new ObisId(meterReading.ReadingType.ObisCode));

            var value     = meterReadingConfig.OMLInitValue;
            var preValue  = value;
            var timestamp = intervalBlock.Interval.Start.ToUniversalTime();

            var end = intervalBlock.Interval.GetEnd().GetDateWithoutSeconds().ToUniversalTime();

            while (timestamp <= end)
            {
                var ir = new IntervalReading()
                {
                    TimePeriod = new Interval()
                    {
                        Duration = 0,
                        Start    = timestamp.ToLocalTime()
                    },
                    Value = value
                };

                if (preValue != value)
                {
                    taf2.Data.Add((timestamp.ToLocalTime(), GetRandomNumber(0, meterReadingConfig.Taf2TariffStages), value - preValue));
                }

                preValue  = value;
                value     = value + GetRandomNumber(1, hanConfiguration.XmlConfig.MaxConsumptionValue);
                timestamp = timestamp.AddSeconds(meterReadingConfig.PeriodSeconds.Value).GetDateWithoutSeconds();
                SetStatusWord(ir, meterReadingConfig);
                ir.IntervalBlock = intervalBlock;
                intervalBlock.IntervalReadings.Add(ir);
            }

            taf2Data.Add(taf2);
            intervalBlock.MeterReading = meterReading;
            meterReading.IntervalBlocks.Add(intervalBlock);
        }