Skip to content

Commit

Permalink
Useful updates for future improvement (#2)
Browse files Browse the repository at this point in the history
* Included reading of transfer and elog channels at __init__ to update respective attributes with channels previously set at Oxygen

* Included elogContext method to use elog start and stop in a with statement

* Included missing ELOG timestamp for setElogTimestamp

* Included _localElogStartTime attribute to track locally when Elog started

* Included False return for fetchElog in case of error fetched

* Fixed getTransferChannels timing out when there are no channels available

* Removed unecessary logging when class is initialized by adding the "add_log" flag at _getTransferChannels and _getElogChannels.

* Fixed fetchElog method splitting array unaccordingly when timestamp is set to OFF. Included attribute that stores the elog timestamp.

* Included _convertElogArray method to convert matrix of strings from elog fetch into matrix of float (or datetime) values.

* Included fetchElogAccumulated

* Included elogTimestamp attribute at __init__

* Included error handling for elog example in case of timeout.

* Increased continuous fetching waiting time for elogFetchAccumulate to 50ms and fixed timeout docstring.

* Fixed fetchElogAccumulated not raising Exception for invalid timestamp configurations.

* Included type annotations for some Elog functions.

---------

Co-authored-by: Matthias Straka <[email protected]>
  • Loading branch information
dantonsa and matthiasstraka authored Sep 5, 2023
1 parent 7856861 commit e9203cd
Show file tree
Hide file tree
Showing 2 changed files with 283 additions and 51 deletions.
37 changes: 37 additions & 0 deletions oxygenscpi_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,41 @@
mDevice.storeStop()
print("Recording stopped.")

# Set Elog channels and fetch some elog data
mDevice.setElogChannels(["AI 4/I1","AI 4/I2"])
mDevice.setElogTimestamp('ABS')
mDevice.setElogPeriod(0.01)
print("Starting Elog")
mDevice.startElog()
print("Waiting for 10 seconds...")
time.sleep(10)
print("Fetching elog Data")
data1 = mDevice.fetchElog()
data2 = mDevice.fetchElog()
mDevice.stopElog()
print("Elog stopped.")
if data1:
print(f"First Elog row values fetched: {data1[0]}")
else:
print("Unable to fetch Elog.")
if data2:
print(f"Last Elog row values fetched: {data2[-1]}")
else:
print("Unable to fetch Elog.")

# Alternatively Start elog with context manager and accumulating values
# for 10 seconds
print("Starting Elog with context manager")
mDevice.setElogTimestamp('ELOG')
with mDevice.elogContext():
print("Waiting for 10 seconds...")
time.sleep(10)
print("Fetching Elog")
data = mDevice.fetchElogAccumulated()
print("Elog stopped.")
if data:
print(f"Fetched Elog from timestamp {data[0][0]} to {data[-1][0]}s.")
else:
print("Unable to fetch Elog.")

mDevice.disconnect()
Loading

0 comments on commit e9203cd

Please sign in to comment.