def hms_topic_print(): topicname = None if len(sys.argv) > 1: arg = sys.argv[1] if arg in ("-a", "--all"): topicname = None elif arg in ("-h", "--help"): hms_topic_usage() else: topicname = arg else: hms_topic_usage() s = Client(topicname) icehms.run_holon(s)
from time import sleep import sys from test1 import TestHolon from icehms import run_holon if __name__ == "__main__": holon = TestHolon("Holon2") holon.other = ("Holon1") run_holon(holon)
import time import sys from struct import pack, unpack import logging from icehms import Holon, run_holon, hms, Message class Server(Holon): def __init__(self, name, logLevel=logging.INFO): Holon.__init__(self, name, logLevel=logLevel ) def run(self): pub = self._get_publisher("MyTopic") counter = 0 while not self._stopev: counter +=1 #pub.put_message(Message(header="myHeader", arguments=dict(counter=counter, data=pack("=i", counter) ))) msg = Message(header="myHeader", body="myBody", arguments=dict(counter=counter, myArgVal="Something", myName=self.name )) pub.put_message(msg) time.sleep(0.5) def getState(self, current): return ["Running and publishing", str(counter)] if __name__ == "__main__": s = Server("MyPublisher") run_holon(s)
from time import sleep import sys from icehms import run_holon, Holon, hms, Holon_ class Client(Holon): def __init__(self, *args, **kwargs): Holon.__init__(self, *args, **kwargs) def run(self): self.logger.info("Starting waiting for messages") while not self._stopev: if len(self.mailbox) > 0: msg = self.mailbox.pop() self.logger.info( "got message %s:", msg.body) else: sleep(0.1) #def put_message(self, m, c): #print "PPPP" if __name__ == "__main__": import logging holon = Client("Holon2", logLevel=logging.DEBUG) run_holon(holon, logLevel=logging.WARNING)
from icehms import Holon, run_holon class TestHolon(Holon): def __init__(self, name, logLevel=logging.INFO): Holon.__init__(self, name, logLevel=logLevel) def run(self): self.logger.info("I am "+ self.name) while not self._stopev: listprx = self._icemgr.find_holons("::mymodule::KHolon") tmp = self._icemgr.find_holons("::hms::myproject::CustomHolon") listprx += tmp if listprx: for prx in listprx: try: self.logger.info( "Calling %s of type %s custom method which returns: %s", prx.get_name(), prx.ice_id(), prx.customMethod() ) self.logger.info(prx) except Ice.Exception as why: self.logger.info("Exception while querying proxy: %s", why) else: self.logger.info("No KHolon found") sleep(1) if __name__ == "__main__": holon = TestHolon("MyServerHolon") run_holon(holon)
conv.put_message(stopmsg) pose = msg.arguments["WorldPositionMatrix"] print("We have a part at", pose) print("We are at: ", ur.getl()) pose = [float(i) for i in pose.split(",")] pose = pose[:3] pose[2] += 0.2 print("Moving to: ", pose) ur.translate(pose, 0.8, 0.8) ur.grasp() pose[2] += 0.2 pose[1] -= 1.0 conv.put_message(startmsg) print("start placing at: ", pose) ur.translate(pose, 0.8, 0.8) pose[2] -= 0.2 ur.translate(pose, 0.8, 0.8) print("release") ur.release() print("Moving to init pose") ur.movej(init, 0.01, 1) if __name__ == "__main__": import logging s = CellCtrl() run_holon(s, logLevel=logging.DEBUG)
from time import sleep import sys import Ice from icehms import Holon, run_holon class TestHolon(Holon): def run(self): self.logger.info("I am "+ self.name) sleep(2) self.logger.info("Life is boring, shutting myself down") self.shutdown() if __name__ == "__main__": import logging #logging.basicConfig(level=logging.INFO) holon = TestHolon("HolonAlone", logLevel=logging.INFO) run_holon(holon, auto_shutdown=True)