예제 #1
0
        public void Interpret(FileInfo file, MathSystem system)
        {
            if(file == null)
                throw new ArgumentNullException("file");

            Interpret(file.OpenText(), system);
        }
예제 #2
0
 public Bridge(MathSystem system, Document document)
 {
     _system = system;
     _document = document;
     _signals = new Dictionary<Guid, SignalShape>();
     _buses = new Dictionary<Guid, BusShape>();
     _ports = new Dictionary<Guid, PortShape>();
 }
예제 #3
0
 public void Interpret(TextReader reader, MathSystem system)
 {
     if(scanner == null)
         scanner = new ParserScanner(reader, system);
     else
         scanner.Reset(reader, system);
     scanner.AllStatements();
 }
예제 #4
0
        public static MathSystem ReadXml(FileInfo file, Context context)
        {
            XmlReader  reader = XmlReader.Create(file.OpenText());
            MathSystem sys    = ReadXml(reader, context);

            reader.Close();
            return(sys);
        }
예제 #5
0
 public void ImportSystem(MathSystem system)
 {
     if (!system.HasSystemMediator)
     {
         system.SystemMediator = Binder.GetInstance <ISystemMediator>();
     }
     _namedSystems.Add(system.InstanceId, system);
 }
예제 #6
0
 public void ImportSystem(MathSystem system)
 {
     if (!system.HasMediator)
     {
         system.Mediator = new Mediator();
     }
     _namedSystems.Add(system.InstanceId, system);
 }
예제 #7
0
        public MathSystem AddSystem()
        {
            MathSystem system = new MathSystem(_context);

            system.Mediator = new Mediator();
            _namedSystems.Add(system.InstanceId, system);
            return(system);
        }
예제 #8
0
 private Bridge CreateBridge(MathSystem system)
 {
     Document doc = new Document();
     Bridge bridge = new Bridge(system, doc);
     _mathBridges.Add(system.InstanceId, bridge);
     _netronBridges.Add(doc, bridge);
     return bridge;
 }
예제 #9
0
        public MathSystem AddSystem()
        {
            MathSystem system = new MathSystem();

            Binder.GetInstance <ISystemMediator, IMathSystem>(system);
            //system.SystemMediator = Binder.GetInstance<ISystemMediator>();
            _namedSystems.Add(system.InstanceId, system);
            return(system);
        }
예제 #10
0
        public ParserScanner(TextReader reader, MathSystem system)
        {
            if(system == null)
                throw new ArgumentNullException("system");
            if(reader == null)
                throw new ArgumentNullException("reader");

            tokenizer = new ParserMarker(reader, system.Context);
            this.system = system;
            this.context = system.Context;
        }
예제 #11
0
        /// <summary>Clear the buffer. Replace the current stream with a new one.</summary>
        public void Reset(TextReader reader, MathSystem system)
        {
            if(system == null)
                throw new ArgumentNullException("system");
            if(reader == null)
                throw new ArgumentNullException("reader");

            this.system = system;
            this.context = system.Context;
            tokenizer.Reset(reader, context);
        }
예제 #12
0
        public Project()
        {
            Service <IPackageLoader> .Instance.LoadDefaultPackages();

            _namedSystems   = new Dictionary <Guid, MathSystem>();
            _localObservers = new List <ISystemObserver>();
            _parser         = Service <IParser> .Instance;
            _mediator       = Service <IMediator> .Instance;
            MathSystem sys = AddSystem();

            LoadSystem(sys.InstanceId);
        }
예제 #13
0
        public Project(Context context)
        {
            _context = context;
            _context.Library.LoadPackageManager(new MathNet.Symbolics.StdPackage.StdPackageManager(context));

            _namedSystems   = new Dictionary <Guid, MathSystem>();
            _localObservers = new List <ISystemObserver>();
            _parser         = new Parser();
            MathSystem sys = AddSystem();

            LoadSystem(sys.InstanceId);
        }
        public CompoundArchitecture(MathIdentifier id, MathIdentifier entityId, Port port, MathSystem system)
            : base(id, entityId, false)
        {
            this.inputSignals = port.InputSignals;
            this.outputSignals = port.OutputSignals;
            this.system = system;
            this.system.OutputValueChanged += system_OutputValueChanged;

            SetPort(port);

            for(int i = 0; i < inputSignals.Count; i++)
                inputSignals[i].SignalValueChanged += CompoundArchitecture_SignalValueChanged;
            system.PushInputValueRange(inputSignals);
        }
예제 #15
0
        private void UnloadSystem()
        {
            if (_currentSystem == null)
            {
                return;
            }

            foreach (ISystemObserver observer in _localObservers)
            {
                _currentSystem.Mediator.DetachObserver(observer);
            }

            _currentSystem = null;
        }
