You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@plc4x.apache.org by cd...@apache.org on 2021/03/04 12:02:11 UTC
[plc4x] branch develop updated: - Added a RawReset function to the
RawPlcValue to allow multiple parser runs of the same raw value.
This is an automated email from the ASF dual-hosted git repository.
cdutz pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/plc4x.git
The following commit(s) were added to refs/heads/develop by this push:
new ac37371 - Added a RawReset function to the RawPlcValue to allow multiple parser runs of the same raw value.
ac37371 is described below
commit ac373715d7b7942a6617163ad5f903a213852a00
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Thu Mar 4 13:00:44 2021 +0100
- Added a RawReset function to the RawPlcValue to allow multiple parser runs of the same raw value.
---
plc4go/internal/plc4go/spi/values/RawPlcValue.go | 4 ++++
plc4go/pkg/plc4go/values/plc_value.go | 4 ++++
2 files changed, 8 insertions(+)
diff --git a/plc4go/internal/plc4go/spi/values/RawPlcValue.go b/plc4go/internal/plc4go/spi/values/RawPlcValue.go
index b825736..5afb471 100644
--- a/plc4go/internal/plc4go/spi/values/RawPlcValue.go
+++ b/plc4go/internal/plc4go/spi/values/RawPlcValue.go
@@ -73,6 +73,10 @@ func (m RawPlcValue) RawHasMore() bool {
return m.readBuffer.HasMore(1)
}
+func (m RawPlcValue) RawReset() {
+ m.readBuffer.Reset()
+}
+
func (m RawPlcValue) MarshalXML(e *xml.Encoder, start xml.StartElement) error {
if err := e.EncodeToken(xml.StartElement{Name: xml.Name{Local: "PlcByteArray"}}); err != nil {
return err
diff --git a/plc4go/pkg/plc4go/values/plc_value.go b/plc4go/pkg/plc4go/values/plc_value.go
index 97f774d..d741909 100644
--- a/plc4go/pkg/plc4go/values/plc_value.go
+++ b/plc4go/pkg/plc4go/values/plc_value.go
@@ -92,8 +92,12 @@ type PlcValue interface {
the payload yet. This allows an application to take the raw plc-value and have the payload decoded later.
*/
type RawPlcValue interface {
+ // Read the internal buffer and parse a value of given type
RawDecodeValue(typeName string) PlcValue
+ // If the internal read-buffer has not yet reached the end
RawHasMore() bool
+ // Reset the internal read-buffer (For the case that a raw plc-value has to be parsed multiple times)
+ RawReset()
PlcValue
}