/// <summary> /// 获取年度用能数据 /// </summary> /// <param name="regionID"></param> /// <param name="energyItemCode"></param> /// <param name="startTime"></param> /// <param name="endTime"></param> /// <returns></returns> public EnergyData GetYearData(string regionID, string energyItemCode, string startTime, string endTime) { DataTable dt = new DataTable(); EnergyData energyData = new EnergyData(); string MonthSQL = @"SELECT Region.F_RegionID AS ID,Region.F_RegionName AS Name ,DATEADD(YEAR,DATEDIFF(YEAR,0,DayResult.F_StartDay),0) AS 'Time' ,SUM((CASE WHEN RegionMeter.F_Operator ='加' THEN 1 ELSE -1 END)*DayResult.F_Value * RegionMeter.F_Rate/100) AS Value FROM T_MC_MeterDayResult DayResult INNER JOIN T_ST_CircuitMeterInfo Circuit ON DayResult.F_MeterID = Circuit.F_MeterID INNER JOIN T_DT_EnergyItemDict EnergyItem ON Circuit.F_EnergyItemCode = EnergyItem.F_EnergyItemCode INNER JOIN T_ST_MeterParamInfo ParamInfo ON DayResult.F_MeterParamID = ParamInfo.F_MeterParamID INNER JOIN T_ST_RegionMeter RegionMeter ON DayResult.F_MeterID = RegionMeter.F_MeterID INNER JOIN T_ST_Region Region ON Region.F_RegionID = RegionMeter.F_RegionID WHERE Region.F_RegionID ='" + regionID + @"' AND EnergyItem.F_EnergyItemCode='" + energyItemCode + @"' AND ParamInfo.F_IsEnergyValue = 1 AND DayResult.F_StartDay BETWEEN '" + startTime + @"' AND '" + endTime + @"' GROUP BY Region.F_RegionID,Region.F_RegionName,DATEADD(YEAR,DATEDIFF(YEAR,0,DayResult.F_StartDay),0) ORDER BY ID,'Time' ASC"; dt = SQLHelper.GetDataTable(MonthSQL); if (dt.Rows.Count > 0) { energyData.ID = dt.Rows[0]["ID"].ToString(); energyData.Name = dt.Rows[0]["Name"].ToString(); energyData.Time = dt.Rows[0]["Time"].ToString(); energyData.Value = Convert.ToDecimal(dt.Rows[0]["Value"]); } return(energyData); }
public EnergyData GetByDate(int projectId, DateTime dt) { var projectInfo = _dictProjectIdToInfo.First(e => e.Key == projectId); EnergyData entry = projectInfo.Value.listEnergyData.First(e => e.TimeStamp.Day == dt.Day); return(entry); }
public SimulatedAnnealing(Learner l) { SimulatedAnnealingRunningParameters pam; using (var file = File.OpenText(@"SimulatedAnnealingParameters.json")) { var serializer = new JsonSerializer(); pam = (SimulatedAnnealingRunningParameters) serializer.Deserialize(file, typeof(SimulatedAnnealingRunningParameters)); } learner = l; threshold = pam.ThresholdTemperature; coolingFactor = pam.CoolingFactor; currentIteration = bestIteration = 1; reportEveryNIterations = pam.ReportEveryNIteration; currentHypothesis = bestHypothesis = learner.GetInitialGrammar(); currentHypothesis.GenerateDerivedRulesFromSchema(); currentEnergy = bestEnergy = learner.Energy(currentHypothesis); currentHypothesis.GenerateInitialRulesFromDerivedRules(); currentTemp = currentEnergy.TotalEnergy * pam.InitialTemperatureTimesInitialEnegrgy; using (var sw = File.AppendText("SessionReport.txt")) { sw.WriteLine(string.Format("cooling factor: {0}, initial energy: {1}, initial temperature: {2}", coolingFactor, currentEnergy, currentTemp)); } }
/// <summary> /// Inicializa o controlador de energia do inimigo /// </summary> /// /// <param name="energyData"> /// Os dados de energia do inimigo /// </param> public override void onBuild(EnergyData energyData) { base.onBuild(energyData); float shield = energyData.shieldMultiplier.randomInRange(20), speed = energyData.speedMultiplier.randomInRange(20), weapon = energyData.weaponMultiplier.randomInRange(20), remainingEnergy = (energyData.totalEnergy - (shield + speed + weapon)) / 3f ; shield += remainingEnergy; speed += remainingEnergy; weapon += remainingEnergy; if (energyController.multipliers == null) { energyController.multipliers = new Multipliers( onValueChange: (slider) => energyController.updateSpaceshipStatus(), shield, speed, weapon ); } else { energyController.multipliers[Sliders.Shield, raw : true] = shield; energyController.multipliers[Sliders.Speed, raw : true] = speed; energyController.multipliers[Sliders.Weapon, raw : true] = weapon; } }
public void PlayerHit(PlayerData player, EnergyData energy) { _playerManager.DamagePlayer(player.id, energy.damage); _playerViewOutputController.DisplayPlayerHit(player.id, energy.damage); _playerViewOutputController.UpdatePlayerView(ConvertToPlayerData(player.id)); }
private void Start() { actorData = FindObjects.GameLogic.GetComponent <ActorData>(); energyData = FindObjects.GameLogic.GetComponent <EnergyData>(); minDrain = energyData.ModNormal; maxHP = 14; }
public ConfigurationGrid2D <TNode, TEnergyData> SmartClone() { return(new ConfigurationGrid2D <TNode, TEnergyData>( RoomShape, Position, EnergyData.SmartClone(), Room )); }
public Configuration <TEnergyData> SmartClone() { return(new Configuration <TEnergyData>( ShapeContainer, Position, EnergyData.SmartClone(), Node )); }
/// <summary> /// Inicializa o controlador de energia da nave /// </summary> /// /// <param name="energyData"> /// Os dados de energia da nave /// </param> public virtual void onBuild(EnergyData energyData) { if (energyController.attackController == null) { energyController.attackController = attackController; energyController.lifeController = lifeController; energyController.movementController = movementController; } }
/// <summary> /// 设置获得体力 /// </summary> /// <param name="energy"></param> public void SetRewardEnergy(int times) { if (EnergyData.dataMap.ContainsKey(1)) { EnergyData energyData = EnergyData.dataMap[1]; int oneEnergy = energyData.fixedPoints; int energy = times * oneEnergy; m_lblEnergyUIUseInfoEnergyNum.text = energy.ToString(); } }
private void Init() { String sampleFile = HostingEnvironment.MapPath(@"\App_Data\sampleData.txt"); StreamReader sr = new StreamReader(sampleFile); // mock data per day List <EnergyData> listEnergyData = new List <EnergyData>(); while (!sr.EndOfStream) { string line = sr.ReadLine(); string[] tokens = line.Split(new char[] { '\t' }); string datetimeStr = tokens[0]; Regex rx = new Regex(@"(\d+)-(\d+)-(\d+)"); Match sm; if (!(sm = rx.Match(datetimeStr)).Success) { throw new Exception(String.Format("Invalid timestamp, {0}", datetimeStr)); } DateTime timestamp = new DateTime(int.Parse(sm.Groups[3].Value), int.Parse(sm.Groups[2].Value), int.Parse(sm.Groups[1].Value)); double yield; if (!double.TryParse(tokens[1], out yield)) { yield = 0; } EnergyData ed = new EnergyData() { Yield = yield, TimeStamp = timestamp }; listEnergyData.Add(ed); } // mock projects var projectInfo = new ProjectData() { projectSize = 100000, listEnergyData = listEnergyData }; _dictProjectIdToInfo.Add(projectInfo.projectId, projectInfo); projectInfo = new ProjectData() { projectSize = 200000, listEnergyData = listEnergyData }; _dictProjectIdToInfo.Add(projectInfo.projectId, projectInfo); projectInfo = new ProjectData() { projectSize = 500000, listEnergyData = listEnergyData }; _dictProjectIdToInfo.Add(projectInfo.projectId, projectInfo); }
/// <summary> /// used to add new points afer creation /// </summary> /// <param name="start">beginning of Energy point</param> /// <param name="val">value</param> public void AddEnergyPoint(DateTime start, decimal val) { if (EnergyData.Count > 0 && EnergyData[EnergyData.Count - 1].From > start) throw new ArgumentException("new EnergyPoint has to occur later then the last entry"); EnergyLevel level = new EnergyLevel(); level.From = start; level.Value = val; EnergyData.Add(level); if (EnergyData.Count > 1) EnergyData[EnergyData.Count - 2].Time = start - EnergyData[EnergyData.Count - 2].From; }
public void OnTriggerEnter2D(Collider2D collision) { if (collision.GetComponent <EnergyView>().GetOwningPlayer() != (int)_playerData.id) { EnergyData energyData = new EnergyData(); energyData.damage = 1; _gameManager.PlayerHit(_playerData, energyData); Destroy(collision.gameObject); } }
private void Start() { energyData = FindObjects.GameLogic.GetComponent <EnergyData>(); board = FindObjects.GameLogic.GetComponent <DungeonBoard>(); direction = FindObjects.GameLogic.GetComponent <Direction>(); message = FindObjects.GameLogic.GetComponent <UIMessage>(); wizard = FindObjects.GameLogic.GetComponent <WizardMode>(); if (!LoadedActorData) { Reset(); } }
public void SetBuyEnergy() { m_listBuyEnergyData.Clear(); int lastTimes = MogoWorld.thePlayer.CalBuyEnergyLastTimes(); EnergyData energyData = EnergyData.dataMap[1]; // 购买一次 BuyEnergyData buyOneEnergyData; buyOneEnergyData.title = LanguageData.GetContent(47806); buyOneEnergyData.icon = IconData.GetIconPath(14); if (lastTimes > 0) { buyOneEnergyData.buttonName = LanguageData.GetContent(47801); // 立即购买 buyOneEnergyData.diamond = MogoWorld.thePlayer.CalBuyEnergyDiamondCost(1); buyOneEnergyData.addEnergy = energyData.fixedPoints * 1; } else { buyOneEnergyData.buttonName = LanguageData.GetContent(47811); // 不可购买 buyOneEnergyData.diamond = 0; buyOneEnergyData.addEnergy = 0; } // 全部购买 BuyEnergyData buyAllEnergyData; buyAllEnergyData.title = LanguageData.GetContent(47807); buyAllEnergyData.icon = IconData.GetIconPath(14); if (lastTimes > 0) { buyAllEnergyData.buttonName = LanguageData.GetContent(47801); // 立即购买 buyAllEnergyData.diamond = MogoWorld.thePlayer.CalBuyEnergyDiamondCost(lastTimes); buyAllEnergyData.addEnergy = energyData.fixedPoints * lastTimes; } else { buyAllEnergyData.buttonName = LanguageData.GetContent(47811); // 不可购买 buyAllEnergyData.diamond = 0; buyAllEnergyData.addEnergy = 0; } m_listBuyEnergyData.Add(buyOneEnergyData); m_listBuyEnergyData.Add(buyAllEnergyData); EnergyNoEnoughUIViewManager.Instance.SetUIGridList(m_listBuyEnergyData.Count, () => { EnergyNoEnoughUIViewManager.Instance.SetBuyEnergyGridListData(m_listBuyEnergyData); }); }
public void PlayerHit(int energyType) { if (!isServer) { return; } EnergyData energyData = new EnergyData(); energyData.damage = 1; energyData.energyType = energyType; _gameManager.PlayerHit(new PlayerData(_playerId, 0, 0), energyData); }
/// <summary> /// median normalizes the List<ChartData> graph /// </summary> /// <param name="normalizatonWindowSize">defines the max size of sliding window used for normalizing</param> /// <param name="start">defines the point in time the resulting function will start</param> /// <returns>normalized function</returns> private IEnumerable<ChartDataDto> normalizeData(int normalizatonWindowSize, DateTime start) { List<decimal> zw = EnergyData.Select(x => x.Value).ToList(); for (int i = 0; i < EnergyData.Count; i++) { ChartDataDto dto = null; DateTimeOffset from = start + (EnergyData[i].From - EnergyData[0].From); dto = new ChartDataDto() { From = from, To = from.Add(EnergyData[i].Time), Value = medianNormalize(zw, normalizatonWindowSize, i) }; yield return dto; } }
/// <summary> /// Inicializa o controlador de energia do jogador /// </summary> /// /// <param name="energyData"> /// Os dados de energia do jogador /// </param> public override void onBuild(EnergyData energyData) { base.onBuild(energyData); energyController.shieldSlider = Game.findWithTag(Tags.ShieldSlider).GetComponent <Slider>(); energyController.speedSlider = Game.findWithTag(Tags.SpeedSlider).GetComponent <Slider>(); energyController.weaponSlider = Game.findWithTag(Tags.WeaponSlider).GetComponent <Slider>(); energyController.multipliers = new Multipliers( (slider) => energyController.onValueChange(slider.Value), energyController.shieldSlider.value, energyController.speedSlider.value, energyController.weaponSlider.value ); energyController.step = 6; }
public EnergyData Get(int id, String datetimeYYYYMMDD) { EnergyData result = null; Regex rx = new Regex(@"(\d{4})(\d{2})(\d{2})"); Match sm; if (!(sm = rx.Match(datetimeYYYYMMDD)).Success) { return(null); } DateTime timestamp = new DateTime(int.Parse(sm.Groups[1].Value), int.Parse(sm.Groups[2].Value), int.Parse(sm.Groups[3].Value)); result = DataStore.Get().GetByDate(id, timestamp); return(result); }
/// <inheritdoc /> /// <summary> /// Smart clones all configurations. /// Graph is not smart cloned. /// </summary> /// <returns></returns> public Layout <TConfiguration, TLayoutEnergyData> SmartClone() { var layout = new Layout <TConfiguration, TLayoutEnergyData>(Graph); for (var i = 0; i < vertices.Length; i++) { var configuration = vertices[i]; if (hasValue[i]) { layout.vertices[i] = configuration.SmartClone(); layout.hasValue[i] = true; } } layout.EnergyData = EnergyData.SmartClone(); return(layout); }
/// <summary> /// 设置一次购买体力说明 /// </summary> /// <param name="oneEnergy"></param> public void SetBuyOneText2(int times) { if (times > 0) { EnergyData energyData = EnergyData.dataMap[1]; int oneEnergy = energyData.fixedPoints; m_lblEnergyUIBtnBuyOneText2.text = string.Format(LanguageData.GetContent(47501), oneEnergy); m_goEnergyUIBtnBuyOne.GetComponentsInChildren <BoxCollider>(true)[0].enabled = true; m_spEnergyUIBtnBuyOneBGUp.spriteName = "tongyong_butten_green_up"; } else { m_lblEnergyUIBtnBuyOneText2.text = string.Format(LanguageData.GetContent(47501), 0); m_goEnergyUIBtnBuyOne.GetComponentsInChildren <BoxCollider>(true)[0].enabled = false; m_spEnergyUIBtnBuyOneBGUp.spriteName = "btn_03grey"; } }
public void AddOneRowData(string column1, string column2, RegionAreaPeople region, RegionAreaPeople lastRegion, EnergyData energyData, EnergyData lastEnergyData) { //第1行 总人数 int row1 = this.dataGridView1.Rows.Add(); this.dataGridView1.Rows[row1].Cells[0].Value = column1; this.dataGridView1.Rows[row1].Cells[1].Value = column2; //当月 this.dataGridView1.Rows[row1].Cells[2].Value = region.People; this.dataGridView1.Rows[row1].Cells[3].Value = lastRegion.People; this.dataGridView1.Rows[row1].Cells[4].Value = ((region.People / lastRegion.People) - 1) * 100; //当年 this.dataGridView1.Rows[row1].Cells[5].Value = region.People; this.dataGridView1.Rows[row1].Cells[6].Value = lastRegion.People; this.dataGridView1.Rows[row1].Cells[7].Value = ((region.People / lastRegion.People) - 1) * 100; this.dataGridView1.Rows[row1].Cells[8].Value = ""; this.dataGridView1.Rows[row1].Cells[9].Value = ""; this.dataGridView1.Rows[row1].Cells[10].Value = ""; }
public Tuple <EnergyData, Grammar> Run() { var rand = new Random(); while (currentTemp > threshold) { try { var newHypothesis = learner.GetNeighbor(currentHypothesis); EnergyData newEnergy = null; if (newHypothesis != null) { newHypothesis.GenerateDerivedRulesFromSchema(); newEnergy = learner.Energy(newHypothesis); newHypothesis.GenerateInitialRulesFromDerivedRules(); } if (newEnergy != null) { if (newEnergy < bestEnergy) { bestEnergy = newEnergy; bestHypothesis = newHypothesis; bestIteration = currentIteration; } var prob = P(currentEnergy, newEnergy, currentTemp); if (rand.NextDouble() < prob) { // moved to new hypothesis currentHypothesis = newHypothesis; currentEnergy = newEnergy; } } currentIteration++; if (currentIteration % reportEveryNIterations == 0) { Console.WriteLine("Iteration {0}", currentIteration); } currentTemp *= coolingFactor; } catch (Exception e) { Console.WriteLine(e.ToString()); } } var actualRuleDistributions = learner.CollectUsages(bestHypothesis); var s = string.Format("{0}. ({1}) \r\nBest Hypothesis: \r\n{2}Best so far: #{3} with energy: {4}\r\n", currentIteration, currentTemp, bestHypothesis.GrammarWithRuleUsages(actualRuleDistributions), bestIteration, bestEnergy); Console.WriteLine(s); using (var sw = File.AppendText("SessionReport.txt")) { sw.WriteLine(s); } return(new Tuple <EnergyData, Grammar>(bestEnergy, bestHypothesis)); }
private double P(EnergyData currStateEnergy, EnergyData possibleStateEnergy, double temp) { var calcValue = Math.Exp((currStateEnergy.TotalEnergy - possibleStateEnergy.TotalEnergy) / temp); return(Math.Min(1.0, calcValue)); }
public void UpdateEnergy(ILayout <TNode, TConfiguration> layout, TConfiguration configuration, ref EnergyData energyData) { energyData.Energy = 0; energyData.Energy += ComputeEnergy(energyData.BasicConstraintData.Overlap, energyData.BasicConstraintData.MoveDistance); energyData.Energy += ComputeEnergy(0, energyData.CorridorConstraintData.CorridorDistance); energyData.Energy += energyData.MinimumDistanceConstraintData.WrongDistanceCount; }
public EnergyRegulator(EnergyData data) { _data = data; _currentEnergy = data.StartingEnergy; _depletedTimer = 0f; }
private void btnGetReport_Click(object sender, EventArgs e) { try { string RegionID = "000001G0010002"; string RegionID1 = "000001G0010002"; string RegionID2 = "000001G0010005"; string EnergyItemCode = "01000"; //获取用户选择的时间 //DateTime startTime = dtpStartTime.Value; DateTime endTime = dtpStopTime.Value; //tabConServerLog.SelectedTab = tabPage1; //startTime = startTime.AddDays(-startTime.Day+1).AddHours(-startTime.Hour).AddMinutes(-startTime.Minute).AddSeconds(-startTime.Second); //月度-当月 //当月第1天 string startday = endTime.AddDays(-endTime.Day + 1).ToString("yyyy-MM-dd"); //当月最后一天 //string endday = endTime.AddMonths(1).AddDays(-endTime.Day).ToString("yyyy-MM-dd"); string endday = endTime.ToString("yyyy-MM-dd"); //月度-去年同月 string lastYearStartday = endTime.AddDays(-endTime.Day + 1).AddYears(-1).ToString("yyyy-MM-dd"); string lastYearEndday = endTime.AddYears(-1).ToString("yyyy-MM-dd"); Console.WriteLine("月度->开始:" + startday + "\n月度->结束:" + endday); Console.WriteLine("月度->同期开始:" + lastYearStartday + "\n月度->同期结束:" + lastYearEndday); //年度-当年 /* * string startYear = startTime.AddDays(-startTime.Day + 1).AddMonths(-startTime.Month + 1).ToString("yyyy-MM-dd"); * string endYear = endTime.AddMonths(1).AddDays(-endTime.Day).ToString("yyyy-MM-dd"); * * string lastStartYear = startTime.AddDays(-startTime.Day + 1).AddMonths(-startTime.Month + 1).AddYears(-1).ToString("yyyy-MM-dd"); * string lastEndYear = endTime.AddMonths(1).AddDays(-endTime.Day).AddYears(-1).ToString("yyyy-MM-dd"); */ string startYear = endTime.AddDays(-endTime.Day + 1).AddMonths(-endTime.Month + 1).ToString("yyyy-MM-dd"); string endYear = endTime.ToString("yyyy-MM-dd"); string lastStartYear = endTime.AddDays(-endTime.Day + 1).AddMonths(-endTime.Month + 1).AddYears(-1).ToString("yyyy-MM-dd"); string lastEndYear = endTime.AddYears(-1).ToString("yyyy-MM-dd"); Console.WriteLine("年度->开始:" + startYear + "\n年度->结束:" + endYear); Console.WriteLine("年度->同期开始:" + lastStartYear + "\n年度->同期结束:" + lastEndYear); #region 获取区域-用电 /*区域1-用电*/ EnergyData monthData = GetMonthData(RegionID, EnergyItemCode, startday, endday); EnergyData lastMonthData = GetMonthData(RegionID, EnergyItemCode, lastYearStartday, lastYearEndday); EnergyData yearData = GetYearData(RegionID, EnergyItemCode, startYear, endYear); EnergyData lastYearData = GetYearData(RegionID, EnergyItemCode, lastStartYear, lastEndYear); Console.WriteLine("月度->本期:" + monthData.Time + " 值:" + monthData.Value); Console.WriteLine("月度->:上年同期:" + lastMonthData.Time + " 值:" + lastMonthData.Value); Console.WriteLine("年度->本期:" + yearData.Time + " 值:" + yearData.Value); Console.WriteLine("年度->:上年同期:" + lastYearData.Time + " 值:" + lastYearData.Value); /*区域2-用电*/ EnergyData R2monthData = GetMonthData(RegionID2, EnergyItemCode, startday, endday); EnergyData R2lastMonthData = GetMonthData(RegionID2, EnergyItemCode, lastYearStartday, lastYearEndday); EnergyData R2yearData = GetYearData(RegionID2, EnergyItemCode, startYear, endYear); EnergyData R2lastYearData = GetYearData(RegionID2, EnergyItemCode, lastStartYear, lastEndYear); Console.WriteLine("R2月度->本期:" + R2monthData.Time + " 值:" + R2monthData.Value); Console.WriteLine("R2月度->:上年同期:" + R2lastMonthData.Time + " 值:" + R2lastMonthData.Value); Console.WriteLine("R2年度->本期:" + R2yearData.Time + " 值:" + R2yearData.Value); Console.WriteLine("R2年度->:上年同期:" + R2lastYearData.Time + " 值:" + R2lastYearData.Value); #endregion 获取区域-用电 #region 获取区域面积和人数 /*获取区域面积和人数*/ int year = endTime.Year; int lastYear = endTime.AddYears(-1).Year; //区域1 RegionAreaPeople region1 = GetAreaAndPeople(RegionID1, EnergyItemCode, year); RegionAreaPeople lastRegion1 = GetAreaAndPeople(RegionID1, EnergyItemCode, lastYear); //区域2 RegionAreaPeople region2 = GetAreaAndPeople(RegionID2, EnergyItemCode, year); RegionAreaPeople lastRegion2 = GetAreaAndPeople(RegionID2, EnergyItemCode, lastYear); Console.WriteLine("区域1 月度->本期面积:" + region1.Area + " 人数:" + region1.People); Console.WriteLine("区域1 月度->:上年同期面积:" + lastRegion1.Area + " 人数:" + lastRegion1.People); Console.WriteLine("区域2 月度->本期面积:" + region2.Area + " 人数:" + region2.People); Console.WriteLine("区域2 月度->:上年同期面积:" + lastRegion2.Area + " 人数:" + lastRegion2.People); #endregion 获取区域面积和人数 #region 添加表格的内容 this.dataGridView1.Rows.Clear(); //第1行 总人数 int row1 = this.dataGridView1.Rows.Add(); this.dataGridView1.Rows[row1].Cells[0].Value = C1Row1; this.dataGridView1.Rows[row1].Cells[1].Value = C2Row1; //当月 this.dataGridView1.Rows[row1].Cells[2].Value = region1.People > 0 ? region1.People : '-'; this.dataGridView1.Rows[row1].Cells[3].Value = lastRegion1.People > 0 ? lastRegion1.People : '-'; this.dataGridView1.Rows[row1].Cells[4].Value = lastRegion1.People > 0 ? ((region1.People / lastRegion1.People) - 1) * 100 : '-'; //当年 this.dataGridView1.Rows[row1].Cells[5].Value = region1.People > 0 ? region1.People : '-'; this.dataGridView1.Rows[row1].Cells[6].Value = lastRegion1.People > 0 ? lastRegion1.People : '-'; this.dataGridView1.Rows[row1].Cells[7].Value = lastRegion1.People > 0 ? ((region1.People / lastRegion1.People) - 1) * 100 : '-'; this.dataGridView1.Rows[row1].Cells[8].Value = ""; this.dataGridView1.Rows[row1].Cells[9].Value = ""; this.dataGridView1.Rows[row1].Cells[10].Value = ""; //第2行 办公大楼用电 int row2 = this.dataGridView1.Rows.Add(); this.dataGridView1.Rows[row2].Cells[0].Value = C1Row2; this.dataGridView1.Rows[row2].Cells[1].Value = C2Row2; //当月用能 this.dataGridView1.Rows[row2].Cells[2].Value = decimal.Round(monthData.Value, 2); this.dataGridView1.Rows[row2].Cells[3].Value = decimal.Round(lastMonthData.Value, 2); this.dataGridView1.Rows[row2].Cells[4].Value = lastMonthData.Value > 0 ? decimal.Round(((monthData.Value / lastMonthData.Value) - 1) * 100, 2) : 0; //当年用能 this.dataGridView1.Rows[row2].Cells[5].Value = decimal.Round(yearData.Value, 2); this.dataGridView1.Rows[row2].Cells[6].Value = decimal.Round(lastYearData.Value, 2); this.dataGridView1.Rows[row2].Cells[7].Value = lastYearData.Value > 0 ? decimal.Round(((yearData.Value / lastYearData.Value) - 1) * 100, 2) : 0; this.dataGridView1.Rows[row2].Cells[8].Value = ""; this.dataGridView1.Rows[row2].Cells[9].Value = ""; this.dataGridView1.Rows[row2].Cells[10].Value = ""; //第3行 办公大楼建筑面积 int row3 = this.dataGridView1.Rows.Add(); this.dataGridView1.Rows[row3].Cells[0].Value = C1Row2; this.dataGridView1.Rows[row3].Cells[1].Value = C2Row3; //当月用能 this.dataGridView1.Rows[row3].Cells[2].Value = decimal.Round(region1.Area, 2); this.dataGridView1.Rows[row3].Cells[3].Value = decimal.Round(lastRegion1.Area, 2); this.dataGridView1.Rows[row3].Cells[4].Value = lastRegion1.Area > 0 ? decimal.Round(((region1.Area / lastRegion1.Area) - 1) * 100, 2) : 0; //当年用能 this.dataGridView1.Rows[row3].Cells[5].Value = decimal.Round(region1.Area, 2); this.dataGridView1.Rows[row3].Cells[6].Value = decimal.Round(lastRegion1.Area, 2); this.dataGridView1.Rows[row3].Cells[7].Value = lastRegion1.Area > 0 ? decimal.Round(((region1.Area / lastRegion1.Area) - 1) * 100, 2) : 0; this.dataGridView1.Rows[row3].Cells[8].Value = ""; this.dataGridView1.Rows[row3].Cells[9].Value = ""; this.dataGridView1.Rows[row3].Cells[10].Value = ""; //第4行 其他用电 int row4 = this.dataGridView1.Rows.Add(); this.dataGridView1.Rows[row4].Cells[0].Value = C1Row3; this.dataGridView1.Rows[row4].Cells[1].Value = C2Row4; //当月用能 this.dataGridView1.Rows[row4].Cells[2].Value = decimal.Round(R2monthData.Value, 2); this.dataGridView1.Rows[row4].Cells[3].Value = decimal.Round(R2lastMonthData.Value, 2); this.dataGridView1.Rows[row4].Cells[4].Value = R2lastMonthData.Value > 0 ? decimal.Round(((R2monthData.Value / R2lastMonthData.Value) - 1) * 100, 2) : 0; //当年用能 this.dataGridView1.Rows[row4].Cells[5].Value = decimal.Round(R2yearData.Value, 2); this.dataGridView1.Rows[row4].Cells[6].Value = decimal.Round(R2lastYearData.Value, 2); this.dataGridView1.Rows[row4].Cells[7].Value = R2lastYearData.Value > 0 ? decimal.Round(((R2yearData.Value / R2lastYearData.Value) - 1) * 100, 2) : 0; this.dataGridView1.Rows[row4].Cells[8].Value = ""; this.dataGridView1.Rows[row4].Cells[9].Value = ""; this.dataGridView1.Rows[row4].Cells[10].Value = ""; //第5行 其他用电建筑面积 int row5 = this.dataGridView1.Rows.Add(); this.dataGridView1.Rows[row5].Cells[0].Value = C1Row3; this.dataGridView1.Rows[row5].Cells[1].Value = C2Row5; //当月用能 this.dataGridView1.Rows[row5].Cells[2].Value = decimal.Round(region2.Area, 2); this.dataGridView1.Rows[row5].Cells[3].Value = decimal.Round(lastRegion2.Area, 2); this.dataGridView1.Rows[row5].Cells[4].Value = lastRegion2.Area > 0 ? decimal.Round(((region2.Area / lastRegion2.Area) - 1) * 100, 2) : 0; //当年用能 this.dataGridView1.Rows[row5].Cells[5].Value = decimal.Round(region2.Area, 2); this.dataGridView1.Rows[row5].Cells[6].Value = decimal.Round(lastRegion2.Area, 2); this.dataGridView1.Rows[row5].Cells[7].Value = lastRegion2.Area > 0 ? decimal.Round(((region2.Area / lastRegion2.Area) - 1) * 100, 2) : 0; this.dataGridView1.Rows[row5].Cells[8].Value = ""; this.dataGridView1.Rows[row5].Cells[9].Value = ""; this.dataGridView1.Rows[row5].Cells[10].Value = ""; //第6行 其他用电建筑面积 int row6 = this.dataGridView1.Rows.Add(); this.dataGridView1.Rows[row6].Cells[0].Value = C2Row6; this.dataGridView1.Rows[row6].Cells[1].Value = C2Row6; //当月用能 this.dataGridView1.Rows[row6].Cells[2].Value = decimal.Round(Convert.ToDecimal(dataGridView1.Rows[1].Cells[2].Value) + Convert.ToDecimal(dataGridView1.Rows[3].Cells[2].Value), 2); this.dataGridView1.Rows[row6].Cells[3].Value = decimal.Round(Convert.ToDecimal(dataGridView1.Rows[1].Cells[3].Value) + Convert.ToDecimal(dataGridView1.Rows[3].Cells[3].Value), 2); this.dataGridView1.Rows[row6].Cells[4].Value = Convert.ToDecimal(dataGridView1.Rows[5].Cells[3].Value) > 0 ? decimal.Round(((Convert.ToDecimal(dataGridView1.Rows[5].Cells[2].Value) / Convert.ToDecimal(dataGridView1.Rows[5].Cells[3].Value)) - 1) * 100, 2) : 0; //当年用能 this.dataGridView1.Rows[row6].Cells[5].Value = decimal.Round(Convert.ToDecimal(dataGridView1.Rows[1].Cells[5].Value) + Convert.ToDecimal(dataGridView1.Rows[3].Cells[5].Value), 2); this.dataGridView1.Rows[row6].Cells[6].Value = decimal.Round(Convert.ToDecimal(dataGridView1.Rows[1].Cells[6].Value) + Convert.ToDecimal(dataGridView1.Rows[3].Cells[6].Value), 2); this.dataGridView1.Rows[row6].Cells[7].Value = Convert.ToDecimal(dataGridView1.Rows[5].Cells[6].Value) > 0 ? decimal.Round(((Convert.ToDecimal(dataGridView1.Rows[5].Cells[5].Value) / Convert.ToDecimal(dataGridView1.Rows[5].Cells[6].Value)) - 1) * 100, 2) : 0; //this.dataGridView1.Rows[row6].Cells[8].Value = ""; //this.dataGridView1.Rows[row6].Cells[9].Value = ""; //this.dataGridView1.Rows[row6].Cells[10].Value = ""; //第7行 人均用电量 int row7 = this.dataGridView1.Rows.Add(); this.dataGridView1.Rows[row7].Cells[0].Value = C2Row7; this.dataGridView1.Rows[row7].Cells[1].Value = C2Row7; //当月用能 this.dataGridView1.Rows[row7].Cells[2].Value = Convert.ToDecimal(dataGridView1.Rows[0].Cells[2].Value) > 0 ? decimal.Round(((Convert.ToDecimal(dataGridView1.Rows[5].Cells[2].Value) / Convert.ToDecimal(dataGridView1.Rows[0].Cells[2].Value))), 2) : 0; this.dataGridView1.Rows[row7].Cells[3].Value = Convert.ToDecimal(dataGridView1.Rows[0].Cells[3].Value) > 0 ? decimal.Round(((Convert.ToDecimal(dataGridView1.Rows[5].Cells[3].Value) / Convert.ToDecimal(dataGridView1.Rows[0].Cells[3].Value))), 2) : 0; this.dataGridView1.Rows[row7].Cells[4].Value = Convert.ToDecimal(dataGridView1.Rows[6].Cells[3].Value) > 0 ? decimal.Round(((Convert.ToDecimal(dataGridView1.Rows[6].Cells[2].Value) / Convert.ToDecimal(dataGridView1.Rows[6].Cells[3].Value)) - 1) * 100, 2) : 0; //当年用能 this.dataGridView1.Rows[row7].Cells[5].Value = Convert.ToDecimal(dataGridView1.Rows[0].Cells[5].Value) > 0 ? decimal.Round(((Convert.ToDecimal(dataGridView1.Rows[5].Cells[5].Value) / Convert.ToDecimal(dataGridView1.Rows[0].Cells[5].Value))), 2) : 0; this.dataGridView1.Rows[row7].Cells[6].Value = Convert.ToDecimal(dataGridView1.Rows[0].Cells[6].Value) > 0 ? decimal.Round(((Convert.ToDecimal(dataGridView1.Rows[5].Cells[6].Value) / Convert.ToDecimal(dataGridView1.Rows[0].Cells[6].Value))), 2) : 0; this.dataGridView1.Rows[row7].Cells[7].Value = Convert.ToDecimal(dataGridView1.Rows[6].Cells[6].Value) > 0 ? decimal.Round(((Convert.ToDecimal(dataGridView1.Rows[6].Cells[5].Value) / Convert.ToDecimal(dataGridView1.Rows[6].Cells[6].Value)) - 1) * 100, 2) : 0; this.dataGridView1.Rows[row7].Cells[8].Value = ""; this.dataGridView1.Rows[row7].Cells[9].Value = ""; this.dataGridView1.Rows[row7].Cells[10].Value = ""; /***第8行 建筑面积合计***/ int row8 = this.dataGridView1.Rows.Add(); this.dataGridView1.Rows[row8].Cells[0].Value = C2Row8; this.dataGridView1.Rows[row8].Cells[1].Value = C2Row8; //当月用能 this.dataGridView1.Rows[row8].Cells[2].Value = decimal.Round(Convert.ToDecimal(dataGridView1.Rows[2].Cells[2].Value) + Convert.ToDecimal(dataGridView1.Rows[4].Cells[2].Value), 2); this.dataGridView1.Rows[row8].Cells[3].Value = decimal.Round(Convert.ToDecimal(dataGridView1.Rows[2].Cells[3].Value) + Convert.ToDecimal(dataGridView1.Rows[4].Cells[3].Value), 2); this.dataGridView1.Rows[row8].Cells[4].Value = Convert.ToDecimal(dataGridView1.Rows[7].Cells[3].Value) > 0 ? decimal.Round(((Convert.ToDecimal(dataGridView1.Rows[7].Cells[2].Value) / Convert.ToDecimal(dataGridView1.Rows[7].Cells[3].Value)) - 1) * 100, 2) : 0; //当年用能 this.dataGridView1.Rows[row8].Cells[5].Value = decimal.Round(Convert.ToDecimal(dataGridView1.Rows[2].Cells[5].Value) + Convert.ToDecimal(dataGridView1.Rows[4].Cells[5].Value), 2); this.dataGridView1.Rows[row8].Cells[6].Value = decimal.Round(Convert.ToDecimal(dataGridView1.Rows[2].Cells[6].Value) + Convert.ToDecimal(dataGridView1.Rows[4].Cells[6].Value), 2); this.dataGridView1.Rows[row8].Cells[7].Value = Convert.ToDecimal(dataGridView1.Rows[7].Cells[6].Value) > 0 ? decimal.Round(((Convert.ToDecimal(dataGridView1.Rows[7].Cells[5].Value) / Convert.ToDecimal(dataGridView1.Rows[7].Cells[6].Value)) - 1) * 100, 2) : 0; this.dataGridView1.Rows[row8].Cells[8].Value = ""; this.dataGridView1.Rows[row8].Cells[9].Value = ""; this.dataGridView1.Rows[row8].Cells[10].Value = ""; /***第9行 单位面积用电***/ int row9 = this.dataGridView1.Rows.Add(); this.dataGridView1.Rows[row9].Cells[0].Value = C2Row9; this.dataGridView1.Rows[row9].Cells[1].Value = C2Row9; //当月用能 this.dataGridView1.Rows[row9].Cells[2].Value = Convert.ToDecimal(dataGridView1.Rows[7].Cells[2].Value) > 0 ? decimal.Round(((Convert.ToDecimal(dataGridView1.Rows[5].Cells[2].Value) / Convert.ToDecimal(dataGridView1.Rows[7].Cells[2].Value))), 2) : 0; this.dataGridView1.Rows[row9].Cells[3].Value = Convert.ToDecimal(dataGridView1.Rows[7].Cells[3].Value) > 0 ? decimal.Round(((Convert.ToDecimal(dataGridView1.Rows[5].Cells[3].Value) / Convert.ToDecimal(dataGridView1.Rows[7].Cells[3].Value))), 2) : 0; this.dataGridView1.Rows[row9].Cells[4].Value = Convert.ToDecimal(dataGridView1.Rows[8].Cells[3].Value) > 0 ? decimal.Round(((Convert.ToDecimal(dataGridView1.Rows[8].Cells[2].Value) / Convert.ToDecimal(dataGridView1.Rows[8].Cells[3].Value)) - 1) * 100, 2) : 0; //当年用能 this.dataGridView1.Rows[row9].Cells[5].Value = Convert.ToDecimal(dataGridView1.Rows[7].Cells[5].Value) > 0 ? decimal.Round(((Convert.ToDecimal(dataGridView1.Rows[5].Cells[5].Value) / Convert.ToDecimal(dataGridView1.Rows[7].Cells[5].Value))), 2) : 0; this.dataGridView1.Rows[row9].Cells[6].Value = Convert.ToDecimal(dataGridView1.Rows[7].Cells[6].Value) > 0 ? decimal.Round(((Convert.ToDecimal(dataGridView1.Rows[5].Cells[6].Value) / Convert.ToDecimal(dataGridView1.Rows[7].Cells[6].Value))), 2) : 0; this.dataGridView1.Rows[row9].Cells[7].Value = Convert.ToDecimal(dataGridView1.Rows[8].Cells[6].Value) > 0 ? decimal.Round(((Convert.ToDecimal(dataGridView1.Rows[8].Cells[5].Value) / Convert.ToDecimal(dataGridView1.Rows[8].Cells[6].Value)) - 1) * 100, 2) : 0; this.dataGridView1.Rows[row9].Cells[8].Value = ""; this.dataGridView1.Rows[row9].Cells[9].Value = ""; this.dataGridView1.Rows[row9].Cells[10].Value = ""; #endregion 添加表格的内容 } catch (Exception ex) { MessageBox.Show("发生异常:" + ex.Message, "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
/// <summary> /// 设置体力恢复 /// </summary> public void SetEnergyRecover() { EnergyData energyData = EnergyData.dataMap[1]; m_lblEnergyNoEnoughUITipText.text = string.Format(LanguageData.GetContent(47805), energyData.recoverInterval, energyData.recoverPoints); }