private double getLatitude(TreeNode <NodeData> node) { if (node.Data.Type == DMSType.ACLINESEGMENT) { //+ ACLineSegment acLineSegment = (ACLineSegment)node.Data.IdentifiedObject; return(acLineSegment.Latitude); } else if (node.Data.Type == DMSType.BREAKER) { //+ Breaker breaker = (Breaker)node.Data.IdentifiedObject; return(breaker.Latitude); } else if (node.Data.Type == DMSType.ENEGRYSOURCE) { //+ EnergySource source = (EnergySource)node.Data.IdentifiedObject; return(source.Latitude); } else if (node.Data.Type == DMSType.ENERGYCONSUMER) { //+ EnergyConsumer consumer = (EnergyConsumer)node.Data.IdentifiedObject; return(consumer.Latitude); } else if (node.Data.Type == DMSType.GENERATOR) { //+ Generator generator = (Generator)node.Data.IdentifiedObject; return(generator.Latitude); } return(0); }
public void RemoveSource(EnergySource source) { if (!m_energySources.ContainsKey(source.SourceId)) { return; } m_energySources.Remove(source.SourceId); m_energyStorage -= source.Power; m_currentConsumption -= source.CurrentConsumption; // make a copy to reset source without loosing consumer list var consumers = new List <EnergyConsumer>(source.Consumers.Values.ToList()); source.Reset(); // try to distribute consumers between other sources foreach (var consumer in consumers) { AddConsumer(consumer); } OnEnergyUpdated(); m_logger.Log($"source {source.SourceId} was removed"); }
private EnergySource getEnergySourceFromUser(bool i_ForTruck) { DataInputScreen dataInputScreen = r_Screens[eUIScreens.DataInput] as DataInputScreen; eEnergySource energySourceType = eEnergySource.Fuel; EnergySource energySource = null; if (!i_ForTruck) { MenuScreen energySourceScreen = r_Screens[eUIScreens.EnergySource] as MenuScreen; energySourceScreen.Display(out string energySourInput); energySourceType = (eEnergySource)parseMenuOption(energySourInput); } if (energySourceType == eEnergySource.Fuel) { MenuScreen FuelType = r_Screens[eUIScreens.FuelType] as MenuScreen; FuelType.Display(out string fuelTypeStr); eFuel fuel = (eFuel)parseMenuOption(fuelTypeStr); dataInputScreen.SetMassageToDisplay("Enter Fuel Tank Capacity"); dataInputScreen.Display(out string fuelTankCapacity); float capacity = float.Parse(fuelTankCapacity); energySource = new FuelTank(fuel, capacity); } else { dataInputScreen.SetMassageToDisplay("Enter Maximum Time Capacity"); dataInputScreen.Display(out string timeCapacity); float capacity = float.Parse(timeCapacity); energySource = new Battery(capacity); } return(energySource); }
public async Task <IActionResult> Index(string SectorName, string SourceName, string Year, string Value) { CreationConfirmation confirmation = new CreationConfirmation(); confirmation.Heading = "New Record Successfully Created"; confirmation.WasSuccessful = true; try { Sector sector = _context.Sector.Where(s => s.SectorName == SectorName).First(); EnergySource energySource = _context.EnergySource.Where(e => e.SourceName == SourceName).First(); AnnualEnergyConsumption newRecord = new AnnualEnergyConsumption(); newRecord.sector = sector; newRecord.energysource = energySource; newRecord.Year = Convert.ToInt32(Year); newRecord.Value = Convert.ToDecimal(Value); _context.AnnualEnergyConsumption.Add(newRecord); await _context.SaveChangesAsync(); AnnualEnergyConsumption confirmRecord = _context.AnnualEnergyConsumption.Where(c => c.sector.SectorName == SectorName & c.energysource.SourceName == SourceName & c.Year == Convert.ToInt32(Year) & c.Value == Convert.ToDecimal(Value)).First(); confirmation.ConsumptionData = confirmRecord; } catch (Exception e) { confirmation.Heading = "Record Creation Failed"; confirmation.WasSuccessful = false; } return(View(confirmation)); }
private void ShowEnergyArea(EnergySource source) { if (m_energySourceSelected) { HideEnergyArea(); } if (EnergyAreaPrefab == null) { m_logger.Warn("Cannot show energy area. Tile prefab not found."); return; } int radius = (int)source.EnergyDistributionCellRadius; Vector2 mouseWorldPosition = TileUtils.NormalizedMousePosition(); Vector2 cellStep = TileUtils.TileSizeRelative; for (float i = -radius * cellStep.y; i <= radius * cellStep.y; i += cellStep.y) { for (float j = -radius * cellStep.x; j <= radius * cellStep.x; j += cellStep.x) { Vector2 tilePosition = TileManagerScript.TileManager.CellToWorld(new Vector2(j, i)) + mouseWorldPosition; var energyAreaTile = Instantiate(EnergyAreaPrefab, tilePosition, Quaternion.identity); m_energyAreaTiles.Add(energyAreaTile); } } m_energyAreaPosition = mouseWorldPosition; m_energySourceSelected = true; }
// Process the energy and raise the event public int AbsorbEnergy(EnergySource source) { int energyAbsorbed = ProcessEnergy(source.energy); _energyAbsorbedEvent.Invoke(new EnergyEventData(source, this, energyAbsorbed)); return(energyAbsorbed); }
public void SlotArmDown() { #if DEBUG #else if (!Player.main.inSeamoth || !AvatarInputHandler.main.IsEnabled()) { return; } #endif if (!seamoth.IsPowered()) { return; } if (currentSelectedArm == SeamothArm.Left) { leftButtonDownProcessed = true; if (seamoth.GetSlotProgress(LeftArmSlotID) != 1f) { return; } QuickSlotType quickSlotType = CraftData.GetQuickSlotType(currentLeftArmType); if (quickSlotType == QuickSlotType.Selectable && leftArm.OnUseDown(out float coolDown)) { if (EnergySource) { EnergySource.ConsumeEnergy(leftArm.GetEnergyCost()); } quickSlotTimeUsed[LeftArmSlotID] = Time.time; quickSlotCooldown[LeftArmSlotID] = coolDown; } } else if (currentSelectedArm == SeamothArm.Right) { rightButtonDownProcessed = true; if (seamoth.GetSlotProgress(RightArmSlotID) != 1f) { return; } QuickSlotType quickSlotType = CraftData.GetQuickSlotType(currentRightArmType); if (quickSlotType == QuickSlotType.Selectable && rightArm.OnUseDown(out float coolDown)) { if (EnergySource) { EnergySource.ConsumeEnergy(rightArm.GetEnergyCost()); } quickSlotTimeUsed[RightArmSlotID] = Time.time; quickSlotCooldown[RightArmSlotID] = coolDown; } } }
void Awake() { controller = GetComponent<CharacterController>(); energyAbsorb = GetComponent<EnergyAbsorber>(); energySor = GetComponent<EnergySource>(); target = PickTarget(); PickIdleTarget(); }
public void AddSource(EnergySource source) { if (source == null) { throw new ArgumentNullException(nameof(source)); } energySources.Add(source); }
void Awake() { energySource = GetComponent<EnergySource>(); energyAbsorber = GetComponent<EnergyAbsorber>(); energySource.energyType = outputEnergyType; if ( ! energyAbsorber.energyAbsorbed.ContainsKey( inputEnergyType ) ) energyAbsorber.energyAbsorbed.Add( inputEnergyType, 0 ); }
/// <summary> /// Creates entity for specified global inside the container. /// </summary> /// <param name="globalId">Global id of the entity for insert</param> /// <returns>Created entity (identified object).</returns> public IdentifiedObject CreateEntity(long globalId) { short type = ModelCodeHelper.ExtractTypeFromGlobalId(globalId); IdentifiedObject io = null; switch ((DMSType)type) { case DMSType.BASEVOLTAGE: io = new BaseVoltage(globalId); break; case DMSType.CONNECTIVITYNODE: io = new ConnectivityNode(globalId); break; case DMSType.ENERGYCONSUMER: io = new EnergyConsumer(globalId); break; case DMSType.ENERGYSOURCE: io = new EnergySource(globalId); break; case DMSType.POWERTRANSFORMER: io = new PowerTransformer(globalId); break; case DMSType.PTRANSFORMEREND: io = new PowerTransformerEnd(globalId); break; case DMSType.SWITCH: io = new Switch(globalId); break; case DMSType.ACLINESEGMENT: io = new ACLineSegment(globalId); break; case DMSType.TERMINAL: io = new Terminal(globalId); break; default: string message = String.Format("Failed to create entity because specified type ({0}) is not supported.", type); Logger.LogError(message); throw new Exception(message); } // Add entity to map this.AddEntity(io); return(io); }
public Turret(string creator, Frame fr, Applicator app, Gear g, EnergySource es) { itemName = "Turret"; itemStackType = ItemStackType.Turret; frame = fr; applicator = app; gear = g; energySource = es; setInventoryTextureName("Turret"); //"Units/Turrets/TurretPlaceholder"); creatorId = creator; }
private void AddPendingConsumersToSource(EnergySource source) { // backward iteration to avoid list invalidation for (int i = m_pendingConsumers.Count - 1; i >= 0; i--) { if (AddConsumerToSource(source, m_pendingConsumers[i])) { m_pendingConsumers.RemoveAt(i); } } }
private bool AddConsumerToSource(EnergySource source, EnergyConsumer consumer) { if (source.AddConsumer(consumer)) { m_currentConsumption += consumer.Power; OnEnergyUpdated(); m_logger.Log($"consumer {consumer.ConsumerId} was added to source {source.SourceId}"); return(true); } return(false); }
private bool RemoveConsumerFromSource(EnergySource source, EnergyConsumer consumer) { if (source.RemoveConsumer(consumer.ConsumerId)) { m_currentConsumption -= consumer.Power; OnEnergyUpdated(); m_logger.Log($"consumer {consumer.ConsumerId} was removed from source {source.SourceId}"); return(true); } return(false); }
private void TryRemoveEnergyObject(GameObject obj) { EnergyConsumer consumer = obj.GetComponent <EnergyConsumer>(); EnergySource source = obj.GetComponent <EnergySource>(); if (consumer != null) { EnergyManager.Instance.RemoveConsumer(consumer); } else if (source != null) { EnergyManager.Instance.RemoveSource(source); } }
private void ChangePrefab(BuildableObjectScript p) { m_isActive = true; m_isRemoverActive = false; PrefabToCreate = p; CreateShadow(); EnergySource source = PrefabToCreate.GetComponent <EnergySource>(); if (source != null) { ShowEnergyArea(source); } }
private void SetTreeOnMap() { if (_tree == null) { return; } _map.Children.Clear(); List <TreeNode <NodeData> > energySources = _tree.Where(x => x.Data.Type == FTN.Common.DMSType.ENEGRYSOURCE).ToList(); foreach (TreeNode <NodeData> node in energySources) { StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilderUniversal = new StringBuilder(); EnergySource energySource = (EnergySource)node.Data.IdentifiedObject; Substation substation = (Substation)_tree.Where(x => x.Data.IdentifiedObject.GlobalId == energySource.Container).FirstOrDefault().Data.IdentifiedObject; SubGeographicalRegion subGeographicalRegion = (SubGeographicalRegion)_tree.Where(x => x.Data.IdentifiedObject.GlobalId == substation.SubGeoReg).FirstOrDefault().Data.IdentifiedObject; GeographicalRegion geographicalRegion = (GeographicalRegion)_tree.Where(x => x.Data.IdentifiedObject.GlobalId == subGeographicalRegion.GeoReg).FirstOrDefault().Data.IdentifiedObject; stringBuilderUniversal.AppendFormat("Geographical Region: {0}{1}", geographicalRegion.Name, Environment.NewLine); stringBuilderUniversal.AppendFormat("SubGeographical Region: {0}{1}", subGeographicalRegion.Name, Environment.NewLine); stringBuilderUniversal.AppendFormat("Substation: {0}{1}", substation.Name, Environment.NewLine); stringBuilderUniversal.AppendFormat("----------------------------------------{0}", Environment.NewLine); Location pinLocation = new Location(energySource.Longitude, energySource.Latitude); stringBuilder.Append(stringBuilderUniversal.ToString()); stringBuilder.AppendFormat("Name: {0}{1}", energySource.Name, Environment.NewLine); stringBuilder.AppendFormat("Description: {0}{1}", energySource.Description, Environment.NewLine); stringBuilder.AppendFormat("Nominal Voltage: {0} kW", energySource.NominalVoltage); string toolTip = stringBuilder.ToString(); Pushpin pushpin = new Pushpin(); pushpin.Uid = energySource.GlobalId.ToString(); pushpin.Location = pinLocation; pushpin.ToolTip = toolTip; pushpin.Cursor = Cursors.Hand; pushpin.Template = (ControlTemplate)Application.Current.Resources["EnergySourceTemplate"]; if (VisibilityOfElements["EnergySource"]) { _map.Children.Add(pushpin); } StartDrowingOnMap(node.Children.ToList(), stringBuilderUniversal.ToString()); } }
private ResourceDescription CreateEnergySourceResourceDecription(EnergySource cimEnergySource) { ResourceDescription rd = null; if (cimEnergySource != null) { long gid = ModelCodeHelper.CreateGlobalId(0, (short)DMSType.ENERGYSOURCE, importHelper.CheckOutIndexForDMSType(DMSType.ENERGYSOURCE)); rd = new ResourceDescription(gid); importHelper.DefineIDMapping(cimEnergySource.ID, gid); ////populate ResourceDescription LoadFlowConverter.PopulateEnergySourceProperties(cimEnergySource, rd, importHelper, report); } return(rd); }
public void AddSource(EnergySource source) { if (m_energySources.ContainsKey(source.SourceId)) { return; } m_energySources.Add(source.SourceId, source); m_energyStorage += source.Power; m_currentConsumption += source.CurrentConsumption; AddPendingConsumersToSource(source); OnEnergyUpdated(); m_logger.Log($"source {source.SourceId} was added"); }
private EnergyConsumption CreateEnergyConsumption(string name, string description, string tag, string iconId, DateTime start, DateTime finish, double consumption = 0, EnergySource energySource = EnergySource.Strommix, double carbonProduction = 0) { return(new EnergyConsumption { Name = name, Description = description, Tag = tag, IconId = iconId, Start = start, Finish = finish, Consumption = consumption, m_EnergySource = (int)energySource, CarbonProduction = carbonProduction }); }
Complex GetVoltageFromEnergySource(EnergySource es) { float re = float.NaN; float im = float.NaN; for (int i = 0; i < es.Measurements.Count; ++i) { Analog analog = Get(es.Measurements[i]) as Analog; if (analog == null) { continue; } switch (analog.MeasurementType) { case MeasurementType.VoltageR: if (!analogs.TryGetValue(analog.GID, out re)) { re = analog.NormalValue; } break; case MeasurementType.VoltageI: if (!analogs.TryGetValue(analog.GID, out im)) { im = analog.NormalValue; } break; } } if (float.IsNaN(re) || float.IsNaN(im)) { BaseVoltage bv = Get(es.BaseVoltage) as BaseVoltage; if (bv != null) { re = bv.NominalVoltage; im = 0; } } return(new Complex(re, im)); }
private EnergyConsumption CreateEnergyConsumption(string name, string description, string tag, string iconId, DateTime start, DateTime finish, double consumption = 0, EnergySource energySource = EnergySource.Strommix, double carbonProduction = 0, ResponsibleSubject responsibleSubject = null) { return(new EnergyConsumption { Name = name, Description = description, Tag = tag, IconId = iconId, Start = start, Finish = finish, Consumption = consumption, EnergySource = energySource, CarbonProduction = carbonProduction, ResponsibleSubject = responsibleSubject }); }
private static EnergySource CreateEnergySource(string name, string description, string unit, double co2equivalent) { var energySource = new EnergySource { EnergySourceId = Guid.NewGuid(), Name = name, Description = description, Unit = unit, CO2Equivalent = co2equivalent, Color = HTMLColor.Colors[_energySourceColors] }; if (_energySourceColors < (HTMLColor.Colors.Length - 1)) { _energySourceColors++; } return(energySource); }
public Turret(string itemData, string delim) : base(itemData, delim) { string[] split = itemData.Split(delim.ToCharArray()); int curr = numSplit; ItemCode frameCode = (ItemCode)int.Parse(split[curr++]); if (frameCode != ItemCode.None) { frame = (Frame)Item.deserializeItem(frameCode, split[curr++], otherDelimiter); } applicator = (Applicator)Item.deserializeItem((ItemCode)int.Parse(split[curr++]), split[curr++], otherDelimiter); gear = (Gear)Item.deserializeItem((ItemCode)int.Parse(split[curr++]), split[curr++], otherDelimiter); energySource = (EnergySource)Item.deserializeItem((ItemCode)int.Parse(split[curr++]), split[curr++], otherDelimiter); if (curr < split.Length) { creatorId = split[curr++]; } }
public override string ToString() { return(string.Format( "License Plate: {0}{7}" + "Model Name: {1}{7}" + "Current Air Pressure: {2}{7}" + "Max Air Pressure: {3}{7}" + "Manufacturer Name: {4}{7}" + "Number of wheels: {5}{7}" + "Type Of Energy: {6}{7}", m_LicensePlate, m_ModelName, m_Wheels[0].CurrentAirPressure, m_Wheels[0].MaxAirPressure, m_Wheels[0].ManufacturerName, m_Wheels.Count, TypeOfVehicle, Environment.NewLine) + EnergySource.ToString()); }
/** * This method gets the vehicles current amount of energy. */ private void getCurrentAmountOfEnergy(EnergySource i_EnergySource) { string message = (i_EnergySource is Fuel) ? "fuel amount" : "battery time left (in hours)"; ConsoleUtils.ClearConsoleAndWrite(string.Format("Enter the current {0}", message)); string userInput = Console.ReadLine(); float convertedInput = ConsoleUtils.CheckFloatInput(userInput, "Energy amount"); try { i_EnergySource.RefuelEnergy(convertedInput); } catch (Exception e) { ConsoleUtils.ClearConsoleAndWrite(e.Message); Console.WriteLine("Press any key to continue"); Console.ReadLine(); getCurrentAmountOfEnergy(i_EnergySource); } }
private MachineEnergyConsumption CreateMachineEnergyConsumption(string name, string description, string tag, string iconId, DateTime start, DateTime finish, EnergySource energySource = EnergySource.Strommix, double hourInStandbyState = 0, double consumptionPerHourForStandby = 0, double hourInProcessingState = 0, double consumptionPerHourForProcessing = 0, double carbonProduction = 0) { return(new MachineEnergyConsumption { Name = name, Description = description, Tag = tag, IconId = iconId, Start = start, Finish = finish, m_EnergySource = (int)energySource, HoursInProcessingState = hourInProcessingState, HoursInStandbyState = hourInStandbyState, ConsumptionPerHourForStandby = consumptionPerHourForStandby, ConsumptionPerHourForProcessing = consumptionPerHourForProcessing, CarbonProduction = carbonProduction }); }
private void CreateEnergySources(EnergyNetworkDbContext context) { _electricity = CreateEnergySource("electricity", "Stromheizung m. Netzverlusten, Emissionsfaktor (inkl. Vorketten) für die Wärmebereitstellung", "g/kWh", 626.1); _oil = CreateEnergySource("fuelOil", "Heizöl-Mix EL + S (Industrie), Emissionsfaktor (inkl. Vorketten) für die Wärmebereitstellung", "g/kWh", 341.4); _gas = CreateEnergySource("naturalGas", "Erdgas (Industrie), Emissionsfaktor (inkl. Vorketten) für die Wärmebereitstellung", "g/kWh", 276.8); _districtHeat = CreateEnergySource("districtHeating", "Fernwärme m. Netzverlust, , Emissionsfaktor (inkl. Vorketten) für die Wärmebereitstellung", "g/kWh", 325.4); }
public void GetDataForFillEnergy(EnergySource i_EnergySource, out string o_Amount, out string o_FuelType) { o_Amount = string.Empty; bool isGasVehicle = i_EnergySource is Gas; if (isGasVehicle) { Console.WriteLine("choose fuel type:"); o_FuelType = Console.ReadLine(); } else { o_FuelType = "None"; } while (o_Amount.Equals(string.Empty)) { Console.WriteLine("enter amount of {0} to fill", isGasVehicle ? "fuel" : "minutes"); o_Amount = Console.ReadLine(); } }
public Truck(VehicleInfo i_VehicleInfo, EnergySource i_EnergySource, float i_CurrentAirPressure) : base(i_VehicleInfo, i_EnergySource, i_CurrentAirPressure) { r_TruckInfo = Helpers.StrongArgumentNeededTypeCheckAndCast <TruckInfo>(i_VehicleInfo); }
public EnergyNullifiedEventData(EnergySourceNullifier energyNullifier, EnergySource energySource) { _nullifyer = energyNullifier; _source = energySource; }