예제 #1
0
        /// <summary>
        /// Determines multiplier based on color value
        /// </summary>
        /// <param name="color"></param>
        /// <returns>Returns multiplier of color.</returns>
        public double GetMultiplier(string color)
        {
            try
            {
                List <Domain.Entity.Resistor> lstresistor = Domain.Entity.Resistor.LoadResistorData();
                Domain.Entity.Resistor        bandc       = lstresistor.Where(p => p.Name.ToLower() == color.ToLower()).SingleOrDefault();


                return(bandc.Multiplier);
            }
            catch (Exception ex)
            {
                logger.Handle(ex);

                return(-33);
            }
        }
예제 #2
0
        /// <summary>
        /// Determines tolerance value based on color.
        /// </summary>
        /// <param name="color">Name of color (e.g. Red, Green...)</param>
        /// <returns>Returns tolerance as a double</returns>
        public double GetTolerance(string color)
        {
            try
            {
                List <Domain.Entity.Resistor> lstresistor = Domain.Entity.Resistor.LoadResistorData();

                Domain.Entity.Resistor banda = lstresistor.Where(p => p.Name.ToLower() == color.ToLower() && p.Tolerance != Domain.Entity.Resistor.NO_COLOR).SingleOrDefault();

                return(banda.Tolerance);
            }
            catch (Exception ex)
            {
                logger.Handle(ex);

                return(-33);
            }
        }
예제 #3
0
        /// <summary>
        /// Calculates 2 digit ohm value based on 4 color band resistor values. A 5-6 band resistor would require 5-6 colors.
        /// </summary>
        /// <param name="bandAColor">The color of the first figure of component value band.</param>
        /// <param name="bandBColor">The color of the second significant figure band.</param>
        /// <param name="bandCColor">The color of the decimal multiplier band.</param>
        /// <param name="bandDColor">The color of the tolerance value band.</param>
        /// <returns>Two digit ohm value referencing significant band colors only.</returns>
        public int CalculateOhmValue(string bandAColor, string bandBColor, string bandCColor, string bandDColor)
        {
            try
            {
                List <Domain.Entity.Resistor> lstresistor = Domain.Entity.Resistor.LoadResistorData();
                Domain.Entity.Resistor        banda       = lstresistor.Where(p => p.Name.ToLower() == bandAColor.ToLower()).SingleOrDefault();
                Domain.Entity.Resistor        bandb       = lstresistor.Where(p => p.Name.ToLower() == bandBColor.ToLower()).SingleOrDefault();
                int ohmValue = 0;



                ohmValue = Convert.ToInt32(banda.Digit.ToString() + bandb.Digit.ToString());


                return(ohmValue);
            }
            catch (Exception ex)
            {
                logger.Handle(ex);

                return(-33);
            }
        }