Beispiel #1
0
 public void Copy(FactorData data)
 {
     foreach(KeyValuePair<eFactorData,double> pair in data.m_dicData)
     {
         IncreaseData(pair.Key, pair.Value);
     }
 }
Beispiel #2
0
        public static IEnumerable <WTRViewModel> CustomSelectEmployeeByWeek(this HtmlHelper helper, IEnumerable <WTRViewModel> wtrList, int weekNum, int Year)
        {
            List <WTRViewModel> result = new List <WTRViewModel>();

            foreach (var wtrPerson in wtrList)
            {
                WTRViewModel onePerson = new WTRViewModel {
                    ID = wtrPerson.ID, FirstName = wtrPerson.FirstName, LastName = wtrPerson.LastName, FactorDetails = new List <FactorData>()
                };

                foreach (var fData in wtrPerson.FactorDetails)
                {
                    if (fData.WeekNumber == weekNum && fData.From.Year == Year)
                    {
                        FactorData data = new FactorData();
                        data.Factor     = fData.Factor;
                        data.From       = fData.From;
                        data.To         = fData.To;
                        data.Hours      = 0;
                        data.WeekNumber = fData.WeekNumber;
                        data.Location   = fData.Location;
                        onePerson.FactorDetails.Add(data);
                    }
                }
                if (onePerson.FactorDetails.Count > 0)
                {
                    result.Add(onePerson);
                }
            }
            return(result);
        }
Beispiel #3
0
 /// <summary>
 /// Construct the Stats with its new() constructor. Then pass it in.
 /// </summary>
 /// <param name="values"></param>
 public void AssignFactorData(FactorData values)
 {
     if (values != null && _stats == null)
     {
         _stats = values;
         UpdateName();
     }
 }
Beispiel #4
0
    //This is digging into the https://en.wikipedia.org/wiki/Great_Oxygenation_Event
    //Purpose here is to simulate the early starts.
    //We want to see:
    //Early H2+CO2 environment
    //Methanogenesis harnesses H2+CO2 into CH4 and water
    //
    //Heavy creation of O2
    //Create of CO2/CH4 (Anaerobic processes)
    //Death of Obligate Anaerobes.
    //Huronian Glaciation with freezing for potential snowball earth.
    public void PopulateEnvFactorsForEarlyEarth()
    {
        //All of these could be loaded from a file in the future (and saved to files for later simulation/debugging)
        FactorData newValue = new FactorData(H2, 5, new Vector2(0, 100), transform.position, planetaryRadius);

        RegisterNewEnvironmentFactor(newValue);

        newValue = new FactorData(O2, 2, new Vector2(0, 100), transform.position, planetaryRadius);
        RegisterNewEnvironmentFactor(newValue);

        newValue = new FactorData(N2, 90, new Vector2(0, 100), transform.position, planetaryRadius);
        RegisterNewEnvironmentFactor(newValue);

        newValue = new FactorData(CH4, 1f, new Vector2(0, 100), transform.position, planetaryRadius);
        RegisterNewEnvironmentFactor(newValue);

        newValue = new FactorData(Ar, 1.93f, new Vector2(0, 100), transform.position, planetaryRadius);
        RegisterNewEnvironmentFactor(newValue);

        //Get some metal in here for Anaerobic Corrosion
        newValue = new FactorData(UnrustedMetals, 35, new Vector2(0, 100), transform.position, planetaryRadius);
        RegisterNewEnvironmentFactor(newValue);

        newValue = new FactorData(CO2, 4.038f, new Vector2(0, 100), transform.position, planetaryRadius);
        RegisterNewEnvironmentFactor(newValue);

        //This isn't an accurate value, but lets me represent the consumption of available unstable carbon.
        newValue = new FactorData(SolidCarbon, 40f, new Vector2(0, 100000), transform.position, planetaryRadius);
        RegisterNewEnvironmentFactor(newValue);

        //This is in Kelvin. Avg temperature is a 287 (14 degrees Celsius)
        newValue = new FactorData(Temperature, 287, new Vector2(0, 5778), transform.position, planetaryRadius);
        RegisterNewEnvironmentFactor(newValue);

        //This+Solid+gaseous = all water
        newValue = new FactorData(LiquidH20, 69.74f, new Vector2(0, 100), transform.position, planetaryRadius);
        RegisterNewEnvironmentFactor(newValue);

        //70% of the earth is covered with water. 2% is fresh water. 90% of that is frozen.
        newValue = new FactorData(SolidH20, 1.26f, new Vector2(0, 100), transform.position, planetaryRadius);
        RegisterNewEnvironmentFactor(newValue);

        newValue = new FactorData(GaseousH20, .001f, new Vector2(0, 100), transform.position, planetaryRadius);
        RegisterNewEnvironmentFactor(newValue);

        newValue = new FactorData(SingleCellLife, .001f, new Vector2(0, 100), transform.position, planetaryRadius);
        RegisterNewEnvironmentFactor(newValue);

        newValue = new FactorData(Anaerobes, 1, new Vector2(0, 5000), transform.position, planetaryRadius);
        RegisterNewEnvironmentFactor(newValue);

        newValue = new FactorData(Cyanobacteria, .02f, new Vector2(0, 5000), transform.position, planetaryRadius);
        RegisterNewEnvironmentFactor(newValue);

        newValue = new FactorData(Methanogens, .02f, new Vector2(0, 5000), transform.position, planetaryRadius);
        RegisterNewEnvironmentFactor(newValue);
    }
