Add some different xPL implementations done by Telldus
This commit is contained in:
parent
deebf2045e
commit
d4b46c71ec
21 changed files with 2285 additions and 0 deletions
1
xpl/pyxpl/__init__.py
Normal file
1
xpl/pyxpl/__init__.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
__all__ = ["xplmessage", "xpldevice", "xplinstance"]
|
||||
22
xpl/pyxpl/xpldevice.py
Normal file
22
xpl/pyxpl/xpldevice.py
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
###########################################################################
|
||||
# Copyright (C) 2009 by Magnus Ahlberg
|
||||
# <magnus.ahlberg@svart-katt.se>
|
||||
#
|
||||
# Copyright: See COPYING file that comes with this distribution
|
||||
#
|
||||
###########################################################################
|
||||
|
||||
class XPLDevice:
|
||||
"""A class to manage and xPL device"""
|
||||
vendor = ""
|
||||
device = ""
|
||||
instance = ""
|
||||
|
||||
def __init__(devicename):
|
||||
pass
|
||||
|
||||
def __init__(vendor, device):
|
||||
pass
|
||||
|
||||
def __init__(vendor, device, instance):
|
||||
pass
|
||||
47
xpl/pyxpl/xplinstance.py
Normal file
47
xpl/pyxpl/xplinstance.py
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
###########################################################################
|
||||
# Copyright (C) 2009 by Magnus Ahlberg
|
||||
# <magnus.ahlberg@svart-katt.se>
|
||||
#
|
||||
# Copyright: See COPYING file that comes with this distribution
|
||||
#
|
||||
###########################################################################
|
||||
|
||||
from xpldevice import *
|
||||
|
||||
from socket import *
|
||||
|
||||
class XPLInstance:
|
||||
"""Class to handle an xPL session"""
|
||||
MODE_UNDEFINED, MODE_CLIENT, MODE_DISCONNECTED, MODE_HUB = range(4)
|
||||
|
||||
__thisDevice = XPLDevice()
|
||||
__devices = ()
|
||||
__mode = MODE_UNDEFINED
|
||||
|
||||
def __init__(self, device):
|
||||
self.__thisDevice = device
|
||||
|
||||
def __init__(self, vendor, deviceName):
|
||||
device = XPLDevice(vendor, deviceName)
|
||||
self.__init__(device)
|
||||
|
||||
def attached(self):
|
||||
pass
|
||||
|
||||
def devices(self):
|
||||
return devices
|
||||
|
||||
def operationMode(self):
|
||||
return operationMode
|
||||
|
||||
def sendMessage(self, message):
|
||||
pass
|
||||
|
||||
def sendMessage(self, message, device):
|
||||
pass
|
||||
|
||||
def shutdown(self):
|
||||
pass
|
||||
|
||||
def bindToPort(self):
|
||||
pass
|
||||
56
xpl/pyxpl/xplmessage.py
Normal file
56
xpl/pyxpl/xplmessage.py
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
###########################################################################
|
||||
# Copyright (C) 2009 by Magnus Ahlberg
|
||||
# <magnus.ahlberg@svart-katt.se>
|
||||
#
|
||||
# Copyright: See COPYING file that comes with this distribution
|
||||
#
|
||||
###########################################################################
|
||||
|
||||
class XPLMessage:
|
||||
"""A class for managing xPL messages"""
|
||||
ID_UNDEFINED, ID_XPLCMND, ID_XPLSTAT, ID_XPLTRIG = range(4)
|
||||
__body = {}
|
||||
__hop = 0
|
||||
__source = ""
|
||||
__target = ""
|
||||
__identifier = ID_UNDEFINED
|
||||
__identifierString = ("-", "xpl-cmnd", "xpl-stat", "xpl-trig")
|
||||
__messageSchemaIdentifier = ""
|
||||
|
||||
def __init__(self, identifier, messageSchemaIdentifier):
|
||||
self.__identifier = identifier
|
||||
self.__messageSchemaIdentifier = messageSchemaIdentifier
|
||||
|
||||
def addBodyItem(self, key, value):
|
||||
self.__body[key] = value
|
||||
|
||||
def bodyItem(self, key):
|
||||
return self.__body[key]
|
||||
|
||||
def createMessageFromString(message):
|
||||
pass
|
||||
|
||||
def setSource(self, value):
|
||||
self.__source = value
|
||||
|
||||
def setTarget(self, value):
|
||||
self.__target = value
|
||||
|
||||
def toString(self):
|
||||
if self.__identifier == self.ID_UNDEFINED:
|
||||
return ""
|
||||
|
||||
messageStringList = []
|
||||
messageStringList.append(self.__identifierString[self.__identifier] + "\n")
|
||||
messageStringList.append("{\n")
|
||||
messageStringList.append("hop=" + str(self.__hop) + "\n")
|
||||
messageStringList.append("source=" + self.__source + "\n")
|
||||
messageStringList.append("target=" + self.__target + "\n")
|
||||
messageStringList.append("}\n")
|
||||
messageStringList.append(self.__messageSchemaIdentifier + "\n")
|
||||
messageStringList.append("{\n")
|
||||
for key, value in self.__body.iteritems():
|
||||
messageStringList.append(key + "=" + value + "\n")
|
||||
messageStringList.append("}\n")
|
||||
|
||||
return "".join(messageStringList)
|
||||
Loading…
Add table
Add a link
Reference in a new issue