def test_inst(self): self.cfg = ConfigParser() self.cfg.read(os.getenv("MACHINEKIT_INI")) self.uuid = self.cfg.get("MACHINEKIT", "MKUUID") rt = rtapi.RTAPIcommand(uuid=self.uuid) rt.loadrt("icomp") rt.newinst("icomp", "foo") assert len(hal.instances) == 1 rt.newinst("icomp", "bar") assert len(hal.instances) == 2 rt.delinst("foo") assert len(hal.instances) == 1 with pytest.raises(RuntimeError): # HAL error: duplicate component name 'icomp' c = hal.Component("icomp") c = hal.components["icomp"] for name in hal.instances: inst = hal.instances[name] assert c.id == inst.owner_id assert c.name == inst.owner.name assert "foo" in hal.instances assert "bar" in hal.instances assert hal.instances["foo"].size > 0 assert hal.instances["bar"].size > 0 try: x = hal.instances["nonexistent"] raise "should not happen" except NameError: pass
def setUp(self): self.cfg = ConfigParser.ConfigParser() self.cfg.read(os.getenv("MACHINEKIT_INI")) self.uuid = self.cfg.get("MACHINEKIT", "MKUUID") rt = rtapi.RTAPIcommand(uuid=self.uuid) rt.loadrt("icomp") rt.newinst("icomp", "foo") assert len(instances) == 1 rt.newinst("icomp", "bar") assert len(instances) == 2 rt.delinst("foo") assert len(instances) == 1 c = hal.Component("icomp") for i in instances: assert c.id == i.owner_id assert c.name == i.owner().name assert "foo" in instances assert "bar" in instances assert instances["foo"].size > 0 assert instances["bar"].size > 0 try: x = instances["nonexistent"] raise "should not happen" except NameError: pass
def setUp(self): self.cfg = ConfigParser() self.cfg.read(os.getenv("MACHINEKIT_INI")) self.uuid = self.cfg.get("MACHINEKIT", "MKUUID") self.rt = rtapi.RTAPIcommand(uuid=self.uuid) self.rt.newinst("or2", "or2.0") self.rt.newthread("servo-thread", 1000000, fp=True) hal.addf("or2.0", "servo-thread") hal.start_threads()
def multiframe_ring(name): try: r = hal.Ring(name) except RuntimeError: r = hal.Ring(name, size=16384, flags=hal.RINGTYPE_MULTIPART) return (r, hal.MultiframeRing(r)) subprocess.call("realtime restart", shell=True, stderr=subprocess.STDOUT) # connect to RTAPI cfg = ConfigParser.ConfigParser() cfg.read(os.getenv("MACHINEKIT_INI")) uuid = cfg.get("MACHINEKIT", "MKUUID") rt = rtapi.RTAPIcommand(uuid=uuid) # setup zeroMQ socket and poller context = zmq.Context() socket = context.socket(zmq.ROUTER) socket.bind("tcp://127.0.0.1:5700") poller = zmq.Poller() poller.register(socket, zmq.POLLIN) # allocate the rings (command, mfcommand) = multiframe_ring(cname) (response, mfresponse) = multiframe_ring(rname) # reflect role - visible in halcmd: command.writer = os.getpid() response.reader = os.getpid()
def test_rtapi_connect(self): global uuid, rt cfg = ConfigParser() cfg.read(os.getenv("MACHINEKIT_INI")) uuid = cfg.get("MACHINEKIT", "MKUUID") rt = rtapi.RTAPIcommand(uuid=uuid)
def setUp(self): global rt self.cfg = ConfigParser.ConfigParser() self.cfg.read(os.getenv("MACHINEKIT_INI")) self.uuid = self.cfg.get("MACHINEKIT", "MKUUID") rt = rtapi.RTAPIcommand(uuid=self.uuid)
def test_rtapi_connect(): global rt rt = rtapi.RTAPIcommand(uuid=uuid)