Exemplo n.º 1
0
        public Simulation(SimConfigurator configurator)
        {
            if (configurator == null)
                throw new ArgumentNullException("configurator");

            _configurator = configurator;
            _previous_config_string = _configurator.SerializeSimConfigToString();
        }
        public MainWindow()
        {
            InitializeComponent();

            // NOTE: Uncomment this to recreate initial XML scenario file
            // this.CreateAndSerializeScenario();

            configurator = new SimConfigurator(filename);
            configurator.DeserializeSimConfig();
            // TODO: Should make sure region 0 is always selected first...
            configurator.SimConfig.scenario.regions[region_list_selected_idx].region_box_spec.PropertyChanged += this.SimConfig_PropertyChanged;

            // Set the data context for the main tab control config GUI
            this.ConfigTabControl.DataContext = configurator.SimConfig;

            sim = new Simulation(configurator);

            this.SetUpRenderWindow();

            // Should be able to do this in the xaml...
            CollectionViewSource ldv = this.Resources["regionsListView"] as CollectionViewSource;

            if (ldv != null)
            {
                ldv.Source = configurator.SimConfig.scenario.regions;
            }
            ldv = this.Resources["cellsListView"] as CollectionViewSource;
            if (ldv != null)
            {
                ldv.Source = configurator.SimConfig.scenario.cellsets;
            }
            ldv = this.Resources["solfacsListView"] as CollectionViewSource;
            if (ldv != null)
            {
                ldv.Source = configurator.SimConfig.scenario.solfacs;
            }
            ldv = this.Resources["solfacTypesListView"] as CollectionViewSource;
            if (ldv != null)
            {
                ldv.Source = configurator.SimConfig.entity_repository.solfac_types;
            }
            ldv = this.Resources["cellTypesListView"] as CollectionViewSource;
            if (ldv != null)
            {
                ldv.Source = configurator.SimConfig.entity_repository.cell_types;
            }
            ldv = this.Resources["gaussianGradientsListView"] as CollectionViewSource;
            if (ldv != null)
            {
                ldv.Source = configurator.SimConfig.entity_repository.gaussian_gradients;
            }
            ldv = this.Resources["globalParameterTypesListView"] as CollectionViewSource;
            if (ldv != null)
            {
                ldv.Source = configurator.SimConfig.global_parameters;
            }
        }
        public MainWindow()
        {
            InitializeComponent();

            // NOTE: Uncomment this to recreate initial XML scenario file
            // this.CreateAndSerializeScenario();

            configurator = new SimConfigurator(filename);
            configurator.DeserializeSimConfig();
            // TODO: Should make sure region 0 is always selected first...
            configurator.SimConfig.scenario.regions[region_list_selected_idx].region_box_spec.PropertyChanged += this.SimConfig_PropertyChanged;

            // Set the data context for the main tab control config GUI
            this.ConfigTabControl.DataContext = configurator.SimConfig;

            sim = new Simulation(configurator);

            this.SetUpRenderWindow();

            // Should be able to do this in the xaml...
            CollectionViewSource ldv = this.Resources["regionsListView"] as CollectionViewSource;
            if (ldv != null)
            {
                ldv.Source = configurator.SimConfig.scenario.regions;
            }
            ldv = this.Resources["cellsListView"] as CollectionViewSource;
            if (ldv != null)
            {
                ldv.Source = configurator.SimConfig.scenario.cellsets;
            }
            ldv = this.Resources["solfacsListView"] as CollectionViewSource;
            if (ldv != null)
            {
                ldv.Source = configurator.SimConfig.scenario.solfacs;
            }
            ldv = this.Resources["solfacTypesListView"] as CollectionViewSource;
            if (ldv != null)
            {
                ldv.Source = configurator.SimConfig.entity_repository.solfac_types;
            }
            ldv = this.Resources["cellTypesListView"] as CollectionViewSource;
            if (ldv != null)
            {
                ldv.Source = configurator.SimConfig.entity_repository.cell_types;
            }
            ldv = this.Resources["gaussianGradientsListView"] as CollectionViewSource;
            if (ldv != null)
            {
                ldv.Source = configurator.SimConfig.entity_repository.gaussian_gradients;
            }
            ldv = this.Resources["globalParameterTypesListView"] as CollectionViewSource;
            if (ldv != null)
            {
                ldv.Source = configurator.SimConfig.global_parameters;
            }
        }
