Skip to main content

ADAM 6050-D REST API Python Wrapper

Project description

ADAM 6050-D REST API Implementation

Documentation Status Tests Publish

image

ADAM 6000-Series Manual

6050-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.

Installation

pip install adam-io

Usage Examples

You can update output state in three steps;

  • Create the ADAM object
  • Create/reuse DigitalOutput
  • Call ADAM’s output method with DigitalOutput

Read the input state;

  • Call ADAM’s input method

Create adam object

IP, username, password of ADAM should be already set from APEX

from adam import ADAM6050D as ADAM

ip='192.168.1.1'
username = 'user'
password = 'pass'

adam = ADAM(ip, username, password)

Construct the digital output object

To 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.

from digital_io import DigitalOutput

do = DigitalOutput()
# set every available output to 1
do[0]=1
do[1]=1
do[2]=1
do[3]=1
do[4]=1
do[5]=1

You don’t have to set every bit, you can just change the ones you need.

from digital_io import DigitalOutput

do = DigitalOutput()
# set DO0 to 1 and DO5 to 0
do[0]=1
do[5]=0

DigitalOutput accepts an array to set the outputs all at once

from digital_io import DigitalOutput

# set every available output to 1
initial_array = [1,1,1,1,1,1,1]
do = DigitalOutput(array=initial_array)

Change the state

After creating adam and setting the digital outputs, make the request by calling the output method of ADAM and pass the digitalOuput object as argument.

from adam import ADAM6050D as ADAM
from digital_io import DigitalOutput

ip='192.168.1.1'
username = 'user'
password = 'pass'

adam = ADAM(ip, username, password)

do = DigitalOutput()
# set DO0 to 1 and DO5 to 0
do[0]=1
do[5]=0

# request the state change
try:
    adam.output(do)
except Exception as err:
    print(err)

Read the state of output

You can get the current state by calling the digitalOutput object without an argument

current_output = adam.output()

# state of DO0
current_output[0]

Read the state of input

To 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 retrieved

input_id = 0
di_0 = adam.input(input_id)

# value of DI0
print(di_0)

di = adam.input(input_id)

# digital inputs
print(di[0]) # DI0
print(di[1]) # DI1
#
#
#
print(di[10]) # DI10
print(di[11]) # DI11

LICENSE

MIT License

Copyright (c) 2020 Event Gates

Permission 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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

adam_io-2.1608646378.6553204.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

adam_io-2.1608646378.6553204-py3-none-any.whl (8.8 kB view details)

Uploaded Python 3

File details

Details for the file adam_io-2.1608646378.6553204.tar.gz.

File metadata

  • Download URL: adam_io-2.1608646378.6553204.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.6.12

File hashes

Hashes for adam_io-2.1608646378.6553204.tar.gz
Algorithm Hash digest
SHA256 277daaeb7790b7f6c8abba162c5293fd0fb89b8ed2dc58243c49dcbb7383e9f9
MD5 571b4a95399fca9b74f428f3bc0dffc9
BLAKE2b-256 ffc09cc9ad62f4d291fb392a1968ff17a3d540f0f987259bd5bef69113ba1f78

See more details on using hashes here.

File details

Details for the file adam_io-2.1608646378.6553204-py3-none-any.whl.

File metadata

  • Download URL: adam_io-2.1608646378.6553204-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.25.1 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.54.1 CPython/3.6.12

File hashes

Hashes for adam_io-2.1608646378.6553204-py3-none-any.whl
Algorithm Hash digest
SHA256 873aa7f31e2de836d7cb30e3839df13f5c7c536d0a91f13204c7eb50e926febd
MD5 93e8eb1c71edb188fd94f742050a1d61
BLAKE2b-256 dbf01a9fac43abec809cd9ed8d7fc97fadceacdc22bbda8e7a3665de6f70fb44

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page