# Path: pyads/commands/adscommand.py
# class AdsCommand:
# 
#     def __init__(self):
#         pass
# 
# 
#     CommandID = 0
# 
# 
#     def CreateRequest(self):
#         raise NotImplementedError()
# 
# 
#     def CreateResponse(self, responsePacket):
#         raise NotImplementedError()
# 
# 
#     def GetAmsPacket(self, adsConnection):
#         packet = AmsPacket(adsConnection)
#         packet.CommandID = self.CommandID
#         packet.StateFlags = 0x0004
#         packet.Data = self.CreateRequest()
# 
#         return packet
# 
# 
#     def Execute(self, adsClient):
# 
#         # create packet
#         packet = self.GetAmsPacket(adsClient.AdsConnection)
# 
#         # send to client
#         responsePacket = adsClient.SendAndRecv(packet)
# 
#         # check for error
#         if (responsePacket.ErrorCode > 0):
#             raise AdsException(responsePacket.ErrorCode)
# 
#         # return response object
#         result = self.CreateResponse(responsePacket)
#         if (result.Error > 0):
#             raise AdsException(result.Error)
# 
#         return result
# 
# Path: pyads/commands/readwriteresponse.py
# class ReadWriteResponse(AdsResponse):
# 
#     def __init__(self, responseAmsPacket):
#         AdsResponse.__init__(self, responseAmsPacket)
# 
#         self.Length = struct.unpack_from('I', responseAmsPacket.Data, 4)[0]
#         self.Data = responseAmsPacket.Data[8:]
# 
# 
#     Length = 0
# 
#     Data = b'0'
# 
# 
#     def __str__(self):
#         result = "AdsReadWriteResponse:\n"
#         result += AmsPacket.GetHexStringBlock(self.Data)
#         return result


import struct
from .adscommand import AdsCommand
from .readwriteresponse import ReadWriteResponse

class ReadWriteCommand(AdsCommand):

    def __init__(self, indexGroup, indexOffset, readLen, dataToWrite = b''):
        self.CommandID = 0x0009
        self.IndexGroup = indexGroup
        self.IndexOffset = indexOffset
        self.ReadLen = readLen
        self.Data = dataToWrite



    IndexGroup = 0


# Path: pyads/commands/adscommand.py
# class AdsCommand:
# 
#     def __init__(self):
#         pass
# 
# 
#     CommandID = 0
# 
# 
#     def CreateRequest(self):
#         raise NotImplementedError()
# 
# 
#     def CreateResponse(self, responsePacket):
#         raise NotImplementedError()
# 
# 
#     def GetAmsPacket(self, adsConnection):
#         packet = AmsPacket(adsConnection)
#         packet.CommandID = self.CommandID
#         packet.StateFlags = 0x0004
#         packet.Data = self.CreateRequest()
# 
#         return packet
# 
# 
#     def Execute(self, adsClient):
# 
#         # create packet
#         packet = self.GetAmsPacket(adsClient.AdsConnection)
# 
#         # send to client
#         responsePacket = adsClient.SendAndRecv(packet)
# 
#         # check for error
#         if (responsePacket.ErrorCode > 0):
#             raise AdsException(responsePacket.ErrorCode)
# 
#         # return response object
#         result = self.CreateResponse(responsePacket)
#         if (result.Error > 0):
#             raise AdsException(result.Error)
# 
#         return result
# 
# Path: pyads/commands/readwriteresponse.py
# class ReadWriteResponse(AdsResponse):
# 
#     def __init__(self, responseAmsPacket):
#         AdsResponse.__init__(self, responseAmsPacket)
# 
#         self.Length = struct.unpack_from('I', responseAmsPacket.Data, 4)[0]
#         self.Data = responseAmsPacket.Data[8:]
# 
# 
#     Length = 0
# 
#     Data = b'0'
# 
# 
#     def __str__(self):
#         result = "AdsReadWriteResponse:\n"
#         result += AmsPacket.GetHexStringBlock(self.Data)
#         return result


# Path: pyads/commands/readwritecommand.py
import struct
from .adscommand import AdsCommand
from .readwriteresponse import ReadWriteResponse


class ReadWriteCommand(AdsCommand):

    def __init__(self, indexGroup, indexOffset, readLen, dataToWrite = b''):
        self.CommandID = 0x0009
        self.IndexGroup = indexGroup
        self.IndexOffset = indexOffset
        self.ReadLen = readLen
        self.Data = dataToWrite



    IndexGroup = 0


    IndexOffset = 0