Beispiel #1
0
        /// <summary>
        /// Devuelve los sistemas de fases que utiliza la aplicación.
        /// </summary>
        /// <returns>Los sistemas de fases que utiliza la aplicación.</returns>
        public static IEnumerable <SistemaFases> GetApplicationSystemPhases()
        {
            SistemaFases[] sistemas  = new SistemaFases[12];
            TensionVal[]   tensiones = new TensionVal[]
            { TensionVal.T_220, TensionVal.T_480, TensionVal.T_208, TensionVal.T_440 };
            SistemaFases sys;

            for (int index = 0, i = 1; index < sistemas.Length; index++, i++)
            {
                if (index < 4)
                {
                    sys = new SistemaTrifasico();
                }
                else if (index < 8)
                {
                    sys = new SistemaBifasico();
                }
                else
                {
                    sys = new SistemaMonofasico();
                }
                sys.SetTension(tensiones[i - 1]);
                sistemas[index] = sys;
                if (i % 4 == 0)
                {
                    i = 1;
                }
            }
            return(sistemas);
        }
Beispiel #2
0
        /// <summary>
        /// Devuelve el indice del sistema
        /// </summary>
        /// <param name="sistema">El sistema a extraer el indice</param>
        /// <returns>El indice del sistema</returns>
        public static int GetIndexOfSystem(this SistemaFases sistema)
        {
            TensionVal[] tensiones = new TensionVal[]
            { TensionVal.T_220, TensionVal.T_480, TensionVal.T_208, TensionVal.T_440 };
            int tIndex = tensiones.ToList().IndexOf((TensionVal)sistema.Tension.Value);

            if (sistema.Fases == 3)
            {
                tIndex += 0;
            }
            else if (sistema.Fases == 2)
            {
                tIndex += 4;
            }
            else
            {
                tIndex += 7;
            }
            return(tIndex);
        }
        /// <summary>
        /// Maneja el evento que realizá la carga inicial del control
        /// </summary>
        /// <param name="sender">La fuente del evento.</param>
        /// <param name="e">Los argumentos de tipo <see cref="RoutedEventArgs"/> que contienen la información del evento.</param>
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            string imgGalleryPath = PathIO.Combine(PathIO.GetDirectoryName(Assembly.GetAssembly(typeof(NewComponent)).Location), IMG_FOLDER, COMPONENT_FOLDER);

            this.Sistema = TabalimApp.CurrentTablero.Sistema;
            this.FillCircuitosList(this.ExistantComponent);
            if (this.ExistantComponent != null)
            {
                this.CType = this.ExistantComponent is Motor ? ComponentType.Motor :
                             this.ExistantComponent is Alumbrado ? ComponentType.Alumbrado :
                             this.ExistantComponent is Contacto ? ComponentType.Contacto : ComponentType.None;
                this.ImageIndex       = this.ExistantComponent.ImageIndex;
                this.Count            = this.ExistantComponent.Count;
                this.miniature.Source = this.ImageIndex.LoadImage(imgGalleryPath, 32, true);
                if (this.ExistantComponent.Circuito != null)
                {
                    this.Fases = this.ExistantComponent.Circuito.Polos.Length;
                    this.powerSelector.ExistantInput = new Object[]
                    {
                        this.Fases,
                        this.CType == ComponentType.Motor?PowerType.HP: PowerType.Watts,
                        this.ExistantComponent.Potencia
                    };
                    int index = 0, selectedIndex = -1;
                    foreach (CtoItem item in this.listOfCircuits.ItemsSource)
                    {
                        if (item.CtoName == this.ExistantComponent.Circuito.ToString())
                        {
                            selectedIndex = index;
                            break;
                        }
                        index++;
                    }
                    this.listOfCircuits.SelectedIndex = selectedIndex;
                    this.btnPickComponent.IsEnabled   = false;
                    this.optOne.IsEnabled             = false;
                    this.optTwo.IsEnabled             = false;
                    this.optThree.IsEnabled           = false;
                    var circuits = UiUtils.GetAvailableCircuitos(TabalimApp.CurrentTablero, this.Fases, this.CType == ComponentType.Motor);
                    if (this.ExistantComponent is Motor)
                    {
                        circuits = circuits.Union(new Circuito[] { this.ExistantComponent.Circuito }).OrderBy(x => x.ToString());
                    }
                    this.listOfCircuits.ItemsSource = circuits.Select(x => new CtoItem(x));
                    int ctoIndex = this.listOfCircuits.ItemsSource.OfType <CtoItem>().Select(x => x.CtoName).ToList().IndexOf(this.ExistantComponent.Circuito.ToString());
                    this.listOfCircuits.SelectedIndex = ctoIndex;
                }
                else
                {
                    this.Fases = 1;
                    this.listOfCircuits.SelectedIndex = -1;
                    this.UpdatePowerSelector();
                }
            }
            else
            {
                this.Count = 1;
                this.Fases = 1;
                this.CType = ComponentType.None;
            }
            this.IsCtrlLoaded = true;
        }