generated from thinkode/modelRepository
clean arbo
This commit is contained in:
@@ -39,6 +39,59 @@ const (
|
||||
EndpointStatusActivated EndpointStatus = "PERIPHERAL_ACTIVATED"
|
||||
)
|
||||
|
||||
// MappingInfo is the configuration for each device
|
||||
type MappingInfo struct {
|
||||
DeviceInfo struct {
|
||||
Name string `yaml:"name"`
|
||||
Manufacturer string `yaml:"manufacturer"`
|
||||
Type string `yaml:"type"`
|
||||
} `yaml:"device"`
|
||||
Features map[string]any `yaml:"features"`
|
||||
}
|
||||
|
||||
// Device represents the methods used to manage a device (logic element include in a Endpoint)
|
||||
type Device interface {
|
||||
Configure() error // Load the mapping for the device
|
||||
}
|
||||
|
||||
// Endpoint represents the methods used to manage a endpoint (input or output hardware)
|
||||
type Endpoint interface {
|
||||
Connect(context.Context) error // Connect the endpoint
|
||||
// SetEventCallback(func(any)) // Callback is called when an event is emitted from the endpoint
|
||||
Disconnect(context.Context) error // Disconnect the endpoint
|
||||
Activate(context.Context) error // Activate the endpoint
|
||||
Deactivate(context.Context) error // Deactivate the endpoint
|
||||
// AddDevice(Device) error // Add a device to the endpoint
|
||||
// RemoveDevice(Device) error // Remove a device to the endpoint
|
||||
GetSettings() map[string]any // Get the endpoint settings
|
||||
SetSettings(context.Context, map[string]any) error // Set a endpoint setting
|
||||
SetDeviceProperty(context.Context, uint32, byte) error // Update a device property
|
||||
WaitStop() error // Properly close the endpoint
|
||||
|
||||
GetInfo() EndpointInfo // Get the endpoint information
|
||||
|
||||
}
|
||||
|
||||
// EndpointInfo represents a endpoint information
|
||||
type EndpointInfo struct {
|
||||
Name string `yaml:"name"` // Name of the endpoint
|
||||
SerialNumber string `yaml:"sn"` // S/N of the endpoint
|
||||
ProtocolName string `yaml:"protocol"` // Protocol name of the endpoint
|
||||
Settings map[string]any `yaml:"settings"` // Endpoint settings
|
||||
}
|
||||
|
||||
// EndpointProvider represents how compatible endpoint drivers are implemented
|
||||
type EndpointProvider interface {
|
||||
Initialize() error // Initializes the protocol
|
||||
Create(ctx context.Context, endpointInfo EndpointInfo) (EndpointInfo, error) // Manually create a endpoint
|
||||
Remove(ctx context.Context, endpoint Endpoint) error // Manually remove a endpoint
|
||||
OnArrival(cb func(context.Context, Endpoint)) // Callback function when a endpoint arrives
|
||||
OnRemoval(cb func(context.Context, Endpoint)) // Callback function when a endpoint goes away
|
||||
Start(context.Context) error // Start the detection
|
||||
WaitStop() error // Waiting for provider to close
|
||||
GetName() string // Get the name of the provider
|
||||
}
|
||||
|
||||
// Manager is the class who manages the hardware
|
||||
type Manager struct {
|
||||
mu sync.Mutex
|
||||
|
||||
@@ -1,56 +0,0 @@
|
||||
package hardware
|
||||
|
||||
import "context"
|
||||
|
||||
// MappingInfo is the configuration for each device
|
||||
type MappingInfo struct {
|
||||
DeviceInfo struct {
|
||||
Name string `yaml:"name"`
|
||||
Manufacturer string `yaml:"manufacturer"`
|
||||
Type string `yaml:"type"`
|
||||
} `yaml:"device"`
|
||||
Features map[string]any `yaml:"features"`
|
||||
}
|
||||
|
||||
// Device represents the methods used to manage a device (logic element include in a Endpoint)
|
||||
type Device interface {
|
||||
Configure() error // Load the mapping for the device
|
||||
}
|
||||
|
||||
// Endpoint represents the methods used to manage a endpoint (input or output hardware)
|
||||
type Endpoint interface {
|
||||
Connect(context.Context) error // Connect the endpoint
|
||||
// SetEventCallback(func(any)) // Callback is called when an event is emitted from the endpoint
|
||||
Disconnect(context.Context) error // Disconnect the endpoint
|
||||
Activate(context.Context) error // Activate the endpoint
|
||||
Deactivate(context.Context) error // Deactivate the endpoint
|
||||
// AddDevice(Device) error // Add a device to the endpoint
|
||||
// RemoveDevice(Device) error // Remove a device to the endpoint
|
||||
GetSettings() map[string]any // Get the endpoint settings
|
||||
SetSettings(context.Context, map[string]any) error // Set a endpoint setting
|
||||
SetDeviceProperty(context.Context, uint32, byte) error // Update a device property
|
||||
WaitStop() error // Properly close the endpoint
|
||||
|
||||
GetInfo() EndpointInfo // Get the endpoint information
|
||||
|
||||
}
|
||||
|
||||
// EndpointInfo represents a endpoint information
|
||||
type EndpointInfo struct {
|
||||
Name string `yaml:"name"` // Name of the endpoint
|
||||
SerialNumber string `yaml:"sn"` // S/N of the endpoint
|
||||
ProtocolName string `yaml:"protocol"` // Protocol name of the endpoint
|
||||
Settings map[string]any `yaml:"settings"` // Endpoint settings
|
||||
}
|
||||
|
||||
// EndpointProvider represents how compatible endpoint drivers are implemented
|
||||
type EndpointProvider interface {
|
||||
Initialize() error // Initializes the protocol
|
||||
Create(ctx context.Context, endpointInfo EndpointInfo) (EndpointInfo, error) // Manually create a endpoint
|
||||
Remove(ctx context.Context, endpoint Endpoint) error // Manually remove a endpoint
|
||||
OnArrival(cb func(context.Context, Endpoint)) // Callback function when a endpoint arrives
|
||||
OnRemoval(cb func(context.Context, Endpoint)) // Callback function when a endpoint goes away
|
||||
Start(context.Context) error // Start the detection
|
||||
WaitStop() error // Waiting for provider to close
|
||||
GetName() string // Get the name of the provider
|
||||
}
|
||||
Reference in New Issue
Block a user