Beispiel #5
0
        public PartialViewResult GetWTRData(string From = "", string To = "", string searchString = "")
        {
            DateTime fromParsed = DateTime.Now;
            DateTime toParse    = DateTime.Now;
            int      FromYear   = DateTime.Now.Year;
            int      ToYear     = DateTime.Now.Year;

            DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo;
            Calendar           cal = dfi.Calendar;

            if (From != "" && To != "")
            {
                fromParsed = DateTime.ParseExact(From, "dd.MM.yyyy", null);
                toParse    = DateTime.ParseExact(To, "dd.MM.yyyy", null);
                FromYear   = fromParsed.Year;
                ToYear     = toParse.Year;
            }
            else
            {
                return(PartialView("GetWTRDataEmpty"));
            }

            searchString = searchString != "" ? searchString.Trim() : "";
            List <Employee>     selectedData = new List <Employee>();
            List <WTRViewModel> wtrDataList  = new List <WTRViewModel>();

            selectedData = SearchEmployeeData(fromParsed, toParse, repository.Employees.ToList(), searchString);

            foreach (var emp in selectedData)
            {
                WTRViewModel onePerson = new WTRViewModel {
                    ID = emp.EID, FirstName = emp.FirstName, LastName = emp.LastName, FactorDetails = new List <FactorData>()
                };
                foreach (var calendarItems in emp.CalendarItems)
                {
                    FactorData data = new FactorData();
                    data.Factor     = calendarItems.Type;
                    data.Location   = calendarItems.Location;
                    data.From       = calendarItems.From;
                    data.To         = calendarItems.To;
                    data.Hours      = 0;
                    data.WeekNumber = cal.GetWeekOfYear(calendarItems.From, dfi.CalendarWeekRule, dfi.FirstDayOfWeek);
                    onePerson.FactorDetails.Add(data);
                }
                wtrDataList.Add(onePerson);
            }

            ViewBag.FromWeek = cal.GetWeekOfYear(fromParsed, dfi.CalendarWeekRule, dfi.FirstDayOfWeek);
            ViewBag.ToWeek   = cal.GetWeekOfYear(toParse, dfi.CalendarWeekRule, dfi.FirstDayOfWeek);
            ViewBag.FromYear = FromYear;
            ViewBag.ToYear   = ToYear;

            ViewBag.fromDate = From;
            ViewBag.toDate   = To;

            return(PartialView(wtrDataList));
        }
Beispiel #6
0
    private void RegisterNewEnvironmentFactor(FactorData newFactor)
    {
        EnvFactor newEnvFactor = AddNewEnvironmentFactor(newFactor);

        //We track the dictionary for easy references
        factors.Add(newFactor.Key, newEnvFactor);

        //But we also have two lists to make it cheaper to iterate. Iterating over a dictionary is very expensive.
        FactorNames.Add(newFactor.Key);
        AllFactors.Add(newEnvFactor);
    }
