Exemplo n.º 1
0
void SaccadeMotorProgram::delta_ext(double e, const Bag<IO_Type>& xb)
{
	_time += e;
	if (!_saccades.empty())
	{
		//Rcout << _time << " There are " << _saccades.size() << " saccades in the motor queue." << endl;
		list<Saccade*>::const_iterator si = _saccades.begin();
		for(; si != _saccades.end(); si++)
		{
			(*si)->nonlabile_t -= e;
		}
	}
	Bag<IO_Type>::const_iterator iter = xb.begin();
	for (; iter != xb.end(); iter++)
	{
		Saccade* s = new Saccade(*((*xb.begin()).value));
		s->labile_stop = _time;
		s->nonlabile_start = _time;
		s->nonlabile_t = ::Rf_rgamma(((_mean*_mean)/(_stdev*_stdev)),(_stdev*_stdev)/_mean);
		_saccades.push_back(s);
	}
	_saccades.sort(sortNonLabile);
	//printf("%f\t    SaccadeMotorProgram: Starting non-labile programming for saccade[id=%d]\n", _time, _saccade->id);
	//printf("%f\t    SaccadeMotorProgram: Next event at %f\n", _time, _time+_threshold);
}
Exemplo n.º 2
0
typename Bag::value_type min(const Bag & b)
{
    typename Bag::const_iterator it;
    typename Bag::value_type m = *b.begin();
    for (it = b.begin(); it != b.end(); ++it)
        if (*it < m)
            m = *it;
    return m;
}
Exemplo n.º 3
0
void LoadControl::delta_ext(double e, const Bag<PortValue<BasicEvent*> >& xb)
{
	Bag<PortValue<BasicEvent*> >::const_iterator iter = xb.begin();
	for (; iter != xb.end(); iter++)
	{
		GenrSampleEvent* measurement = dynamic_cast<GenrSampleEvent*>((*iter).value);
		if (measurement->freqBreakerOpen()) fdata.erase(measurement->getBusID());
		else fdata[measurement->getBusID()] = measurement->getRotorSpeed();
	}
	// Compute adjustment fraction
	double modified_adjustment = 0.0;
	// Get average frequency
	map<unsigned,double>::iterator fiter = fdata.begin();
	for (; fiter != fdata.end(); fiter++)
	{
		modified_adjustment += (*fiter).second;
	}
	modified_adjustment /= fdata.size();
	// Normalize to a percentage and apply the gain
	modified_adjustment *= (K/FreqTol);
	// Signal?
	if (!(fabs(modified_adjustment) <= max_adjust))
	{
		if (modified_adjustment > 0.0) modified_adjustment = max_adjust;
		else modified_adjustment = -max_adjust;
	}
	signal = adjustment != modified_adjustment;
	adjustment = modified_adjustment;
	assert(fabs(adjustment) <= max_adjust);
}
Exemplo n.º 4
0
void Generator::gc_output(Bag<IO_Type>& g)
{
	// Delete the customer that was produced as output
	Bag<IO_Type>::iterator i;
	for (i = g.begin(); i != g.end(); i++)
	{
		delete (*i).value;
	}
}
Exemplo n.º 5
0
void Payer::delta_ext(double e, const Bag<IO>& xb)
{
	// Record the times at which the bene left the provider.
	Bag<IO>::const_iterator i;
	for (i = xb.begin(); i != xb.end(); i++)
	{
		//const Signal* c = (*i).value;
		total_number_of_patients += 1;
	}
}
Exemplo n.º 6
0
		/**
		 * Change Vref on receiving input.
		 */
		void external_event(double* q, double e, const Bag<double>& xb)
		{
			// Apply the external event function of the base class
			Circuit::external_event(q,e,xb);
			// Set the reference voltage and indicate that we are no longer
			// at the reference.
			set_V_Vref(*(xb.begin()));
			atVref = false;
			// Reinitialize the continuous model. This is really only necessary
			// if your discrete event may result in new values for the 
			// state variables (discrete or continuous) of the modelica model.
			update_vars(q,true);
		}
Exemplo n.º 7
0
void QueueBus::delta_ext(double e, const Bag<PortValue<BasicEvent*> >& xb)
{
	if (!q.empty()) ttg -= e;
	for (Bag<PortValue<BasicEvent*> >::const_iterator iter = xb.begin();
			iter != xb.end(); iter++)
	{
		if (q.empty()) schedule_next_packet();
		packet_t pkt;
		pkt.e = ((*iter).value);
		if (pkt.e != NULL) pkt.e = pkt.e->clone();
		// Goes out on the same port that it arrived from
		pkt.out_port = ((*iter).port);
		q.push_back(pkt);
	}
}
Exemplo n.º 8
0
		void external_event(double* q, double e, const Bag<double>& xb)
		{
			static const double pi = 3.141592653589793;
			test_count++;
			double test_angle = *(xb.begin());
			double diff = fabs(q[0]-test_angle);
			// Rotate by a full circle?
			if (diff > 1E-4) diff -= 2.0*pi;
			if (!(fabs(diff) < 1E-4))
			{
				cerr << "AGGGH: " << q[0] << "," << test_angle << "," 
					<< diff << endl;
			}
			assert(fabs(diff) < 1E-4);
		}
Exemplo n.º 9
0
void PacketProcessing::delta_ext(double e, const Bag<SimEvent>& xb)
{
	// If we are not interrupted and are processing a packet, then
	// reduce the time remaining to finish with that packet
	if (!interrupt && !q.empty()) sigma -= e;
	// Process input events
	for (Bag<SimEvent>::const_iterator iter = xb.begin();
			iter != xb.end(); iter++)
	{
		if ((*iter).getType() == SIM_PACKET)
			q.push_back((*iter).simPacket()); 
		else if ((*iter).getType() == SIM_INTERRUPT)
			interrupt = !interrupt;
	}
	// If we are idle and there are more packets, then start
	// processing the next one
	if (sigma == DBL_MAX && !q.empty()) sigma = processing_time;
}
Exemplo n.º 10
0
void QueueBus::gc_output(Bag<PortValue<BasicEvent*> >& gb)
{
	for (Bag<PortValue<BasicEvent*> >::const_iterator iter = gb.begin();
			iter != gb.end(); iter++)
		if ((*iter).value != NULL) delete (*iter).value;
}
Exemplo n.º 11
0
		void external_event(double*,double,const Bag<bool>& xb)
		{
			s = *(xb.begin());
		}
Exemplo n.º 12
0
void SaccadeMotorProgram::gc_output(Bag<IO_Type>& g)
{
	Bag<IO_Type>::iterator i;
	for (i = g.begin(); i != g.end(); i++)
		delete (*i).value;
}
Exemplo n.º 13
0
		void delta_conf(const Bag<IO_Type>& xb)
		{
			QemuComputer<IO_Type>::delta_conf(xb);
			mem->write_mem(0xb0,*(xb.begin()));
		}
Exemplo n.º 14
0
		void delta_ext(double e, const Bag<IO_Type>& xb)
		{
			QemuComputer<IO_Type>::delta_ext(e,xb);
			mem->write_mem(0xb0,*(xb.begin()));
		}
Exemplo n.º 15
0
		void delta_ext(double e, const Bag<IO_Type>& xb)
		{
			t += e;
			printf("Got %x @ %f\n",(*(xb.begin())),t);
		}
Exemplo n.º 16
0
void LoadControl::gc_output(Bag<PortValue<BasicEvent*> >& gb)
{
	Bag<PortValue<BasicEvent*> >::iterator iter = gb.begin();
	for (; iter != gb.end(); iter++) delete (*iter).value;
}