Beispiel #1
0
        private void BreakerOnOff(object obj)
        {
            try
            {
                bool NormalOpen = Open ? true : false;

                ProxyCE.ChangeBreakerStatus(GID, NormalOpen);

                if (NormalOpen == true)
                {
                    e = new Event("Breaker is opened", Enums.Component.SCADA, DateTime.Now);
                }
                else
                {
                    e = new Event("Breaker is closed", Enums.Component.SCADA, DateTime.Now);
                }


                events.WriteToFile(e);

                if (NormalOpen == true)
                {
                }

                for (int i = 0; i < Application.Current.Windows.Count; i++)
                {
                    if (Application.Current.Windows[i].Name == "BreakerControl")
                    {
                        Application.Current.Windows[i].Close();
                        break;
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("BreakerControlThroughGISWindowViewModel: " + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
Beispiel #2
0
        public void Command(double valueKW, FlexibilityIncDec incdec, long gid)
        {
            //ProxyCE.UpdateThroughUI(valueKW, incOrDec);
            string text = "";

            try
            {
                bool canManualCommand = false;

                if (incdec.Equals(FlexibilityIncDec.Increase))
                {
                    if (valueKW > 0)
                    {
                        if (valueKW > Inc)
                        {
                            if (Inc == 0)
                            {
                                text = "It's impossible to increase flexibility any more.";
                            }
                            else
                            {
                                text = "Please enter value between\n0 and " + String.Format("{0:0.00}", Inc);
                            }
                            canManualCommand = false;
                        }
                        else
                        {
                            canManualCommand = true;
                        }
                    }
                    else
                    {
                        text             = "Please enter positive value.";
                        canManualCommand = false;
                    }
                }
                else
                {
                    if (valueKW < 0)
                    {
                        if (-1 * valueKW > Dec)
                        {
                            if (Dec == 0)
                            {
                                text = "It's impossible to decrease flexibility any more.";
                            }
                            else
                            {
                                text = "Please enter value between\n0 and " + String.Format("{0:0.00}", Dec);
                            }
                            canManualCommand = false;
                        }
                        else
                        {
                            canManualCommand = true;
                        }
                    }
                    else
                    {
                        text             = "Please enter positive value.";
                        canManualCommand = false;
                    }
                }


                if (canManualCommand)
                {
                    ProxyCE.UpdateFlexibilityFromUIToCE(valueKW, incdec, gid);

                    Event        e  = new Event("Manual optimization was performed. ", Enums.Component.CalculationEngine, DateTime.Now);
                    EventsLogger el = new EventsLogger();

                    el.WriteToFile(e);
                }
                else
                {
                    PopUpWindow popUpWindow = new PopUpWindow(text);
                    popUpWindow.ShowDialog();
                }
            }
            catch (Exception e)
            {
                MessageBox.Show("ManualCommandingViewModel 34: " + e.Message, "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }