Table Of Contents

Previous topic

test Package

This Page

xchg Package

raw_xchg Module

A python module for GridLAB-D data (JSON) data exchange over UDP and TCP

Classes:
MasterXchg SlaveXchg

Implemented Methods:

Notes:

  • Should work with Python 2.6+ and 3.x. Tested with 2.7.2 and 3.3
  • Currently only supports IPv4
  • The SLAVE will handle connections from any number of masters, BUT since the code is only single threaded each processing (including delay) are blocking. Hence, the SLAVE may miss packets if it is busy processing (or waiting to send) a different reply.

@author: Bryan Palmintier, NREL 2013

class json_link.xchg.raw_xchg.MasterXchg(host_addr, port, protocol, opt_raw=True, opt_header=True, timeout=None, buf_size=4906)[source]

Bases: json_link.xchg.raw_xchg._BaseXchg

Implements a low-level GridLAB-D (JSON) UDP/TCP Master/client link

response_code_in = '200'
response_code_out = '0'
send(msg_out, add_header=True)[source]

Wrap message with a header and send out

setupXchg()[source]
exception json_link.xchg.raw_xchg.RawXchgCantSendError[source]

Bases: json_link.xchg.raw_xchg.RawXchgError

Unable to send packet

code = 1005
exception json_link.xchg.raw_xchg.RawXchgError[source]

Bases: builtins.OSError

Base class for exceptions in the raw_xchg module

code = 1000
exception json_link.xchg.raw_xchg.RawXchgHeaderError[source]

Bases: json_link.xchg.raw_xchg.RawXchgError

Malformed or incorrect header

code = 1003
exception json_link.xchg.raw_xchg.RawXchgNoDataError[source]

Bases: json_link.xchg.raw_xchg.RawXchgError

No data read

code = 1004
exception json_link.xchg.raw_xchg.RawXchgSetupError[source]

Bases: json_link.xchg.raw_xchg.RawXchgError

Problems setting up the communication (e.g. opening the socket)

code = 1002
exception json_link.xchg.raw_xchg.RawXchgTimeoutError[source]

Bases: json_link.xchg.raw_xchg.RawXchgError

Timeout waiting for reply

code = 1001
class json_link.xchg.raw_xchg.SlaveXchg(host_addr, port, protocol, opt_raw=True, opt_header=True, timeout=None, buf_size=4906)[source]

Bases: json_link.xchg.raw_xchg._BaseXchg

Implements a low_level GridLAB-D (JSON) UDP/TCP Slave/server link

close()[source]

Expanded close to handle our state flags

receive()[source]

(Slave) wait to receive a packet, decode the header, and return data

response_code_in = '0'
response_code_out = '200'
send(msg_out, add_header=True)[source]

Wrap message with a header and send out

setupXchg()[source]

Setup (Internet) socket for Slave.