Example #1
0
        private void TransformChanges(string pcmModel, string changes, string target, Action <Root_MM06, Root_MM06> compareResults)
        {
            var repository  = new ModelRepository();
            var model       = repository.Resolve(pcmModel + ".xmi");
            var targetModel = PcmToComponentBasedSystems.Transform(model, NMF.Transformations.ChangePropagationMode.OneWay);
            var targetRoot  = targetModel.RootElements[0] as Root_MM06;

            repository.Save(targetModel, string.Format(target, "initial"));

            for (int i = 0; i < PcmChangeGenerator.NumChanges; i++)
            {
                var change   = repository.Resolve(string.Format(changes, i)).RootElements[0] as ModelChangeSet;
                var recorder = new ModelChangeRecorder();
                recorder.Start(targetModel);
                foreach (var subChange in change.Changes)
                {
                    subChange.Apply();
                }
                recorder.Stop();
                if (compareResults != null)
                {
                    compareResults(targetRoot, PcmToComponentBasedSystems.Transform(model, NMF.Transformations.ChangePropagationMode.None).RootElements[0] as Root_MM06);
                }
                var targetChange = recorder.GetModelChanges();
                repository.Save(targetChange, string.Format(target, i));
            }
        }
Example #2
0
        public void RecordListInsertionComposition()
        {
            var semaphore = new Semaphore {
                Signal = Signal.STOP
            };
            var rec = new ModelChangeRecorder();

            rec.Start(railway);

            railway.Semaphores.Insert(0, semaphore);

            var expected = new ChangeTransaction()
            {
                SourceChange = new ListInsertionComposition <ISemaphore>(railway.AbsoluteUri, "Semaphores", 0, new List <ISemaphore>()
                {
                    semaphore
                }),
                NestedChanges = new List <IModelChange>()
                {
                    new ElementCreation(semaphore)
                }
            };
            var actual = rec.GetModelChanges().Changes[0];

            Assert.AreEqual(expected, actual);
        }
Example #3
0
        public void SerializationIntegration()
        {
            //Load the model
            var repository = new ModelRepository();
            var model      = LoadRailwayModel(repository);

            //Create the recorder
            var recorder = new ModelChangeRecorder();

            recorder.Start(model);

            //Change the model
            var route = new Route()
            {
                Id = 42
            };

            model.Routes.Add(route);
            model.Routes[0].DefinedBy.RemoveAt(0);
            model.Routes[0].DefinedBy[0].Elements.RemoveAt(0);
            model.Semaphores[0].Signal = Signal.FAILURE;

            //Parse the changes
            var changes = recorder.GetModelChanges();

            //Serialize the changes
            var file = System.IO.Path.GetTempFileName();

            try
            {
                repository.Save(changes, file);

                var xmi = File.ReadAllText(file);

                //Load second instance of the model
                var newRepository = new ModelRepository();
                var newModel      = LoadRailwayModel(newRepository);

                //Deserialize the XMI
                var newChangesModel = newRepository.Resolve(file);
                var newChanges      = newChangesModel.RootElements[0] as ModelChangeSet;

                Assert.IsNotNull(newChanges);


                //Apply changes to the new model
                newChanges.Apply();

                Assert.AreEqual(model.Routes.Count, newModel.Routes.Count);
                Assert.AreEqual(model.Routes[0].DefinedBy.Count, newModel.Routes[0].DefinedBy.Count);
                Assert.AreEqual(model.Routes[0].DefinedBy[0].Elements.Count, newModel.Routes[0].DefinedBy[0].Elements.Count);
                Assert.AreEqual(model.Semaphores[0].Signal, newModel.Semaphores[0].Signal);
            }
            finally
            {
                File.Delete(file);
            }
        }
