'''Some basic examples using Espec North America's web controller RESTful APIrequires the requests library: http://docs.python-requests.org/en/master/'''importrequests,json,timedefpprint(data):print(json.dumps(data,sort_keys=True,indent=4))uri='http://10.30.200.254/api/v1.0/chambers/1'headers={'Content-type':'application/json'}# 1) Turn on the environmental chamber.print('\n\nRun constant mode:')pprint(requests.post(uri+'/operations/constant').json())# 2) Turn on humidity control.data=[{'controller':1,'N':2,'enable':True}#Humidity]pprint(requests.post(uri+'/loops',data=json.dumps(data),headers=headers).json())# 3/4) Set the temperature/humidity set pointdata=[{'controller':1,'N':1,'enable':True,'setValue':45},#Temperature{'controller':1,'N':2,'enable':True,'setValue':55}#Humidity]pprint(requests.post(uri+'/loops',data=json.dumps(data),headers=headers).json())# 5/6) Read the temperature/humidityprint('Get control loop status')pprint(requests.get(uri+'/loops').json())# 7) Turn off the chamber.print('\n\nStop operation for 10 seconds:')pprint(requests.post(uri+'/operations/standby').json())
Comments (0)
HTTPSSSH
You can clone a snippet to your computer for local editing.
Learn more.