Jump to content

Device Monitor Python scripting


James

Recommended Posts

I hear tell a few folks were wondering about the Run Script feature in Device Monitor->Diagnostics->Advanced. This is mostly meant for scientific study, automation, testing, etc.

The scripting language is IronPython so you can use normal Python libraries to save files and such.
The script runs in a background thread while Device Monitor is running.


As a reference, here are the functions available through the Python scripting at present:

ECig.Puff(time)
Time is in seconds.

ECig.ClearTracking()
Removes all variables from the graph.

ECig.Track(state)
Adds a variable to the graph.

ECig.IsTracked(state)
Returns True if the variable is on the graph.

ECig.StopTracking(state)
Removes a variable from the graph.

Recorder.Record(filename)
Starts recording a CSV file. You can't change which variables are on the graph while recording.

Recorder.StopRecording()
Stops recording a CSV file.

Recorder.IsRecording
Returns True if the Device Monitor is recording.

Serial.Open(portName)
Serial.Open(portName, baudRate)
Opens a serial port. If you do not specify a baud rate, the default is 9600 baud.
You can use the returned object to communicate with a serial device.

UI.Message(text)
Pops up a message box.


The ECig object also has an indexer.

x = ECig[state]

ECig[state] = y


States are strings representing the variables in the device monitor.
For example, ECig['Power Set'], ECig['Current'], ECig['Battery Cell 1'].


Here is a sample script. It records current, voltage, and power while doing 3-second puffs ranging from 5 to 30 watts:

import time

ECig.ClearTracking()
ECig.Track('Current')
ECig.Track('Voltage')
ECig.Track('Power')
Recorder.Record(r'C:\Users\James\Test.csv')

time.sleep(1)
for p in xrange(5, 35, 5):
  ECig['Power Set'] = p
  ECig.Puff(3)
  time.sleep(6)

Recorder.StopRecording()

 

EScribe, starting with 1.2 SP5, includes a short manual with samples for Device Monitor scripting. I've attached it for your convenience.

EScribe.pdf

Link to comment
Share on other sites

  • 1 month later...
  • James changed the title to Device Monitor Python scripting
  • James pinned this topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...