Example #4
0
        public void SerializationIntegration()
        {
            //Load the model
            var repository = new ModelRepository();
            var model = LoadRailwayModel(repository);

            //Create the recorder
            var recorder = new ModelChangeRecorder();
            recorder.Start(model);

            //Change the model
            var route = new Route() { Id = 42 };
            model.Routes.Add(route);
            model.Routes[0].DefinedBy.RemoveAt(0);
            model.Routes[0].DefinedBy[0].Elements.RemoveAt(0);
            model.Semaphores[0].Signal = Signal.FAILURE;

            //Parse the changes
            var changes = recorder.GetModelChanges();

            //Serialize the changes
            var types = changes.TraverseFlat().Select(t => t.GetType()).Distinct();
            var serializer = new XmiSerializer(types);
            string xmi;
            using (var writer = new StringWriter())
            {
                serializer.Serialize(changes, writer);
                xmi = writer.ToString();
            }

            //Deserialize the XMI
            ModelChangeCollection newChanges;
            using (var reader = new StringReader(xmi))
            {
                newChanges = serializer.Deserialize(reader) as ModelChangeCollection;
            }

            Assert.IsNotNull(newChanges);
            //Since model elements don't implement Equals() we can only test for property equality
            var newRoute = ((ListInsertionComposition<IRoute>)((ChangeTransaction)newChanges.Changes[0]).SourceChange).NewElements[0];
            Assert.AreEqual(route.Id, newRoute.Id);
            //We have to leave out the changes with model elements in them when tesing for equality
            CollectionAssert.AreEqual(changes.Changes.Skip(1).ToArray(), newChanges.Changes.Skip(1).ToArray());

            //Load second instance of the model
            var newRepository = new ModelRepository();
            var newModel = LoadRailwayModel(newRepository);

            //Apply changes to the new model
            newChanges.Apply(newRepository);

            Assert.AreEqual(model.Routes.Count, newModel.Routes.Count);
            Assert.AreEqual(model.Routes[0].DefinedBy.Count, newModel.Routes[0].DefinedBy.Count);
            Assert.AreEqual(model.Routes[0].DefinedBy[0].Elements.Count, newModel.Routes[0].DefinedBy[0].Elements.Count);
            Assert.AreEqual(model.Semaphores[0].Signal, newModel.Semaphores[0].Signal);
        }
Example #5
0
 public ModelTransaction(IModelElement rootElement)
 {
     if (rootElement == null)
     {
         throw new ArgumentNullException(nameof(rootElement));
     }
     _repository = rootElement.Model.Repository;
     _recorder.Start(rootElement);
     _engine.BeginTransaction();
 }
Example #6
0
        private ModelChangeSet GetDiff <T>(T from, T to)
            where T : class, IModelElement
        {
            var recorder = new ModelChangeRecorder(false);

            recorder.Start(from);
            transformation.Synchronize(ref from, ref to, SynchronizationDirection.RightToLeftForced, ChangePropagationMode.None);
            recorder.Stop();
            return(recorder.GetModelChanges());
        }
Example #7
0
        public void RecordListDeletion()
        {
            var rec = new ModelChangeRecorder();
            rec.Start(railway);

            railway.Semaphores.RemoveAt(0);

            var expected = new ListDeletion(railway.AbsoluteUri, "Semaphores", 0, 1);
            var actual = ((ChangeTransaction)rec.GetModelChanges().Changes[0]).SourceChange;
            Assert.AreEqual(expected, actual);
        }
Example #8
0
        public void OperationDoesNotDoAnything()
        {
            var recorder = new ModelChangeRecorder();

            recorder.Start(model);
            b.PullUpFeature("no such feature");
            recorder.Stop();
            var changes = recorder.GetModelChanges();

            Assert.AreEqual(1, changes.Changes.Count);
            Assert.IsInstanceOfType(changes.Changes[0], typeof(OperationCall));
        }
