Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
Added unit_value parameter.
  • Loading branch information
avichalk authored Apr 1, 2024
1 parent dea02a8 commit 13e20cf
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions alicat/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ async def get_totalizer_batch(self, batch: int = 1) -> str:
Returns:
line: Current value of totalizer batch
"""
command = f'{self.unit} TB {batch}'
command = f'{self.unit}$$TB {batch}'
line = await self._write_and_read(command)

if line == '?':
Expand All @@ -396,16 +396,27 @@ async def get_totalizer_batch(self, batch: int = 1) -> str:
values = line.split(" ") # type: ignore[union-attr]
return f'{values[2]} {values[4]}' # returns 'batch vol' 'units'

async def set_totalizer_batch(self, batch_volume: float, batch: int = 1) -> None:
async def set_totalizer_batch(self, batch_volume: float, batch: int = 1, units: str = 'default') -> None:
"""Set the totalizer batch volume.
Args:
batch: Which of the two totalizer batches to set.
Default is 1; some devices have 2
batch_volume: Target batch volume, in same units as units
on device
units: Units of the volume being provided. Default
is 0, so device returns default engineering units.
"""
command = f'{self.unit} TB {batch} {batch_volume}'
engineering_units_table = {"default":0, "SμL":2, "SmL":3, "SL":4, \
"Scm3":6, "Sm3":7, "Sin3":8, "Sft3":9, "kSft3":10, "NμL":32, \
"NmL":33, "NL":34, "Ncm3":36, "Nm3":37}

if units in engineering_units_table:
units_no = engineering_units_table[units]
else:
raise ValueError("Units not in unit list. Please consult Appendix B-3 of the Alicat Serial Primer.")

command = f'{self.unit}$$TB {batch} {batch_volume} {units_no}'
line = await self._write_and_read(command)

if line == '?':
Expand Down

0 comments on commit 13e20cf

Please sign in to comment.