コード例 #1
0
        public void AddSameListenerMultipleTimesTest()
        {
            var signal = new Signal();

            var counter = 0;

            Slot listener1 = ((args) => { counter++; });

            signal.Add(listener1);
            signal.Add(listener1);

            signal.Dispatch();

            Assert.AreEqual(1, counter, "The listener should only be added once");
        }
コード例 #2
0
        public void AddTest()
        {
            var signal = new Signal();

            var counter = 0;

            Slot listener1 = ((args) => { counter += (int)args[0] + (int)args[1] + (int)args[2]; });
            Slot listener2 = ((args) => { counter += (int)args[0] + (int)args[1] + (int)args[2]; });

            signal.Add(listener1);
            signal.Add(listener2);

            signal.Dispatch(100, 10, 1);

            Assert.AreEqual(222, counter, "All listeners should have been called with all parameters");
        }
コード例 #3
0
        //восстановление сигналов и шума из old...
        public void AfterMagic()
        {
            Signal.Clear();
            Noise.Clear();
            OriginalSignal.Clear();
            OriginalNoise.Clear();



            foreach (double item in oldSignal)
            {
                Signal.Add(item);
            }

            foreach (double item in oldNoise)
            {
                Noise.Add(item);
            }

            foreach (double item in oldOriginalSignal)
            {
                OriginalSignal.Add(item);
            }

            foreach (double item in oldOriginalNoise)
            {
                OriginalNoise.Add(item);
            }
        }
コード例 #4
0
        public AFServer()
        {
            InitSmarfoxServer();

            onPause.Add(OnSistemPause);
            onPause.Dispatch(true);
        }
コード例 #5
0
        public void Priority2Test()
        {
            var signal = new Signal();

            var val = 0;

            Slot listener1 = ((args) => { val = 100; });
            Slot listener2 = ((args) => { val = 200; });

            signal.Add(listener1, 0);
            signal.Add(listener2, -100);

            signal.Dispatch();

            // we expect listener2 to be called the last
            Assert.AreEqual(200, val);
        }
コード例 #6
0
        static void Main(string[] args)
        {
            Network network = new Network();
            Layer layer2 = new Layer();
            Layer layer3 = new Layer();
            Node node1 = new Node(2);
            Node node2 = new Node(2);
            Node node3 = new Node(2);

            layer2.Add(node1);
            layer2.Add(node2);
            layer3.Add(node3);

            network.Add(layer2);
            network.Add(layer3);

            Dictionary<Signal, Signal> trainingSet = new Dictionary<Signal, Signal>();
            Signal signalFF = new Signal();
            Signal signalFT = new Signal();
            Signal signalTF = new Signal();
            Signal signalTT = new Signal();
            Signal signalF = new Signal();
            Signal signalT = new Signal();

            signalFF.Add(0.0); signalFF.Add(0.0);
            signalFT.Add(0.0); signalFT.Add(1.0);
            signalTF.Add(1.0); signalTF.Add(0.0);
            signalTT.Add(1.0); signalTT.Add(1.0);

            signalF.Add(0.0);
            signalT.Add(1.0);

            trainingSet.Add(signalFF, signalF);
            trainingSet.Add(signalFT, signalT);
            trainingSet.Add(signalTF, signalT);
            trainingSet.Add(signalTT, signalF);

            network.Train(trainingSet);

            Console.WriteLine("OutputFF: " + signalFF * network);
            Console.WriteLine("OutputFT: " + signalFT * network);
            Console.WriteLine("OutputTF: " + signalTF * network);
            Console.WriteLine("OutputTT: " + signalTT * network);

            Console.ReadLine();
        }
コード例 #7
0
ファイル: TestSignal.cs プロジェクト: paunaal/Utils
    // Use this for initialization
    void Start()
    {
        OnButtonPressed = new Signal <string>();

        OnButtonPressed.Add(ChangeColor);

        panel  = FindObjectOfType <Image>();
        button = FindObjectOfType <Button>();

        button.onClick.AddListener(() => OnButtonPressed.Dispatch("test"));
    }
コード例 #8
0
        public Signal Scale(Signal signal, double scaleCoefficient)
        {
            var scaledSignal = new Signal();

            foreach (var readout in signal.Readouts)
            {
                scaledSignal.Add(readout * scaleCoefficient);
            }

            return(scaledSignal);
        }
コード例 #9
0
        public void TestMethod1()
        {
            //
            // TODO: Testlogik hier einfügen
            //
            Signal signal = new Signal();

            signal.Add(State.Low);
            signal.Add(State.High);
            SignalList sigList = new SignalList();

            sigList.Add(signal);

            SignalData[] sigData;
            sigData = SignalConverter.Instance.ConvertFromSignalList(sigList);
            SignalList compare = SignalConverter.Instance.ConvertToSignalList(sigData);

            Assert.AreEqual <SignalList>(sigList, compare);
            //Assert.IsTrue(sigList.Equals(compare));
        }
