HiQnet package

Submodules

hiqnet.protocol module

HiQnet protocol library.

class hiqnet.protocol.Command(source=None, destination=None, command=None)[source]

Bases: object

HiQnet command.

address_used()[source]

Build an Address Used command.

bytes_remaining = 0
commandlen
decode(command)[source]

Decodes a binary command.

Parameters:command – The binary command to decode
decode_discoinfo()[source]

Decode discovery information command payload.

Payload: - HiQnet Device - Cost - Serial Number - Max Message size - Keep alive period - NetwordID - NetworkInfo

destination_address = None.0.0.0.0
disco_info(device, disco_type='Q')[source]

Build a Discovery Information command.

Parameters:
  • device (Device) – The HiQnet device sending the discovery command
  • disco_type (str) – Discovery type message. I(nfo) or Q(uery)
error_code = 0
error_string = ''
flags = reqack:0 ack:0 info:0 error:0 res1:0 guaranteed:0 multipart:0 res2:0 session:0 res3:0 res4:0 res5:0 res6:0 res7:0 res8:0 res9:0
get_attributes()[source]

Build a Get Attributes command.

get_vd_list(workgroup='')[source]

Build a Get VD List command.

Parameters:workgroup (str) – The workgroup to get the VD list from.
header = '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
headerlen
hello()[source]

Build an hello command.

Starts a session.

Returns:The session number
Return type:int
hop_counter = 5
locate(time, serial_number)[source]

Builds a Locate command.

The receiver makes itself visible. Usually this is done by flashing some LEDs on the front panel.

Parameters:
  • time (bytearray) – time the leds should flash in ms 0x0000 turns off locate led(s) 0xffff turns on locate led(s)
  • serial_number (str) – The target device’s serial number
locate_off(serial_number)[source]

Builds a locate command asking for the visual clue to be inactive.

Parameters:serial_number (str) – The target device’s serial number
locate_on(serial_number)[source]

Builds a locate command asking for the visual clue to be active.

Parameters:serial_number (str) – The target device’s serial number
message = DISCOINFO
new_sequence_number = count(0)
optional_headers = ''
payload = ''
recall()[source]

Build a Recall command.

Recalls a preset.

request_address(req_addr)[source]

Build a Request Address command.

Parameters:req_addr (int) –
sequence_number = 0
session_number = 0
source_address = None.0.0.0.0
start_seq_no = 0
store()[source]

Build a Store command.

Stores current state to a preset.

version
class hiqnet.protocol.FullyQualifiedAddress(device_address=None, vd_address='x00', object_address='x00x00x00', devicevdobject=None)[source]

Bases: object

Fully Qualified HiQnet Address.

classmethod broadcast_address()[source]

Get the Fully Qualified HiQnet Broadcast Address.

Return type:FullyQualifiedAddress
device_address = None
object_address = None
vd_address = None
class hiqnet.protocol.Message(identifier=None, name=None)[source]

Bases: object

HiQnet messages handling.

MESSAGES = {'\x00\x02': 'GETNETINFO', '\x00\x03': 'RESERVED1', '\x00\x00': 'DISCOINFO', '\x00\x01': 'RESERVED0', '\x00\x06': 'SETADDR', '\x00\x07': 'GOODBYE', '\x00\x04': 'REQADDR', '\x00\x05': 'ADDRUSED', '\x00\x08': 'HELLO', 'MULTPARMSUB': '\x01\x0f', 'GETATTR': '\x01\r', 'PARMUNSUBALL': '\x01\x14', 'SUBEVTLOGMSGS': '\x01\x15', 'PARMSUBPCT': '\x01\x11', 'PARMSUBALL': '\x01\x13', 'HELLO': '\x00\x08', 'MULTPARMGET': '\x01\x03', 'SETATTR': '\x01\x0e', 'UNSUBEVTLOGMSGS': '\x01+', 'GETNETINFO': '\x00\x02', 'MULTPARMUNSUB': '\x01\x12', 'ADDRUSED': '\x00\x05', 'MULTOBJPARMSET': '\x01\x01', 'RESERVED1': '\x00\x03', 'RESERVED0': '\x00\x01', 'REQADDR': '\x00\x04', '\x01\x01': 'MULTOBJPARMSET', 'SETADDR': '\x00\x06', 'PARMSETPCT': '\x01\x02', 'GOODBYE': '\x00\x07', 'REQEVTLOG': '\x01,', 'DISCOINFO': '\x00\x00', 'GETVDLIST': '\x01\x1a', 'LOCATE': '\x01)', '\x01\x00': 'MULTPARMSET', '\x01\x03': 'MULTPARMGET', '\x01\x02': 'PARMSETPCT', '\x01\r': 'GETATTR', '\x01\x0f': 'MULTPARMSUB', '\x01\x0e': 'SETATTR', '\x01\x11': 'PARMSUBPCT', '\x01\x13': 'PARMSUBALL', '\x01\x12': 'MULTPARMUNSUB', '\x01\x15': 'SUBEVTLOGMSGS', '\x01\x14': 'PARMUNSUBALL', 'MULTPARMSET': '\x01\x00', '\x01\x1a': 'GETVDLIST', 'STORE': '\x01$', '\x01%': 'RECALL', '\x01$': 'STORE', '\x01)': 'LOCATE', 'RECALL': '\x01%', '\x01+': 'UNSUBEVTLOGMSGS', '\x01,': 'REQEVTLOG'}
identifier = None
name = None

