static double calculateEventSignal(Parameters p) { double d = 0D; foreach (Event e in p.eventList) d += e.calculateSignal(); return d; }
internal Event createEventEntry(Parameters p) { Event ev = new CreateBDFFile.Event(); if (GVPanel.Items.Count != 0) { ev.nextGVValues = new int[GVPanel.Items.Count]; ev.oldGVValues = new int[GVPanel.Items.Count]; } else ev.nextGVValues = ev.oldGVValues = null; SignalPs s = new SignalPs(); ev.times.Add(s); if ((bool)PeriodicRB.IsChecked) // Periodic event { ev.oType = Event.OccType.Periodic; ev.oP1 = Convert.ToDouble(period.Text); ev.nextTime = Utilities.UniformRND(0D,ev.oP1); //make first time random } else if ((bool)GaussianRB.IsChecked) // Random, Gaussian distribution { ev.oType = Event.OccType.Gaussian; ev.oP1 = Convert.ToDouble(GMean.Text); ev.oP2 = Convert.ToDouble(GSD.Text); ev.nextTime = Utilities.GaussRND(ev.oP1,ev.oP2); //schedule first occurence } else // Random, uniform distribution { ev.oType = Event.OccType.Uniform; ev.oP1 = Convert.ToDouble(UMin.Text); if (ev.oP1 < 0D) ev.oP1 = 0D; ev.oP2 = Convert.ToDouble(UMax.Text); ev.nextTime =Utilities.UniformRND(ev.oP1, ev.oP2); //schedule first occurence } s.time = -ev.nextTime; if ((bool)SNone.IsChecked) ev.sType = Event.SignalType.None; else if ((bool)SImpulse.IsChecked) { ev.sType = Event.SignalType.Impulse; ev.sP1 = Convert.ToDouble(BW.Text); } else // damped sinusoid { ev.sType = Event.SignalType.DampedSine; ev.sP1 = Convert.ToDouble(DSCoef.Text); ev.sP2 = Convert.ToDouble(DSDamp.Text); ev.sP3 = Convert.ToDouble(DSFreq.Text); ev.sP4 = Convert.ToDouble(DSPhase.Text); } ev.GVs = new List<GV>(); s.parameters[0] = ev.sP1; s.parameters[1] = ev.sP2; s.parameters[2] = ev.sP3; s.parameters[3] = ev.sP4; int i = 0; foreach (GVEntry gve in GVPanel.Items) { GV gv = gve.createGV(); int v = gv.nextValue(); ev.nextGVValues[i++] = v; if (gv.dType == GV.DependencyType.Coeff) s.parameters[0] *= gv.poly.evaluate((double)v); else if (gv.dType == GV.DependencyType.Damp) s.parameters[1] *= gv.poly.evaluate((double)v); else if (gv.dType == GV.DependencyType.Freq) s.parameters[2] *= gv.poly.evaluate((double)v); ev.GVs.Add(gv); } return ev; }