Exemplo n.º 1
0
Arquivo: GA.cs Projeto: EMS-Master/EMS
        public GA(float necessaryEnergy, Dictionary <long, OptimisationModel> optModelMap)
        {
            EmsContext e = new EmsContext();

            commandedGeneratrs        = new Dictionary <long, OptimisationModel>();
            CommandedGenGidsAndValues = e.CommandedGenerators.Where(x => x.CommandingFlag).ToDictionary(x => x.Gid, x => x.CommandingValue);
            this.optModelMap          = optModelMap.Where(x => !CommandedGenGidsAndValues.Any(y => y.Key == x.Key)).ToDictionary(param => param.Key, param => param.Value);
            MaxValuePerGen            = 1000000f;
            foreach (var item in CommandedGenGidsAndValues)
            {
                var comm = optModelMap.FirstOrDefault(x => x.Key == item.Key);
                if (comm.Value != null)
                {
                    comm.Value.MeasuredValue = item.Value;
                    comm.Value.measurementUnit.CurrentValue = item.Value;
                    comm.Value.GenericOptimizedValue        = item.Value;
                    commandedGeneratrs.Add(item.Key, comm.Value);
                }
            }

            indexToGid = new Dictionary <int, long>();
            int i = 0;

            foreach (var valPair in this.optModelMap)
            {
                indexToGid.Add(i++, valPair.Key);
            }

            this.NecessaryEnergy = necessaryEnergy - commandedGeneratrs.Sum(x => x.Value.MeasuredValue);
            if (this.NecessaryEnergy <= 0)
            {
                this.NecessaryEnergy = 0;
            }
        }
Exemplo n.º 2
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values[0] is IEnumerable <MeasurementUI> measUIs)
            {
                var generator = measUIs.LastOrDefault();
                if (generator.GeneratorType != FTN.Common.GeneratorType.Wind && generator.GeneratorType != FTN.Common.GeneratorType.Solar && generator.GeneratorType != FTN.Common.GeneratorType.Hydro)
                {
                    //List<CommandedGenerator> gen = new List<CommandedGenerator>();
                    //gen = DbManager.Instance.GetCommandedGenerators().Where(x => x.CommandingFlag && x.CommandingValue != 0).Select(x => x).ToList();
                    EmsContext e = new EmsContext();
                    bool       commandingFlag = e.CommandedGenerators.FirstOrDefault(x => x.Gid == generator.Gid).CommandingFlag; //DbManager.Instance.GetCommandedGenerator(generator.Gid).CommandingFlag; //e.CommandedGenerators.FirstOrDefault(x => x.Gid == generator.Gid).CommandingFlag;
                    if (commandingFlag)
                    {
                        return(Visibility.Visible);
                    }
                    else
                    {
                        return(Visibility.Collapsed);
                    }
                }
                else
                {
                    return(Visibility.Collapsed);
                }
            }

            return(Visibility.Collapsed);
        }
        public ManagersController(EmsContext context)
        {
            _context = context;

            if (Startup.ResetManagerDatabase == true)
            {
                Startup.ResetManagerDatabase = false;
                _context.Managers.RemoveRange(_context.Managers);
                _context.SaveChanges();

                var vighnesh = _context.Employees.Where(e => e.Name == "Vighnesh").First().Id;
                var omkar    = _context.Employees.Where(e => e.Name == "Omkar").First().Id;
                var bhanu    = _context.Employees.Where(e => e.Name == "Bhanu").First().Id;
                var shubham  = _context.Employees.Where(e => e.Name == "Shubham").First().Id;

                _context.Managers.Add(new Managers
                {
                    EmployeeId = shubham,
                    ManagerId  = omkar
                });
                _context.Managers.Add(new Managers
                {
                    EmployeeId = bhanu,
                    ManagerId  = omkar
                });
                _context.Managers.Add(new Managers
                {
                    EmployeeId = omkar,
                    ManagerId  = vighnesh
                });

                _context.SaveChanges();
            }
        }
        public ManagerController(EmsContext context, List <Manager> managers)
        {
            _context = context;

            foreach (Manager manager in managers)
            {
                _context._managers.Add(manager);
            }
        }