Example #9
0
        public void RecordElementDeletion()
        {
            var toDelete = railway.Routes[0];
            var rec      = new ModelChangeRecorder();

            rec.Start(railway);

            toDelete.Delete();

            //var actual = ((ChangeTransaction)rec.GetModelChanges().Changes[0]).SourceChange;
            //Assert.AreEqual(expected, actual);
        }
Example #10
0
        public void RecordListClear()
        {
            var parent = railway.Routes[0].DefinedBy[0].Elements[0];
            var rec = new ModelChangeRecorder();
            rec.Start(railway);

            parent.ConnectsTo.Clear();

            var expected = new ListDeletion(parent.AbsoluteUri, "ConnectsTo", 0, int.MaxValue);
            var actual = rec.GetModelChanges().Changes[0];
            Assert.AreEqual(expected, actual);
        }
Example #11
0
        public void RecordElementDeletion()
        {
            var toDelete = railway.Routes[0];
            var expected = new ElementDeletion(toDelete.AbsoluteUri);
            var rec = new ModelChangeRecorder();
            rec.Start(railway);

            toDelete.Delete();

            var actual = ((ChangeTransaction)rec.GetModelChanges().Changes[0]).SourceChange;
            Assert.AreEqual(expected, actual);
        }
Example #12
0
        public void RecordListClear()
        {
            var parent = railway.Routes[0].DefinedBy[0].Elements[0];
            var rec    = new ModelChangeRecorder();

            rec.Start(railway);

            parent.ConnectsTo.Clear();

            var actual = rec.GetModelChanges().Changes.Single();

            Assert.IsInstanceOfType(actual, typeof(AssociationCollectionReset));
        }
Example #13
0
        public void RecordListClear()
        {
            var parent = railway.Routes[0].DefinedBy[0].Elements[0];
            var rec    = new ModelChangeRecorder();

            rec.Start(railway);

            parent.ConnectsTo.Clear();

            //var expected = new CollectionResetAssociation<ITrackElement>(parent.AbsoluteUri, "ConnectsTo", new List<Uri>());
            //var actual = rec.GetModelChanges().Changes[0];
            //Assert.AreEqual(expected, actual);
        }
Example #14
0
        public void RecordListDeletionAssociation()
        {
            var parent = railway.Routes[0].DefinedBy[0].Elements[0];
            var rec    = new ModelChangeRecorder();

            rec.Start(railway);

            parent.ConnectsTo.RemoveAt(0);
            var actual = rec.GetModelChanges().Changes;

            Assert.AreEqual(1, actual.Count);
            Assert.IsInstanceOfType(actual.Single(), typeof(AssociationListDeletion));
        }
Example #15
0
        public void RecordListDeletion()
        {
            var rec = new ModelChangeRecorder();

            rec.Start(railway);

            railway.Semaphores.RemoveAt(0);

            var expected = new ListDeletion(railway.AbsoluteUri, "Semaphores", 0, 1);
            var actual   = ((ChangeTransaction)rec.GetModelChanges().Changes[0]).SourceChange;

            Assert.AreEqual(expected, actual);
        }
Example #16
0
        public void RecordPropertyChangeReference()
        {
            var parent = railway.Routes[0];
            var rec    = new ModelChangeRecorder();

            rec.Start(railway);

            parent.Entry = railway.Semaphores[0];

            var expected = new PropertyChangeReference <ISemaphore>(parent.AbsoluteUri, "Entry", railway.Semaphores[0].AbsoluteUri);
            var actual   = rec.GetModelChanges().Changes[0];

            Assert.AreEqual(expected, actual);
        }
Example #17
0
        public void RecordListInsertionAssociation()
        {
            var parent  = railway.Routes[0].DefinedBy[0].Elements[0];
            var newItem = railway.Routes[0].DefinedBy[1].Elements[0];
            var rec     = new ModelChangeRecorder();

            rec.Start(railway);

            parent.ConnectsTo.Insert(0, newItem);

            var actual = rec.GetModelChanges().Changes.Single();

            Assert.IsInstanceOfType(actual, typeof(AssociationListInsertion));
        }