예제 #16
0
 public MathSystem BuildSystem()
 {
     if (!HasSystem)
     {
         Entity localEntity = entity;
         if (entity.IsGeneric)
         {
             localEntity = entity.CompileGenericEntity(1, 0);
         }
         Signal[]          inputs  = new Signal[localEntity.InputSignals.Length];
         ReadOnlySignalSet outputs = context.Builder.Functions(localEntity, inputs);
         system = new MathSystem(context);
         system.AddSignalTreeRange(outputs, true, true);
     }
     return(system);
 }
예제 #17
0
        public MathSystem BuildSystem()
        {
            if (!HasSystem)
            {
                IEntity localEntity = entity;
                if (entity.IsGeneric)
                {
                    localEntity = entity.CompileGenericEntity(1, 0, null);
                }
                Signal[]          inputs  = new Signal[localEntity.InputSignals.Length];
                ReadOnlySignalSet outputs = Service <IBuilder> .Instance.Functions(localEntity, inputs);

                system = new MathSystem();
                system.AddSignalTreeRange(outputs, true, true);
            }
            return(system);
        }
예제 #18
0
        private void LoadSystem(MathSystem system)
        {
            _currentSystem = system;

            if (!system.HasMediator)
            {
                system.Mediator = new Mediator();
            }

            foreach (ISystemObserver observer in _localObservers)
            {
                system.Mediator.AttachObserver(observer);
            }

            if (SystemLoaded != null)
            {
                SystemLoaded(this, EventArgs.Empty);
            }
        }
예제 #19
0
        private void LoadSystem(MathSystem system)
        {
            _currentSystem = system;

            if (!system.HasSystemMediator)
            {
                system.SystemMediator = Binder.GetInstance <ISystemMediator>();
            }

            foreach (ISystemObserver observer in _localObservers)
            {
                system.SystemMediator.AttachObserver(observer);
            }

            if (SystemLoaded != null)
            {
                SystemLoaded(this, EventArgs.Empty);
            }
        }
예제 #20
0
        /// <param name="inputSignalIndexes">note: negative indexes are interpreted as internal signal indexes, incremented by one (thus -1 means the internal signal with index zero)!</param>
        /// <param name="outputSignalIndexes">note: negative indexes are interpreted as internal signal indexes, incremented by one (thus -1 means the internal signal with index zero)!</param>
        public CompoundProcess(MathSystem system, int[] inputSignalIndexes, int[] outputSignalIndexes, int[] busIndexes)
        {
            this.system = system;
            this.inputSignalIndexes = inputSignalIndexes;
            this.outputSignalIndexes = outputSignalIndexes;
            this.busIndexes = busIndexes;

            if(inputSignalIndexes.Length != system.InputCount)
                throw new ArgumentException("The count of input signal mappings doesn't match the compound process structure.", "inputSignalIndexes");
            if(outputSignalIndexes.Length != system.OutputCount)
                throw new ArgumentException("The count of output signal mappings doesn't match the compound process structure.", "outputSignalIndexes");
            if(busIndexes.Length != system.BusCount)
                throw new ArgumentException("The count of bus mappings doesn't match the compound process structure.", "busIndexes");

            this.inputSignals = new Signal[inputSignalIndexes.Length];
            this.outputSignals = new Signal[outputSignalIndexes.Length];
            this.buses = new Bus[busIndexes.Length];

            this.system.OutputValueChanged += system_OutputValueChanged;
        }
예제 #21
0
        private void LoadSystem(MathSystem system)
        {
            _currentSystem = system;

            if(!system.HasMediator)
                system.Mediator = new Mediator();

            foreach(ISystemObserver observer in _localObservers)
                system.Mediator.AttachObserver(observer);

            if(SystemLoaded != null)
                SystemLoaded(this, EventArgs.Empty);
        }
예제 #22
0
 public void ImportSystem(MathSystem system)
 {
     if(!system.HasMediator)
         system.Mediator = new Mediator();
     _namedSystems.Add(system.InstanceId, system);
 }
예제 #23
0
 public MathSystem AddSystem()
 {
     MathSystem system = new MathSystem(_context);
     system.Mediator = new Mediator();
     _namedSystems.Add(system.InstanceId, system);
     return system;
 }
예제 #24
0
 protected abstract void UnloadSystem(MathSystem system);
