(*
   $Id$
   ISO TC184/SC4/WG12 N4014 - ISO/TS 10303-1689 Interconnect physical requirement allocation - EXPRESS ARM
   Supersedes ISO TC184/SC4/WG12 N3456
*)

 SCHEMA Interconnect_physical_requirement_allocation_arm;

	USE FROM Requirement_view_definition_relationship_arm; -- ISO/TS 10303-1142
	
	USE FROM Integral_shield_arm; -- ISO/TS 10303-xxxx

	REFERENCE FROM Requirement_decomposition_arm(get_rvd);	-- ISO/TS 10303-1740

	REFERENCE FROM Characterizable_object_arm(bag_to_set);  -- ISO/TS 10303-1765

  TYPE land_physical_template_or_inter_stratum_feature_template = SELECT
       (Land_physical_template,
        Inter_stratum_feature_template);
  END_TYPE;

  ENTITY Dependent_electrical_isolation_removal_template
    SUBTYPE OF (Electrical_isolation_removal_template);
      associated_item : land_physical_template_or_inter_stratum_feature_template;
    WHERE
      WR1 : SIZEOF(QUERY (dtlipd <* USEDIN(SELF,'PART_TEMPLATE_2D_SHAPE_ARM.TEMPLATE_LOCATION_IN_STRUCTURED_TEMPLATE.TEMPLATE') | 
                  NOT(
                     (SIZEOF(QUERY (tlist <* USEDIN(associated_item,'PART_TEMPLATE_2D_SHAPE_ARM.TEMPLATE_LOCATION_IN_STRUCTURED_TEMPLATE.TEMPLATE') | 
                             NOT(
                                 (tlist\Template_location_in_structured_template.assembly :=: 
                                  dtlipd\Template_location_in_structured_template.assembly) AND
                                 ('PART_TEMPLATE_2D_SHAPE_ARM.DEPENDENT_TEMPLATE_LOCATION_IN_PADSTACK_DEFINITION' IN TYPEOF(dtlipd)) AND                                 
                                 (tlist :=: dtlipd\Dependent_template_location_in_padstack_definition.reference_location)
                                 )
                      )) = 0)
                      )
             )) = 0;
        END_ENTITY;

  ENTITY Dependent_thermal_isolation_removal_template
    SUBTYPE OF (Thermal_isolation_removal_template);
      associated_item : Land_physical_template;
    WHERE
      WR1 : SIZEOF(QUERY (dtlipd <* USEDIN(SELF,'PART_TEMPLATE_2D_SHAPE_ARM.TEMPLATE_LOCATION_IN_STRUCTURED_TEMPLATE.TEMPLATE') | 
                  NOT(
                     (SIZEOF(QUERY (tlist <* USEDIN(associated_item,'PART_TEMPLATE_2D_SHAPE_ARM.TEMPLATE_LOCATION_IN_STRUCTURED_TEMPLATE.TEMPLATE') | 
                             NOT(
                                 (tlist\Template_location_in_structured_template.assembly :=: 
                                  dtlipd\Template_location_in_structured_template.assembly) AND
                                 ('PART_TEMPLATE_2D_SHAPE_ARM.DEPENDENT_TEMPLATE_LOCATION_IN_PADSTACK_DEFINITION' IN TYPEOF(dtlipd)) AND                                 
                                 (tlist :=: dtlipd\Dependent_template_location_in_padstack_definition.reference_location)
                                 )
                      )) = 0)
                      )
             )) = 0;
  END_ENTITY;

  ENTITY Electrical_isolation_removal_template
    SUBTYPE OF (Material_removal_feature_template);
    DERIVE
      electrical_isolation_spacing_requirement : SET[1:?] OF Requirement_view_definition := 
        get_rvd(SELF, 'electrical requirement');
    WHERE
      WR1: SIZEOF(QUERY(eisr <* electrical_isolation_spacing_requirement |
         NOT('INTERCONNECT_PHYSICAL_REQUIREMENT_ALLOCATION_ARM.ELECTRICAL_ISOLATION_REQUIREMENT'
        IN TYPEOF(eisr)) )) =0;
      WR2: SIZEOF(QUERY(s <* SELF\Geometric_template.shapes |
        ('PART_TEMPLATE_EXTENSION_ARM.PLANAR_CLOSED_PATH_SHAPE_MODEL_WITH_PARAMETERS' IN TYPEOF(s)))) = 0;
      WR3: SIZEOF(QUERY(s <* SELF\Geometric_template.shapes |
        NOT ('CONSTRUCTIVE_SOLID_GEOMETRY_2D_ARM.SINGLE_BOUNDARY_CSG_2D_MODEL' IN TYPEOF(s)))) = 0;        
  END_ENTITY;

  ENTITY Electrical_isolation_requirement
    SUBTYPE OF (Requirement_view_definition);
  effective_voltage_withstand_capacity_requirement : OPTIONAL Value_limit;
    DERIVE
  electrical_isolation_spacing_requirement         : SET[1:1] OF Predefined_requirement_view_definition := 
    get_specific_requirement_type_for_primary_rvd_relationship(SELF, 'electrical isolation spacing requirement', 
              'INTERCONNECT_PLACEMENT_REQUIREMENTS_ARM.LAYOUT_SPACING_REQUIREMENT_OCCURRENCE');
    WHERE
      WR1 : NOT EXISTS(effective_voltage_withstand_capacity_requirement) OR
             ((effective_voltage_withstand_capacity_requirement\Qualified_representation_item.qualifiers[1]\Type_qualifier.name in ['minimum'])
              AND
             ('VALUE_WITH_UNIT_EXTENSION_ARM.ELECTRIC_POTENTIAL_DATA_ELEMENT' IN TYPEOF(effective_voltage_withstand_capacity_requirement)));
      WR2 : 'INTERCONNECT_PLACEMENT_REQUIREMENTS_ARM.LAYOUT_SPACING_REQUIREMENT_OCCURRENCE' IN TYPEOF(electrical_isolation_spacing_requirement[1]);
      WR3 : NOT EXISTS(SELF\Product_view_definition.additional_characterization);
  END_ENTITY;

  ENTITY Interconnect_shield_allocation
    SUBTYPE OF (Requirement_assignment);
      SELF\Requirement_assignment.assigned_to : Integral_shield;
      SELF\Requirement_assignment.assigned_requirement RENAMED assigned_requirement_property  : Predefined_requirement_view_definition;
    WHERE
     WR1 : assigned_requirement_property\Product_view_definition.initial_context\View_definition_context.application_domain = 'electrical';
  END_ENTITY;
		
  ENTITY Thermal_isolation_removal_template
    SUBTYPE OF (Material_removal_structured_template);
	DERIVE
  		thermal_isolation_spacing_requirement: SET[1:?] OF Requirement_view_definition :=
		  get_rvd(SELF, 'thermal requirement');
	WHERE
	  WR1: SIZEOF(QUERY(tisr <* THERMAL_ISOLATION_SPACING_REQUIREMENT |
       NOT('INTERCONNECT_PHYSICAL_REQUIREMENT_ALLOCATION_ARM.THERMAL_ISOLATION_REQUIREMENT' IN TYPEOF(tisr))
       )) =0;
  END_ENTITY;

  ENTITY Thermal_isolation_requirement
  	SUBTYPE OF (Requirement_view_definition);
    thermal_bar_width                        : OPTIONAL Length_tolerance_characteristic;
    number_of_bars                           : OPTIONAL INTEGER;
    effective_current_capacity_requirement   : OPTIONAL Value_limit;
    angular_orientation_requirement          : OPTIONAL Value_range;
    effective_thermal_resistance_requirement : OPTIONAL Value_limit;
   DERIVE
    thermal_isolation_spacing_requirement    : SET[1:1] OF Predefined_requirement_view_definition := 
            get_specific_requirement_type_for_primary_rvd_relationship(SELF, 'thermal isolation spacing requirement', 'INTERCONNECT_PLACEMENT_REQUIREMENTS_ARM.LAYOUT_SPACING_REQUIREMENT_OCCURRENCE');
   WHERE
      WR1 : NOT EXISTS(SELF\Product_view_definition.additional_characterization);
      WR2 : NOT(EXISTS(thermal_bar_width) XOR EXISTS(number_of_bars));
      WR3 : 'INTERCONNECT_PLACEMENT_REQUIREMENTS_ARM.LAYOUT_SPACING_REQUIREMENT_OCCURRENCE' IN TYPEOF(thermal_isolation_spacing_requirement[1]);
      WR4 : NOT EXISTS(effective_current_capacity_requirement) OR
              ((effective_current_capacity_requirement\Qualified_representation_item.qualifiers[1]\Type_qualifier.name in ['minimum'])
              AND
              ('VALUE_WITH_UNIT_EXTENSION_ARM.ELECTRIC_CURRENT_DATA_ELEMENT' IN TYPEOF(effective_current_capacity_requirement)));
      WR5 : NOT EXISTS(angular_orientation_requirement) OR
              ('VALUE_WITH_UNIT_EXTENSION_ARM.ANGLE_DATA_ELEMENT' IN TYPEOF(angular_orientation_requirement));
      WR6 : NOT EXISTS(effective_thermal_resistance_requirement) OR
              ((effective_thermal_resistance_requirement\Qualified_representation_item.qualifiers[1]\Type_qualifier.name in ['minimum'])
              AND
              ('VALUE_WITH_UNIT_EXTENSION_ARM.THERMAL_RESISTANCE_DATA_ELEMENT' IN TYPEOF(effective_thermal_resistance_requirement)));
  END_ENTITY;

FUNCTION get_specific_requirement_type_for_primary_rvd_relationship 
                 (input : Requirement_view_definition; id : STRING; reqType : STRING) : SET OF Predefined_requirement_view_definition; 
LOCAL
    rvdr : SET[0:?] OF Requirement_view_definition_relationship := [];
    rdp : SET[0:?] OF Predefined_requirement_view_definition := [];  --this gives us access to the information base
END_LOCAL;
	rvdr := bag_to_set(QUERY(rvdre <* USEDIN (input, 'REQUIREMENT_DECOMPOSITION_ARM.'+ 'REQUIREMENT_VIEW_DEFINITION_RELATIONSHIP.SECONDARY')|
	                           ((rvdre.relation_type = id) AND (reqType IN TYPEOF(rvdre.primary)))
                       ));
	-- iterate over rvdr
	REPEAT i := 1 to SIZEOF(rvdr) by 1;
      rdp := rdp + rvdr[i].primary;
	END_REPEAT;

	RETURN(rdp);
END_FUNCTION;
	
END_SCHEMA;
