Title: Access Rsync event · pyControl · Discussion #162 · GitHub
Open Graph Title: Access Rsync event · pyControl · Discussion #162
X Title: Access Rsync event · pyControl · Discussion #162
Description: Access Rsync event
Open Graph Description: Hello, This may be fairly trivial and hopefully possible. I'm trying to listen to when a rsync event occurs while a task is being run, have a conditional catch it, and in my case have an LED turn o...
X Description: Hello, This may be fairly trivial and hopefully possible. I'm trying to listen to when a rsync event occurs while a task is being run, have a conditional catch it, and in my case have an LED tu...
Opengraph URL: https://github.com/orgs/pyControl/discussions/162
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"QAPage","mainEntity":{"@type":"Question","name":"Access Rsync event","text":"Hello,
\nThis may be fairly trivial and hopefully possible. I'm trying to listen to when a rsync event occurs while a task is being run, have a conditional catch it, and in my case have an LED turn on every time a pulse goes out.
\nThe issue is that when I do have a conditional listening to rsync events (which are successfully going out and logging), nothing occurs. I'm assuming I'm referencing it wrong.
\nBelow is a short example.
\n from pyControl.utility import *\n from devices import *\n import hardware_definition as hw\n\n sync_output = Rsync(pin=board.BNC_1, event_name='rsync', mean_IPI=1000)\n\n states = [\"trial\"]\n\n events = [\"session_timer\", \"rsync\"]\n\n initial_state = \"trial\"\n\n\n def trial(event):\n\n if event == \"rsync\":\n #--------> Do something <--------------\n
","upvoteCount":1,"answerCount":3,"acceptedAnswer":{"@type":"Answer","text":"The rsync event does not get processed by the state machine, it just goes straight to the data log. The line of interest is
\n \n \n code/source/pyControl/hardware.py\n
\n \n Line 509\n in\n e6fe329\n
\n \n \n \n\n \n \n fw.data_output_queue.put(fw.Datatuple(fw.current_time, fw.EVENT_TYP, \"s\", self.event_ID)) \n \n
\n \n\n\nI believe this is intentional so the sync signal is as low overhead as possible? @ThomasAkam, should we add an option to the Rsync initialization for sending the event to the event queue? Something like...
\nclass Rsync(IO_object):\n # Class for generating sync pulses with random inter-pulse interval.\n\n def __init__(self, pin, event_name=\"rsync\", mean_IPI=5000, pulse_dur=50, process_event=False):\n assert 0.1 * mean_IPI > pulse_dur, \"0.1*mean_IPI must be greater than pulse_dur\"\n self.sync_pin = pyb.Pin(pin, pyb.Pin.OUT)\n self.event_name = event_name\n self.pulse_dur = pulse_dur # Sync pulse duration (ms)\n self.process_event = process_event\n self.min_IPI = int(0.1 * mean_IPI)\n self.max_IPI = int(1.9 * mean_IPI)\n assign_ID(self)\n\n def _initialise(self):\n self.event_ID = sm.events[self.event_name] if self.event_name in sm.events else False\n\n def _run_start(self):\n if self.event_ID:\n self.state = False # Whether output is high or low.\n self._timer_callback()\n\n def _run_stop(self):\n self.sync_pin.value(False)\n\n def _timer_callback(self):\n if self.state: # Pin high -> low, set timer for next pulse.\n timer.set(randint(self.min_IPI, self.max_IPI), fw.HARDW_TYP, \"\", self.ID)\n else: # Pin low -> high, set timer for pulse duration.\n timer.set(self.pulse_dur, fw.HARDW_TYP, \"\", self.ID)\n if self.process_event:\n fw.event_queue.put(fw.Datatuple(fw.current_time, fw.EVENT_TYP, \"s\", self.event_ID))\n else:\n fw.data_output_queue.put(fw.Datatuple(fw.current_time, fw.EVENT_TYP, \"s\", self.event_ID))\n self.state = not self.state\n self.sync_pin.value(self.state)
","upvoteCount":1,"url":"https://github.com/orgs/pyControl/discussions/162#discussioncomment-14821569"}}}
| route-pattern | /_view_fragments/Voltron::DiscussionsFragmentsController/show/orgs/:org/:discussion_number/discussion_layout(.:format) |
| route-controller | voltron_discussions_fragments |
| route-action | discussion_layout |
| fetch-nonce | v2:f123fbf3-8f20-4cbb-46ee-5feaf8ee211d |
| current-catalog-service-hash | 9f0abe34da433c9b6db74bffa2466494a717b579a96b30a5d252e5090baea7be |
| request-id | E286:871AF:1A988:24544:698E14A2 |
| html-safe-nonce | a211558559df1410b5b9e28bad9c6b481f4e76c46bd5620cba0186e4ccfa83f3 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMjg2Ojg3MUFGOjFBOTg4OjI0NTQ0OjY5OEUxNEEyIiwidmlzaXRvcl9pZCI6IjYzMDcyNjgyNzYwNTg0NjEzNDYiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 8baddb3c40a8e5e215d35c454dabb9d1175b5c90dc8d56912a069e0b0fb6151d |
| hovercard-subject-tag | discussion:9086883 |
| github-keyboard-shortcuts | repository,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/Voltron::DiscussionsFragmentsController/show/orgs/pyControl/162/discussion_layout |
| twitter:image | https://opengraph.githubassets.com/dd92ed3739efdaa18ea37470cca4e0bf7cdfe2e7a1edfc5233f7f7ecc84502b2/orgs/pyControl/discussions/162 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/dd92ed3739efdaa18ea37470cca4e0bf7cdfe2e7a1edfc5233f7f7ecc84502b2/orgs/pyControl/discussions/162 |
| og:image:alt | Hello, This may be fairly trivial and hopefully possible. I'm trying to listen to when a rsync event occurs while a task is being run, have a conditional catch it, and in my case have an LED turn o... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | fdf74c91c9ac187cc5cd7b14d4af2d6ef3e18136d002f5d36253f8538e97ee4c |
| turbo-cache-control | no-preview |
| octolytics-dimension-user_id | 58780920 |
| octolytics-dimension-user_login | pyControl |
| octolytics-dimension-repository_id | 219033872 |
| octolytics-dimension-repository_nwo | pyControl/code |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 219033872 |
| octolytics-dimension-repository_network_root_nwo | pyControl/code |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 1a5a3e7bbfb3486980e340c242368684156fba87 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width