private static void UpdateFuelDispenserInfo(ModelingForm modelingForm, MappedTopology mappedTopology)
        {
            _selectedFuelDispenser = modelingForm.SelectedFuelDispenser ?? mappedTopology.FuelDispensersList.First();
            var fuelDispenserView = _selectedFuelDispenser.Tag as FuelDispenserView;

            modelingForm.LabelSpeedOfFillingValue.Text = fuelDispenserView.SpeedOfFillingPerMinute.ToString();
        }
Example #2
0
 private void treeLog_KeyDown(object sender, KeyEventArgs e)
 {
     if (ModelingForm != null)
     {
         ModelingForm.Close();
         ModelingForm = null;
     }
 }
        internal static void SetUpClickEventProvider(ModelingForm modelingForm)
        {
            _modelingForm                   = modelingForm;
            _labelSelectedElement           = modelingForm.LabelSelectedElement;
            _textBoxSelectedItemInformation = modelingForm.TextBoxSelectedItemInformation;

            _buttonPausePlay = modelingForm.ButtonPausePlay;
            _labelModelState = modelingForm.LabelModelState;
        }
        private static void UpdateFuelTankInfo(ModelingForm modelingForm, MappedTopology mappedTopology)
        {
            _selectedFuelTank = modelingForm.SelectedFuelTank ?? mappedTopology.FuelTanksList.First();
            var fuelTankView = _selectedFuelTank.Tag as FuelTankView;

            modelingForm.LabelFuelValue.Text            = fuelTankView.Fuel.ToString();
            modelingForm.LabelVolumeValue.Text          = ((int)fuelTankView.Volume).ToString();
            modelingForm.LabelCurrentFullnessValue.Text = ((int)fuelTankView.CurrentFullness).ToString();
        }
Example #5
0
        public RefuellerPictureBox(ModelingForm modelingForm, RefuellerView refuellerView)
        {
            Tag      = refuellerView;
            Image    = Properties.Resources.refueler_30x35_;
            Location = DestinationPointsDefiner.RefuellerSpawnPoint;
            SizeMode = PictureBoxSizeMode.AutoSize;

            MouseClick += ClickEventProvider.RefuellerPictureBox_Click;

            modelingForm.PlaygroundPanel.Controls.Add(this);
            BringToFront();
        }
        internal static void SetUpModelingProcessor(ModelingForm modelingForm, MappedTopology mappedTopology)
        {
            CashCounter        = mappedTopology.CashCounter;
            FuelDispensersList = mappedTopology.FuelDispensersList;
            FuelTanksList      = mappedTopology.FuelTanksList;
            _isCollectingMoney = false;
            _isRefilling       = false;

            CarMover.SetUpCarMover(modelingForm);
            CarRouter.SetUpCarRouter(modelingForm);

            RefuellerMover.SetUpRefuellerMover(modelingForm);
        }
        public CarPictureBox(ModelingForm modelingForm, CarView carView)
        {
            Tag      = carView;
            Image    = Properties.Resources.car_32x17__left;
            Location = DestinationPointsDefiner.SpawnPoint;
            SizeMode = PictureBoxSizeMode.AutoSize;

            IsGoesFilling = false;

            MouseClick += ClickEventProvider.CarPictureBox_Click;

            modelingForm.PlaygroundPanel.Controls.Add(this);
            BringToFront();
        }
        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);
        }
        private void btnOpenModeling_Click(object sender, EventArgs e)
        {
            if (rbRandomFlow.Checked == true)
            {
                try
                {
                    switch (cbChooseDistributionLaw.SelectedIndex)
                    {
                    case (int)DistributionLaws.UniformDistribution:
                        randNumGenerator = new UniformDistribution((double)nudUniformDistParamA.Value, (double)nudUniformDistParamB.Value);
                        break;

                    case (int)DistributionLaws.NormalDistribution:
                        randNumGenerator = new NormalDistribution((double)nudNormalDistrExpectedValue.Value, (double)nudNormalDistrVariance.Value);
                        break;

                    case (int)DistributionLaws.ExponentialDistribution:
                        randNumGenerator = new ExponentialDistribution((double)nudExponentialDistrLambda.Value);
                        break;

                    default:
                        break;
                    }
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message);
                    return;
                }
            }
            else
            {
                randNumGenerator = new DeterminedDistribution((double)nudDeterminedFlow.Value);
            }

            TrafficFlow trafficFlow = new TrafficFlow(randNumGenerator, (double)nudProbabilityOfStoppingAtGasStation.Value);

            ModelingForm modeling = new ModelingForm(topology, trafficFlow);

            modeling.Show();

            Dispose();
            Close();
        }
        private static void UpdateUI(ModelingForm modelingForm, MappedTopology mappedTopology)
        {
            UpdateCashCounterInfo(modelingForm, mappedTopology);
            UpdateFuelDispenserInfo(modelingForm, mappedTopology);
            UpdateFuelTankInfo(modelingForm, mappedTopology);

            _selectedItem = modelingForm.SelectedItem;

            if (_selectedItem != null)
            {
                if (_selectedItem.Tag is CarView)
                {
                    CarPictureBox_Click(_selectedItem, null);
                }

                if (_selectedItem.Tag is FuelDispenserView)
                {
                    FuelDispenserPictureBox_Click(_selectedItem, null);
                }

                if (_selectedItem.Tag is FuelTankView)
                {
                    FuelTankPictureBox_Click(_selectedItem, null);
                }

                if (_selectedItem.Tag is CashCounterView)
                {
                    CashCounterPictureBox_Click(_selectedItem, null);
                }

                if (_selectedItem is CollectorPictureBox)
                {
                    CashCollectorPictureBox_Click(_selectedItem, null);
                }
            }
        }
 internal static void SetUpRefuellerMover(ModelingForm modelingForm)
 {
     _modelingForm = modelingForm;
 }
