Exemple #1
0
        private void loadNetworkToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (ofd.ShowDialog() == DialogResult.OK && File.Exists(ofd.FileName))
            {
                try
                {
                    nw = SFNetworkOscillator.Debinarize(ofd.FileName);

                    // вот эта лажа - попытка линейно интерполировать значения между 2 значениями фаз.. работает, но качественно получается плохой результат
                    double n = 1;
                    for (int i = 0; i < nw.States.Count / n - 1; i++)
                    {
                        SFNetworkOscillatorState d  = nw.States[(int)(i * n)];
                        SFNetworkOscillatorState d2 = nw.States[(int)(i * n) + 1];
                        for (int j = 1; j < n; j++)
                        {
                            double   time = d.Time + (d2.Time - d.Time) / n * j;
                            double[] phs  = new double[d.Phases.Length];
                            for (int k = 0; k < phs.Length; k++)
                            {
                                phs[k] = d.Phases[k] + (d2.Phases[k] - d.Phases[k]) / n * j;
                            }
                            SFNetworkOscillatorState st = new SFNetworkOscillatorState(time, phs);
                            nw.States.Insert(i * (int)(n) + j, st);
                        }
                    }

                    VisualizeNetwork();
                    InitializeMacro();
                    InitializeHist();
                }
                catch (Exception ex) { MessageBox.Show("Error occured while loading file: " + ex.Message, "Loading error"); }
            }
        }
Exemple #2
0
        private void nwopenToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (ofd.ShowDialog() == DialogResult.OK && File.Exists(ofd.FileName))
            {
                try
                {
                    foreach (string fn in ofd.FileNames)
                    {
                        SFNetworkOscillator nw  = SFNetworkOscillator.Debinarize(fn);
                        SFNWOscGraph        nwg = new SFNWOscGraph(nw, fn, Color.Red, Color.Blue);
                        networks.Add(nwg);

                        listBox1.Items.Clear();
                        foreach (SFNWOscGraph i in networks)
                        {
                            listBox1.Items.Add(i);
                        }

                        OnNetworkOpened?.Invoke(this, nwg);
                    }
                }
                catch (Exception ex) { MessageBox.Show("Error occured while loading file: " + ex.Message, "Loading error"); }
            }
        }