uint8_t lerpStepChannel( channelLerp_t *channel ) { channel->x_prev = channel->x0; channel->y_prev = channel->y0; // skip over all brightnesses which are in the same time step while ( channel->x_prev == channel->x0 ) { brenthamIteration( channel ); if ( channel->x0 == channel->x1 && channel->y0 == channel->y1 ) { channel->done = TRUE; break; } } // if we're done on this interpolation, generate a result if ( !channel->done ) { if ( channel->first ) { channel->first = FALSE; channel->result = channel->y_prev; } else { channel->result = (channel->y0+channel->y_prev)>>1; } channelOut( channel ); } // return if successfully set an output return !channel->done; }
const Cinfo* ChanBase::initCinfo() { ///////////////////////////////////////////////////////////////////// // Shared messages ///////////////////////////////////////////////////////////////////// static DestFinfo process( "process", "Handles process call", new ProcOpFunc< ChanBase >( &ChanBase::process ) ); static DestFinfo reinit( "reinit", "Handles reinit call", new ProcOpFunc< ChanBase >( &ChanBase::reinit ) ); static Finfo* processShared[] = { &process, &reinit }; static SharedFinfo proc( "proc", "Shared message to receive Process message from scheduler", processShared, sizeof( processShared ) / sizeof( Finfo* ) ); ///////////////////////////////////////////////////////////////////// /// ChannelOut SrcFinfo defined above. static DestFinfo Vm( "Vm", "Handles Vm message coming in from compartment", new OpFunc1< ChanBase, double >( &ChanBase::handleVm ) ); static Finfo* channelShared[] = { channelOut(), &Vm }; static SharedFinfo channel( "channel", "This is a shared message to couple channel to compartment. " "The first entry is a MsgSrc to send Gk and Ek to the compartment " "The second entry is a MsgDest for Vm from the compartment.", channelShared, sizeof( channelShared ) / sizeof( Finfo* ) ); /////////////////////////////////////////////////////// // Here we reuse the Vm DestFinfo declared above. /// Permability SrcFinfo defined above. static Finfo* ghkShared[] = { &Vm, permeability() }; static SharedFinfo ghk( "ghk", "Message to Goldman-Hodgkin-Katz object", ghkShared, sizeof( ghkShared ) / sizeof( Finfo* ) ); /////////////////////////////////////////////////////// // Field definitions /////////////////////////////////////////////////////// static ElementValueFinfo< ChanBase, double > Gbar( "Gbar", "Maximal channel conductance", &ChanBase::setGbar, &ChanBase::getGbar ); static ElementValueFinfo< ChanBase, double > modulation( "modulation", "Modulation, i.e, scale factor for channel conductance." "Note that this is a regular parameter, it is not " "recomputed each timestep. Thus one can use a slow update, " "say, from a molecule pool, to send a message to set " "the modulation, and it will stay at the set value even if " "the channel runs many timesteps before the next assignment. " "This differs from the GENESIS semantics of a similar message," "which required update each timestep. ", &ChanBase::setModulation, &ChanBase::getModulation ); static ElementValueFinfo< ChanBase, double > Ek( "Ek", "Reversal potential of channel", &ChanBase::setEk, &ChanBase::getEk ); static ElementValueFinfo< ChanBase, double > Gk( "Gk", "Channel conductance variable", &ChanBase::setGk, &ChanBase::getGk ); static ReadOnlyElementValueFinfo< ChanBase, double > Ik( "Ik", "Channel current variable", &ChanBase::getIk ); /////////////////////////////////////////////////////// // MsgSrc definitions /////////////////////////////////////////////////////// // IkOut SrcFinfo defined above. /////////////////////////////////////////////////////// // MsgDest definitions /////////////////////////////////////////////////////// /////////////////////////////////////////////////////// static Finfo* ChanBaseFinfos[] = { &channel, // Shared &ghk, // Shared &Gbar, // Value &modulation, // Value &Ek, // Value &Gk, // Value &Ik, // ReadOnlyValue IkOut(), // Src &proc, // Shared }; static string doc[] = { "Name", "ChanBase", "Author", "Upinder S. Bhalla, 2007-2014, NCBS", "Description", "ChanBase: Base class for assorted ion channels." "Presents a common interface for all of them. ", }; static ZeroSizeDinfo< int > dinfo; static Cinfo ChanBaseCinfo( "ChanBase", Neutral::initCinfo(), ChanBaseFinfos, sizeof( ChanBaseFinfos )/sizeof(Finfo *), &dinfo, doc, sizeof(doc)/sizeof(string) ); return &ChanBaseCinfo; }