예제 #1
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;
        }
예제 #2
0
파일: Robot.cs 프로젝트: taesiri/Simulation
        public void MoveIt(ServiceEntranceStation source, ServicePlatformElement destination, TimeSpan duration)
        {
            duration = TimeSpan.FromSeconds(duration.TotalSeconds*GlobalTimeScale);

            // Move one Box from Entrance Station and put it on StationA
            LastActivity = "EQ->A"; // One Possibility!
            ServiceBoxElement box = source.Dequeue();
            destination.ServiceBox = box;

            double src = box.Transformer.OffsetX;
            const double desten = -7.5;

            var da = new DoubleAnimation {From = src, To = desten, 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, da);

            var robotTransform = new TranslateTransform3D(box.Transformer.OffsetX, box.Transformer.OffsetY, 0);
            World.Instance.MotherRobot.Transform = robotTransform;
            robotTransform.BeginAnimation(TranslateTransform3D.OffsetXProperty, da);
        }