Documentation ¶
Overview ¶
Controls AC and DC Solid State Relays.
See also the documentation here: https://www.tinkerforge.com/en/doc/Software/Bricklets/SolidStateRelay_Bricklet_Go.html.
Index ¶
- Constants
- type Function
- type SolidStateRelayBricklet
- func (device *SolidStateRelayBricklet) DeregisterMonoflopDoneCallback(registrationId uint64)
- func (device *SolidStateRelayBricklet) GetAPIVersion() [3]uint8
- func (device *SolidStateRelayBricklet) GetIdentity() (uid string, connectedUid string, position rune, hardwareVersion [3]uint8, ...)
- func (device *SolidStateRelayBricklet) GetMonoflop() (state bool, time uint32, timeRemaining uint32, err error)
- func (device *SolidStateRelayBricklet) GetResponseExpected(functionID Function) (bool, error)
- func (device *SolidStateRelayBricklet) GetState() (state bool, err error)
- func (device *SolidStateRelayBricklet) RegisterMonoflopDoneCallback(fn func(bool)) uint64
- func (device *SolidStateRelayBricklet) SetMonoflop(state bool, time uint32) (err error)
- func (device *SolidStateRelayBricklet) SetResponseExpected(functionID Function, responseExpected bool) error
- func (device *SolidStateRelayBricklet) SetResponseExpectedAll(responseExpected bool)
- func (device *SolidStateRelayBricklet) SetState(state bool) (err error)
Constants ¶
const DeviceDisplayName = "Solid State Relay Bricklet"
const DeviceIdentifier = 244
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SolidStateRelayBricklet ¶
type SolidStateRelayBricklet struct {
// contains filtered or unexported fields
}
func New ¶
func New(uid string, ipcon *ipconnection.IPConnection) (SolidStateRelayBricklet, error)
Creates an object with the unique device ID `uid`. This object can then be used after the IP Connection `ipcon` is connected.
func (*SolidStateRelayBricklet) DeregisterMonoflopDoneCallback ¶
func (device *SolidStateRelayBricklet) DeregisterMonoflopDoneCallback(registrationId uint64)
Remove a registered Monoflop Done callback.
func (*SolidStateRelayBricklet) GetAPIVersion ¶
func (device *SolidStateRelayBricklet) GetAPIVersion() [3]uint8
Returns the version of the API definition (major, minor, revision) implemented by this API bindings. This is neither the release version of this API bindings nor does it tell you anything about the represented Brick or Bricklet.
func (*SolidStateRelayBricklet) GetIdentity ¶
func (device *SolidStateRelayBricklet) GetIdentity() (uid string, connectedUid string, position rune, hardwareVersion [3]uint8, firmwareVersion [3]uint8, deviceIdentifier uint16, err error)
Returns the UID, the UID where the Bricklet is connected to, the position, the hardware and firmware version as well as the device identifier.
The position can be 'a', 'b', 'c', 'd', 'e', 'f', 'g' or 'h' (Bricklet Port). A Bricklet connected to an `Isolator Bricklet <isolator_bricklet>` is always at position 'z'.
The device identifier numbers can be found `here <device_identifier>`. |device_identifier_constant|
func (*SolidStateRelayBricklet) GetMonoflop ¶
func (device *SolidStateRelayBricklet) GetMonoflop() (state bool, time uint32, timeRemaining uint32, err error)
Returns the current state and the time as set by SetMonoflop as well as the remaining time until the state flips.
If the timer is not running currently, the remaining time will be returned as 0.
func (*SolidStateRelayBricklet) GetResponseExpected ¶
func (device *SolidStateRelayBricklet) GetResponseExpected(functionID Function) (bool, error)
Returns the response expected flag for the function specified by the function ID parameter. It is true if the function is expected to send a response, false otherwise.
For getter functions this is enabled by default and cannot be disabled, because those functions will always send a response. For callback configuration functions it is enabled by default too, but can be disabled by SetResponseExpected. For setter functions it is disabled by default and can be enabled.
Enabling the response expected flag for a setter function allows to detect timeouts and other error conditions calls of this setter as well. The device will then send a response for this purpose. If this flag is disabled for a setter function then no response is sent and errors are silently ignored, because they cannot be detected.
See SetResponseExpected for the list of function ID constants available for this function.
func (*SolidStateRelayBricklet) GetState ¶
func (device *SolidStateRelayBricklet) GetState() (state bool, err error)
Returns the state of the relay, *true* means on and *false* means off.
func (*SolidStateRelayBricklet) RegisterMonoflopDoneCallback ¶
func (device *SolidStateRelayBricklet) RegisterMonoflopDoneCallback(fn func(bool)) uint64
This callback is triggered whenever the monoflop timer reaches 0. The parameter is the current state of the relay (the state after the monoflop).
func (*SolidStateRelayBricklet) SetMonoflop ¶
func (device *SolidStateRelayBricklet) SetMonoflop(state bool, time uint32) (err error)
The first parameter is the desired state of the relay (*true* means on and *false* means off). The second parameter indicates the time that the relay should hold the state.
If this function is called with the parameters (true, 1500): The relay will turn on and in 1.5s it will turn off again.
A monoflop can be used as a failsafe mechanism. For example: Lets assume you have a RS485 bus and a Solid State Relay Bricklet connected to one of the slave stacks. You can now call this function every second, with a time parameter of two seconds. The relay will be on all the time. If now the RS485 connection is lost, the relay will turn off in at most two seconds.
func (*SolidStateRelayBricklet) SetResponseExpected ¶
func (device *SolidStateRelayBricklet) SetResponseExpected(functionID Function, responseExpected bool) error
Changes the response expected flag of the function specified by the function ID parameter. This flag can only be changed for setter (default value: false) and callback configuration functions (default value: true). For getter functions it is always enabled.
Enabling the response expected flag for a setter function allows to detect timeouts and other error conditions calls of this setter as well. The device will then send a response for this purpose. If this flag is disabled for a setter function then no response is sent and errors are silently ignored, because they cannot be detected.
func (*SolidStateRelayBricklet) SetResponseExpectedAll ¶
func (device *SolidStateRelayBricklet) SetResponseExpectedAll(responseExpected bool)
Changes the response expected flag for all setter and callback configuration functions of this device at once.
func (*SolidStateRelayBricklet) SetState ¶
func (device *SolidStateRelayBricklet) SetState(state bool) (err error)
Sets the state of the relays *true* means on and *false* means off.
A running monoflop timer will be aborted if this function is called.