public SignalEventItem(Signal signal, ValueStructure newValue, SetValue setValue, SetEventFlag setEventFlag, NotifyNewValue notifyNewValue)
 {
     _signal = signal;
     _newValue = newValue;
     _setEventFlag = setEventFlag;
     _setValue = setValue;
     _notifyNewValue = notifyNewValue;
 }
Beispiel #2
0
        public Signal(Context context)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            _context = context;
            _iid     = _context.GenerateInstanceId();

            _properties  = new PropertyBag(context);
            _constraints = new PropertyBag(context);
            _eventQueue  = new SignalDelayedEventTimeline(context.Scheduler);

            _setValue = delegate(ValueStructure newValue)
            {
                if (newValue == null)
                {
                    return(false);
                }
                bool different = _presentStructure == null || !_presentStructure.Equals(newValue);
                _presentStructure = newValue;
                _properties.ValidatePropertiesAfterEvent(this);
                _context.NotifySignalValueChanged(this);
                return(different);
            };
            _setEventFlag   = delegate(bool flagEvent) { _hasEvent = flagEvent; };
            _notifyNewValue = delegate()
            {
                EventHandler <SignalEventArgs> handler = SignalValueChanged;
                if (handler != null)
                {
                    handler(this, new SignalEventArgs(this));
                }
            };

            context.NotifyNewSignalConstructed(this);
        }
Beispiel #3
0
 public CurveSegment(Curve segment, TimeSpan begin, ValueStructure offset)
 {
     this.Segment = segment;
     this.Begin = begin;
     this.Offset = offset;
 }
 public ConversionRouter LookupRouter(ValueStructure value)
 {
     return _table.GetValue(value.StructureId).Router;
 }
 public bool TryConvertFrom(ValueStructure value, out ValueStructure returnValue)
 {
     MathIdentifier id = value.StructureId;
     if(structureId.Equals(id))
     {
         returnValue = value;
         return true;
     }
     ConversionDistance cd;
     if(vector.TryGetValue(id, out cd))
     {
         returnValue = cd.Convert(value);
         return true;
     }
     returnValue = null;
     return false;
 }
 public bool CanConvertLossyFrom(ValueStructure value)
 {
     return value != null && CanConvertFrom(value.StructureId, true);
 }
        public ValueStructure ConvertFrom(ValueStructure value)
        {
            MathIdentifier id = value.StructureId;
            if(structureId.Equals(id))
                return value;
            ConversionDistance cd;
            if(vector.TryGetValue(id,out cd))
                return cd.Convert(value);

            throw new MathNet.Symbolics.Backend.Exceptions.IncompatibleStructureException(id.Label, id.Domain);
        }
 protected StructureNotSupportedException(SerializationInfo info, StreamingContext context)
     : base(info, context)
 {
     structure = (ValueStructure)info.GetValue("structure", typeof(ValueStructure));
 }
 public StructureNotSupportedException(ValueStructure structure)
 {
     this.structure = structure;
 }
Beispiel #10
0
 /// <summary>
 /// Returns the coefficient factor in the monomial <see cref="signal"/>
 /// </summary>
 /// <returns>
 /// Constant UndefinedSymbol if <see cref="signal"/> is not a single-variable monomial.
 /// Otherwise the coefficient factor of the term.
 /// </returns>
 /// </returns>
 /// <remarks><see cref="signal"/> is assumed to be automatic simplified.</remarks>
 public static Signal MonomialCoefficient(Signal signal, Signal variable, out ValueStructure degree)
 {
     if(IsConstantAdditiveIdentity(signal))
     {
         degree = NegativeInfinitySymbol.Instance;
         return signal;
     }
     if(IsAlwaysRational(signal))
     {
         degree = IntegerValue.Zero;
         return signal;
     }
     Signal coeff = IntegerValue.ConstantOne(signal.Context);
     if(signal.IsDrivenByPortEntity("Multiply", "Std") && signal.DrivenByPort.InputSignalCount == 2 && IsAlwaysRational(signal.DrivenByPort.InputSignals[0]))
     {
         coeff = signal.DrivenByPort.InputSignals[0];
         signal = signal.DrivenByPort.InputSignals[1];
     }
     if(signal.Equals(variable))
     {
         degree = IntegerValue.One;
         return coeff;
     }
     if(signal.IsDrivenByPortEntity("Power", "Std"))
     {
         Signal b = signal.DrivenByPort.InputSignals[0];
         Signal e = signal.DrivenByPort.InputSignals[1];
         if(b.Equals(variable) && Std.IsAlwaysPositiveInteger(e))
         {
             degree = e.Value;
             return coeff;
         }
     }
     degree = UndefinedSymbol.Instance;
     return UndefinedSymbol.Constant(signal.Context);
 }
Beispiel #11
0
 internal void BuilderSetValue(ValueStructure structure)
 {
     _presentStructure = structure;
 }
Beispiel #12
0
 public void PostNewValue(ValueStructure newValue, TimeSpan delay)
 {
     _context.Scheduler.ScheduleDelayedEvent(new TimedSignalEventItem(new SignalEventItem(this, newValue, _setValue, _setEventFlag, _notifyNewValue), delay));
 }
Beispiel #13
0
 public void PostNewValue(ValueStructure newValue)
 {
     _context.Scheduler.ScheduleDeltaEvent(new SignalEventItem(this, newValue, _setValue, _setEventFlag, _notifyNewValue));
 }
Beispiel #14
0
 public Signal(Context context, ValueStructure value)
     : this(context)
 {
     _presentStructure = value;
     //this.setValue(Value);
 }
 protected void PublishToOutputs(ValueStructure value, TimeSpan delay)
 {
     for(int i = 0; i < outputs.Length; i++)
         outputs[i].PostNewValue(value,delay);
 }
Beispiel #16
0
 public static StructurePack Pack(ValueStructure structure, Dictionary<Guid, Guid> signalMappings, Dictionary<Guid, Guid> busMappings)
 {
     StringBuilder sb = new StringBuilder();
     XmlWriterSettings settings = new XmlWriterSettings();
     settings.Encoding = Context.DefaultEncoding;
     settings.Indent = false;
     settings.ConformanceLevel = ConformanceLevel.Fragment;
     settings.NewLineHandling = NewLineHandling.Entitize;
     settings.OmitXmlDeclaration = true;
     XmlWriter writer = XmlWriter.Create(sb, settings);
     ValueStructure.Serialize(writer, structure);
     writer.Flush();
     writer.Close();
     return new StructurePack(sb.ToString());
 }