void logException(unsigned int errorCode, const char * pStrError, int takeAction) { // errorcode == 1 means memory error from BodyInit() and ucBSInit() int i; char errorString[160]; if(vCur_1 < V_MIN_SDWRITE_VOLTAGE) { } if (takeAction || LOG_WARNINGS) { strcpy(errorString,"\x0d\x0a" "*** ERROR! (cycle "); //cycle number longToDecimalString(systemCounts.powerUpNumber,(char *)(errorString+strlen(errorString)),4); strcat(errorString," - version " VERSION ")\x0d\x0a*** #"); longToDecimalString((long)errorCode,(char *)(errorString+strlen(errorString)),3); if (takeAction) { strcat(errorString,"-fatal"); stop(); } else strcat(errorString,"-warning"); if (LOG_FILE) { logString(errorString,ASAP); if (pStrError) { LBstrncpy(errorString,pStrError,80); logString(errorString,ASAP); } } else { appendStringToFile(ERROR_LOG_FILE,errorString); if (pStrError) { LBstrncpy(errorString,pStrError,80); appendStringToFile(ERROR_LOG_FILE,errorString); } } } //todo: put a parameter in fct to return instead of reset or USB //maybe a choice of the three RETURN, RESET, USB if (takeAction) { // commenting out code to alert user of error -- just use lights and auto-reset to welcome msg // if (errorCode != 10 && errorCode != 14) // can't access config or system boot // insertSoundFile(ERROR_SOUND_FILE_IDX); // if (errorCode != 14) // LED_GREEN and LED_RED are not assigned without config file for (i=0; i < 5; i++) { setLED(LED_GREEN,FALSE); setLED(LED_RED,TRUE); wait(500); setLED(LED_RED,FALSE); setLED(LED_GREEN,TRUE); wait(500); } if (takeAction == USB_MODE) // can't load config setUSBDevice (TRUE); else if (takeAction == RESET) resetSystem(); else if (takeAction == SHUT_DOWN) setOperationalMode((int)P_SLEEP); } }
TutorialGui::TutorialGui(TutorialUnit *control) : ui(new Ui::TutorialGui), mController(control) { ui->setupUi(this); connect(this, SIGNAL(resetSystem()), mController, SLOT(resetSetup()), Qt::QueuedConnection); connect(this, SIGNAL(resetSystemRandom()), mController, SLOT(resetSetupRandom()), Qt::QueuedConnection); }
ErrorCode setNewOrder(Traj dist, Traj rot, portTickType xBlockTime) { ErrorCode err = resetSystem(&ctlBlock, xBlockTime); taskENTER_CRITICAL(); { trajDist.pos = dist.pos; trajRot.pos = rot.pos; } taskEXIT_CRITICAL(); startSystem(&ctlBlock); return err;
/** * Initializes the scene (used in main). */ void initScene() { glutSetCursor(GLUT_CURSOR_NONE); glutWarpPointer(GW / 2, GH / 2); srand(time(NULL)); resetSystem(); setScreenSaver(); cam = camera(); objs.push_back(new ground()); objs.push_back(new particleSystem(pnt3d(0, 0, 0))); glutTimerFunc(d_time, loop, d_time); }
TutorialUnitGui::TutorialUnitGui(TutorialUnit *control, GraphicsView *scene) : ui(new Ui::TutorialUnitGui), mController(control), mScene(scene) { ui->setupUi(this); connect(mController, SIGNAL(connectStatusChanged(bool)), SLOT(updateStatus(bool))); connect(mController, SIGNAL(positionUpdated(QPointF,qreal)), SLOT(onPositionUpdate(QPointF, qreal))); connect(this, SIGNAL(connectClicked()), mController, SLOT(acquireHardware())); connect(this, SIGNAL(disconnectClicked()), mController, SLOT(releaseHardware())); connect(this, SIGNAL(resetSystem()), mController, SLOT(resetSetup())); connect(this, SIGNAL(resetSystemRandom()), mController, SLOT(resetSetupRandom())); scene->show(); scene->hide(); }
/* Set registers for BOOT */ EXPORT void setUpBoot( void *start, BootInfo *bootinfo ) { bootFlag = 1; /* suppress the setting register R0 upon exit of the monitor */ regStack[ixCPSR] = PSR_I | PSR_F | PSR_SVC; regStack[0] = (UW)bootinfo; // R0 boot parameter regStack[ixPC] = (UW)start; // PC start address regStack[ixSP_SVC] = (UW)&__stack_bottom; // SP monitor stack // MMU enabled, Cache / Write Buffer not enabled regStack[ixCP15R1] &= MASK_CACHEMMU; regStack[ixCP15R1] |= ENB_MMUONLY; // system initialization processing resetSystem(1); }
/** * Changes particle values. */ void general(char *value) { for (unsigned int i = 0; i < objs.size(); i++) { if (objs[i]->classId == PART_ID) { particleSystem *temp = (particleSystem*)objs[i]; if (!strcmp(value, "reset")) { temp->resetSystem(temp->init_pos); cam.spin_speed = 0.25; resetSystem(); } else if (!strcmp(value, "screen_saver")) { is_screen_saver = !is_screen_saver; } else { temp->general(value); } } } }
void SlamDriver::startRecording() { resetSystem(); mRecordFrames = true; mRecordId = 0; mRecordFileFormat = FLAGS_DriverRecordPath + "frame%.4d.jpg"; //Delete all previous bool filesToDelete=true; int deleteId=0; char buffer[1024]; while(filesToDelete) { sprintf(buffer, mRecordFileFormat.c_str(), deleteId++); if(std::remove(buffer)) filesToDelete = false; }; }
void BillboardParticleSystem::setTotalParticles(int tp) { // If we are setting the total number of particles to a number higher // than what is allocated, we need to allocate new arrays if( tp > _allocatedParticles ) { // Allocate new memory size_t particlesSize = tp * sizeof(tParticle); size_t quadsSize = sizeof(_quads[0]) * tp * 1; size_t indicesSize = sizeof(_indices[0]) * tp * 6 * 1; sBillboardParticle* particlesNew = (sBillboardParticle*)realloc(_particles, particlesSize); V3F_C4B_T2F_Quad* quadsNew = (V3F_C4B_T2F_Quad*)realloc(_quads, quadsSize); GLushort* indicesNew = (GLushort*)realloc(_indices, indicesSize); if (particlesNew && quadsNew && indicesNew) { // Assign pointers _particles = particlesNew; _quads = quadsNew; _indices = indicesNew; // Clear the memory memset(_particles, 0, particlesSize); memset(_quads, 0, quadsSize); memset(_indices, 0, indicesSize); _allocatedParticles = tp; } else { // Out of memory, failed to resize some array if (particlesNew) _particles = particlesNew; if (quadsNew) _quads = quadsNew; if (indicesNew) _indices = indicesNew; CCLOG("Particle system: out of memory"); return; } _totalParticles = tp; initIndices(); if (Configuration::getInstance()->supportsShareableVAO()) { setupVBOandVAO(); } else { setupVBO(); } // fixed http://www.cocos2d-x.org/issues/3990 // Updates texture coords. updateTexCoords(); } else { _totalParticles = tp; } // fixed issue #5762 // reset the emission rate setEmissionRate(_totalParticles / _life); resetSystem(); }
void ParticleSystem::keyboardActions() { if (keyboardState.get('\\')) { resetSystem(); } if (keyboardState.get('x')) { translatePositiveX(); } if (keyboardState.get('X')) { translateNegativeX(); } if (keyboardState.get('y')) { translatePositiveY(); } if (keyboardState.get('Y')) { translateNegativeY(); } if (keyboardState.get('z')) { translatePositiveZ(); } if (keyboardState.get('Z')) { translateNegativeZ(); } if (keyboardState.get('a')) { increaseParticlesPerSecond(); } if (keyboardState.get('A')) { decreaseParticlesPerSecond(); } if (keyboardState.get('s')) { increaseBirthSize(); } if (keyboardState.get('S')) { decreaseBirthSize(); } if (keyboardState.get('r')) { increaseBirthRed(); } if (keyboardState.get('R')) { decreaseBirthRed(); } if (keyboardState.get('g')) { increaseBirthGreen(); } if (keyboardState.get('G')) { decreaseBirthGreen(); } if (keyboardState.get('b')) { increaseBirthBlue(); } if (keyboardState.get('B')) { decreaseBirthBlue(); } if (keyboardState.get('t')) { increaseDeathRed(); } if (keyboardState.get('T')) { decreaseDeathRed(); } if (keyboardState.get('h')) { increaseDeathGreen(); } if (keyboardState.get('H')) { decreaseDeathGreen(); } if (keyboardState.get('n')) { increaseDeathBlue(); } if (keyboardState.get('N')) { decreaseDeathBlue(); } }
void startUp(void) { char buffer[200]; char strCounts[20]; int key; SetSystemClockRate(MAX_CLOCK_SPEED); // to speed up initial startup -- set CLOCK_RATE later setDefaults(); setLED(LED_RED,FALSE); // red light can be left on after reprog restart setLED(LED_GREEN,TRUE); // red light can be left on after reprog restart //to stop user from wondering if power is on and possibly cycling too quickly, playDing(); // it is important to play a sound immediately key = keyCheck(1); // long keycheck // voltage checks in SystemIntoUSB.c if (key == KEY_STAR || key == KEY_MINUS) { // allows USB device mode no matter what is on memory card Snd_Stop(); SystemIntoUDisk(1); loadConfigFile(); processInbox(); resetSystem(); } else if (key == KEY_PLUS) { // outbox mode: copy outbox files to connecting device loadConfigFile(); copyOutbox(); resetSystem(); } // check for new firmware first, but don't flash if voltage is low if(V_MIN_SDWRITE_VOLTAGE <= vCur_1) { check_new_sd_flash(); } if (loadConfigFile() == -1) // config.txt file not found testPCB(); if (!SNexists()) logException(32,(const char *)"no serial number",SHUT_DOWN); SysDisableWaitMode(WAITMODE_CHANNEL_A); adjustVolume(NORMAL_VOLUME,FALSE,FALSE); adjustSpeed(NORMAL_SPEED,FALSE); loadDefaultPackage(); if (MACRO_FILE) loadMacro(); loadSystemCounts(); systemCounts.powerUpNumber++; if (systemCounts.powerUpNumber - systemCounts.lastLogErase > MAX_PWR_CYCLES_IN_LOG) { systemCounts.lastLogErase = systemCounts.powerUpNumber; clearStaleLog(); } #ifndef TB_CAN_WAKE resetRTC(); // reset before saving anything to disk and running macros #endif saveSystemCounts(); strcpy(buffer,"\x0d\x0a" "---------------------------------------------------\x0d\x0a"); strcat(buffer,getDeviceSN(1)); strcpy(strCounts,(char *)" counts:S"); longToDecimalString(systemCounts.powerUpNumber, strCounts+9, 4); strcat(strCounts,(char *)"P"); longToDecimalString(systemCounts.packageNumber, strCounts+14, 4); strcat(strCounts,(char *)"R"); longToDecimalString(systemCounts.revdPkgNumber, strCounts+19, 4); strcat(buffer,strCounts); strcat(buffer,"\x0d\x0a" "CYCLE "); //cycle number longToDecimalString(systemCounts.powerUpNumber,(char *)(buffer+strlen(buffer)),4); strcat(buffer,(const char *)" - version " VERSION); logString(buffer,BUFFER); #ifdef TB_CAN_WAKE logRTC(); #endif loadPackage(PKG_SYS,BOOT_PACKAGE); SetSystemClockRate(CLOCK_RATE); // either set in config file or the default 48 MHz set at beginning of startUp() mainLoop(); }
void CCParticleSystemQuad::setTotalParticles(unsigned int tp) { // If we are setting the total number of particles to a number higher // than what is allocated, we need to allocate new arrays if( tp > m_uAllocatedParticles ) { // Allocate new memory size_t particlesSize = tp * sizeof(tCCParticle); size_t quadsSize = sizeof(m_pQuads[0]) * tp * 1; size_t indicesSize = sizeof(m_pIndices[0]) * tp * 6 * 1; tCCParticle* particlesNew = (tCCParticle*)realloc(m_pParticles, particlesSize); ccV3F_C4B_T2F_Quad* quadsNew = (ccV3F_C4B_T2F_Quad*)realloc(m_pQuads, quadsSize); GLushort* indicesNew = (GLushort*)realloc(m_pIndices, indicesSize); if (particlesNew && quadsNew && indicesNew) { // Assign pointers m_pParticles = particlesNew; m_pQuads = quadsNew; m_pIndices = indicesNew; // Clear the memory // XXX: Bug? If the quads are cleared, then drawing doesn't work... WHY??? XXX memset(m_pParticles, 0, particlesSize); memset(m_pQuads, 0, quadsSize); memset(m_pIndices, 0, indicesSize); m_uAllocatedParticles = tp; } else { // Out of memory, failed to resize some array if (particlesNew) m_pParticles = particlesNew; if (quadsNew) m_pQuads = quadsNew; if (indicesNew) m_pIndices = indicesNew; CCLOG("Particle system: out of memory"); return; } m_uTotalParticles = tp; // Init particles if (m_pBatchNode) { for (unsigned int i = 0; i < m_uTotalParticles; i++) { m_pParticles[i].atlasIndex=i; } } initIndices(); #if CC_TEXTURE_ATLAS_USE_VAO setupVBOandVAO(); #else setupVBO(); #endif } else { m_uTotalParticles = tp; } resetSystem(); }
/********************************************************************* * * recovery, based on the cmd code decides what recovery action * to perform. * * Author Greg Brissey 12-7-94 */ void recovery(CNTLR_COMM_MSG *msge, int externflag) { char *token; int len; int cmd; int i,nMsg2Read; int bytes; extern int systemConRestart(); CNTLR_COMM_MSG discardedmsge; DPRINT(-1,"Local Exception\n"); switch( msge->cmd /* exceptionType */ ) { case PANIC: #ifdef INSTRUMENT wvEvent(EVENT_PHDLR_PANIC,NULL,NULL); #endif errLogRet(LOGIT,debugInfo, "phandler: Panic Error: %d", msge->errorcode); break; case WARNING_MSG: #ifdef INSTRUMENT wvEvent(EVENT_PHDLR_WARNMSG,NULL,NULL); #endif DPRINT2(-10,"WARNING: doneCode: %d, errorCode: %d\n", msge->cmd,msge->errorcode); /* errLogRet(LOGIT,debugInfo, "phandler: Warning Message: %d", msge->reportEvent); */ /* the send2Expproc is commented out. The msg is send /* via other ways. We got two warning msgs for the /* following numbers: /* PNEU_ERROR + PRESSURE; /* PNEU_ERROR + NB_STACK; /* PNEU_ERROR + VTTHRESH; /* PNEU_ERROR + PS; /* VTERROR + NOGAS /* Don't send ADC overflows to Expproc */ /* if ( (msge->errorcode != WARNINGS+ADCOVER) && /* (msge->errorcode != SFTERROR+LOCKLOST) ) /* send2Expproc(CASE,msge->cmd,msge->errorcode,0,NULL,0); */ break; case SOFT_ERROR: #ifdef INSTRUMENT wvEvent(EVENT_PHDLR_SOFTERROR,NULL,NULL); #endif /* update_acqstate( ACQ_IDLE ); INOVA */ DPRINT2(0,"SOFT_ERROR: doneCode: %d, errorCode: %d\n", msge->cmd,msge->errorcode); /* errLogRet(LOGIT,debugInfo, "phandler: Soft Error: %d", msge->reportEvent); */ #ifdef INOVA statMsg.Status = msge->exceptionType; statMsg.Event = msge->reportEvent; /* Error Code */ msgQSend(pMsgesToHost,(char*) &statMsg,sizeof(statMsg), WAIT_FOREVER, MSG_PRI_NORMAL); #endif break; case EXP_ABORTED: #ifdef INSTRUMENT wvEvent(EVENT_PHDLR_EXPABORTED,NULL,NULL); #endif DPRINT(0,"Exp. Aborted"); case HARD_ERROR: #ifdef INSTRUMENT wvEvent(EVENT_PHDLR_HARDERROR,NULL,NULL); #endif DPRINT2(0,"HARD_ERROR: doneCode: %d, errorCode: %d\n", msge->cmd, msge->errorcode); AbortExp(msge,externflag); /* fifoCloseLog(pTheFifoObject); */ DPRINT(0,"Done"); break; case INTERACTIVE_ABORT: #ifdef INSTRUMENT wvEvent(EVENT_PHDLR_HARDERROR,NULL,NULL); #endif /* DPRINT1(0,"INTERACTIVE_ABORT: doneCode: %d, errorCode: %d\n", msge->reportEvent); */ AbortExp(msge,externflag); /* fifoCloseLog(pTheFifoObject); */ DPRINT(0,"Done"); break; case EXP_HALTED: #ifdef INSTRUMENT wvEvent(EVENT_PHDLR_EXPHALTED,NULL,NULL); #endif DPRINT2(0,"EXP_HALTED: doneCode: %d, errorCode: %d\n", msge->cmd, msge->errorcode); AbortExp(msge,externflag); break; case STOP_CMPLT: /* the monitor set the SA_Criteria value, when the upLinker obtained a FID that meet this Criteria the upLinker sent this msge here and then blocked itself Our job is to 1. Foward the Stopped msge to Host 2. reset hardware 3. put hardware into a safe state 4. call stmSA, clears upLinker msgQ, send SA msge 5. reset SA_Criteria back to Zero 6. give the semaphore to restart upLinker 7. reset update task 8. reset parser task 9. Free the buffers 10. Re-enable Interrupts */ #ifdef INSTRUMENT wvEvent(EVENT_PHDLR_STOPCMPLT,NULL,NULL); #endif #ifdef INOVA statMsg.Status = msge->exceptionType; statMsg.Event = msge->reportEvent; /* Error Code */ msgQSend(pMsgesToHost,(char*) &statMsg,sizeof(statMsg), WAIT_FOREVER, MSG_PRI_NORMAL); errLogRet(LOGIT,debugInfo, "phandler: Exp. Stopped: %d", msge->reportEvent); /* reprogram HSlines, ap registers to safe state */ reset2SafeState( msge->exceptionType ); resetSystem(); /* reset fifo, disable intrps, reset tasks & buffers */ DPRINT2(0,"stmHaltCode: doneCode: %d, errorCode: %d\n", msge->exceptionType,msge->reportEvent); semGive(pSemSAStop); /* release the UpLinker */ /* stmHaltCode(pTheStmObject,(int) msge->exceptionType, (int) msge->reportEvent); */ /* DPRINT(0,"stmSA"); stmSA(pTheStmObject); */ DPRINT(0,"STOP_CMPLT: lower priority below upLinker\n"); taskPrioritySet(pHandlerTid,(UPLINKER_TASK_PRIORITY+1)); taskPrioritySet(pHandlerTid,pHandlerPriority); SA_Criteria = 0; SA_Mod = 0L; DPRINT(0,"wait4DowninkerReady"); wait4DownLinkerReady(); /* let downlinker become ready, then delete any left over buffers */ resetNameBufs(); /* free all named buffers */ /* stmInitial(pTheStmObject, 1, 1024, pUpLinkMsgQ, 0); */ clrDwnLkAbort(); wait4SystemReady(); /* pend till all activities are complete */ DPRINT(0,"enableInterrupts"); enableInterrupts(); /* now inform Expproc System is Ready */ statMsg.Status = SYSTEM_READY; /* Console Ready */ statMsg.Event = 0; /* Error Code */ msgQSend(pMsgesToHost,(char*) &statMsg,sizeof(statMsg), WAIT_FOREVER, MSG_PRI_NORMAL); update_acqstate( ACQ_IDLE ); getstatblock(); /* if (pTheTuneObject != NULL) semGive( pTheTuneObject->pSemAccessFIFO ); */ #endif sendSysReady(); break; case LOST_CONN: #ifdef INSTRUMENT wvEvent(EVENT_PHDLR_LOSTCONN,NULL,NULL); #endif #ifdef INOVA errLogRet(LOGIT,debugInfo, "phandler: Host Closed Connection to Console: %d", msge->reportEvent); update_acqstate( ACQ_IDLE ); /* stmItrpDisable(pTheStmObject, STM_ALLITRPS); */ storeConsoleDebug( SYSTEM_ABORT ); /* reprogram HSlines, ap registers to safe state */ reset2SafeState( msge->exceptionType ); resetSystem(); /* reset fifo, disable intrps, reset tasks & buffers */ /* stmReset(pTheStmObject); */ taskDelay(calcSysClkTicks(332)); /* taskDelay(20); */ resetNameBufs(); /* free all named buffers */ enableInterrupts(); /* if (pTheTuneObject != NULL) semGive( pTheTuneObject->pSemAccessFIFO ); */ taskSpawn("tRestart",50,0,2048,systemConRestart,NULL, 2,3,4,5,6,7,8,9,10); clrDwnLkAbort(); #endif break; case ALLOC_ERROR: #ifdef INSTRUMENT wvEvent(EVENT_PHDLR_ALLOCERROR,NULL,NULL); #endif #ifdef INOVA errLogRet(LOGIT,debugInfo, "phandler: Memory Allocation Error: %d", msge->reportEvent); update_acqstate( ACQ_IDLE ); statMsg.Status = HARD_ERROR; /* HARD_ERROR */ statMsg.Event = msge->reportEvent; /* Error Code */ msgQSend(pMsgesToHost,(char*) &statMsg,sizeof(statMsg), WAIT_FOREVER, MSG_PRI_URGENT); /* report HARD_ERROR to Recvproc */ DPRINT2(0,"stmHaltCode: doneCode: %d, errorCode: %d\n", HARD_ERROR,msge->reportEvent); /* stmHaltCode(pTheStmObject,(int) HARD_ERROR, (int) msge->reportEvent); */ /* reprogram HSlines, ap registers to safe state */ reset2SafeState( msge->exceptionType ); resetSystem(); /* reset fifo, disable intrps, reset tasks & buffers */ #ifdef XXXX statMsg.Status = WARNING_MSG; statMsg.Event = WARNINGS + MEM_ALLOC_ERR; /* Error Code */ msgQSend(pMsgesToHost,(char*) &statMsg,sizeof(statMsg), WAIT_FOREVER, MSG_PRI_NORMAL); #endif resetNameBufs(); /* free all named buffers */ /* stmInitial(pTheStmObject, 1, 1024, pUpLinkMsgQ, 0); */ clrDwnLkAbort(); DPRINT(0,"enableInterrupts"); enableInterrupts(); /* now inform Expproc System is Ready */ statMsg.Status = SYSTEM_READY; /* Console Ready */ statMsg.Event = 0; /* Error Code */ msgQSend(pMsgesToHost,(char*) &statMsg,sizeof(statMsg), WAIT_FOREVER, MSG_PRI_NORMAL); getstatblock(); /* if (pTheTuneObject != NULL) semGive( pTheTuneObject->pSemAccessFIFO ); */ #endif break; case WATCHDOG: #ifdef INOVA #ifdef INSTRUMENT wvEvent(EVENT_PHDLR_WATCHDOG,NULL,NULL); #endif /* Giv'm a bone */ errLogRet(LOGIT,debugInfo, "phandler: Watch Dog: %d", msge->reportEvent); #endif break; default: /* Who Cares */ errLogRet(LOGIT,debugInfo, "phandler: Invalid Exception Type: %d, Event: %d", msge->cmd, msge->errorcode); break; } /* nMsg2Read = msgQNumMsgs(pMsgesToPHandlr); DPRINT1(-1,"Message in Q: %d\n",nMsg2Read); */ if (msge->cmd != WARNING_MSG) resumeLedShow(); /* resume LED Idle display */ while ( (bytes = msgQReceive(pMsgesToPHandlr, (char*) &discardedmsge, sizeof( CNTLR_COMM_MSG ), NO_WAIT)) != ERROR ) { DPRINT(-1,"vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv\n"); DPRINT1(0,"Read %d bytes from Phandler msgQ, (Bogus Errors at this point)\n",bytes); DPRINT4(-1,"'%s': Exception from: -> '%s' <-, Type: %d, ErrorCode: %d \n", hostName, discardedmsge.cntlrId, discardedmsge.cmd, discardedmsge.errorcode); DPRINT(-1,"^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n"); } }
void ParticleSystemQuad::setTotalParticles(int tp) { // If we are setting the total number of particles to a number higher // than what is allocated, we need to allocate new arrays if( tp > _allocatedParticles ) { // Allocate new memory size_t quadsSize = sizeof(_quads[0]) * tp * 1; size_t indicesSize = sizeof(_indices[0]) * tp * 6 * 1; _particleData.release(); if (!_particleData.init(tp)) { CCLOG("Particle system: not enough memory"); return; } V3F_C4B_T2F_Quad* quadsNew = (V3F_C4B_T2F_Quad*)realloc(_quads, quadsSize); GLushort* indicesNew = (GLushort*)realloc(_indices, indicesSize); if (quadsNew && indicesNew) { // Assign pointers _quads = quadsNew; _indices = indicesNew; // Clear the memory memset(_quads, 0, quadsSize); memset(_indices, 0, indicesSize); _allocatedParticles = tp; } else { // Out of memory, failed to resize some array if (quadsNew) _quads = quadsNew; if (indicesNew) _indices = indicesNew; CCLOG("Particle system: out of memory"); return; } _totalParticles = tp; // Init particles if (_batchNode) { for (int i = 0; i < _totalParticles; i++) { _particleData.atlasIndex[i] = i; } } initIndices(); if (Configuration::getInstance()->supportsShareableVAO()) { setupVBOandVAO(); } else { setupVBO(); } // fixed http://www.cocos2d-x.org/issues/3990 // Updates texture coords. updateTexCoords(); } else { _totalParticles = tp; } // fixed issue #5762 // reset the emission rate setEmissionRate(_totalParticles / _life); resetSystem(); }
void DebugConnector::handleMessage(int type, uint8_t *payload, unsigned int paylen) { uint8_t *buf; uint16_t *buf_short; int rv; switch (type) { case MSGTYPE_SYSDISCOVER: buf = (uint8_t*) malloc(8); buf[0] = 8; // size buf[1] = MSGTYPE_SYSDISCOVER; // type buf[2] = 0xde; // version (hi) buf[3] = 0xad; // version (lo) buf[4] = ((uint16_t) m_debugModules.size()) >> 8; // num of debug modules (hi) buf[5] = ((uint16_t) m_debugModules.size()) & 0xff; // num of debug modules (lo) buf[6] = m_systemid >> 8; // system id (hi) buf[7] = m_systemid & 0xff; // system id (lo) rv = write(m_connectionfd, buf, 8); free(buf); if (rv != 8) { cerr << "handleMessage(type = MSGTYPE_SYSDISCOVER): Only " << rv << "Bytes written, 8 expected." << endl; } break; case MSGTYPE_SYSENUMERATE: // do system enumeration buf = (uint8_t*) malloc(6 * m_debugModules.size() + 2); buf[0] = 6 * m_debugModules.size() + 2; buf[1] = MSGTYPE_SYSENUMERATE; buf_short = (uint16_t*) &buf[2]; int i; for (i = 0; i < m_debugModules.size(); i++) { buf_short[i*3+0] = i; buf_short[i*3+1] = m_debugModules[i]->getType(); buf_short[i*3+2] = m_debugModules[i]->getVersion(); } rv = write(m_connectionfd, buf, 6 * m_debugModules.size() + 2); free(buf); if (rv != 6 * m_debugModules.size() + 2) { cerr << "handleMessage(type = MSGTYPE_SYSENUMERATE): Only " << rv << "Bytes written, " << (6 * m_debugModules.size() + 2) << " expected." << endl; } break; case MSGTYPE_SYSSTART: start(); buf = (uint8_t*) malloc(2); buf[0] = 2; buf[1] = MSGTYPE_SYSSTART; rv = write(m_connectionfd, buf, 2); free(buf); if (rv != 2) { cerr << "handleMessage(type = MSGTYPE_SYSSTART): Only " << rv << "Bytes written, 2 expected." << endl; } break; case MSGTYPE_SYSRESET: // do a reset resetSystem(); break; case MSGTYPE_MODSEND: uint16_t smaddress; DebugModule *smod; uint16_t saddress; uint16_t ssize; uint16_t sresponse; smaddress = ((payload[0] << 8) & 0xff00) | (payload[1] = 0xff); if (smaddress >= m_debugModules.size()) { cerr << "module send for invalid module address" << endl; break; } smod = m_debugModules[smaddress]; saddress = ((payload[2] << 8) & 0xff00) | (payload[3] & 0xff); ssize = paylen - 4; sresponse = smod->write(saddress, ssize, (char*) &payload[4]); buf = (uint8_t*) malloc(4); buf[0] = 4; buf[1] = MSGTYPE_MODSEND; buf[2] = sresponse >> 8; buf[3] = sresponse & 0xff; rv = write(m_connectionfd, buf, 4); free(buf); if (rv != 4) { cerr << "handleMessage(type = MSGTYPE_MODSEND): Only " << rv << "Bytes written, 4 expected." << endl; } break; default: cout << "unhandled debug request" << endl; break; } }
static void AbortExp(EXCEPTION_MSGE *msge) { /* donecode = EXP_ABORTED or HARD_ERROR plus errorCode(FOO,etc..) */ /* need to get this msge up to expproc as soon as possible since the receipt of this msge cause expproc to send the SIGUSR2 (abort cmd) to Sendproc, without this msge all the acodes will be sent down. */ /* EXP_ABORT or HARD_ERROR */ statMsg.Status = (msge->exceptionType != INTERACTIVE_ABORT) ? msge->exceptionType : EXP_ABORTED; statMsg.Event = msge->reportEvent; /* Error Code */ if (msge->reportEvent == (HDWAREERROR + STMERROR)) reportNpErr(pTheStmObject->npOvrRun, 1 + pTheStmObject->activeIndex); msgQSend(pMsgesToHost,(char*) &statMsg,sizeof(statMsg), WAIT_FOREVER, MSG_PRI_URGENT); DPRINT2(0,"stmHaltCode: doneCode: %d, errorCode: %d\n", msge->exceptionType,msge->reportEvent); stmHaltCode(pTheStmObject,(int) statMsg.Status, (int) msge->reportEvent); if ( msge->exceptionType == EXP_ABORTED) storeConsoleDebug( SYSTEM_ABORT ); /* reprogram HSlines, ap registers to safe state */ reset2SafeState( msge->exceptionType ); resetSystem(); /* reset fifo, disable intrps, reset tasks & buffers */ if (msge->reportEvent == (SFTERROR + MAXCT)) { /* if maxsum error reset the stm */ /* obtain lock on stm, i.e. not transfer data prior to reseting stm */ stmTake(pTheStmObject); stmReset(pTheStmObject); taskDelay(sysClkRateGet()/3); /* only after wait for the stm to functional again do we release the lock */ stmGive(pTheStmObject); } DPRINT(0,"wait4DowninkerReady"); wait4DownLinkerReady(); /* let downlinker become ready, then delete any left over buffers */ resetNameBufs(); /* free all named buffers */ DPRINT(0,"wait4SystemReady"); wait4SystemReady(); /* pend till all activities are complete */ DPRINT(0,"SystemReady"); clrDwnLkAbort(); DPRINT(0,"enableInterrupts"); enableInterrupts(); /* now inform Expproc System is Ready */ statMsg.Status = SYSTEM_READY; /* Console Ready */ statMsg.Event = 0; /* Error Code */ msgQSend(pMsgesToHost,(char*) &statMsg,sizeof(statMsg), WAIT_FOREVER, MSG_PRI_NORMAL); update_acqstate( ACQ_IDLE ); getstatblock(); if (pTheTuneObject != NULL) semGive( pTheTuneObject->pSemAccessFIFO ); return; }
/********************************************************************* * * recovery, based on the cmd code decides what recovery action * to perform. * * Author Greg Brissey 12-7-94 */ void recovery(EXCEPTION_MSGE *msge) { char *token; int len; int cmd; int i,nMsg2Read; int bytes; EXCEPTION_MSGE discardMsge; extern int systemConRestart(); static void resetSystem(); static void resetNameBufs(); /* reset STM & ADC Intrp MsgQ to standard msgQ, encase they have been switched */ stmRestoreMsgQ(pTheStmObject); switch( msge->exceptionType ) { case PANIC: #ifdef INSTRUMENT wvEvent(EVENT_PHDLR_PANIC,NULL,NULL); #endif errLogRet(LOGIT,debugInfo, "phandler: Panic Error: %d", msge->reportEvent); break; case WARNING_MSG: #ifdef INSTRUMENT wvEvent(EVENT_PHDLR_WARNMSG,NULL,NULL); #endif DPRINT2(0,"WARNING: doneCode: %d, errorCode: %d\n", msge->exceptionType,msge->reportEvent); /* errLogRet(LOGIT,debugInfo, "phandler: Warning Message: %d", msge->reportEvent); */ statMsg.Status = msge->exceptionType; statMsg.Event = msge->reportEvent; /* Error Code */ msgQSend(pMsgesToHost,(char*) &statMsg,sizeof(statMsg), WAIT_FOREVER, MSG_PRI_NORMAL); break; case SOFT_ERROR: #ifdef INSTRUMENT wvEvent(EVENT_PHDLR_SOFTERROR,NULL,NULL); #endif update_acqstate( ACQ_IDLE ); DPRINT2(0,"SOFT_ERROR: doneCode: %d, errorCode: %d\n", msge->exceptionType,msge->reportEvent); /* errLogRet(LOGIT,debugInfo, "phandler: Soft Error: %d", msge->reportEvent); */ statMsg.Status = msge->exceptionType; statMsg.Event = msge->reportEvent; /* Error Code */ msgQSend(pMsgesToHost,(char*) &statMsg,sizeof(statMsg), WAIT_FOREVER, MSG_PRI_NORMAL); break; case EXP_ABORTED: #ifdef INSTRUMENT wvEvent(EVENT_PHDLR_EXPABORTED,NULL,NULL); #endif stmItrpDisable(pTheStmObject, STM_ALLITRPS); DPRINT(0,"Exp. Aborted"); case HARD_ERROR: #ifdef INSTRUMENT wvEvent(EVENT_PHDLR_HARDERROR,NULL,NULL); #endif DPRINT1(0,"HARD_ERROR: doneCode: %d, errorCode: %d\n", msge->reportEvent); AbortExp(msge); fifoCloseLog(pTheFifoObject); DPRINT(0,"Done"); break; case INTERACTIVE_ABORT: #ifdef INSTRUMENT wvEvent(EVENT_PHDLR_HARDERROR,NULL,NULL); #endif DPRINT1(0,"INTERACTIVE_ABORT: doneCode: %d, errorCode: %d\n", msge->reportEvent); AbortExp(msge); fifoCloseLog(pTheFifoObject); DPRINT(0,"Done"); break; case EXP_HALTED: #ifdef INSTRUMENT wvEvent(EVENT_PHDLR_EXPHALTED,NULL,NULL); #endif stmItrpDisable(pTheStmObject, STM_ALLITRPS); statMsg.Status = msge->exceptionType; statMsg.Event = msge->reportEvent; /* Error Code */ msgQSend(pMsgesToHost,(char*) &statMsg,sizeof(statMsg), WAIT_FOREVER, MSG_PRI_NORMAL); errLogRet(LOGIT,debugInfo, "phandler: Exp. Halted: %d", msge->reportEvent); /* Based on the premise the user now has achieve the S/N or whatever from data that has already been obtained therefore there is no need to wait for any data to be acquired. I.E. Halt Experiment with extreme prejudice! */ /* reprogram HSlines, ap registers to safe state */ reset2SafeState( msge->exceptionType ); resetSystem(); /* reset fifo, disable intrps, reset tasks & buffers */ update_acqstate( ACQ_IDLE ); DPRINT2(0,"stmHaltCode: doneCode: %d, errorCode: %d\n", msge->exceptionType,msge->reportEvent); stmHaltCode(pTheStmObject,(int) msge->exceptionType, (int) msge->reportEvent); DPRINT(0,"EXP_HALTED: lower priority below upLinker\n"); taskPrioritySet(pHandlerTid,(UPLINKER_TASK_PRIORITY+1)); taskPrioritySet(pHandlerTid,pHandlerPriority); DPRINT(0,"wait4DowninkerReady"); wait4DownLinkerReady(); /* let downlinker become ready, then delete any left over buffers */ resetNameBufs(); /* free all named buffers */ stmInitial(pTheStmObject, 1, 1024, pUpLinkMsgQ, 0); clrDwnLkAbort(); wait4SystemReady(); /* pend till all activities are complete */ DPRINT(0,"enableInterrupts"); enableInterrupts(); /* now inform Expproc System is Ready */ statMsg.Status = SYSTEM_READY; /* Console Ready */ statMsg.Event = 0; /* Error Code */ msgQSend(pMsgesToHost,(char*) &statMsg,sizeof(statMsg), WAIT_FOREVER, MSG_PRI_NORMAL); update_acqstate( ACQ_IDLE ); getstatblock(); if (pTheTuneObject != NULL) semGive( pTheTuneObject->pSemAccessFIFO ); break; case STOP_CMPLT: /* the monitor set the SA_Criteria value, when the upLinker obtained a FID that meet this Criteria the upLinker sent this msge here and then blocked itself Our job is to 1. Foward the Stopped msge to Host 2. reset hardware 3. put hardware into a safe state 4. call stmSA, clears upLinker msgQ, send SA msge 5. reset SA_Criteria back to Zero 6. give the semaphore to restart upLinker 7. reset update task 8. reset parser task 9. Free the buffers 10. Re-enable Interrupts */ #ifdef INSTRUMENT wvEvent(EVENT_PHDLR_STOPCMPLT,NULL,NULL); #endif statMsg.Status = msge->exceptionType; statMsg.Event = msge->reportEvent; /* Error Code */ msgQSend(pMsgesToHost,(char*) &statMsg,sizeof(statMsg), WAIT_FOREVER, MSG_PRI_NORMAL); errLogRet(LOGIT,debugInfo, "phandler: Exp. Stopped: %d", msge->reportEvent); /* reprogram HSlines, ap registers to safe state */ reset2SafeState( msge->exceptionType ); resetSystem(); /* reset fifo, disable intrps, reset tasks & buffers */ DPRINT2(0,"stmHaltCode: doneCode: %d, errorCode: %d\n", msge->exceptionType,msge->reportEvent); clearIntrpMsgQ(pTheStmObject); semGive(pSemSAStop); /* release the UpLinker */ stmHaltCode(pTheStmObject,(int) msge->exceptionType, (int) msge->reportEvent); /* DPRINT(0,"stmSA"); stmSA(pTheStmObject); */ DPRINT(0,"STOP_CMPLT: lower priority below upLinker\n"); taskPrioritySet(pHandlerTid,(UPLINKER_TASK_PRIORITY+1)); taskPrioritySet(pHandlerTid,pHandlerPriority); SA_Criteria = 0; SA_Mod = 0L; DPRINT(0,"wait4DowninkerReady"); wait4DownLinkerReady(); /* let downlinker become ready, then delete any left over buffers */ resetNameBufs(); /* free all named buffers */ stmInitial(pTheStmObject, 1, 1024, pUpLinkMsgQ, 0); clrDwnLkAbort(); wait4SystemReady(); /* pend till all activities are complete */ DPRINT(0,"enableInterrupts"); enableInterrupts(); /* now inform Expproc System is Ready */ statMsg.Status = SYSTEM_READY; /* Console Ready */ statMsg.Event = 0; /* Error Code */ msgQSend(pMsgesToHost,(char*) &statMsg,sizeof(statMsg), WAIT_FOREVER, MSG_PRI_NORMAL); update_acqstate( ACQ_IDLE ); getstatblock(); if (pTheTuneObject != NULL) semGive( pTheTuneObject->pSemAccessFIFO ); break; case LOST_CONN: #ifdef INSTRUMENT wvEvent(EVENT_PHDLR_LOSTCONN,NULL,NULL); #endif errLogRet(LOGIT,debugInfo, "phandler: Host Closed Connection to Console: %d", msge->reportEvent); update_acqstate( ACQ_IDLE ); stmItrpDisable(pTheStmObject, STM_ALLITRPS); storeConsoleDebug( SYSTEM_ABORT ); /* reprogram HSlines, ap registers to safe state */ reset2SafeState( msge->exceptionType ); resetSystem(); /* reset fifo, disable intrps, reset tasks & buffers */ stmReset(pTheStmObject); taskDelay(sysClkRateGet()/3); resetNameBufs(); /* free all named buffers */ enableInterrupts(); if (pTheTuneObject != NULL) semGive( pTheTuneObject->pSemAccessFIFO ); taskSpawn("tRestart",50,0,2048,systemConRestart,NULL, 2,3,4,5,6,7,8,9,10); clrDwnLkAbort(); break; case ALLOC_ERROR: #ifdef INSTRUMENT wvEvent(EVENT_PHDLR_ALLOCERROR,NULL,NULL); #endif errLogRet(LOGIT,debugInfo, "phandler: Memory Allocation Error: %d", msge->reportEvent); update_acqstate( ACQ_IDLE ); statMsg.Status = HARD_ERROR; /* HARD_ERROR */ statMsg.Event = msge->reportEvent; /* Error Code */ msgQSend(pMsgesToHost,(char*) &statMsg,sizeof(statMsg), WAIT_FOREVER, MSG_PRI_URGENT); /* report HARD_ERROR to Recvproc */ DPRINT2(0,"stmHaltCode: doneCode: %d, errorCode: %d\n", HARD_ERROR,msge->reportEvent); stmHaltCode(pTheStmObject,(int) HARD_ERROR, (int) msge->reportEvent); /* reprogram HSlines, ap registers to safe state */ reset2SafeState( msge->exceptionType ); resetSystem(); /* reset fifo, disable intrps, reset tasks & buffers */ #ifdef XXXX statMsg.Status = WARNING_MSG; statMsg.Event = WARNINGS + MEM_ALLOC_ERR; /* Error Code */ msgQSend(pMsgesToHost,(char*) &statMsg,sizeof(statMsg), WAIT_FOREVER, MSG_PRI_NORMAL); #endif resetNameBufs(); /* free all named buffers */ stmInitial(pTheStmObject, 1, 1024, pUpLinkMsgQ, 0); clrDwnLkAbort(); DPRINT(0,"enableInterrupts"); enableInterrupts(); /* now inform Expproc System is Ready */ statMsg.Status = SYSTEM_READY; /* Console Ready */ statMsg.Event = 0; /* Error Code */ msgQSend(pMsgesToHost,(char*) &statMsg,sizeof(statMsg), WAIT_FOREVER, MSG_PRI_NORMAL); getstatblock(); if (pTheTuneObject != NULL) semGive( pTheTuneObject->pSemAccessFIFO ); break; case WATCHDOG: #ifdef INSTRUMENT wvEvent(EVENT_PHDLR_WATCHDOG,NULL,NULL); #endif /* Giv'm a bone */ errLogRet(LOGIT,debugInfo, "phandler: Watch Dog: %d", msge->reportEvent); break; default: /* Who Cares */ errLogRet(LOGIT,debugInfo, "phandler: Invalid Exception Type: %d, Event: %d", msge->exceptionType, msge->reportEvent); break; } /* nMsg2Read = msgQNumMsgs(pMsgesToPHandlr); DPRINT1(-1,"Message in Q: %d\n",nMsg2Read); */ while ( (bytes = msgQReceive(pMsgesToPHandlr, (char*) &msge, sizeof( EXCEPTION_MSGE ), NO_WAIT)) != ERROR ) { DPRINT1(0,"Read %d bytes from Phandler msgQ, (Bogus Errors at this point)\n",bytes); } }
void TutorialUnitGui::on_resetButton_clicked() { emit resetSystem(); }
void TutorialGui::on_resetButton_clicked() { emit resetSystem(); parentWidget()->hide(); }
static void AbortExp(CNTLR_COMM_MSG *msge, int externflag) { int result; char cntlrList[256]; /* donecode = EXP_ABORTED or HARD_ERROR plus errorCode(FOO,etc..) */ /* need to get this msge up to expproc as soon as possible since the receipt of this msge cause expproc to send the SIGUSR2 (abort cmd) to Sendproc, without this msge all the acodes will be sent down. */ /* This controller is sending the exception and fail has yet to be asserted */ if ( (externflag == 0) && (failAsserted != 1) ) { DPRINT(-1,"AbortExp: Asserting FalureLine\n"); assertFailureLine(); /* assert failure, if this is the controller causing * error and not already asserted */ } /* EXP_ABORT or HARD_ERROR */ /* * statMsg.Status = (msge->exceptionType != INTERACTIVE_ABORT) ? msge->exceptionType : EXP_ABORTED; * statMsg.Event = msge->reportEvent; /* Error Code */ #ifdef INOVA if (msge->reportEvent == (HDWAREERROR + STMERROR)) reportNpErr(pTheStmObject->npOvrRun, 1 + pTheStmObject->activeIndex); #endif /* stop lock/spinvt error/warning msgs */ setLkInterLk(0); setVTinterLk(0); setSpinInterlk(0); /* ------------------------------------------------- */ /* send abort message to Expproc */ send2Expproc(CASE,msge->cmd,msge->errorcode,0,NULL,0); /* send tickcount & active channel reset info to Console_Stat */ sendInfo2ConsoleStat(0); /* Controller output from FIFO to Software registers */ /* setFifoOutputSelect(SELECT_SW_CONTROLLED_OUTPUT); no longer needed, as per Debbie */ /* force values that must serialized out to whomever */ /* setAbortSerializedStates(); no longer needed, as per Debbie */ /* clear Experiment downld codes,patterns,tables, etc. * and restart parser * */ DPRINT(-1,"restart AParser\n"); /* several things that could have the parser Suspended */ givePrepSem(); /* only the master, go('prep') semaphore */ /* giveRoboAckSem(); /* just a master */ abortRoboAckMsgQ(); /* send sample change Ack msg with abort to release parser if pended */ giveParseSem(); parseCntDownReset(); AParserAA(); /* resetExpBufsAndParser(); replaced with AParserAA above */ DPRINT(-1,"Waiting for Parser to be ready\n"); wait4ParserReady(WAIT_FOREVER); /* ------------------------------------------------- */ resetTnEqualsLkState(); // recover if we had tn='lk' /* ------------------------------------------------- */ if ( pTheVTObject != NULL) semGive(pTheVTObject->pVTRegSem); // stop wainting for VT // liq spinner is different /* ------------------------------------------------- */ /* Disable DMA, and clear any Queued DMA transfers */ abortFifoBufTransfer(); /* reset FIFO */ cntrlFifoReset(); /* ------------------------------------------------- */ freeAllDwnldBufsSynced(); /* free download buffer after dwnld completion msg recv'd */ DPRINT(-1,"wait4CnltrsReady"); /* cntlrStatesCmp(CNTLR_EXCPT_CMPLT, 5); /* wait for controller to become ready for 5 sec max */ result = cntlrStatesCmpList(CNTLR_EXCPT_CMPLT, 30, cntlrList); /* 1/2 minute to complete */ if (result > 0) { errLogRet(LOGIT,debugInfo, "AbortExp(): Master Timed Out on Cntlrs reporting Exception Complete.\n"); errLogRet(LOGIT,debugInfo, "ABortExp(): Controllers: -> '%s' <- FAILED to report Exception Completed \n", cntlrList); } DPRINT(-1,"CnltrsAreReady"); /* int cntlrStatesCmp(READYANDIDLE, WAIT_FOREVER or time in ticks) */ /* wait4SystemReady(); /* pend till all activities are complete */ /* send2Expproc(CASE,msge->cmd,msge->errorcode,0,NULL,0); */ send2Expproc(CASE,SYSTEM_READY,0,0,NULL,0); /* sendSysReady(); */ setFidCtState(0, 0); setAcqState(ACQ_IDLE); if (pSemOK2Tune != NULL) semGive(pSemOK2Tune); /* now allow tuning */ /* if ( msge->exceptionType == EXP_ABORTED) storeConsoleDebug( SYSTEM_ABORT ); */ /* reprogram HSlines, ap registers to safe state */ #ifdef INOVA reset2SafeState( msge->exceptionType ); resetSystem(); /* reset fifo, disable intrps, reset tasks & buffers */ if (msge->reportEvent == (SFTERROR + MAXCT)) { /* if maxsum error reset the stm */ /* obtain lock on stm, i.e. not transfer data prior to reseting stm */ /* only after wait for the stm to functional again do we release the lock */ } DPRINT(0,"wait4DowninkerReady"); wait4DownLinkerReady(); /* let downlinker become ready, then delete any left over buffers */ resetNameBufs(); /* free all named buffers */ DPRINT(0,"wait4SystemReady"); wait4SystemReady(); /* pend till all activities are complete */ DPRINT(0,"SystemReady"); clrDwnLkAbort(); DPRINT(0,"enableInterrupts"); /* now inform Expproc System is Ready */ statMsg.Status = SYSTEM_READY; /* Console Ready */ statMsg.Event = 0; /* Error Code */ msgQSend(pMsgesToHost,(char*) &statMsg,sizeof(statMsg), WAIT_FOREVER, MSG_PRI_NORMAL); update_acqstate( ACQ_IDLE ); getstatblock(); /* if (pTheTuneObject != NULL) semGive( pTheTuneObject->pSemAccessFIFO ); */ #endif return; }