mkcontrol-app/other/test-device-methods.py

57 lines
1.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# test-device-methods.py
from mkconnect.mouldking.MouldKing import MouldKing
from mkconnect.tracer.TracerConsole import TracerConsole
from mkconnect.advertiser.AdvertiserBTSocket import AdvertiserBTSocket
tracer = TracerConsole()
advertiser = AdvertiserBTSocket()
mk = MouldKing()
mk.SetAdvertiser(advertiser)
mk.SetTracer(tracer)
print("=== Hole Module6_0 ===")
mod6 = mk.Module6_0()
print("\nMethoden von Device0:")
dev0 = mod6.Device0
print([m for m in dir(dev0) if not m.startswith('_')])
print("\nMethoden von Device1:")
dev1 = mod6.Device1
print([m for m in dir(dev1) if not m.startswith('_')])
# Optional: Device2 auch noch, falls interessant
# print("\nMethoden von Device2:")
# print([m for m in dir(mod6.Device2) if not m.startswith('_')])
print("\n=== Test mit Device0 ===")
try:
# Hier ein paar typische Aufruf-Versuche was funktioniert?
print("Versuche .set_motor(0, 0.5):")
dev0.set_motor(0, 0.5) # Kanal 0 = A, Power 0.5
print("→ Erfolgreich (kein Fehler)")
except AttributeError as e:
print("set_motor nicht vorhanden:", e)
except Exception as e:
print("Fehler bei set_motor:", e)
try:
print("Versuche .set_channel('A', 1.0):")
dev0.set_channel('A', 1.0)
print("→ Erfolgreich")
except AttributeError as e:
print("set_channel nicht vorhanden:", e)
try:
print("Versuche .motor(0, 1.0):")
dev0.motor(0, 1.0)
except AttributeError as e:
print("motor nicht vorhanden:", e)
try:
print("Versuche .stop():")
dev0.stop()
print("→ stop() erfolgreich")
except AttributeError as e:
print("stop nicht vorhanden:", e)