Example #18
0
        public void RecordListClear()
        {
            var parent = railway.Routes[0].DefinedBy[0].Elements[0];
            var rec    = new ModelChangeRecorder();

            rec.Start(railway);

            parent.ConnectsTo.Clear();

            var expected = new ListDeletion(parent.AbsoluteUri, "ConnectsTo", 0, int.MaxValue);
            var actual   = rec.GetModelChanges().Changes[0];

            Assert.AreEqual(expected, actual);
        }
Example #19
0
        public void RecordPropertyChangeAttribute()
        {
            var semaphore = railway.Semaphores[0];
            var rec       = new ModelChangeRecorder();

            rec.Start(railway);

            semaphore.Signal = Signal.FAILURE;

            var expected = new PropertyChangeAttribute <Signal>(semaphore.AbsoluteUri, "Signal", Signal.FAILURE);
            var actual   = rec.GetModelChanges().Changes[0];

            Assert.AreEqual(expected, actual);
        }
Example #20
0
        public void RecordElementDeletion()
        {
            var toDelete = railway.Routes[0];
            var rec      = new ModelChangeRecorder();

            rec.Start(railway);

            toDelete.Delete();

            // deleting a route means that a range of elements are deleted, so we see several changes that an association was deleted
            // only the last one is the actual deletion from the composition
            var actual = rec.GetModelChanges().Changes.Last();

            Assert.IsInstanceOfType(actual, typeof(CompositionListDeletion));
        }
Example #21
0
        public void RecordListInsertionComposition()
        {
            var semaphore = new Semaphore {
                Signal = Signal.STOP
            };
            var rec = new ModelChangeRecorder();

            rec.Start(railway);

            railway.Semaphores.Insert(0, semaphore);

            var actual = rec.GetModelChanges().Changes.Single();

            Assert.IsInstanceOfType(actual, typeof(CompositionListInsertion));
        }
Example #22
0
        public void RecordListDeletionComposition()
        {
            var rec = new ModelChangeRecorder();

            rec.Start(railway);

            railway.Semaphores.RemoveAt(0);

            var actual = rec.GetModelChanges().Changes[0];

            Assert.IsInstanceOfType(actual, typeof(ChangeTransaction));
            var transaction = actual as ChangeTransaction;

            Assert.IsInstanceOfType(transaction.SourceChange, typeof(CompositionListDeletion));
        }
Example #23
0
        public void RecordListInsertionAssociation()
        {
            var parent = railway.Routes[0].DefinedBy[0].Elements[0];
            var newItem = railway.Routes[0].DefinedBy[1].Elements[0];
            var rec = new ModelChangeRecorder();
            rec.Start(railway);

            parent.ConnectsTo.Insert(0, newItem);

            var expected = new List<IModelChange>()
            {
                new ListInsertionAssociation<ITrackElement>(parent.AbsoluteUri, "ConnectsTo", 0, new List<Uri>() { newItem.AbsoluteUri })
            };
            var actual = rec.GetModelChanges().Changes;
            CollectionAssert.AreEqual(expected, actual);
        }
Example #24
0
 private static void StartNextRecorder(Model model, string target, bool last, ref int i, ref ModelChangeRecorder recorder)
 {
     if (target != null)
     {
         if (recorder != null)
         {
             recorder.Stop();
             var changes = recorder.GetModelChanges();
             (model.Repository as ModelRepository).Save(changes, string.Format(target, i++));
         }
         if (!last)
         {
             recorder = new ModelChangeRecorder();
             recorder.Start(model);
         }
     }
 }
