cantabile_edge, cantabile_modbus, cantabile_eebus 0.1.2148: EEBUS bridge 0.1.2 (connection and grid-limit fixes); full source
This commit is contained in:
1 parent
b3dfc9bb68
commit
87e4a42274
387 files changed
+66823
-127
No files matched your search
+108
@@ -0,0 +1,108 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/enbility/ship-go/logging"
|
||||
|
||||
shipapi "github.com/enbility/ship-go/api"
|
||||
spineapi "github.com/enbility/spine-go/api"
|
||||
)
|
||||
|
||||
//go:generate mockery
|
||||
|
||||
/* Service */
|
||||
|
||||
// central service interface
|
||||
//
|
||||
// implemented by service, used by the eebus service implementation
|
||||
type ServiceInterface interface {
|
||||
// setup the service
|
||||
Setup() error
|
||||
|
||||
// start the service
|
||||
Start()
|
||||
|
||||
// shutdown the service
|
||||
Shutdown()
|
||||
|
||||
// add a use case to the service
|
||||
AddUseCase(useCase UseCaseInterface)
|
||||
|
||||
// set logging interface
|
||||
SetLogging(logger logging.LoggingInterface)
|
||||
|
||||
// return the configuration
|
||||
Configuration() *Configuration
|
||||
|
||||
// return the local service details
|
||||
LocalService() *shipapi.ServiceDetails
|
||||
|
||||
// return the local device
|
||||
LocalDevice() spineapi.DeviceLocalInterface
|
||||
|
||||
// Passthough functions to HubInterface
|
||||
|
||||
// Provide the current pairing state for a SKI
|
||||
PairingDetailForSki(ski string) *shipapi.ConnectionStateDetail
|
||||
|
||||
// Defines wether incoming pairing requests should be automatically accepted or not
|
||||
//
|
||||
// Default: false
|
||||
SetAutoAccept(value bool)
|
||||
|
||||
// Returns if the service has auto accept enabled or not
|
||||
IsAutoAcceptEnabled() bool
|
||||
|
||||
// Returns the Service detail of a remote SKI
|
||||
RemoteServiceForSKI(ski string) *shipapi.ServiceDetails
|
||||
|
||||
// Sets the SKI as being paired
|
||||
RegisterRemoteSKI(ski string)
|
||||
|
||||
// Sets the SKI as not being paired
|
||||
UnregisterRemoteSKI(ski string)
|
||||
|
||||
// Disconnect from a connected remote SKI
|
||||
DisconnectSKI(ski string, reason string)
|
||||
|
||||
// Cancels the pairing process for a SKI
|
||||
//
|
||||
// This should be called while the service is running and the end
|
||||
// user wants to cancel/disallow an incoming pairing request
|
||||
CancelPairingWithSKI(ski string)
|
||||
|
||||
// Define wether the user is able to react to an incoming pairing request
|
||||
//
|
||||
// Call this with `true` e.g. if the user is currently using a web interface
|
||||
// where an incoming request can be accepted or denied
|
||||
//
|
||||
// Default is set to false, meaning every incoming pairing request will be
|
||||
// automatically denied
|
||||
UserIsAbleToApproveOrCancelPairingRequests(allow bool)
|
||||
}
|
||||
|
||||
// interface for receiving data for specific events from Service
|
||||
//
|
||||
// some are passthrough readers, because service needs to coordinate
|
||||
// everything with SPINE
|
||||
//
|
||||
// implemented by the eebus service implementation, used by service
|
||||
type ServiceReaderInterface interface {
|
||||
// report a connection to a SKI
|
||||
RemoteSKIConnected(service ServiceInterface, ski string)
|
||||
|
||||
// report a disconnection to a SKI
|
||||
RemoteSKIDisconnected(service ServiceInterface, ski string)
|
||||
|
||||
// report all currently visible EEBUS services
|
||||
VisibleRemoteServicesUpdated(service ServiceInterface, entries []shipapi.RemoteService)
|
||||
|
||||
// Provides the SHIP ID the remote service reported during the handshake process
|
||||
// This needs to be persisted and passed on for future remote service connections
|
||||
// when using `PairRemoteService`
|
||||
ServiceShipIDUpdate(ski string, shipdID string)
|
||||
|
||||
// Provides the current pairing state for the remote service
|
||||
// This is called whenever the state changes and can be used to
|
||||
// provide user information for the pairing/connection process
|
||||
ServicePairingDetailUpdate(ski string, detail *shipapi.ConnectionStateDetail)
|
||||
}
|
||||
@@ -0,0 +1,241 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/enbility/ship-go/mdns"
|
||||
"github.com/enbility/spine-go/model"
|
||||
)
|
||||
|
||||
const defaultPort int = 4711
|
||||
|
||||
// defines requires meta information about this service
|
||||
type Configuration struct {
|
||||
// The vendors IANA PEN, optional but highly recommended.
|
||||
// If not set, brand will be used instead
|
||||
// Used for the Device Address: SPINE - Protocol Specification 7.1.1.2
|
||||
vendorCode string
|
||||
|
||||
// The deviceBrand of the device, required
|
||||
// Used for the Device Address: SPINE - Protocol Specification 7.1.1.2
|
||||
// Used for mDNS txt record: SHIP - Specification 7.3.2
|
||||
deviceBrand string
|
||||
|
||||
// The device model, required
|
||||
// Used for the Device Address: SPINE - Protocol Specification 7.1.1.2
|
||||
// Used for mDNS txt record: SHIP - Specification 7.3.2
|
||||
deviceModel string
|
||||
|
||||
// Serial number of the device, required
|
||||
// Used for the Device Address: SPINE - Protocol Specification 7.1.1.2
|
||||
deviceSerialNumber string
|
||||
|
||||
// An alternate mDNS service identifier
|
||||
// Optional, if not set will be generated using "Brand-Model-SerialNumber"
|
||||
// Used for mDNS service and SHIP identifier: SHIP - Specification 7.2
|
||||
alternateIdentifier string
|
||||
|
||||
// An alternate mDNS service name
|
||||
// Optional, if not set will be identical to alternateIdentifier or generated using "Brand-Model-SerialNumber"
|
||||
alternateMdnsServiceName string
|
||||
|
||||
// SPINE device type of the device model, required
|
||||
// Used for SPINE device type
|
||||
// Used for mDNS txt record: SHIP - Specification 7.3.2
|
||||
deviceType model.DeviceTypeType
|
||||
|
||||
// SPINE device network feature set type, optional
|
||||
// SPINE Protocol Specification 6
|
||||
featureSet model.NetworkManagementFeatureSetType
|
||||
|
||||
// SPINE entity types for each entity that should be created
|
||||
// Each entity has to have a different type!
|
||||
entityTypes []model.EntityTypeType
|
||||
|
||||
// Network interface to use for the service
|
||||
// Optional, if not set all detected interfaces will be used
|
||||
interfaces []string
|
||||
|
||||
// The port address of the websocket server, required
|
||||
port int
|
||||
|
||||
// The certificate used for the service and its connections, required
|
||||
certificate tls.Certificate
|
||||
|
||||
// The timeout to be used for sending heartbeats and applied to all
|
||||
// local entities created on setup the service
|
||||
heartbeatTimeout time.Duration
|
||||
|
||||
// Optional set which mDNS providers should be used
|
||||
mdnsProviderSelection mdns.MdnsProviderSelection
|
||||
}
|
||||
|
||||
// Setup a Configuration with the required parameters
|
||||
func NewConfiguration(
|
||||
vendorCode,
|
||||
deviceBrand,
|
||||
deviceModel,
|
||||
serialNumber string,
|
||||
deviceType model.DeviceTypeType,
|
||||
entityTypes []model.EntityTypeType,
|
||||
port int,
|
||||
certificate tls.Certificate,
|
||||
heartbeatTimeout time.Duration,
|
||||
) (*Configuration, error) {
|
||||
configuration := &Configuration{
|
||||
certificate: certificate,
|
||||
port: port,
|
||||
heartbeatTimeout: heartbeatTimeout,
|
||||
mdnsProviderSelection: mdns.MdnsProviderSelectionAll,
|
||||
}
|
||||
|
||||
if port == 0 {
|
||||
configuration.port = defaultPort
|
||||
}
|
||||
|
||||
isRequired := "is required"
|
||||
|
||||
if len(vendorCode) == 0 {
|
||||
return nil, fmt.Errorf("vendorCode %s", isRequired)
|
||||
}
|
||||
configuration.vendorCode = vendorCode
|
||||
|
||||
if len(deviceBrand) == 0 {
|
||||
return nil, fmt.Errorf("brand %s", isRequired)
|
||||
}
|
||||
configuration.deviceBrand = deviceBrand
|
||||
|
||||
if len(deviceModel) == 0 {
|
||||
return nil, fmt.Errorf("model %s", isRequired)
|
||||
}
|
||||
configuration.deviceModel = deviceModel
|
||||
|
||||
if len(serialNumber) == 0 {
|
||||
return nil, fmt.Errorf("serialNumber %s", isRequired)
|
||||
}
|
||||
configuration.deviceSerialNumber = serialNumber
|
||||
|
||||
if len(deviceType) == 0 {
|
||||
return nil, fmt.Errorf("deviceType %s", isRequired)
|
||||
}
|
||||
configuration.deviceType = deviceType
|
||||
|
||||
if len(entityTypes) == 0 {
|
||||
return nil, fmt.Errorf("entityTypes %s", isRequired)
|
||||
}
|
||||
configuration.entityTypes = entityTypes
|
||||
|
||||
// set default
|
||||
configuration.featureSet = model.NetworkManagementFeatureSetTypeSmart
|
||||
|
||||
return configuration, nil
|
||||
}
|
||||
|
||||
func (s *Configuration) VendorCode() string {
|
||||
return s.vendorCode
|
||||
}
|
||||
|
||||
func (s *Configuration) DeviceBrand() string {
|
||||
return s.deviceBrand
|
||||
}
|
||||
|
||||
func (s *Configuration) DeviceModel() string {
|
||||
return s.deviceModel
|
||||
}
|
||||
|
||||
func (s *Configuration) DeviceSerialNumber() string {
|
||||
return s.deviceSerialNumber
|
||||
}
|
||||
|
||||
// define an alternative mDNS and SHIP identifier
|
||||
// usually this is only used when no deviceCode is available or identical to the brand
|
||||
// if this is not set, generated identifier is used
|
||||
func (s *Configuration) SetAlternateIdentifier(identifier string) {
|
||||
s.alternateIdentifier = identifier
|
||||
}
|
||||
|
||||
// define an alternative mDNS service name
|
||||
// this is normally not needed or used
|
||||
func (s *Configuration) SetAlternateMdnsServiceName(name string) {
|
||||
s.alternateMdnsServiceName = name
|
||||
}
|
||||
|
||||
func (s *Configuration) SetMdnsProviderSelection(providerSelection mdns.MdnsProviderSelection) {
|
||||
s.mdnsProviderSelection = providerSelection
|
||||
}
|
||||
|
||||
func (s *Configuration) MdnsProviderSelection() mdns.MdnsProviderSelection {
|
||||
return s.mdnsProviderSelection
|
||||
}
|
||||
|
||||
func (s *Configuration) DeviceType() model.DeviceTypeType {
|
||||
return s.deviceType
|
||||
}
|
||||
|
||||
func (s *Configuration) FeatureSet() model.NetworkManagementFeatureSetType {
|
||||
return s.featureSet
|
||||
}
|
||||
|
||||
func (s *Configuration) EntityTypes() []model.EntityTypeType {
|
||||
return s.entityTypes
|
||||
}
|
||||
|
||||
func (s *Configuration) Interfaces() []string {
|
||||
return s.interfaces
|
||||
}
|
||||
|
||||
// define which network interfaces should be considered instead of all existing
|
||||
// expects a list of network interface names
|
||||
func (s *Configuration) SetInterfaces(ifaces []string) {
|
||||
s.interfaces = ifaces
|
||||
}
|
||||
|
||||
// generates a standard identifier used for mDNS ID and SHIP ID
|
||||
// Brand-Model-SerialNumber
|
||||
func (s *Configuration) generateIdentifier() string {
|
||||
return fmt.Sprintf("%s-%s-%s", s.deviceBrand, s.deviceModel, s.deviceSerialNumber)
|
||||
}
|
||||
|
||||
// return the identifier to be used for mDNS and SHIP ID
|
||||
// returns in this order:
|
||||
// - alternateIdentifier
|
||||
// - generateIdentifier
|
||||
func (s *Configuration) Identifier() string {
|
||||
// SHIP identifier is identical to the mDNS ID
|
||||
if len(s.alternateIdentifier) > 0 {
|
||||
return s.alternateIdentifier
|
||||
}
|
||||
|
||||
return s.generateIdentifier()
|
||||
}
|
||||
|
||||
// return the name to be used as the mDNS service name
|
||||
// returns in this order:
|
||||
// - alternateMdnsServiceName
|
||||
// - generateIdentifier
|
||||
func (s *Configuration) MdnsServiceName() string {
|
||||
// SHIP identifier is identical to the mDNS ID
|
||||
if len(s.alternateMdnsServiceName) > 0 {
|
||||
return s.alternateMdnsServiceName
|
||||
}
|
||||
|
||||
return s.generateIdentifier()
|
||||
}
|
||||
|
||||
func (s *Configuration) Certificate() tls.Certificate {
|
||||
return s.certificate
|
||||
}
|
||||
|
||||
func (s *Configuration) Port() int {
|
||||
return s.port
|
||||
}
|
||||
|
||||
func (s *Configuration) SetCertificate(cert tls.Certificate) {
|
||||
s.certificate = cert
|
||||
}
|
||||
|
||||
func (s *Configuration) HeartbeatTimeout() time.Duration {
|
||||
return s.heartbeatTimeout
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package api
|
||||
|
||||
import "errors"
|
||||
|
||||
// ErrMetadataNotAvailable indicates that the meta data information is not available
|
||||
// e.g. decsriptions, constraints, ...
|
||||
var ErrMetadataNotAvailable = errors.New("meta data not available")
|
||||
|
||||
// ErrDataNotAvailable indicates that no data set is yet available
|
||||
var ErrDataNotAvailable = errors.New("data not available")
|
||||
|
||||
// ErrDataForMetadataKeyNotFound indicates that no data item is found for the given key
|
||||
var ErrDataForMetadataKeyNotFound = errors.New("data for key not found")
|
||||
|
||||
var ErrNotSupported = errors.New("not supported")
|
||||
|
||||
var ErrEntityNotFound = errors.New("entity not found")
|
||||
|
||||
var ErrUsecCaseNotSupported = errors.New("usecase is not supported")
|
||||
|
||||
var ErrFunctionNotSupported = errors.New("function is not supported")
|
||||
|
||||
var ErrOperationOnFunctionNotSupported = errors.New("operation is not supported on function")
|
||||
|
||||
var ErrMissingData = errors.New("missing data")
|
||||
|
||||
var ErrDeviceDisconnected = errors.New("device is disconnected")
|
||||
|
||||
var ErrNoCompatibleEntity = errors.New("no compatible entity")
|
||||
@@ -0,0 +1,244 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/enbility/spine-go/api"
|
||||
"github.com/enbility/spine-go/model"
|
||||
)
|
||||
|
||||
// Feature client interface were the local feature role is client and the remote feature role is server
|
||||
type FeatureClientInterface interface {
|
||||
// check if there is a subscription to the remote feature
|
||||
HasSubscription() bool
|
||||
|
||||
// subscribe to the feature of the entity
|
||||
Subscribe() (*model.MsgCounterType, error)
|
||||
|
||||
// check if there is a binding to the remote feature
|
||||
HasBinding() bool
|
||||
|
||||
// bind to the feature of the entity
|
||||
Bind() (*model.MsgCounterType, error)
|
||||
|
||||
// add a callback function to be invoked once a result or reply message for a msgCounter came in
|
||||
AddResponseCallback(msgCounterReference model.MsgCounterType, function func(msg api.ResponseMessage)) error
|
||||
|
||||
// add a callback function to be invoked once a result came in
|
||||
AddResultCallback(function func(msg api.ResponseMessage))
|
||||
}
|
||||
|
||||
// Feature server interface were the local feature role is a server
|
||||
type FeatureServerInterface interface {
|
||||
}
|
||||
|
||||
// Common interface for DeviceClassificationClientInterface and DeviceClassificationServerInterface
|
||||
type DeviceClassificationCommonInterface interface {
|
||||
// get the current manufacturer details for a remote device entity
|
||||
GetManufacturerDetails() (*model.DeviceClassificationManufacturerDataType, error)
|
||||
}
|
||||
|
||||
// Common interface for DeviceConfigurationClientInterface and DeviceConfigurationServerInterface
|
||||
type DeviceConfigurationCommonInterface interface {
|
||||
// check if spine.EventPayload Data contains data for a given filter
|
||||
//
|
||||
// data type will be checked for model.DeviceConfigurationKeyValueListDataType,
|
||||
// filter type will be checked for model.DeviceConfigurationKeyValueDescriptionDataType
|
||||
CheckEventPayloadDataForFilter(payloadData any, filter any) bool
|
||||
|
||||
// Get the description for a given keyId
|
||||
//
|
||||
// Will return nil if no matching description was found
|
||||
GetKeyValueDescriptionFoKeyId(keyId model.DeviceConfigurationKeyIdType) (*model.DeviceConfigurationKeyValueDescriptionDataType, error)
|
||||
|
||||
// Get the description for a given value combination
|
||||
//
|
||||
// Returns an error if no matching description was found
|
||||
GetKeyValueDescriptionsForFilter(filter model.DeviceConfigurationKeyValueDescriptionDataType) ([]model.DeviceConfigurationKeyValueDescriptionDataType, error)
|
||||
|
||||
// Get the key value data for a given keyId
|
||||
//
|
||||
// Will return nil if no matching data was found
|
||||
GetKeyValueDataForKeyId(keyId model.DeviceConfigurationKeyIdType) (*model.DeviceConfigurationKeyValueDataType, error)
|
||||
|
||||
// Get key value data for a given filter
|
||||
//
|
||||
// Will return nil if no matching data was found
|
||||
GetKeyValueDataForFilter(filter model.DeviceConfigurationKeyValueDescriptionDataType) (*model.DeviceConfigurationKeyValueDataType, error)
|
||||
}
|
||||
|
||||
// Common interface for DeviceDiagnosisClientInterface and DeviceDiagnosisServerInterface
|
||||
type DeviceDiagnosisCommonInterface interface {
|
||||
// get the current diagnosis state for an device entity
|
||||
GetState() (*model.DeviceDiagnosisStateDataType, error)
|
||||
|
||||
// check if the currently available heartbeat data is within a time duration
|
||||
IsHeartbeatWithinDuration(duration time.Duration) bool
|
||||
}
|
||||
|
||||
// Common interface for ElectricalConnectionClientInterface and ElectricalConnectionServerInterface
|
||||
type ElectricalConnectionCommonInterface interface {
|
||||
// check if spine.EventPayload Data contains data for a given filter
|
||||
//
|
||||
// data type will be checked for model.ElectricalConnectionPermittedValueSetListDataType,
|
||||
// filter type will be checked for model.ElectricalConnectionParameterDescriptionDataType
|
||||
CheckEventPayloadDataForFilter(payloadData any, filter any) bool
|
||||
|
||||
// Get the description for a given filter
|
||||
//
|
||||
// Returns an error if no matching description is found
|
||||
GetDescriptionsForFilter(
|
||||
filter model.ElectricalConnectionDescriptionDataType,
|
||||
) ([]model.ElectricalConnectionDescriptionDataType, error)
|
||||
|
||||
// Get the description for a given parameter description
|
||||
//
|
||||
// Returns an error if no matching description is found
|
||||
GetDescriptionForParameterDescriptionFilter(
|
||||
filter model.ElectricalConnectionParameterDescriptionDataType) (
|
||||
*model.ElectricalConnectionDescriptionDataType, error)
|
||||
|
||||
// Get the description for a given filter
|
||||
//
|
||||
// Returns an error if no matching description is found
|
||||
GetParameterDescriptionsForFilter(
|
||||
filter model.ElectricalConnectionParameterDescriptionDataType,
|
||||
) ([]model.ElectricalConnectionParameterDescriptionDataType, error)
|
||||
|
||||
// return permitted values for all Electrical Connections
|
||||
GetPermittedValueSetForFilter(filter model.ElectricalConnectionPermittedValueSetDataType) (
|
||||
[]model.ElectricalConnectionPermittedValueSetDataType, error)
|
||||
|
||||
// returns minimum, maximum, default/pause limit values
|
||||
GetPermittedValueDataForFilter(filter model.ElectricalConnectionPermittedValueSetDataType) (
|
||||
float64, float64, float64, error)
|
||||
|
||||
// Get the min, max, default current limits for each phase
|
||||
GetPhaseCurrentLimits(measDesc []model.MeasurementDescriptionDataType) (
|
||||
resultMin []float64, resultMax []float64, resultDefault []float64, resultErr error)
|
||||
|
||||
// Adjust a value to be within the permitted value range
|
||||
AdjustValueToBeWithinPermittedValuesForParameterId(
|
||||
value float64, parameterId model.ElectricalConnectionParameterIdType) float64
|
||||
|
||||
// Get the characteristics for a given filter
|
||||
//
|
||||
// Returns an error if no matching description is found
|
||||
GetCharacteristicsForFilter(
|
||||
filter model.ElectricalConnectionCharacteristicDataType,
|
||||
) ([]model.ElectricalConnectionCharacteristicDataType, error)
|
||||
}
|
||||
|
||||
// Common interface for LoadControlClientInterface and LoadControlServerInterface
|
||||
type LoadControlCommonInterface interface {
|
||||
// check if spine.EventPayload Data contains data for a given filter
|
||||
//
|
||||
// data type will be checked for model.LoadControlLimitListDataType,
|
||||
// filter type will be checked for model.LoadControlLimitDescriptionDataType
|
||||
CheckEventPayloadDataForFilter(payloadData any, filter any) bool
|
||||
|
||||
// Get the description for a given limitId
|
||||
//
|
||||
// Will return nil if no matching description is found
|
||||
GetLimitDescriptionForId(limitId model.LoadControlLimitIdType) (
|
||||
*model.LoadControlLimitDescriptionDataType, error)
|
||||
|
||||
// Get the description for a given filter
|
||||
//
|
||||
// Returns an error if no matching description is found
|
||||
GetLimitDescriptionsForFilter(
|
||||
filter model.LoadControlLimitDescriptionDataType,
|
||||
) ([]model.LoadControlLimitDescriptionDataType, error)
|
||||
|
||||
// Get the description for a given limitId
|
||||
//
|
||||
// Will return nil if no data is available
|
||||
GetLimitDataForId(limitId model.LoadControlLimitIdType) (*model.LoadControlLimitDataType, error)
|
||||
|
||||
// Get limit data for a given filter
|
||||
//
|
||||
// Will return nil if no data is available
|
||||
GetLimitDataForFilter(filter model.LoadControlLimitDescriptionDataType) ([]model.LoadControlLimitDataType, error)
|
||||
}
|
||||
|
||||
// Common interface for MeasurementClientInterface and MeasurementServerInterface
|
||||
type MeasurementCommonInterface interface {
|
||||
// check if spine.EventPayload Data contains data for a given filter
|
||||
//
|
||||
// data type will be checked for model.MeasurementListDataType,
|
||||
// filter type will be checked for model.MeasurementDescriptionDataType
|
||||
CheckEventPayloadDataForFilter(payloadData any, filter any) bool
|
||||
|
||||
// Get the description for a given id
|
||||
//
|
||||
// Returns an error if no matching description is found
|
||||
GetDescriptionForId(
|
||||
measurementId model.MeasurementIdType,
|
||||
) (*model.MeasurementDescriptionDataType, error)
|
||||
|
||||
// Get the description for a given filter
|
||||
//
|
||||
// Returns an error if no matching description is found
|
||||
GetDescriptionsForFilter(
|
||||
filter model.MeasurementDescriptionDataType,
|
||||
) ([]model.MeasurementDescriptionDataType, error)
|
||||
|
||||
// Get the constraints for a given filter
|
||||
//
|
||||
// Returns an error if no matching constraint is found
|
||||
GetConstraintsForFilter(
|
||||
filter model.MeasurementConstraintsDataType,
|
||||
) ([]model.MeasurementConstraintsDataType, error)
|
||||
|
||||
// Get the measuement data for a given measurementId
|
||||
//
|
||||
// Will return nil if no data is available
|
||||
GetDataForId(measurementId model.MeasurementIdType) (*model.MeasurementDataType, error)
|
||||
|
||||
// Get measuement data for a given filter
|
||||
//
|
||||
// Will return nil if no data is available
|
||||
GetDataForFilter(filter model.MeasurementDescriptionDataType) (
|
||||
[]model.MeasurementDataType, error)
|
||||
}
|
||||
|
||||
// Common interface for IdentificationClientInterface and IdentificationServerInterface
|
||||
type IdentificationCommonInterface interface {
|
||||
// check if spine.EventPayload Data contains identification data
|
||||
//
|
||||
// data type will be checked for model.IdentificationListDataType
|
||||
CheckEventPayloadDataForFilter(payloadData any) bool
|
||||
|
||||
// return current values for Identification
|
||||
GetDataForFilter(filter model.IdentificationDataType) ([]model.IdentificationDataType, error)
|
||||
}
|
||||
|
||||
// Common interface for IncentiveTableClientInterface and IncentiveTableServerInterface
|
||||
type IncentiveTableCommonInterface interface {
|
||||
// return list of descriptions for a given filter
|
||||
GetDescriptionsForFilter(filter model.TariffDescriptionDataType) ([]model.IncentiveTableDescriptionType, error)
|
||||
|
||||
// return list of constraints
|
||||
GetConstraints() ([]model.IncentiveTableConstraintsType, error)
|
||||
|
||||
// return current data for Time Series
|
||||
GetData() ([]model.IncentiveTableType, error)
|
||||
}
|
||||
|
||||
// Common interface for SmartEnergyManagementPsClientInterface and SmartEnergyManagementPsServerInterface
|
||||
type SmartEnergyManagementPsCommonInterface interface {
|
||||
// return current data for FunctionTypeSmartEnergyManagementPsData
|
||||
GetData() (*model.SmartEnergyManagementPsDataType, error)
|
||||
}
|
||||
|
||||
// Common interface for TimeSeriesClientInterface and TimeSeriesServerInterface
|
||||
type TimeSeriesCommonInterface interface {
|
||||
// return list of descriptions for a given filter
|
||||
GetDescriptionsForFilter(filter model.TimeSeriesDescriptionDataType) ([]model.TimeSeriesDescriptionDataType, error)
|
||||
|
||||
// return current constraints for Time Series
|
||||
GetConstraints() ([]model.TimeSeriesConstraintsDataType, error)
|
||||
|
||||
// return current data for Time Series for a given filter
|
||||
GetDataForFilter(filter model.TimeSeriesDescriptionDataType) ([]model.TimeSeriesDataType, error)
|
||||
}
|
||||
@@ -0,0 +1,167 @@
|
||||
package api
|
||||
|
||||
import "github.com/enbility/spine-go/model"
|
||||
|
||||
type DeviceClassificationClientInterface interface {
|
||||
// request DeviceClassificationManufacturerData from a remote device entity
|
||||
RequestManufacturerDetails() (*model.MsgCounterType, error)
|
||||
}
|
||||
|
||||
type DeviceConfigurationClientInterface interface {
|
||||
DeviceConfigurationCommonInterface
|
||||
|
||||
// request DeviceConfigurationKeyValueDescriptionDataType from a remote entity
|
||||
RequestKeyValueDescriptions(
|
||||
selector *model.DeviceConfigurationKeyValueDescriptionListDataSelectorsType,
|
||||
elements *model.DeviceConfigurationKeyValueDescriptionDataElementsType,
|
||||
) (*model.MsgCounterType, error)
|
||||
|
||||
// request DeviceConfigurationKeyValueListData from a remote entity
|
||||
RequestKeyValues(
|
||||
selector *model.DeviceConfigurationKeyValueListDataSelectorsType,
|
||||
elements *model.DeviceConfigurationKeyValueDataElementsType,
|
||||
) (*model.MsgCounterType, error)
|
||||
|
||||
// write key values
|
||||
// returns an error if this failed
|
||||
WriteKeyValues(data []model.DeviceConfigurationKeyValueDataType) (*model.MsgCounterType, error)
|
||||
}
|
||||
|
||||
type DeviceDiagnosisClientInterface interface {
|
||||
// request DeviceDiagnosisStateData from a remote entity
|
||||
RequestState() (*model.MsgCounterType, error)
|
||||
|
||||
// request FunctionTypeDeviceDiagnosisHeartbeatData from a remote device
|
||||
RequestHeartbeat() (*model.MsgCounterType, error)
|
||||
}
|
||||
|
||||
type ElectricalConnectionClientInterface interface {
|
||||
// request ElectricalConnectionDescriptionListDataType from a remote entity
|
||||
RequestDescriptions(
|
||||
selector *model.ElectricalConnectionDescriptionListDataSelectorsType,
|
||||
elements *model.ElectricalConnectionDescriptionDataElementsType,
|
||||
) (*model.MsgCounterType, error)
|
||||
|
||||
// request FunctionTypeElectricalConnectionParameterDescriptionListData from a remote entity
|
||||
RequestParameterDescriptions(
|
||||
selector *model.ElectricalConnectionParameterDescriptionListDataSelectorsType,
|
||||
elements *model.ElectricalConnectionParameterDescriptionDataElementsType,
|
||||
) (*model.MsgCounterType, error)
|
||||
|
||||
// request FunctionTypeElectricalConnectionPermittedValueSetListData from a remote entity
|
||||
RequestPermittedValueSets(
|
||||
selector *model.ElectricalConnectionPermittedValueSetListDataSelectorsType,
|
||||
elements *model.ElectricalConnectionPermittedValueSetDataElementsType,
|
||||
) (*model.MsgCounterType, error)
|
||||
|
||||
// request FunctionTypeElectricalConnectionCharacteristicListData from a remote entity
|
||||
RequestCharacteristics(
|
||||
selector *model.ElectricalConnectionCharacteristicListDataSelectorsType,
|
||||
elements *model.ElectricalConnectionCharacteristicDataElementsType,
|
||||
) (*model.MsgCounterType, error)
|
||||
}
|
||||
|
||||
type IdentificationClientInterface interface {
|
||||
// request FunctionTypeIdentificationListData from a remote entity
|
||||
RequestValues() (*model.MsgCounterType, error)
|
||||
}
|
||||
|
||||
type IncentiveTableClientInterface interface {
|
||||
// request FunctionTypeIncentiveTableDescriptionData from a remote entity
|
||||
RequestDescriptions() (*model.MsgCounterType, error)
|
||||
|
||||
// request FunctionTypeIncentiveTableConstraintsData from a remote entity
|
||||
RequestConstraints() (*model.MsgCounterType, error)
|
||||
|
||||
// request FunctionTypeIncentiveTableData from a remote entity
|
||||
RequestValues() (*model.MsgCounterType, error)
|
||||
|
||||
// write incentivetable descriptions
|
||||
// returns an error if this failed
|
||||
WriteDescriptions(data []model.IncentiveTableDescriptionType) (*model.MsgCounterType, error)
|
||||
|
||||
// write incentivetable descriptions
|
||||
// returns an error if this failed
|
||||
WriteValues(data []model.IncentiveTableType) (*model.MsgCounterType, error)
|
||||
}
|
||||
|
||||
type LoadControlClientInterface interface {
|
||||
// request FunctionTypeLoadControlLimitDescriptionListData from a remote device
|
||||
RequestLimitDescriptions(
|
||||
selector *model.LoadControlLimitDescriptionListDataSelectorsType,
|
||||
elements *model.LoadControlLimitDescriptionDataElementsType,
|
||||
) (*model.MsgCounterType, error)
|
||||
|
||||
// request FunctionTypeLoadControlLimitConstraintsListData from a remote device
|
||||
RequestLimitConstraints(
|
||||
selector *model.LoadControlLimitConstraintsListDataSelectorsType,
|
||||
elements *model.LoadControlLimitConstraintsDataElementsType,
|
||||
) (*model.MsgCounterType, error)
|
||||
|
||||
// request FunctionTypeLoadControlLimitListData from a remote device
|
||||
RequestLimitData(
|
||||
selector *model.LoadControlLimitListDataSelectorsType,
|
||||
elements *model.LoadControlLimitDataElementsType,
|
||||
) (*model.MsgCounterType, error)
|
||||
|
||||
// write load control limits
|
||||
// returns an error if this failed
|
||||
WriteLimitData(
|
||||
data []model.LoadControlLimitDataType,
|
||||
deleteSelectors *model.LoadControlLimitListDataSelectorsType,
|
||||
deleteElements *model.LoadControlLimitDataElementsType,
|
||||
) (*model.MsgCounterType, error)
|
||||
}
|
||||
|
||||
type MeasurementClientInterface interface {
|
||||
// request FunctionTypeMeasurementDescriptionListData from a remote device
|
||||
RequestDescriptions(
|
||||
selector *model.MeasurementDescriptionListDataSelectorsType,
|
||||
elements *model.MeasurementDescriptionDataElementsType,
|
||||
) (*model.MsgCounterType, error)
|
||||
|
||||
// request FunctionTypeMeasurementConstraintsListData from a remote entity
|
||||
RequestConstraints(
|
||||
selector *model.MeasurementConstraintsListDataSelectorsType,
|
||||
elements *model.MeasurementConstraintsDataElementsType,
|
||||
) (*model.MsgCounterType, error)
|
||||
|
||||
// request FunctionTypeMeasurementListData from a remote entity
|
||||
RequestData(
|
||||
selector *model.MeasurementListDataSelectorsType,
|
||||
elements *model.MeasurementDataElementsType,
|
||||
) (*model.MsgCounterType, error)
|
||||
}
|
||||
|
||||
type SmartEnergyManagementPsClientInterface interface {
|
||||
// request FunctionTypeSmartEnergyManagementPsData from a remote entity
|
||||
RequestData() (*model.MsgCounterType, error)
|
||||
|
||||
// write SmartEnergyManagementPsData
|
||||
// returns an error if this failed
|
||||
WriteData(data *model.SmartEnergyManagementPsDataType) (*model.MsgCounterType, error)
|
||||
}
|
||||
|
||||
type TimeSeriesClientInterface interface {
|
||||
// request FunctionTypeTimeSeriesDescriptionListData from a remote entity
|
||||
RequestDescriptions(
|
||||
selector *model.TimeSeriesDescriptionListDataSelectorsType,
|
||||
elements *model.TimeSeriesDescriptionDataElementsType,
|
||||
) (*model.MsgCounterType, error)
|
||||
|
||||
// request FunctionTypeTimeSeriesConstraintsListData from a remote entity
|
||||
RequestConstraints(
|
||||
selector *model.TimeSeriesConstraintsListDataSelectorsType,
|
||||
elements *model.TimeSeriesConstraintsDataElementsType,
|
||||
) (*model.MsgCounterType, error)
|
||||
|
||||
// request FunctionTypeTimeSeriesListData from a remote device
|
||||
RequestData(
|
||||
selector *model.TimeSeriesListDataSelectorsType,
|
||||
elements *model.TimeSeriesDataElementsType,
|
||||
) (*model.MsgCounterType, error)
|
||||
|
||||
// write Time Series values
|
||||
// returns an error if this failed
|
||||
WriteData(data []model.TimeSeriesDataType) (*model.MsgCounterType, error)
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
package api
|
||||
|
||||
import "github.com/enbility/spine-go/model"
|
||||
|
||||
type DeviceClassificationServerInterface interface {
|
||||
}
|
||||
|
||||
type DeviceConfigurationServerInterface interface {
|
||||
DeviceConfigurationCommonInterface
|
||||
|
||||
// Add a new description data set and return the keyId
|
||||
//
|
||||
// will return nil if the data set could not be added
|
||||
AddKeyValueDescription(description model.DeviceConfigurationKeyValueDescriptionDataType) *model.DeviceConfigurationKeyIdType
|
||||
|
||||
// Set or update data set for a keyId
|
||||
// Elements provided in deleteElements will be removed from the data set before the update
|
||||
//
|
||||
// Will return an error if the data set could not be updated
|
||||
UpdateKeyValueDataForKeyId(
|
||||
data model.DeviceConfigurationKeyValueDataType,
|
||||
deleteElements *model.DeviceConfigurationKeyValueDataElementsType,
|
||||
keyId model.DeviceConfigurationKeyIdType,
|
||||
) error
|
||||
|
||||
// Set or update data set for a filter
|
||||
// Elements provided in deleteElements will be removed from the data set before the update
|
||||
//
|
||||
// Will return an error if the data set could not be updated
|
||||
UpdateKeyValueDataForFilter(
|
||||
data model.DeviceConfigurationKeyValueDataType,
|
||||
deleteElements *model.DeviceConfigurationKeyValueDataElementsType,
|
||||
filter model.DeviceConfigurationKeyValueDescriptionDataType,
|
||||
) error
|
||||
}
|
||||
|
||||
type DeviceDiagnosisServerInterface interface {
|
||||
// set the local diagnosis state of the device
|
||||
SetLocalState(operatingState *model.DeviceDiagnosisStateDataType)
|
||||
}
|
||||
|
||||
type ElectricalConnectionServerInterface interface {
|
||||
ElectricalConnectionCommonInterface
|
||||
|
||||
// Add a new description data set
|
||||
//
|
||||
// NOTE: the electricalConnectionId has to be provided
|
||||
//
|
||||
// will return nil if the data set could not be added
|
||||
AddDescription(
|
||||
description model.ElectricalConnectionDescriptionDataType,
|
||||
) error
|
||||
|
||||
// Add a new parameter description data sett and return the parameterId
|
||||
//
|
||||
// NOTE: the electricalConnectionId has to be provided, parameterId may not be provided
|
||||
//
|
||||
// will return nil if the data set could not be added
|
||||
AddParameterDescription(
|
||||
description model.ElectricalConnectionParameterDescriptionDataType,
|
||||
) *model.ElectricalConnectionParameterIdType
|
||||
|
||||
// Add a new characteristic data set
|
||||
//
|
||||
// Note: ElectricalConnectionId and ParameterId must be set, CharacteristicId will be set automatically
|
||||
//
|
||||
// Will return an error if the data set could not be added
|
||||
AddCharacteristic(data model.ElectricalConnectionCharacteristicDataType) (*model.ElectricalConnectionCharacteristicIdType, error)
|
||||
|
||||
// Update data set for a filter
|
||||
// Elements provided in deleteElements will be removed from the data set before the update
|
||||
//
|
||||
// // ElectricalConnectionId, ParameterId and CharacteristicId must be set
|
||||
//
|
||||
// Will return an error if the data set could not be updated
|
||||
UpdateCharacteristic(
|
||||
data model.ElectricalConnectionCharacteristicDataType,
|
||||
deleteElements *model.ElectricalConnectionCharacteristicDataElementsType,
|
||||
) error
|
||||
}
|
||||
|
||||
type LoadControlServerInterface interface {
|
||||
// Add a new description data set and return the limitId
|
||||
//
|
||||
// NOTE: the limitId may not be provided
|
||||
//
|
||||
// will return nil if the data set could not be added
|
||||
AddLimitDescription(
|
||||
description model.LoadControlLimitDescriptionDataType,
|
||||
) *model.LoadControlLimitIdType
|
||||
|
||||
// Set or update data set for a limitId
|
||||
// Elements provided in deleteElements will be removed from the data set before the update
|
||||
//
|
||||
// Will return an error if the data set could not be updated
|
||||
UpdateLimitDataForId(
|
||||
data model.LoadControlLimitDataType,
|
||||
deleteElements *model.LoadControlLimitDataElementsType,
|
||||
limitId model.LoadControlLimitIdType,
|
||||
) error
|
||||
|
||||
// Set or update data set for a filter
|
||||
// Elements provided in deleteElements will be removed from the data set before the update
|
||||
//
|
||||
// Will return an error if the data set could not be updated
|
||||
UpdateLimitDataForFilter(
|
||||
data model.LoadControlLimitDataType,
|
||||
deleteElements *model.LoadControlLimitDataElementsType,
|
||||
filter model.LoadControlLimitDescriptionDataType,
|
||||
) error
|
||||
}
|
||||
|
||||
type MeasurementServerInterface interface {
|
||||
// Add a new parameter description data sett and return the measurementId
|
||||
//
|
||||
// NOTE: the measurementId may not be provided
|
||||
//
|
||||
// will return nil if the data set could not be added
|
||||
AddDescription(
|
||||
description model.MeasurementDescriptionDataType,
|
||||
) *model.MeasurementIdType
|
||||
|
||||
// Set or update data set for a measurementId
|
||||
// Elements provided in deleteElements will be removed from the data set before the update
|
||||
//
|
||||
// Will return an error if the data set could not be updated
|
||||
UpdateDataForId(
|
||||
data model.MeasurementDataType,
|
||||
deleteElements *model.MeasurementDataElementsType,
|
||||
measurementId model.MeasurementIdType,
|
||||
) error
|
||||
|
||||
// Set or update data set for a filter
|
||||
// Elements provided in deleteElements will be removed from the data set before the update
|
||||
//
|
||||
// Will return an error if the data set could not be updated
|
||||
UpdateDataForFilter(
|
||||
data model.MeasurementDataType,
|
||||
deleteElements *model.MeasurementDataElementsType,
|
||||
filter model.MeasurementDescriptionDataType,
|
||||
) error
|
||||
}
|
||||
|
||||
type IdentificationServerInterface interface {
|
||||
}
|
||||
|
||||
type IncentiveTableServerInterface interface {
|
||||
}
|
||||
|
||||
type SmartEnergyManagementPsServerInterface interface {
|
||||
}
|
||||
|
||||
type TimeSeriesServerInterface interface {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package api
|
||||
|
||||
// type for cem and usecase specfic event names
|
||||
type EventType string
|
||||
@@ -0,0 +1,76 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
spineapi "github.com/enbility/spine-go/api"
|
||||
"github.com/enbility/spine-go/model"
|
||||
)
|
||||
|
||||
// details about each use case scenario
|
||||
type UseCaseScenario struct {
|
||||
Scenario model.UseCaseScenarioSupportType // the scenario number
|
||||
Mandatory bool // if this scenario is mandatory to be supported by the remote entity
|
||||
ServerFeatures []model.FeatureTypeType // the server features required for this scenario on the remote entity
|
||||
}
|
||||
|
||||
// contains the available scenarios of a remote entity
|
||||
type RemoteEntityScenarios struct {
|
||||
Entity spineapi.EntityRemoteInterface
|
||||
Scenarios []uint
|
||||
}
|
||||
|
||||
// Entity event callback
|
||||
//
|
||||
// Used by Use Case implementations
|
||||
type EntityEventCallback func(ski string, device spineapi.DeviceRemoteInterface, entity spineapi.EntityRemoteInterface, event EventType)
|
||||
|
||||
type UseCaseBaseInterface interface {
|
||||
// add the use case
|
||||
AddUseCase()
|
||||
|
||||
// remove the use case
|
||||
RemoveUseCase()
|
||||
|
||||
// update availability of the use case
|
||||
//
|
||||
// NOTE: only allowed to be used for client side implementations
|
||||
// of a use case! Otherwise use `RemoveUseCase` and `AddUseCase`.
|
||||
UpdateUseCaseAvailability(available bool)
|
||||
|
||||
// check if the entity is compatible with the use case
|
||||
IsCompatibleEntityType(entity spineapi.EntityRemoteInterface) bool
|
||||
|
||||
// return the current list of compatible remote entities and their available scenarios of this use case
|
||||
RemoteEntitiesScenarios() []RemoteEntityScenarios
|
||||
|
||||
// return the current list of available scenarios of this use case for the remote entity
|
||||
AvailableScenariosForEntity(entity spineapi.EntityRemoteInterface) []uint
|
||||
|
||||
// check if the provided scenario are available at the remote entity
|
||||
IsScenarioAvailableAtEntity(
|
||||
entity spineapi.EntityRemoteInterface,
|
||||
scenario uint,
|
||||
) bool
|
||||
}
|
||||
|
||||
// Implemented by each Use Case
|
||||
type UseCaseInterface interface {
|
||||
UseCaseBaseInterface
|
||||
|
||||
// add the features
|
||||
AddFeatures()
|
||||
}
|
||||
|
||||
type ManufacturerData struct {
|
||||
DeviceName string `json:"deviceName,omitempty"`
|
||||
DeviceCode string `json:"deviceCode,omitempty"`
|
||||
SerialNumber string `json:"serialNumber,omitempty"`
|
||||
SoftwareRevision string `json:"softwareRevision,omitempty"`
|
||||
HardwareRevision string `json:"hardwareRevision,omitempty"`
|
||||
VendorName string `json:"vendorName,omitempty"`
|
||||
VendorCode string `json:"vendorCode,omitempty"`
|
||||
BrandName string `json:"brandName,omitempty"`
|
||||
PowerSource string `json:"powerSource,omitempty"`
|
||||
ManufacturerNodeIdentification string `json:"manufacturerNodeIdentification,omitempty"`
|
||||
ManufacturerLabel string `json:"manufacturerLabel,omitempty"`
|
||||
ManufacturerDescription string `json:"manufacturerDescription,omitempty"`
|
||||
}
|
||||
Reference in new issue
Block a user