Skip to content

Commit

Permalink
Added str() and repr() methods to LgxTag and LGXDevice classes
Browse files Browse the repository at this point in the history
  • Loading branch information
dmroeder committed Feb 19, 2020
1 parent 5896f4b commit e459769
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 0 deletions.
1 change: 1 addition & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
02/19/20
- Changed connection to properly allow unconnected send for getting module properties
- Added GetDeviceProperties to get properties of a device at the specified address
- Added str() and repr() methods to LgxTag and LGXDevice

01/16/20
- Updated readme
Expand Down
25 changes: 25 additions & 0 deletions pylogix/eip.py
Original file line number Diff line number Diff line change
Expand Up @@ -1931,6 +1931,31 @@ def __init__(self):
self.Struct = 0x00
self.Size = 0x00

def __repr__(self):

props = ''
props += 'TagName={}, '.format(self.TagName)
props += 'InstanceID={}, '.format(self.InstanceID)
props += 'SymbolType={}, '.format(self.SymbolType)
props += 'DataTypeValue={}, '.format(self.DataTypeValue)
props += 'DataType={}, '.format(self.DataType)
props += 'Array={}, '.format(self.Array)
props += 'Struct={}, '.format(self.Struct)
props += 'Size={}'.format(self.Size)

return 'LgxTag({})'.format(props)

def __str__(self):

return '{} {} {} {} {} {} {} {}'.format(
self.TagName,
self.InstanceID,
self.SymbolType,
self.DataTypeValue,
self.DataType,
self.Array,
self.Struct,
self.Size)

class Response:

Expand Down
42 changes: 42 additions & 0 deletions pylogix/lgxDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,48 @@ def __init__(self):
self.ProductName=""
self.State=None

def __repr__(self):

props = ''
props += 'Length={}, '.format(self.Length)
props += 'EncapsulationVersion={}, '.format(self.EncapsulationVersion)
props += 'IPAddress={}, '.format(self.IPAddress)
props += 'VendorID={}, '.format(self.VendorID)
props += 'Vendor={}, '.format(self.Vendor)
props += 'DeviceID={}, '.format(self.DeviceID)
props += 'DeviceType={}, '.format(self.DevceType)
props += 'ProductCode={}, '.format(self.ProductCode)
props += 'Revision={}, '.format(self.Revision)
props += 'Status={}, '.format(self.Status)
props += 'SerialNumber={}, '.format(self.SerialNumber)
props += 'ProductNameLength={}, '.format(self.ProductNameLength)
props += 'ProductName={}, '.format(self.ProductName)
props += 'State={}'.format(self.State)

return 'LGXDevice({})'.format(props)



def __str__(self):

ret = "{} {} {} {} {} {} {} {} {} {} {} {} {} {}".format(
self.Length,
self.EncapsulationVersion,
self.IPAddress,
self.VendorID,
self.Vendor,
self.DeviceID,
self.DeviceType,
self.ProductCode,
self.Revision,
self.Status,
self.SerialNumber,
self.ProductNameLength,
self.ProductName,
self.State)

return ret

def GetDevice(deviceID):
if deviceID in devices.keys():
return devices[deviceID]
Expand Down

0 comments on commit e459769

Please sign in to comment.