from . import CableDistributorDingo


class MVCableDistributorDingo(CableDistributorDingo):
    """ Cable distributor (connection point) """

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        self.lv_load_area_group = kwargs.get('lv_load_area_group', None)

        # build id from associated grid district id and the count of cable distributors in grid,
        # use 10^4 (because max. count of MV grid districts is 4*10^3) as factor to separate both ids
        # (allow later distinction between these two parts)
        self.id_db = self.grid.grid_district.id_db * 10**4 + self.grid.cable_distributors_count() + 1

    def __repr__(self):
        return 'mv_cable_dist_' + str(self.id_db)


class LVCableDistributorDingo(CableDistributorDingo):
    """LV Cable distributor (connection point) """

    def __init__(self, **kwargs):
        super().__init__(**kwargs)

        self.string_id = kwargs.get('string_id', None)
        self.branch_no = kwargs.get('branch_no', None)
        self.load_no = kwargs.get('load_no', None)

        # build id from associated grid district id and the count of cable distributors in grid,
        # use 10^7 (because max. count of LV grid districts is 5*10^6) as factor to separate both ids
        # (allow later distinction between these two parts)
        self.id_db = self.grid.grid_district.id_db * 10**7 + self.grid.cable_distributors_count() + 1

    def __repr__(self):
        return 'lv_cable_dist_' + str(self.id_db)

@@ -367,32 +367,41 @@
 ibutors in grid,
+ use 10%5E4
 %0A        # use 1
@@ -394,25 +394,16 @@
        #
- use 10%5E4
  (becaus
@@ -1151,16 +1151,25 @@
 in grid,
+ use 10%5E8
 %0A       
@@ -1174,17 +1174,8 @@
    #
- use 10%5E7
  (be
@@ -1221,16 +1221,109 @@
 s 5*10%5E6
+ and an additional 10%5E1 is required to achieve same length%0A        # as MV grid branches' ids
 ) as fac
@@ -1342,34 +1342,24 @@
 ate both ids
-%0A        #
  (allow late
@@ -1458,9 +1458,9 @@
 10**
-7
+8
  + s

modify factor for cable dist. id setting