Documentation
¶
Overview ¶
Package gomcprotocol implements Mitsubishi MC Protocol clients for 3E and 4E frames over TCP and UDP transports.
Index ¶
- type Client3E
- func (c *Client3E) Close() error
- func (c *Client3E) Connect() error
- func (c *Client3E) RandomRead(words, dwords []DeviceAddr) ([]uint16, []uint32, error)
- func (c *Client3E) RandomWrite(words []DeviceAddr, wordVals []uint16, dwords []DeviceAddr, dwordVals []uint32) error
- func (c *Client3E) RandomWriteBits(devices []DeviceAddr, values []bool) error
- func (c *Client3E) ReadBits(device string, start, count int) ([]bool, error)
- func (c *Client3E) ReadWords(device string, start, count int) ([]uint16, error)
- func (c *Client3E) RemoteLatchClear() error
- func (c *Client3E) RemotePause(force bool) error
- func (c *Client3E) RemoteReset() error
- func (c *Client3E) RemoteRun(clearMode int, force bool) error
- func (c *Client3E) RemoteStop() error
- func (c *Client3E) SetTimeout(d time.Duration)
- func (c *Client3E) WriteBits(device string, start int, values []bool) error
- func (c *Client3E) WriteWords(device string, start int, values []uint16) error
- type Client4E
- func (c *Client4E) Close() error
- func (c *Client4E) Connect() error
- func (c *Client4E) RandomRead(words, dwords []DeviceAddr) ([]uint16, []uint32, error)
- func (c *Client4E) RandomWrite(words []DeviceAddr, wordVals []uint16, dwords []DeviceAddr, dwordVals []uint32) error
- func (c *Client4E) RandomWriteBits(devices []DeviceAddr, values []bool) error
- func (c *Client4E) ReadBits(device string, start, count int) ([]bool, error)
- func (c *Client4E) ReadWords(device string, start, count int) ([]uint16, error)
- func (c *Client4E) RemoteLatchClear() error
- func (c *Client4E) RemotePause(force bool) error
- func (c *Client4E) RemoteReset() error
- func (c *Client4E) RemoteRun(clearMode int, force bool) error
- func (c *Client4E) RemoteStop() error
- func (c *Client4E) SetTimeout(d time.Duration)
- func (c *Client4E) WriteBits(device string, start int, values []bool) error
- func (c *Client4E) WriteWords(device string, start int, values []uint16) error
- type DeviceAddr
- type MCProtocolConnectionError
- type MCProtocolError
- type Mode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client3E ¶
type Client3E struct {
// contains filtered or unexported fields
}
Client3E is a 3E frame MC Protocol client (TCP or UDP). Safe for concurrent use; requests are serialized by an internal mutex.
func New3EClient ¶
New3EClient creates a new 3E frame client. Call Connect before use.
func New3EClientUDP ¶
New3EClientUDP creates a new 3E frame client using UDP transport. Call Connect before use.
func (*Client3E) RandomRead ¶
func (c *Client3E) RandomRead(words, dwords []DeviceAddr) ([]uint16, []uint32, error)
RandomRead reads word (2-byte) and dword (4-byte) values from multiple devices in a single request (command 0x0403).
func (*Client3E) RandomWrite ¶
func (c *Client3E) RandomWrite(words []DeviceAddr, wordVals []uint16, dwords []DeviceAddr, dwordVals []uint32) error
RandomWrite writes word (2-byte) and dword (4-byte) values to multiple devices in a single request (command 0x1402, subcmd 0x0000).
func (*Client3E) RandomWriteBits ¶
func (c *Client3E) RandomWriteBits(devices []DeviceAddr, values []bool) error
RandomWriteBits writes individual bit values to multiple devices in a single request (command 0x1402, subcmd 0x0001).
func (*Client3E) ReadWords ¶
ReadWords reads count word values from device starting at address start.
func (*Client3E) RemoteLatchClear ¶
RemoteLatchClear clears the latch remotely (command 0x1005). The PLC must be stopped before calling this.
func (*Client3E) RemotePause ¶
RemotePause pauses the PLC CPU remotely (command 0x1003).
func (*Client3E) RemoteReset ¶
RemoteReset resets the PLC remotely (command 0x1006). The PLC must be stopped before calling this. The connection may be closed by the PLC before a response is received.
func (*Client3E) RemoteRun ¶
RemoteRun starts the PLC CPU remotely (command 0x1001).
clearMode: 0 = no clear, 1 = clear except latch, 2 = clear all force: true to execute even if another device is controlling remotely
func (*Client3E) RemoteStop ¶
RemoteStop stops the PLC CPU remotely (command 0x1002).
func (*Client3E) SetTimeout ¶
SetTimeout sets the per-request I/O deadline and the connect timeout. A value of 0 or less disables both the per-request deadline and the connect timeout (Connect will block until the OS times out). Default is 5 seconds.
type Client4E ¶
type Client4E struct {
// contains filtered or unexported fields
}
Client4E is a 4E frame MC Protocol client (TCP only). The 4E frame extends 3E by adding a serial number and reserved field. Safe for concurrent use; requests are serialized by an internal mutex.
func New4EClient ¶
New4EClient creates a new 4E frame client. Call Connect before use.
func (*Client4E) RandomRead ¶
func (c *Client4E) RandomRead(words, dwords []DeviceAddr) ([]uint16, []uint32, error)
RandomRead reads word and dword values from multiple devices (command 0x0403).
func (*Client4E) RandomWrite ¶
func (c *Client4E) RandomWrite(words []DeviceAddr, wordVals []uint16, dwords []DeviceAddr, dwordVals []uint32) error
RandomWrite writes word and dword values to multiple devices (command 0x1402, subcmd 0x0000).
func (*Client4E) RandomWriteBits ¶
func (c *Client4E) RandomWriteBits(devices []DeviceAddr, values []bool) error
RandomWriteBits writes individual bit values to multiple devices (command 0x1402, subcmd 0x0001).
func (*Client4E) ReadWords ¶
ReadWords reads count word values from device starting at address start.
func (*Client4E) RemoteLatchClear ¶ added in v0.2.0
RemoteLatchClear clears the latch remotely (command 0x1005). The PLC must be stopped before calling this.
func (*Client4E) RemotePause ¶ added in v0.2.0
RemotePause pauses the PLC CPU remotely (command 0x1003).
func (*Client4E) RemoteReset ¶ added in v0.2.0
RemoteReset resets the PLC remotely (command 0x1006). The PLC must be stopped before calling this. The connection may be closed by the PLC before a response is received.
func (*Client4E) RemoteRun ¶ added in v0.2.0
RemoteRun starts the PLC CPU remotely (command 0x1001).
clearMode: 0 = no clear, 1 = clear except latch, 2 = clear all force: true to execute even if another device is controlling remotely
func (*Client4E) RemoteStop ¶ added in v0.2.0
RemoteStop stops the PLC CPU remotely (command 0x1002).
func (*Client4E) SetTimeout ¶
SetTimeout sets the per-request I/O deadline and the connect timeout. A value of 0 or less disables both the per-request deadline and the connect timeout (Connect will block until the OS times out). Default is 5 seconds.
type DeviceAddr ¶
DeviceAddr identifies a single device point for random-access operations.
type MCProtocolConnectionError ¶
type MCProtocolConnectionError struct {
// contains filtered or unexported fields
}
MCProtocolConnectionError is returned on network-level failures.
func (*MCProtocolConnectionError) Error ¶
func (e *MCProtocolConnectionError) Error() string
type MCProtocolError ¶
type MCProtocolError struct {
EndCode uint16
}
MCProtocolError is returned when the PLC responds with a non-zero end code.
func (*MCProtocolError) Error ¶
func (e *MCProtocolError) Error() string
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
examples
|
|
|
01_basic_read
command
01_basic_read: PLCからワードデバイスを読み取る最小限のサンプル。
|
01_basic_read: PLCからワードデバイスを読み取る最小限のサンプル。 |
|
02_basic_write
command
02_basic_write: ワードデバイスへの書き込みと読み返しのサンプル。
|
02_basic_write: ワードデバイスへの書き込みと読み返しのサンプル。 |
|
03_bit_operations
command
03_bit_operations: ビットデバイス(M, X, Y)の読み書きサンプル。
|
03_bit_operations: ビットデバイス(M, X, Y)の読み書きサンプル。 |
|
04_random_access
command
04_random_access: バラバラなアドレスをまとめて1リクエストで読み書きするサンプル。
|
04_random_access: バラバラなアドレスをまとめて1リクエストで読み書きするサンプル。 |
|
05_remote_control
command
05_remote_control: PLCのリモート操作(停止・ラッチクリア・起動)サンプル。
|
05_remote_control: PLCのリモート操作(停止・ラッチクリア・起動)サンプル。 |
|
06_monitor
command
06_monitor: 複数デバイスを定期ポーリングし、値が変化したら表示するサンプル。
|
06_monitor: 複数デバイスを定期ポーリングし、値が変化したら表示するサンプル。 |