示例#1
0
        protected override void DoForwardProcess(SimpleProtocolEventArgs args)
        {
            // alice forward
            Devices.Laser(args.Item);
            var topState = args.Item.QuantumState;
            var bottomState = QuantumState.Vacuum;
            Devices.BeamSplit(topState, bottomState);
            Devices.Delay(bottomState);
            Devices.BeamSplit(topState, bottomState);

            // bob
            Devices.Attenuator(args.Item.QuantumState, ProtocolAct.Params);
            args.Item.BobValue = RandomHelper.RandomBool();
            Devices.PhaseShift(args.Item.QuantumState, 1, args.Item.BobPhase);

            // eva
            var catched = args.ModelingMode == ModelingMode.Random
                              ? RandomHelper.RandomBool()
                              : (args.ModelingMode != ModelingMode.NoEvaWithClick &&
                                 args.ModelingMode != ModelingMode.NoEvaNoClick);
            args.Item.CatchedByEva = catched;
            if (catched)
            {
                var result = Devices.EvaMeasure(args.Item);
                args.Item.EvaResult = args.ModelingMode == ModelingMode.Random
                                          ? result
                                          : args.ModelingMode == ModelingMode.EvaUndefinedResult
                                                ? MeasurementResult.Inconclusive
                                                : args.Item.BobValue
                                                      ? MeasurementResult.Phase0
                                                      : MeasurementResult.Phase1;
                switch (args.Item.EvaResult)
                {
                    case MeasurementResult.Phase0:
                        args.Item.EvaValue = false;
                        break;
                    case MeasurementResult.Phase1:
                        args.Item.EvaValue = true;
                        break;
                    case MeasurementResult.Inconclusive: // transmission will be blocked
                        args.Item.EvaValue = RandomHelper.RandomBool();
                        break;
                }
            }

            // alice backward
            var stateTop = args.Item.QuantumState;
            var stateBottom = QuantumState.Vacuum;
            Devices.BeamSplit(stateTop, stateBottom);
            args.Item.AliceValue = args.ModelingMode == ModelingMode.Random
                                       ? RandomHelper.RandomBool()
                                       : (args.ModelingMode == ModelingMode.NoEvaWithClick || args.ModelingMode == ModelingMode.EvaDefinedResultDetected)
                                             ? !args.Item.BobValue
                                             : args.Item.BobValue;
            Devices.PhaseShift(stateBottom, 0, args.Item.AlicePhase);
            Devices.Delay(args.Item.QuantumState);
            Devices.BeamSplit(stateTop, stateBottom);
            args.Item.QuantumState = stateBottom;
        }
示例#2
0
 public TransmissionItem Process(ModelingMode modelingMode)
 {
     _transmissionItem = new TransmissionItem(Params.Phase0, Params.Phase1);
     var e = new SimpleProtocolEventArgs(_transmissionItem, modelingMode);
     AllInOneDevice.ProcessForward(e);
     Started(this, e);
     return _transmissionItem;
 }
示例#3
0
 void AllInOneDevice_BackwardProcessFinished(object sender, SimpleProtocolEventArgs e)
 {
     Finished(this, e);
 }
示例#4
0
 void AllInOneDevice_ForwardProcessFinished(object sender, SimpleProtocolEventArgs e)
 {
     AllInOneDevice.ProcessBackward(e);
 }
示例#5
0
 protected override void DoBackwardProcess(SimpleProtocolEventArgs args)
 {
 }
示例#6
0
 protected abstract void DoBackwardProcess(SimpleProtocolEventArgs args);
示例#7
0
 public void ProcessBackward(SimpleProtocolEventArgs args)
 {
     _args = args;
     DoBackwardProcess(args);
     BackwardProcessStarted(this, args);
 }
示例#8
0
 public void ProcessForward(SimpleProtocolEventArgs args)
 {
     _args = args;
     DoForwardProcess(args);
     ForwardProcessStarted(this, args);
 }
