Exemplo n.º 1
0
ostream& operator<<(ostream&s, timeStamp z) {
  time_t s1970 = static_cast<time_t>(z.getI(timeUnit::sec(), timeBase::b1970()));
  int64_t nsI1970 = static_cast<int64_t>(s1970) * I64_C(1000000000);
  int64_t max_time_t = (I64_C(1)<<((sizeof(time_t)*8)-1))-1;  // eg. (2^(32-1)) -1
  if(! z.isInitialized()) {  
    s << "[uninitialized]";
  } else if(z < timeStamp(0, timeUnit::year(), timeBase::b1970()) ||
	    z > timeStamp(max_time_t, timeUnit::sec(), timeBase::b1970())) {
    timeLength tl(z - timeStamp(0, timeUnit::year(), timeBase::b1970()));
    // setting the oct flag is just a hack to tell the timeLength ostream<<
    // to print the time compressed
#if !defined(mips_sgi_irix6_4) && !defined(i386_unknown_nt4_0)  &&!defined(mips_unknown_ce2_11) //ccw 10 apr 2001
    ostream::fmtflags oldflags;
#else
    long oldflags;  // irix,nt environment doesn't define ostream::fmtflags
#endif
    oldflags = s.flags(ostream::oct);
    s << "[1970 + " << tl << "]"; 
    s.flags(oldflags);
  } else {
    int64_t nstot = z.getI(timeUnit::ns(), timeBase::b1970());
    int64_t nsrem = nstot - nsI1970;
    char dateStr[50];
    s1970 = mktime(localtime(&s1970));
    strcpy(dateStr, ctime(&s1970));
    char *p = strstr(dateStr, "\n");  // erase the nl
    if(p != NULL) {  *p++ = 0;   *p = 0; }
    char strFmt[30];
    insCommas(static_cast<int>(nsrem), strFmt);
    s << "[" << dateStr << "  " << strFmt << "ns]";
  }
  return s;
}
Exemplo n.º 2
0
void ASControl::SHM_checkDnarAlive()
{
#define CHECK_TIMES	18
	static int last_rd=0,tms=0;
	static time_t first_time=0,check_time=0;
	int now_rd;
	TsASControl* p_asTbl;
	usleep(100);
	if(!_dbIF->TransASControl(&p_asTbl)) 
	{
		printf("TransASControl fail,in SHM_checkDnarAlive(),prog exit\n");
		exit(1);
	}
	//if(!(now_rd =  p_asTbl->d_dnar_refresh)) return;

	now_rd =  p_asTbl->d_dnar_refresh;
	printf("now_rd=%d, last_rd=%d\n", now_rd, last_rd);
	printf("_dnar_status=%d\n", _dnar_status);
	if (last_rd != now_rd)
	{
		tms = 0;
		last_rd = now_rd;
		printf("(_dnar_status&L_DNAR_ALIVE)=%d\n",(_dnar_status&L_DNAR_ALIVE));
		if (!(_dnar_status&L_DNAR_ALIVE))
		{
			printf("LOCAL DNAR RESUME detected.%s\n",timeStamp());
			SendDnarDeadAlarmResume();
			
			_dnar_status|=L_DNAR_ALIVE;
			_dnar_status|=DNAR_UPDATE;
		}
	}
	else 
	{
		printf("tms=%d\n", tms);
		//第一次检测到
		if(1==++tms){
			first_time=time(NULL);
			check_time=first_time;}
		else{check_time=time(NULL);}
		printf("(check_time-first_time)=%d\n",(check_time-first_time));
		if((check_time-first_time)> CHECK_TIMES) 
		{
			if (_dnar_status&L_DNAR_ALIVE) 
			{
				printf("LOCAL DNAR_DEAD detected.%s\n",timeStamp());
				SendDnarDeadAlarm();

				_dnar_status&=~L_DNAR_ALIVE;
				_dnar_status|=DNAR_UPDATE;
			}
			//tms = CHECK_TIMES;
			tms=0;//replaced by wangxx 20120825
		}
	}
	return;
}
Exemplo n.º 3
0
Arquivo: main.c Projeto: koron/ctags
static void makeTags (cookedArgs *args)
{
	clock_t timeStamps [3];
	boolean resize = FALSE;
	boolean files = (boolean)(! cArgOff (args) || Option.fileList != NULL
							  || Option.filter);

	if (! files)
	{
		if (filesRequired ())
			error (FATAL, "No files specified. Try \"%s --help\".",
				getExecutableName ());
		else if (! Option.recurse && ! etagsInclude ())
			return;
	}

#define timeStamp(n) timeStamps[(n)]=(Option.printTotals ? clock():(clock_t)0)
	if ((! Option.filter) && (! Option.printLanguage))
		openTagFile ();

	timeStamp (0);

	if (! cArgOff (args))
	{
		verbose ("Reading command line arguments\n");
		resize = createTagsForArgs (args);
	}
	if (Option.fileList != NULL)
	{
		verbose ("Reading list file\n");
		resize = (boolean) (createTagsFromListFile (Option.fileList) || resize);
	}
	if (Option.filter)
	{
		verbose ("Reading filter input\n");
		resize = (boolean) (createTagsFromFileInput (stdin, TRUE) || resize);
	}
	if (! files  &&  Option.recurse)
		resize = recurseIntoDirectory (".");

	timeStamp (1);

	if ((! Option.filter) && (!Option.printLanguage))
		closeTagFile (resize);

	timeStamp (2);

	if (Option.printTotals)
		printTotals (timeStamps);
#undef timeStamp
}
Exemplo n.º 4
0
void archiveOutputFiles(const std::string &fileName)
{
  std::string stamp;
  std::vector<onelab::string> ps;
  onelab::server::instance()->get(ps,"0Metamodel/9Tag");
  if(ps.size() && ps[0].getValue().size())
    stamp.assign(timeStamp() + "_" + ps[0].getValue());
  else
    stamp.assign(timeStamp());

  // add time stamp in all output files in the db, and rename them on disk
  std::vector<onelab::string> strings;
  onelab::server::instance()->get(strings);
  for(unsigned int i = 0; i < strings.size(); i++){
    if(strings[i].getName().find("9Output files") != std::string::npos){
      std::vector<std::string> names = strings[i].getChoices();
      names.push_back(strings[i].getValue());
      for(unsigned int j = 0; j < names.size(); j++){
        std::vector<std::string> split = SplitFileName(names[j]);
        int n = split[1].size();
        // if name is not already stamped
        if(n < 18 || split[1][n-3] != '-' || split[1][n-6] != '-' ||
           split[1][n-9] != '_'){
          std::string old = names[j];
          CreateSingleDir(split[0] + "archive/");
          names[j] = split[0] + "archive/" + split[1] + stamp + split[2];
          Msg::Info("Renaming '%s' into '%s'", old.c_str(), names[j].c_str());
          rename(old.c_str(), names[j].c_str());
        }
      }
      strings[i].setValue(names.back());
      names.pop_back();
      strings[i].setChoices(names);
      onelab::server::instance()->set(strings[i]);
    }
  }

  // save stamped db
  {
    std::vector<std::string> split = SplitFileName(fileName);
    CreateSingleDir(split[0] + "archive/");
    saveDb(split[0] + "archive/" + split[1] + stamp + split[2]);
  }

#if defined(HAVE_FLTK)
  FlGui::instance()->rebuildTree(true);
#endif
}
Exemplo n.º 5
0
int receiveAndUnpackUdpPacket()
{
    pSession->sizeRemoteAddressInformation = sizeof pSession->remoteAddressInformation;
    if ((pHandleUdpLoad->sizeUdpLoadHasReceive = recvfrom(pSession->localSocket,
                                                        pHandleUdpLoad->aUdpLoadReceiveBuffer,
                                                        udpLoadReceiveMax,//udpLoadReceiveMax-1,////for end of string
                                                        0,
                                                        (struct sockaddr *)&pSession->remoteAddressInformation,
                                                        &pSession->sizeRemoteAddressInformation
                                                        )
         ) == -1)
    {
        perror("recvfrom");
        exit(1);
    }
    pSession->pTextIpRemote = inet_ntop(pSession->remoteAddressInformation.ss_family,
                                        getBinaryIp((struct sockaddr *)&pSession->remoteAddressInformation),
                                        pSession->aIpRemote,
                                        sizeof pSession->aIpRemote
                                        );
    printf("ok: got packet from %s\n",pSession->pTextIpRemote);
    if(dDbugOk){printf("ok: recv: %dbytes, %s.\n", pHandleUdpLoad->sizeUdpLoadHasReceive,pHandleUdpLoad->aUdpLoadReceiveBuffer);}
    else{if(dbug)printf("ok: sizeUdpLoadHasReceive:%d.\n",pHandleUdpLoad->sizeUdpLoadHasReceive);}

    printf("ok: receiveAndUnpackUdpPacket().%s.\n",timeStamp());
    return 0;
}
Exemplo n.º 6
0
void* TrampolineMgr::printInfoR(uint32_t index, CallStack* stack)
{
    void* rv = g_returnInfo->top().retAddr;
    std::ostream* out;

    out = m_pInstance->getLogger();

    auto it = g_returnInfo->top().it;

    std::string stamp = timeStamp();
    (*out) << std::string(20 - stamp.size(), ' ');
    (*out) << '[' << stamp << "] ";
    (*out) << std::string(g_returnInfo->size(), ' ');

    ArgumentWalker w(stack);
    if (it != m_functionInfo.end())
        (*out) << "-> " << w.ret(it->second.retType);
    else
        (*out) << "-> ? (" << w.ret('p') << ')';

    (*out) << " {" << callTime() << "} errno=" << errno << std::endl << std::flush;

    g_returnInfo->pop();

    // standard retval in rax, double in xmm0
    return rv;
}
Exemplo n.º 7
0
bool ErrorLogger::Stop(const QString& stopMessage)
{
	bool retval = false;

	if (m_LogFile.isOpen())
	{
		if (!stopMessage.isEmpty())
		{
			QString timeStamp("");
			QDateTime now = QDateTime::currentDateTime();
			timeStamp = now.toString("yyyy-MM-dd hh:mm:ss");

			m_LogStream << "     ***** STOP *****\n";
			m_LogStream << timeStamp;
			m_LogStream << " ";
			m_LogStream << stopMessage;
			m_LogStream << "\n     ***** STOP *****\n";
		}

		m_LogStream.flush();
		m_LogStream.setDevice(0);
		m_LogFile.close();

		retval = true;
	}

	return retval;
}
Exemplo n.º 8
0
int tryAccept()
{
    pSession->sizeRemoteAddressInformation = sizeof pSession->remoteAddressInformation;
    pSession->localSocket = accept(pSession->localListener,
                                    (struct sockaddr *)&pSession->remoteAddressInformation,
                                    &pSession->sizeRemoteAddressInformation
                                    );

    if (pSession->localSocket == -1)
    {
        perror("ERR: accept");
        return 1;
    }
    else
    {
        debug("ok: accept().");
    }

    //inet_ntop: convert IPv4 or IPv6 addresses from binary to text string form
    inet_ntop(pSession->remoteAddressInformation.ss_family,
              getBinaryIp( (struct sockaddr *) &pSession->remoteAddressInformation ),
              pSession->aIpRemote,
              sizeof pSession->aIpRemote
             );
    printf("ok: got connection from: %s, %s.\n\n", pSession->aIpRemote,timeStamp());//char ipRemote[INET6_ADDRSTRLEN];

    return 0;
}
Exemplo n.º 9
0
bool ErrorLogger::Start(const QString& fileName, const QString& startMessage,
	bool abortOnFatal)
{
	bool retval = false;

	if (!fileName.isEmpty() && !m_LogFile.isOpen())
	{
		m_LogFile.setFileName(fileName);
		m_LogFile.open(QIODevice::Append | QIODevice::Text);
		AbortOnFatal(abortOnFatal);

		if (m_LogFile.isOpen())
		{
			m_LogStream.setDevice(&m_LogFile);

			if (!startMessage.isEmpty())
			{
				QString timeStamp("");
				QDateTime now = QDateTime::currentDateTime();
				timeStamp = now.toString("yyyy-MM-dd hh:mm:ss");
				
				m_LogStream << "     ***** START *****\n";
				m_LogStream << timeStamp;
				m_LogStream << " ";
				m_LogStream << startMessage;
				m_LogStream << "\n     ***** START *****\n";
			}

			retval = true;
		}
	}

	return retval;
}
//SIM800 initialization procedure for simple SMS and call features
void AGS::SIM800Init()
{
	while (Serial.available() > 0) Serial.read();
	Serial.println F("****************************************");
	while (sendATcommand("AT", "OK", 2000) == 0);
	Serial.println F("SIM800 available!");
	delay(2000);
	//otestuj registraci do site
	while ((sendATcommand("AT+CREG?", "+CREG: 0,1", 1000) ||
		sendATcommand("AT+CREG?", "+CREG: 0,5", 1000)) == 0);
	while (Serial.available() > 0) Serial.read();
	Serial.println F("SIM800 registered to GSM!");
	//parameters to obtain time stamp from GSM network
	while (sendATcommand("AT+CLTS=1", "OK", 500) == 0);
	while (sendATcommand("AT+CENG=3", "OK", 500) == 0);
	while (Serial.available() > 0) Serial.read();
	Serial.println("Time stamp from GSM:" + timeStamp());
	Serial.println("GSM signal quality:" + getQuality());
	Serial.println("GSM provider:" + getProviderName());
	sendATcommand("AT+CMGF=1", "OK", 500);
	//zakaz indikace SMS
	sendATcommand("AT+CNMI=0,0", "OK", 500);
	//CLIP enabled
	sendATcommand("AT+CLIP=1", "OK", 1000);
	//smaz vsechny SMSky
	sendATcommand("AT+CMGD=1,4", "OK", 2000);
	sendATcommand("AT+CMGD=1", "OK", 2000);
	Serial.println F("SIM800 has been configured!");
	Serial.println F("****************************************");
}
Exemplo n.º 11
0
bool Chat::handleMsg(User *user, std::string msg)
{
  // Timestamp
  time_t rawTime = time(NULL);

  struct tm *Tm  = localtime(&rawTime);

  std::string timeStamp (asctime(Tm));
  timeStamp = timeStamp.substr(11, 5);

  //
  // Chat commands
  //

  // Servermsg (Admin-only)
  if(msg[0] == SERVERMSGPREFIX && user->admin)
  {
    // Decorate server message
    msg = COLOR_RED + "[!] " + COLOR_GREEN + msg.substr(1);
    this->sendMsg(user, msg, ALL);
  }

  // Adminchat
  else if(msg[0] == ADMINCHATPREFIX && user->admin)
  {
    msg = timeStamp + " @@ <"+ COLOR_DARK_MAGENTA + user->nick + COLOR_WHITE + "> " + msg.substr(1);
    this->sendMsg(user, msg, ADMINS);
  }

  // Command
  else if(msg[0] == CHATCMDPREFIX)
  {
    std::deque<std::string> cmd = this->parseCmd(msg.substr(1));

    std::string command         = cmd[0];
    cmd.pop_front();

    // User commands
    CommandList::iterator iter;
    if((iter = userCommands.find(command)) != userCommands.end())
      iter->second(user, command, cmd);
    else if(user->admin && (iter = adminCommands.find(command)) != adminCommands.end())
      iter->second(user, command, cmd);
  }
  // Normal message
  else
  {
    if(user->admin)
      msg = timeStamp + " <"+ COLOR_DARK_MAGENTA + user->nick + COLOR_WHITE + "> " + msg;
    else
      msg = timeStamp + " <"+ user->nick + "> " + msg;

    LOG(msg);

    this->sendMsg(user, msg, ALL);
  }

  return true;
}
Exemplo n.º 12
0
void VPreviewManager::clearPreview()
{
    for (int i = 0; i < (int)PreviewSource::MaxNumberOfSources; ++i) {
        TS ts = ++timeStamp(static_cast<PreviewSource>(i));
        clearBlockObsoletePreviewInfo(ts, static_cast<PreviewSource>(i));
        clearObsoleteImages(ts, static_cast<PreviewSource>(i));
    }
}
Exemplo n.º 13
0
NAString CmpInternalSP::OutTableName()
{
  // To make the OutTableName unique, put in the timestamp
  // Note the timeStamp() above returns just lower 4 bytes of seconds since
  // 01/01/1970 00:00:00, so it may not be unique if we get here to soon.
  NAString tableName = "SPTableOut" + procName() + timeStamp();
  return tableName;
}
Exemplo n.º 14
0
std::vector<uint64_t> timeGenerator (uint64_t init_time, int num)
{
	std::vector<uint64_t> timeStamp(num);
	for (int i=0; i<num;++i)
	{
		timeStamp[i] = init_time + i * 100 + genRandom(0, 25);
	}
	return timeStamp;
}
Exemplo n.º 15
0
void setup()
{
	initBoard();
	while(true)
	{
		serial0.println(timeStamp());
		delay(300);
	}
}
Exemplo n.º 16
0
std::string Screen::currentTimestamp(bool seconds)
{
	time_t currentTime = time(nullptr);
	struct tm* Tm  = localtime(&currentTime);
	std::string timeStamp(asctime(Tm));
	timeStamp = timeStamp.substr(11, seconds ? 8 : 5);

	return timeStamp;
}
Exemplo n.º 17
0
void VPreviewManager::updateImageLinks(const QVector<VElementRegion> &p_imageRegions)
{
    if (!m_previewEnabled) {
        return;
    }

    TS ts = ++timeStamp(PreviewSource::ImageLink);
    previewImages(ts, p_imageRegions);
}
Exemplo n.º 18
0
void QInstallPage::resetPage(){
     wizard()->button(QWizard::BackButton)->setEnabled(true);
     wizard()->button(QWizard::FinishButton)->setEnabled(true);
     //installButton->setText("&Install");
     installButton->setEnabled(true);
     progressBar->setValue( progressBar->maximum() );
     //connect(installButton,SIGNAL(clicked()),this,SLOT(start()));
     //qDebug("Total steps = %d",i_config_steps);
     timeStamp();
}
Exemplo n.º 19
0
TargetPixel::TargetPixel(LightElement *st0) : BasePixel() {
  target = new SubPixel(st0);
  if (st0->lightType != LightElement::TARGET) {
    timeStamp(); std::clog << "Attempt to use non-taget LightElement with TargetPixel\n";
  }
  rotA = trotA = 0.0f;
  x = y = z = -1;
  isTarget = true;

}
Exemplo n.º 20
0
/*access shared memory interface*/
void ASControl::SHM_updateAS(int as_state)
{
	TsASControl* p_asTbl;
	usleep(100);/*syscall gap*/
	if(!_dbIF->TransASControl(&p_asTbl)) {
		printf("TransASControl fail,in SHM_updateAS(),prog exit\n");
		exit(1);
	}
	p_asTbl->d_as_state = as_state;
	printf("updated AS to %s at %s\n",AS_str[as_state],timeStamp());
}
Exemplo n.º 21
0
void Search::readSettings(QSettings* config)
{
    setMailbox( config->value("mailbox", "inbox").toString() );
    setMailFrom( config->value("from").toString().trimmed() );
    setMailTo( config->value("to").toString().trimmed() );
    setMailSubject( config->value("subject").toString().trimmed() );
    setMailBody( config->value("body").toString().trimmed() );
    setStatus( config->value("status", Search::Any).toInt() );
    setName( config->value("name").toString().trimmed() );

    QString strDate = config->value("dateafter").toString();
    if (!strDate.isEmpty()) {
        QMailTimeStamp timeStamp(strDate);
        setAfterDate( timeStamp.toLocalTime().date() );
    }
    strDate = config->value("datebefore").toString();
    if (!strDate.isEmpty()) {
        QMailTimeStamp timeStamp(strDate);
        setBeforeDate( timeStamp.toLocalTime().date() );
    }
}
Exemplo n.º 22
0
int main(int argc, char *argv[])
{
    initialize(argc, argv);

    getaddrinfoSend();
    createSocketSend();

    getaddrinfoReceive();
    bindSendSocketAsReceive();
    freeaddrinfo(pSession->pGetaddrinfoResultLinkList);

    packTftpRequestPacket();
    packAndSendUdpPacket();

    pSession->commandTimer = clock();

    if(pSession->cReadOrWrite == 'r')//read request
    {
        debug("ok: read request");
        pPrepareTftpErrorPacket->expectedBlockNr = 1;
        receiveTheRequestFile();
    }
    else//write request
    {
        debug("ok: read request");

        //receive ack //ack of wrq
        receiveAndUnpackUdpPacket();
        unpackTftpPacket();//here, set pSession->requsetOk = 1

        pPrepareTftpErrorPacket->expectedOpcode = 4;
        pPrepareTftpErrorPacket->expectedBlockNr = 0;
        if(checkOpcodeAndBlockNr())
        {
            say("ERR: didn't get expected ack of write request.");
            exit(1);
        }

        debug("ok: get ack of write request.");
        pSession->requsetOk = 1;
        sendTheRequestFile();
        pSession->requsetOk = 0;
    }

    close(pSession->localSocket);
    debug("ok: close(localSocket).");

    pSession->commandTimer = clock() - pSession->commandTimer;
    printf("ok: handeling this command costs: %i s.\n",pSession->commandTimer/CLOCKS_PER_SEC);

    if(dbug){printf("ok: %s.\n",timeStamp());}
    return 0;
}
//-----------------------------------------------------------------------------
void CCBVirtualWallSensor::updateData( const double dt)
{
  mFgAnyTriggered = false;

  if ( mFgEnabled == true ) {
     mBitData[0] = mCBDriver->mCreateSensorPackage.virtualWall;
     if (mBitData[0])
       mFgAnyTriggered = true;

    // update time stamp of this measurement
    mTimeStamp = timeStamp();
  }
}
Exemplo n.º 24
0
void VPreviewManager::updateMathjaxBlocks(const QVector<QSharedPointer<VImageToPreview> > &p_images)
{
    if (!m_previewEnabled) {
        return;
    }

    TS ts = ++timeStamp(PreviewSource::MathjaxBlock);

    updateBlockPreviewInfo(ts, PreviewSource::MathjaxBlock, p_images);

    clearBlockObsoletePreviewInfo(ts, PreviewSource::MathjaxBlock);

    clearObsoleteImages(ts, PreviewSource::MathjaxBlock);
}
Exemplo n.º 25
0
void sendHttpRequest(byte ip[], int port, EthernetClient cl) {
  if (cl.connect(ip, port)) {
    timeStamp();
    Serial.print("Host ");
    printIp(ip);
    Serial.print(" ");
    Serial.println(buf);
    cl.println(buf);
    cl.print("Host: ");
    sendIpClient(SELF_IP, cl);
    cl.println();
    cl.println();
    delay(100);
    cl.stop();
  } else {
      timeStamp();
      Serial.print("Host ");
      printIp(ip);
      Serial.print(" not connected (");
      Serial.print(buf);
      Serial.println(")");
    }
}
Exemplo n.º 26
0
LightFile::LightFile(const char *dmxFilename) {
  minCol = new int[Panels::PANEL_CNT];
  maxCol = new int[Panels::PANEL_CNT];
  minRow = new int[Panels::PANEL_CNT];
  maxRow = new int[Panels::PANEL_CNT];
  
  filenameStr = dmxFilename;
//  locFilenameStr = locFileName;


  if(open(file, dmxFilename)) {
    timeStamp(); clog << "INFO  Opened light file: " << dmxFilename << "\n";
  } else {
    timeStamp(); clog << "ERROR  Unable to open file: " << dmxFilename << endl;
			Globals::hasError = true;

  }
  
  /*
  if(open(locFile, locFileName)) {
    co ut << "Opened Light Location file: " << locFileName << endl;
  } else {
    cou t << "ERROR: unable to open file: " << locFileName << endl;
  }
  */
  
  for(int i = 0; i < Panels::PANEL_CNT; i++) {
    minCol[i] = INT_MAX;
    minRow[i] = INT_MAX;
    maxCol[i] = -INT_MAX;
    maxRow[i] = -INT_MAX;
  }
  line = 0;
  scale = 1;
  
}
Exemplo n.º 27
0
bool Chat::handleMsg(User* user, std::string msg)
{
  // Timestamp
  time_t rawTime = time(NULL);
  struct tm* Tm  = localtime(&rawTime);
  std::string timeStamp (asctime(Tm));
  timeStamp = timeStamp.substr(11, 5);

  bool blockMessage = false;
  Plugin::get()->hookChat.doUntilFalse(user, timeStamp, msg, &blockMessage);
  if (blockMessage)
  {
    return false;
  }

  char prefix = msg[0];

  switch(prefix)
  {
    // Servermsg (Admin-only)
    case SERVERMSGPREFIX:
      if(IS_ADMIN(user->permissions))
      {
        handleServerMsg(user, msg, timeStamp);
      }
      break;

    // Admin message
    case ADMINCHATPREFIX:
      if(IS_ADMIN(user->permissions))
      {
        handleAdminChatMsg(user, msg, timeStamp);
      }
      break;

    // Command
    case CHATCMDPREFIX:
      handleCommandMsg(user, msg, timeStamp);
      break;

    // Normal chat message
    default:
      handleChatMsg(user, msg, timeStamp);
      break;
  }

  return true;
}
Exemplo n.º 28
0
bool Chat::handleMsg(User* user, std::string msg)
{
  // Timestamp
  time_t rawTime = time(NULL);
  struct tm* Tm  = localtime(&rawTime);
  std::string timeStamp (asctime(Tm));
  timeStamp = timeStamp.substr(11, 5);

  if ((static_cast<Hook3<bool,User*,time_t,std::string>*>(Mineserver::get()->plugin()->getHook("ChatPre")))->doUntilFalse(user, rawTime, msg))
  {
    return false;
  }
  (static_cast<Hook3<void,User*,time_t,std::string>*>(Mineserver::get()->plugin()->getHook("ChatPre")))->doAll(user, rawTime, msg);

  char prefix = msg[0];

  switch(prefix)
  {
    // Servermsg (Admin-only)
    case SERVERMSGPREFIX:
      if(IS_ADMIN(user->permissions))
      {
        handleServerMsg(user, msg, timeStamp);
      }
      break;

    // Admin message
    case ADMINCHATPREFIX:
      if(IS_ADMIN(user->permissions))
      {
        handleAdminChatMsg(user, msg, timeStamp);
      }
      break;

    // Command
    case CHATCMDPREFIX:
      handleCommandMsg(user, msg, timeStamp);
      break;

    // Normal chat message
    default:
      handleChatMsg(user, msg, timeStamp);
      break;
  }

  return true;
}
Exemplo n.º 29
0
void testApp::update()
{
	static bool lastRecording = false;

	context.update();
	depth.update();
	user.update();

	if (recording)
	{
		recorder.update();
	}

	if (recording != lastRecording)
	{
		if (recording)
		{
			recorder.startRecord("recording-" + timeStamp() + ".oni");
		}
		else
		{
			recorder.stopRecord();
		}
	}
	lastRecording = recording;

	XnUserID userId = user.getTrackedUser(1)->id;

	xn::SkeletonCapability pUserSkel = user.getXnUserGenerator().GetSkeletonCap();
	if (pUserSkel.IsTracking(userId))
	{
        transformNode(0, XN_SKEL_TORSO);
        transformNode(1, XN_SKEL_WAIST);
        transformNode(2, XN_SKEL_LEFT_SHOULDER);
        transformNode(3, XN_SKEL_RIGHT_SHOULDER);
        transformNode(4, XN_SKEL_LEFT_ELBOW);
        transformNode(5, XN_SKEL_RIGHT_ELBOW);
        transformNode(6, XN_SKEL_LEFT_HIP);
        transformNode(7, XN_SKEL_RIGHT_HIP);
        transformNode(8, XN_SKEL_LEFT_KNEE);
        transformNode(9, XN_SKEL_RIGHT_KNEE);
        transformNode(10, XN_SKEL_NECK);
    }
}
Exemplo n.º 30
0
bool LightFile::readLine(char &let, int &col, int &row, float &x, float &y, float &z, int &dataEnablerID, int &channel) {
  // temporary strings for reading lines
  string letStr;
  string colStr;
  string rowStr;
  string xStr;
  string yStr;
  string zStr;
  string dataStr;
  string chanStr;
  
  
  if (getline(file, letStr, ',').eof()) return false;
  if (getline(file, colStr, ',').eof()) return false;
  if (getline(file, rowStr, ',').eof()) return false;
  if (getline(file, xStr, ',').eof()) return false;
  if (getline(file, yStr, ',').eof()) return false;
  if (getline(file, zStr, ',').eof()) return false;
  if (getline(file, dataStr, ',').eof()) return false;
  if (getline(file, chanStr).eof()) return false;
  
  let = letStr[0];
  if((let < 'A') || (let > 'J')) {
    timeStamp(); clog << "ERROR  Malformed Panel Letter (Letter must be between A and J)" << endl;
		Globals::hasError = true;

    return false;
  }
  
  col = atoi(colStr.c_str());
  row = atoi(rowStr.c_str());
  x = atof(xStr.c_str()) * scale;
  y = atof(yStr.c_str()) * scale;
  z = atof(zStr.c_str()) * scale;
  dataEnablerID = atoi(dataStr.c_str());
  channel = atoi(chanStr.c_str()); 
  
  line++;
  
  
  return true;
  
}