{"action":"created","comment":{"url":"https://api.github.com/repos/CampbellGroup/common/pulls/comments/57517670","id":57517670,"diff_hunk":"@@ -0,0 +1,227 @@\n+\"\"\"\n+### BEGIN NODE INFO\n+[info]\n+name = eVPump\n+version = 1.0\n+description = \n+instancename = eVPump\n+[startup]\n+cmdline = %PYTHON% %FILE%\n+timeout = 20\n+[shutdown]\n+message = 987654321\n+timeout = 20\n+### END NODE INFO\n+\"\"\"\n+\n+'''\n+Created on Mar 25, 2016\n+\n+@author: Anthony Ransford\n+'''\n+\n+UPDATECURR = 150327\n+UPDATEPOW = 114327\n+UPDATETMP = 153422\n+UPDATESTAT = 356575\n+\n+from common.lib.servers.serialdeviceserver import SerialDeviceServer, setting, inlineCallbacks, SerialDeviceError, SerialConnectionError\n+from twisted.internet import reactor\n+from labrad.server import Signal\n+from labrad import types as T\n+from twisted.internet.defer import returnValue\n+from labrad.support import getNodeName\n+from labrad.units import WithUnit as U\n+\n+SERVERNAME = 'eVPump'\n+TIMEOUT = 1.0\n+BAUDRATE = 115200\n+\n+class eVPump(SerialDeviceServer):\n+    name = SERVERNAME\n+    regKey = 'eVPump'\n+    port = None\n+    serNode = getNodeName()\n+    timeout = T.Value(TIMEOUT,'s')\n+    temperature = None\n+    power = None\n+    current = None\n+    status = None\n+\n+    currentchanged = Signal(UPDATECURR, 'signal: current changed', 'v')\n+    powerchanged = Signal(UPDATEPOW, 'signal: power changed', 'v')\n+    temperaturechanged = Signal(UPDATETMP, 'signal: temp changed', 'v')\n+    statuschanged = Signal(UPDATESTAT, 'signal: stat changed', 's')\n+    \n+    @inlineCallbacks\n+    def initServer( self ):\n+        if not self.regKey or not self.serNode: \n+            raise SerialDeviceError( 'Must define regKey and serNode attributes' )\n+        port = yield self.getPortFromReg( self.regKey )\n+        self.port = port\n+        print port\n+        try:\n+            serStr = yield self.findSerial( self.serNode )\n+            self.initSerial( serStr, port, baudrate = BAUDRATE )\n+        except SerialConnectionError, e:\n+            self.ser = None\n+            if e.code == 0:\n+                print 'Could not find serial server for node: %s' % self.serNode\n+                print 'Please start correct serial server'\n+            elif e.code == 1:\n+                print 'Error opening serial connection'\n+                print 'Check set up and restart serial server'\n+            else: raise\n+        self.measure_pump()\n+\n+    @setting(1, 'toggle laser', value = 'b')\n+    def toggle_laser(self, c, value):\n+        if value:\n+            yield self.ser.write_line('ON')\n+        else:\n+            yield self.ser.write_line('OFF')\n+            \n+    @setting(2, 'toggle shutter', value = 'b')\n+    def toggle_shutter(self, c, value):\n+        if value:\n+            yield self.ser.write_line('SHT:1')\n+        else:\n+            yield self.ser.write_line('SHT:0')\n+            \n+    @setting(3, 'set power', value = 'v[W]')\n+    def set_power(self, c, value):\n+        value = str(value['W'])\n+        yield self.ser.write_line('P:' + value)\n+        \n+    @setting(4, 'read power', returns = 'v[W]')\n+    def read_power(self,c):\n+        yield None\n+        returnValue(self.power)\n+        \n+    @setting(5, 'set current', value = 'v[A]')\n+    def set_current(self, c, value):\n+        value = str(value['A'])\n+        yield self.ser.write_line('C1:' + value)\n+        \n+    @setting(6, 'read current', returns = 'v[A]')\n+    def read_current(self,c):\n+        yield None\n+        returnValue(self.current)\n+\n+    @setting(7, 'diode status', returns = 'b')\n+    def diode_status(self,c):\n+        yield self.ser.write_line('?D')\n+        value = yield self.ser.read_line()\n+        value = bool(float(value))\n+        returnValue(value)\n+        \n+    @setting(8, 'system status', returns = 's')\n+    def system_status(self,c):\n+        yield None\n+        returnValue(self.status)\n+        \n+    @setting(9, 'get power setpoint', returns = 'v[W]')\n+    def get_power_setpoint(self, c):\n+        yield self.ser.write_line('?PSET')\n+        value = yield self.ser.read_line()\n+        value = U(float(value), 'W')\n+        returnValue(value)\n+        \n+    @setting(15, 'get current setpoint', returns = 'v[A]')\n+    def get_current_setpoint(self, c):\n+        yield self.ser.write_line('?CS1')\n+        value = yield self.ser.read_line()\n+        if value:\n+            value = U(float(value), 'A')\n+        else:\n+            value = U(0.0, 'A')\n+        returnValue(value)\n+        \n+    @setting(10, 'get shutter status', returns = 'b')\n+    def get_shutter_status(self, c):\n+        yield self.ser.write_line('?SHT')\n+        value = yield self.ser.read_line()\n+        value = bool(float(value))\n+        returnValue(value)\n+    \n+    @setting(11, 'set control mode', mode = 's')\n+    def set_control_mode(self, c, mode):\n+        if mode == 'current':\n+            yield self.ser.write_line('M:0')\n+        elif mode == 'power':\n+            yield self.ser.write_line('M:1')            \n+        else:\n+            yield None\n+            \n+    @setting(12, 'get control mode', returns = 's')\n+    def get_control_mode(self, c):\n+        yield self.ser.write_line('?M')\n+        value = yield self.ser.read_line()\n+        if value == '0':\n+            value = 'current'\n+        elif value == '1':\n+            value = 'power'\n+        else:\n+            value = None\n+        returnValue(value)\n+        \n+    @setting(13, 'read temperature', returns = 'v[degC]')\n+    def read_temperature(self,c):\n+        yield None\n+        returnValue(self.temperature)\n+        \n+    @setting(14, 'get diode current limit', returns = 'v[A]')","path":"lib/servers/evPump/evPumpServer.py","position":null,"original_position":173,"commit_id":"b4344755a200afd0fd7d32b6e0e6e254b5b6448f","original_commit_id":"92fa1ca4977d3d2b5055a562c7b6717d79401f72","user":{"login":"gregllong","id":7970506,"avatar_url":"https://avatars.githubusercontent.com/u/7970506?v=3","gravatar_id":"","url":"https://api.github.com/users/gregllong","html_url":"https://github.com/gregllong","followers_url":"https://api.github.com/users/gregllong/followers","following_url":"https://api.github.com/users/gregllong/following{/other_user}","gists_url":"https://api.github.com/users/gregllong/gists{/gist_id}","starred_url":"https://api.github.com/users/gregllong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gregllong/subscriptions","organizations_url":"https://api.github.com/users/gregllong/orgs","repos_url":"https://api.github.com/users/gregllong/repos","events_url":"https://api.github.com/users/gregllong/events{/privacy}","received_events_url":"https://api.github.com/users/gregllong/received_events","type":"User","site_admin":false},"body":"Sorry Tony I think I'm just confused. where are the two different functioins? I thought we just have a function named ```read_temperature``` which gets wrapped by the settings decorator. If I did not have anything in the settings decorator string, and I want to call the function from the server after the function name gets changed to ```read_temperature_now```, I do not have to change two things in the code, right?","created_at":"2016-03-26T18:43:23Z","updated_at":"2016-03-26T18:43:23Z","html_url":"https://github.com/CampbellGroup/common/pull/80#discussion_r57517670","pull_request_url":"https://api.github.com/repos/CampbellGroup/common/pulls/80","_links":{"self":{"href":"https://api.github.com/repos/CampbellGroup/common/pulls/comments/57517670"},"html":{"href":"https://github.com/CampbellGroup/common/pull/80#discussion_r57517670"},"pull_request":{"href":"https://api.github.com/repos/CampbellGroup/common/pulls/80"}}},"pull_request":{"url":"https://api.github.com/repos/CampbellGroup/common/pulls/80","id":64222926,"html_url":"https://github.com/CampbellGroup/common/pull/80","diff_url":"https://github.com/CampbellGroup/common/pull/80.diff","patch_url":"https://github.com/CampbellGroup/common/pull/80.patch","issue_url":"https://api.github.com/repos/CampbellGroup/common/issues/80","number":80,"state":"open","locked":false,"title":"Amr/e v pump server","user":{"login":"aransfor","id":5297978,"avatar_url":"https://avatars.githubusercontent.com/u/5297978?v=3","gravatar_id":"","url":"https://api.github.com/users/aransfor","html_url":"https://github.com/aransfor","followers_url":"https://api.github.com/users/aransfor/followers","following_url":"https://api.github.com/users/aransfor/following{/other_user}","gists_url":"https://api.github.com/users/aransfor/gists{/gist_id}","starred_url":"https://api.github.com/users/aransfor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aransfor/subscriptions","organizations_url":"https://api.github.com/users/aransfor/orgs","repos_url":"https://api.github.com/users/aransfor/repos","events_url":"https://api.github.com/users/aransfor/events{/privacy}","received_events_url":"https://api.github.com/users/aransfor/received_events","type":"User","site_admin":false},"body":"This thing seems pretty robust, runs on RS232. May have some aesthetic things but seems like a good program.","created_at":"2016-03-26T00:46:55Z","updated_at":"2016-03-26T18:43:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e3bd69b004975ce2dfe00818a25230aba3607e80","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/CampbellGroup/common/pulls/80/commits","review_comments_url":"https://api.github.com/repos/CampbellGroup/common/pulls/80/comments","review_comment_url":"https://api.github.com/repos/CampbellGroup/common/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CampbellGroup/common/issues/80/comments","statuses_url":"https://api.github.com/repos/CampbellGroup/common/statuses/b4344755a200afd0fd7d32b6e0e6e254b5b6448f","head":{"label":"CampbellGroup:AMR/eVPump_server","ref":"AMR/eVPump_server","sha":"b4344755a200afd0fd7d32b6e0e6e254b5b6448f","user":{"login":"CampbellGroup","id":7468712,"avatar_url":"https://avatars.githubusercontent.com/u/7468712?v=3","gravatar_id":"","url":"https://api.github.com/users/CampbellGroup","html_url":"https://github.com/CampbellGroup","followers_url":"https://api.github.com/users/CampbellGroup/followers","following_url":"https://api.github.com/users/CampbellGroup/following{/other_user}","gists_url":"https://api.github.com/users/CampbellGroup/gists{/gist_id}","starred_url":"https://api.github.com/users/CampbellGroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CampbellGroup/subscriptions","organizations_url":"https://api.github.com/users/CampbellGroup/orgs","repos_url":"https://api.github.com/users/CampbellGroup/repos","events_url":"https://api.github.com/users/CampbellGroup/events{/privacy}","received_events_url":"https://api.github.com/users/CampbellGroup/received_events","type":"Organization","site_admin":false},"repo":{"id":19996100,"name":"common","full_name":"CampbellGroup/common","owner":{"login":"CampbellGroup","id":7468712,"avatar_url":"https://avatars.githubusercontent.com/u/7468712?v=3","gravatar_id":"","url":"https://api.github.com/users/CampbellGroup","html_url":"https://github.com/CampbellGroup","followers_url":"https://api.github.com/users/CampbellGroup/followers","following_url":"https://api.github.com/users/CampbellGroup/following{/other_user}","gists_url":"https://api.github.com/users/CampbellGroup/gists{/gist_id}","starred_url":"https://api.github.com/users/CampbellGroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CampbellGroup/subscriptions","organizations_url":"https://api.github.com/users/CampbellGroup/orgs","repos_url":"https://api.github.com/users/CampbellGroup/repos","events_url":"https://api.github.com/users/CampbellGroup/events{/privacy}","received_events_url":"https://api.github.com/users/CampbellGroup/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CampbellGroup/common","description":"Shared campbell lab code.","fork":false,"url":"https://api.github.com/repos/CampbellGroup/common","forks_url":"https://api.github.com/repos/CampbellGroup/common/forks","keys_url":"https://api.github.com/repos/CampbellGroup/common/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CampbellGroup/common/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CampbellGroup/common/teams","hooks_url":"https://api.github.com/repos/CampbellGroup/common/hooks","issue_events_url":"https://api.github.com/repos/CampbellGroup/common/issues/events{/number}","events_url":"https://api.github.com/repos/CampbellGroup/common/events","assignees_url":"https://api.github.com/repos/CampbellGroup/common/assignees{/user}","branches_url":"https://api.github.com/repos/CampbellGroup/common/branches{/branch}","tags_url":"https://api.github.com/repos/CampbellGroup/common/tags","blobs_url":"https://api.github.com/repos/CampbellGroup/common/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CampbellGroup/common/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CampbellGroup/common/git/refs{/sha}","trees_url":"https://api.github.com/repos/CampbellGroup/common/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CampbellGroup/common/statuses/{sha}","languages_url":"https://api.github.com/repos/CampbellGroup/common/languages","stargazers_url":"https://api.github.com/repos/CampbellGroup/common/stargazers","contributors_url":"https://api.github.com/repos/CampbellGroup/common/contributors","subscribers_url":"https://api.github.com/repos/CampbellGroup/common/subscribers","subscription_url":"https://api.github.com/repos/CampbellGroup/common/subscription","commits_url":"https://api.github.com/repos/CampbellGroup/common/commits{/sha}","git_commits_url":"https://api.github.com/repos/CampbellGroup/common/git/commits{/sha}","comments_url":"https://api.github.com/repos/CampbellGroup/common/comments{/number}","issue_comment_url":"https://api.github.com/repos/CampbellGroup/common/issues/comments{/number}","contents_url":"https://api.github.com/repos/CampbellGroup/common/contents/{+path}","compare_url":"https://api.github.com/repos/CampbellGroup/common/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CampbellGroup/common/merges","archive_url":"https://api.github.com/repos/CampbellGroup/common/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CampbellGroup/common/downloads","issues_url":"https://api.github.com/repos/CampbellGroup/common/issues{/number}","pulls_url":"https://api.github.com/repos/CampbellGroup/common/pulls{/number}","milestones_url":"https://api.github.com/repos/CampbellGroup/common/milestones{/number}","notifications_url":"https://api.github.com/repos/CampbellGroup/common/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CampbellGroup/common/labels{/name}","releases_url":"https://api.github.com/repos/CampbellGroup/common/releases{/id}","deployments_url":"https://api.github.com/repos/CampbellGroup/common/deployments","created_at":"2014-05-20T20:20:49Z","updated_at":"2016-03-09T00:17:53Z","pushed_at":"2016-03-26T18:30:50Z","git_url":"git://github.com/CampbellGroup/common.git","ssh_url":"git@github.com:CampbellGroup/common.git","clone_url":"https://github.com/CampbellGroup/common.git","svn_url":"https://github.com/CampbellGroup/common","homepage":null,"size":982,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":39,"forks":1,"open_issues":39,"watchers":2,"default_branch":"master"}},"base":{"label":"CampbellGroup:master","ref":"master","sha":"f56071c5e8a2652d6537d93ef7b52d9e0a4c1394","user":{"login":"CampbellGroup","id":7468712,"avatar_url":"https://avatars.githubusercontent.com/u/7468712?v=3","gravatar_id":"","url":"https://api.github.com/users/CampbellGroup","html_url":"https://github.com/CampbellGroup","followers_url":"https://api.github.com/users/CampbellGroup/followers","following_url":"https://api.github.com/users/CampbellGroup/following{/other_user}","gists_url":"https://api.github.com/users/CampbellGroup/gists{/gist_id}","starred_url":"https://api.github.com/users/CampbellGroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CampbellGroup/subscriptions","organizations_url":"https://api.github.com/users/CampbellGroup/orgs","repos_url":"https://api.github.com/users/CampbellGroup/repos","events_url":"https://api.github.com/users/CampbellGroup/events{/privacy}","received_events_url":"https://api.github.com/users/CampbellGroup/received_events","type":"Organization","site_admin":false},"repo":{"id":19996100,"name":"common","full_name":"CampbellGroup/common","owner":{"login":"CampbellGroup","id":7468712,"avatar_url":"https://avatars.githubusercontent.com/u/7468712?v=3","gravatar_id":"","url":"https://api.github.com/users/CampbellGroup","html_url":"https://github.com/CampbellGroup","followers_url":"https://api.github.com/users/CampbellGroup/followers","following_url":"https://api.github.com/users/CampbellGroup/following{/other_user}","gists_url":"https://api.github.com/users/CampbellGroup/gists{/gist_id}","starred_url":"https://api.github.com/users/CampbellGroup/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CampbellGroup/subscriptions","organizations_url":"https://api.github.com/users/CampbellGroup/orgs","repos_url":"https://api.github.com/users/CampbellGroup/repos","events_url":"https://api.github.com/users/CampbellGroup/events{/privacy}","received_events_url":"https://api.github.com/users/CampbellGroup/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CampbellGroup/common","description":"Shared campbell lab code.","fork":false,"url":"https://api.github.com/repos/CampbellGroup/common","forks_url":"https://api.github.com/repos/CampbellGroup/common/forks","keys_url":"https://api.github.com/repos/CampbellGroup/common/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CampbellGroup/common/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CampbellGroup/common/teams","hooks_url":"https://api.github.com/repos/CampbellGroup/common/hooks","issue_events_url":"https://api.github.com/repos/CampbellGroup/common/issues/events{/number}","events_url":"https://api.github.com/repos/CampbellGroup/common/events","assignees_url":"https://api.github.com/repos/CampbellGroup/common/assignees{/user}","branches_url":"https://api.github.com/repos/CampbellGroup/common/branches{/branch}","tags_url":"https://api.github.com/repos/CampbellGroup/common/tags","blobs_url":"https://api.github.com/repos/CampbellGroup/common/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CampbellGroup/common/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CampbellGroup/common/git/refs{/sha}","trees_url":"https://api.github.com/repos/CampbellGroup/common/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CampbellGroup/common/statuses/{sha}","languages_url":"https://api.github.com/repos/CampbellGroup/common/languages","stargazers_url":"https://api.github.com/repos/CampbellGroup/common/stargazers","contributors_url":"https://api.github.com/repos/CampbellGroup/common/contributors","subscribers_url":"https://api.github.com/repos/CampbellGroup/common/subscribers","subscription_url":"https://api.github.com/repos/CampbellGroup/common/subscription","commits_url":"https://api.github.com/repos/CampbellGroup/common/commits{/sha}","git_commits_url":"https://api.github.com/repos/CampbellGroup/common/git/commits{/sha}","comments_url":"https://api.github.com/repos/CampbellGroup/common/comments{/number}","issue_comment_url":"https://api.github.com/repos/CampbellGroup/common/issues/comments{/number}","contents_url":"https://api.github.com/repos/CampbellGroup/common/contents/{+path}","compare_url":"https://api.github.com/repos/CampbellGroup/common/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CampbellGroup/common/merges","archive_url":"https://api.github.com/repos/CampbellGroup/common/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CampbellGroup/common/downloads","issues_url":"https://api.github.com/repos/CampbellGroup/common/issues{/number}","pulls_url":"https://api.github.com/repos/CampbellGroup/common/pulls{/number}","milestones_url":"https://api.github.com/repos/CampbellGroup/common/milestones{/number}","notifications_url":"https://api.github.com/repos/CampbellGroup/common/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CampbellGroup/common/labels{/name}","releases_url":"https://api.github.com/repos/CampbellGroup/common/releases{/id}","deployments_url":"https://api.github.com/repos/CampbellGroup/common/deployments","created_at":"2014-05-20T20:20:49Z","updated_at":"2016-03-09T00:17:53Z","pushed_at":"2016-03-26T18:30:50Z","git_url":"git://github.com/CampbellGroup/common.git","ssh_url":"git@github.com:CampbellGroup/common.git","clone_url":"https://github.com/CampbellGroup/common.git","svn_url":"https://github.com/CampbellGroup/common","homepage":null,"size":982,"stargazers_count":2,"watchers_count":2,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":39,"forks":1,"open_issues":39,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CampbellGroup/common/pulls/80"},"html":{"href":"https://github.com/CampbellGroup/common/pull/80"},"issue":{"href":"https://api.github.com/repos/CampbellGroup/common/issues/80"},"comments":{"href":"https://api.github.com/repos/CampbellGroup/common/issues/80/comments"},"review_comments":{"href":"https://api.github.com/repos/CampbellGroup/common/pulls/80/comments"},"review_comment":{"href":"https://api.github.com/repos/CampbellGroup/common/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CampbellGroup/common/pulls/80/commits"},"statuses":{"href":"https://api.github.com/repos/CampbellGroup/common/statuses/b4344755a200afd0fd7d32b6e0e6e254b5b6448f"}}}}