Beispiel #1
0
        /////////////////////////////////////////////////////////
        #region Constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="SolutionPagePresenter"/> class.
        /// </summary>
        /// <param name="view">The view.</param>
        /// <param name="viewModel">The view model.</param>
        /// <param name="model">The model.</param>
        /// <param name="viewStateProvider">A common <see cref="IViewStateProvider"/>.</param>
        /// <param name="fileSystem">The file sytem access.</param>
        /// <param name="systemInterface">The interface for system operations.</param>
        /// <param name="userIOInterface">The user IO interface.</param>
        /// <param name="ide">Information about the current Visual Studio instance.</param>
        /// <exception cref="ArgumentNullException">Any parameter is null.</exception>
        public SolutionPagePresenter([NotNull] ISolutionPageView view,
                                     [NotNull] ISolutionPageViewModel viewModel,
                                     [NotNull] ISolutionPageModel model,
                                     [NotNull] IViewStateProvider viewStateProvider,
                                     [NotNull] IFileSystem fileSystem,
                                     [NotNull] ISystemInterface systemInterface,
                                     [NotNull] IUserIOInterface userIOInterface,
                                     [NotNull] IIde ide)
            : base(view, viewModel)
        {
            ThrowIfNull(model, nameof(model));
            ThrowIfNull(viewStateProvider, nameof(viewStateProvider));
            ThrowIfNull(fileSystem, nameof(fileSystem));
            ThrowIfNull(systemInterface, nameof(systemInterface));
            ThrowIfNull(userIOInterface, nameof(userIOInterface));
            ThrowIfNull(ide, nameof(ide));

            _model             = model;
            _viewStateProvider = viewStateProvider;
            _fileSystem        = fileSystem;
            _systemInterface   = systemInterface;
            _userIOInterface   = userIOInterface;
            _ide           = ide;
            _configuration = _model.LoadConfiguration();
        }
        public void GetNumActiveAlarmsFromSmartSUB(ISystemInterface systemInterface, ushort stationID)
        {
            SiteID siteID = new SiteID(stationID);

            DatabaseManagerStub databaseManager = new DatabaseManagerStub(systemInterface);

            databaseManager.GetActiveAlarms(siteID, (response, expected) => ExtractNumAlarms(response, expected, stationID, systemInterface));
        }
 public ref ObservableCollection <Stations> GetStations(ISystemInterface systemInterface)
 {
     foreach (int station in GetDistinctStations(systemInterface))
     {
         GetNumActiveAlarmsFromSmartSUB(systemInterface, Convert.ToUInt16(station));
     }
     return(ref stations);
 }
        public List <int> GetDistinctStations(ISystemInterface systemInterface)
        {
            List <int> stations = new List <int>();

            var siteIDs = systemInterface.SystemInfo.SiteIds;

            foreach (int i in siteIDs)
            {
                if (i != 0)
                {
                    stations.Add(i);
                }
            }
            return(stations);
        }
        public void ExtractNumAlarms(QueryResult response, IEnumerable <AlarmRecord> expected, ushort stationID, ISystemInterface systemInterface)
        {
            int      count             = 0;
            DateTime latestActiveAlarm = new DateTime(1970, 01, 01);

            if (response == QueryResult.Valid)
            {
                var alarm = expected.GetEnumerator();

                while (alarm.MoveNext())
                {
                    var      nodeDefinition = systemInterface.SystemInfo.NodeFromID(alarm.Current.NodeID);
                    NodeType nodeType       = nodeDefinition.Type;

                    if (nodeType.ID != Symbol.Intern("CompanyType") &&
                        nodeType.ID != Symbol.Intern("RegionType") &&
                        nodeType.ID != Symbol.Intern("SubstationType"))
                    {
                        count++;

                        if (latestActiveAlarm < alarm.Current.TimeStamp)
                        {
                            latestActiveAlarm = alarm.Current.TimeStamp;
                        }
                    }
                }

                if (latestActiveAlarm == new DateTime(1970, 01, 01))
                {
                    stations.Add(new Stations()
                    {
                        StationID         = "Station: " + stationID,
                        NumActiveAlarms   = "Active Alarms: " + count,
                        DateOfLatestAlarm = "No Active Alarms Found."
                    });
                }
                else
                {
                    stations.Add(new Stations()
                    {
                        StationID         = "Station: " + stationID,
                        NumActiveAlarms   = "Active Alarms: " + count,
                        DateOfLatestAlarm = "Latest Alarm Date: " + latestActiveAlarm
                    });
                }
            }
        }