Ejemplo n.º 1
0
 Guid IPort_BuilderAdapter.AcceptSystemBuilder(ISystemBuilder builder, Dictionary <Guid, Guid> signalMappings, Dictionary <Guid, Guid> busMappings)
 {
     return(builder.BuildPort(_entity.EntityId,
                              BuilderMapSignals(_inputSignalSet, signalMappings),
                              BuilderMapSignals(_outputSignalSet, signalMappings),
                              BuilderMapBuses(_busSet, busMappings)));
 }
Ejemplo n.º 2
0
        public void ReadSystems(XmlReader reader, bool multiple)
        {
            _reader     = reader;
            _fsm.Reader = reader;
            _fsm.Reset();

            Dictionary <Guid, Guid> signalMappings = new Dictionary <Guid, Guid>();
            Dictionary <Guid, Guid> busMappings    = new Dictionary <Guid, Guid>();

            bool active = false;

            BuilderState state;

            while (BuilderState.Idle != (state = _fsm.ReadNextState()) || active)
            {
                switch (state)
                {
                case BuilderState.System:
                    int inputCnt  = int.Parse(_reader.GetAttribute("inputCount"), Context.NumberFormat);
                    int outputCnt = int.Parse(_reader.GetAttribute("outputCount"), Context.NumberFormat);
                    int busCnt    = int.Parse(_reader.GetAttribute("busCount"), Context.NumberFormat);
                    _reader.Read();
                    _builder.BeginBuildSystem(inputCnt, outputCnt, busCnt);
                    active = true;
                    break;

                case BuilderState.Signals:
                    _reader.Read();
                    while (ReadToElement() && _reader.LocalName == "Signal")
                    {
                        Guid   myGuid   = new Guid(_reader.GetAttribute("iid"));
                        string label    = _reader.GetAttribute("label");
                        bool   hold     = bool.Parse(_reader.GetAttribute("hold"));
                        bool   isSource = bool.Parse(_reader.GetAttribute("isSource"));
                        _reader.Read();
                        Guid tGuid = _builder.BuildSignal(label, hold, isSource);
                        signalMappings.Add(myGuid, tGuid);
                    }
                    break;

                case BuilderState.Buses:
                    _reader.Read();
                    while (ReadToElement() && _reader.LocalName == "Bus")
                    {
                        Guid   myGuid = new Guid(_reader.GetAttribute("iid"));
                        string label  = _reader.GetAttribute("label");
                        _reader.Read();
                        Guid tGuid = _builder.BuildBus(label);
                        busMappings.Add(myGuid, tGuid);
                    }
                    break;

                case BuilderState.Ports:
                    _reader.Read();
                    while (ReadToElement() && _reader.LocalName == "Port")
                    {
                        InstanceIdSet inputSignals  = new InstanceIdSet();
                        InstanceIdSet outputSignals = new InstanceIdSet();
                        InstanceIdSet buses         = new InstanceIdSet();
                        //Guid myGuid = new Guid(_reader.GetAttribute("iid"));
                        MathIdentifier entityId = MathIdentifier.Parse(_reader.GetAttribute("entityId"));
                        _reader.ReadToDescendant("InputSignals");
                        _reader.Read();
                        while (_reader.IsStartElement("SignalRef"))
                        {
                            inputSignals.Add(signalMappings[new Guid(_reader.ReadElementString())]);
                        }
                        _reader.ReadEndElement();
                        _reader.ReadToFollowing("OutputSignals");
                        _reader.Read();
                        while (_reader.IsStartElement("SignalRef"))
                        {
                            outputSignals.Add(signalMappings[new Guid(_reader.ReadElementString())]);
                        }
                        _reader.ReadEndElement();
                        _reader.ReadToFollowing("Buses");
                        _reader.Read();
                        while (_reader.IsStartElement("BusRef"))
                        {
                            buses.Add(busMappings[new Guid(_reader.ReadElementString())]);
                        }
                        _reader.ReadEndElement();
                        _builder.BuildPort(entityId, inputSignals, outputSignals, buses);
                    }
                    break;

                case BuilderState.SignalDetails:
                    _reader.Read();
                    while (ReadToElement())
                    {
                        Guid tGuid = signalMappings[new Guid(_reader.GetAttribute("iid"))];
                        switch (_reader.LocalName)
                        {
                        case "SignalValue":
                        {
                            StructurePack pack = StructurePack.Repack(_reader.ReadInnerXml(), signalMappings, busMappings);
                            _builder.AppendSignalValue(tGuid, pack);
                        }
                        break;

                        case "SignalProperty":
                        {
                            PropertyPack pack = PropertyPack.Repack(_reader.ReadInnerXml(), signalMappings, busMappings);
                            _builder.AppendSignalProperty(tGuid, pack);
                        }
                        break;

                        case "SignalConstraint":
                        {
                            PropertyPack pack = PropertyPack.Repack(_reader.ReadInnerXml(), signalMappings, busMappings);
                            _builder.AppendSignalConstraint(tGuid, pack);
                        }
                        break;
                        }
                    }
                    break;

                case BuilderState.InputSignals:
                    _reader.Read();
                    while (ReadToElement() && _reader.LocalName == "SignalRef")
                    {
                        Guid tGuid = signalMappings[new Guid(_reader.ReadElementString())];
                        _builder.AppendSystemInputSignal(tGuid);
                    }
                    break;

                case BuilderState.OutputSignals:
                    _reader.Read();
                    while (ReadToElement() && _reader.LocalName == "SignalRef")
                    {
                        Guid tGuid = signalMappings[new Guid(_reader.ReadElementString())];
                        _builder.AppendSystemOutputSignal(tGuid);
                    }
                    break;

                case BuilderState.NamedSignals:
                    _reader.Read();
                    while (ReadToElement() && _reader.LocalName == "SignalRef")
                    {
                        string name  = _reader.GetAttribute("name");
                        Guid   tGuid = signalMappings[new Guid(_reader.ReadElementString())];
                        _builder.AppendSystemNamedSignal(tGuid, name);
                    }
                    break;

                case BuilderState.NamedBuses:
                    _reader.Read();
                    while (ReadToElement() && _reader.LocalName == "BusRef")
                    {
                        string name  = _reader.GetAttribute("name");
                        Guid   tGuid = busMappings[new Guid(_reader.ReadElementString())];
                        _builder.AppendSystemNamedBus(tGuid, name);
                    }
                    break;

                case BuilderState.Idle:
                    _builder.EndBuildSystem();
                    active = false;
                    if (!multiple)
                    {
                        return;
                    }
                    break;
                }
            }
        }
Ejemplo n.º 3
0
 Guid IPort_BuilderAdapter.AcceptSystemBuilder(ISystemBuilder builder, Dictionary<Guid, Guid> signalMappings, Dictionary<Guid, Guid> busMappings)
 {
     return builder.BuildPort(_entity.EntityId,
         BuilderMapSignals(_inputSignalSet, signalMappings),
         BuilderMapSignals(_outputSignalSet, signalMappings),
         BuilderMapBuses(_busSet, busMappings));
 }