Exemplo n.º 1
0
        public void MoveIt(ServicePlatformElement source, ServiceInspectorStation destination, TimeSpan duration, int p)
        {
            duration = TimeSpan.FromSeconds(duration.TotalSeconds*GlobalTimeScale);

            LastActivity = "C->Ins";
            ServiceBoxElement box = source.ServiceBox;
            source.ServiceBox = null;
            source.Status = StationStatus.Empty;
            int qLen = destination.GetQueueLen;
            double srcX = box.Transformer.OffsetX;
            const double destenX = 16;
            double srcY = box.Transformer.OffsetY;

            double destenY = 0;

            if (p == 0)
            {
                destenY = 10 + (5*qLen);
                destination.PushBoxToQueue(box);
            }
            else if (p == 1)
            {
                destenY = 3;
                destination.Inspector1Box = box;
            }
            else if (p == 2)
            {
                destenY = -3;
                destination.Inspector2Box = box;
            }

            var daX = new DoubleAnimation {From = srcX, To = destenX, Duration = new Duration(duration)};
            var daY = new DoubleAnimation {From = srcY, To = destenY, Duration = new Duration(duration)};
            var newTransformer = new TranslateTransform3D(box.Transformer.OffsetX, box.Transformer.OffsetY, 2.1);
            box.Transform = newTransformer;
            box.Transformer = newTransformer;
            newTransformer.BeginAnimation(TranslateTransform3D.OffsetXProperty, daX);
            newTransformer.BeginAnimation(TranslateTransform3D.OffsetYProperty, daY);

            var robotTransform = new TranslateTransform3D(box.Transformer.OffsetX, box.Transformer.OffsetY, 0);
            World.Instance.MotherRobot.Transform = robotTransform;
            robotTransform.BeginAnimation(TranslateTransform3D.OffsetXProperty, daX);
            robotTransform.BeginAnimation(TranslateTransform3D.OffsetYProperty, daY);
        }
Exemplo n.º 2
0
        public void CreateScene()
        {
            _entranceStation = new ServiceEntranceStation(new Point3D(-22, 0, 0.5f)) {Name = "Entrance"};

            _platformA = new ServicePlatformElement(new Point3D(-7.5, 0, -4.5)) {Name = "A"};
            _platformA.PlatformStatusText.Position = new Point3D(-8, 2, -1);
            _platformA.PlatformStatusText.Text = _platformA.Status.ToString();
            _platformB = new ServicePlatformElement(new Point3D(0, 0, -4.5)) {Name = "B"};
            _platformB.PlatformStatusText.Position = new Point3D(0, 2, -1);
            _platformB.PlatformStatusText.Text = _platformB.Status.ToString();
            _platformC = new ServicePlatformElement(new Point3D(7.5, 0, -4.5)) {Name = "C"};
            _platformC.PlatformStatusText.Position = new Point3D(8, 2, -1);
            _platformC.PlatformStatusText.Text = _platformC.Status.ToString();

            _inspectorStation = new ServiceInspectorStation(new Point3D(18, 0, 0.5f));
            _inspectorStation.Inspector1StatusText.Position = new Point3D(22, 3, 0);
            _inspectorStation.Inspector2StatusText.Position = new Point3D(22, -3, 0);
            _inspectorStation.InspectorQStatusText.Position = new Point3D(22, 14, 0);
            _inspectorStation.Inspector1StatusText.Text = "Worker 1 : " + _inspectorStation.Inspector1Status.ToString();
            _inspectorStation.Inspector2StatusText.Text = "Worker 2 : " + _inspectorStation.Inspector2Status.ToString();
            _inspectorStation.InspectorQStatusText.Text = "Queue Len : 0";

            _robot = new Robot {GlobalTimeScale = 1/60f};

            Mother.Children.Add(_platformA);
            Mother.Children.Add(_platformB);
            Mother.Children.Add(_platformC);
            Mother.Children.Add(_entranceStation);
            Mother.Children.Add(_inspectorStation);

            MotherRobot = new ServiceRobotElement();
            MotherRobot.Transform = new TranslateTransform3D(-12, 8, -3.5);
            Mother.Children.Add(MotherRobot);

            //Timer
            GlobalTimeScale = 1/60f;
            _simulationClock = 0;

            _timer = new DispatcherTimer {Interval = TimeSpan.FromMilliseconds(10f)};

            _timer.Tick += timer_Tick;
        }