import time

from snap7.client import Client

from rockwell.allen_bradley_connect import AllenBradleyCPU
from siemens.snap7_server import SiemensServer


cpu = SiemensServer()
cpu.start()

client = Client()
client.connect("127.0.0.1", 0, 0, 102)

while True:
  time.sleep(1)
  vals = [0] * 16
  for meas in cpu.read():
    vals[meas.channel] = meas.current

  client.db_write(1, 0, b'Hello World')
  print(client.db_read(1, 0, 100))