Exemple #1
0
        public static PetriNet Parse(string file)
        {
            string[] lines = File.ReadAllLines(file);

            var net = new PetriNet();
            net.PlacesCount = int.Parse(lines[0]);
            net.TransitionsCount = int.Parse(lines[1]);
            net.WeightMatrix = new WeightElement[net.PlacesCount, net.TransitionsCount];

            int k = int.Parse(lines[2]);
            for (int i = 3; i < k+3; i++)
            {
                var parts = lines[i].Split(new[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries);

                if (parts.Length != 3)
                {
                    throw new FormatException(string.Format("Incorrect file format. Arcs arguments are not correct. Line {0}", k));
                }

                var arcType = (ArcType)Enum.Parse(typeof(ArcType), (parts[0][0].ToString()+parts[1][0].ToString()).ToUpperInvariant());
                int p = int.Parse(parts[arcType == ArcType.PT ? 0 : 1].Substring(1));
                int t = int.Parse(parts[arcType == ArcType.PT ? 1 : 0].Substring(1));

                if (net.WeightMatrix[p, t] == null)
                    net.WeightMatrix[p, t] = new WeightElement();

                if (arcType == ArcType.PT)
                    net.WeightMatrix[p, t].PT = int.Parse(parts[2]);
                else
                    net.WeightMatrix[p, t].TP = int.Parse(parts[2]);
            }

            net.InitialMarking = new Vector(net.PlacesCount);
            var m0 = lines[k+3].Split(new[] { ' ' }, System.StringSplitOptions.RemoveEmptyEntries);
            for (int i = 0; i < m0.Length; i++)
            {
                net.InitialMarking[i] = int.Parse(m0[i]);
            }
            net.BuildIncedentMatrix();
            return net;
        }
Exemple #2
0
 public TreeBuilderBase(PetriNet petriNet)
 {
     PetriNet = petriNet;
 }
 public CoverageTreeBuilder(PetriNet petriNet)
     : base(petriNet)
 {
 }
Exemple #4
0
        private void UploadButton_Click(object sender, EventArgs e)
        {
            var ofd = new OpenFileDialog();

            if(ofd.ShowDialog()==DialogResult.OK)
            {
                if (File.Exists(ofd.FileName))
                {
                    _petriNet = PetriNet.Parse(ofd.FileName);
                }
            }
        }