hiqnet.device module

HiQnet device architecture.

Node (Device)

  • At least one virtual device (The first is the device manager)
  • Parameters and/or objects
  • Objects contains parameters and/or other objects

Attributes everywhere

Either STATIC, Instance or Instance+Dynamic

Virtual devices, objects and parameters

Have a Class Name and a Class ID

class hiqnet.device.Attribute(atr_type)[source]

Bases: object

Member variables of the HiQnet architecture.

Static are basically constants. Instance are variables that are set at device bootup. Instance+Dynamic are regular variables that can change during the life of the device.

type = None
class hiqnet.device.Device(name, hiqnet_address=6797, network_info=<hiqnet.networkinfo.IPNetworkInfo object>)[source]

Bases: object

Describes a device (aka node).

address

Get the device manager address

Returns:The fully qualified address of the device manager
Return type:FullyQualifiedAddress
hiqnet_address

Get the device HiQnet address

Returns:The device HiQnet address
Return type:int
manager = None
name

Get the device name

Returns:The device name
Return type:str
network_info = None
virtual_devices = None
class hiqnet.device.DeviceManager(name_string, class_name=None, flags=0, serial_number=None, software_version=None)[source]

Bases: hiqnet.device.VirtualDevice

Describes a HiQnet device manager.

Each device has one and this is always the first virtual device.

flags = reqack:0 ack:0 info:0 error:0 res1:0 guaranteed:0 multipart:0 res2:0 session:0 res3:0 res4:0 res5:0 res6:0 res7:0 res8:0 res9:0
serial_number = None
software_version = None
class hiqnet.device.Object[source]

Bases: object

HiQnet objects.

May contain other objects or parameters.

class hiqnet.device.Parameter[source]

Bases: hiqnet.device.Object

HiQnet parameters.

Represents the manipulable elements and their attributes.

control_law = None
data_type = None
flags = res1:0 sensor:0 res2:0 res3:0
maximum_value = None
minimum_value = None
name_string = ''
class hiqnet.device.VirtualDevice[source]

Bases: object

Describes a HiQnet virtual device.

This is the basic container object type.

attributes = None
class_name = <hiqnet.device.Attribute object>
name_string = <hiqnet.device.Attribute object>
objects = None
parameters = None
hiqnet.device.negotiate_address()[source]

Generates a random HiQnet address.

The address is automatically checked on the network.

hiqnet.networkinfo module

HiQnet device network informations.

class hiqnet.networkinfo.IPNetworkInfo(mac_address, dhcp, ip_address, subnet_mask, gateway_address='0.0.0.0')[source]

Bases: hiqnet.networkinfo.NetworkInfo

IPv4 network informations.

classmethod autodetect()[source]

Get infos from the interface.

We assume that interface to the default gateway is the one we want and fallback to the second interface since the first is usually “lo”.

Return type:NetworkInfo
dhcp = True
gateway = None
ip_address = None
mac_address = None
subnet_mask = None
class hiqnet.networkinfo.NetworkInfo(network_id=1)[source]

Bases: object

