def get_cnc_hal(log): print 'get_cnc_hal', log engine = uconfig['cnc']['engine'] if engine == 'mock': return cnc_hal.MockHal(log=log) elif engine == 'lcnc-py': import linuxcnc return lcnc_hal.LcncPyHal(linuxcnc=linuxcnc, log=log) elif engine == 'lcnc-rpc': host = uconfig["cnc"]["lcnc"]["host"] try: return lcnc_hal.LcncPyHal(linuxcnc=LCNCRPC(host=host), log=log) except socket.error: raise raise Exception("Failed to connect to LCNCRPC %s" % host) elif engine == 'lcnc-arpc': host = uconfig["cnc"]["lcnc"]["host"] return lcnc_ar.LcncPyHalAr(host=host, log=log) elif engine == 'lcnc-rsh': return lcnc_hal.LcncRshHal(log=log) else: raise Exception("Unknown CNC engine %s" % engine) ''' # pr0ndexer (still on MicroControle hardware though) elif engine == 'pdc': try: #return PDC(debug=False, log=log, config=config) return cnc_hal.PdcHal(log=log) except IOError: print 'Failed to open PD device' raise ''' '''
def run(cnc_host, dry, width, height, fnout, step, samples=1, force=False): hal = None try: print print 'Initializing LCNC' hal = lcnc_ar.LcncPyHalAr(host=cnc_host, dry=dry, log=None) print print 'Initializing programmer' bp = startup.get() fout = None if not force and os.path.exists(fnout): raise Exception("Refusing to overwrite") if not dry: fout = open(fnout, 'w') print print 'Running' do_run(hal=hal, bp=bp, width=width, height=height, dry=dry, fout=fout, xstep=step, ystep=step, samples=samples) finally: print 'Shutting down hal' if hal: hal.ar_stop()
def main(): parser = argparse.ArgumentParser(description='Use ezlaze to fuzz dice') #parser.add_argument('--prog', default='/dev/ttyUSB0', help='minipro serial port') parser.add_argument('--prog-dev', default='pic16f84', help='microchip device') parser.add_argument('--cnc', default='mk-bs', help='LinuxCNC host') parser.add_argument('--dry', action='store_true', help='Dry run') parser.add_argument('fout', nargs='?', default='pwrmap.csv', help='Store data to') args = parser.parse_args() if os.path.exists(args.fout): raise Exception("Refusing to overwrite") hal = None elt = None try: print print 'Initializing LCNC' hal = lcnc_ar.LcncPyHalAr(host=args.cnc, dry=args.dry, log=None) print print 'Initializing programmer' prog = Minipro(device=args.prog_dev) # frickin laser print print 'Initializing laser' el = EzLaze(args.ezlaze) # Max speed ''' Readout should complete within 0.601 sec (command line) At 5 hz need at least 4 pulses, lets do 5 (1.0 sec) ''' el.pulse(hz=5) el.burst(n=5) elt = ELT(el) elt.start() print print 'Running' run(hal, prog, el, elt, fout=args.fout, dry=args.dry) finally: print 'Shutting down laser thread' if elt: elt.running = False print 'Shutting down hal' if hal: hal.ar_stop()
if __name__ == "__main__": parser = argparse.ArgumentParser(description='Use ezlaze with LinuxCNC to carve a bitmap') parser.add_argument('--dmm', default='/dev/serial/by-id/usb-Prologix_Prologix_GPIB-USB_Controller_PX8ZBY4W-if00-port0', help='K2750 serial port') parser.add_argument('--laser', default='/dev/serial/by-id/usb-1a86_USB2.0-Ser_-if00-port0', help='ezlaze serial port') parser.add_argument('--host', default='mk', help='LinuxCNC host') parser.add_argument('--dry', action='store_true', help='Dry run') parser.add_argument('fout', nargs='?', default='cwmap.pv', help='Store data to') args = parser.parse_args() if os.path.exists(args.fout): raise Exception("Refusing to overwrite") hal = None try: print print 'Initializing LCNC' hal = lcnc_ar.LcncPyHalAr(host=args.host, dry=args.dry, log=None) print print 'Initializing DMM' dmm = K2750(args.dmm) print print 'Running' main3(hal, dmm) finally: print 'Shutting down hal' if hal: hal.ar_stop()
'%0.1f' % dt, '%0.4f' % z, stepn, stat_step.pulsesl ] cw.writerow(row) fd.flush() print row break if __name__ == '__main__': parser = argparse.ArgumentParser(description='Replay captured USB packets') parser.add_argument('--verbose', '-v', action='store_true', help='verbose') parser.add_argument('fn', nargs='?', default='out.csv', help='csv out') args = parser.parse_args() hal = None try: print 'Initializing HAL' hal = lcnc_ar.LcncPyHalAr(host='cnc', username='******', dry=False, log=None) #hal._cmd('G91 G1 Z0.01 F1') cap(hal, args.fn) #print hal.limit() #hal.mv_abs({'z': 0}, limit=False) finally: print 'Shutting down hal' if hal: hal.ar_stop()
add_bool_arg(parser, '--dry', default=True, help='Due to health hazard, default is True') parser.add_argument('scan_json', nargs='?', default='scan.json', help='Scan parameters JSON') parser.add_argument('out', nargs='?', default='out/default', help='Output directory') args = parser.parse_args() if os.path.exists(args.out): if not args.overwrite: raise Exception("Refusing to overwrite") shutil.rmtree(args.out) if not args.dry: os.mkdir(args.out) wps = WPS7() imager = XrayImager(dry=args.dry) #imager = MockImager() hal = lcnc_ar.LcncPyHalAr(host=args.host, local_ini='config/xray/rsh.ini', dry=args.dry) try: #config = get_config() ''' 2015-10-03 improved calibration p4/x-ray/04_l_65kvp_75map/png/c000_r000.png slot length meas: 5.4 mm 398 - 101 pix = 297 pix 297 / 5.4 mm = 55 pix / mm mm / pix = 1 / 55. = 0.018181818 Was using: 0.019221622 (1.400 x 1.017") This makes the sensor (including unusable areas): 1344 / 55 = 24.4 mm => 0.962" 1850 / 55 = 33.6 mm => 1.324" 1.324 x 0.962"
#!/usr/bin/env python from uvscada.cnc_hal import lcnc_ar import argparse import time if __name__ == "__main__": parser = argparse.ArgumentParser( description='LinuxCNC automatic remote client test') parser.add_argument('host', help='Host') args = parser.parse_args() hal = None try: hal = lcnc_ar.LcncPyHalAr(host=args.host, dry=False, log=None) hal.home() print hal.limit() #time.sleep(1) print 'getting ready to hal' hal._cmd('G90 G0 X100') hal._cmd('G90 G0 X0') print 'Movement done' #hal.mv_rel({'x': ) finally: print 'Shutting down hal' if hal: hal.ar_stop()