Exemplo n.º 1
0
 /// <summary>
 /// Write FaultTree into file.
 /// </summary>
 /// <param name="ft">The Fault Tree</param>
 /// <param name="fileName">The file to be written.</param>
 public void Write(FaultTree ft, string fileName)
 {
     using (var stream = new FileStream(fileName, FileMode.Create))
     {
         this.Write(ft, stream);
     }
 }
Exemplo n.º 2
0
        private static void Main()
        {
            List <string> files = new List <string>(Directory.GetFiles("examples")).Where(f => new Regex(@".*-ft.dot$").IsMatch(f)).ToList();

            foreach (string s in files.Take(1))
            {
                Console.WriteLine("Converting tree " + s);

                IFaultTreeCodec     codec = FaultTreeEncoderFactory.CreateFaultTreeCodec(s);
                FaultTree.FaultTree ft    = codec.Read(s);

                //ft = ft.deepCopy().replace(1, false).simplify();

                //IFaultTreeCodec xmlCodec = FaultTreeEncoderFactory.createFaultTreeCodec(FaultTreeFormat.FAULT_TREE_XML);
                //xmlCodec.write(ft, s + ".xml");

                BDDNode test = BDDFactory.GetComponentConnectionInstance().CreateBDD(ft);
                Console.WriteLine("Successfully converted tree");

                IBDDCodec bCodec = BDDEncoderFactory.CreateFaultTreeCodec(s + ".dot");
                bCodec.Write(new BinaryDecisionDiagram(test), s + ".dot");
            }
            Console.WriteLine("Finished construction");
            Console.ReadKey();
        }
Exemplo n.º 3
0
        /// <summary>
        /// Writes Fault Tree to stream
        /// </summary>
        /// <param name="ft">
        /// The Fault Tree.
        /// </param>
        /// <param name="stream">
        /// The stream.
        /// </param>
        public override void Write(FaultTree ft, FileStream stream)
        {
            var listOfNodes = (from lAssembly in AppDomain.CurrentDomain.GetAssemblies()
                               from lType in lAssembly.GetTypes()
                               where typeof(FaultTreeNode).IsAssignableFrom(lType)
                               select lType).ToArray();
            var setting = new DataContractSerializerSettings {
                PreserveObjectReferences = true, KnownTypes = listOfNodes
            };

            var xmlSettings = new XmlWriterSettings {
                Indent = true
            };

            var serializer = new DataContractSerializer(typeof(FaultTree), setting);

            using (XmlWriter w = XmlWriter.Create(stream, xmlSettings))
            {
                serializer.WriteObject(XmlWriter.Create(w, xmlSettings), ft);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Write FaultTree into stream.
 /// </summary>
 /// <param name="ft">
 /// The FaultTree.
 /// </param>
 /// <param name="stream">
 /// The stream the Fault Tree is written to.
 /// </param>
 public abstract void Write(FaultTree ft, FileStream stream);
 public override void Write(FaultTree ft, FileStream stream)
 {
     throw new NotImplementedException();
 }