Skip to content

Retrieving the ALDB (API question) #99

@wz2b

Description

@wz2b

I'm attempting to write my own little tool for doing some maintenance of the ALDB, starting with the PLM. It's not going super, and I'm looking for some help. Based on that help, I'll try to contribute to the documentation and make it easier to understand.

What I'm doing involves Qt so I create the asyncio loop using quamash. I don't think that affects my question, but I'm including this for completeness, as I'm a Java/Scala/C/C++ developer hacking my way through Python-land:

loop = QEventLoop(app)
print(loop)
asyncio.set_event_loop(loop)```

My attempt to dump the ALDB starts with just printing to the console:

```class Controller:
  def __init__(self, loop):
    self.loop=loop
    print("Controller initialized")

  def connect(self):
    self.loop.create_task(self._connect())

  def load(self):
    self.loop.create_task(self._load())

  def dump(self):
     self.loop.create_task(self._dump())

  @asyncio.coroutine
  def _connect(self):
    self.conn = yield from insteonplm.Connection.create();
    print("Connected")

  @asyncio.coroutine
  def _load(self):
    print("Loading...")
    self.plm = self.conn.protocol
    self.plm.aldb.clear()
    yield from asyncio.sleep(1, loop=self.loop)
    self.plm.read_aldb()

    yield from asyncio.sleep(5, loop=self.loop)

    while self.plm.aldb.status == ALDBStatus.LOADING:
      print(str(self.plm.aldb.status))
      yield from asyncio.sleep(1, loop=self.loop)

    print(str(self.plm.aldb.status))
    print("Done.");

  @asyncio.coroutine
  def _dump(self):
    for i in self.plm.aldb:
      record=self.plm.aldb[i]
      print(record)```

The problem is I get very few records - sometimes zero, sometimes two.  There should be something on the order of 80 links.  This is all with 0.13.1.

Am I doing something obviously wrong here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions