{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Axes: >"
      ]
     },
     "execution_count": 4,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "[encoded data, 51284 characters]",
      "text/plain": [
       "<Figure size 640x480 with 1 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    }
   ],
   "source": [
    "from imc_utils.oscilloscope_dsox1204a import DSOX1204A, CommonOperations\n",
    "\n",
    "scope = DSOX1204A()\n",
    "\n",
    "scope.set_volt_scale(3, 1)\n",
    "scope.set_timebase(0.2)\n",
    "scope.set_timebase_reference_left()\n",
    "\n",
    "scope.set_trigger_rising_edge(3, 3)\n",
    "scope.aquire_single()\n",
    "\n",
    "result = {}\n",
    "result[\"eps_power_on\"] = scope.get_waveform(3)\n",
    "result[\"vdd\"] = scope.get_waveform(1)\n",
    "result[\"task\"] = scope.get_waveform(2)\n",
    "pd.DataFrame(result).plot()\n",
    "\n",
    "eps_rising = CommonOperations.get_rising_edge_index(result[\"eps_power_on\"])\n",
    "print(eps_rising)\n",
    "\n",
    "# scope.handle.write(\":TRIG:MODE EDGE\")\n",
    "# scope.handle.write(\":TRIG:EDGE:SOUR CHAN3\")\n",
    "# scope.handle.write(\":TRIG:EDGE:LEV 3\")\n",
    "# scope.handle.write(\":TRIG:EDGE:SLOP POSitive\")\n",
    "\n",
    "# scope.handle.write(\":ACQ:COUN 1\")\n",
    "\n",
    "# scope.handle.write(\":CHAN3:SCALe 1\")\n",
    "# scope.handle.write(\":SINGle\")\n",
    "# scope.handle.write(\":WAVeform:SOURce CHAN3\")\n",
    "# scope.handle.write(\":WAVeform:FORMat ASCii\")\n",
    "# r = scope.handle.ask(\":WAVeform:DATA?\")\n",
    "# r = r.split()[1:]\n",
    "# r = [ float(x[:-1]) for x in r]\n",
    "\n",
    "# d = pd.DataFrame(r)\n",
    "# d.plot()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "embedded",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.9"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
