Title: Out records without an initial_value cannot be correctly validated · Issue #43 · DiamondLightSource/pythonSoftIOC · GitHub
Open Graph Title: Out records without an initial_value cannot be correctly validated · Issue #43 · DiamondLightSource/pythonSoftIOC
X Title: Out records without an initial_value cannot be correctly validated · Issue #43 · DiamondLightSource/pythonSoftIOC
Description: If an out record is constructed without an initial_value or has no set() called before the IOC is initialised, validate methods will not work as expected - they won't work at all. An example program is: # Import the basic framework compo...
Open Graph Description: If an out record is constructed without an initial_value or has no set() called before the IOC is initialised, validate methods will not work as expected - they won't work at all. An example progra...
X Description: If an out record is constructed without an initial_value or has no set() called before the IOC is initialised, validate methods will not work as expected - they won't work at all. An example pr...
Opengraph URL: https://github.com/DiamondLightSource/pythonSoftIOC/issues/43
X: @github
Domain: github.com
IPv4 address: 140.82.112.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Out records without an initial_value cannot be correctly validated","articleBody":"If an out record is constructed without an `initial_value` or has no `set()` called before the IOC is initialised, `validate` methods will not work as expected - they won't work at all. An example program is:\r\n\r\n```\r\n# Import the basic framework components.\r\nfrom softioc import softioc, builder, asyncio_dispatcher\r\nimport asyncio\r\n\r\n# Create an asyncio dispatcher, the event loop is now running\r\ndispatcher = asyncio_dispatcher.AsyncioDispatcher()\r\n\r\n# Set the record prefix\r\nbuilder.SetDeviceName(\"MY-DEVICE-PREFIX\")\r\n\r\ndef _capture_validate(record, new_val) -> bool:\r\n \"\"\"Check the required records have been set before allowing Capture=1\"\"\"\r\n try:\r\n raise ValueError(\"Test\")\r\n except ValueError:\r\n return False\r\n\r\n return True\r\n\r\n# Create some records\r\nao = builder.boolOut('BO', ZNAM=\"0\", ONAM=\"1\", validate=_capture_validate)\r\n\r\n# Boilerplate get the IOC started\r\nbuilder.LoadDatabase()\r\nsoftioc.iocInit(dispatcher)\r\n\r\n# Finally leave the IOC running with an interactive shell.\r\nsoftioc.interactive_ioc(globals())\r\n```\r\n\r\nAnd running the following commands in the terminal, we see an error message BUT we also see the underlying value has changed:\r\n\r\n```\r\n[...]$ caget MY-DEVICE-PREFIX:BO\r\nMY-DEVICE-PREFIX:BO 0\r\n[...]$ caput MY-DEVICE-PREFIX:BO 1\r\nOld : MY-DEVICE-PREFIX:BO 0\r\nCA.Client.Exception...............................................\r\n Warning: \"Channel write request failed\"\r\n Context: \"op=1, channel=MY-DEVICE-PREFIX:BO, type=DBR_STRING, count=1, ctx=\"MY-DEVICE-PREFIX:BO\"\"\r\n Source File: ../oldChannelNotify.cpp line 160\r\n Current Time: Tue Oct 05 2021 09:30:02.714662686\r\n..................................................................\r\nNew : MY-DEVICE-PREFIX:BO 1\r\n[...]$ caget MY-DEVICE-PREFIX:BO\r\nMY-DEVICE-PREFIX:BO 1\r\n[eyh46967@pc0103 PandABlocks-client]$ \r\n```\r\n\r\n\r\nFollowing a bit of debugging with @Araneidae it seems that all Out records will face similar issues if there is no initial_value set. ","author":{"url":"https://github.com/AlexanderWells-diamond","@type":"Person","name":"AlexanderWells-diamond"},"datePublished":"2021-10-05T08:31:41Z","url":"https://github.com/DiamondLightSource/pythonSoftIOC/issues/43"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:08ac5905-9085-8562-ddae-5a9f808a3989 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 85BE:12379F:3E224D:540588:6B04404A |
| html-safe-nonce | a22c5190dd67b35f4b1cc1cbc098a903ee7455bc0692d003f0b261a40a470eef |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NUJFOjEyMzc5RjozRTIyNEQ6NTQwNTg4OjZCMDQ0MDRBIiwidmlzaXRvcl9pZCI6Ijc5ODgyMTQ2NzA2NzI4MDU5NjIiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 37bb94acad14609602fbf88afc5aa71091ae464a295e45da2a0dab58d319c77b |
| hovercard-subject-tag | issue:1016039015 |
| github-keyboard-shortcuts | repository,issues,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/issues/show/DiamondLightSource/pythonSoftIOC/43/issue_layout |
| twitter:image | https://opengraph.githubassets.com/4657cd5073d5fb3c44296835f08c262a9d08652dce63bb09d51a0944dec31723/DiamondLightSource/pythonSoftIOC/issues/43 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/4657cd5073d5fb3c44296835f08c262a9d08652dce63bb09d51a0944dec31723/DiamondLightSource/pythonSoftIOC/issues/43 |
| og:image:alt | If an out record is constructed without an initial_value or has no set() called before the IOC is initialised, validate methods will not work as expected - they won't work at all. An example progra... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | AlexanderWells-diamond |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9185ccfefd80c1ff2d9ddcdb0cd2becf46b5a1efbbf30741a895e4bb8de25e64 |
| turbo-cache-control | no-preview |
| go-import | github.com/DiamondLightSource/pythonSoftIOC git https://github.com/DiamondLightSource/pythonSoftIOC.git |
| octolytics-dimension-user_id | 1233618 |
| octolytics-dimension-user_login | DiamondLightSource |
| octolytics-dimension-repository_id | 20049394 |
| octolytics-dimension-repository_nwo | DiamondLightSource/pythonSoftIOC |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 20049394 |
| octolytics-dimension-repository_network_root_nwo | DiamondLightSource/pythonSoftIOC |
| 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 | 06dc448a76fe4751ac1db26524aefa3aa3e889a8 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width