예제 #1
0
        public SignalDefenition BuildSignal()
        {
            if (_wires.Any())
            {
                var             min         = _wires.Min(x => x.Enumeration.Bottom);
                var             max         = _wires.Max(x => x.Enumeration.Bottom);
                EnumerationBase enumeration = null;
                string          valueType;
                if (min == max)
                {
                    valueType = "STD_LOGIC";
                }
                else
                {
                    valueType   = "STD_LOGIC_VECTOR";
                    enumeration = new ComplexEnumeration(max, min, EnumerationDirections.Downto);
                }
                _defenition.ValueType   = valueType;
                _defenition.Enumeration = enumeration;
                Router.InserSignalDefenition(_defenition.Name, valueType, enumeration);

                _wires.ForEach(x => Router.AddSignal(x));
                return(_defenition);
            }
            return(null);
        }
        public static AssignmentSignal Parse(ISignalsParentSection parent, string text, SignalDefenition defaultDefenition = null)
        {
            var signalStr = Regex.Match(text, PC.VHDLName + PC.MFS + PC.Enumeration).Value;
            var name      = Regex.Match(signalStr, PC.VHDLName).Value;

            name = string.IsNullOrEmpty(name)  ? Regex.Match(text, ParsConstants.VHDLName).Value : name;
            EnumerationBase enumeration = null;

            if (!String.IsNullOrEmpty(signalStr))
            {
                var enumerationStr = Regex.Match(signalStr, PC.Enumeration).Value;
                enumeration = EnumerationParser.Parse(enumerationStr);
                if (enumeration == null)
                {
                    return(null);
                }
            }

            var  isComponentPort = false;
            bool?isSource        = null;
            var  defenition      = defaultDefenition ?? parent.Document.Signals.GetSignalDefenition(name);

            if (defenition == null)
            {
                //Error unknown signal
                defenition = parent.Document.Entity.Ports.FirstOrDefault(x => x.Name == name);

                if (defenition == null)
                {
                    var component = parent.Document.Components
                                    .FirstOrDefault(x => x.Name == parent.EntityName);
                    if (component != null)
                    {
                        defenition = component.Ports.FirstOrDefault(f => f.Name == name);
                    }
                    else
                    {
                        defenition = new Port(null)
                        {
                            Name = name, PortType = PortTypes.In
                        };                                                                   //TODO Delete
                    }
                }
                isComponentPort = true;
                isSource        = (defenition as Port).PortType != PortTypes.In;
            }

            return(new AssignmentSignal(defenition, parent)
            {
                Name = Regex.Match(text, ParsConstants.VHDLName).Value,
                IsComponentPort = isComponentPort,
                IsSource = isSource,
                Enumeration = enumeration
            });
        }
예제 #3
0
        public void GetAll_ReturnsAllEnumerationValuesForType()
        {
            //ARRANGE
            var expectedCount = DummyEnumerationClass.CountOf();

            //ACT
            var results = EnumerationBase.GetAll <DummyEnumerationClass>().Count();

            //ASSERT
            results.ShouldBe(expectedCount);
        }
예제 #4
0
            public GetRoomForRentAnnouncementsInputQuery Convert(GetRoomForRentAnnouncementsRequest source, GetRoomForRentAnnouncementsInputQuery destination,
                                                                 ResolutionContext context)
            {
                var roomType = source.RoomType.HasValue
                    ? EnumerationBase.GetAll <RoomTypeEnumeration>().SingleOrDefault(x =>
                                                                                     Equals(x, ConvertToRoomTypeEnumeration(source.RoomType.Value)))
                    : null;

                return(new GetRoomForRentAnnouncementsInputQuery(source.Page, source.PageSize, source.Sort,
                                                                 source.CreatedFrom, source.CreatedTo, source.CityId, source.PriceFrom, source.PriceTo,
                                                                 roomType, source.CityDistrict));
            }
예제 #5
0
        public AssignmentSignal GetWire(EnumerationBase enumeration)
        {
            var result = new AssignmentSignal(_defenition, null)
            {
                Name            = Name,
                Enumeration     = enumeration,
                IsComponentPort = false
            };

            _wires.Add(result);
            return(result);
        }
