Exemple #1
0
    def SetVertexFromString(self, inputStr):
        splitString = inputStr.split(',')
        self.inputID = int(splitString[0])
        self.outputID = int(splitString[1])

        self.destinationIP = HeepIPAddress(0, 0, 0, 0)
        self.destinationIP.SetIPFromString(splitString[2])

        self.destinationID = int(splitString[3])
        self.sourceID = int(splitString[4])
    def ExecuteDeleteVertex(self, byteArray, HeepDevice):
        counter = 1
        (numBytes, counter) = OpCodeUtilities().GetNumberFromMemory(
            byteArray, counter, 1)
        (TxID, counter) = OpCodeUtilities().GetDeviceIDFromMemory(
            byteArray, counter)
        (RxID, counter) = OpCodeUtilities().GetDeviceIDFromMemory(
            byteArray, counter)
        (TxControl, counter) = OpCodeUtilities().GetNumberFromMemory(
            byteArray, counter, 1)
        (RxControl, counter) = OpCodeUtilities().GetNumberFromMemory(
            byteArray, counter, 1)

        (IPOct1, counter) = OpCodeUtilities().GetNumberFromMemory(
            byteArray, counter, 1)
        (IPOct2, counter) = OpCodeUtilities().GetNumberFromMemory(
            byteArray, counter, 1)
        (IPOct3, counter) = OpCodeUtilities().GetNumberFromMemory(
            byteArray, counter, 1)
        (IPOct4, counter) = OpCodeUtilities().GetNumberFromMemory(
            byteArray, counter, 1)
        destinationIP = HeepIPAddress(IPOct1, IPOct2, IPOct3, IPOct4)

        NewVertex = Vertex()
        NewVertex.sourceID = TxID
        NewVertex.outputID = TxControl
        NewVertex.destinationID = RxID
        NewVertex.inputID = RxControl
        NewVertex.destinationIP = destinationIP

        HeepDevice.DeleteVertex(NewVertex)

        return ResponseOpCodeParser().GetSuccessROPBuffer(
            HeepDevice, "Vertex Deleted")
Exemple #3
0
    def ReadVertexOpCode(self, byteArray, counter):
        counter = counter + 1

        (sourceID, counter) = OpCodeUtilities().GetDeviceIDFromMemory(
            byteArray, counter)

        (numBytes, counter) = self.GetNumberFromMemory(byteArray, counter, 1)

        (destinationID, counter) = OpCodeUtilities().GetDeviceIDFromMemory(
            byteArray, counter)

        (outputID, counter) = self.GetNumberFromMemory(byteArray, counter, 1)
        (inputID, counter) = self.GetNumberFromMemory(byteArray, counter, 1)

        (IPOct1, counter) = self.GetNumberFromMemory(byteArray, counter, 1)
        (IPOct2, counter) = self.GetNumberFromMemory(byteArray, counter, 1)
        (IPOct3, counter) = self.GetNumberFromMemory(byteArray, counter, 1)
        (IPOct4, counter) = self.GetNumberFromMemory(byteArray, counter, 1)

        NewVertex = Vertex()
        NewVertex.inputID = inputID
        NewVertex.sourceID = sourceID
        NewVertex.outputID = outputID
        NewVertex.destinationID = destinationID
        NewVertex.destinationIP = HeepIPAddress(IPOct1, IPOct2, IPOct3, IPOct4)

        RetData = MemoryData()
        RetData.counter = counter
        RetData.deviceID = sourceID
        RetData.data = NewVertex

        return RetData