Example #12
0
 internal static void SetUpCarRouter(ModelingForm modelingForm)
 {
     _modelingForm = modelingForm;
 }
Example #13
0
File: Main.cs Project: chdmitr2/CRM
        private void modelingToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var form = new ModelingForm();

            form.Show();
        }
 internal static void SetUpElementPictureBoxProducer(ModelingForm modelingForm, MappedTopology mappedTopology)
 {
     _modelingForm   = modelingForm;
     _mappedTopology = mappedTopology;
 }
Example #15
0
        private void treeLog_MouseDown(object sender, MouseEventArgs e)
        {
            if (ModelingForm == null)
            {
                if (e.Button == MouseButtons.Middle)
                {
                    TreeNode node = treeLog.GetNodeAt(e.X, e.Y);
                    if (node != null && node.Parent == null)
                    {
                        treeLog.SelectedNode = node;
                        CSMEvent tag = (CSMEvent)node.Tag;
                        ModelingForm = new Form();
                        ModelingForm.SuspendLayout();
                        ModelingForm.StartPosition   = FormStartPosition.Manual;
                        ModelingForm.Left            = Cursor.Position.X + 5;
                        ModelingForm.Top             = Cursor.Position.Y + 5;
                        ModelingForm.Width           = 0;
                        ModelingForm.Height          = 0;
                        ModelingForm.FormBorderStyle = FormBorderStyle.None;
                        ModelingForm.Name            = "frmModeling";
                        ModelingForm.BackColor       = System.Drawing.Color.LightGray;
                        RichTextBox eee = new RichTextBox();
                        eee.Margin    = new System.Windows.Forms.Padding(0);
                        eee.Font      = new System.Drawing.Font("Calibri", 10);
                        eee.Multiline = true;
                        eee.ReadOnly  = true;
                        eee.Text      = tag.eventInfo.Modeling;
                        int globalindex = 0;
                        foreach (string line in eee.Lines)
                        {
                            int index = line.IndexOf(" = ", 0);
                            if (index > -1)
                            {
                                eee.SelectionStart  = globalindex + index + 3;
                                eee.SelectionLength = line.Length - index - 3;
                                eee.SelectionFont   = new System.Drawing.Font(eee.Font, FontStyle.Bold);
                            }
                            globalindex += line.Length + 1;
                        }
                        if (tag.eventInfo.SGCID != default(string))
                        {
                            eee.SelectionStart  = 0;
                            eee.SelectionLength = 0;
                            eee.SelectionFont   = new System.Drawing.Font(eee.Font, FontStyle.Bold);
                            eee.SelectedText    = String.Format("SGCID: {0}{1}", tag.eventInfo.SGCID, Environment.NewLine);
                        }
                        if (tag.eventInfo.PGCID != default(string))
                        {
                            eee.SelectionStart  = 0;
                            eee.SelectionLength = 0;
                            eee.SelectionFont   = new System.Drawing.Font(eee.Font, FontStyle.Bold);
                            eee.SelectedText    = String.Format("PGCID: {0}{1}", tag.eventInfo.PGCID, Environment.NewLine);
                        }
                        if (tag.eventInfo.CGCID != default(string))
                        {
                            eee.SelectionStart  = 0;
                            eee.SelectionLength = 0;
                            eee.SelectionFont   = new System.Drawing.Font(eee.Font, FontStyle.Bold);
                            eee.SelectedText    = String.Format("CGCID: {0}{1}", tag.eventInfo.CGCID, Environment.NewLine);
                        }
                        //Monitor
                        eee.SelectionStart  = 0;
                        eee.SelectionLength = 0;
                        eee.SelectionFont   = new System.Drawing.Font(eee.Font, FontStyle.Bold);
                        eee.SelectedText    = String.Format("Monitor: {0}{1}", tag.Monitor, Environment.NewLine);
                        //Event
                        eee.SelectionStart  = 0;
                        eee.SelectionLength = 0;
                        eee.SelectionFont   = new System.Drawing.Font(eee.Font, FontStyle.Bold);
                        eee.SelectedText    = String.Format("Event: {0}{1}", tag.eventInfo.Type, Environment.NewLine);

                        eee.Size = eee.PreferredSize;
                        ModelingForm.Controls.AddRange(new Control[] { eee });
                        ModelingForm.AutoSize = true;
                        ModelingForm.Show(this);
                        ModelingForm.ResumeLayout();
                    }
                }
                else if (e.Button == MouseButtons.Right)
                {
                    TreeNode node = treeLog.GetNodeAt(e.X, e.Y);
                    if (node != null && node.Parent == null)
                    {
                        treeLog.SelectedNode = node;
                        string result = (node.Text + Environment.NewLine).TrimStart();
                        foreach (TreeNode inode in node.Nodes)
                        {
                            result += "    " + inode.Text + Environment.NewLine;
                        }
                        Clipboard.SetText(result);
                    }
                }
            }
            else
            {
                ModelingForm.Close();
                ModelingForm = null;
            }
        }
        internal static void Tick(ModelingForm modelingForm, MappedTopology mappedTopology)
        {
            if (IsPaused)
            {
                return;
            }

            TimerTicksCount++;
            TicksAfterLastCarSpawning++;

            if (TimeAfterLastCarSpawningInSeconds >= TimeBetweenCars)
            {
                CarCreator.SpawnCar();
                TimeBetweenCars           = ModelSettings.TrafficFlow.TimeBetweenCars;
                TicksAfterLastCarSpawning = 0;
            }

            //if (!_paused)
            //{
            //    //return;
            //    //CarCreator.SpawnCar();
            //    CarCreator.SpawnCollector();

            //    _paused = true;
            //}


            //if (TimerTicksCount % 20 == 0)
            //{
            //    CarCreator.SpawnCar();
            //}

            #region LoopingControls

            var panelPlayground = modelingForm.PlaygroundPanel;

            foreach (Control control in panelPlayground.Controls)
            {
                if (!(control is MoveablePictureBox))
                {
                    continue;
                }

                var moveablePictureBox = control as MoveablePictureBox;

                // Car
                if (moveablePictureBox is CarPictureBox car)
                {
                    CarRouter.RouteCar(car);

                    CarMover.MoveCarToDestination(car);

                    continue;
                }

                // Collector
                if (moveablePictureBox is CollectorPictureBox collector)
                {
                    CarRouter.RouteCar(collector);

                    CarMover.MoveCarToDestination(collector);

                    continue;
                }

                // Refueller
                if (moveablePictureBox is RefuellerPictureBox refueller)
                {
                    RefuellerRouter.RouteRefueller(refueller);

                    RefuellerMover.MoveRefuellerToDestination(refueller);
                }
            }

            #endregion /LoopingControls

            #region UI

            UpdateUI(modelingForm, mappedTopology);

            #endregion UI
        }
