(*
   $Id$
   ISO TC184/SC4/WG12 N4215 - ISO/TS 10303-1756 Conductivity material aspects - EXPRESS ARM
   Supersedes ISO TC184/SC4/WG12 N3654
*)

SCHEMA Conductivity_material_aspects_arm;

	USE FROM Classification_assignment_arm;	-- ISO/TS 10303-1114
	USE FROM Generic_material_aspects_arm;	-- ISO/TS 10303-1681
	USE FROM Part_view_definition_arm;	-- ISO/TS 10303-1023

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

	TYPE cma_classification_item = EXTENSIBLE GENERIC_ENTITY SELECT BASED_ON classification_item WITH
		(Material_identification_with_conductivity_classification);
	END_TYPE;

	TYPE cma_material_item_select = EXTENSIBLE GENERIC_ENTITY SELECT BASED_ON material_item_select WITH
		(Part_view_definition);
	END_TYPE;

	SUBTYPE_CONSTRAINT cma_class_subtypes FOR Class; 
	    (ONEOF (Conductivity_material_property_class,
		 Relative_permeability_material_property_class,
		 Relative_optical_insertion_loss_material_property_class,
		 Relative_permittivity_material_property_class));
	END_SUBTYPE_CONSTRAINT;

	
 ENTITY Conductivity_material_property_class
	ABSTRACT SUPERTYPE OF (ONEOF (Material_electrical_conductivity_class, 
		Material_thermal_conductivity_class))
  SUBTYPE OF (Class);
  WHERE
	WR1: SELF\Class.name IN 
       ['conductive', 'non conductive', 'resistive', 'semi conductive', 'super conductive'];
    WR2: NOT EXISTS(SELF\Class.description);
 END_ENTITY;

 ENTITY Relative_permeability_material_property_class
  SUBTYPE OF (Class);
  WHERE
	WR1: SELF\Class.name IN 
       ['free space permeabilty', 'low permeability', 'medium permeability', 'highly permeable'];
    WR2: NOT EXISTS(SELF\Class.description);
 END_ENTITY;

 ENTITY Relative_optical_insertion_loss_material_property_class
  SUBTYPE OF (Class);
  WHERE
	WR1: SELF\Class.name IN 
       ['vacuum', 'very low loss', 'low loss', 'medium loss', 'high loss'];
    WR2: NOT EXISTS(SELF\Class.description);
 END_ENTITY;

 ENTITY Relative_permittivity_material_property_class
  SUBTYPE OF (Class);
  WHERE
	WR1: SELF\Class.name IN 
       ['vacuum permittivity', 'low permittivity', 'medium permittivity', 'high permittivity'];
    WR2: NOT EXISTS(SELF\Class.description);
 END_ENTITY;

ENTITY Material_electrical_conductivity_class
  SUBTYPE OF (Conductivity_material_property_class);
END_ENTITY;

ENTITY Material_thermal_conductivity_class
  SUBTYPE OF (Conductivity_material_property_class);
END_ENTITY;

 ENTITY Material_identification_with_conductivity_classification
  SUBTYPE OF (Material_identification);
  DERIVE
    electrical_conductivity_classification : STRING := get_cond_class(SELF,'MATERIAL_ELECTRICAL_CONDUCTIVITY_CLASS');
    magnetic_permeability_classification   : STRING := get_cond_class(SELF,'RELATIVE_PERMEABILITY_MATERIAL_PROPERTY_CLASS');
    optical_insertion_loss_classification  : STRING := get_cond_class(SELF,'RELATIVE_OPTICAL_INSERTION_LOSS_MATERIAL_PROPERTY_CLASS');
    thermal_conductivity_classification    : STRING := get_cond_class(SELF,'MATERIAL_THERMAL_CONDUCTIVITY_CLASS');
    dielectric_permittivity_classification : STRING := get_cond_class(SELF,'RELATIVE_PERMITTIVITY_MATERIAL_PROPERTY_CLASS');
  WHERE 	
  	WR1: (SIZEOF(QUERY(ca <* USEDIN(SELF,
	 	'CLASSIFICATION_ASSIGNMENT_ARM.' + 
	 	'CLASSIFICATION_ASSIGNMENT.' + 'ITEMS') |
	 	('CONDUCTIVITY_MATERIAL_ASPECTS_ARM.'+
	 	'MATERIAL_ELECTRICAL_CONDUCTIVITY_CLASS' IN TYPEOF (ca.assigned_class)))) = 1);
  	WR2: (SIZEOF(QUERY(ca <* USEDIN(SELF,
	 	'CLASSIFICATION_ASSIGNMENT_ARM.' + 
	 	'CLASSIFICATION_ASSIGNMENT.' + 'ITEMS') |
	 	('CONDUCTIVITY_MATERIAL_ASPECTS_ARM.'+
	 	'MATERIAL_THERMAL_CONDUCTIVITY_CLASS' IN TYPEOF (ca.assigned_class)))) <= 1);
  	WR3: (SIZEOF(QUERY(ca <* USEDIN(SELF,
	 	'CLASSIFICATION_ASSIGNMENT_ARM.' + 
	 	'CLASSIFICATION_ASSIGNMENT.' + 'ITEMS') |
	 	('CONDUCTIVITY_MATERIAL_ASPECTS_ARM.'+
	 	'RELATIVE_PERMEABILITY_MATERIAL_PROPERTY_CLASS' IN TYPEOF (ca.assigned_class)))) <= 1);
  	WR4: (SIZEOF(QUERY(ca <* USEDIN(SELF,
	 	'CLASSIFICATION_ASSIGNMENT_ARM.' + 
	 	'CLASSIFICATION_ASSIGNMENT.' + 'ITEMS') |
	 	('CONDUCTIVITY_MATERIAL_ASPECTS_ARM.'+
	 	'RELATIVE_PERMITTIVITY_MATERIAL_PROPERTY_CLASS' IN TYPEOF (ca.assigned_class)))) <= 1);
  	WR5: (SIZEOF(QUERY(ca <* USEDIN(SELF,
	 	'CLASSIFICATION_ASSIGNMENT_ARM.' + 
	 	'CLASSIFICATION_ASSIGNMENT.' + 'ITEMS') |
	 	('CONDUCTIVITY_MATERIAL_ASPECTS_ARM.'+
	 	'RELATIVE_OPTICAL_INSERTION_LOSS_MATERIAL_PROPERTY_CLASS' IN TYPEOF (ca.assigned_class)))) <= 1);
 END_ENTITY;
 
 FUNCTION get_cond_class(input1 : Material_identification_with_conductivity_classification;
                         input2 : STRING) : STRING;
 LOCAL
  car : SET OF Classification_assignment := [];
 END_LOCAL;
  car := QUERY(ca <* bag_to_set(USEDIN(input1,
	 	'CLASSIFICATION_ASSIGNMENT_ARM.' + 
	 	'CLASSIFICATION_ASSIGNMENT.' + 'ITEMS')) |
	 	('CONDUCTIVITY_MATERIAL_ASPECTS_ARM.'+
	 	input2 IN TYPEOF (ca.assigned_class)));
 IF SIZEOF(car) = 1
  THEN
    RETURN(car[1].assigned_class\class.name);
  ELSE
    RETURN('?');
 END_IF;
 END_FUNCTION;
 
 END_SCHEMA;
