Esempio n. 1
0
 public static void ProtoSaveToFile(object sender, DoWorkEventArgs e)
 {
     try
     {
         worker = sender as BackgroundWorker;
         string       filename = e.Argument as string;
         SaveLoadData data     = new SaveLoadData();
         data.railml = XML.ToXElement <railml>(Data.DataContainer.model).ToString();
         data.NN     = DataContainer.NeuralNetwork;
         if (DataContainer.NeuralNetwork.Network != null)
         {
             data.network = SerializeNetwork();
         }
         if (DataContainer.NeuralNetwork.Data != null)
         {
             data.trainingset = SerializeDataSet();
         }
         MyStream stream = new MyStream(filename, FileMode.Create, FileAccess.Write);
         stream.ProgressChanged += new ProgressChangedEventHandler(Save_ProgressChanged);
         Serializer.Serialize(stream, data);
         stream.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex + "      Inner Exception: " + ex.InnerException);
         worker.ReportProgress(1, ex + "      Inner Exception: " + ex.InnerException);
     }
 }
Esempio n. 2
0
        public static void LoadFile(object sender, DoWorkEventArgs e)
        {
            worker = sender as BackgroundWorker;
            string   filename = e.Argument as string;
            MyStream stream   = new MyStream(filename, FileMode.Open, FileAccess.Read);

            stream.ProgressChanged += new ProgressChangedEventHandler(Load_ProgressChanged);
            IFormatter   formatter = new BinaryFormatter();
            SaveLoadData data      = (SaveLoadData)formatter.Deserialize(stream);
            XElement     elem      = XElement.Parse(data.railml);

            DataContainer.model         = XML.FromXElement <railml>(elem);
            DataContainer.NeuralNetwork = data.NN;
            stream.Close();
        }
Esempio n. 3
0
        public static void SaveToFile(object sender, DoWorkEventArgs e)
        {
            worker = sender as BackgroundWorker;
            string       filename = e.Argument as string;
            SaveLoadData data     = new SaveLoadData();

            data.railml = XML.ToXElement <railml>(Data.DataContainer.model).ToString();
            data.NN     = DataContainer.NeuralNetwork;
            MyStream stream = new MyStream(filename, FileMode.Create, FileAccess.Write);

            stream.ProgressChanged += new ProgressChangedEventHandler(Save_ProgressChanged);
            IFormatter formatter = new BinaryFormatter();

            formatter.Serialize(stream, data);
            stream.Close();
        }
Esempio n. 4
0
        public static void ProtoLoadFile(object sender, DoWorkEventArgs e)
        {
            worker = sender as BackgroundWorker;
            string   filename = e.Argument as string;
            MyStream stream   = new MyStream(filename, FileMode.Open, FileAccess.Read);

            stream.ProgressChanged += new ProgressChangedEventHandler(Load_ProgressChanged);
            SaveLoadData data = Serializer.Deserialize <SaveLoadData>(stream);
            XElement     elem = XElement.Parse(data.railml);

            DataContainer.model         = XML.FromXElement <railml>(elem);
            DataContainer.NeuralNetwork = data.NN;
            if (data.trainingset != null)
            {
                DataContainer.NeuralNetwork.Data = DeserializeDataSet(data.trainingset);
            }
            if (data.network != null)
            {
                DataContainer.NeuralNetwork.Network = DeserializeNetwork(data.network);
            }
            stream.Close();
        }
Esempio n. 5
0
 public static void SaveToFile(object sender, DoWorkEventArgs e )
 {
     worker = sender as BackgroundWorker;
     string filename = e.Argument as string;
     SaveLoadData data = new SaveLoadData();
     data.railml = XML.ToXElement<railml>(Data.DataContainer.model).ToString();
     data.NN = DataContainer.NeuralNetwork;
     MyStream stream = new MyStream(filename, FileMode.Create, FileAccess.Write);
     stream.ProgressChanged += new ProgressChangedEventHandler(Save_ProgressChanged);
     IFormatter formatter = new BinaryFormatter();
     formatter.Serialize(stream, data);
     stream.Close();
 }
Esempio n. 6
0
 public static void ProtoSaveToFile(object sender, DoWorkEventArgs e)
 {
     try
     {
         worker = sender as BackgroundWorker;
         string filename = e.Argument as string;
         SaveLoadData data = new SaveLoadData();
         data.railml = XML.ToXElement<railml>(Data.DataContainer.model).ToString();
         data.NN = DataContainer.NeuralNetwork;
         if (DataContainer.NeuralNetwork.Network != null) { data.network = SerializeNetwork(); }
         if (DataContainer.NeuralNetwork.Data != null) { data.trainingset = SerializeDataSet(); }
         MyStream stream = new MyStream(filename, FileMode.Create, FileAccess.Write);
         stream.ProgressChanged += new ProgressChangedEventHandler(Save_ProgressChanged);
         Serializer.Serialize(stream, data);
         stream.Close();
     }
     catch(Exception ex)
     {
         MessageBox.Show(ex + "      Inner Exception: " + ex.InnerException);
         worker.ReportProgress(1, ex + "      Inner Exception: " + ex.InnerException);
     }
 }
Esempio n. 7
0
 public static void ProtoLoadFile(object sender, DoWorkEventArgs e)
 {
     worker = sender as BackgroundWorker;
     string filename = e.Argument as string;
     MyStream stream = new MyStream(filename, FileMode.Open, FileAccess.Read);
     stream.ProgressChanged += new ProgressChangedEventHandler(Load_ProgressChanged);
     SaveLoadData data = Serializer.Deserialize<SaveLoadData>(stream);
     XElement elem = XElement.Parse(data.railml);
     DataContainer.model = XML.FromXElement<railml>(elem);
     DataContainer.NeuralNetwork = data.NN;
     if (data.trainingset != null) { DataContainer.NeuralNetwork.Data = DeserializeDataSet(data.trainingset); }
     if (data.network != null) { DataContainer.NeuralNetwork.Network = DeserializeNetwork(data.network); }
     stream.Close();
 }
Esempio n. 8
0
 public static void LoadFile(object sender, DoWorkEventArgs e)
 {
     worker = sender as BackgroundWorker;
     string filename = e.Argument as string;
     MyStream stream = new MyStream(filename, FileMode.Open, FileAccess.Read);
     stream.ProgressChanged += new ProgressChangedEventHandler(Load_ProgressChanged);
     IFormatter formatter = new BinaryFormatter();
     SaveLoadData data = (SaveLoadData)formatter.Deserialize(stream);
     XElement elem = XElement.Parse(data.railml);
     DataContainer.model = XML.FromXElement<railml>(elem);
     DataContainer.NeuralNetwork = data.NN;
     stream.Close();
 }