diff --git a/Lawo.EmberPlusSharp/Model/ElementWithSchemas.cs b/Lawo.EmberPlusSharp/Model/ElementWithSchemas.cs index 627b9e67..152d387a 100644 --- a/Lawo.EmberPlusSharp/Model/ElementWithSchemas.cs +++ b/Lawo.EmberPlusSharp/Model/ElementWithSchemas.cs @@ -63,8 +63,8 @@ internal ElementWithSchemas(RequestState onlineRequestState) /// Gets or sets the request state. /// This property (along with its backing fields) has nothing to do with schemas. However, it so - /// happens that all subclasses (parameters and nodes) need this member. If this fact ever changes, it probably - /// makes sense to move this member to its own base class (named e.g. RequestedElement). + /// happens that all subclasses (parameters, nodes and matrices) need this member. If this fact ever changes, it + /// probably makes sense to move this member to its own base class (named e.g. RequestedElement). internal RequestState RequestState { get @@ -95,6 +95,17 @@ internal sealed override void SetRequestState(bool isEmpty, ref RequestState new this.RequestState = newRequestState; } + internal override RequestState UpdateRequestState(bool throwForMissingRequiredChildren) + { + if (!this.IsOnline || (this.RequestState.Equals(RequestState.Complete) && + this.AreRequiredChildrenAvailable(throwForMissingRequiredChildren))) + { + this.RequestState = base.UpdateRequestState(throwForMissingRequiredChildren); + } + + return this.RequestState; + } + internal override void SetComplete() { this.RequestState = RequestState.Complete; diff --git a/Lawo.EmberPlusSharp/Model/NodeBase.cs b/Lawo.EmberPlusSharp/Model/NodeBase.cs index 729d3624..2eb26926 100644 --- a/Lawo.EmberPlusSharp/Model/NodeBase.cs +++ b/Lawo.EmberPlusSharp/Model/NodeBase.cs @@ -171,17 +171,9 @@ internal sealed override RequestState ReadQualifiedChild( internal sealed override RequestState UpdateRequestState(bool throwForMissingRequiredChildren) { - if (!this.IsOnline) + if (!this.IsOnline || (this.children.Count == 0)) { - this.RequestState = RequestState.Verified; - } - else if (this.children.Count == 0) - { - if (this.RequestState.Equals(RequestState.Complete) && - this.AreRequiredChildrenAvailable(throwForMissingRequiredChildren)) - { - this.RequestState = RequestState.Verified; - } + return base.UpdateRequestState(throwForMissingRequiredChildren); } else { @@ -207,9 +199,9 @@ internal sealed override RequestState UpdateRequestState(bool throwForMissingReq this.RequestState = this.GetRequestState(throwForMissingRequiredChildren, accumulatedChildRequestState); } - } - return this.RequestState; + return this.RequestState; + } } internal override bool WriteRequest(EmberWriter writer) diff --git a/Lawo.EmberPlusSharp/Model/ParameterBase.cs b/Lawo.EmberPlusSharp/Model/ParameterBase.cs index 53479baa..c0e814b0 100644 --- a/Lawo.EmberPlusSharp/Model/ParameterBase.cs +++ b/Lawo.EmberPlusSharp/Model/ParameterBase.cs @@ -64,8 +64,18 @@ public ParameterType Type /// public int? StreamIdentifier { - get { return this.streamIdentifier; } - private set { this.SetValue(ref this.streamIdentifier, value); } + get + { + return this.streamIdentifier; + } + + private set + { + if (this.SetValue(ref this.streamIdentifier, value) && value.HasValue && this.IsOnline) + { + this.RequestState = RequestState.None; + } + } } /// @@ -220,6 +230,23 @@ internal virtual TValue AssertValueType(object value) } } + internal sealed override bool WriteRequest(EmberWriter writer) + { + if (this.RequestState.Equals(RequestState.None)) + { + writer.WriteStartApplicationDefinedType( + GlowElementCollection.Element.OuterId, GlowQualifiedParameter.InnerNumber); + writer.WriteValue(GlowQualifiedParameter.Path.OuterId, this.NumberPath); + writer.WriteStartApplicationDefinedType( + GlowQualifiedParameter.Children.OuterId, GlowElementCollection.InnerNumber); + this.WriteCommandCollection(writer, GlowCommandNumber.Subscribe, RequestState.Complete); + writer.WriteEndContainer(); + writer.WriteEndContainer(); + } + + return false; + } + internal override RequestState ReadContents(EmberReader reader, ElementType actualType) { this.AssertElementType(ElementType.Parameter, actualType); @@ -265,6 +292,10 @@ internal override RequestState ReadContents(EmberReader reader, ElementType actu break; case GlowParameterContents.IsOnline.OuterNumber: this.IsOnline = reader.AssertAndReadContentsAsBoolean(); + var send = (this.IsOnlineChangeStatus == IsOnlineChangeStatus.Changed) && + this.IsOnline && this.StreamIdentifier.HasValue; + var newRequestState = this.RequestState & (send ? RequestState.None : RequestState.Complete); + this.SetRequestState(false, ref newRequestState); break; case GlowParameterContents.Formula.OuterNumber: this.FormulaCore = reader.AssertAndReadContentsAsString(); diff --git a/Lawo.EmberPlusSharpTest/Model/Test/EmberDataPayloads/MainLog.xml b/Lawo.EmberPlusSharpTest/Model/Test/EmberDataPayloads/MainLog.xml index ff5a9ce6..9ae561e6 100644 --- a/Lawo.EmberPlusSharpTest/Model/Test/EmberDataPayloads/MainLog.xml +++ b/Lawo.EmberPlusSharpTest/Model/Test/EmberDataPayloads/MainLog.xml @@ -286,6 +286,78 @@ Three EmberData 01 0A 02 + + 1 + + + 30 + + + + + 2 + + + 30 + + + + + 3 + + + 30 + + + + + 4 + + + 30 + + + + + 5 + + + 30 + + + + + 6 + + + 30 + + + + + 7 + + + 30 + + + + + 8 + + + 30 + + + + + 9 + + + 30 + + + 10 diff --git a/Lawo.EmberPlusSharpTest/Model/Test/EmberDataPayloads/MainRequest2.xml b/Lawo.EmberPlusSharpTest/Model/Test/EmberDataPayloads/MainRequest2.xml index f8ca1494..eb05317e 100644 --- a/Lawo.EmberPlusSharpTest/Model/Test/EmberDataPayloads/MainRequest2.xml +++ b/Lawo.EmberPlusSharpTest/Model/Test/EmberDataPayloads/MainRequest2.xml @@ -2,6 +2,78 @@ + + 1 + + + 30 + + + + + 2 + + + 30 + + + + + 3 + + + 30 + + + + + 4 + + + 30 + + + + + 5 + + + 30 + + + + + 6 + + + 30 + + + + + 7 + + + 30 + + + + + 8 + + + 30 + + + + + 9 + + + 30 + + + 10