Exemplo n.º 1
0
        public ViewModel()
        {
            _curr4Draw = new RobotDynamics();
            _curr4Draw.Rebuild();
            Model1Rx = new VMPropRx <PlotModel, SolPoint>(() => {
                var Model1 = GetNewModel("params", "X", "Y");
                bSer       = new LineSeries()
                {
                    Title = "Body",
                    // StrokeThickness = 2,
                    Color = OxyColors.Green
                };
                Model1.Series.Add(bSer);

                return(Model1);
            },
                                                          (sp, pm) => {
                _curr4Draw.SynchMeTo(sp);
                Draw(sp.T, pm);
                return(pm);
            }
                                                          );

            SolPointList = new VMPropRx <List <SolPoint>, SolPoint>(
                () => new List <SolPoint>(),
                (sp, lst) => {
                lst.Add(sp);
                return(lst);
            });
        }
Exemplo n.º 2
0
        private void button_Save_Click_1(object sender, RoutedEventArgs e)
        {
            controller.Pause();
            button.Content = "Paused";
            var unit4save = new RobotDynamics();

            unit4save.Rebuild();

            int newVal = (int)slider.Value;
            int index  = newVal < vm.SolPointList.Value.Count ? newVal : vm.SolPointList.Value.Count - 1;

            if (index < 0)
            {
                return;
            }
            unit4save.SynchMeTo(vm.SolPointList.Value[index]);
            var sd = new SaveFileDialog()
            {
                Filter   = "XML Files|*.xml",
                FileName = "sph1D"
            };

            if (sd.ShowDialog() == true)
            {
                var sw = new StreamWriter(sd.FileName);
                unit4save.Serialize(sw);
                sw.Close();
            }
        }
Exemplo n.º 3
0
        public MainWindow()
        {
            vm          = new ViewModel();
            DataContext = vm;
            InitializeComponent();

            var sol = new RobotDynamics();

            sol.Body.Vec3D = new Sharp3D.Math.Core.Vector3D(10, 1, 10);
            sol.floor      = new RbSurfFloor(100, 100, new Sharp3D.Math.Core.Vector3D(1, 0, 1));
            sol.Body.AddForce(new Force(0.1, new Position3D(1, 2, 3), new Position3D(1, 1, 1), null));
            sol.Body.AddForce(new Force(0.1, new Position3D(-1, -2, -3), new Position3D(-1, -1, -1), null));
            sol.Body.AddForce(new ForceCenter(1, new Position3D(0, -1, 0), null));
            initObs(sol);//(0.001875+0.0075) * 0.5


            var trackbarch = Observable.FromEventPattern <RoutedPropertyChangedEventArgs <double> >(slider, "ValueChanged").Select(i => {
                int newVal = (int)i.EventArgs.NewValue;
                int index  = newVal < vm.SolPointList.Value.Count ? newVal : vm.SolPointList.Value.Count - 1;
                return(index);
            }).Publish();

            trackbarch.Subscribe(i => {
                if (i < 0)
                {
                    return;
                }
                vm.Model1Rx.Update(vm.SolPointList.Value[i]);
            });
            trackbarch.Connect();
        }
Exemplo n.º 4
0
        private void initObs(RobotDynamics calc)
        {
            pr = calc;
            v0 = pr.Rebuild(pr.TimeSynch);
            var dt  = 0.0001;
            var sol = Ode.RK45(pr.TimeSynch, v0, pr.f, dt).WithStepRx(0.001, out controller).StartWith(new SolPoint(pr.TimeSynch, v0)).Publish();

            controller.Pause();

            sol.ObserveOnDispatcher().Subscribe(sp => {
                vm.SolPointList.Update(sp);
                slider.Maximum = (double)(vm.SolPointList.Value.Count > 0 ? vm.SolPointList.Value.Count : 0);
            });
            sol.Connect();
        }
Exemplo n.º 5
0
        private void button_Copy1_Click_1(object sender, RoutedEventArgs e)
        {
            controller.Pause();
            button.Content = "Paused";
            var unit4load = new RobotDynamics();

            unit4load.Rebuild();
            var sd = new OpenFileDialog()
            {
                Filter   = "XML Files|*.xml",
                FileName = "sph1D"
            };

            if (sd.ShowDialog() == true)
            {
                var sr = new StreamReader(sd.FileName);
                unit4load.Deserialize(sr);
                sr.Close();

                controller.Cancel();
                vm.SolPointList.Value.Clear();
                initObs(unit4load);
            }
        }