public void ConvertFrom(Substation substation, SubstationView substationView) { substationView.SubstationPK = substation.SubstationPK; substationView.Name = substation.Name; substationView.RegionalOfficeFK = substation.RegionalOfficeFK; substationView.Deleted = substation.Deleted; }
public SubstationViewModel(IServiceUnitOfWork serviceUnitOfWork, Substation substation) { this.serviceUnitOfWork = serviceUnitOfWork; oldSubstation = substation; Substation newSubstation = new Substation(); newSubstation.Name = substation.Name; newSubstation.InputYear = substation.InputYear; newSubstation.Team = substation.Team; newSubstation.TransformerType = substation.TransformerType; newSubstation.DistrictElectricalNetwork = substation.DistrictElectricalNetwork; newSubstation.InspectionsFrequency = substation.InspectionsFrequency; Substation = newSubstation; if (substation.Name != null) { InputYear = substation.InputYear.ToString(); TransformerCount = substation.TransformerCount.ToString(); } Teams = serviceUnitOfWork.Teams.GetAll(); TransformerTypes = serviceUnitOfWork.TransformerTypes.GetAll(); DistrictElectricalNetworks = serviceUnitOfWork.DistrictElectricalNetworks.GetAll(); InspectionsFrequencies = serviceUnitOfWork.InspectionsFrequencies.GetAll(); }
public SLSEDataHandler() { _data_buffer = new Dictionary <string, Dictionary <string, double> >(); _result_buffer = new Dictionary <string, Dictionary <string, double> >(); _signals = new List <Signal>(); _substation = new Substation(); }
/// <summary> /// The designated constructor for the <see cref="SynchrophasorAnalytics.Graphs.SubstationGraph"/> class. Requires a reference to a <see cref="SynchrophasorAnalytics.Modeling.Substation"/> of interest. /// </summary> /// <param name="substation">The <see cref="SynchrophasorAnalytics.Modeling.Substation"/> desired to represent as a graph.</param> public SubstationGraph(Substation substation) { m_internalID = substation.InternalID; BuildVertexSet(substation); BuildeEdgeSet(substation); InitializeAdjacencyList(); }
public override void Izvrsi() { for (int i = 0; i < Singleton.Instance().Substations.Count; i++) { if (Singleton.Instance().Substations[i].mRID.Equals(s.mRID)) { s = Singleton.Instance().Substations[i]; foreach (ConnectivityNode cn2 in s.connectivityNodes) { foreach (ConnectivityNode cn in Singleton.Instance().Nodes) { if (cn.mRID.Equals(cn2.mRID)) { foreach (ACLineSegment line in Singleton.Instance().AClines) { foreach (Terminal t in line.terminali) { if (t.ConnectivityNode.mRID.Equals(cn.mRID)) { lines.Add(line); Singleton.Instance().AClines.Remove(line); break; } } } } } } Singleton.Instance().Substations.Remove(Singleton.Instance().Substations[i]); break; } } }
public void Create(Substation t) { MaintenanceType type = dataBase.MaintenanceTypes.GetAll().First(x => x.Name == "осмотр"); MaintenanceRecord record; int section = 12 / t.InspectionsFrequency.Count; for (int year = t.InputYear.Value; year <= DateTime.Now.Year + 10; year++) { for (int i = 1; i <= t.InspectionsFrequency.Count; i++) { record = new MaintenanceRecord(); if (year < DateTime.Now.Year) { record.PlannedMaintenanceDate = new DateTime(year, section * i, 1); record.PlannedMaintenanceType = type; record.ActualMaintenanceDate = new DateTime(year, section * i, 1); record.ActualMaintenanceType = type; record.IsPlanned = true; } else if (year == DateTime.Now.Year && DateTime.Now.Month > 2) { if (DateTime.Now.Month > section * i) { record.PlannedMaintenanceDate = new DateTime(year, section * i, 1); record.ActualMaintenanceDate = new DateTime(year, section * i, 1); record.PlannedMaintenanceType = type; record.ActualMaintenanceType = type; } else if (t.InspectionsFrequency.Count == 1) { record.PlannedMaintenanceDate = new DateTime(year, section * i / 2, 1); } else { record.PlannedMaintenanceDate = new DateTime(year, section * i, 1); } record.PlannedMaintenanceType = type; record.IsPlanned = true; } else { if (t.InspectionsFrequency.Count == 12) { record.PlannedMaintenanceDate = new DateTime(year, section * i, 1); } else { record.PlannedMaintenanceDate = new DateTime(year, 1, 1); } record.PlannedMaintenanceType = type; record.IsPlanned = false; } record.IsRescheduled = false; record.MaintainedEquipment = t; dataBase.MaintenanceRecords.Create(record); } } dataBase.Substations.Create(t); dataBase.Save(); }
public override void Execute(object parameter) { Substation subs = new Substation() { Id = conflictVM.editSubsVM.Id, Name = conflictVM.editSubsVM.Name, Location = conflictVM.editSubsVM.Location, }; bool success = DataProxy.Instance.Proxy.UpdateSubstation(subs); if (success) { LoginVM.Log.Info("Conflict arrised. Changes Overriden"); LoginVM.Log.Info($"Substation updated. Id=('{subs.Id}')"); conflictVM.view.Close(); conflictVM.editSubsVM.EditView.Close(); conflictVM.editSubsVM.HomeVM.RefreshData(); } else { LoginVM.Log.Error($"Substation could not be updated. Id=('{subs.Id}')"); } }
public DerForecastDayAhead CalculateSubstation(Forecast forecast, Substation substation) { List <Generator> generators = new List <Generator>(); foreach (KeyValuePair <DMSType, Dictionary <long, IdentifiedObject> > kvp in networkModel.Insert) { foreach (KeyValuePair <long, IdentifiedObject> kvpDic in kvp.Value) { var type = kvpDic.Value.GetType(); if (type.Name.Equals("Generator")) { var generator = (Generator)kvpDic.Value; generators.Add(generator); } } } DerForecastDayAhead substationForecast = new DerForecastDayAhead(substation.GlobalId); foreach (Generator generator in generators) { if (substation.Equipments.Contains(generator.GlobalId)) { // DayAhead dayAhead = generator.CalculateDayAhead(forecast, substation.GlobalId, substation); substationForecast.Production += generatorForecastList[generator.GlobalId].Production; substationsForecast[substation.GlobalId] = substationForecast; } } return(substationForecast); }
public int AddSubstation(Substation sub) { lock (dummyObj) { using (var context = new DataContext()) { var existingStation = context.Substations.FirstOrDefault(x => x.Id == sub.Id); if (existingStation != null) { Program.Log.Error($"Tried to add substation with existing Id (ID='{sub.Id}')"); return(-1); } context.Substations.Add(sub); context.SaveChanges(); Task.Factory.StartNew(() => { NotifyUsersAboutChange(); }); } } Program.Log.Info($"New substation has been added (ID = '{sub.Id}')"); return(sub.Id); }
public bool UpdateSubstation(Substation sub) { lock (dummyObj) { using (var context = new DataContext()) { var subFromDB = context.Substations.FirstOrDefault(x => x.Id == sub.Id); if (subFromDB == null) { Program.Log.Error($"Update to non-existing substation. ID = ('{sub.Id}')"); return(false); } subFromDB.Location = sub.Location; subFromDB.Name = sub.Name; context.SaveChanges(); Task.Factory.StartNew(() => { NotifyUsersAboutChange(); }); } } Program.Log.Info($"Substation was updated. ID = ('{sub.Id}')"); return(true); }
public SubstationDetailViewModel(object substation) { if (substation != null && substation is Substation) { m_substation = substation as Substation; } }
public override void Execute(object parameter) { if (viewModel.RedoHistory.Count <= 0) { MessageBox.Show("Nema nsita za redo"); return; } BaseCommand cmd = viewModel.RedoHistory[viewModel.RedoHistory.Count - 1]; //get last item Substation subs = viewModel.SubstationsRedo[viewModel.SubstationsRedo.Count - 1]; //Mozda napraviti apstraktnu klasu za sve modele, i u njoj apstraktnu metodu GetParams. //Kako ne bih pravio undo/redo komande za svaki model //za sad nek ide ovako object[] parameters = new object[3]; parameters[0] = subs.Name; parameters[1] = subs.Location; if (cmd is DeleteSubstation) { subs.Id = DataProxy.Instance.Proxy.GetIdOfLastAddedSubstation(); } parameters[2] = subs.Id; cmd.Execute(parameters); viewModel.RedoHistory.Remove(cmd); viewModel.SubstationsRedo.RemoveAt(viewModel.SubstationsRedo.Count - 1); viewModel.RefreshData(); LoginVM.Log.Info("REDO command invoked"); }
public DropSub(Substation draggedSubstation, double x, double y) { s = draggedSubstation; this.x = x; this.y = y; this.x2 = s.x; this.y2 = s.y; }
/// <summary> /// The designated constructor for the <see cref="LinearStateEstimator.Graphs.SubstationGraph"/> class. Requires a reference to a <see cref="LinearStateEstimator.Modeling.Substation"/> of interest. /// </summary> /// <param name="substation">The <see cref="LinearStateEstimator.Modeling.Substation"/> desired to represent as a graph.</param> public SubstationGraph(Substation substation) { m_internalID = substation.InternalID; BuildVertexSet(substation); BuildeEdgeSet(substation); InitializeAdjacencyList(); m_observedBuses = new List <ObservedBus>(); }
private async Task ReadInputData() { using (var stream = await FileSystem.OpenAppPackageFileAsync("Inputs.json")) { using (var reader = new StreamReader(stream)) { var jsonInputs = await reader.ReadToEndAsync(); if (jsonInputs == null) { throw new Exception("Unable to read files"); } else { Subdivision subdivision = JsonConvert.DeserializeObject <Subdivision>(jsonInputs); if (subdivision == null) { throw new Exception("Unable to read files"); } else { var allFeederStation = new Substation() { ID = -1, Name = "All Substations", Feeders = new List <Feeder>(), }; allFeederStation.Feeders.Insert(0, new Feeder() { ID = -1, Name = "All Feeders", }); foreach (var substation in subdivision.SubStations) { foreach (var feeder in substation.Feeders) { allFeederStation.Feeders.Add(feeder); } substation.Feeders.Insert(0, new Feeder() { ID = -1, Name = "All Feeders", }); } subdivision.SubStations.Insert(0, allFeederStation); CurrentInterruption = new Interruption() { SubDivision = subdivision, SubStation = subdivision.SubStations[0], Feeder = subdivision.SubStations[0].Feeders[0], ReportedDate = DateTime.Now, }; } } } } }
private void BuildVertexSet(Substation substation) { m_vertexSet = new List <Node>(); // Build Vertex Set foreach (Node node in substation.Nodes) { m_vertexSet.Add(node); } }
private void AddSubstationToRetainList() { MainWindowViewModel mainWindow = m_networkTree.MainWindow as MainWindowViewModel; Substation substation = m_networkElement.Element as Substation; if (!mainWindow.RetainedSubstations.Contains(substation)) { mainWindow.RetainedSubstations.Add(substation); mainWindow.ActionStatus = $"{substation.Name} added to retained list."; } }
public void InsertUpdate(Substation rec) { if (rec.Id == Guid.Empty) { context.Substations.Add(rec); } else { context.Entry(rec).State = EntityState.Modified; } }
private void BrisiTrafostanicu(object sender, RoutedEventArgs e) { if (dataGrid.SelectedItem != null) { Substation s = dataGrid.SelectedItem as Substation; BrisiTrafo bt = new BrisiTrafo(s.mRID); Singleton.Instance().inv.DodajIzvrsi(bt); serializer.SerializeObject <BindingList <Substation> >(Singleton.Instance().Substations, "../../doc/trafostanice.xml"); Singleton.Instance().NotifyObservers(); } }
private void KlonirajTrafo(object sender, RoutedEventArgs e) { if (dataGrid.SelectedItem != null) { Substation s = dataGrid.SelectedItem as CIM.IEC61970.Base.Core.Substation; CloneTrafo ct = new CloneTrafo(s.mRID); Singleton.Instance().inv.DodajIzvrsi(ct); serializer.SerializeObject <BindingList <CIM.IEC61970.Base.Core.Substation> >(Singleton.Instance().Substations, "../../doc/trafostanice.xml"); Singleton.Instance().NotifyObservers(); } }
static void Main(string[] args) { string filepath = "test.xml"; Substation substation = new Substation(); substation = substation.DeserializeFromXml(filepath); substation.Initialize(); // substation.MeasurementReceived(); substation.SLSE(); }
public void FillWithSubstations() { int wModulo = Width % 18; int hModulo = Height % 18; int newWidth = Width; int newHeight = Height; bool isSizeChanged = false; if (wModulo != 0) { newWidth += 18 - wModulo; wModulo++; isSizeChanged = true; } if (hModulo != 0) { newHeight += 18 - hModulo; hModulo++; isSizeChanged = true; } if (isSizeChanged) { var newMap = new MapEntity[newWidth, newHeight]; for (int x = 0; x < Width; x++) { for (int y = 0; y < Height; y++) { if (_map[x, y] != null) { newMap[x, y] = _map[x, y]; } } } _map = newMap; Width = newWidth; Height = newHeight; } int wSubsCount = Width / 18; int hSubsCount = Height / 18; for (int x = 0; x < wSubsCount; x++) { for (int y = 0; y < hSubsCount; y++) { var substation = new Substation(x * 18 + 8.5f, y * 18 + 8.5f); _map[(int)(substation.X - 0.5f), (int)(substation.Y - 0.5f)] = substation; _map[(int)(substation.X - 0.5f), (int)(substation.Y + 0.5f)] = substation; _map[(int)(substation.X + 0.5f), (int)(substation.Y - 0.5f)] = substation; _map[(int)(substation.X + 0.5f), (int)(substation.Y + 0.5f)] = substation; } } }
public List <Device> GetDevices(Substation substation) { lock (dummyObj) { using (var context = new DataContext()) { var devices = context.Devices.Where(x => x.Device_Substation == substation.Id); Program.Log.Info($"All devices in substation have been requested and returned. Substation_ID = ('{substation.Id}')"); return(devices.ToList()); } } }
public async Task ImportForeignSubstations(WRLDCWarehouseDbContext _context, ILogger _log, string oracleConnStr, EntityWriteOption opt) { SubstationExtract ssExtract = new SubstationExtract(); List <SubstationForeign> ssForeignList = ssExtract.ExtractSubstationsForeign(oracleConnStr); LoadSubstation loadSS = new LoadSubstation(); foreach (SubstationForeign ssForeign in ssForeignList) { Substation insertedSS = await loadSS.LoadSingleAsync(_context, _log, ssForeign, opt); } }
/// <summary> /// The designated constructor for the <see cref="LinearStateEstimator.Graphs.SubstationGraph"/> class. Requires a reference to a <see cref="LinearStateEstimator.Modeling.Substation"/> of interest. /// </summary> /// <param name="substation">The <see cref="LinearStateEstimator.Modeling.Substation"/> desired to represent as a graph.</param> public SubstationGraph(Substation substation) { m_internalID = substation.InternalID; m_topologyLevel = substation.TopologyLevel; m_angleDeltaThresholdInDegrees = substation.AngleDeltaThresholdInDegrees; BuildVertexSet(substation); BuildeEdgeSet(substation); InitializeAdjacencyList(); m_observedBuses = new List <ObservedBus>(); CreatePhasorPairMatrix(); InitializeConnectivityMatrix(); }
private ResourceDescription CreateSubstationResourceDescription(Substation cimSubstation) { ResourceDescription rd = null; if (cimSubstation != null) { long gid = ModelCodeHelper.CreateGlobalId(0, (short)DMSType.SUBSTATION, importHelper.CheckOutIndexForDMSType(DMSType.SUBSTATION)); rd = new ResourceDescription(gid); importHelper.DefineIDMapping(cimSubstation.ID, gid); SCADAConverter.PopulateSubstationProperties(cimSubstation, rd, importHelper, report); } return(rd); }
public void MarkActualRecord(Substation substation, DateTime date) { MaintenanceRecord record = substation.MaintenanceRecords.FirstOrDefault(x => x.ActualMaintenanceDate == null && x.IsPlanned == true && x.IsRescheduled == false); if (record == null) { return; } MaintenanceType type = dataBase.MaintenanceTypes.GetAll().First(x => x.Name == "осмотр"); record.ActualMaintenanceDate = date; record.ActualMaintenanceType = type; dataBase.Save(); }
private void BuildeEdgeSet(Substation substation) { m_edgeSet = new List <SwitchingDeviceBase>(); // Build Edge Set foreach (CircuitBreaker circuitBreaker in substation.CircuitBreakers) { m_edgeSet.Add(circuitBreaker); } foreach (Switch circuitSwitch in substation.Switches) { m_edgeSet.Add(circuitSwitch); } }
[HttpGet("[action]/substation/{substationId}")] //api/ajax/Equipments/substation/1 public async Task <IActionResult> Equipments(int substationId) { Substation substation = await _repoSubstation.DeepFindAsync(substationId); var toReturn = substation.Equipments.Select(x => new IndexViewModel { Name = x.Name, IsFolder = false }); if (toReturn == null) { return(NotFound()); } return(Ok(toReturn)); }
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()); } }