本文整理汇总了C#中Signal类的典型用法代码示例。如果您正苦于以下问题:C# Signal类的具体用法?C# Signal怎么用?C# Signal使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Signal类属于命名空间,在下文中一共展示了Signal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Particle
public Particle(Signal signal)
{
this.done = false;
// Init the seek and flee
seek = new Seek();
seek.endingRadius = 0;
// Initialize the origin and target
origin.position = new Vector3(signal.origin.point.X, signal.origin.point.Y, 0);
target.position = new Vector3(signal.location.X, signal.location.Y, 0);
// Now move the origin a little
int alpha = GameMode.random.Next(10, 50);
int beta = GameMode.random.Next(10, 50);
float x = (float)GameMode.random.NextDouble() * 2 * alpha - alpha;
float y = (float)GameMode.random.NextDouble() * 2 * beta - beta;
origin.position += new Vector3(x, y, 0);
// And now the target
alpha = GameMode.random.Next(0, 100);
beta = GameMode.random.Next(0, 100);
x = (float)GameMode.random.NextDouble() * 2 * alpha - alpha;
y = (float)GameMode.random.NextDouble() * 2 * beta - beta;
target.position += new Vector3(x, y, 0);
}
示例2: EnterSignal
public override bool EnterSignal(Signal signal, Port parent, bool again, bool root)
{
if(again)
return false;
_signals.Add(signal);
return true;
}
示例3: Import
public Signal Import(FileInfo file)
{
string textFromFile;
using (StreamReader sr = file.OpenText())
{
textFromFile = sr.ReadToEnd();
}
textFromFile = textFromFile.Replace('.', ',');
textFromFile = textFromFile.Trim('\n', ' ');
string[] txtValues = textFromFile.Split(' ', '\n', '\t');
double[] values = new double[txtValues.Length];
for (int i = 0; i < txtValues.Length; ++i)
values[i] = double.Parse(txtValues[i]);
if (values.Length < 2)
{
throw new Exception("Should be at least 2 values in file!");
}
try
{
var s = new Signal(values, file.Name.Remove(file.Name.Length - 4));
return s;
}
catch (Exception ex)
{
throw ex;
}
}
示例4: RegisterTheorems
public static void RegisterTheorems(ILibrary library)
{
Analysis.DerivativeTransformation.Provider.Add(
new Analysis.DerivativeTransformation(_entityId,
delegate(Port port, SignalSet manipulatedInputs, Signal variable, bool hasManipulatedInputs)
{
Signal[] outputs = new Signal[manipulatedInputs.Count];
ReadOnlySignalSet cotangents = StdBuilder.Cotangent(port.InputSignals);
for(int i = 0; i < outputs.Length; i++)
outputs[i] = Std.Multiply(port.OutputSignals[i], cotangents[i], manipulatedInputs[i]);
return StdBuilder.Negate(outputs);
}));
MathIdentifier typeId = new MathIdentifier("TrigonometricSubstitute", "Std");
ITheoremProvider basicProvider;
if(!library.TryLookupTheoremType(typeId, out basicProvider))
{
basicProvider = Binder.GetInstance<ITransformationTheoremProvider, MathIdentifier>(typeId);
library.AddTheoremType(basicProvider);
}
((ITransformationTheoremProvider)basicProvider).Add(
new BasicTransformation(_entityId.DerivePostfix("TrigonometricSubstitute"), typeId,
delegate() { return new Pattern(new EntityCondition(_entityId)); },
delegate(Port port) { return ManipulationPlan.DoAlter; },
delegate(Port port, SignalSet transformedInputs, bool hasTransformedInputs)
{
return StdBuilder.Invert(StdBuilder.Sine(transformedInputs));
//Signal[] ret = new Signal[transformedInputs.Count];
//for(int i = 0; i < ret.Length; i++)
// ret[i] = Std.Invert(Std.Sine(transformedInputs[i]));
//return ret;
}));
}
示例5: EnterPort
public override bool EnterPort(Port port, Signal parent, bool again, bool root)
{
if(again)
return false;
_ports.Add(port);
return true;
}
示例6: GenericFunctionProcess
protected GenericFunctionProcess(bool[] inInput, bool[] inInternal, bool[] outOutput, bool[] outInternal)
{
if(inInput == null)
throw new ArgumentNullException("inInput");
if(inInternal == null)
throw new ArgumentNullException("inInternal");
if(outOutput == null)
throw new ArgumentNullException("outOutput");
if(outInternal == null)
throw new ArgumentNullException("outInternal");
this.inInput = inInput;
this.inInternal = inInternal;
this.outOutput = outOutput;
this.outInternal = outInternal;
//count mapped signals
for(int i = 0; i < inInput.Length; i++)
if(inInput[i]) inCount++;
for(int i = 0; i < inInternal.Length; i++)
if(inInternal[i]) inCount++;
for(int i = 0; i < outOutput.Length; i++)
if(outOutput[i]) outCount++;
for(int i = 0; i < outInternal.Length; i++)
if(outInternal[i]) outCount++;
inputs = new Signal[inCount];
outputs = new Signal[outCount];
}
示例7: Form1_FormClosing
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
{
degreesSignal.Stop();
degreesSignal.Dispose();
degreesSignal = null;
radiansSignal.Dispose();
radiansSignal = null;
sineSignal.Dispose();
sineSignal = null;
cosineSignal.Dispose();
cosineSignal = null;
signalTickCount.Dispose();
signalTickCount = null;
intervalChanged.Dispose();
intervalChanged = null;
runningEvent.Dispose();
runningEvent = null;
intervalBehavior.Dispose();
intervalBehavior = null;
runningBehavior.Dispose();
runningBehavior = null;
}
示例8: MonomialDegree
public static IValueStructure MonomialDegree(Signal signal, Signal[] generalizedVariables)
{
if(Std.IsConstantAdditiveIdentity(signal))
return NegativeInfinitySymbol.Instance;
if(Array.Exists<Signal>(generalizedVariables, signal.Equals))
return IntegerValue.One;
if(!Array.Exists<Signal>(generalizedVariables, signal.DependsOn))
return IntegerValue.Zero;
ISignalSet factors;
long deg = 0;
if(signal.IsDrivenByPortEntity("Multiply", "Std"))
factors = signal.DrivenByPort.InputSignals;
else
factors = new SignalSet(signal);
for(int i = 0; i < factors.Count; i++)
{
if(Array.Exists<Signal>(generalizedVariables, factors[i].Equals))
deg++;
else if(factors[i].IsDrivenByPortEntity("Power", "Std"))
{
Signal b = signal.DrivenByPort.InputSignals[0];
Signal e = signal.DrivenByPort.InputSignals[1];
IntegerValue v;
if(Array.Exists<Signal>(generalizedVariables, b.Equals) && (v = e.Value as IntegerValue) != null && v.Value > 0)
deg += v.Value;
}
}
return new IntegerValue(deg);
}
示例9: DescriptionTest
public void DescriptionTest()
{
var s = new Signal();
s.Description = null;
var validDescription = string.Empty;
var random = new Random(1);
for (int i = 0; i < Signal.MaxDescriptionLength; i++)
{
validDescription +=(char) random.Next(1, 255);
}
try
{
s.Description = validDescription;
}
catch (Exception)
{
Assert.Fail("Exception should not have been thrown.");
}
var invalidDescription = validDescription + (char)random.Next(1,255);
try
{
s.Description = invalidDescription;
Assert.Fail("ArgumentException should have been thrown.");
}
catch (ArgumentException)
{
}
Wfdb.Quit();
}
示例10: LogArgs
public LogArgs( string str, LogType p, Signal s )
{
Message = str;
Type = p;
sig = s;
timestamp = DateTime.Now;
}
示例11: IsMonomial
public static bool IsMonomial(Signal signal, Signal[] generalizedVariables)
{
if(signal.IsDrivenByPortEntity("Multiply", "Std"))
return signal.DrivenByPort.InputSignals.TrueForAll(delegate(Signal s) { return IsMonomialFactor(s, generalizedVariables); });
else
return IsMonomialFactor(signal, generalizedVariables);
}
示例12: JuliaFractal
public JuliaFractal(String algebra, String function, int precision, int iterations,
Point3 location = null, float x = -0.162f, float y = 0.163f, float z = 0.560f, float k = -0.599f,
Signal<float> rx = null, Signal<float> ry = null, Signal<float> rz = null, Signal<float> rk = null,
Point3 rotation = null, PovTexture texture = null, String finish = null, bool reactive = false)
{
this.reactive = reactive;
this.loc = location ?? new Point3(0, 0, 0, reactive: reactive);
this.rot = rotation ?? new Point3(0, 0, 0, reactive: reactive);
this.tex = texture ?? new POVColor("Red");
this.finish = finish ?? "finish {phong .9 reflection .5}";
this.x = rx ?? new Lift0f(x);
this.y = ry ?? new Lift0f(y);
this.z = rz ?? new Lift0f(z);
this.k = rk ?? new Lift0f(k);
if (algebra.Equals("quaternion"))
{
this.algebra = algebra;
}
else if (algebra.Equals(" hypercomplex"))
{
this.algebra = algebra;
}
else this.algebra = "quaternion";
this.precision = precision;
this.iterations = iterations;
this.function = function;
}
示例13: FulfillsCondition
public override bool FulfillsCondition(Signal output, Port port)
{
foreach(Condition c in _conditions)
if(!c.FulfillsCondition(output, port))
return false;
return true;
}
示例14: RaiseSignal
public bool RaiseSignal(Signal signal, long? id)
{
switch (signal)
{
case Signal.SOMEONE_WON:
foreach (var trigger in m_winTriggers)
if (trigger.IsTrue || trigger.RaiseSignal(signal, id))
{ //Won!
trigger.DisplayMessage(true);
Won = true;
return true;
}
foreach (var trigger in m_loseTriggers)
if (trigger.IsTrue || trigger.RaiseSignal(signal, id))
{//Lost
trigger.DisplayMessage(false);
Lost = true;
return true;
}
return false;
break;
default:
Debug.Assert(false,"Wrong signal received");
return false;
break;
}
}
示例15: ProcessFilter
/// <summary>
/// Applies the filter to a signal.
/// </summary>
protected unsafe override void ProcessFilter(Signal sourceData, Signal destinationData)
{
SampleFormat format = sourceData.SampleFormat;
int samples = sourceData.Samples;
if (format == SampleFormat.Format32BitIeeeFloat)
{
float* src = (float*)sourceData.Data.ToPointer();
float* dst = (float*)destinationData.Data.ToPointer();
for (int i = 0; i < samples; i++, dst++, src++)
*dst = System.Math.Abs(*src);
}
else if (format == SampleFormat.Format128BitComplex)
{
Complex* src = (Complex*)sourceData.Data.ToPointer();
Complex* dst = (Complex*)destinationData.Data.ToPointer();
Complex c = new Complex();
for (int i = 0; i < samples; i++, dst++, src++)
{
c.Re = (*src).Magnitude;
*dst = c;
}
}
}