Skip to content

Pythonic abstraction layer for Nonolith Connect's RESTful API.

License

Notifications You must be signed in to change notification settings

nonolith/connectClientPython

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Pythonic abstraction layer for Nonolith Connect's RESTful API.

This is a simple abstraction layer for the low-speed API provided by Nonolith Connect V1.1.

For API documentation, see The Nonolith Wiki

This Python module provides a 'CEE' class with methods getOutput, setOutputConstant, setOutputRepeating, setOutputArbitrary, getInput, and setInput.


def getOutput(self, channel = "a"):

Return a dictionary containing the output state of a given channel.


def setOutputConstant(self, channel = "a", mode = "d", value = 0):

Set the output state for a given channel.

  • 'mode' can be 'v' to set voltage, 'i' to set current, or 'd' for high impedance mode.
  • 'value' is a number either in volts or milliamps specifying the target value.

def setOutputRepeating(self, channel = "a", mode = "d", value = 0, wave="square", amplitude = 0, frequency = 0, relPhase = 1, phase = 0):

Set the output state for a given channel.

  • 'mode' can be 'v' to set voltage, 'i' to set current, or 'd' for high impedance mode.
  • 'value' is a number either in volts or milliamps specifying the center value in AC mode.
  • 'wave' can be either triangle,' 'square,' or 'sine'.
  • 'amplitude' determines the maximum offset from center.
  • 'frequency' is the cycles per second.
  • 'relPhase' determines whether the starting value is based off of the previous output setting to provide seamless change in frequency.
  • 'phase' is the phase offset in seconds from the beginning of the stream (relPhase=0) or from the previous source (relPhase=1).

def setOutputArbitrary(self, channel = "a", mode = "d", times = [0], values = [0]): 

Set the output state for a given channel.

  • 'mode' can be 'v' to set voltage, 'i' to set current, or 'd' for high impedance mode.
  • 'times' is a list of times in seconds.
  • 'values' is a list of values in SI units, either volts or amps.

def getInput(self, channel = "a", resample = .01, count = 1, start = None):

Returns a pair of list indicating the measured state of the specified channel.

The first list is measured voltage, the second list is measured current.

Each list contains 'count' samples, averaged over 'resample' seconds, separated by 'resample' seconds.

'start' is the sample index from which to start measuring.


def setInput(self, channel = "a", vGain = 1, iGain = 1):

Set the input gain for both streams of a given channel.

Usage examples:

CEE = CEE()
# matches any CEE
CEE.setOutput(mode = "v", wave = "sine", amplitude = 1, value = 1, frequency = 100)
# sources a 100Hz sinewave centered at 1V with a 2V pk-pk amplitude
print(CEE.getInput(resample = 0, count = 100))
# prints 100 un-averaged samples

About

Pythonic abstraction layer for Nonolith Connect's RESTful API.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages