GetEdge() публичный Метод

public GetEdge ( int channel ) : EdgeSense
channel int
Результат EdgeSense
Пример #1
0
        public override String ToString()
        {
            StringBuilder sb = new StringBuilder();

            // work out how many tabs are needed after the time field
            int maxTime       = LastEventTime;
            int maxTimeLength = maxTime.ToString().Length;
            int maxTabs       = maxTimeLength / 4 + 1;

            // Header
            sb.Append("t");
            for (int i = 0; i < maxTabs; i++)
            {
                sb.Append("\t");
            }
            for (int i = 0; i < channels; i++)
            {
                sb.Append(i + "\t");
            }
            sb.Append("\n");

            // Events
            foreach (DictionaryEntry ev in EventList)
            {
                int     time = (int)ev.Key;
                EdgeSet es   = (EdgeSet)ev.Value;
                // display this event
                sb.Append(time);
                // pad with tabs
                int timeLength = time.ToString().Length;
                int numTabs    = maxTabs - (timeLength / 4);
                for (int i = 0; i < numTabs; i++)
                {
                    sb.Append("\t");
                }
                for (int i = 0; i < channels; i++)
                {
                    EdgeSense sense = es.GetEdge(i);
                    if (sense == EdgeSense.NC)
                    {
                        sb.Append("-\t");
                    }
                    if (sense == EdgeSense.UP)
                    {
                        sb.Append("U\t");
                    }
                    if (sense == EdgeSense.DOWN)
                    {
                        sb.Append("D\t");
                    }
                }
                sb.Append("\n");
            }
            return(sb.ToString());
        }
Пример #2
0
		private UInt32 GenerateNextInt( UInt32 previousInt, EdgeSet es, bool throwError, int time)
		{
			// build a bit mask for the upwards edges
			UInt32 upMask = 0;
			for (int i = 0 ; i < 32 ; i++) if (es.GetEdge(i) == EdgeSense.UP) upMask = upMask | bitValues[i];
			// and the downwards edges
			UInt32 downMask = 0;
			for (int i = 0 ; i < 32 ; i++) if (es.GetEdge(i) == EdgeSense.DOWN) downMask = downMask | bitValues[i];
	  	
			// error checking
			if (throwError) 
			{
				if ( (upMask & previousInt) != 0 )
					throw new PatternBuildException("Edge conflict on upward edge at time " + time);
				if ( (downMask & ~previousInt) != 0 )
					throw new PatternBuildException("Edge conflict on downward edge at time " + time);
			}
			UInt32 returnInt = previousInt | upMask;
			returnInt = ~(~returnInt | downMask);
			return returnInt;
		}
Пример #3
0
        private UInt32 GenerateNextInt( UInt32 previousInt, EdgeSet es, bool throwError, int time)
        {
            // build a bit mask for the upwards edges
            UInt32 upMask = 0;
            for (int i = 0 ; i < 32 ; i++) if (es.GetEdge(i) == EdgeSense.UP) upMask = upMask | bitValues[i];
            // and the downwards edges
            UInt32 downMask = 0;
            for (int i = 0 ; i < 32 ; i++) if (es.GetEdge(i) == EdgeSense.DOWN) downMask = downMask | bitValues[i];

            // error checking
            if (throwError)
            {
                if ( (upMask & previousInt) != 0 )
                    throw new PatternBuildException("Edge conflict on upward edge at time " + time);
                if ( (downMask & ~previousInt) != 0 )
                    throw new PatternBuildException("Edge conflict on downward edge at time " + time);
            }
            UInt32 returnInt = previousInt | upMask;
            returnInt = ~(~returnInt | downMask);
            return returnInt;
        }