private void GetDataFromCollector() { var telemetries = _collector.Collect(); foreach (var item in telemetries) { if (item.Kind == "Pressure") { // Write the telemetry + date time to pressure file when pressure > 30 psi if (int.Parse(item.Value.Split(' ')[0]) > 30) { using (StreamWriter writer = new StreamWriter("pressures.txt", true)) { writer.Write($"[{DateTime.Now}] {item.Value}"); } } } else if (item.Kind == "Temperature") { // temparature should be converted to Degree when in fahrenheit var valueInDegree = int.Parse(item.Value.Split(' ')[0]) - 32 * 5 / 9; // Write the temparature + date time to temparature file using (StreamWriter writer = new StreamWriter("temparatures.txt", true)) { writer.Write($"[{DateTime.Now}] {valueInDegree} °C"); } } else { // Raise error event to be consumed by consumers of TelemetryClient ErrorDetected?.Invoke(this, new ErrorEventArgs(item.Value)); } } }
/// <summary> /// Cette fonction va nous permettre de préparer l'affichage de la main et vérifier que le fichier indiqué existe. /// </summary> /// <param name="fileName"> Le nom du fichier à lire. </param> public void InitVizualisation(string fileName) { try { string filePath = string.Format("{0}/{1}.txt", _assetPath, fileName); using (StreamReader reader = new StreamReader(filePath)) { _fileContent = reader.ReadToEnd(); } List <string> lines = _fileContent.Split('\n').ToList(); _nbHandJoint = lines.Where(l => l.Contains("START")).Count(); } // Cette erreur arrive lorsque le nom du fichier fileName n'existe pas. catch (Exception ex) { Debug.LogError(ex.Message); ErrorDetected?.Invoke(this, null); } }
/// <summary> /// Triggers <see cref="ErrorDetected"/> event with given exception. /// </summary> /// <param name="error"></param> public void TriggerError(LocateableException error) { ErrorDetected?.Invoke(this, error); }
/// <summary> /// Caller method for the ErrorDetected event. /// </summary> protected virtual void OnErrorDetected() { ErrorDetected?.Invoke(this, EventArgs.Empty); }
public void NotifyErrorDetected(Models.ScrapingRule scraper, Models.ScrapingResult result) { Instance.ShowInformation($"{scraper.Name} is failed."); ErrorDetected?.Invoke(this, new DetectedEventArgs(scraper, result)); }
internal void onErrorDetected(ErrorDetectedEventArgs args) { ErrorDetected?.Invoke(PenClient, args); }