Skip to content

Commit

Permalink
Fixing style issues
Browse files Browse the repository at this point in the history
  • Loading branch information
mjrand committed Oct 25, 2023
2 parents 1e2bdcc + e73ee33 commit 0284e7b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
17 changes: 17 additions & 0 deletions socs/agents/hi6200/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,17 @@ def init(self, session, params=None):
if not acquired:
return False, "Could not acquire lock"

<<<<<<< HEAD
self.scale = Hi6200Interface(self.ip_address, self.tcp_port)

=======
try:
self.scale = Hi6200Interface(self.ip_address, self.tcp_port)

except BaseException:
self.log.error(f"Some unknown error occurred initializing TCP Server")
return False, "TCP Failure"
>>>>>>> refs/remotes/origin/add_Hi6200_Agent
self.log.info("Connected to scale.")

return True, 'Initialized Scale.'
Expand Down Expand Up @@ -70,6 +79,10 @@ def monitor_weight(self, session, params=None):
}

try:
<<<<<<< HEAD
=======

>>>>>>> refs/remotes/origin/add_Hi6200_Agent
data['data']["Gross"] = self.scale.read_scale_gross_weight()
data['data']["Net"] = self.scale.read_scale_net_weight()

Expand All @@ -79,6 +92,10 @@ def monitor_weight(self, session, params=None):
session.data = data

except ValueError as e:
<<<<<<< HEAD
=======

>>>>>>> refs/remotes/origin/add_Hi6200_Agent
self.log.error(f"Scale responded with an anomolous number, ignorning: {e}")

except AttributeError as e:
Expand Down
14 changes: 13 additions & 1 deletion socs/agents/hi6200/drivers.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
from pyModbusTCP.client import ModbusClient
import struct

<<<<<<< HEAD
=======
from pyModbusTCP.client import ModbusClient

>>>>>>> refs/remotes/origin/add_Hi6200_Agent

class Hi6200Interface():

"""
The Hi6200 Weight Processor uses a Modbus TCP Interface to communicate.
<<<<<<< HEAD
=======
>>>>>>> refs/remotes/origin/add_Hi6200_Agent
The Gross and Net weight sensors are always available to read on the 8,9 and 6,7 registers respectively.
"""

def __init__(self, ip_address, tcp_port, verbose=False, **kwargs):
"""
Connects to the Hi6200 weight sensor using a TCP Modbus Client with pyModbusTCP.
This works ~similarly to a socket connection using a IP and port.
<<<<<<< HEAD
=======
>>>>>>> refs/remotes/origin/add_Hi6200_Agent
ModbusClient will not throw errors upon incorrect ip_address!
ModbusClient will also allow multiple recconects unlike a socket.
"""
Expand Down

0 comments on commit 0284e7b

Please sign in to comment.