Esempio n. 1
0
        public static SimulationResult Simulate(Topology.Topology topology, int maxSimulationSteps)
        {
            var state     = InitState(topology);
            var stateList = new List <SchemeState>();

            for (var i = 0; i < maxSimulationSteps; i++)
            {
                state = Step(state, false);
                stateList.Add(state);
            }

            return(new SimulationResult(stateList));
        }
Esempio n. 2
0
 private void сохранитьToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         Topology.Topology topology = topologyBuilder.ToTopology();
         TopologySaverAndLoader.Save(fullFilePath, topology);
         MessageBox.Show("Топология сохраненена в\n" + fullFilePath);
     }
     catch (Exception exc)
     {
         MessageBox.Show(exc.Message);
     }
 }
Esempio n. 3
0
        private void сохранитьКакToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog
            {
                DefaultExt = TopologySaverAndLoader.DotExt,
                Filter     = TopologySaverAndLoader.Filter
            };

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                fullFilePath = sfd.FileName;
                Topology.Topology topology = topologyBuilder.ToTopology();
                TopologySaverAndLoader.Save(fullFilePath, topology);
            }
        }
        internal static MappedTopology MapTopology(ModelingForm modelingForm,
                                                   Topology.Topology topology, TrafficFlow trafficFlow)
        {
            _modelingForm = modelingForm;
            _topology     = topology;
            ModelSettings.SetUpModelSettings(trafficFlow);
            _mappedTopology = new MappedTopology();
            ElementPictureBoxProducer.SetUpElementPictureBoxProducer(modelingForm, _mappedTopology);

            SetupPlaygroundPanel();
            SetupServiceArea();

            DestinationPointsDefiner.DefineElementsPoints(_mappedTopology);

            return(_mappedTopology);
        }
Esempio n. 5
0
        public SchemeState(Topology.Topology topology)
        {
            Gates = topology.Gates.ToDictionary(x => x, x => new GateState(x, false));
            Nodes = topology.Nodes.ToDictionary(x => x, x => new NodeState(x, false));

            InputPins  = topology.Pins.Where(x => !x.IsOutputPin).ToArray();
            OutputPins = topology.Pins.Where(x => x.IsOutputPin).ToArray();

            PinNodes = topology.Pins.ToDictionary(
                p => p,
                p => (IReadOnlyList <SchemeNode>)topology.Nodes.Where(n => n.Pins.Contains(p)).ToArray());

            InputPinStates            = InputPins.ToDictionary(x => x, x => new PinState(x, false, x.ValuesFunction.Begin(topology.ValuesFunctions)));
            OutputPinStates           = OutputPins.ToDictionary(x => x, x => new PinState(x, false, x.ValuesFunction.Begin(topology.ValuesFunctions)));
            GeneratedOutputPinsStates = OutputPins.ToDictionary(x => x, _ => false);
        }
        public Constructor(string fullFilePath, Topology.Topology topology)
        {
            this.fullFilePath = fullFilePath ?? throw new NullReferenceException();

            if (topology == null)
            {
                throw new NullReferenceException();
            }

            InitializeComponent();
            connection = ConnectionHelpers.OpenConnection();
            crudHelper = new CrudHelper(connection);

            SetupSettings();
            topologyBuilder = new TopologyBuilder(dgvField, topology);
        }
        public ModelingForm(Topology.Topology topology, TrafficFlow trafficFlow)
        {
            InitializeComponent();
            RemoveUnusedControls();
            DefineProperties();
            LocateFormElements();
            SetUpModelingTimeManager(timerModeling);

            ElementSizeDefiner.TopologyCellSize = 50;

            ClickEventProvider.SetUpClickEventProvider(this);
            pictureBoxPauseAndPlay.MouseClick += ClickEventProvider.PictureBoxPauseAndPlay_Click;

            _mappedTopology = TopologyMapper.MapTopology(this, topology, trafficFlow);

            ModelingProcessor.SetUpModelingProcessor(this, _mappedTopology);

            // not implemented
            labelTotalTime.Hide();
            labelTotalTimeValue.Hide();
            // /not implemented
        }
Esempio n. 8
0
        public static SchemeState InitState(Topology.Topology topology)
        {
            var state = new SchemeState(topology);

            return(Step(state, true)); // ensuring gates in the right states
        }