Example #1
0
        public static string GetMediumLabel(this ObisId id)
        {
            switch (id.Medium)
            {
            case ObisMedium.Abstract:
                return(string.Empty);

            case ObisMedium.Electricity:
                return("Elektrizität");

            case ObisMedium.HeatCostAllocator:
                return("Heizkostenverteiler");

            case ObisMedium.Cooling:
                return("Kälte");

            case ObisMedium.Heat:
                return("Wärme");

            case ObisMedium.Gas:
                return("Gas");

            case ObisMedium.WaterCold:
                return("Kaltwasser");

            case ObisMedium.WaterHot:
                return("Warmwasser");

            case ObisMedium.Communication:
                return("Kommunikationsgerät");

            default:
                return("unbekannt");
            }
        }
Example #2
0
 public ObisId(ObisId src)
 {
     this.A = src.A;
     this.B = src.B;
     this.C = src.C;
     this.D = src.D;
     this.E = src.E;
     this.F = src.F;
 }
Example #3
0
        public static string GetLabel(this ObisId id)
        {
            switch (id.Medium)
            {
            case ObisMedium.Electricity:
                return(GetElectricityLabel(id));

            case ObisMedium.Gas:
                return(GetGasLabel(id));

            default:
                return($"Für die Kennziffer {id} ist keine Beschreibung hinterlegt.");
            }
        }
Example #4
0
        private static string GetGasLabel(ObisId id)
        {
            // 7-0:3.1.0*255 - Volume, temperature converted
            if (id.C == 3 && id.D == 1 && id.E == 0)
            {
                return("Volumen");
            }

            // 7-0:3.0.0*255 - Volume, measuring conditions
            if (id.C == 3 && id.D == 0 && id.E == 0)
            {
                return("Volumen");
            }

            return($"Für die Kennziffer {id} ist keine Beschreibung hinterlegt.");
        }
Example #5
0
 // Validates the maximum amount of tariff stages
 private static void ValidateSupplierModelTariffStageCount(UsagePointLieferant supplier, List <Exception> exceptions)
 {
     if (supplier.AnalysisProfile.TariffStages.Count > 20)
     {
         var stages             = supplier.AnalysisProfile.TariffStages;
         int errorRegisterCount = 0;
         foreach (TariffStage stage in stages)
         {
             var obisId = new ObisId(stage.ObisCode);
             if (obisId.E == 63)
             {
                 errorRegisterCount++;
             }
         }
         if (stages.Count - errorRegisterCount > 20)
         {
             exceptions.Add(new InvalidOperationException("Es sind maximal 20 Tarifstuffen zulässig."));
         }
     }
 }
Example #6
0
        private static string GetElectricityLabel(ObisId id)
        {
            if (id.C == 81 && id.D == 7)
            {
                switch (id.E)
                {
                case 1:
                    return("Phasenwinkel U (L2) / U (L1)");

                case 2:
                    return("Phasenwinkel U (L3) / U (L1)");

                case 4:
                    return("Phasenwinkel I (L1) / U (L1)");

                case 15:
                    return("Phasenwinkel I (L2) / U (L2)");

                case 26:
                    return("Phasenwinkel I (L3) / U (L3)");
                }
            }

            if (id.D == 7 && id.E == 0)
            {
                switch (id.C)
                {
                case 14:
                    return("Frequenz");

                case 16:
                    return("Wirkleistung Verbrauch");

                case 32:
                    return("Spannung L1");

                case 36:
                    return("Wirkleistung L1");

                case 52:
                    return("Spannung L2");

                case 56:
                    return("Wirkleistung L2");

                case 72:
                    return("Spannung L3");

                case 76:
                    return("Wirkleistung L3");

                case 31:
                    return("Strom L1");

                case 51:
                    return("Strom L2");

                case 71:
                    return("Strom L3");
                }
            }

            string tariff;

            switch (id.E)
            {
            case 0:
                tariff = "Gesamt";
                break;

            case 63:
                tariff = "Fehlerregister";
                break;

            default:
                tariff = $"Tarifregister {id.E}";
                break;
            }

            switch (id.C)
            {
            case 1:
                return("Elektrische Wirkarbeit Bezug " + tariff);

            case 2:
                return("Elektrische Wirkarbeit Lieferung " + tariff);
            }

            return($"Für die Kennziffer {id} ist keine Beschreibung hinterlegt.");
        }
Example #7
0
        public static bool TryParse(string value, out ObisId id)
        {
            id = null;

            if (Regex.IsMatch(value, "[0-9A-Fa-f]{12}"))
            {
                var longValue = ulong.Parse(value, NumberStyles.HexNumber);
                if (longValue > 0xFFFFFFFFFFFF)
                {
                    return(false);
                }

                id   = new ObisId();
                id.A = (byte)((longValue >> 40) & 0xFF);
                id.B = (byte)((longValue >> 32) & 0xFF);
                id.C = (byte)((longValue >> 24) & 0xFF);
                id.D = (byte)((longValue >> 16) & 0xFF);
                id.E = (byte)((longValue >> 8) & 0xFF);
                id.F = (byte)(longValue & 0xFF);
                return(true);
            }

            var match = Regex.Match(value, @"^(?<A>\d+)-(?<B>\d+)\:(?<C>\d+)\.(?<D>\d+)\.(?<E>\d+)\*(?<F>\d+)$|^(?<A>\d+)-(?<B>\d+)\:(?<C>\d+)\.(?<D>\d+)\.(?<E>\d+)$|^(?<C>\d+)\.(?<D>\d+)\.(?<E>\d+)$");

            if (match.Success)
            {
                id = new ObisId();

                if (match.Groups["A"].Success)
                {
                    id.A = byte.Parse(match.Groups["A"].Value);
                }
                else
                {
                    id.A = 1;
                }

                if (match.Groups["B"].Success)
                {
                    id.B = byte.Parse(match.Groups["B"].Value);
                }
                else
                {
                    id.B = 0;
                }

                id.C = byte.Parse(match.Groups["C"].Value);
                id.D = byte.Parse(match.Groups["D"].Value);
                id.E = byte.Parse(match.Groups["E"].Value);

                if (match.Groups["F"].Success)
                {
                    id.F = byte.Parse(match.Groups["F"].Value);
                }
                else
                {
                    id.F = 255;
                }

                return(true);
            }

            return(false);
        }
Example #8
0
 public bool Equals(ObisId other)
 {
     return(this == other);
 }