frappy_psi.bronkhorst: minor change
This commit is contained in:
@@ -46,8 +46,8 @@ from frappy.errors import CommunicationFailedError
|
||||
|
||||
class IO(StringIO):
|
||||
end_of_line = '\r\n' # hex: 0D0A
|
||||
adr = 128
|
||||
identification = [(f':07{adr:02X}047163716300', f':10{adr:02X}02716300.*')] # serial number
|
||||
addr = 128
|
||||
identification = [(f':07{addr:02X}047163716300', f':10{addr:02X}02716300.*')] # serial number
|
||||
default_settings = {'baudrate': 38400}
|
||||
|
||||
|
||||
@@ -69,11 +69,11 @@ class Sensor(HasIO, Readable):
|
||||
|
||||
value = Parameter('pressure', FloatRange())
|
||||
scale = Property('scale factor', FloatRange(), default=1)
|
||||
adr = Property('node adress', IntRange(0, 255))
|
||||
addr = Property('node adress', IntRange(0, 255), default=128)
|
||||
|
||||
def get_par(self, length, param, scale):
|
||||
reply = self.communicate(f':{length}{self.adr:02X}04{param}{param}')
|
||||
if reply[:11] != f':{length}{self.adr:02X}02{param}':
|
||||
reply = self.communicate(f':{length}{self.addr:02X}04{param}{param}')
|
||||
if reply[:11] != f':{length}{self.addr:02X}02{param}':
|
||||
return CommunicationFailedError(f'bad reply: {reply}')
|
||||
val = int(reply[11:14], 16) / 32000 * scale
|
||||
return val
|
||||
@@ -85,8 +85,8 @@ class Sensor(HasIO, Readable):
|
||||
class Controller(Sensor, Writable):
|
||||
|
||||
def set_par(self, length, param, scale, value):
|
||||
reply = self.communicate(f':{length}{self.adr:02X}01{param}{round(value/scale):04X}')
|
||||
if reply[:8] != f':04{self.adr:02X}0000':
|
||||
reply = self.communicate(f':{length}{self.addr:02X}01{param}{round(value/scale):04X}')
|
||||
if reply[:8] != f':04{self.addr:02X}0000':
|
||||
raise CommunicationFailedError(f'bad reply: {reply}')
|
||||
return self.get_par(length, param, scale)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user