Example #1
0
        static void Main(string[] args)
        {
            OutputManager outMan = new OutputManager();
            SimManager simMan = new SimManager(outMan);
            OutputPanelVM outpan = new OutputPanelVM();

            outMan.link(new DisplayVM(), new FileModel(outMan), outpan, simMan);
            double precision = 0.0001;

            simMan.CompStep_ = 2;
            simMan.Duration_ = 5;
            simMan.accuracyMode = true;

            outpan.fromSim = true;
            outpan.EnableLog = true;
            outpan.DisplayEnbld = false;
            outpan.DisplayStep = "1";
            outpan.TargetFile = "C:\\Users\\Doz\\Source\\Repos\\Physics_Simulator\\ConsoleEntryPoint\\UnitTestOutputFile.txt";

            bool temp = false;
            if (!System.IO.File.Exists(outpan.TargetFile)) { temp = true; System.IO.File.Create(outpan.TargetFile); }

            simMan.addMaterialPoint(0, 0, 0, 0, 0, 0, 1, 0);
            simMan.addActionPoint(0, 0.5, 1, 10.5);
            outMan.launch();

            string content = System.IO.File.ReadLines(outpan.TargetFile).Last();
            var sp = content.Split();
            double t = Double.Parse(sp[0]);
            double x = Double.Parse(sp[2]);
            double y = Double.Parse(sp[3]);
            double z = Double.Parse(sp[4]);
            if (temp == true) { System.IO.File.Delete(outpan.TargetFile); }
        }
        public MainWindow()
        {
            InitializeComponent();

            display = new DisplayVM();
            outPan  = new OutputPanelVM();

            outManager = new OutputManager();
            fileVM_    = new FileModel(outManager);
            sManager   = new SimManager(outManager);
            outManager.link(display, fileVM_, outPan, sManager);

            elemDef = new ElemDefVM(sManager, outManager);
            envDef  = new EnvironmentDefVM(sManager);
            simSett = new SimSettingsVM(sManager);

            this.ElemDefTools.DataContext = elemDef;
            this.EnvDefTools.DataContext  = envDef;
            this.SimSetTools.DataContext  = simSett;
            this.SceneDisplay.DataContext = display;
            this.OutputPanel.DataContext  = outPan;

            Loaded         += MyWindow_Loaded;
            SizeChanged    += OnResize;
            dispTimer.Tick += onDispStep;
        }
        public MainWindow()
        {
            InitializeComponent();

            display = new DisplayVM();
            outPan = new OutputPanelVM();

            outManager = new OutputManager();
            fileVM_ = new FileModel(outManager);
            sManager = new SimManager(outManager);
            outManager.link(display, fileVM_, outPan, sManager);

            elemDef = new ElemDefVM(sManager, outManager);
            envDef = new EnvironmentDefVM(sManager);
            simSett = new SimSettingsVM(sManager);

            this.ElemDefTools.DataContext = elemDef;
            this.EnvDefTools.DataContext = envDef;
            this.SimSetTools.DataContext = simSett;
            this.SceneDisplay.DataContext = display;
            this.OutputPanel.DataContext = outPan;

            Loaded += MyWindow_Loaded;
            SizeChanged += OnResize;
            dispTimer.Tick += onDispStep;
        }
        public void link(DisplayVM dispVM, FileModel FVM, OutputPanelVM outPanel, SimManager sM)
        {
            disVM = dispVM;
            outPan = outPanel;
            fileVm_ = FVM;
            simMan = sM;

            RTTimer.Elapsed += IncrementRT;
            RTTimer.AutoReset = true;
        }
Example #5
0
        public void link(DisplayVM dispVM, FileModel FVM, OutputPanelVM outPanel, SimManager sM)
        {
            disVM   = dispVM;
            outPan  = outPanel;
            fileVm_ = FVM;
            simMan  = sM;

            RTTimer.Elapsed  += IncrementRT;
            RTTimer.AutoReset = true;
        }
        public void noLogPrecModeTest()
        {
            OutputManager outMan = new OutputManager();
            SimManager simMan = new SimManager(outMan);
            OutputPanelVM outpan = new OutputPanelVM();

            outMan.link(new DisplayVM(), new FileModel(outMan), outpan, simMan);
            double precision = 0.0001;

            simMan.CompStep_ = 2;
            simMan.Duration_ = 5;
            simMan.accuracyMode = true;

            outpan.fromSim = true;
            outpan.EnableLog = false;
            outpan.DisplayEnbld = true;
            outpan.DisplayStep = "1";
            outpan.TargetFile = "C:\\Users\\Doz\\Source\\Repos\\Physics_Simulator\\ConsoleEntryPoint\\UnitTestOutputFile.txt";

            if (!System.IO.File.Exists(outpan.TargetFile)) { System.IO.File.Create(outpan.TargetFile); }

            simMan.addMaterialPoint(0, 0, 0, 0, 0, 0, 1, 0);
            simMan.addActionPoint(0, 0.5, 1, 10.5);
            outMan.launch();

            System.IO.File.Delete(outpan.TargetFile);

            Assert.IsTrue(simMan.sceneElems_[0] - 0.5 * 0.5 * 25 < precision);
            Assert.IsTrue(simMan.sceneElems_[1] - 0.5 * 25 < precision);
            Assert.IsTrue(simMan.sceneElems_[2] - 0.5 * 10.5 * 25 < precision);
        }
        public void RToutputTest()
        {
            OutputManager outMan = new OutputManager();
            SimManager simMan = new SimManager(outMan);
            OutputPanelVM outpan = new OutputPanelVM();

            outMan.link(new DisplayVM(), new FileModel(outMan), outpan, simMan);

            simMan.CompStep_ = 2;
            simMan.accuracyMode = false;

            outpan.fromSim = true;
            outpan.EnableLog = false;
            outpan.DisplayEnbld = true;
            outpan.DisplayStep = "1";

            simMan.addMaterialPoint(0, 0, 0, 0, 0, 0, 1, 0);
            simMan.addActionPoint(0, 0.5, 1, 10.5);

            outMan.launch();
            System.Threading.Thread.Sleep(5000);
            outMan.stopTimer();
            double t = 5;
            Assert.IsTrue(simMan.sceneElems_[0] < 0.5 * 0.5 * (t + simMan.CompStep_) * (t + simMan.CompStep_));
            Assert.IsTrue(simMan.sceneElems_[0] > 0.5 * 0.5 * (t - simMan.CompStep_) * (t - simMan.CompStep_));
        }