void GenerateSample( void) { // Increment sample no SampleNo++; // Fill in spikecount header, assume spike count itself has already been filled, and send it MDF_SPM_SPIKECOUNT *sc = (MDF_SPM_SPIKECOUNT*) SpikeCountMessage.GetDataPointer(); sc->sample_header.DeltaTime = ((double)0.020); sc->sample_header.SerialNo = SampleNo; sc->sample_header.Flags = 0; sc->source_timestamp = LatestSourceTimestamp; sc->count_interval = RawCountInterval * ((double)RAW_COUNTS_PER_SAMPLE); dragonfly.SendMessage( &SpikeCountMessage); MDF_SAMPLE_GENERATED *sg = (MDF_SAMPLE_GENERATED*) SampleGeneratedMessage.GetDataPointer(); //MDF_SAMPLE_GENERATED sgd; //MDF_SAMPLE_GENERATED *sg = &sgd; sg->sample_header.DeltaTime = ((double)0.020); sg->sample_header.SerialNo = SampleNo; sg->sample_header.Flags = 0; sg->source_timestamp = LatestSourceTimestamp; //SampleGeneratedMessage.SetData( sg, sizeof(MDF_SAMPLE_GENERATED)); dragonfly.SendMessage( &SampleGeneratedMessage); // Update list of active sources UpdateActiveSources(); // Reset count ResetCount(); //PrintCount( SpikeCountData); }
void CGameCounter::Use(CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value) { if (!CanFireForActivator(pActivator)) return; switch (useType) { case USE_ON: case USE_TOGGLE: CountUp(); break; case USE_OFF: CountDown(); break; case USE_SET: SetCountValue((int)value); break; } if (HitLimit()) { SUB_UseTargets(pActivator, USE_TOGGLE, 0); if (RemoveOnFire()) { UTIL_Remove(this); } if (ResetOnFire()) { ResetCount(); } } }
SpikeCounter:: SpikeCounter( int maxchannels, int maxunits) { _maxChannels = maxchannels; _maxUnits = maxunits; int total_units = maxchannels * maxunits; _count = new int[total_units]; ResetCount( ); }
int main(int argc, char *argv[]) { // Process command line arguments char *config_filename = NULL; if( argc > 1) { config_filename = argv[1]; } char *mm_ip = NULL; if( argc > 2) { mm_ip = argv[2]; } static CMessage inMsg; Initialize(); bool try_again = true; while(try_again) { try { fprintf(stdout, "Connecting to Dragonfly\n"); if( mm_ip == NULL) dragonfly.ConnectToMMM(); else dragonfly.ConnectToMMM(mm_ip); dragonfly.Subscribe(MT_EXIT); dragonfly.Subscribe(MT_PING); dragonfly.Subscribe(MT_RAW_SPIKECOUNT); dragonfly.SendModuleReady(); fprintf(stdout, "Connected to Dragonfly\n"); ResetCount(); ResetActiveSources(); bool keep_running = true; while(keep_running) { double timeout = .5; // seconds bool got_msg = dragonfly.ReadMessage( &inMsg, timeout); if( got_msg) { keep_running = ProcessMessage(&dragonfly, &inMsg); if( !keep_running) { try_again = false; break; } } else { //fprintf(stdout, "Waiting for messages\n"); } } } catch(UPipeClosedException) { fprintf(stderr, "Reconnecting to Dragonfly\n"); Sleep(500); // milliseconds } catch(UPipeException) { fprintf(stderr, "Cannot connect to Dragonfly, waiting to reconnect\n"); Sleep(500); // milliseconds } } }
void CCount::UpdateMoneyDataCount(int nTime) { if((m_dwCountMoneyTime + 1000 * 60 * nTime) <= GetTickCount()) { m_dwCountMoneyTime = 0; StartTime(CCT_MONEYDATA); PrintMoneyDataCount(); ResetCount(CCT_MONEYDATA); } }
void CCount::UpdatePlayerDataCount(_PLAYERDATA *pData, const char*filename, int nTime, int nSaveType) { if (!pData || !filename) { rfalse(4, 1, "Count.cpp - UpdatePlayerDataCount() - !pData || !filename"); return; } if((m_dwCountPlayerTime + 1000 * 60 * nTime) <= GetTickCount()) { m_dwCountPlayerTime = 0; StartTime(CCT_PLAYERDATA); PrintPlayerDataCount(pData, filename, nSaveType); ResetCount(CCT_PLAYERDATA); } }
void RotaryEncoder::Setup() { /* Setup encoder pins as inputs */ // set up as inputs ENC_DDR &= ~(ENC_BIT_A|ENC_BIT_B|ENC_BIT_BTN); // turn on pullups ENC_PORT |= ENC_BIT_A|ENC_BIT_B|ENC_BIT_BTN; m_tcnt = 0; m_old_AB = 0; m_lastDebounceTime = 0; m_lastbtnval = ENC_BIT_BTN; m_lastbtnstate = ENC_BIT_BTN; // 0=pressed ResetCount(); }
GPlainTextLogger::GPlainTextLogger(QObject *parent, QString uniqueIdentifierName /* = "" */) : GProgDevice(parent, uniqueIdentifierName) , m_FolderPath("Folder", this/*, GParam::ReadOnly*/) , m_FileName("File name", this) , m_ShouldLogOnUpdate("On update?", this) , m_ShouldLogOnTimer("On timer?", this) , m_SecondTimer("Delay [s]:", this) , m_Bucket("Data", this) , m_BucketColNames("Col Names", this) , m_UpdateCount(0) , m_SecUpdate("Elapsed time (s):", this, GParam::ReadOnly) , m_SecMidnight("sec mid", this, GParam::ReadOnly) , m_SecEpoch("sec epoch", this, GParam::ReadOnly) , m_CurrentIndexUpdate("Update #:", this, GParam::ReadOnly) , m_pNotePadProcess(0) , m_FirstColName("Col. name:", this) , m_FirstColFormula("Formula (use i,t,tu,tm):", this) , m_FirstColValue("=", this, GParam::ReadOnly) { connect(&m_Bucket, SIGNAL(BucketUpdatedValues()), this, SLOT(EventBucketUpdated())); connect(&m_Timer, SIGNAL(timeout()), this, SLOT(EventTimerFired())); connect(&m_SecondTimer, SIGNAL(ValueUpdated(double)), this, SLOT(SetTimerLapse(double))); connect(&m_FileName, SIGNAL(ValueUpdated(QString)), this, SLOT(ResetCount())); connect(&m_FolderPath, SIGNAL(ValueUpdated(QString)), this, SLOT(ChooseFolder(QString)), Qt::QueuedConnection); m_SecUpdate.SetHardLimits(0.0, 9e99); m_SecMidnight.SetHardLimits(0.0, 9e99); m_SecEpoch.SetHardLimits(0.0, 9e99); m_FirstColValue.SetHardLimits(0.0, 9e99); m_SecondTimer = 1.0; m_SecondTimer.SetDisplayDecimals(2); m_SecondTimer.SetTypicalStep(0.1); m_SecondTimer.SetHardLimits(0.01, 9999); m_FirstColName = "unix time (s)"; m_FirstColFormula = "t"; m_Timer.start(); }
task main() { int count=0; int direction=1; int end=0; int doubleline=0; int pause=0; //turn right go forward until hit double line go back half a square then turn left (You are at bottom left sq now RightTurn(); while(pause==0) { motor(motorB)=SPEED; motor(motorC)=SPEED; wait1Msec(1); if(SensorValue(S3)<45&&doubleline!=1) { if(time1[T1]<200) { pause=1; } doubleline=1; } if(SensorValue(S3)>45&&doubleline==1) { doubleline=0; clearTimer(T1); } } motor[motorB]=-20; motor[motorC]=-20; wait1Msec(700); LeftTurn(); while(end!=7) { //traverse right and count lines if(direction==1) { end++; while(count<8) { if(SensorValue(S3)<45) { blacksq++; //store position to array grid[pos1][pos2]=1; } //increment counters count++; total++; displayBigTextLine(2,"Black:%d",blacksq); displayBigTextLine(5,"Count:%d ",count); displayBigTextLine(8,"Total:%d",total); //move forward one square Forward(); pos2++; } //Switches to next line if(end!=6) { direction=NextLineLeft(direction); //Resets count count=ResetCount(count); pos2=0; pos1++; } } if(direction==2) { end++; while(count<8) { if(SensorValue(S3)<45) { blacksq++; //store position to array grid[pos1][pos2]=1; } //increment counters count++; total++; displayBigTextLine(2,"Black:%d",blacksq); displayBigTextLine(5,"Count:%d ",count); displayBigTextLine(8,"Total:%d",total); //move forward one square Forward(); pos2++; } //Switches to next line if(end!=7) { //Switches to next line direction=NextLineRight(direction); //Resets count count=ResetCount(count); pos2=0; pos1++; } }//end if() //go back 7 suares and take away distance from bottom col from start from 7 and go to start }//end while() }//end main()
task main() { int count=0; int direction=1; int end=0; int doubleline=0; int pause=0; //open the file to write fileHandle=fileOpenWrite(filename); //turn right go forward until hit double line go back half a square then turn left You are at bottom left sq now RightTurn(); while(pause==0) { motor(motorB)=SPEED; motor(motorC)=SPEED; wait1Msec(1); if(SensorValue(S3)<45&&doubleline!=1) { if(time1[T1]<200) { pause=1; } doubleline=1; } if(SensorValue(S3)>45&&doubleline==1) { doubleline=0; clearTimer(T1); } } motor[motorB]=-20; motor[motorC]=-20; wait1Msec(700); LeftTurn(); //start traversing grid while(end!=7) { //traverse right and count lines if(direction==1) { end++; while(count<8) { if(SensorValue(S3)<45) { blacksq++; //store position to array grid[pos1][pos2]='1'; } //increment counters count++; total++; displayBigTextLine(2,"Black:%d",blacksq); displayBigTextLine(5,"Count:%d ",count); displayBigTextLine(8,"Total:%d",total); //move forward one square Forward(); pos2++; } //Switches to next line if(end!=7) { direction=NextLineLeft(direction); //Resets count count=ResetCount(count); pos1++; } } if(direction==2) { end++; while(count<8) { if(SensorValue(S3)<45) { blacksq++; //store position to array grid[pos1][pos2]='1'; } //increment counters count++; total++; displayBigTextLine(2,"Black:%d",blacksq); displayBigTextLine(5,"Count:%d ",count); displayBigTextLine(8,"Total:%d",total); //move forward one square Forward(); pos2--; } //Switches to next line if(end!=7) { //Switches to next line direction=NextLineRight(direction); //Resets count count=ResetCount(count); pos1++; } }//end if() }//end while() checkarray(); //Goes back to the start function GoStart(); //THIS IS THE SECOND PART OF THE PROGRAM TO MAP THE LOCATION OF THE OBJECT while(1==1) { if(getTouchValue(S2)==1) { //reset all values pos1=0; pos2=0; count=0; direction=1; end=0; while(end!=7) { //traverse right and count lines if(direction==1) { end++; while(count<8) { //check to see if there is an object 140mm away if(getUSDistance(S1)<14) { grid[pos1][pos2]='J'; motor[motorB]=0; motor[motorC]=0; wait1Msec(1000000); } //increment counters count++; Forward(); pos2++; } //Switches to next line if(end!=7) { direction=NextLineLeft(direction); //Resets count count=ResetCount(count); pos1++; } } if(direction==2) { //check to see if there is an object 140mm away end++; while(count<8) { if(getUSDistance(S1)<14) { grid[pos1][pos2]='J'; motor[motorB]=0; motor[motorC]=0; wait1Msec(1000000); } //increment counters count++; //move forward one square Forward(); pos2--; } //Switches to next line if(end!=7) { //Switches to next line direction=NextLineRight(direction); //Resets count count=ResetCount(count); pos1++; } }//end if() }//end while() } }//end if() }//end main()