/// <summary>Parse and load pnml file.</summary> public static PetriNet loadFromFile(string file, int id) { PetriNet pn = PnmlParser.loadFromPath(file); pn.attachID(id); return(pn); }
internal void computeUniqueId() { mut.WaitOne(); try { MonitoringManager mm = MonitoringManager.Instance; // Check if we have to compute a new Id. if (id == -1) { // Get all used ids List <int> ids = new List <int>(); foreach (ComponentMonitoring _cm in mm.c_monitors) { if (_cm) { ids.Add(_cm.id); } } foreach (FamilyMonitoring _fm in mm.f_monitors) { if (_fm) { ids.Add(_fm.id); } } ids.Sort(); // Find the first hole available int newId = 0; int iterationLength = ids.Count + 1; for (; newId < iterationLength; newId++) { if (!ids.Contains(newId)) { break; } } id = newId; // update id of petrinet if (petriNet != null) { petriNet.attachID(id); } } // register this monitor mm.registerMonitor(this); } catch (Exception e) { mut.ReleaseMutex(); throw e; } mut.ReleaseMutex(); }