added device-methods-check
This commit is contained in:
parent
26c6081086
commit
27d080e09a
57
other/test-device-methods.py
Normal file
57
other/test-device-methods.py
Normal file
@ -0,0 +1,57 @@
|
||||
# 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)
|
||||
Loading…
x
Reference in New Issue
Block a user