osate / osate2

Open Source AADL2 Tool Environment
http://osate.org
Eclipse Public License 2.0
36 stars 8 forks source link

units in instance model property values messed up #75

Closed reteprelief closed 12 years ago

reteprelief commented 12 years ago

If a property value has more than one integer or real with units, the units do not get copied correctly into the values in the instance model. The problem is with EcoreUtil.copy used making a copy of the value. Examples are range values or list of numeric values. It only seems to do it if the same numeric values occurs multiple times.

package My_Model
public
with SEI,Timing_Properties,Memory_Properties,ARINC653,Deployment_Properties;
  system S1
  end S1;

  system implementation S1.impl
    subcomponents
      CPU_1: system module.CPU2;
    properties
    -- copies all units correctly when copying with Ecoreutil.copy
--      ARINC653::Partition_Slots => (10 ms, 5 ms, 3 ms, 2 ms) ;
      -- drops units for the 5 ms entries when copying with EcoreUtil.copy
      ARINC653::Partition_Slots => (10 ms, 5 ms, 5 ms, 5 ms);
  end S1.impl;

  system module
  end module;

  system implementation module.CPU2
  end module.CPU2;

end My_Model;
property set ARINC653 is 

--The Partition_Slots property specifies time slot duration for each partition scheduled.
Partition_Slots : list of Time applies to ( processor, virtual processor, system);
end ARINC653;
reteprelief commented 12 years ago

Here is the possible cause: the EcoreUtil Copier uses a hash table and the NumberValue has a hash function that results in the same key for different IntegerValue object with the same numeric value and unit. When filling in the references with copyReferences it simply walks the map and for each original object entry copies the references into the copied object. It does so only for the first instance with the same value and unit since all have the same key.

lwrage commented 12 years ago

Problem was that IntegerLiteral methods equals and hashCode didn't call super methods.