examples: add main function

This commit is contained in:
Sebastien Bourdeauducq 2014-10-05 16:24:21 +08:00
parent 53b259b9a0
commit 2f58cf6aff
6 changed files with 24 additions and 6 deletions

View File

@ -32,7 +32,7 @@ class AluminumSpectroscopy(AutoContext):
return state_0_count return state_0_count
if __name__ == "__main__": def main():
from artiq.sim import devices as sd from artiq.sim import devices as sd
from artiq.sim import time from artiq.sim import time
@ -51,3 +51,6 @@ if __name__ == "__main__":
) )
exp.run() exp.run()
print(time.manager.format_timeline()) print(time.manager.format_timeline())
if __name__ == "__main__":
main()

View File

@ -29,7 +29,7 @@ class CompilerTest(AutoContext):
self.print_done() self.print_done()
if __name__ == "__main__": def main():
from artiq.devices import corecom_dummy, core, dds_core from artiq.devices import corecom_dummy, core, dds_core
coredev = core.Core(corecom_dummy.CoreCom()) coredev = core.Core(corecom_dummy.CoreCom())
@ -45,3 +45,6 @@ if __name__ == "__main__":
reg_channel=3, rtio_channel=3) reg_channel=3, rtio_channel=3)
) )
exp.run(3, 100*us) exp.run(3, 100*us)
if __name__ == "__main__":
main()

View File

@ -22,7 +22,7 @@ class DDSTest(AutoContext):
self.led.set(0) self.led.set(0)
if __name__ == "__main__": def main():
with corecom_serial.CoreCom() as com: with corecom_serial.CoreCom() as com:
coredev = core.Core(com) coredev = core.Core(com)
exp = DDSTest( exp = DDSTest(
@ -38,3 +38,6 @@ if __name__ == "__main__":
led=gpio_core.GPIOOut(core=coredev, channel=1) led=gpio_core.GPIOOut(core=coredev, channel=1)
) )
exp.run() exp.run()
if __name__ == "__main__":
main()

View File

@ -38,7 +38,10 @@ class Mandelbrot(AutoContext):
self.row() self.row()
if __name__ == "__main__": def main():
with corecom_serial.CoreCom() as com: with corecom_serial.CoreCom() as com:
exp = Mandelbrot(core=core.Core(com)) exp = Mandelbrot(core=core.Core(com))
exp.run() exp.run()
if __name__ == "__main__":
main()

View File

@ -35,7 +35,7 @@ class PhotonHistogram(AutoContext):
self.report(i, hist[i]) self.report(i, hist[i])
if __name__ == "__main__": def main():
with corecom_serial.CoreCom() as com: with corecom_serial.CoreCom() as com:
coredev = core.Core(com) coredev = core.Core(com)
exp = PhotonHistogram( exp = PhotonHistogram(
@ -49,3 +49,6 @@ if __name__ == "__main__":
nbins=100 nbins=100
) )
exp.run() exp.run()
if __name__ == "__main__":
main()

View File

@ -15,7 +15,7 @@ class SimpleSimulation(AutoContext):
self.d.pulse(400*MHz, 20*us) self.d.pulse(400*MHz, 20*us)
if __name__ == "__main__": def main():
from artiq.sim import devices as sd from artiq.sim import devices as sd
from artiq.sim import time from artiq.sim import time
@ -28,3 +28,6 @@ if __name__ == "__main__":
) )
exp.run() exp.run()
print(time.manager.format_timeline()) print(time.manager.format_timeline())
if __name__ == "__main__":
main()