Exemplo n.º 4
0
        public Simulation(SimConfigurator configurator)
        {
            if (configurator == null)
            {
                throw new ArgumentNullException("configurator");
            }

            _configurator           = configurator;
            _previous_config_string = _configurator.SerializeSimConfigToString();
        }
        public void CreateAndSerializeScenario()
        {
            var config     = new SimConfigurator(filename);
            var sim_config = config.SimConfig;

            // Experiment
            sim_config.experiment_name = "Test experiment for XML serialization";
            sim_config.scenario.time_config.duration = 100;
            sim_config.scenario.time_config.timestep = 3;

            // Global Paramters
            sim_config.LoadDefaultGlobalParameters();

            // Entity Repository
            EntityRepository repository = new EntityRepository();
            // Possible solfac types
            SolfacType st = new SolfacType();

            st.solfac_type_name = "ccr7";
            repository.solfac_types.Add(st);
            st = new SolfacType();
            st.solfac_type_name = "cxcl13";
            repository.solfac_types.Add(st);
            // Possible cell types
            CellType ct = new CellType();

            ct.cell_type_name = "bcell";
            ct.LoadDefaultMotileCellParams();
            repository.cell_types.Add(ct);
            ct = new CellType();
            ct.cell_type_name = "tcell";
            ct.LoadDefaultMotileCellParams();
            repository.cell_types.Add(ct);
            sim_config.entity_repository = repository;
            // Gaussian Gradients
            GaussianSpecification gg = new GaussianSpecification();

            gg.gaussian_spec_name = "Default on-center gradient";
            sim_config.entity_repository.gaussian_gradients.Add(gg);

            // Regions (not part of repository right now...)
            sim_config.scenario.regions.Add(new Region("Sphere", RegionShape.Ellipsoid));
            sim_config.scenario.regions.Add(new Region("Cube", RegionShape.Rectangular));

            // Cells
            CellSet cs = new CellSet();

            cs.cell_name     = "Generic motile bcell";
            cs.cell_type_ref = sim_config.entity_repository.cell_types[0].cell_type_name;
            cs.number        = 200;
            cs.cells_constrained_to_region = true;
            cs.region_name_ref             = sim_config.scenario.regions[0].region_name;
            cs.wrt_region = RelativePosition.Inside;
            sim_config.scenario.cellsets.Add(cs);
            cs               = new CellSet();
            cs.cell_name     = "Generic motile tcell";
            cs.cell_type_ref = sim_config.entity_repository.cell_types[1].cell_type_name;
            cs.number        = 200;
            cs.cells_constrained_to_region = true;
            cs.region_name_ref             = sim_config.scenario.regions[1].region_name;
            cs.wrt_region = RelativePosition.Outside;
            sim_config.scenario.cellsets.Add(cs);

            // Solfacs
            Solfac solfac = new Solfac();

            solfac.solfac_name     = "Gauss";
            solfac.solfac_type_ref = sim_config.entity_repository.solfac_types[0].solfac_type_name;
            SolfacGaussianGradient sgg = new SolfacGaussianGradient();

            sgg.gaussian_spec_name_ref = sim_config.entity_repository.gaussian_gradients[0].gaussian_spec_name;
            solfac.solfac_distribution = sgg;
            sim_config.scenario.solfacs.Add(solfac);
            solfac             = new Solfac();
            solfac.solfac_name = "Lin";
            SolfacLinearGradient sll = new SolfacLinearGradient();

            sll.min_concentration         = 20;
            sll.max_concentration         = 150;
            solfac.solfac_distribution    = sll;
            solfac.solfac_type_ref        = sim_config.entity_repository.solfac_types[1].solfac_type_name;
            solfac.solfac_is_time_varying = false;
            sim_config.scenario.solfacs.Add(solfac);
            solfac                        = new Solfac();
            solfac.solfac_name            = "Homog";
            solfac.solfac_type_ref        = sim_config.entity_repository.solfac_types[1].solfac_type_name;
            solfac.solfac_is_time_varying = true;
            solfac.solfac_amplitude_keyframes.Add(new TimeAmpPair(0, 1));
            sim_config.scenario.solfacs.Add(solfac);

            // Write out XML file
            config.SerializeSimConfigToFile();
        }
        public void CreateAndSerializeScenario()
        {
            var config = new SimConfigurator(filename);
            var sim_config = config.SimConfig;

            // Experiment
            sim_config.experiment_name = "Test experiment for XML serialization";
            sim_config.scenario.time_config.duration = 100;
            sim_config.scenario.time_config.timestep = 3;

            // Global Paramters
            sim_config.LoadDefaultGlobalParameters();

            // Entity Repository
            EntityRepository repository = new EntityRepository();
            // Possible solfac types
            SolfacType st = new SolfacType();
            st.solfac_type_name = "ccr7";
            repository.solfac_types.Add(st);
            st = new SolfacType();
            st.solfac_type_name = "cxcl13";
            repository.solfac_types.Add(st);
            // Possible cell types
            CellType ct = new CellType();
            ct.cell_type_name = "bcell";
            ct.LoadDefaultMotileCellParams();
            repository.cell_types.Add(ct);
            ct = new CellType();
            ct.cell_type_name = "tcell";
            ct.LoadDefaultMotileCellParams();
            repository.cell_types.Add(ct);
            sim_config.entity_repository = repository;
            // Gaussian Gradients
            GaussianSpecification gg = new GaussianSpecification();
            gg.gaussian_spec_name = "Default on-center gradient";
            sim_config.entity_repository.gaussian_gradients.Add(gg);

            // Regions (not part of repository right now...)
            sim_config.scenario.regions.Add(new Region("Sphere", RegionShape.Ellipsoid));
            sim_config.scenario.regions.Add(new Region("Cube", RegionShape.Rectangular));

            // Cells
            CellSet cs = new CellSet();
            cs.cell_name = "Generic motile bcell";
            cs.cell_type_ref = sim_config.entity_repository.cell_types[0].cell_type_name;
            cs.number = 200;
            cs.cells_constrained_to_region = true;
            cs.region_name_ref = sim_config.scenario.regions[0].region_name;
            cs.wrt_region = RelativePosition.Inside;
            sim_config.scenario.cellsets.Add(cs);
            cs = new CellSet();
            cs.cell_name = "Generic motile tcell";
            cs.cell_type_ref = sim_config.entity_repository.cell_types[1].cell_type_name;
            cs.number = 200;
            cs.cells_constrained_to_region = true;
            cs.region_name_ref = sim_config.scenario.regions[1].region_name;
            cs.wrt_region = RelativePosition.Outside;
            sim_config.scenario.cellsets.Add(cs);

            // Solfacs
            Solfac solfac = new Solfac();
            solfac.solfac_name = "Gauss";
            solfac.solfac_type_ref = sim_config.entity_repository.solfac_types[0].solfac_type_name;
            SolfacGaussianGradient sgg = new SolfacGaussianGradient();
            sgg.gaussian_spec_name_ref = sim_config.entity_repository.gaussian_gradients[0].gaussian_spec_name;
            solfac.solfac_distribution = sgg;
            sim_config.scenario.solfacs.Add(solfac);
            solfac = new Solfac();
            solfac.solfac_name = "Lin";
            SolfacLinearGradient sll = new SolfacLinearGradient();
            sll.min_concentration = 20;
            sll.max_concentration = 150;
            solfac.solfac_distribution = sll;
            solfac.solfac_type_ref = sim_config.entity_repository.solfac_types[1].solfac_type_name;
            solfac.solfac_is_time_varying = false;
            sim_config.scenario.solfacs.Add(solfac);
            solfac = new Solfac();
            solfac.solfac_name = "Homog";
            solfac.solfac_type_ref = sim_config.entity_repository.solfac_types[1].solfac_type_name;
            solfac.solfac_is_time_varying = true;
            solfac.solfac_amplitude_keyframes.Add(new TimeAmpPair(0, 1));
            sim_config.scenario.solfacs.Add(solfac);

            // Write out XML file
            config.SerializeSimConfigToFile();
        }