Example #17
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (ModelingForm == null)
            {
                ModelingForm = new Form();
                ModelingForm.StartPosition   = FormStartPosition.Manual;
                ModelingForm.Left            = Cursor.Position.X + 5;
                ModelingForm.Top             = Cursor.Position.Y + 5;
                ModelingForm.FormBorderStyle = FormBorderStyle.Sizable;
                ModelingForm.Name            = "frmModeling";
                ModelingForm.BackColor       = System.Drawing.Color.LightGray;
                RichTextBox eee = new RichTextBox();
                eee.Margin    = new System.Windows.Forms.Padding(0);
                eee.Font      = new System.Drawing.Font("Calibri", 10);
                eee.Multiline = true;
                eee.ReadOnly  = true;
                TabControl       tbc = new TabControl();
                SplitContainer   sc  = new SplitContainer();
                TableLayoutPanel tbl = new TableLayoutPanel();
                Button           b   = new Button();
                b.Text = "Hello";
                b.Dock = DockStyle.Fill;
                tbl.Controls.Add(b, 0, 0);
                tbl.Controls.Add(new Button(), 0, 1);
                tbl.Controls.Add(new Button(), 0, 2);
                tbl.Controls.Add(new Button(), 0, 3);
                tbl.AutoSize = true;
                TableLayoutPanel tbl2 = new TableLayoutPanel();
                b      = new Button();
                b.Text = "Hello";
                tbl2.Controls.Add(b, 0, 0);
                tbl2.Controls.Add(new Button(), 0, 1);
                tbl2.Controls.Add(new Button(), 0, 2);
                tbl2.Controls.Add(new Button(), 0, 3);
                tbl2.AutoSize = true;
                tbl2.SuspendLayout();
                tbl.SuspendLayout();
                sc.Panel2.Controls.Add(tbl2);
                sc.Panel1.Controls.Add(tbl);
                sc.Panel1.AutoSize = true;
                sc.AutoSize        = true;
                tbl2.ResumeLayout();
                tbl.ResumeLayout();
                sc.BorderStyle = BorderStyle.Fixed3D;
                sc.AutoSize    = true;
                string   aaa     = @"
================================================================
MainCallEndByExtension - sCallIDTelSys = 9D1CE0BF47B8039EDB48 :
     byCallType = INTERNAL
     sDeviceExtension = 3312
     sDeviceDistantOptional = 
     sDeviceExtLst = 
     bIncludeDistConnectnsFromToDevIfInternal = True
     bSearchConnctnsForwards = False
     bOnlyConsiderNonAnsweredGroupCalls = False
     ppMainCallIDsDeleted = 
================================================================
DevCallConnctnDelete - sCallIDTelSys = 9D1CE0BF47B8039EDB48 :
     sDevice = [CONF]
     sCallIDTelSys = 9D1CE0BF47B8039EDB48
     sDeviceDistantEnd = 3312
     bUseDistantEndAlsoIfUsingCallID = True
     bCallInInfoOverride = False
     sCallInInfoGrp = 
     sCallInInfoDDIDigits = 
     bIgnoreNonCallConnections = True
     bSearchForwards = False
     bSearchAllCallConnections = True
     bClearByDevFirstRung = False
     bClearDistantEndConnectionIfFlagsMatch = False
     iClearDistantEndConnectionIfFlagsMatch = 0
     bDoNotAttemptOnHookCalculation = False
================================================================
DevCallConnctnDelete - sCallIDTelSys = 9D1CE0BF47B8039EDB48 :
     sDevice = 3312
     sCallIDTelSys = 9D1CE0BF47B8039EDB48
     sDeviceDistantEnd = 
     bUseDistantEndAlsoIfUsingCallID = False
     bCallInInfoOverride = False
     sCallInInfoGrp = 
     sCallInInfoDDIDigits = 
     bIgnoreNonCallConnections = True
     bSearchForwards = False
     bSearchAllCallConnections = True
     bClearByDevFirstRung = False
     bClearDistantEndConnectionIfFlagsMatch = False
     iClearDistantEndConnectionIfFlagsMatch = 0
     bDoNotAttemptOnHookCalculation = False
================================================================
MainCallEndByExtension - sCallIDTelSys = 9D1CE0BF47B8039EDB48 :
     byCallType = INTERNAL
     sDeviceExtension = 3321
     sDeviceDistantOptional = 
     sDeviceExtLst = 
     bIncludeDistConnectnsFromToDevIfInternal = True
     bSearchConnctnsForwards = False
     bOnlyConsiderNonAnsweredGroupCalls = False
     ppMainCallIDsDeleted = 
================================================================
DevCallConnctnDelete - sCallIDTelSys = 9D1CE0BF47B8039EDB48 :
     sDevice = [CONF]
     sCallIDTelSys = 9D1CE0BF47B8039EDB48
     sDeviceDistantEnd = 3321
     bUseDistantEndAlsoIfUsingCallID = True
     bCallInInfoOverride = False
     sCallInInfoGrp = 
     sCallInInfoDDIDigits = 
     bIgnoreNonCallConnections = True
     bSearchForwards = False
     bSearchAllCallConnections = True
     bClearByDevFirstRung = False
     bClearDistantEndConnectionIfFlagsMatch = False
     iClearDistantEndConnectionIfFlagsMatch = 0
     bDoNotAttemptOnHookCalculation = False
================================================================
DevCallConnctnDelete - sCallIDTelSys = 9D1CE0BF47B8039EDB48 :
     sDevice = 3321
     sCallIDTelSys = 9D1CE0BF47B8039EDB48
     sDeviceDistantEnd = 
     bUseDistantEndAlsoIfUsingCallID = False
     bCallInInfoOverride = False
     sCallInInfoGrp = 
     sCallInInfoDDIDigits = 
     bIgnoreNonCallConnections = True
     bSearchForwards = False
     bSearchAllCallConnections = True
     bClearByDevFirstRung = False
     bClearDistantEndConnectionIfFlagsMatch = False
     iClearDistantEndConnectionIfFlagsMatch = 0
     bDoNotAttemptOnHookCalculation = False
================================================================
DevCallConnctnDelete - sCallIDTelSys = 9D1CE0BF47B8039EDB48 :
     sDevice = [CONF]
     sCallIDTelSys = 9D1CE0BF47B8039EDB48
     sDeviceDistantEnd = 
     bUseDistantEndAlsoIfUsingCallID = False
     bCallInInfoOverride = False
     sCallInInfoGrp = 
     sCallInInfoDDIDigits = 
     bIgnoreNonCallConnections = True
     bSearchForwards = False
     bSearchAllCallConnections = True
     bClearByDevFirstRung = False
     bClearDistantEndConnectionIfFlagsMatch = False
     iClearDistantEndConnectionIfFlagsMatch = 0
     bDoNotAttemptOnHookCalculation = False
================================================================
DevCallAnswer - sCallIDTelSys = 9D1CE0BF47B8039EDB48 :
     sDeviceLocal = 3311, LegID = 
     sDeviceDistant = 3321, LegID = 
     sDeviceGroup = , LegID = 
     bAlwaysUseDevGrpToCalcGrpDistrib = False
     iCallModellingFlags = 15
     sCallIDTelSys = 9D1CE0BF47B8039EDB48
     bCalcMainCallIDFromConnectns = True
     bMarkAnsweredIn = True
     bMarkAnsweredOut = True
     bMarkUnHeldIn = True
     bMarkUnHeldOut = True
     bDeleteCallConnectnsElsewhere = False
     bUseCallAnswerFlagForCallConnectns = False
     bDegenerateCallConference = True
     bSegAlgrthmRun = True
     iSegAlgrthmFlags = 257
================================================================
MainCallEnd - sCallIDTelSys = 9D1CE0BF47B8039EDB48 :
     sCallIDTelSys = 9D1CE0BF47B8039EDB48
     pSDeviceDistant = [CONF], LegID = 
     pSDeviceLocal = 3311, LegID = 
     sDeviceExtLst = 
";
                string[] bbb     = System.Text.RegularExpressions.Regex.Split(aaa, String.Format("{1}+{0}{1}+", @"={2,}\s*", Environment.NewLine));//, System.Text.RegularExpressions.RegexOptions.Multiline);
                int      counter = 1;
                foreach (string item in bbb)
                {
                    eee.Text += item;
                    if (!String.IsNullOrWhiteSpace(item))
                    {
                        string [] info = item.Split(new string[] { " - " }, StringSplitOptions.RemoveEmptyEntries);
                        if (info.Length == 2)
                        {
                            TabPage     tb     = new TabPage(counter.ToString());
                            RichTextBox tbText = new RichTextBox();
                            tbText.Text  = info[0] + Environment.NewLine;
                            tbText.Text += "     " + info[1];
                            tbText.Size  = tbText.PreferredSize;
                            tb.Controls.Add(tbText);
                            tbc.TabPages.Add(tb);
                            tb.Dock = DockStyle.Fill;
                            counter++;
                        }
                    }
                }
                //tbc.Size = tbc.GetPreferredSize(tbc.Size);
                tbc.Dock = DockStyle.Fill;
                //tbc.Anchor = AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Top | AnchorStyles.Right;
                //int globalindex = 0;
                //foreach (string line in eee.Lines)
                //{
                //    int index = line.IndexOf(" = ", 0);
                //    if (index > -1)
                //    {
                //        eee.SelectionStart = globalindex + index + 3;
                //        eee.SelectionLength = line.Length - index - 3;
                //        eee.SelectionFont = new System.Drawing.Font(eee.Font, FontStyle.Bold);
                //    }
                //    globalindex += line.Length + 1;
                //}
                eee.Size = eee.PreferredSize;
                ModelingForm.SuspendLayout();
                sc.Size = sc.PreferredSize;
                sc.SuspendLayout();
                //ModelingForm.Controls.AddRange(new Control[] { eee, tbc });
                //ModelingForm.Controls.AddRange(new Control[] { tbc });
                ModelingForm.Controls.AddRange(new Control[] { sc });
                ModelingForm.Show(this);
                sc.ResumeLayout();
                ModelingForm.ResumeLayout();
            }
            else
            {
                ModelingForm.Close();
                ModelingForm = null;
            }
        }
 private static void UpdateCashCounterInfo(ModelingForm modelingForm, MappedTopology mappedTopology)
 {
     modelingForm.LabelCashCounterSumValue.Text =
         ((int)((CashCounterView)mappedTopology.CashCounter.Tag).CurrentCashVolume).ToString();
 }