public void Start() { _logger.Information("Alarm Service started successfully"); _logger.Information($"{AppDomain.CurrentDomain.BaseDirectory}"); (_IsConnected, _SitePI) = _piCM.Connect(); // If cannot connecto to PI Data Collective, return to terminate console app if (!_IsConnected) { return; } else { // Retrieve list of Alarm PI Points from CSV _csvlist = _reader.readFile(); _aTimer = new Timer(AppSettings.Freq * 1000); _aTimer.AutoReset = true; _aTimer.Elapsed += new ElapsedEventHandler(_OnTimedEvent); _aTimer.Start(); //_aTimer.AutoReset = false; //_aTimer.Interval = GetInterval(); //_aTimer.Start(); } }
public async Task Start() { _logger.Information("History Backfill Service started successfully"); (_IsConnected, _SitePI) = _piCM.Connect(); // If cannot connecto to PI Data Collective, return to terminate console app if (!_IsConnected) { return; } else { await _backfiller.automateBackfill(); _backfiller.logErrors(); } }
//Get Alarm String public async Task RetrieveAlarmAsync(IList <Foo> _csvlist, DateTime signalTime) { _logger.Information($"Start Cycle"); // Retrieve connected PIServer from PIConnectionManager (_IsConnected, _SitePI) = _piCM.Connect(); _signalTime = signalTime; _queryRange = GetQueryRange(_signalTime); var taskList = new List <Task>(); foreach (var item in _csvlist) { taskList.Add(_RetrieveAlarmandUpdateAsync(item)); //RetrieveAlarmandUpdate(item); } await Task.WhenAll(taskList); _logger.Information($"End Cycle"); }
public async Task automateBackfill() { // Retrieve connected PIServer from PIConnectionManager (_IsConnected, _SitePI) = _piCM.Connect(); // Retrieve list of HDA PI Points from CSV and find those PI Points on the PI Data Server _nameList = _reader.readFile(); _totalCount = _nameList.Count; // If _nameList is empty, terminate without doing anything if (_totalCount == 0) { _errorList.Add("List of PI Points is empty. Terminating Service"); return; } // Request Backfill Time Range _backfillRange = _RequestBackfillTimeRange(); // Create list of tasks for multi-threading the workload through the list of PI Points var tasks = new List <Task>(); _progressBar = new ProgressBar(); foreach (var HDAPIPointName in _nameList) { tasks.Add(_RetrieveAndBackfillAsync(HDAPIPointName)); //await Task.Delay(2000); } await Task.WhenAll(tasks); // Wait for progress bar to reach 100% first before disposing await Task.Delay(10000); _progressBar.Dispose(); return; }