{"action":"created","issue":{"url":"https://api.github.com/repos/LabPy/labpy-discussion/issues/5","labels_url":"https://api.github.com/repos/LabPy/labpy-discussion/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/LabPy/labpy-discussion/issues/5/comments","events_url":"https://api.github.com/repos/LabPy/labpy-discussion/issues/5/events","html_url":"https://github.com/LabPy/labpy-discussion/issues/5","id":57689225,"number":5,"title":"Descriptor for instrument properties.","user":{"login":"MatthieuDartiailh","id":4481740,"avatar_url":"https://avatars.githubusercontent.com/u/4481740?v=3","gravatar_id":"","url":"https://api.github.com/users/MatthieuDartiailh","html_url":"https://github.com/MatthieuDartiailh","followers_url":"https://api.github.com/users/MatthieuDartiailh/followers","following_url":"https://api.github.com/users/MatthieuDartiailh/following{/other_user}","gists_url":"https://api.github.com/users/MatthieuDartiailh/gists{/gist_id}","starred_url":"https://api.github.com/users/MatthieuDartiailh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MatthieuDartiailh/subscriptions","organizations_url":"https://api.github.com/users/MatthieuDartiailh/orgs","repos_url":"https://api.github.com/users/MatthieuDartiailh/repos","events_url":"https://api.github.com/users/MatthieuDartiailh/events{/privacy}","received_events_url":"https://api.github.com/users/MatthieuDartiailh/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":21,"created_at":"2015-02-14T10:39:14Z","updated_at":"2015-02-18T12:50:51Z","closed_at":null,"body":"I think this is the most viable solutions (and is requested for the current implementation of the subsytems). I will describe what I chose to do in Eapii.\r\nIn Eapii each get/set operation is divided in three parts and each part can be customized separately using specially named method (to reserve to the case where the behavior is not standard, ie not well described by simply passing arguments to the descriptor) : \r\n- pre_get : used to perform some check before attempting to read the value. This can be for example checking that the current instrument mode makes sense for the requested value.\r\n- get : This is dedicated to the communication. It can be handled automatically using the HasIProperty to which belongs the descriptor default_get_iproperty method. The get argument of the descriptor is passed to this method (it can be for example the message to send to the instrument).\r\n- post_get : This is dedicated to converting the value to something nice for the user. For example is we do a simple pyvisa query we get a string, here we can convert it to an integer or use a dictionary to  map it a user friendly value.\r\n\r\n- pre_set : Once again it can be used to perform checks but it can also convert the value so that it can be understood by the instrument. (we can do mapping, unit conversion, range checking, etc)\r\n- set : Here also we can simply rely on the HasIProperty default method, which may have been customised for example to automatically add the channel id to the message before calling the driver method.\r\n- post_set : Here we can check whether or not the operation succeeded (checking an error bit for example), by default this rely once more on a default method on the HasIProperty object.\r\n\r\nContrary to what was done in Lantz, I chose to subclass IProperties as to me it made for cleaner code. Another capabilities built-in was the possibility to automatically retry the operation if some error (specified in the driver) happened. This was requested by one of my users as some instrument would crash on a communication but work after reopening the connection.\r\n\r\nI think there is room to improve this system so please comment !"},"comment":{"url":"https://api.github.com/repos/LabPy/labpy-discussion/issues/comments/74858720","html_url":"https://github.com/LabPy/labpy-discussion/issues/5#issuecomment-74858720","issue_url":"https://api.github.com/repos/LabPy/labpy-discussion/issues/5","id":74858720,"user":{"login":"MatthieuDartiailh","id":4481740,"avatar_url":"https://avatars.githubusercontent.com/u/4481740?v=3","gravatar_id":"","url":"https://api.github.com/users/MatthieuDartiailh","html_url":"https://github.com/MatthieuDartiailh","followers_url":"https://api.github.com/users/MatthieuDartiailh/followers","following_url":"https://api.github.com/users/MatthieuDartiailh/following{/other_user}","gists_url":"https://api.github.com/users/MatthieuDartiailh/gists{/gist_id}","starred_url":"https://api.github.com/users/MatthieuDartiailh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MatthieuDartiailh/subscriptions","organizations_url":"https://api.github.com/users/MatthieuDartiailh/orgs","repos_url":"https://api.github.com/users/MatthieuDartiailh/repos","events_url":"https://api.github.com/users/MatthieuDartiailh/events{/privacy}","received_events_url":"https://api.github.com/users/MatthieuDartiailh/received_events","type":"User","site_admin":false},"created_at":"2015-02-18T12:50:50Z","updated_at":"2015-02-18T12:50:50Z","body":"I would actually favor using action for measurement, to make a clear difference between a fetch (value is read in the buffer of the instrument directly) and a measure (the instrument tries to be smart about the measure and optimize some parameters). The distinction is common in multimeters for example. But I am not sure about others. I though we would discuss this later but miss the link.\r\n\r\nHowever if the cache is an option (per Feature) defaulting to True you could still set False for a measure so that you always read the instrument. "}}