agent = RegistrationAgent(self.myIdentity)
agent.setServerAddress(self.testingRegistrationUri)
agent.setDebugMode(True)
- print agent.getServerAddress()
# registrate
try:
- s = Service.Service("http://smart-api.io/tests/python/registration/service/")
+ s = Service("http://smart-api.io/tests/python/registration/service/")
s.setName("Registration Server Test Service")
- a = Activity.Activity()
- a.setMethod(RESOURCE.OPERATION)
- s.addCapability(a)
+
+ i = InterfaceAddress()
+ i.setHost("127.0.0.1")
+ i.setPath("/smart/v1.0e1.0")
+ i.setPort(80)
+ i.setScheme("http")
+
+ write = Activity()
+ write.setMethod(RESOURCE.WRITE)
+ write.setInterface(i)
+
+ read = Activity()
+ read.setMethod(RESOURCE.READ)
+ read.setInterface(i)
+
+ s.addCapability(write)
+ s.addCapability(read)
+
s.setCoordinates(latitude=60.180824, longitude=24.832116)
- power = ValueObject.ValueObject("http://smart-api.io/tests/python/registration/service/Cpower")
+ power = ValueObject("http://smart-api.io/tests/python/registration/service/Cpower")
+ power.addType(RESOURCE.READABLE)
+ power.addType(RESOURCE.WRITABLE)
power.setQuantity(RESOURCE.POWER)
power.setUnit(RESOURCE.WATT)
power.setValue(6.5)
- power.setMaximum(7.0)
+ power.setMaximum(1000.0)
+ power.setMinimum(0.0)
s.addValueObject(power)
+ s.turtlePrint()
agent.addEntity(s)
r = agent.registrate()
if r is None or r.hasErrors():
- print "RegistrationServerTest phase 1 FAILED (Registration)"
- return False
+ print "RegistrationServerTest phase 1 FAILED (Registration)"
+ return False
except:
traceback.print_exc()
print "RegistrationServerTest phase 1 FAILED (Registration)"