Example #25
0
        public void RecordListInsertionAssociation()
        {
            var parent  = railway.Routes[0].DefinedBy[0].Elements[0];
            var newItem = railway.Routes[0].DefinedBy[1].Elements[0];
            var rec     = new ModelChangeRecorder();

            rec.Start(railway);

            parent.ConnectsTo.Insert(0, newItem);

            //var expected = new List<IModelChange>()
            //{
            //    new ListInsertionAssociation<ITrackElement>(parent.AbsoluteUri, "ConnectsTo", 0, new List<Uri>() { newItem.AbsoluteUri })
            //};
            //var actual = rec.GetModelChanges().Changes;
            //CollectionAssert.AreEqual(expected, actual);
        }
Example #26
0
        public void InvertChangeTransaction()
        {
            var rec = new ModelChangeRecorder(true);

            rec.Start(railway1);

            railway1.Semaphores.RemoveAt(0);
            rec.Stop();
            var changes = rec.GetModelChanges().Changes[0];

            foreach (var inverted in changes.Invert())
            {
                inverted.Apply();
            }

            Assert.AreEqual(railway1.Semaphores.Count, railway2.Semaphores.Count);
        }
Example #27
0
        public void TestPullUpInverted()
        {
            var method   = b.Encapsulates[0];
            var recorder = new ModelChangeRecorder();

            recorder.Start(model);
            b.PullUpFeature("b");
            recorder.Stop();
            var changes = recorder.GetModelChanges();

            Assert.AreEqual(0, b.Encapsulates.Count);

            changes.Invert();

            Assert.AreEqual(1, b.Encapsulates.Count);
            Assert.AreEqual(method, b.Encapsulates[0]);
        }
Example #28
0
        public void RecordPropertyChangeReference()
        {
            var parent = railway.Routes[0];
            var rec    = new ModelChangeRecorder();

            rec.Start(railway);

            parent.Entry = railway.Semaphores[0];

            var actual = rec.GetModelChanges().Changes[0];

            Assert.IsInstanceOfType(actual, typeof(AssociationPropertyChange));
            var change = actual as AssociationPropertyChange;

            Assert.AreSame(parent, change.AffectedElement);
            Assert.AreEqual("entry", change.Feature.Name);
            Assert.AreEqual(railway.Semaphores[0], change.NewValue);
        }
Example #29
0
        public void TestPullUpCorrectlyRecorded()
        {
            var recorder = new ModelChangeRecorder();

            recorder.Start(model);
            b.PullUpFeature("b");
            recorder.Stop();
            var changes = recorder.GetModelChanges();

            Assert.AreEqual(1, changes.Changes.Count);
            Assert.IsInstanceOfType(changes.Changes[0], typeof(ChangeTransaction));
            var t = changes.Changes[0] as ChangeTransaction;

            Assert.IsInstanceOfType(t.SourceChange, typeof(OperationCall));
            var call = t.SourceChange as OperationCall;

            Assert.AreEqual("b", (call.Arguments[0] as ValueArgument).Value);
        }
Example #30
0
        public void RecordPropertyChangeAttribute()
        {
            var semaphore = railway.Semaphores[0];
            var rec       = new ModelChangeRecorder();

            rec.Start(railway);

            var oldValue = semaphore.Signal;

            semaphore.Signal = Signal.FAILURE;

            var actual = rec.GetModelChanges().Changes[0];

            Assert.IsInstanceOfType(actual, typeof(AttributePropertyChange));
            var change = actual as AttributePropertyChange;

            Assert.AreSame(semaphore, change.AffectedElement);
            Assert.AreEqual("signal", change.Feature.Name);
            Assert.AreEqual(oldValue.ToString(), change.OldValue);
            Assert.AreEqual(Signal.FAILURE.ToString(), change.NewValue);
        }
