void CDBThread::connect2db() { #ifdef __SYB_ESQL__ int ret = -1; while((ret = ::connectDb(sysPtr->getSysCfg().szDbUser, sysPtr->getSysCfg().szDbPassword, sysPtr->getSysCfg().szDbName)) < 0 && !EXIT()) { LOG4CXX_WARN(dbLogger, "Connect to DB failed: "<<::getLastError()<<", retry after 3s ..."); ::disconnectDb(0); Delay2(3, 0); } if(ret >= 0) LOG4CXX_DEBUG(dbLogger, "Connect to db OK"); #endif #ifdef __SYB_CTLIB__ while(m_pSybClient->open() < 0 && !EXIT()) { LOG4CXX_WARN(dbLogger, "SYBASE CTLIB initialize failed, retry after 3s ..."); Delay2(3, 0); } while((m_iDbConnId = m_pSybClient->connect(sysPtr->getSysCfg().szDbName, sysPtr->getSysCfg().szDbUser, sysPtr->getSysCfg().szDbPassword)) < 0 && !EXIT()) { LOG4CXX_WARN(dbLogger, "Connect to db failed, retry after 3s ..."); Delay2(3, 0); } if(m_iDbConnId >= 0) LOG4CXX_DEBUG(dbLogger, "Connect to db OK"); #endif }
void CAMERA(void) { SIU.PCR[27].R = 0x0200; /* Program the Sensor read start pin as output*/ SIU.PCR[29].R = 0x0200; /* Program the Sensor Clock pin as output*/ for(j=0;j<2;j++) { SIU.PCR[27].R = 0x0200; /* Program the Sensor read start pin as output*/ SIU.PCR[29].R = 0x0200; /* Program the Sensor Clock pin as output*/ SIU.PGPDO[0].R &= ~0x00000014; /* All port line low */ SIU.PGPDO[0].R |= 0x00000010; /* Sensor read start High */ Delay(); SIU.PGPDO[0].R |= 0x00000004; /* Sensor Clock High */ Delay(); SIU.PGPDO[0].R &= ~0x00000010; /* Sensor read start Low */ Delay(); SIU.PGPDO[0].R &= ~0x00000004; /* Sensor Clock Low */ Delay(); for (i=0;i<128;i++) { Delay(); SIU.PGPDO[0].R |= 0x00000004; /* Sensor Clock High */ ADC.MCR.B.NSTART=1; /* Trigger normal conversions for ADC0 */ while (ADC.MCR.B.NSTART == 1) {}; adcdata = ADC.CDR[0].B.CDATA; Delay(); SIU.PGPDO[0].R &= ~0x00000004; /* Sensor Clock Low */ Result[i] = (uint8_t)(adcdata >> 2); } //Delaycamera2(); Delay2(); } //printlistall(); }
void CDBThread::_connect2db() { #ifdef __SYB_CTLIB__ m_pSybClient->disconnect(m_iDbConnId, true); while((m_iDbConnId = m_pSybClient->connect(sysPtr->getSysCfg().szDbName, sysPtr->getSysCfg().szDbUser, sysPtr->getSysCfg().szDbPassword)) < 0 && !EXIT()) { checkSybCtlibError("Connect to db failed: "); Delay2(3, 0); } if(m_iDbConnId >= 0) LOG4CXX_DEBUG(dbLogger, "Connect to db OK"); #endif }
void CObserverThread::run() { while(!EXIT()) { ++uiTimerCnt; //清理切换数据 int iTimer = sysPtr->getSysCfg().uiHoTimer/uiSleepPeriod; iTimer = (iTimer == 0) ? 1 : iTimer; if(uiTimerCnt/iTimer == 0) { //CGsmASythesize::GetInstance().GetCallMgr()->TimerClearHo(); } //sleep(uiSleepPeriod); Delay2(uiSleepPeriod, 0); } printf("RS monitor thread exit!\n"); }
main() { int i, delaytime; bit mark = 0; int bright = 0; while(1) { if(bright == 0) Delay2(50000); if(bright == 255 || bright == 0) mark = !mark; if(mark == 1) { bright++; delaytime = 9; } else { bright--; delaytime = 4; } for(i = 0; i < 255; i++) { if(i < bright) { Pin = 0; Delay(delaytime); } else { Pin = 1; Delay(delaytime); } } } }
void SYSTEM::Run( ) { char evtBuf[IPC_MAXMSG] = {0}; WEvent ev; int r = 0; // int registerState = SYS_NOTREGISTER; RegisterLabel: while ((FALSE == isExit) && (SYS_NOTREGISTER == registerState)) { ipcPtr->Exit( ); Delay2(RETRY_INTERVAL, 0); LOG4CXX_DEBUG(rootlog, "Register to SYSMGR, please wait......"); int ir = ipcPtr->Init(lmid); if (ir < 0) { LOG4CXX_ERROR(rootlog, "Register to SYSMGR failed"); } else { rmi_t rmid = ir; RealModuleId* pRealM = (RealModuleId*)&rmid; char buf[128] = {0}; sprintf(buf, "LMID=0x%04X, NID=0x%04X, AC=0x%04X, RMID=0x%08lX\n", pRealM->lmi, pRealM->ni, pRealM->ac, rmid); LOG4CXX_DEBUG(rootlog, "Register to SYSMGR success. "<<buf); registerState = SYS_REGISTERED; } } // while (isExit == FALSE) { ev.msgPtr = evtBuf; if (SYS_NOTREGISTER == registerState) { ipcPtr->Exit( ); goto RegisterLabel; } r = ipcPtr->GetMsgV2(ev); if((r > 0) && (ev.what != evNothing)) { HandleEvent(ev); } else if(r == 0) { Delay2(0, 10000); // sleep 10ms } else { LOG4CXX_ERROR(rootlog, "Get msg from IPC Queue failed."); } //ev.del(); } // //////////////////////////////////////////////////////////////////// // CProtocolTree* packets[512] = {0}; // int n; // while ((FALSE == isExit)) // { // n = 512; // n = packetBuffer.pop_back(&packets[0], n); // if(n>0) // { // for(int ii = 0; ii < n; ++ii) // { // CGsmASythesize::GetInstance().handleProtocol(packets[ii]); // delete packets[ii]; // } // } // } LOG4CXX_DEBUG(rootlog, "Terminate by user press Ctrl-C"); }
// Takes digit and number for LED display void Display(int digit, int number){ GPIO_PORTB_DATA_R = 0x00; // Turns off LEDs GPIO_PORTE_DATA_R = digit; // Selects digit GPIO_PORTB_DATA_R = numbers[number]; // Turns on number in selected digit Delay2(); // Wait 0.1 ms }
void CDBThread::run() { while(!EXIT()) { // if(m_DelImsiMsisdnByImsiQueue.size() == 0 && m_DelImsiMsisdnByMsisdnQueue.size() == 0 && m_ImsiMsisdnUpdateQueue.size() == 0) { refreshDB(); Delay2(0, 500000); continue; } //delete imsi<=>msisdn by imsi //delete imsi<=>msisdn by msisdn //update imsi<=>msisdn pthread_mutex_lock(&m_ImsiMsisdnUpdateMutex); _DelImsiMsisdnByImsiQueue = m_DelImsiMsisdnByImsiQueue; m_DelImsiMsisdnByImsiQueue.clear(); // _DelImsiMsisdnByMsisdnQueue = m_DelImsiMsisdnByMsisdnQueue; m_DelImsiMsisdnByMsisdnQueue.clear(); // _ImsiMsisdnUpdateQueue = m_ImsiMsisdnUpdateQueue; m_ImsiMsisdnUpdateQueue.clear(); pthread_mutex_unlock(&m_ImsiMsisdnUpdateMutex); // if(_DelImsiMsisdnByImsiQueue.size() > 0) { vector<stIMSI*>::iterator it = _DelImsiMsisdnByImsiQueue.begin(); for(; it != _DelImsiMsisdnByImsiQueue.end(); ++it) { delImsiMsisdnByImsi(*it); // delete *it; } // _DelImsiMsisdnByImsiQueue.clear(); } // if(_DelImsiMsisdnByMsisdnQueue.size() > 0) { vector<stMSISDN*>::iterator it = _DelImsiMsisdnByMsisdnQueue.begin(); for(; it != _DelImsiMsisdnByMsisdnQueue.end(); ++it) { delImsiMsisdnByMsisdn(*it); // delete *it; } // _DelImsiMsisdnByMsisdnQueue.clear(); } // if(_ImsiMsisdnUpdateQueue.size() > 0) { vector<stImsiMsisdn*>::iterator it = _ImsiMsisdnUpdateQueue.begin(); for(; it != _ImsiMsisdnUpdateQueue.end(); ++it) { insertImsiMsisdn(*it); // delete *it; } _ImsiMsisdnUpdateQueue.clear(); } //refresh database refreshDB(); } #ifdef __SYB_ESQL__ ::disconnectDb(0); #endif #ifdef __SYB_CTLIB__ m_pSybClient->disconnect(m_iDbConnId, true); m_pSybClient->close(true); #endif LOG4CXX_DEBUG(dbLogger, "DB thread exit"); }