/// <summary> /// Deserialize JSON into a FHIR DetectedIssue /// </summary> public static void DeserializeJson(this DetectedIssue current, ref Utf8JsonReader reader, JsonSerializerOptions options) { string propertyName; while (reader.Read()) { if (reader.TokenType == JsonTokenType.EndObject) { return; } if (reader.TokenType == JsonTokenType.PropertyName) { propertyName = reader.GetString(); if (Hl7.Fhir.Serialization.FhirSerializerOptions.Debug) { Console.WriteLine($"DetectedIssue >>> DetectedIssue.{propertyName}, depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } reader.Read(); current.DeserializeJsonProperty(ref reader, options, propertyName); } } throw new JsonException($"DetectedIssue: invalid state! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); }
void OnIssueDetected(DetectedIssue issue) { if (!Settings.GetObject("Do not show Issue Detector", false)) { IssueDetectorForm.CreateAndShowDialog(issue); } }
private ResumeJobForm(int exec, int sent, int target, DetectedIssue issue, bool allowHoming, bool suggestHoming, bool allowWCO, bool suggestWCO, GPoint wcopos) { InitializeComponent(); mAllowH = allowHoming; mSuggestH = suggestHoming; mSomeLine = Math.Max(0, exec - 17) + 1; mExec = exec + 1; mSent = sent + 1; LblSomeLines.Text = mSomeLine.ToString(); LblSent.Text = mSent.ToString(); UdSpecific.Maximum = mSent; UdSpecific.Value = mSent; RbSomeLines.Enabled = LblSomeLines.Enabled = mSomeLine > 1; RbFromSent.Enabled = true; LblSent.Enabled = sent < target; TxtCause.Text = issue.ToString(); if (/*issue == GrblCore.DetectedIssue.StopMoving ||*/ issue == DetectedIssue.StopResponding || issue == DetectedIssue.UnexpectedReset || issue == DetectedIssue.ManualReset) { //all this causes indicate a situation where grbl does not execute the content of buffers (both planned and rx) //so restart from some line (17 lines) before the last command in planned buffer if (RbSomeLines.Enabled) { RbSomeLines.Checked = true; } else { RbFromBeginning.Checked = true; } } else if (issue == DetectedIssue.ManualDisconnect || issue == DetectedIssue.UnexpectedDisconnect) { //if issue is a disconnect all sent lines could be already executed //so restart from sent if (RbFromSent.Enabled) { RbFromSent.Checked = true; } else { RbFromSpecific.Checked = true; } } else if (issue == DetectedIssue.ManualAbort) { RbFromBeginning.Checked = true; } CbRedoHoming.Visible = allowHoming; CbRedoHoming.Checked = allowHoming && suggestHoming; CbRestoreWCO.Visible = allowWCO; CbRestoreWCO.Checked = allowWCO && suggestWCO; CbRestoreWCO.Text = String.Format("{0} X{1} Y{2}", CbRestoreWCO.Text, wcopos.X, wcopos.Y); if (wcopos.Z != 0) { CbRestoreWCO.Text += String.Format(" Z{0}", wcopos.Z); } }
internal static void CreateAndShowDialog(DetectedIssue issue) { IssueDetectorForm f = new IssueDetectorForm(); f.TxtCause.Text = issue.ToString(); f.ShowDialog(); f.Dispose(); }
internal static int CreateAndShowDialog(int exec, int sent, int target, DetectedIssue issue, bool allowHoming, bool suggestHoming, out bool homing, bool allowWCO, bool suggestWCO, out bool wco, GPoint wcopos) { ResumeJobForm f = new ResumeJobForm(exec, sent, target, issue, allowHoming, suggestHoming, allowWCO, suggestWCO, wcopos); int rv = f.ShowDialog() == DialogResult.OK ? f.Position : -1; homing = f.DoHoming; wco = f.RestoreWCO; f.Dispose(); return(rv); }
/// <summary> /// Serialize a FHIR DetectedIssue into JSON /// </summary> public static void SerializeJson(this DetectedIssue current, Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true) { if (includeStartObject) { writer.WriteStartObject(); } writer.WriteString("resourceType", "DetectedIssue"); // Complex: DetectedIssue, Export: DetectedIssue, Base: DomainResource (DomainResource) ((Hl7.Fhir.Model.DomainResource)current).SerializeJson(writer, options, false); if ((current.Identifier != null) && (current.Identifier.Count != 0)) { writer.WritePropertyName("identifier"); writer.WriteStartArray(); foreach (Identifier val in current.Identifier) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } writer.WriteString("status", Hl7.Fhir.Utility.EnumUtility.GetLiteral(current.StatusElement.Value)); if (current.Code != null) { writer.WritePropertyName("code"); current.Code.SerializeJson(writer, options); } if (current.SeverityElement != null) { if (current.SeverityElement.Value != null) { writer.WriteString("severity", Hl7.Fhir.Utility.EnumUtility.GetLiteral(current.SeverityElement.Value)); } if (current.SeverityElement.HasExtensions() || (!string.IsNullOrEmpty(current.SeverityElement.ElementId))) { JsonStreamUtilities.SerializeExtensionList(writer, options, "_severity", false, current.SeverityElement.Extension, current.SeverityElement.ElementId); } } if (current.Patient != null) { writer.WritePropertyName("patient"); current.Patient.SerializeJson(writer, options); } if (current.Identified != null) { switch (current.Identified) { case FhirDateTime v_FhirDateTime: if (v_FhirDateTime != null) { if (!string.IsNullOrEmpty(v_FhirDateTime.Value)) { writer.WriteString("identifiedDateTime", v_FhirDateTime.Value); } if (v_FhirDateTime.HasExtensions() || (!string.IsNullOrEmpty(v_FhirDateTime.ElementId))) { JsonStreamUtilities.SerializeExtensionList(writer, options, "_identifiedDateTime", false, v_FhirDateTime.Extension, v_FhirDateTime.ElementId); } } break; case Period v_Period: writer.WritePropertyName("identifiedPeriod"); v_Period.SerializeJson(writer, options); break; } } if (current.Author != null) { writer.WritePropertyName("author"); current.Author.SerializeJson(writer, options); } if ((current.Implicated != null) && (current.Implicated.Count != 0)) { writer.WritePropertyName("implicated"); writer.WriteStartArray(); foreach (ResourceReference val in current.Implicated) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if ((current.Evidence != null) && (current.Evidence.Count != 0)) { writer.WritePropertyName("evidence"); writer.WriteStartArray(); foreach (DetectedIssue.EvidenceComponent val in current.Evidence) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (current.DetailElement != null) { if (!string.IsNullOrEmpty(current.DetailElement.Value)) { writer.WriteString("detail", current.DetailElement.Value); } if (current.DetailElement.HasExtensions() || (!string.IsNullOrEmpty(current.DetailElement.ElementId))) { JsonStreamUtilities.SerializeExtensionList(writer, options, "_detail", false, current.DetailElement.Extension, current.DetailElement.ElementId); } } if (current.ReferenceElement != null) { if (!string.IsNullOrEmpty(current.ReferenceElement.Value)) { writer.WriteString("reference", current.ReferenceElement.Value); } if (current.ReferenceElement.HasExtensions() || (!string.IsNullOrEmpty(current.ReferenceElement.ElementId))) { JsonStreamUtilities.SerializeExtensionList(writer, options, "_reference", false, current.ReferenceElement.Extension, current.ReferenceElement.ElementId); } } if ((current.Mitigation != null) && (current.Mitigation.Count != 0)) { writer.WritePropertyName("mitigation"); writer.WriteStartArray(); foreach (DetectedIssue.MitigationComponent val in current.Mitigation) { val.SerializeJson(writer, options, true); } writer.WriteEndArray(); } if (includeStartObject) { writer.WriteEndObject(); } }
/// <summary> /// Deserialize JSON into a FHIR DetectedIssue /// </summary> public static void DeserializeJsonProperty(this DetectedIssue current, ref Utf8JsonReader reader, JsonSerializerOptions options, string propertyName) { switch (propertyName) { case "identifier": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"DetectedIssue error reading 'identifier' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Identifier = new List <Identifier>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.Identifier v_Identifier = new Hl7.Fhir.Model.Identifier(); v_Identifier.DeserializeJson(ref reader, options); current.Identifier.Add(v_Identifier); if (!reader.Read()) { throw new JsonException($"DetectedIssue error reading 'identifier' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Identifier.Count == 0) { current.Identifier = null; } break; case "status": if (reader.TokenType == JsonTokenType.Null) { current.StatusElement = new Code <Hl7.Fhir.Model.ObservationStatus>(); reader.Skip(); } else { current.StatusElement = new Code <Hl7.Fhir.Model.ObservationStatus>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.ObservationStatus>(reader.GetString())); } break; case "_status": if (current.StatusElement == null) { current.StatusElement = new Code <Hl7.Fhir.Model.ObservationStatus>(); } ((Hl7.Fhir.Model.Element)current.StatusElement).DeserializeJson(ref reader, options); break; case "code": current.Code = new Hl7.Fhir.Model.CodeableConcept(); ((Hl7.Fhir.Model.CodeableConcept)current.Code).DeserializeJson(ref reader, options); break; case "severity": if (reader.TokenType == JsonTokenType.Null) { current.SeverityElement = new Code <Hl7.Fhir.Model.DetectedIssue.DetectedIssueSeverity>(); reader.Skip(); } else { current.SeverityElement = new Code <Hl7.Fhir.Model.DetectedIssue.DetectedIssueSeverity>(Hl7.Fhir.Utility.EnumUtility.ParseLiteral <Hl7.Fhir.Model.DetectedIssue.DetectedIssueSeverity>(reader.GetString())); } break; case "_severity": if (current.SeverityElement == null) { current.SeverityElement = new Code <Hl7.Fhir.Model.DetectedIssue.DetectedIssueSeverity>(); } ((Hl7.Fhir.Model.Element)current.SeverityElement).DeserializeJson(ref reader, options); break; case "patient": current.Patient = new Hl7.Fhir.Model.ResourceReference(); ((Hl7.Fhir.Model.ResourceReference)current.Patient).DeserializeJson(ref reader, options); break; case "identifiedDateTime": if (reader.TokenType == JsonTokenType.Null) { current.Identified = new FhirDateTime(); reader.Skip(); } else { current.Identified = new FhirDateTime(reader.GetString()); } break; case "_identifiedDateTime": if (current.Identified == null) { current.Identified = new FhirDateTime(); } ((Hl7.Fhir.Model.Element)current.Identified).DeserializeJson(ref reader, options); break; case "identifiedPeriod": current.Identified = new Hl7.Fhir.Model.Period(); ((Hl7.Fhir.Model.Period)current.Identified).DeserializeJson(ref reader, options); break; case "author": current.Author = new Hl7.Fhir.Model.ResourceReference(); ((Hl7.Fhir.Model.ResourceReference)current.Author).DeserializeJson(ref reader, options); break; case "implicated": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"DetectedIssue error reading 'implicated' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Implicated = new List <ResourceReference>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.ResourceReference v_Implicated = new Hl7.Fhir.Model.ResourceReference(); v_Implicated.DeserializeJson(ref reader, options); current.Implicated.Add(v_Implicated); if (!reader.Read()) { throw new JsonException($"DetectedIssue error reading 'implicated' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Implicated.Count == 0) { current.Implicated = null; } break; case "evidence": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"DetectedIssue error reading 'evidence' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Evidence = new List <DetectedIssue.EvidenceComponent>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.DetectedIssue.EvidenceComponent v_Evidence = new Hl7.Fhir.Model.DetectedIssue.EvidenceComponent(); v_Evidence.DeserializeJson(ref reader, options); current.Evidence.Add(v_Evidence); if (!reader.Read()) { throw new JsonException($"DetectedIssue error reading 'evidence' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Evidence.Count == 0) { current.Evidence = null; } break; case "detail": if (reader.TokenType == JsonTokenType.Null) { current.DetailElement = new FhirString(); reader.Skip(); } else { current.DetailElement = new FhirString(reader.GetString()); } break; case "_detail": if (current.DetailElement == null) { current.DetailElement = new FhirString(); } ((Hl7.Fhir.Model.Element)current.DetailElement).DeserializeJson(ref reader, options); break; case "reference": if (reader.TokenType == JsonTokenType.Null) { current.ReferenceElement = new FhirUri(); reader.Skip(); } else { current.ReferenceElement = new FhirUri(reader.GetString()); } break; case "_reference": if (current.ReferenceElement == null) { current.ReferenceElement = new FhirUri(); } ((Hl7.Fhir.Model.Element)current.ReferenceElement).DeserializeJson(ref reader, options); break; case "mitigation": if ((reader.TokenType != JsonTokenType.StartArray) || (!reader.Read())) { throw new JsonException($"DetectedIssue error reading 'mitigation' expected StartArray, found {reader.TokenType}! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } current.Mitigation = new List <DetectedIssue.MitigationComponent>(); while (reader.TokenType != JsonTokenType.EndArray) { Hl7.Fhir.Model.DetectedIssue.MitigationComponent v_Mitigation = new Hl7.Fhir.Model.DetectedIssue.MitigationComponent(); v_Mitigation.DeserializeJson(ref reader, options); current.Mitigation.Add(v_Mitigation); if (!reader.Read()) { throw new JsonException($"DetectedIssue error reading 'mitigation' array, read failed! depth: {reader.CurrentDepth}, pos: {reader.BytesConsumed}"); } if (reader.TokenType == JsonTokenType.EndObject) { reader.Read(); } } if (current.Mitigation.Count == 0) { current.Mitigation = null; } break; // Complex: DetectedIssue, Export: DetectedIssue, Base: DomainResource default: ((Hl7.Fhir.Model.DomainResource)current).DeserializeJsonProperty(ref reader, options, propertyName); break; } }
/// <summary> /// Creates a new instance of an IssueException with the specified issue /// </summary> public IssueException(DetectedIssue issue) { this.Issue = issue; }
/// <summary> /// Detected issue exception /// </summary> public DetectedIssueException(DetectedIssue issue, Exception cause) : this(new List <DetectedIssue>() { issue }, cause) { }
/// <summary> /// Detected issue exception /// </summary> public DetectedIssueException(DetectedIssue issue) : this(new List <DetectedIssue>() { issue }) { }
public DetectedIssueResultDetail(ResultDetailType type, string message, Exception exception, DetectedIssue issue) : base(type, message, exception) { this.Issue = issue; }
public DetectedIssueResultDetail(string message, DetectedIssue issue) : this(ResultDetailType.Error, message, (Exception)null, issue) { }