initial import
This commit is contained in:
commit
ca74d8073b
1
plclink/__init__.py
Normal file
1
plclink/__init__.py
Normal file
@ -0,0 +1 @@
|
||||
__version__ = "0.4.2"
|
||||
14
plclink/cli.py
Normal file
14
plclink/cli.py
Normal file
@ -0,0 +1,14 @@
|
||||
import click
|
||||
from .registers import load_map
|
||||
|
||||
@click.command()
|
||||
@click.argument("workbook")
|
||||
@click.option("--site", default="default")
|
||||
def main(workbook, site):
|
||||
"""Generate a staged point list from the master workbook."""
|
||||
rmap = load_map(workbook, site)
|
||||
for reg in rmap:
|
||||
click.echo(f"{reg.addr:>6} {reg.tag:<24} {reg.kind}")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
13
plclink/registers.py
Normal file
13
plclink/registers.py
Normal file
@ -0,0 +1,13 @@
|
||||
from collections import namedtuple
|
||||
Reg = namedtuple("Reg", "addr tag kind")
|
||||
|
||||
def load_map(path, site):
|
||||
import openpyxl
|
||||
wb = openpyxl.load_workbook(path, read_only=True)
|
||||
sheet = wb[site] if site in wb.sheetnames else wb.active
|
||||
out = []
|
||||
for row in sheet.iter_rows(min_row=2, values_only=True):
|
||||
if not row or row[0] is None:
|
||||
continue
|
||||
out.append(Reg(int(row[0]), str(row[1]), str(row[2] or "HR")))
|
||||
return out
|
||||
3
requirements.txt
Normal file
3
requirements.txt
Normal file
@ -0,0 +1,3 @@
|
||||
pymodbus==3.6.8
|
||||
openpyxl==3.1.2
|
||||
click==8.1.7
|
||||
Loading…
Reference in New Issue
Block a user