{"action":"created","issue":{"url":"https://api.github.com/repos/m-labs/artiq/issues/529","repository_url":"https://api.github.com/repos/m-labs/artiq","labels_url":"https://api.github.com/repos/m-labs/artiq/issues/529/labels{/name}","comments_url":"https://api.github.com/repos/m-labs/artiq/issues/529/comments","events_url":"https://api.github.com/repos/m-labs/artiq/issues/529/events","html_url":"https://github.com/m-labs/artiq/issues/529","id":167976462,"number":529,"title":"Call seconds_to_mu in build","user":{"login":"r-srinivas","id":11219276,"avatar_url":"https://avatars.githubusercontent.com/u/11219276?v=3","gravatar_id":"","url":"https://api.github.com/users/r-srinivas","html_url":"https://github.com/r-srinivas","followers_url":"https://api.github.com/users/r-srinivas/followers","following_url":"https://api.github.com/users/r-srinivas/following{/other_user}","gists_url":"https://api.github.com/users/r-srinivas/gists{/gist_id}","starred_url":"https://api.github.com/users/r-srinivas/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/r-srinivas/subscriptions","organizations_url":"https://api.github.com/users/r-srinivas/orgs","repos_url":"https://api.github.com/users/r-srinivas/repos","events_url":"https://api.github.com/users/r-srinivas/events{/privacy}","received_events_url":"https://api.github.com/users/r-srinivas/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"whitequark","id":54771,"avatar_url":"https://avatars.githubusercontent.com/u/54771?v=3","gravatar_id":"","url":"https://api.github.com/users/whitequark","html_url":"https://github.com/whitequark","followers_url":"https://api.github.com/users/whitequark/followers","following_url":"https://api.github.com/users/whitequark/following{/other_user}","gists_url":"https://api.github.com/users/whitequark/gists{/gist_id}","starred_url":"https://api.github.com/users/whitequark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whitequark/subscriptions","organizations_url":"https://api.github.com/users/whitequark/orgs","repos_url":"https://api.github.com/users/whitequark/repos","events_url":"https://api.github.com/users/whitequark/events{/privacy}","received_events_url":"https://api.github.com/users/whitequark/received_events","type":"User","site_admin":false},"assignees":[{"login":"whitequark","id":54771,"avatar_url":"https://avatars.githubusercontent.com/u/54771?v=3","gravatar_id":"","url":"https://api.github.com/users/whitequark","html_url":"https://github.com/whitequark","followers_url":"https://api.github.com/users/whitequark/followers","following_url":"https://api.github.com/users/whitequark/following{/other_user}","gists_url":"https://api.github.com/users/whitequark/gists{/gist_id}","starred_url":"https://api.github.com/users/whitequark/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whitequark/subscriptions","organizations_url":"https://api.github.com/users/whitequark/orgs","repos_url":"https://api.github.com/users/whitequark/repos","events_url":"https://api.github.com/users/whitequark/events{/privacy}","received_events_url":"https://api.github.com/users/whitequark/received_events","type":"User","site_admin":false}],"milestone":null,"comments":35,"created_at":"2016-07-27T23:00:14Z","updated_at":"2016-08-04T04:28:14Z","closed_at":null,"body":"We wanted to set some variables in machine units in an experiment subcomponent. It seems like the place to do this would be in the build method. However, as mentioned in #493 calling it in the build raises a ValueError as the `get_device` call for the `core` returns `None.` Is there a better way to do this? It seems like all this conversion needs is the `ref_period`. I've attached the subcomponent we want to use it in below.\r\n\r\n```python\r\nfrom artiq.experiment import *\r\nfrom artiq.language.core import seconds_to_mu\r\n\r\nclass Microwaves(HasEnvironment):\r\n\r\n    def build(self):    \r\n        #  build hardware for experiment\r\n        self.setattr_device(\"core\")\r\n        self.setattr_device(\"dds_box\")\r\n        self.setattr_device(\"ttl_ps0\")\r\n        self.setattr_device(\"ttl_ps1\")\r\n        self.setattr_device(\"ttl_ps2\")\r\n        self.setattr_device(\"ttl_mw_mux\")\r\n        self.setattr_device(\"ttl_mw_ab\")\r\n        \r\n        #  profiles\r\n        self.profiles = [\"3p2_2p2\",\"3p3_2p2\",\"3p1_2p2\", \"3p1_2p1\",\r\n                         \"3p0_2p1\", \"3p0_2m1\", \"3p1_2p0\", \"3p0_2p0\"]\r\n\r\n        self.profile_3p3_2p2 = 1\r\n        self.profile_3p2_2p2 = 0\r\n        self.profile_3p1_2p2 = 2\r\n        self.profile_3p1_2p1 = 3\r\n        self.profile_3p1_2p0 = 6\r\n        self.profile_3p0_2p1 = 4\r\n        self.profile_3p0_2p0 = 7\r\n        self.profile_3p0_2m1 = 5\r\n\r\n        # pi times for population transfers\r\n        self.t_pi_3p3_2p2_e1 = seconds_to_mu(self.get_dataset(\"mw.t_pi.3p3_2p2.e1\"), core=self.core)\r\n        self.t_pi_3p2_2p2_e1 = seconds_to_mu(self.get_dataset(\"mw.t_pi.3p2_2p2.e1\"), core=self.core)   \r\n        self.t_pi_3p1_2p2_e1 = self.get_dataset(\"mw.t_pi.3p1_2p2.e1\")\r\n\r\n        self.t_pi_3p3_2p2_e2 = seconds_to_mu(self.get_dataset(\"mw.t_pi.3p3_2p2.e2\"), core=self.core)\r\n        self.t_pi_3p2_2p2_e2 = seconds_to_mu(self.get_dataset(\"mw.t_pi.3p2_2p2.e2\"), core=self.core)\r\n        \r\n        self.t_pi_3p1_2p2_e2 = self.get_dataset(\"mw.t_pi.3p1_2p2.e2\")         \r\n        #  subclass keyword arguments\r\n        self.scan = self.get_argument('scan')\r\n        self.transition = self.get_argument('transition')\r\n        #  arguments in gui\r\n        if self.scan:\r\n            self.setattr_argument(\"electrode\", NumberValue(1, ndecimals=0,\r\n                                                       scale=1, step=1),\r\n                                                       \"Scan\")\r\n        self.f0 = (self.get_dataset(\"mw.f.\" + self.transition) +\r\n                  self.get_dataset(\"mw.d.\" + self.transition))\r\n        \r\n#==============================================================================\r\n# generic functions\r\n#==============================================================================\r\n    @kernel\r\n    def mw_pulse(self, electrode, profile, time):\r\n        self.set_profile(profile)\r\n        self.pulse_electrode(electrode, time)\r\n\r\n    @kernel\r\n    def pulse_electrode(self, electrode, time):\r\n        if electrode == 0:\r\n            delay_mu(time)\r\n        elif electrode == 1:\r\n            self.ttl_mw_ab.pulse_mu(time)\r\n        elif electrode == 2:\r\n            with parallel:\r\n                self.ttl_mw_mux.pulse_mu(time)                \r\n                self.ttl_mw_ab.pulse_mu(time)\r\n        elif electrode == 3:\r\n            self.ttl_mw_mux.pulse_mu(time)\r\n        \r\n\r\n    @kernel\r\n    def set_profile(self, profile):\r\n        if profile & 4:\r\n            self.ttl_ps2.on()\r\n        else:\r\n            self.ttl_ps2.off()\r\n        delay(1000*ns)        \r\n        if profile & 2:\r\n            self.ttl_ps1.on()\r\n        else:\r\n            self.ttl_ps1.off()\r\n        delay(1000*ns)\r\n        if profile & 1:\r\n            self.ttl_ps0.on()\r\n        else:\r\n            self.ttl_ps0.off()\r\n        #  need delay here to ensure dds profile updated\r\n        delay(1000*ns)\r\n\r\n    def update_profile_dataset(self):\r\n        for i in range(8):\r\n            self.set_dataset('mw.profile.'+self.profiles[i], i,\r\n                         persist=True)\r\n                         \r\n    def set_dds_f(self, profile, frequency):\r\n        self.dds_box.set_profile_frequency(2, profile, frequency/(2*1e6))\r\n        self.dds_box.io_update()\r\n\r\n    def start(self):\r\n        self.dds_box.reset()\r\n        self.dds_box.start_profile_mode(2)\r\n        self.dds_box.io_update()\r\n\r\n#==============================================================================\r\n# transition specific functions\r\n#==============================================================================\r\n\r\n    @kernel\r\n    def pulse_3p3_2p2(self, electrode, time):\r\n        self.mw_pulse(electrode, self.profile_3p3_2p2, time)\r\n\r\n    def set_freq_3p3_2p2(self, frequency):\r\n        self.set_dds_f(self.profile_3p3_2p2, frequency)\r\n\r\n    @kernel\r\n    def pulse_3p2_2p2(self, electrode, time):\r\n        self.mw_pulse(electrode, self.profile_3p2_2p2, time)\r\n\r\n    def set_freq_3p2_2p2(self, frequency):\r\n        self.set_dds_f(self.profile_3p2_2p2, frequency)\r\n        \r\n    @kernel\r\n    def pulse_3p1_2p2(self, electrode, time):\r\n        self.mw_pulse(electrode, self.profile_3p1_2p2, time)\r\n\r\n    def set_freq_3p1_2p2(self, frequency):\r\n        self.set_dds_f(self.profile_3p1_2p2, frequency)\r\n        \r\n    @kernel\r\n    def pulse_3p1_2p1(self, electrode, time):\r\n        self.mw_pulse(electrode, self.profile_3p1_2p1, time)\r\n\r\n    def set_freq_3p1_2p1(self, frequency):\r\n        self.set_dds_f(self.profile_3p1_2p1, frequency)\r\n```"},"comment":{"url":"https://api.github.com/repos/m-labs/artiq/issues/comments/237449456","html_url":"https://github.com/m-labs/artiq/issues/529#issuecomment-237449456","issue_url":"https://api.github.com/repos/m-labs/artiq/issues/529","id":237449456,"user":{"login":"sbourdeauducq","id":720864,"avatar_url":"https://avatars.githubusercontent.com/u/720864?v=3","gravatar_id":"","url":"https://api.github.com/users/sbourdeauducq","html_url":"https://github.com/sbourdeauducq","followers_url":"https://api.github.com/users/sbourdeauducq/followers","following_url":"https://api.github.com/users/sbourdeauducq/following{/other_user}","gists_url":"https://api.github.com/users/sbourdeauducq/gists{/gist_id}","starred_url":"https://api.github.com/users/sbourdeauducq/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sbourdeauducq/subscriptions","organizations_url":"https://api.github.com/users/sbourdeauducq/orgs","repos_url":"https://api.github.com/users/sbourdeauducq/repos","events_url":"https://api.github.com/users/sbourdeauducq/events{/privacy}","received_events_url":"https://api.github.com/users/sbourdeauducq/received_events","type":"User","site_admin":false},"created_at":"2016-08-04T04:28:14Z","updated_at":"2016-08-04T04:28:14Z","body":"For the mor1kx FPU, I would roughly estimate a couple months, at most."}}
{"actor":{"display_login":"sbourdeauducq"}}