Documentation
¶
Index ¶
- Constants
- func ListenAndServe()
- type Client
- type Device
- type Message
- func (m *Message) ByteArray() []byte
- func (m *Message) IsBroadcast() bool
- func (m *Message) IsValid() bool
- func (m *Message) Length() uint16
- func (m *Message) SetLength(length uint16)
- func (m *Message) SetPixelColor(pixel int, r uint8, g uint8, b uint8)
- func (m *Message) SystemExclusive(systemId []byte, data []byte)
- type Server
Constants ¶
const ( SET_PIXEL_COLORS = 0x00 SYSTEM_EXCLUSIVE = 0xFF HEADER_BYTES = 4 BROADCAST_CHANNEL = 0 MAX_MESSAGE_SIZE = 0xFFFF )
const (
DEFAULT_OPC_PORT = "7890"
)
Variables ¶
This section is empty.
Functions ¶
func ListenAndServe ¶
func ListenAndServe()
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
This struct represents an OPC client which is used to send OPC messages to an OPC server.
type Device ¶
This interface describes the behavior of an OPC device. OPC devices should be able to write OPC messages to themselves as well as be able to announce a Channel in which they are listening on.
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
This struct describes a single message that follows the OPC protocol
func NewMessage ¶
Creates and returns a pointer to a new message that is to be sent to the passed in channel
func (*Message) IsBroadcast ¶
Returns whether or not this message is a Broadcast message.
func (*Message) IsValid ¶
Returns whether or not this message is valid or not. Validity is determined as whether or not the Length of the message corresponds with the number of data bytes in the message
func (*Message) Length ¶
Returns the length of the message. The length of the message is respresented by combining the high and low length bytes of this message.
func (*Message) SetLength ¶
Sets the length of this message by splitting the passed in length into high and low length bytes.
func (*Message) SetPixelColor ¶
Sets the pixel color of the passed in pixel to the passed in red, green, and blue colors, respectively for this message
func (*Message) SystemExclusive ¶
Specifies that this message is a System Exclusive Message and populates data accordingly
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
This struct describes an OPC server, which keeps track of all connected OPC devices as well as a channel of incoming messages from all connected clients
func NewServer ¶
func NewServer() *Server
Creates and returns a new opc.Server. Accepts a list of usb product IDs in which to send opc messages to.
func (*Server) ListenOnPort ¶
Listens on the passed in port with the passed in protocol, which in turn accepts incoming connections and handles them by issuing individual goroutines.
func (*Server) RegisterDevice ¶
Registers the passed in device to the OPC server
func (*Server) UnregisterDevice ¶
Unregisters the passed in device from the OPC server