private void ScanDefineArchitecture() { tokenizer.Match(TokenTypes.TextIdentifier, "architecture"); MathIdentifier architectureId = ScanEntityMathIdentifierOrLabel(true); MathIdentifier entityId = ScanEntityMathIdentifierOrLabel(true); Entity entity = context.Library.LookupEntity(entityId); tokenizer.Match("{"); MathSystem originalSystem = system; MathSystem tempSystem = new MathSystem(system.Context); system = tempSystem; while(tokenizer.LookaheadFistToken.Text != "}") NextStatement(); foreach(string input in entity.InputSignals) tempSystem.PromoteAsInput(tempSystem.LookupNamedSignal(input)); foreach(string output in entity.OutputSignals) tempSystem.AddSignalTree(tempSystem.LookupNamedSignal(output), tempSystem.GetAllInputs(), true, false); ReadOnlyCollection<Signal> leafs = tempSystem.GetAllLeafSignals(); foreach(Signal s in leafs) { Signal so; if(originalSystem.TryLookupNamedSignal(s.Label, out so) && so.Value != null) s.PostNewValue(so.Value); } context.Scheduler.SimulateInstant(); system = originalSystem; tokenizer.Match("}"); tempSystem.RemoveUnusedObjects(); tempSystem.PublishToLibrary(architectureId, entity.EntityId); }
public MathFunction(Signal outputSignal, params Signal[] inputSignals) { this.system = new MathSystem(); system.AddSignalTree(outputSignal, inputSignals, true, true); }
void context_OnSignalDrivenByPort(object sender, SignalPortIndexEventArgs e) { _currentSystem.AddSignalTree(e.Signal, false, true); _currentSystem.UnpromoteAsInput(e.Signal); }
public MathFunction(Context context, Signal outputSignal, params Signal[] inputSignals) { this.context = context; this.system = new MathSystem(context); system.AddSignalTree(outputSignal, inputSignals, true, true); }
void IObserver.OnPortDrivesSignal(Signal signal, Port port, int outputIndex) { _currentSystem.AddSignalTree(signal, false, true); _currentSystem.UnpromoteAsInput(signal); }
private void btnBuildSample_Click(object sender, EventArgs e) { s = _project.CurrentSystem; Context c = s.Context; Builder b = c.Builder; Signal x = new Signal(c); x.Label = "x"; x.AddConstraint(RealSetProperty.Instance); Signal x2 = b.Square(x); x2.Label = "x2"; Signal sinx2 = Std.Sine(c, x2); sinx2.Label = "sinx2"; Signal sinx2t2 = sinx2 * IntegerValue.ConstantTwo(c); Signal sinx2t2cosx = sinx2t2 + Std.Cosine(c, x); sinx2t2cosx.Label = "sinx2t2cosx"; s.AddSignalTree(sinx2t2, true, true); }