コード例 #1
0
void getRespSpikes::SimulationClass::SpikeValidityCalc(void) {

	GenSpikeListCalc();

	std::function<bool(const float &, const float &)> isInReset = [&] (const float &UNow, const float &VNow) -> bool {
		float Discriminant = 25.0f-4.0f*0.04f*(140.0f-UNow);
		return Discriminant > 0 && VNow < (-5 - std::sqrt(Discriminant))*12.5f + 5.0f;
	};

	for(uint32_t i=0; i<N; ++i) {
		auto NSpikesGen = GenSpikeList[i].size();
		for(uint32_t j=0; j<NSpikesGen; ++j) {
			auto CurrentSpikeTime = GenSpikeList[i][j];
			auto FirstTimeAfterPrevSpike = (j > 0) ? GenSpikeList[i][j-1]+1 : StartTime;

			DiscreteRange CurrentRange;
			CurrentRange.endPoint = CurrentSpikeTime+1;
			bool foundRangeBegin = false;
			for(uint32_t TIndex=CurrentSpikeTime; TIndex --> FirstTimeAfterPrevSpike;) {
				if (isInReset(U(TIndex-StartTime, i), V(TIndex-StartTime, i))) {
					foundRangeBegin = true;
					CurrentRange.beginPoint = TIndex+1;
					break;
				}
			}
			if (!foundRangeBegin) {
				CurrentRange.beginPoint = FirstTimeAfterPrevSpike;
			}
			SpikeValidity[i].push_back(CurrentRange);
		}
	}
}
コード例 #2
0
ファイル: pString_Connection.C プロジェクト: PlanetAPL/a-plus
int pString_Connection::send(const A &msg_)
{
  ipcWarn(wrnlvl(),"%t pString_Connection::send\n");
  if(isInReset()||readChannel()==0) return -1;
  if(Ct!=msg_->t) return -1;

  MSBuffer *sb=new MSBuffer(msg_->n+sizeof(int));
  if(NULL==sb) return -1;
  int msgLen=htonl((int)msg_->n);
  sb->stuff((char *)(&msgLen),sizeof(int));
  sb->stuff((const char *)msg_->p, msg_->n);
  sendTheBuffer(sb);
  if (MSFalse==isWritePause()) writeChannel()->enable();
  return doWrite(MSFalse);
}
コード例 #3
0
ファイル: pSimple_Connection.C プロジェクト: PlanetAPL/a-plus
int pSimple_Connection::send(const A &msg_)
{
  ipcWarn(wrnlvl(),"%t pSimple_Connection::send\n");
  if(isInReset()||readChannel()==0) return -1;
  if(Et<=msg_->t) return -1;

  long len=AH+Tt(msg_->t,msg_->n)+((Ct==msg_->t)?1:0);
  MSBuffer *sb=new MSBuffer(len+sizeof(long));
  if(NULL==sb) return -1;
  long msgLen=htonl(len);
  sb->stuff((char *)(&msgLen),sizeof(long));
  sb->stuff((const char *)msg_, len);
  sendTheBuffer(sb);
  if (MSFalse==isWritePause()) writeChannel()->enable();
  return doWrite(MSFalse);
}
コード例 #4
0
ファイル: pString_Connection.C プロジェクト: PlanetAPL/a-plus
I pString_Connection::syncDoRead(A *pdataobj)
{
  I result;
  MSBuffer *hb=headBuffer();
  MSBuffer *db=readBuffer();
  ipcWarn(wrnlvl(),"%t pString_Connection::syncDoRead\n");
  
  *pdataobj=readOne();
  if(*pdataobj==(A)0) 
  {
    if(isInReset()) 
      result=syncFillError("reset","Reset occurred.  No message read.");
    else result=0;
  } 
  else result=1;

  return result;
}