Package: adam-io
ADAM 6050-D REST API ImplementationADAM 6000-Series Manual6050-D has 12 digital inputs and 6 digital outputs. It can be controlled with http requests. The aim of this repo is to wrap the ADAM API into a convenience module for Event Gates' deep learning platform VIS.Installationpip install adam-ioUsage ExamplesYou can update output state in three steps;Create the ADAM objectCreate/reuse DigitalOutputCall ADAM’s output method with DigitalOutputRead the input state;Call ADAM’s input methodCreate adam objectIP, username, password of ADAM should be already set from APEXfromadamimportADAM6050DasADAMip='192.168.1.1'username='user'password='pass'adam=ADAM(ip,username,password)Construct the digital output objectTo change the state of the outputs, you should create/reuse a DigitalOutput object
After creating the object, the initial state is empty, so making a request straight away changes nothing.fromdigital_ioimportDigitalOutputdo=DigitalOutput()# set every available output to 1do[0]=1do[1]=1do[2]=1do[3]=1do[4]=1do[5]=1You don’t have to set every bit, you can just change the ones you need.fromdigital_ioimportDigitalOutputdo=DigitalOutput()# set DO0 to 1 and DO5 to 0do[0]=1do[5]=0DigitalOutput accepts an array to set the outputs all at oncefromdigital_ioimportDigitalOutput# set every available output to 1initial_array=[1,1,1,1,1,1,1]do=DigitalOutput(array=initial_array)Change the stateAfter creating adam and setting the digital outputs, make the request by calling the output method of ADAM and pass the digitalOuput object as argument.fromadamimportADAM6050DasADAMfromdigital_ioimportDigitalOutputip='192.168.1.1'username='user'password='pass'adam=ADAM(ip,username,password)do=DigitalOutput()# set DO0 to 1 and DO5 to 0do[0]=1do[5]=0# request the state changetry:adam.output(do)exceptExceptionaserr:print(err)Read the state of outputYou can get the current state by calling the digitalOutput object without an argumentcurrent_output=adam.output()# state of DO0current_output[0]Read the state of inputTo read the input state, call input() on ADAM. You can pass in the id of a specific input if you want. Otherwise every input value is retrievedinput_id=0di_0=adam.input(input_id)# value of DI0print(di_0)di=adam.input(input_id)# digital inputsprint(di[0])# DI0print(di[1])# DI1###print(di[10])# DI10print(di[11])# DI11LICENSEMIT LicenseCopyright (c) 2020 Event GatesPermission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the “Software”), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.