示例#9
0
        private void BackwardProcessStarted(object sender, SimpleProtocolEventArgs e)
        {
            var alicePhaseAnimation = (ColorAnimation)FindResource("AlicePhaseShiftAnimation");
            var bobPhaseAnimation = (ColorAnimation)FindResource("BobPhaseShiftAnimation");
            var evaDetectorAnimation = (ColorAnimation)FindResource("EvaDetectorAnimation");
            var aliceDetectorAnimation = (ColorAnimation)FindResource("AliceDetectorAnimation");
            var photon1Animation = (DoubleAnimation)FindResource("MiddlePhoton1Animation");
            var photon2Animation = (DoubleAnimation)FindResource("MiddlePhoton2Animation");

            var eva1Animation = (PointAnimationUsingPath) FindResource("Eva1");
            var eva2Animation = (PointAnimationUsingPath)FindResource("Eva2");

            var aliceRng = (TextBlock)FindResource("AliceRng");
            var bobRng = (TextBlock)FindResource("BobRng");

            var fromEveToAliceAnimation = (Storyboard)FindResource("FromEveToAliceAnimation");
            var aliceBackwardAnimation = (Storyboard)FindResource("AliceBackwardAnimation");
            var aliceAlarmAnimation = (Timeline)FindResource("AliceDetectorAlarmAnimation");
            var storyboard = (Storyboard)FindResource("BackwardAnimation");

            var unblock1 = (Timeline)FindResource("Unblock1");
            var unblock2 = (Timeline)FindResource("Unblock2");
            var unblock3 = (Timeline)FindResource("Unblock3");
            var unblock4 = (Timeline)FindResource("Unblock4");

            alicePhaseAnimation.To = Math.Abs(e.Item.AlicePhase - e.Item.Phase0) < 1e-5 ? Colors.DeepSkyBlue : Colors.Orchid;
            bobPhaseAnimation.To = Math.Abs(e.Item.BobPhase - e.Item.Phase0) < 1e-5 ? Colors.DeepSkyBlue : Colors.Orchid;
            var destructiveInterference = Math.Abs(e.Item.AlicePhase - e.Item.BobPhase) < 1e-5;
            aliceRng.Text = e.Item.AliceValue ? "1" : "0";
            bobRng.Text = e.Item.BobValue ? "1" : "0";

            if (e.Item.CatchedByEva)
            {
                eva1Animation.PathGeometry = (PathGeometry) FindResource("EvaCatchedWay1");
                eva2Animation.PathGeometry = (PathGeometry)FindResource("EvaCatchedWay2");
                aliceBackwardAnimation.BeginTime = TimeSpan.FromSeconds(11);
                alicePhaseAnimation.BeginTime = TimeSpan.FromSeconds(2.9);
                aliceDetectorAnimation.BeginTime = TimeSpan.FromSeconds(9.9);
                aliceDetectorAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.3));
                aliceDetectorAnimation.To = Colors.Black;//Colors.GreenYellow;
                photon2Animation.To = photon1Animation.To = e.Item.IsBlocked ? 0 : 1;
                evaDetectorAnimation.To = e.Item.EvaResult == MeasurementResult.Inconclusive
                                              ? Colors.Blue
                                              : e.Item.EvaResult == MeasurementResult.Phase0
                                                    ? Colors.DeepSkyBlue
                                                    : Colors.Orchid;

                if (e.Item.IsBlocked)
                {
                    fromEveToAliceAnimation.Children.Remove(unblock1);
                    fromEveToAliceAnimation.Children.Remove(unblock3);
                    aliceBackwardAnimation.Children.Remove(unblock2);
                    aliceBackwardAnimation.Children.Remove(unblock4);
                    storyboard.Children.Remove(aliceAlarmAnimation);
                }
                else
                {
                    if (!fromEveToAliceAnimation.Children.Contains(unblock1))
                    {
                        fromEveToAliceAnimation.Children.Insert(2, unblock1);
                        fromEveToAliceAnimation.Children.Insert(fromEveToAliceAnimation.Children.Count - 1, unblock3);
                        aliceBackwardAnimation.Children.Insert(0, unblock4);
                        aliceBackwardAnimation.Children.Insert(0, unblock2);
                    }

                    if (!storyboard.Children.Contains(aliceAlarmAnimation))
                    {
                        storyboard.Children.Insert(storyboard.Children.Count - 1, aliceAlarmAnimation);
                    }
                }

                if (!storyboard.Children.Contains((Timeline) FindResource("EveMirrorAnimation")))
                {
                    storyboard.Children.Insert(storyboard.Children.Count - 1,
                                               (Timeline) FindResource("EveMirrorAnimation"));
                }
                if (!storyboard.Children.Contains(fromEveToAliceAnimation))
                {
                    storyboard.Children.Insert(storyboard.Children.Count - 1, fromEveToAliceAnimation);
                }

            }
            else
            {
                eva1Animation.PathGeometry = (PathGeometry)FindResource("EvaNoCatchWay1");
                eva2Animation.PathGeometry = (PathGeometry)FindResource("EvaNoCatchWay2");
                aliceBackwardAnimation.BeginTime = TimeSpan.FromSeconds(9);
                alicePhaseAnimation.BeginTime = TimeSpan.FromSeconds(3.9);
                aliceDetectorAnimation.BeginTime = TimeSpan.FromSeconds(10.9);
                aliceDetectorAnimation.Duration = new Duration(TimeSpan.FromSeconds(0.5));
                aliceDetectorAnimation.To = destructiveInterference ? Colors.Black : Colors.GreenYellow;
                photon2Animation.To = photon1Animation.To = destructiveInterference ? 0 : 1;
                evaDetectorAnimation.To = Colors.Black;
                storyboard.Children.Remove((Timeline)FindResource("EveMirrorAnimation"));
                storyboard.Children.Remove(fromEveToAliceAnimation);
                storyboard.Children.Remove(aliceAlarmAnimation);
                if (!aliceBackwardAnimation.Children.Contains(unblock2))
                {
                    aliceBackwardAnimation.Children.Insert(0, unblock4);
                    aliceBackwardAnimation.Children.Insert(0, unblock2);
                }
            }

            storyboard.Begin(this, true);
        }