0
의 그것을 그렇게되면 우리는 인스턴스를파이썬 클래스의 이해와 기본 클래스
client = PiHttpClient("192.168.1.234")
# RPi native GPIO
gpio = NativeGPIO(client)
gpio.setFunction(25, "out")
state = True
을 그리고 clients.py 코드에서 나는 위에서, 그래서
class PiMixedClient():
def __init__(self, host, port=8000, coap=5683):
def sendRequest(self, method, uri):
class PiHttpClient(PiMixedClient):
def __init__(self, host, port=8000):
PiMixedClient.__init__(self, host, port, -1)
class NativeGPIO(GPIO):
def __init__(self, client):
RESTAPI.__init__(self, client, "/GPIO")
class GPIO(Device):
def __init__(self, client, name):
Device.__init__(self, client, name, "digital")
def getFunction(self, channel):
return self.sendRequest("GET", "/%d/function" % channel)
def setFunction(self, channel, func):
return self.sendRequest("POST", "/%d/function/%s" % (channel, func))
class Device(RESTAPI):
def __init__(self, client, name, category):
RESTAPI.__init__(self, client, "/devices/" + name + "/" + category)
class RESTAPI():
def __init__(self, client, path):
self.client = client
self.path = path
def sendRequest(self, method, path):
return self.client.sendRequest(method, self.path + path)
있다고 가정 해 봅시다 PiHttpClient ("192.168.1.234") 호스트 = "192.168.1.234", 맞습니까? (self, host, port = 8000)은 자체 호스트를 찾습니다. 나는 자기가 논쟁으로 전달되는 것을 보지 못했다.
- 다음 PiMixedClient 내부 PiHttpClient가 PiMixedClient 연장하기 때문에, 그때 그 호스트와 자기
다음 = 다시 NativeGPIO (클라이언트)를 INIT NativeGPIO의 _ 내부 INIT을 GPIO PiMixedClient 같은과 같아야 (자기, 클라이언트), 호출 기능에서 나는 자기를 공급할 필요가 없다?
그래서 가장 낮은 레벨로 확장하면 RESTAPI 기본 클래스가되며 sendRequest 메소드는 PiMixedClient 클래스의 sendRequest?
들여 쓰기를 수정하십시오. – adil