Ejemplo n.º 1
0
      private static int _computeTotalSocketsInState(GridSite grid, GridElementStatus status) {
         int res = 0;
         foreach (var c in grid.MainPanel.Circuits) {
            res += c.Sockets.Count(s => s.Status == status);
         }

         // Add to this the total number of sockets in all secondary panels
         foreach (ElectricPanel secondary in grid.MainPanel.SecondaryPanels) {
            for (int i = 0; i < secondary.Circuits.Count; i++)
               res += secondary.Circuits[i].Sockets.Count(s => s.Status == status);
         }

         return res;
      }
Ejemplo n.º 2
0
      private static int _computeTotalSockets(GridSite grid) {
         int res = 0;

         // Compute total number of sockets in the main panel
         for (int i = 0; i < grid.MainPanel.Circuits.Count; i++) {
            res += grid.MainPanel.Circuits[i].Sockets.Count;
         }

         // Add to this the total number of sockets in all secondary panels
         foreach (ElectricPanel secondary in grid.MainPanel.SecondaryPanels) {
            for (int i = 0; i < secondary.Circuits.Count; i++)
               res += secondary.Circuits[i].Sockets.Count;
         }

         return res;
      }
Ejemplo n.º 3
0
      /// <summary>Create a summary object from the specified grid.</summary>
      /// <param name="grid">The grid to use for creating the summary</param>
      /// <returns>A grid summary object</returns>
      public static GridSiteSummary CreateSummary(GridSite grid) {
         GridSiteSummary res = new GridSiteSummary();
         res.ActualCurrent = grid.MainPanel.ActualCurrent;
         res.ActualDemand = grid.MainPanel.ActualDemand;
         res.MaxCurrent = grid.MainPanel.MaxCurrent;
         res.SiteId = grid.Id;

         res.TotalActiveSockets = _computeTotalSocketsContainState(grid, GridElementStatus.IsActive);
         res.TotalConnectedSockets = _computeTotalSocketsContainState(grid, GridElementStatus.IsConnected);

         res.TotalInactiveSockets = _computeTotalSocketsInState(grid, GridElementStatus.Inactive);
         res.TotalUnknownSockets = _computeTotalSocketsInState(grid, GridElementStatus.Unknown);
         res.TotalChargingSockets = _computeTotalSocketsInState(grid, GridElementStatus.Charging);
         res.TotalOccupiedSockets = _computeTotalSocketsInState(grid, GridElementStatus.Occupied);
         res.TotalPendingSockets = _computeTotalSocketsInState(grid, GridElementStatus.Pending);
         res.TotalVacantSockets = _computeTotalSocketsInState(grid, GridElementStatus.Vacant);
         res.TotalMalfunctionSockets = _computeTotalSocketsInState(grid, GridElementStatus.Error);

         res.TotalSockets = _computeTotalSockets(grid);
         res.IsOnline = (grid.Status & GridElementStatus.IsOnline) != 0;
         return res;
      }