예제 #25
0
 public MathSystem BuildSystem()
 {
     if(!HasSystem)
     {
         IEntity localEntity = entity;
         if(entity.IsGeneric)
             localEntity = entity.CompileGenericEntity(1,0,null);
         Signal[] inputs = new Signal[localEntity.InputSignals.Length];
         ReadOnlySignalSet outputs = Service<IBuilder>.Instance.Functions(localEntity, inputs);
         system = new MathSystem();
         system.AddSignalTreeRange(outputs, true, true);
     }
     return system;
 }
예제 #26
0
 public void AttachedToSystem(MathSystem system)
 {
     LoadSystem(system);
 }
예제 #27
0
 public MathFunction(MathSystem system)
 {
     this.system = system;
 }
예제 #28
0
 protected override void UnloadSystem(MathSystem system)
 {
 }
예제 #29
0
 public MathFunction(Context context, Entity entity, MathSystem system)
 {
     this.context = context;
     this.entity  = entity;
     this.system  = system;
 }
 public CompoundArchitectureFactory(MathIdentifier architectureId, MathIdentifier entityId, MathSystem system)
 {
     _architectureId = architectureId;
     _entityId = entityId;
     _inputCnt = system.InputCount;
     _outputCnt = system.OutputCount;
     _busCnt = system.BusCount;
     _xml = system.WriteXml(false);
 }
예제 #31
0
 public MathFunction(Context context, MathSystem system)
 {
     this.context = context;
     this.system  = system;
 }
예제 #32
0
 public MathFunction(Context context, Signal outputSignal, params Signal[] inputSignals)
 {
     this.context = context;
     this.system  = new MathSystem(context);
     system.AddSignalTree(outputSignal, inputSignals, true, true);
 }
예제 #33
0
 public ParserScanner(TextReader reader, MathSystem system)
 {
     tokenizer = new ParserMarker(reader, system.Context);
     this.system = system;
     this.context = system.Context;
 }
        public CompoundArchitectureFactory(MathIdentifier architectureId, MathIdentifier entityId, MathSystem system)
        {
            if(system == null)
                throw new ArgumentNullException("system");

            _architectureId = architectureId;
            _entityId = entityId;
            _inputCnt = system.InputCount;
            _outputCnt = system.OutputCount;
            _busCnt = system.BusCount;
            _xml = system.WriteXml(false);
        }
예제 #35
0
        private void UnloadSystem()
        {
            if(_currentSystem == null)
                return;

            foreach(ISystemObserver observer in _localObservers)
                _currentSystem.Mediator.DetachObserver(observer);

            _currentSystem = null;
        }
예제 #36
0
 public void Interpret(string expression, MathSystem system)
 {
     Interpret(new StringReader(expression), system);
 }
예제 #37
0
 public void DetachedFromSystem(MathSystem system)
 {
     UnloadSystem(system);
 }
예제 #38
0
 protected override void LoadSystem(MathSystem system)
 {
     Bridge bridge;
     if(!_mathBridges.ContainsKey(system.InstanceId))
         bridge = CreateBridge(system);
     else
         bridge = _mathBridges[system.InstanceId];
     _presentation.AttachToDocument(bridge.Document);
     _bridge = bridge;
 }
예제 #39
0
 public MathFunction(IEntity entity, MathSystem system)
 {
     this.entity = entity;
     this.system = system;
 }
예제 #40
0
 public void AttachedToSystem(MathSystem system)
 {
     _currentSysId = system.InstanceId;
     _writer.WriteEntry(DateTime.Now, _currentSysId, LogAction.SystemChanged, _emptyGuid, _emptyGuid, _emptyGuid, _emptyId, -1);
 }
예제 #41
0
 public MathFunction(Signal outputSignal, params Signal[] inputSignals)
 {
     this.system = new MathSystem();
     system.AddSignalTree(outputSignal, inputSignals, true, true);
 }
예제 #42
0
 public void DetachedFromSystem(MathSystem system)
 {
 }
예제 #43
0
 public MathFunction(IEntity entity, MathSystem system)
 {
     this.entity = entity;
     this.system = system;
 }
예제 #44
0
 public void ReadSystem(MathSystem system)
 {
     system.AcceptSystemBuilder(_builder);
 }
예제 #45
0
 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);
 }
예제 #46
0
 public MathFunction(MathSystem system)
 {
     this.system = system;
 }
예제 #47
0
 /// <summary>Clear the buffer. Replace the current stream with a new one.</summary>
 public void Reset(TextReader reader, MathSystem system)
 {
     this.system = system;
     this.context = system.Context;
     tokenizer.Reset(reader, context);
 }
예제 #48
0
 public MathFunction(Signal outputSignal, params Signal[] inputSignals)
 {
     this.system = new MathSystem();
     system.AddSignalTree(outputSignal, inputSignals, true, true);
 }