コード例 #10
0
        public void UpdateSignal()
        {
            int    index   = Values.Count - SignalLength;
            var    subMacd = Values.GetRange(index, SignalLength);
            double signal  = 0;

            foreach (var delta in subMacd)
            {
                signal += delta;
            }
            signal /= SignalLength;
            Signal.Add(signal);
        }
コード例 #11
0
    public void Start()
    {
        //OnEvent += this.OnMyEvent;
        MyListenerDelegate myLisPtr = new MyListenerDelegate(this.SignalListener);

        Signal signal = new Signal();
        ISlot  slot   = signal.Add(myLisPtr);

        slot.Enabled = false;
        signal.Dispatch("aa");
        slot.Enabled = true;
        signal.Dispatch("bb");
    }
コード例 #12
0
        protected override decimal Calculate()
        {
            var emaShort = Short.Calculate();
            var emaLong  = Long.Calculate();
            var macd     = emaShort - emaLong;

            Signal.Add(macd);
            var signalLine = Signal.Calculate();

            currentmacd       = macd;
            currentSignalLine = signalLine;

            return(macd - signalLine);
        }
コード例 #13
0
 public Gen2SlaveInfo()
 {
     for (int i = 0; i < 60; i++)
     {
         Vol.Add("");
         Signal.Add("");
         Balance.Add("");
     }
     Signal.Add("");
     for (int i = 0; i < 10; i++)
     {
         TemSensor.Add("");
     }
 }
コード例 #14
0
        /// <summary>
        /// Converts a SignalData to a Signal
        /// </summary>
        /// <param name="signalData">the SignalData to convert</param>
        /// <returns>the converted Signal</returns>
        private Signal ConvertSignalData(SignalData signalData)
        {
            Signal signal = new Signal();

            signal.Name = signalData.Name;
            StateTypeConverter stateconv = new StateTypeConverter();

            foreach (StateData stateData in signalData.States)
            {
                State state = (State)stateconv.ConvertFrom(stateData.Level.Trim());
                signal.Add(new DurationState(state, stateData.Duration));
            }
            return(signal);
        }
コード例 #15
0
        public void RemoveTest()
        {
            var signal = new Signal();

            var  counter   = 0;
            Slot listener1 = ((args) => { counter++; });

            // add the listener
            signal.Add(listener1);
            signal.Dispatch();
            // and remove it again
            signal.Remove(listener1);
            signal.Dispatch();

            Assert.AreEqual(1, counter, "The listener should only be called once");
        }
コード例 #16
0
        private void GenerateSignal()
        {
            double y_i = 0;
            double t   = (double)T / N;

            for (double i = 0; i < 1; i += t / 10)
            {
                Time.Add(i);
                y_i = Math.Pow(Amplitude, K) * Math.Sin(2 * Math.PI * Frequency * i); //+ Math.Pow(2 * Amplitude, K) * Math.Sin(2 * Math.PI * 2 * Frequency * i);
                Signal.Add(y_i);
            }

            //CalcSum();
            Filter();
            CalculateAmplitude();
        }
コード例 #17
0
        //public decimal CurrentSpeed { get; set; }

        //private readonly FilterNearZero _filterNearZero = new FilterNearZero();

        public override void Add(decimal value)
        {
            this.Short.Add(value);
            this.Long.Add(value);
            // CurrentSpeed = Derivative(value);

            if (!this.Signal.IsValid())
            {
                var emaShort = Short.Calculate();
                var emaLong  = Long.Calculate();
                var macd     = emaShort - emaLong;
                Signal.Add(macd);
            }

            this.CurrentValue = Calculate();

            Derivative.Add(this.CurrentValue);
        }
コード例 #18
0
        public void Add_Inserts_Readout_Into_List()
        {
            const int    expectedReadoutsCount = 4;
            const double expectedReadout       = 3.14;
            var          readouts = new List <double> {
                3, 4, 5
            };

            var subject = new Signal {
                Readouts = readouts
            };

            subject.Add(expectedReadout);
            var result = subject.Readouts;

            Assert.That(result.Count(), Is.EqualTo(expectedReadoutsCount));
            Assert.That(result.Last(), Is.EqualTo(expectedReadout));
        }
コード例 #19
0
 private void OnAddDayNightHandler(MAddDayNightHandler msg)
 {
     onDayNight.Add(msg.handler);
 }
コード例 #20
0
 private void OnAddCamMoveHandler(MAddCameraMoveHandler msg)
 {
     onCameraMoveSig.Add(msg.handler);
 }