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"); }
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"); }
//восстановление сигналов и шума из 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); } }
public AFServer() { InitSmarfoxServer(); onPause.Add(OnSistemPause); onPause.Dispatch(true); }
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); }
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(); }
// 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")); }
public Signal Scale(Signal signal, double scaleCoefficient) { var scaledSignal = new Signal(); foreach (var readout in signal.Readouts) { scaledSignal.Add(readout * scaleCoefficient); } return(scaledSignal); }
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)); }
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); }
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"); }
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); }
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(""); } }
/// <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); }
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"); }
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(); }
//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); }
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)); }
private void OnAddDayNightHandler(MAddDayNightHandler msg) { onDayNight.Add(msg.handler); }
private void OnAddCamMoveHandler(MAddCameraMoveHandler msg) { onCameraMoveSig.Add(msg.handler); }