/*
============================================================================
Cavitational Capacitive Drive (CCD) GUI Interface (mW/cm2)
Author: Mithun Padmakumar
Date: July 2026

Citation:
  Padmakumar, M., Rajan, D., & Steephen, J. E. (2026). Cavitational capacitive 
  drive: A computationally efficient model for ultrasonic neuromodulation. 
  Journal of Neural Engineering.

Description:
  Defines the control panel interface for setting CCD stimulation parameters 
  (with intensity recorded in mW/cm2) and managing output saving options.
============================================================================
*/

load_file("processes.hoc")

// Initial CCD parameters
bFUSS = 1
tbegin = 20    // FUSS start time (ms)
tdurn = 100    // FUSS duration (ms)
freq = 100     // Default frequency (kHz)
usi = 50       // Default CCD intensity (mW/cm2)

// Main panel for setting CCD parameters
objref xccd
xccd = new HBox()
xccd.intercept(1)

xpanel("CCD Parameters")
xlabel("CCD Model Stimulation Parameters")
xlabel("")
xstatebutton("FUSS Enabled", &bFUSS, "toggle_fuss(bFUSS)")
xpvalue("tbegin (ms) :", &tbegin, 1, "update_ccd()")
xpvalue("tdurn (ms) :", &tdurn, 1, "update_ccd()")
xpvalue("Frequency (kHz) :", &freq, 1, "update_ccd()")
xpvalue("Intensity (mW/cm2) :", &usi, 1, "update_ccd()")
xpanel(0)

xccd.intercept(0)
xccd.map("CCD Parameters", 500, 20, -1, -1)

// Panel for managing output saving options
objref xout
xout = new HBox()
xout.intercept(1)

xpanel("Manage Output")
xlabel("Output Management Options")
xlabel("")
xbutton("Save Raw Vm", "saveRawVm()")
xbutton("Save Processed Vm", "saveProcessedVm()")
xbutton("Save Cm Waveform", "saveCm()")
xbutton("Save AP Times", "saveAPC()")
xpanel(0)

xout.intercept(0)
xout.map("Manage Output", 500, 260, -1, -1)

// Insert CCD mechanism on initial startup
InsertCCD(bFUSS)