Example #31
0
        public void SerializationIntegration()
        {
            //Load the model
            var repository = new ModelRepository();
            var model      = LoadRailwayModel(repository);

            //Create the recorder
            var recorder = new ModelChangeRecorder();

            recorder.Start(model);

            //Change the model
            var route = new Route()
            {
                Id = 42
            };

            model.Routes.Add(route);
            model.Routes[0].DefinedBy.RemoveAt(0);
            model.Routes[0].DefinedBy[0].Elements.RemoveAt(0);
            model.Semaphores[0].Signal = Signal.FAILURE;

            //Parse the changes
            var changes = recorder.GetModelChanges();

            //Serialize the changes
            var    types      = changes.TraverseFlat().Select(t => t.GetType()).Distinct();
            var    serializer = new XmiSerializer(types);
            string xmi;

            using (var writer = new StringWriter())
            {
                serializer.Serialize(changes, writer);
                xmi = writer.ToString();
            }

            //Deserialize the XMI
            ModelChangeCollection newChanges;

            using (var reader = new StringReader(xmi))
            {
                newChanges = serializer.Deserialize(reader) as ModelChangeCollection;
            }

            Assert.IsNotNull(newChanges);
            //Since model elements don't implement Equals() we can only test for property equality
            var newRoute = ((ListInsertionComposition <IRoute>)((ChangeTransaction)newChanges.Changes[0]).SourceChange).NewElements[0];

            Assert.AreEqual(route.Id, newRoute.Id);
            //We have to leave out the changes with model elements in them when tesing for equality
            CollectionAssert.AreEqual(changes.Changes.Skip(1).ToArray(), newChanges.Changes.Skip(1).ToArray());

            //Load second instance of the model
            var newRepository = new ModelRepository();
            var newModel      = LoadRailwayModel(newRepository);

            //Apply changes to the new model
            newChanges.Apply(newRepository);

            Assert.AreEqual(model.Routes.Count, newModel.Routes.Count);
            Assert.AreEqual(model.Routes[0].DefinedBy.Count, newModel.Routes[0].DefinedBy.Count);
            Assert.AreEqual(model.Routes[0].DefinedBy[0].Elements.Count, newModel.Routes[0].DefinedBy[0].Elements.Count);
            Assert.AreEqual(model.Semaphores[0].Signal, newModel.Semaphores[0].Signal);
        }
Example #32
0
        public void RecordPropertyChangeAttribute()
        {
            var semaphore = railway.Semaphores[0];
            var rec = new ModelChangeRecorder();
            rec.Start(railway);

            semaphore.Signal = Signal.FAILURE;

            var expected = new PropertyChangeAttribute<Signal>(semaphore.AbsoluteUri, "Signal", Signal.FAILURE);
            var actual = rec.GetModelChanges().Changes[0];
            Assert.AreEqual(expected, actual);
        }
Example #33
0
        public void RecordPropertyChangeReference()
        {
            var parent = railway.Routes[0];
            var rec = new ModelChangeRecorder();
            rec.Start(railway);

            parent.Entry = railway.Semaphores[0];

            var expected = new PropertyChangeReference<ISemaphore>(parent.AbsoluteUri, "Entry", railway.Semaphores[0].AbsoluteUri);
            var actual = rec.GetModelChanges().Changes[0];
            Assert.AreEqual(expected, actual);
        }
Example #34
0
        public void RecordListInsertionComposition()
        {
            var semaphore = new Semaphore { Signal = Signal.STOP };
            var rec = new ModelChangeRecorder();
            rec.Start(railway);

            railway.Semaphores.Insert(0, semaphore);

            var expected = new ChangeTransaction()
            {
                SourceChange = new ListInsertionComposition<ISemaphore>(railway.AbsoluteUri, "Semaphores", 0, new List<ISemaphore>() { semaphore }),
                NestedChanges = new List<IModelChange>() { new ElementCreation(semaphore) }
            };
            var actual = rec.GetModelChanges().Changes[0];
            Assert.AreEqual(expected, actual);
        }