Beispiel #7
0
        public PartialViewResult GetWTRDataPerEMP(string From = "", string To = "", string userName = "")
        {
            DateTime fromParsed = DateTime.Now;
            DateTime toParse    = DateTime.Now;
            int      FromYear   = DateTime.Now.Year;
            int      ToYear     = DateTime.Now.Year;

            DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo;
            Calendar           cal = dfi.Calendar;

            if (From != "" && To != "")
            {
                fromParsed = DateTime.ParseExact(From, "dd.MM.yyyy", null);
                toParse    = DateTime.ParseExact(To, "dd.MM.yyyy", null);
                FromYear   = fromParsed.Year;
                ToYear     = toParse.Year;
            }
            else
            {
                return(PartialView("GetWTRDataEmpty"));
            }

            List <WTRViewModel> wtrDataList = new List <WTRViewModel>();
            Employee            employee    = repository.Employees.Where(e => e.EID == userName).FirstOrDefault();

            if (employee == null)
            {
                return(PartialView("NoData"));
            }

            WTRViewModel onePerson = new WTRViewModel {
                ID = employee.EID, FirstName = employee.FirstName, LastName = employee.LastName, FactorDetails = new List <FactorData>()
            };

            foreach (var calendarItems in employee.CalendarItems)
            {
                FactorData data = new FactorData();
                data.Factor     = calendarItems.Type;
                data.Location   = calendarItems.Location;
                data.From       = calendarItems.From;
                data.To         = calendarItems.To;
                data.Hours      = 0;
                data.WeekNumber = cal.GetWeekOfYear(calendarItems.From, dfi.CalendarWeekRule, dfi.FirstDayOfWeek);
                onePerson.FactorDetails.Add(data);
            }
            wtrDataList.Add(onePerson);

            ViewBag.FromWeek = cal.GetWeekOfYear(fromParsed, dfi.CalendarWeekRule, dfi.FirstDayOfWeek);
            ViewBag.ToWeek   = cal.GetWeekOfYear(toParse, dfi.CalendarWeekRule, dfi.FirstDayOfWeek);
            ViewBag.FromYear = FromYear;
            ViewBag.ToYear   = ToYear;

            return(PartialView("GetWTRData", wtrDataList));
        }
Beispiel #8
0
    /// <summary>
    /// Define FactorData separate of the MonoBehavior component. This lets us test/simulate outside of Unity more easily.
    /// </summary>
    /// <param name="values">Just use new FactorData(params)</param>
    /// <returns>The component created on a new game object</returns>
    private EnvFactor AddNewEnvironmentFactor(FactorData values)
    {
        GameObject go = new GameObject();

        EnvFactor newFactor = go.AddComponent <EnvFactor>();

        go.transform.SetParent(transform);

        newFactor.AssignFactorData(values);
        return(newFactor);
    }
        public void FillData()
        {
            SQLiteTableReader reader = new SQLiteTableReader(null, Program.DbPath);

            reader.Connect();
            DataTable factorTable = reader.ExecuteQuery("SELECT tm.factor_id as id, tm.factor_type, t0.text as FactorName, t1.text as FactorDesc FROM (SELECT factor_id, factor_type FROM succession_factor) as tm, (SELECT \"index\", text FROM text_data WHERE category=147) as t0, (SELECT \"index\", text FROM text_data WHERE category=172) as t1 WHERE tm.factor_id = t0.\"index\" AND tm.factor_id = t1.\"index\"");

            reader.Disconnect();
            for (int i = 0; i < factorTable.Rows.Count; i++)
            {
                FactorData data = new FactorData();
                data.Id         = (long)factorTable.Rows[i]["id"];
                data.FactorType = (FactorType)factorTable.Rows[i]["factor_type"];
                data.Desc       = (string)factorTable.Rows[i]["FactorDesc"];
                data.Desc       = data.Desc.Replace("\\n", "");
                data.SetName((string)factorTable.Rows[i]["FactorName"]);
                if (!FactorDataList.Exists(a => a.Name.Equals(data.Name)))
                {
                    string transName = Program.TransDict.GetTranslation(transDict, data.Name);
                    if (string.IsNullOrEmpty(transName))
                    {
                        transName = string.Empty;
                    }
                    data.NameTrans = transName;
                    string transDesc = Program.TransDict.GetTranslation(transDict, data.Desc);
                    if (string.IsNullOrEmpty(transDesc))
                    {
                        transDesc = string.Empty;
                    }
                    data.DescTrans = transDesc;
                    FactorDataList.Add(data);
                }
            }

            for (int i = 0; i < FactorDataList.Count; i++)
            {
                KeyValuePair <int, StringData> data = new KeyValuePair <int, StringData>(i, new StringData(FactorDataList[i].NameToCheck));
                int key = FactorDataList[i].NameToCheck.Length;
                if (factorListByName.ContainsKey(key))
                {
                    factorListByName[key].Add(data);
                }
                else
                {
                    factorListByName.Add(key, new List <KeyValuePair <int, StringData> >()
                    {
                        data
                    });
                }
            }
        }
