extern "C" int {{modelName}}_event (double t, N_Vector y, N_Vector yp, double *g, void* pnode) { double v, vt; v = -1.0; vt = 0.0; // S is shorthand for the type that describes the model state typedef {{modelName}}::State_ S; // cast the node ptr to an object of the proper type assert(pnode); const {{modelName}} & node = *(reinterpret_cast<{{modelName}}*>(pnode)); // params is a reference to the model parameters const struct {{modelName}}::Parameters_ *params; params = &(node.P_); // state is a reference to the model state const struct {{modelName}}::State_ *state; state = &(node.S_); {% if (("v" in stateIndexMap) and ("V_t" in defaultDefs)) %} v = Ith (y, {{stateIndexMap | attr("v")}}); vt = params->V_t; g[0] = v - vt; {% else %} g[0] = -1.0; {% endif %} return 0; }