Exemplo n.º 5
0
        private List <AlarmHelper> SelectAlarmsFromDatabase()
        {
            List <AlarmHelper> alarms = new List <AlarmHelper>();

            EmsContext ems = new EmsContext();

            try
            {
                var alarmsdb = ems.Alarms.ToList();

                foreach (var item in alarmsdb)
                {
                    AlarmHelper alarm = new AlarmHelper
                    {
                        Gid          = item.Gid,
                        Severity     = (SeverityLevel)item.Severity,
                        Value        = item.AlarmValue,
                        MinValue     = item.MinValue,
                        MaxValue     = item.MaxValue,
                        TimeStamp    = item.AlarmTimeStamp,
                        CurrentState = item.CurrentState,
                        AckState     = (AckState)item.AckState,
                        PubStatus    = (PublishingStatus)item.PubStatus,
                        Type         = (AlarmType)item.AlarmType,
                        Message      = item.AlarmMessage,
                    };

                    alarms.Add(alarm);
                }
            }
            catch (Exception e)
            {
                string message = string.Format("Failed read alarms from database. {0}", e.Message);
                CommonTrace.WriteTrace(CommonTrace.TraceError, message);
                Console.WriteLine(message);
            }

            return(alarms);
        }
Exemplo n.º 6
0
        public EmployeesController(EmsContext context)
        {
            _context = context;

            if (Startup.ResetEmployeeDatabase == true)
            {
                Startup.ResetEmployeeDatabase = false;
                _context.Employees.RemoveRange(_context.Employees);
                _context.SaveChanges();

                _context.Employees.Add(new Employee
                {
                    Name   = "Vighnesh",
                    Age    = 21,
                    Salary = 10000000
                });
                _context.Employees.Add(new Employee
                {
                    Name   = "Shubham",
                    Age    = 30,
                    Salary = 1232123
                });
                _context.Employees.Add(new Employee
                {
                    Name   = "Omkar",
                    Age    = 32,
                    Salary = 131232
                });
                _context.Employees.Add(new Employee
                {
                    Name   = "Bhanu",
                    Age    = 45,
                    Salary = 12313200
                });
                _context.SaveChanges();
            }
        }
Exemplo n.º 7
0
        private bool InsertAlarmIntoDb(AlarmHelper alarm)
        {
            bool success = true;

            EmsContext ems = new EmsContext();

            try
            {
                Alarm a = new Alarm()
                {
                    Gid            = alarm.Gid,
                    AlarmValue     = alarm.Value,
                    MinValue       = alarm.MinValue,
                    MaxValue       = alarm.MaxValue,
                    AlarmTimeStamp = alarm.TimeStamp,
                    AckState       = alarm.AckState,
                    AlarmType      = alarm.Type,
                    AlarmMessage   = alarm.Message,
                    Severity       = alarm.Severity,
                    CurrentState   = alarm.CurrentState
                };

                ems.Alarms.Add(a);
                ems.SaveChanges();
            }

            catch (Exception e)
            {
                success = false;
                string message = string.Format("Failed to insert alarm into database. {0}", e.Message);
                CommonTrace.WriteTrace(CommonTrace.TraceError, message);
                Console.WriteLine(message);
            }

            return(success);
        }
        public ManagerController(EmsContext context)
        {
            _context = context;

            if (_context._managers.Count() == 0)
            {
                _context._managers.Add(new Manager {
                    Name = "vighnesh", Salary = 600000
                });
                _context._managers.Add(new Manager {
                    Name = "shubham", Salary = 600000
                });
                _context._managers.Add(new Manager {
                    Name = "bhanu", Salary = 600000
                });
                _context._managers.Add(new Manager {
                    Name = "raunak", Salary = 600000
                });
                _context._managers.Add(new Manager {
                    Name = "omkar", Salary = 600000
                });
                _context.SaveChanges();
            }
        }
Exemplo n.º 9
0
 public ModuleRepository(EmsContext context) : base(context)
 {
 }
Exemplo n.º 10
0
 public BaseRepository(EmsContext context)
 {
     _context = context;
 }
Exemplo n.º 11
0
 public EmployeeService(EmsContext context) : base(context)
 {
 }
Exemplo n.º 12
0
 public GeneralService(EmsContext context)
 {
     this.Context = context;
 }
Exemplo n.º 13
0
 public TechnicalProfileRepository(EmsContext context) : base(context)
 {
 }
Exemplo n.º 14
0
 public UnityOfWork(EmsContext context)
 {
     _context = context;
 }
Exemplo n.º 15
0
 public DepartmentRepository(EmsContext context)
 {
     this.context = context;
 }