Beispiel #10
0
    /// <summary>
    /// This was my first attempt at simulating the modern day atmosphere and factors on the surface.
    /// I rapidly decided to start with an Early Earth for the Great Oxygenation Extinction.
    /// </summary>
    public void PopulateEnvFactorsForCurrentDay()
    {
        //This code is not used, but a test case for the idea of creating factors and having them be influenced by the planet.
        FactorData newValue = new FactorData(O2, 21, new Vector2(0, 100), transform.position, planetaryRadius);

        RegisterNewEnvironmentFactor(newValue);

        newValue = new FactorData(N2, 78, new Vector2(0, 100), transform.position, planetaryRadius);
        RegisterNewEnvironmentFactor(newValue);

        newValue = new FactorData(CH4, 0.00017f, new Vector2(0, 100), transform.position, planetaryRadius);
        RegisterNewEnvironmentFactor(newValue);

        newValue = new FactorData(Ar, 0.93f, new Vector2(0, 100), transform.position, planetaryRadius);
        RegisterNewEnvironmentFactor(newValue);

        newValue = new FactorData(CO2, 0.038f, new Vector2(0, 100), transform.position, planetaryRadius);
        RegisterNewEnvironmentFactor(newValue);

        newValue = new FactorData(SolidCarbon, 0.038f, new Vector2(0, 100000), transform.position, planetaryRadius);
        RegisterNewEnvironmentFactor(newValue);

        newValue = new FactorData(Temperature, 284, new Vector2(0, 5778), transform.position, planetaryRadius);
        RegisterNewEnvironmentFactor(newValue);

        //This+Solid+gaseous = all water
        newValue = new FactorData(LiquidH20, 69.74f, new Vector2(0, 100), transform.position, planetaryRadius);
        RegisterNewEnvironmentFactor(newValue);

        //70% of the earth is covered with water. 2% is fresh water. 90% of that is frozen.
        newValue = new FactorData(SolidH20, 1.26f, new Vector2(0, 100), transform.position, planetaryRadius);
        RegisterNewEnvironmentFactor(newValue);

        newValue = new FactorData(GaseousH20, .001f, new Vector2(0, 100), transform.position, planetaryRadius);
        RegisterNewEnvironmentFactor(newValue);

        newValue = new FactorData(SingleCellLife, .001f, new Vector2(0, 100), transform.position, planetaryRadius);
        RegisterNewEnvironmentFactor(newValue);

        newValue = new FactorData(Anaerobes, 1, new Vector2(0, 5000), transform.position, planetaryRadius);
        RegisterNewEnvironmentFactor(newValue);
    }
Beispiel #11
0
 public void AddFactorData(string strKey, FactorData factorData)
 {
     m_dicFactor.Remove(strKey);
     m_dicFactor.Add(strKey, factorData);
     m_bRefresh = true;
 }
Beispiel #12
0
 public abstract void ModifyTarget(ref FactorData value);
Beispiel #13
0
 public abstract bool IsConditionMet(ref FactorData value);
Beispiel #14
0
 //Decided not to support this. I'd use a XOR on Evaluate to get the intended behavior.
 //public bool Not = false;
 public Requirement(ref FactorData FactorToObserve, Condition ConditionOnFactor)
 {
     Observed     = FactorToObserve;
     IfObservedIs = ConditionOnFactor;
 }
Beispiel #15
0
 public override void ModifyTarget(ref FactorData value)
 {
     value.Strength = value.StrengthRange.y;
 }
Beispiel #16
0
 public override bool IsConditionMet(ref FactorData value)
 {
     return(value.Strength < GatewayValue);
 }
Beispiel #17
0
 public override void ModifyTarget(ref FactorData value)
 {
     value.Strength += Factor.Strength * Adjustment * Time.deltaTime;
 }
Beispiel #18
0
 public override void ModifyTarget(ref FactorData value)
 {
     //Debug.Log("Applying " + value.Key + " Mult by % & dt  " + value.Strength + " *  " + PercentChangePerSecond + "  /  " + Time.deltaTime + "\n");
     value.Strength = value.Strength * (PercentChangePerSecond * Time.deltaTime);
 }
Beispiel #19
0
 public RefAdjustValueByDeltaTime(float adjustment, ref FactorData factor)
 {
     Adjustment = adjustment;
     Factor     = factor;
 }
Beispiel #20
0
 public override void ModifyTarget(ref FactorData value)
 {
     //Later we would want to step away from Time.deltaTime so we could control our simulation better.
     value.Strength += Adjustment * Time.deltaTime;
 }
Beispiel #21
0
 public override void ModifyTarget(ref FactorData value)
 {
     value.Strength += Adjustment;
 }
Beispiel #22
0
 public override bool IsConditionMet(ref FactorData value)
 {
     return(value.Strength > Range.x && value.Strength < Range.y);
 }
Beispiel #23
0
 public Result(ref FactorData TargetFactor, Modification newModification)
 {
     Target         = TargetFactor;
     TargetModified = newModification;
 }