Exemple #4
0
class Vertex:

    inputID = 0
    outputID = 0
    destinationID = 0
    destinationIP = HeepIPAddress(0, 0, 0, 0)
    sourceID = 0

    def __init__(self):
        return

    def GetVertexString(self):
        myStr = str(self.inputID) + ',' + str(
            self.outputID) + ',' + self.destinationIP.GetIPAsString(
            ) + ',' + str(self.destinationID) + ',' + str(self.sourceID) + ';'
        return myStr

    def SetVertexFromString(self, inputStr):
        splitString = inputStr.split(',')
        self.inputID = int(splitString[0])
        self.outputID = int(splitString[1])

        self.destinationIP = HeepIPAddress(0, 0, 0, 0)
        self.destinationIP.SetIPFromString(splitString[2])

        self.destinationID = int(splitString[3])
        self.sourceID = int(splitString[4])

    def IsVertexEqual(self, vertex):
        if vertex.inputID == self.inputID:
            if vertex.sourceID == self.sourceID:
                if vertex.outputID == self.outputID:
                    if vertex.destinationID == self.destinationID:
                        return 1

        return 0

    def PrepareForJSON(self):
        self.inputID = self.inputID
        self.outputID = self.outputID
        self.destinationIP = self.destinationIP
        self.destinationID = self.destinationID
        self.sourceID = self.sourceID

    def FromDict(self, Dict):
        self.__dict__ = Dict
Exemple #5
0
 def __init__(self):
     self.DeviceID = 12345678910
     self.IPAddress = HeepIPAddress(0, 0, 0, 0)
     self.DeviceName = 'none'
     self.IconCustom = 0
     self.IconName = 'none'
     self.ControlList = []
     self.ControlQueue = []
     self.VertexList = []
     self.DeviceMemory = DeviceMemory()
     return
Exemple #6
0
class OutputData:

    inputID = 0
    destinationID = 0
    destinationIP = HeepIPAddress(0, 0, 0, 0)
    sourceID = 0
    value = 0

    def __init__(self, _inputID, _destID, _destIP, _sourceID, _value):
        self.inputID = _inputID
        self.destinationID = _destID
        self.destinationIP = _destIP
        self.sourceID = _sourceID
        self.value = _value
        return
Exemple #7
0
    def ReadIPAddressOPCode(self, byteArray, counter):
        counter = counter + 1
        (deviceID, counter) = OpCodeUtilities().GetDeviceIDFromMemory(
            byteArray, counter)
        (numBytes, counter) = self.GetNumberFromMemory(byteArray, counter, 1)

        (IPOct1, counter) = self.GetNumberFromMemory(byteArray, counter, 1)
        (IPOct2, counter) = self.GetNumberFromMemory(byteArray, counter, 1)
        (IPOct3, counter) = self.GetNumberFromMemory(byteArray, counter, 1)
        (IPOct4, counter) = self.GetNumberFromMemory(byteArray, counter, 1)

        IPAddr = HeepIPAddress(IPOct1, IPOct2, IPOct3, IPOct4)

        RetData = MemoryData()
        RetData.counter = counter
        RetData.deviceID = deviceID
        RetData.data = IPAddr

        return RetData
Exemple #8
0
# Transfer device information via serialization
controlStr = otherDevice.GetDeviceString()
newDevice = Device()
newDevice.DeviceID = 1523
newDevice.SetDeviceFromString(controlStr)

print CheckEquality(len(newDevice.ControlList), len(otherDevice.ControlList),
                    'Transfer device information')

newDevice = Device()
myVertex = Vertex()
myVertex.inputID = 1
myVertex.outputID = 2
myVertex.destinationID = 123456
myVertex.sourceID = 666
myVertex.destinationIP = HeepIPAddress(192, 142, 132, 132)
newDevice.AddVertex(myVertex)

outputQueue = newDevice.QueueOutput(2, 20)

print CheckEquality(len(outputQueue), 1, 'Output Queue Size')

myVertex = Vertex()
myVertex.inputID = 2
myVertex.outputID = 2
myVertex.destinationID = 123223456
myVertex.sourceID = 666
myVertex.destinationIP = HeepIPAddress(192, 142, 132, 132)
newDevice.AddVertex(myVertex)

outputQueue = newDevice.QueueOutput(2, 20)