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/12/01 14:56:12 UTC
[plc4x] branch develop updated: fix(plc4go): updated PlcValueAdapter to panic instead of returning 0, updated PlcBYTE to allow returning of uint 8
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 cfdf58a fix(plc4go): updated PlcValueAdapter to panic instead of returning 0, updated PlcBYTE to allow returning of uint 8
cfdf58a is described below
commit cfdf58a3087141dbfdcc079e824409ab17b1f558
Author: cdutz <ch...@c-ware.de>
AuthorDate: Wed Dec 1 15:53:48 2021 +0100
fix(plc4go): updated PlcValueAdapter to panic instead of returning 0, updated PlcBYTE to allow returning of uint 8
---
plc4go/internal/plc4go/knxnetip/Browser.go | 10 +--
plc4go/internal/plc4go/spi/values/BYTE.go | 19 ++++-
.../internal/plc4go/spi/values/PlcValueAdapter.go | 90 +++++++++++++++-------
3 files changed, 85 insertions(+), 34 deletions(-)
diff --git a/plc4go/internal/plc4go/knxnetip/Browser.go b/plc4go/internal/plc4go/knxnetip/Browser.go
index 7479051..4e88c2e 100644
--- a/plc4go/internal/plc4go/knxnetip/Browser.go
+++ b/plc4go/internal/plc4go/knxnetip/Browser.go
@@ -248,10 +248,10 @@ func (m Browser) executeCommunicationObjectQuery(field CommunicationObjectQueryF
}
// Read the data in the group address table
- readRequestBuilder = m.connection.ReadRequestBuilder()
- readRequestBuilder.AddQuery("groupAddressTable",
- fmt.Sprintf("%s#%X:UINT[%d]", knxAddressString, groupAddressTableStartAddress, numGroupAddresses))
- readRequest, err = readRequestBuilder.Build()
+ readRequest, err = m.connection.ReadRequestBuilder().
+ AddQuery("groupAddressTable",
+ fmt.Sprintf("%s#%X:UINT[%d]", knxAddressString, groupAddressTableStartAddress, numGroupAddresses)).
+ Build()
if err != nil {
return nil, errors.Wrap(err, "error creating read request")
}
@@ -439,7 +439,7 @@ func (m Browser) executeCommunicationObjectQuery(field CommunicationObjectQueryF
}
} else if (m.connection.DeviceConnections[*knxAddress].deviceDescriptor & 0xFFF0) == uint16(0x0700) /* System7 */ {
// For System 7 Devices we unfortunately can't access the information of where the memory address for the
- // Com Object Table is programmatically, so we have to lookup the address which is extracted from the XML data
+ // Com Object Table is programmatically, so we have to look up the address which is extracted from the XML data
// Provided by the manufacturer. Unfortunately in order to be able to do this, we need to get the application
// version from the device first.
diff --git a/plc4go/internal/plc4go/spi/values/BYTE.go b/plc4go/internal/plc4go/spi/values/BYTE.go
index 9e7165c..5ef6ce0 100644
--- a/plc4go/internal/plc4go/spi/values/BYTE.go
+++ b/plc4go/internal/plc4go/spi/values/BYTE.go
@@ -24,11 +24,11 @@ import (
)
type PlcBYTE struct {
- value uint8
+ value byte
PlcSimpleValueAdapter
}
-func NewPlcBYTE(value uint8) PlcBYTE {
+func NewPlcBYTE(value byte) PlcBYTE {
return PlcBYTE{
value: value,
}
@@ -60,6 +60,21 @@ func (m PlcBYTE) GetBoolArray() []bool {
m.value>>6&1 == 1, m.value>>7&1 == 1}
}
+func (m PlcBYTE) IsByte() bool {
+ return true
+}
+
+func (m PlcBYTE) GetByte() byte {
+ return m.value
+}
+
+func (m PlcBYTE) IsUint8() bool {
+ return true
+}
+func (m PlcBYTE) GetUint8() uint8 {
+ return m.value
+}
+
func (m PlcBYTE) IsString() bool {
return true
}
diff --git a/plc4go/internal/plc4go/spi/values/PlcValueAdapter.go b/plc4go/internal/plc4go/spi/values/PlcValueAdapter.go
index b78c77a..9a7ada7 100644
--- a/plc4go/internal/plc4go/spi/values/PlcValueAdapter.go
+++ b/plc4go/internal/plc4go/spi/values/PlcValueAdapter.go
@@ -24,11 +24,15 @@ import (
"time"
)
-// Dummy structure
+// PlcValueAdapter Dummy structure
type PlcValueAdapter struct {
}
+////////
+////
// Simple Types
+//
+
func (m PlcValueAdapter) IsSimple() bool {
return false
}
@@ -39,7 +43,11 @@ func (m PlcValueAdapter) IsNull() bool {
return false
}
+////////
+////
// Boolean
+//
+
func (m PlcValueAdapter) IsBool() bool {
return false
}
@@ -67,136 +75,164 @@ func (m PlcValueAdapter) GetByte() byte {
return m.GetUint8()
}
+////////
+////
// Integer
+//
+
func (m PlcValueAdapter) IsUint8() bool {
return false
}
func (m PlcValueAdapter) GetUint8() uint8 {
- return 0
+ panic("GetUint8 not implemented")
}
func (m PlcValueAdapter) IsUint16() bool {
return false
}
func (m PlcValueAdapter) GetUint16() uint16 {
- return 0
+ panic("GetUint16 not implemented")
}
func (m PlcValueAdapter) IsUint32() bool {
return false
}
func (m PlcValueAdapter) GetUint32() uint32 {
- return 0
+ panic("GetUint32 not implemented")
}
func (m PlcValueAdapter) IsUint64() bool {
return false
}
func (m PlcValueAdapter) GetUint64() uint64 {
- return 0
+ panic("GetUint64 not implemented")
}
func (m PlcValueAdapter) IsInt8() bool {
return false
}
func (m PlcValueAdapter) GetInt8() int8 {
- return 0
+ panic("GetInt8 not implemented")
}
func (m PlcValueAdapter) IsInt16() bool {
return false
}
func (m PlcValueAdapter) GetInt16() int16 {
- return 0
+ panic("GetInt16 not implemented")
}
func (m PlcValueAdapter) IsInt32() bool {
return false
}
func (m PlcValueAdapter) GetInt32() int32 {
- return 0
+ panic("GetInt32 not implemented")
}
func (m PlcValueAdapter) IsInt64() bool {
return false
}
func (m PlcValueAdapter) GetInt64() int64 {
- return 0
+ panic("GetInt64 not implemented")
}
+////////
+////
// Floating Point
+//
+
func (m PlcValueAdapter) IsFloat32() bool {
return false
}
func (m PlcValueAdapter) GetFloat32() float32 {
- return 0.0
+ panic("GetFloat32 not implemented")
}
func (m PlcValueAdapter) IsFloat64() bool {
return false
}
func (m PlcValueAdapter) GetFloat64() float64 {
- return 0.0
+ panic("GetFloat64 not implemented")
}
+////////
+////
// String
+//
+
func (m PlcValueAdapter) IsString() bool {
return false
}
func (m PlcValueAdapter) GetString() string {
- return ""
+ panic("GetString not implemented")
}
+////////
+////
// Time
+//
+
func (m PlcValueAdapter) IsTime() bool {
return false
}
func (m PlcValueAdapter) GetTime() time.Time {
- return time.Time{}
+ panic("GetTime not implemented")
}
func (m PlcValueAdapter) IsDuration() bool {
return false
}
func (m PlcValueAdapter) GetDuration() time.Duration {
- return 0
+ panic("GetDuration not implemented")
}
-// Raw Access
+////////
+////
+// Raw access
+//
+
func (m PlcValueAdapter) GetRaw() []byte {
- return nil
+ panic("GetRaw not implemented")
}
+////////
+////
// List Methods
+//
+
func (m PlcValueAdapter) IsList() bool {
- return true
+ return false
}
func (m PlcValueAdapter) GetLength() uint32 {
- return 1
+ panic("GetLength not implemented")
}
func (m PlcValueAdapter) GetIndex(i uint32) api.PlcValue {
return nil
}
func (m PlcValueAdapter) GetList() []api.PlcValue {
- return []api.PlcValue{}
+ panic("GetList not implemented")
}
+////////
+////
// Struct Methods
+//
+
func (m PlcValueAdapter) IsStruct() bool {
return false
}
func (m PlcValueAdapter) GetKeys() []string {
- return []string{}
+ panic("GetKeys not implemented")
}
-func (m PlcValueAdapter) HasKey(key string) bool {
+func (m PlcValueAdapter) HasKey(_ string) bool {
return false
}
-func (m PlcValueAdapter) GetValue(key string) api.PlcValue {
- return nil
+func (m PlcValueAdapter) GetValue(_ string) api.PlcValue {
+ panic("GetValue not implemented")
}
func (m PlcValueAdapter) GetStruct() map[string]api.PlcValue {
- return nil
+ panic("GetStruct not implemented")
}
func (m PlcValueAdapter) IsDate() bool {
- return false
+ panic("IsDate not implemented")
}
func (m PlcValueAdapter) GetDate() time.Time {
- return time.Time{}
+ panic("GetDate not implemented")
}
func (m PlcValueAdapter) IsDateTime() bool {
return false
}
func (m PlcValueAdapter) GetDateTime() time.Time {
- return time.Time{}
+ panic("GetDateTime not implemented")
}