Network informations.

NET_ID_RS232 = 4
NET_ID_TCP_IP = 1
network_id = None
  • 1: TCP/IP
  • 2: reserved
  • 3: reserved
  • 4: RS232
class hiqnet.networkinfo.RS232NetworkInfo[source]

Bases: hiqnet.networkinfo.NetworkInfo

RS232 network informations.

Note

Not implemented

  • com_id 1 byte

  • baud_rate 4 bytes

  • parity 1 byte

    • 0 - None
    • 1 - Odd
    • 2 - Even
    • 3 - Mark
    • 4 - Space
  • stop_bits 1 byte

    • 0 - 1 bit
    • 1 - 1.5 bits
    • 2 - 2 bits
  • data_bits 1 byte

    • 4-9
  • flow_control 1_byte

    • 0 - None
    • 1 - Hardware
    • 2 - XON/OFF

hiqnet.flags module

HiQnet Flags.

Simplified flags management with direct bitfields access.

class hiqnet.flags.DeviceFlags[source]

Bases: _ctypes.Union

Device flags.

ack

Structure/Union member

asByte

Structure/Union member

b

Structure/Union member

error

Structure/Union member

guaranteed

Structure/Union member

info

Structure/Union member

multipart

Structure/Union member

reqack

Structure/Union member

res1

Structure/Union member

res2

Structure/Union member

res3

Structure/Union member

res4

Structure/Union member

res5

Structure/Union member

res6

Structure/Union member

res7

Structure/Union member

res8

Structure/Union member

res9

Structure/Union member

session

Structure/Union member

class hiqnet.flags.DeviceFlagsBits[source]

Bases: _ctypes.Structure

Bitfields for the device flags.

ack

Structure/Union member

error

Structure/Union member

guaranteed

Structure/Union member

info

Structure/Union member

multipart

Structure/Union member

reqack

Structure/Union member

res1

Structure/Union member

res2

Structure/Union member

res3

Structure/Union member

res4

Structure/Union member

res5

Structure/Union member

res6

Structure/Union member

res7

Structure/Union member

res8

Structure/Union member

res9

Structure/Union member

session

Structure/Union member

class hiqnet.flags.ParameterFlags[source]

Bases: _ctypes.Union

Parameter flags.

asByte

Structure/Union member

b

Structure/Union member

res1

Structure/Union member

res2

Structure/Union member

res3

Structure/Union member

sensor

Structure/Union member

class hiqnet.flags.ParameterFlagsBits[source]

Bases: _ctypes.Structure

Bitfields for the parameters flags.

Bits 0, 2, and 3 are reserved. Bit 1 is the Sensor Attribute.
0 = Non-Sensor 1 = Sensor
res1

Structure/Union member

res2

Structure/Union member

res3

Structure/Union member

sensor

Structure/Union member

hiqnet.service.ip module

HiQnet IP communication.

class hiqnet.service.ip.Connection(udp_transport, tcp_transport)[source]

Bases: object

Handles HiQnet IP connection.

Warning

Other connection types such as RS232, RS485 or USB are not handled yet.

sendto(command, destination='<broadcast>')[source]

Send command to the destination.

Parameters:
  • command (Command) – Message to send
  • destination (str) – Destination IPv4 address or ‘<broadcast>’
tcp_transport = None
udp_transport = None
class hiqnet.service.ip.Factory(app)[source]

Bases: twisted.internet.protocol.Factory

HiQnet Twisted Factory.

protocol

alias of TCPProtocol

class hiqnet.service.ip.TCPProtocol[source]

Bases: twisted.internet.protocol.Protocol

HiQnet Twisted TCP protocol.

dataReceived(data)[source]

Called when data is received.

Parameters:data (bytearray) – Received binary data
name = 'HiQnetTCP'
startProtocol()[source]

Called after protocol started listening.

class hiqnet.service.ip.UDPProtocol(app)[source]

Bases: twisted.internet.protocol.DatagramProtocol

HiQnet Twisted UDP protocol.

datagramReceived(data, addr)[source]

Called when data is received.

Parameters:
  • data (bytearray) – Received binary data
  • addr (tuple) – IPv4 address and port of the sender
name = 'HiQnetUDP'
startProtocol()[source]

Called after protocol started listening.