예제 #6
0
        public SignalDefenition InserSignalDefenition(string name, string valueType, EnumerationBase enumeration = null)
        {
            SignalDefenition signal = new SignalDefenition(Document.Entity)
            {
                Name        = name,
                ValueType   = valueType,
                Enumeration = enumeration
            };

            AddObserv(signal);
            return(signal);
        }
예제 #7
0
 public bool Replace(SignalDefenition replaced, SignalDefenition signal, EnumerationBase enumeration = null)
 {
     if (_routes.ContainsKey(replaced.Name) && _routes.ContainsKey(signal.Name))
     {
         enumeration = enumeration ?? signal.Enumeration;
         var enumerationBits = enumeration?.Bits ?? 1;
         if (replaced.Bits == enumerationBits)
         {
             _routes[replaced.Name].Signals.ForEach(s => s.Replace(AssignmentSignal(s.SignalsParentSection, signal, enumeration)));
             _routes[replaced.Name].Signals.Clear();
             return(true);
         }
     }
     return(false);
 }
예제 #8
0
        public static Assignment Create(Map map, Port left, SignalDefenition right, EnumerationBase enumeration = null)
        {
            var result = new Assignment()
            {
                Map  = map,
                Text = left + " => " + right + ","
            };

            result._left = AssignmentSide.Create(result, left);
            result._rigt = AssignmentSide.Create(result, right, enumeration);

            if (!result.Validation())
            {
                throw new Exception("Inncorect bits");
            }
            return(result);
        }
예제 #9
0
 public static NumberOfRoomsEnumeration ConvertToNumberOfRoomsEnumeration(NumberOfRooms numberOfRooms)
 {
     return(EnumerationBase.GetAll <NumberOfRoomsEnumeration>()
            .SingleOrDefault(x => x.DisplayName.ToLower().Equals(numberOfRooms.ToString().ToLower())));
 }
예제 #10
0
 public static RoomTypeEnumeration ConvertToEnumeration(this RoomType?roomType)
 {
     return(!roomType.HasValue ?
            null :
            EnumerationBase.GetAll <RoomTypeEnumeration>().SingleOrDefault(x => x.DisplayName.ToLower().Equals(roomType.ToString().ToLower())));
 }
예제 #11
0
 public static TokenTypeEnumeration ConvertToEnumeration(this TokenType type)
 {
     return(EnumerationBase.GetAll <TokenTypeEnumeration>()
            .SingleOrDefault(x => x.DisplayName.ToLower().Equals(type.ToString().ToLower())));
 }
예제 #12
0
 public static AnnouncementSendingFrequencyEnumeration ConvertToEnumeration(this AnnouncementSendingFrequency announcementSendingFrequency)
 {
     return(EnumerationBase.GetAll <AnnouncementSendingFrequencyEnumeration>()
            .SingleOrDefault(x => x.DisplayName.ToLower().Equals(announcementSendingFrequency.ToString().ToLower())));
 }
예제 #13
0
 public PartialSignal(AssignmentSide parent, SignalDefenition defenition, EnumerationBase enumeration) : base(defenition, parent)
 {
     Name        = defenition.Name;
     Enumeration = enumeration;
 }
예제 #14
0
 public static RoomTypeEnumeration ConvertToRoomTypeEnumeration(RoomType roomType)
 {
     return(EnumerationBase.GetAll <RoomTypeEnumeration>()
            .SingleOrDefault(x => x.DisplayName.ToLower().Equals(roomType.ToString().ToLower())));
 }
예제 #15
0
        public static AssignmentSide Create(Assignment assignment, SignalDefenition defenition, EnumerationBase enumeration = null)
        {
            var result = new AssignmentSide(assignment, defenition.ToString());

            result.Signal = assignment.Document.Router.AssignmentSignal(result, defenition);
            return(result);
        }
예제 #16
0
        public AssignmentSignal AssignmentSignal(ISignalsParentSection parent, SignalDefenition defenition, EnumerationBase enumeration = null)
        {
            if (!_routes.ContainsKey(defenition.Name))
            {
                return(null);
            }
            enumeration = enumeration ?? defenition.Enumeration?.CloneEnumeration();
            var result = new AssignmentSignal(defenition, parent)
            {
                Name = defenition.Name, Enumeration = enumeration
            };

            _routes[defenition.Name].AddSignal(result);
            return(result);
        }