Example #35
0
        internal void GenerateChanges(Options options)
        {
            Console.WriteLine("Initializing repository");
            var repository = new ModelRepository();

            Console.WriteLine("Loading CIM model");
            cim = repository.Resolve(options.CimPath).RootElements[0] as CIM.CIMRoot;
            Console.WriteLine("Loading COSEM model");
            cosem = repository.Resolve(options.CosemPath).RootElements[0] as COSEM.COSEMRoot;
            Console.WriteLine("Loading Substandard model");
            substation = repository.Resolve(options.SubstationPath).RootElements[0] as SubstationStandard.Substandard;

            Console.WriteLine("Performing changes");

            var actions = new Action[]
            {
                ToggleRandomConnection,
                IncreaseRandomElectricityValues,
                CreateNewMeterAsset,
                DeleteMeterAsset,

                IncreaseMMXUVoltage,
                CreateMMXU,
                ChangeMMXULocation,
                ChangePosition
            };

            var probabilities = new int[]
            {
                10,
                30,
                10,
                10,

                20,
                10,
                5,
                5
            };

            var sum = probabilities.Sum();

            CreateDirectory(options.CimOutPath);
            CreateDirectory(options.CosemOutPath);
            CreateDirectory(options.SubstationOutPath);

            Console.WriteLine("Saving modified CIM model");
            var cimPath = options.CimOutPath + string.Format("-out{0:000}.xmi", 0);

            repository.Save(cim, cimPath);
            cim.Model.ModelUri = new Uri(Path.GetFullPath(cimPath));
            Console.WriteLine("Saving modified COSEM model");
            var cosemPath = options.CosemOutPath + string.Format("-out{0:000}.xmi", 0);

            repository.Save(cosem, cosemPath);
            cosem.Model.ModelUri = new Uri(Path.GetFullPath(cosemPath));
            Console.WriteLine("Saving modified Substandard model");
            var subStandardPath = options.SubstationOutPath + string.Format("-out{0:000}.xmi", 0);

            repository.Save(substation, subStandardPath);
            substation.Model.ModelUri = new Uri(Path.GetFullPath(subStandardPath));

            for (int d = 1; d <= options.Deltas; d++)
            {
                var cimRecorder        = new ModelChangeRecorder();
                var cosemRecorder      = new ModelChangeRecorder();
                var substationRecorder = new ModelChangeRecorder();

                cimRecorder.Start(cim);
                cosemRecorder.Start(cosem);
                substationRecorder.Start(substation);

                Console.WriteLine($"Generating change {d}");
                for (int i = 0; i < options.Changes; i++)
                {
                    var dice = rnd.Next(sum);
                    for (int j = 0; j < actions.Length; j++)
                    {
                        if (dice < probabilities[j])
                        {
                            actions[j]();
                            break;
                        }
                        else
                        {
                            dice -= probabilities[j];
                        }
                    }
                }

                cimRecorder.Stop();
                cosemRecorder.Stop();
                substationRecorder.Stop();

                Console.WriteLine("Saving modified CIM model");
                repository.Serializer.Serialize(cim, options.CimOutPath + string.Format("-out{0:000}.xmi", d));
                Console.WriteLine("Saving modified COSEM model");
                repository.Serializer.Serialize(cosem, options.CosemOutPath + string.Format("-out{0:000}.xmi", d));
                Console.WriteLine("Saving modified Substandard model");
                repository.Serializer.Serialize(substation, options.SubstationOutPath + string.Format("-out{0:000}.xmi", d));

                Console.WriteLine("Saving CIM changes");
                repository.Save(cimRecorder.GetModelChanges(), options.CimOutPath + string.Format("-delta{0:000}.xmi", d));
                Console.WriteLine("Saving COSEM changes");
                repository.Save(cosemRecorder.GetModelChanges(), options.CosemOutPath + string.Format("-delta{0:000}.xmi", d));
                Console.WriteLine("Saving Substandard changes");
                repository.Save(substationRecorder.GetModelChanges(), options.SubstationOutPath + string.Format("-delta{0:000}.xmi", d));
            }
        }