/// <summary> /// How to get process data automatically /// </summary> /// <param name="sender"></param> /// <param name="e">Here you find the current process data (e.g. weight value)</param> private void update(object sender, ProcessDataReceivedEventArgs e) { this.BeginInvoke(new Action(() => { DisplayText("Net:" + _wtxDevice.PrintableWeight.Net + _wtxDevice.Unit + Environment.NewLine + "Gross:" + _wtxDevice.PrintableWeight.Gross + _wtxDevice.Unit + Environment.NewLine + "Tara:" + _wtxDevice.PrintableWeight.Gross + _wtxDevice.Unit); if (e.ProcessData.Underload == true) { DisplayText("Underload : Lower than minimum" + Environment.NewLine); picNE107.Image = Properties.Resources.NE107_OutOfSpecification; } else if (e.ProcessData.Overload == true) { DisplayText("Overload : Higher than maximum capacity" + Environment.NewLine); picNE107.Image = Properties.Resources.NE107_OutOfSpecification; } else if (e.ProcessData.HigherSafeLoadLimit == true) { DisplayText("Higher than safe load limit" + Environment.NewLine); picNE107.Image = Properties.Resources.NE107_OutOfSpecification; } else { picNE107.Image = Properties.Resources.NE107_DiagnosisActive; } })); }
private void OnErrorDataReceived(object sender, ProcessDataReceivedEventArgs e) { if (!string.IsNullOrEmpty(e.Data)) { _term.WriteLine(e.Data); } }
private void Process_ErrorDataReceived(object sender, ProcessDataReceivedEventArgs e) { if (!string.IsNullOrWhiteSpace(e.Data)) { this.Log(this.ErrorLevel, e.Data); } }
private void Process_OutputDataReceived(object sender, ProcessDataReceivedEventArgs e) { if (!string.IsNullOrWhiteSpace(e.Data)) { this.LogDebug(e.Data); } }
// This method prints the values of the device (as a integer and the interpreted string) as well as the description of each bit. private static void Update(object sender, ProcessDataReceivedEventArgs e) { // The description and the value of the WTX are only printed on the console if the Interface, containing all auto-properties of the values is // not null (respectively empty) and if no calibration is done at that moment. if (_wtxDevice != null && e != null) { Console.Clear(); if (connectiontype == ConnectionType.Modbus) { Console.WriteLine("\n0-Taring | 1-Gross/net | 2-Zeroing | 3- Adjust zero | 4-Adjust nominal |\n5-Record weight|m-Manual redosing | j-Switch connection to Jetbus | \nc-Calculate Calibration | w-Calibration with weight | e-Exit the application\n"); } else { if (connectiontype == ConnectionType.Jetbus) { Console.WriteLine("\n0-Taring | 1-Gross/net | 2-Zeroing | 3- Adjust zero | 4-Adjust nominal |\n5-Record weight|m-Manual redosing | j-Switch connection to Modbus | \nc-Calculate Calibration | w-Calibration with weight | e-Exit the application\n"); } } if (_wtxDevice.ApplicationMode == ApplicationMode.Standard) // If the device is in the standard mode (standard=0 or standard=1; filler=1 or filler=2) { Console.WriteLine("Net value: " + _wtxDevice.Weight.Net + "\t As an int/bool: " + e.ProcessData.Weight.Net); Console.WriteLine("Gross value: " + _wtxDevice.Weight.Gross + "\t As an int/bool: " + e.ProcessData.Weight.Gross); Console.WriteLine("General weight error: " + e.ProcessData.GeneralWeightError.ToString() + "\t As an int/bool: " + e.ProcessData.GeneralWeightError); Console.WriteLine("Scale alarm triggered: " + e.ProcessData.ScaleAlarm.ToString() + "\t As an int/bool: " + e.ProcessData.ScaleAlarm); Console.WriteLine("Scale seal is open: " + e.ProcessData.LegalForTrade.ToString() + "\t As an int/bool: " + e.ProcessData.LegalForTrade); Console.WriteLine("Weight type: " + e.ProcessData.TareMode + "\t As an int/bool: " + e.ProcessData.TareMode); Console.WriteLine("Scale range: " + e.ProcessData.ScaleRange + "\t As an int/bool: " + e.ProcessData.ScaleRange); Console.WriteLine("Zero required/True zero: " + e.ProcessData.ZeroRequired.ToString() + "\t As an int/bool: " + e.ProcessData.ZeroRequired); Console.WriteLine("Weight within center of zero: " + e.ProcessData.CenterOfZero.ToString() + "\t As an int/bool: " + e.ProcessData.CenterOfZero); Console.WriteLine("Weight in zero range: " + e.ProcessData.InsideZero.ToString() + "\t As an int/bool: " + e.ProcessData.InsideZero); Console.WriteLine("Application mode: " + _wtxDevice.ApplicationMode.ToString() + "\t As an int/bool: " + _wtxDevice.ApplicationMode.ToString()); Console.WriteLine("Decimal places: " + e.ProcessData.Decimals.ToString() + "\t As an int/bool: " + e.ProcessData.Decimals); Console.WriteLine("Unit: " + _wtxDevice.Unit + "\t As an int/bool: " + e.ProcessData.Unit); Console.WriteLine("Limit status: " + limitCommentMethod() + " As an int/bool: " + e.ProcessData.Overload); Console.WriteLine("Weight moving: " + e.ProcessData.WeightStable.ToString() + " As an int/bool: " + e.ProcessData.WeightStable); } else // In Filler application : { Console.WriteLine("Net value: " + _wtxDevice.PrintableWeight.Net + "\t As an int/bool: " + e.ProcessData.Weight.Net); Console.WriteLine("Gross value: " + _wtxDevice.PrintableWeight.Gross + "\t As an int/bool: " + e.ProcessData.Weight.Gross); Console.WriteLine("General weight error: " + e.ProcessData.GeneralWeightError.ToString() + "\t As an int/bool: " + e.ProcessData.GeneralWeightError); Console.WriteLine("Scale alarm triggered: " + e.ProcessData.ScaleAlarm.ToString() + "\t As an int/bool: " + e.ProcessData.ScaleAlarm); Console.WriteLine("Scale seal is open: " + e.ProcessData.LegalForTrade.ToString() + "\t As an int/bool: " + e.ProcessData.LegalForTrade); Console.WriteLine("Weight type: " + e.ProcessData.TareMode + "\t As an int/bool: " + e.ProcessData.TareMode); Console.WriteLine("Scale range: " + e.ProcessData.ScaleRange + "\t As an int/bool: " + e.ProcessData.ScaleRange); Console.WriteLine("Zero required/True zero: " + e.ProcessData.ZeroRequired.ToString() + "\t As an int/bool: " + e.ProcessData.ZeroRequired); Console.WriteLine("Weight within center of zero: " + e.ProcessData.CenterOfZero.ToString() + "\t As an int/bool: " + e.ProcessData.CenterOfZero); Console.WriteLine("Weight in zero range: " + e.ProcessData.InsideZero.ToString() + "\t As an int/bool: " + e.ProcessData.InsideZero); Console.WriteLine("Application mode: " + _wtxDevice.ApplicationMode.ToString() + "\t As an int/bool: " + _wtxDevice.ApplicationMode); Console.WriteLine("Decimal places: " + e.ProcessData.Decimals.ToString() + "\t As an int/bool: " + e.ProcessData.Decimals); Console.WriteLine("Unit: " + _wtxDevice.Unit + "\t As an int/bool: " + e.ProcessData.Unit); Console.WriteLine("Limit status: " + limitCommentMethod() + " As an int/bool: " + e.ProcessData.Overload); Console.WriteLine("Weight moving: " + e.ProcessData.WeightStable.ToString() + " As an int/bool: " + e.ProcessData.WeightStable); } } }
private void OnDataReceived(object sender, ProcessDataReceivedEventArgs e) { // This does not need to be inside of a critical section. // The logging queues and command handlers are thread-safe. if (!CommandManager.TryProcessCommand(ExecutionContext, e.Data)) { ExecutionContext.Output(e.Data); } }
private void OnErrorDataReceived(object sender, ProcessDataReceivedEventArgs e) { lock (_outputLock) { if (!string.IsNullOrEmpty(e.Data)) { _errorBuffer.AppendLine(e.Data); } } }
private void OnOutputDataReceived(object sender, ProcessDataReceivedEventArgs e) { lock (_outputLock) { FlushErrorData(); if (!CommandManager.TryProcessCommand(ExecutionContext, e.Data)) { ExecutionContext.Output(e.Data); } } }
private void ErrorDataReceived(object sender, ProcessDataReceivedEventArgs args) { if (this.UseNinja) { this.NinjaErrorDataReceived(sender, args); } else { this.MakeErrorDataReceived(sender, args); } }
private void OnOutputDataReceived(object sender, ProcessDataReceivedEventArgs e) { lock (_outputLock) { FlushErrorData(); string line = e.Data ?? string.Empty; if (_modifyEnvironment) { if (_foundDelimiter) { // The line is output from the SET command. Update the environment. int index = line.IndexOf('='); if (index > 0) { string key = line.Substring(0, index); string value = line.Substring(index + 1); // Omit special environment variables: // "TF_BUILD" is set by ProcessInvoker. // "agent.jobstatus" is set by ???. if (string.Equals(key, Constants.TFBuild, StringComparison.Ordinal) || string.Equals(key, Constants.Variables.Agent.JobStatus, StringComparison.Ordinal)) { return; } ExecutionContext.Debug($"Setting env '{key}' = '{value}'"); System.Environment.SetEnvironmentVariable(key, value); } return; } // if (_foundDelimiter) // Use StartsWith() instead of Equals() to allow for trailing spaces from the ECHO command. if (line.StartsWith(OutputDelimiter, StringComparison.Ordinal)) { // The line is the output delimiter. // Set the flag and clear the environment variable dictionary. _foundDelimiter = true; return; } } // if (_modifyEnvironment) // The line is output from the process that was invoked. if (!CommandManager.TryProcessCommand(ExecutionContext, line)) { ExecutionContext.Output(line); } } }
private void OnDataReceived(object sender, ProcessDataReceivedEventArgs e) { // drop any outputs after the task get force completed. if (ExecutionContext.ForceCompleted.IsCompleted) { return; } // This does not need to be inside of a critical section. // The logging queues and command handlers are thread-safe. if (!CommandManager.TryProcessCommand(ExecutionContext, e.Data)) { ExecutionContext.Output(e.Data); } }
protected string RemoveLogRubbish(ProcessDataReceivedEventArgs e) { var line = e.Data.TrimEnd(); if (this.ImageTag == "msvc" && line == @"wine: cannot find L""C:\\windows\\Microsoft.NET\\Framework\\v4.0.30319\\mscorsvw.exe""") { return(null); } if (this.ImageTag == "msvc" && line.StartsWith("cl : Command line warning D9025 : overriding '/O")) { return(null); } return(line); }
private void NinjaOutputDataReceived(object source, ProcessDataReceivedEventArgs args) { int?percentage = null; var line = this.RemoveLogRubbish(args); if (line == null) { return; } var slash = line.IndexOf('/'); var close = line.IndexOf(']'); if (slash != -1 && slash < close && line[0] == '[') { var num = AH.ParseInt(line.Substring(1, slash - 1)); var den = AH.ParseInt(line.Substring(slash + 1, close - slash - 1)); if (num.HasValue && den.HasValue) { percentage = 100 * num.Value / den.Value; this.progress = new OperationProgress(percentage, $"{this.serverName} {line.Substring(0, close + 1)}"); } } if (this.ImageTag == "msvc" && !percentage.HasValue && args.Data != line && new[] { ".c", ".cc", ".cpp" }.Any(ext => line.EndsWith(ext))) { return; } if (percentage.HasValue) { this.LogInformation(line); } else if (line.Contains(this.ImageTag == "msvc" ? " error C" : ": error: ")) { this.LogError(line); } else if (line.Contains(this.ImageTag == "msvc" ? " warning C" : ": warning: ")) { this.LogWarning(line); } else { this.LogDebug(line); } }
private void Process_OutputDataReceived(object sender, ProcessDataReceivedEventArgs e) { var regex = this.warnRegex.Value; if (regex != null) { var match = regex.Match(e.Data); if (match.Success) { this.LogWarning(match.Groups["m"]?.Value ?? e.Data); return; } } this.Log(this.OutputLevel, e.Data); }
private void OnErrorDataReceived(object sender, ProcessDataReceivedEventArgs e) { lock (_outputLock) { if (_failOnStandardError) { if (!string.IsNullOrEmpty(e.Data)) { _errorBuffer.AppendLine(e.Data); } } else { ExecutionContext.Output(e.Data); } } }
private void MakeErrorDataReceived(object source, ProcessDataReceivedEventArgs args) { var line = this.RemoveLogRubbish(args); if (line == null) { return; } if (line.Contains(this.ImageTag == "msvc" ? " error C" : ": error: ")) { this.LogError(line); } else { this.LogWarning(line); } }
private void NinjaErrorDataReceived(object source, ProcessDataReceivedEventArgs args) { var line = this.RemoveLogRubbish(args); if (line == null) { return; } if (this.ImageTag == "msvc" && line.StartsWith("cl : Command line warning D9025 : overriding '/O")) { return; } if (line.Contains(this.ImageTag == "msvc" ? " error C" : ": error: ")) { this.LogError(line); } else { this.LogWarning(line); } }
private void MakeOutputDataReceived(object source, ProcessDataReceivedEventArgs args) { int? percentage = null; bool targetsChanged = false; var line = this.RemoveLogRubbish(args); if (line == null) { return; } if (line.Length > "[100%] ".Length && line[0] == '[' && line[4] == '%' && line[5] == ']' && line[6] == ' ') { percentage = AH.ParseInt(line.Substring(1, 3).TrimStart()); if (line.Substring("[100%] ".Length).StartsWith("Built target ")) { if (activeTargets.Remove(line.Substring("[100%] Built target ".Length).Trim())) { targetsChanged = true; } } } else if (line.StartsWith("Scanning dependencies of target ")) { if (activeTargets.Add(line.Substring("Scanning dependencies of target ".Length).Trim())) { targetsChanged = true; } } else if (line.StartsWith("CPack: ")) { this.LogInformation(line); if (!line.StartsWith("CPack: - ")) { this.progress = new OperationProgress(100, line); } return; } if (targetsChanged || (percentage.HasValue && percentage != this.progress.Percent)) { this.progress = new OperationProgress(percentage ?? this.progress.Percent, string.Join(", ", activeTargets)); } if (this.ImageTag == "msvc" && (!targetsChanged || !percentage.HasValue) && args.Data != line && new[] { ".c", ".cc", ".cpp" }.Any(ext => line.EndsWith(ext))) { return; } if (targetsChanged && percentage.HasValue) { this.LogInformation(line); } else if (line.Contains(this.ImageTag == "msvc" ? " error C" : ": error: ")) { this.LogError(line); } else if (line.Contains(this.ImageTag == "msvc" ? " warning C" : ": warning: ")) { this.LogWarning(line); } else { this.LogDebug(line); } }
public void OnDataReceived(object sender, ProcessDataReceivedEventArgs e) { var line = e.Data; // ## commands if (!String.IsNullOrEmpty(line) && (line.IndexOf(ActionCommand.Prefix) >= 0 || line.IndexOf(ActionCommand._commandKey) >= 0)) { // This does not need to be inside of a critical section. // The logging queues and command handlers are thread-safe. if (_commandManager.TryProcessCommand(_executionContext, line, _container)) { return; } } // Problem matchers if (_matchers.Length > 0) { // Copy the reference var matchers = _matchers; // Strip color codes var stripped = line.Contains(_colorCodePrefix) ? _colorCodeRegex.Replace(line, string.Empty) : line; foreach (var matcher in matchers) { IssueMatch match = null; for (var attempt = 1; attempt <= _maxAttempts; attempt++) { // Match try { match = matcher.Match(stripped); break; } catch (RegexMatchTimeoutException ex) { if (attempt < _maxAttempts) { // Debug _executionContext.Debug($"Timeout processing issue matcher '{matcher.Owner}' against line '{stripped}'. Exception: {ex.ToString()}"); } else { // Warn _executionContext.Warning($"Removing issue matcher '{matcher.Owner}'. Matcher failed {_maxAttempts} times. Error: {ex.Message}"); // Remove Remove(matcher); } } } if (match != null) { // Reset other matchers foreach (var otherMatcher in matchers.Where(x => !object.ReferenceEquals(x, matcher))) { otherMatcher.Reset(); } // Convert to issue var issue = ConvertToIssue(match); if (issue != null) { // Log issue _executionContext.AddIssue(issue, stripped); return; } } } } // Regular output _executionContext.Output(line); }
private void UpdateReadTest(object sender, ProcessDataReceivedEventArgs e) { _testValue = (ushort)e.ProcessData.Weight.Net; }
/* * // Test for checking the handshake bit * [Test, TestCaseSource(typeof(ReadTestsModbus), "HandshakeTestCases")] * public bool testHandshake(Behavior behavior) * { * testConnection = new TestModbusTCPConnection(behavior, "172.19.103.8"); * _wtxDevice = new WTXModbus(testConnection, 200,UpdateTestHandshake); * * _wtxDevice.Connect(this.OnConnect, 100); * * _wtxDevice.WriteSync(0, 0x1); * * return _wtxDevice.ProcessData.Handshake; * } */ private void UpdateTestHandshake(object sender, ProcessDataReceivedEventArgs e) { }
private void Update(object sender, ProcessDataReceivedEventArgs e) { //throw new NotImplementedException(); }
private void UpdateMeasureZeroTest(object sender, ProcessDataReceivedEventArgs e) { }
private void UpdateApplicationModeTest(object sender, ProcessDataReceivedEventArgs e) { }
private void Update(object sender, ProcessDataReceivedEventArgs e) { }
private void UpdateLogEventSetTest(object sender, ProcessDataReceivedEventArgs e) { }