FrameScheduler::FrameScheduler(std::ostream *_LogDestination, Whole StartingThreadCount) :
    FrameTimeLog(MEZZ_FRAMESTOTRACK),
    PauseTimeLog(MEZZ_FRAMESTOTRACK),
    CurrentFrameStart(GetTimeStamp()),
    CurrentPauseStart(GetTimeStamp()),
    LogDestination(_LogDestination),
    Sorter(0),
#ifdef MEZZ_USEBARRIERSEACHFRAME
    StartFrameSync(StartingThreadCount),
    EndFrameSync(StartingThreadCount),
    LastFrame(0),
#endif
#ifdef MEZZ_USEATOMICSTODECACHECOMPLETEWORK
    DecacheMain(0),
    DecacheAffinity(0),
#endif
    CurrentThreadCount(StartingThreadCount),
    FrameCount(0), TargetFrameLength(16666),
    TimingCostAllowance(0),
    MainThreadID(this_thread::get_id()),
    LoggingToAnOwnedFileStream(false),
    NeedToLogDeps(true)
{
    Resources.push_back(new DefaultThreadSpecificStorage::Type(this));
    (*LogDestination) << "<MezzanineLog>" << std::endl;
    LogDestination->flush();
}
Exemple #2
0
void optic_flow( cv::Mat mGray1, cv::Mat mGray2, cv::Mat& flow, cv::Mat& mAnnotated )
{
	cv::Mat frame1_gray, frame2_gray;
	cv::UMat  flowUmat;
	struct timeval start1,end1;	
	start1 = GetTimeStamp();
	calcOpticalFlowFarneback(mGray1, mGray2, 
							flowUmat, 0.5, 3, 15, 3, 5, 1.2, 0);
	flowUmat.copyTo(flow);    

    for (int y = 0; y < mAnnotated.rows; y += 5) 
     	for (int x = 0; x < mAnnotated.cols; x += 5)
     	{
			// get the flow from y, x position * 10 for better visibility
			const cv::Point2f flowatxy = flow.at<cv::Point2f>(y, x) * 10;

            // draw line at flow direction
       		line(mAnnotated, cv::Point(x, y), cv::Point( cvRound(x + flowatxy.x), 
       			 cvRound(y + flowatxy.y)), cv::Scalar(255,0,0));

            // draw initial point
       		circle(mAnnotated, cv::Point(x, y), 1, cv::Scalar(0, 0, 0), -1);
      	}
	end1 = GetTimeStamp();
	float delta = ((end1.tv_sec-start1.tv_sec)*1000 - (end1.tv_usec - start1.tv_usec));
	printf("OpticalFlowFarneback() Duration =  %8.3f\n",  delta/1000 );

}
THREAD_FUNC QdplusBarometerThread(void *argptr)
{
INT32 i, value, missed;
struct {
    ISIDL_TIMESTAMP prev;
    ISIDL_TIMESTAMP crnt;
} ttag;
BAROMETER *bp;
static char *fid = "QdplusBarometerThread";

    LogMsg(LOG_DEBUG, "%s started", fid);

    bp = (BAROMETER *) argptr;

    bp->nsamp = 0;

/* Time tag the current sample and stuff it into the buffer */

    GetTimeStamp(&ttag.prev);
    while (1) {
        GetTimeStamp(&ttag.crnt);
        if (ttag.crnt.sys > ttag.prev.sys) {
            value = GetSample(bp);
            missed = ttag.crnt.sys - ttag.prev.sys - 1;
            for (i = 0; i < missed; i++) {
                ++ttag.prev.sys;
                StuffSample(bp, &ttag.prev, MISSED_BAROMETER_SAMPLE);
            }
            StuffSample(bp, &ttag.crnt, value);
            ttag.prev = ttag.crnt;
        }
        utilDelayMsec(250);
    }
}
bool test_chip(char chipid[])
{
	nEntry++;

	g_chipdata.Invalidate();
	g_chipdata.nEntry = nEntry;
	printf("#%05i: %s -> ", nEntry, chipid);
	fflush(stdout);
	Log.section("CHIP1", false);
	Log.printf(" %s\n", chipid);
	strcpy(g_chipdata.chipId, chipid);

	GetTimeStamp(g_chipdata.startTime);
	Log.timestamp("BEGIN");

	tb.SetLed(0x10);
	bool repeat;
	int bin = settings.rocType == 0 ? TestRocAna::test_roc(repeat) : TestRocDig::test_roc(repeat);
	tb.SetLed(0x00);
	tb.Flush();

	GetTimeStamp(g_chipdata.endTime);
	Log.timestamp("END");
	Log.puts("\n");
	Log.flush();

	printf("%3i\n", bin);

	return true;
}
bool test_wafer()
{
	int x, y;

	g_chipdata.Invalidate();

	if (!ReportWafer()) return true;
	if (!ReportChip(x,y)) return true;
	g_chipdata.nEntry = nEntry;

	GetTimeStamp(g_chipdata.startTime);
	Log.timestamp("BEGIN");
	tb.SetLed(0x10);
	bool repeat;
	int bin = settings.rocType == 0 ? TestRocAna::test_roc(repeat) : TestRocDig::test_roc(repeat);
	tb.SetLed(0x00);
	tb.Flush();
	GetTimeStamp(g_chipdata.endTime);
	Log.timestamp("END");
	Log.puts("\n");
	Log.flush();
	printf("%3i\n", bin);

	printf(" RSP %s\n", prober.printf("BinMapDie %i", bin));

	return true;
}
Exemple #6
0
bool test_wafer()
{
	int x, y;

	g_chipdata.Invalidate();

	if (!ReportWafer()) return true;
	if (!ReportChip(x,y)) return true;
	g_chipdata.nEntry = nEntry;

	GetTimeStamp(g_chipdata.startTime);
	Log.timestamp("BEGIN");
	tb.SetLed(0x10);
	bool repeat;
	int bin = test_roc(repeat);
	tb.SetLed(0x00);
	tb.Flush();
	GetTimeStamp(g_chipdata.endTime);
	Log.timestamp("END");
	Log.puts("\n");
	Log.flush();
	printf("%3i\n", bin);

	prober.SendCmd("BinMapDie %i", bin);

	return true;
}
Exemple #7
0
void cLogMgr::Write(eLogLevel verbosity, std::string entry) 
{
	if (ENABLE_LOGGING)
	{
		WriteToConsole(verbosity, GetTimeStamp() + GetVerbosityToken(verbosity) + entry);
		WriteToFile(verbosity, GetTimeStamp() + GetVerbosityToken(verbosity) + entry);
	}
}
void IPlatformFile::GetTimeStampPair(const TCHAR* PathA, const TCHAR* PathB, FDateTime& OutTimeStampA, FDateTime& OutTimeStampB)
{
	if (GetLowerLevel())
	{
		GetLowerLevel()->GetTimeStampPair(PathA, PathB, OutTimeStampA, OutTimeStampB);
	}
	else
	{
		OutTimeStampA = GetTimeStamp(PathA);
		OutTimeStampB = GetTimeStamp(PathB);
	}
}
Exemple #9
0
/*
 * Wait
 * ----
 *  wait n ticks.
 *
 *  Paramters:
 *  n: ticks number.
 */
void Wait(int n) {
    int start, end;

    start = GetTimeStamp();

    /* Loop if time laspe is lower than wait time */
    while (1) {
        end = GetTimeStamp();
        if ((end - start) > n) {
            break;
        }
    }
}
DrawSheetStruct * DrawSheetStruct::GenCopy(void)
/***********************************************/
{
DrawSheetStruct * newitem = new DrawSheetStruct(m_Pos);
DrawSheetLabelStruct * Slabel = NULL, * label = m_Label;
int ii;

	newitem->m_End = m_End;
	newitem->m_Parent = m_Parent;
	newitem->m_TimeStamp = GetTimeStamp();

	/* initialisation des Fields */
	for(ii = 0; ii < NUMBER_OF_FIELDS; ii++)
		{
		m_Field[ii].PartTextCopy(& newitem->m_Field[ii]);
		}

	if( label )
		{
		Slabel = newitem->m_Label = label->GenCopy();
		Slabel->m_Parent = newitem;
		label = (DrawSheetLabelStruct*)label->Pnext;
		}

	while( label )
		{
		Slabel->Pnext = label->GenCopy();
		Slabel = (DrawSheetLabelStruct*)Slabel->Pnext;
		Slabel->m_Parent = newitem;
		label = (DrawSheetLabelStruct*)label->Pnext;
		}

	return newitem;
}
Exemple #11
0
	// /////////////////////////////////////////////////////////////////
	// 
	// /////////////////////////////////////////////////////////////////
	void GameLog::Log(const LogLevel level, const string &messageRef)
	{
		if(!m_logger.is_open())
		{
			return;
		}
		
		// Check if message should be logged.
		if(level <= m_logLevel)
		{
			// Create highlight text to make ERR or FAT logs stand out.
			string highlightText("");
			if(level == FAT)
			{
				highlightText.assign(string(" #### "));
			}
			else if(level == ERR)
			{
				highlightText.assign(string(" **** "));
			}
			
			// Log error.
			if(m_timestamp)
			{
				m_logger << GetTimeStamp() << ": " << highlightText << messageRef << "." << highlightText << endl;
			}
			else
			{
				m_logger << highlightText << messageRef << "." << highlightText << endl;
			}
		}
	}
Exemple #12
0
    virtual void Update ()
    {
      // delete inverse;
      if (GetTimeStamp() == bfa->GetTimeStamp()) return;
      timestamp = bfa->GetTimeStamp();
      
      cout << IM(3) << "Update Direct Solver Preconditioner" << flush;
      
      try
	{                                          
          auto have_sparse_fact = dynamic_pointer_cast<SparseFactorization> (inverse);
          if (have_sparse_fact && have_sparse_fact -> SupportsUpdate())
            {
              if (have_sparse_fact->GetAMatrix() == bfa->GetMatrixPtr())
                {
                  // cout << "have the same matrix, can update factorization" << endl;
                  have_sparse_fact->Update();
                  return;
                }
            }
          
	  bfa->GetMatrix().SetInverseType (inversetype);
	  shared_ptr<BitArray> freedofs = 
	    bfa->GetFESpace()->GetFreeDofs (bfa->UsesEliminateInternal());
	  inverse = bfa->GetMatrix().InverseMatrix(freedofs);
	}
      catch (exception & e)
	{
	  throw Exception (string("caught exception in DirectPreconditioner: \n") +
                           e.what() + 
                           "\nneeds a sparse matrix (or has memory problems)");
	}
    }
Exemple #13
0
//==========================================================================
// Class:			Logger::LoggerStreamBuffer
// Function:		sync
//
// Description:		Override of standard sync method.  Called when stream encounters
//					endl object.  Handles addition of timestamp to the stream.
//
// Input Arguments:
//		None
//
// Output Arguments:
//		None
//
// Return Value:
//		int
//
//==========================================================================
int Logger::LoggerStreamBuffer::sync()
{
	output << GetTimeStamp() << " : " << str();
	str("");
	output.flush();
	return 0;
}
Exemple #14
0
void CLogSystem::WriteToLog( const char *format, ... )
{
	if ( !m_bCreateLog ) return;

	va_list argptr;
	const int maxbytes=4095;
	char buffer[maxbytes+1];
	char cTimeStamp[30];
	timeStamp_t timeStamp;

	
	va_start(argptr, format);
	
	_vsnprintf(buffer, maxbytes, format, argptr);
	buffer[maxbytes]=NULL;
	va_end(argptr);

	GetTimeStamp( &timeStamp );





	sprintf(cTimeStamp, "%4d-%02d-%02d %02d:%02d:%02d", 
		timeStamp.year, timeStamp.month, timeStamp.day, timeStamp.hour, timeStamp.minute, timeStamp.second);

	fprintf(m_fpLog, "%s;%s\n", cTimeStamp, buffer);
}
Monitor::Monitor(SimObject * simObject, std::string directoryPath)
	:m_simObject(simObject), m_directoryPath(directoryPath), m_timeStamp(GetTimeStamp())
{
	//open csv
	std::string fileName = m_directoryPath + "/" + simObject->GetName() + m_timeStamp + ".csv";
	m_csvStream.open(fileName);
}
Exemple #16
0
long TimeStamp::GetDateStamp()
{
	double time_stamp = GetTimeStamp();
	int date_stamp = (int)time_stamp;

	return date_stamp;
}
void ClientTCP::measure_latency()
{
	time_before_ = GetTimeStamp();
	timer_.expires_from_now(boost::posix_time::seconds(MAX_DELAY));
	timer_.async_wait(boost::bind(&ClientTCP::handle_timeout, this, boost::asio::placeholders::error));
	socket_.async_connect(endpoint_, boost::bind(&ClientTCP::handle_connect, this, boost::asio::placeholders::error));
}
Exemple #18
0
VOID ScoreKeeper::ExpireStaleStates(
		IN BOOLEAN FlushAll)
{
	std::map<ULONG, ApplicationState *>::iterator It;
	ULONG CurrentTimeStamp = GetTimeStamp();

	for (It = ApplicationStateHash.begin();
	     It != ApplicationStateHash.end();
	    )
	{
		//
		// If we're not removing all entries and this entry is not expired, don't
		// remove it.
		//
		if (!FlushAll)
		{
			if ((CurrentTimeStamp - (*It).second->GetLastTouchTime()) < APPLICATION_EXPIRATION_TIME_WINDOW)
			{
				It++;
				continue;
			}
		}

		//
		// If we get here, we're removing the entry.
		//
		ApplicationState *State = (*It).second;

		ApplicationStateHash.erase(It);

		delete State;

		It = ApplicationStateHash.begin();
	}
}
Exemple #19
0
j_boolean_t CAccessOprator::HasDownLoaded(const j_char_t *pFileName)
{
	try
	{
		char strCmd[512] = {0};
		sprintf(strCmd, "SELECT * FROM FileInfo WHERE FileName = '%s';", pFileName);
		m_pRec = m_pConn->Execute((_bstr_t)strCmd, NULL, adCmdText);
		if (!m_pRec->EndOfFile)
		{
			return true;
		}

		j_string_t strTimeStamp = GetTimeStamp(pFileName);
		memset (strCmd, 0, sizeof(strCmd));
		sprintf(strCmd, "SELECT * FROM FileInfo WHERE [TimeStamp] <= (SELECT  MIN([TimeStamp]) FROM FileInfo);");
		m_pRec = m_pConn->Execute((_bstr_t)strCmd, NULL, adCmdText);
		if (!m_pRec->EndOfFile && strTimeStamp < (char*)_bstr_t(m_pRec->GetCollect("TimeStamp")))
		{
			return true;
		}
	}
	catch (...){}

	return false;
}
Exemple #20
0
//Debug
void
Packet::Print ()
{
  std::cout <<
      " ********** \n **Packet:"
	  "\n  ** ID " <<  GetID () <<
      " timeStamp " <<  GetTimeStamp () <<
      "\n  ** size: " << GetSize() <<
      "\n  ** sourcePort "  << GetSourcePort() <<
      " destinationPort " << GetDestinationPort() <<
      "\n  ** srcIP " << GetSourceID() <<
      " dstIP " << GetDestinationID() <<
      "\n  ** srcMAC " << GetSourceMAC() <<
      " dstMAC " << GetDestinationMAC() << std::endl;

  if (m_RLCHeader->IsAFragment())
	  std::cout << "  ** IsAFragment TRUE ";
  else
	  std::cout << "  ** IsAFragment FALSE ";

  if (m_RLCHeader->IsTheLatestFragment())
	  std::cout << " IsTheLatestFragment TRUE ";
  else
	  std::cout << " IsTheLatestFragment FALSE ";

      std::cout << "\n **********"  << std::endl;
}
LRESULT	CAgentCfg::WriteDevicesFile(std::string xmlFile,  std::string destFolder)
{
	std::string contents;
	contents+="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
	contents+="<MTConnectDevices xmlns=\"urn:mtconnect.org:MTConnectDevices:1.1\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:mtconnect.org:MTConnectDevices:1.1 http://www.mtconnect.org/schemas/MTConnectDevices_1.1.xsd\">\n";
	contents+=StdStringFormat("<Header bufferSize=\"130000\" instanceId=\"1\" creationTime=\"%s\" sender=\"local\" version=\"1.1\"/>\n",
		GetTimeStamp().c_str());
	contents+="<Devices>\n";

	// Check all machine names unique

	// Generate Devices.xml file with all devices in it.
	for(UINT i=0; i<devices.size(); i++)
	{
		std::string config = ReadXmlDevicesFile(devices[i]);
		ReplaceAll(config,"####", names[i]); 
		config=ReplaceOnce(config,"name=\"NNNNNN\"","name=\""+names[i]+"\"");
		contents+=config+"\n";
	}
	contents+="</Devices>\n";
	contents+="</MTConnectDevices>\n";

	if(!xmlFile.empty())
		WriteFile(destFolder + "\\" + xmlFile  , contents);
	return 0;
}
Exemple #22
0
void updatefromserver(char server_reply[255],struct device *s_device){
	int linecount = 0,countdelimiter=0;
	char **res,buff[255];
	char reply[100];
	int servertime;
	//printf("enterrd func");
	strcpy(reply,server_reply);
	servertime = GetTimeStamp(reply);
	//printf("Time : %d\n",servertime);
	if (strstr(server_reply,"Switch")!=NULL)
	{

		split( server_reply, ':', &res, &countdelimiter );

		if((strstr(res[2],"On"))!=NULL) { s_device->onstatus = true;
		//printf("Turned on from server\n");
		}
		else if ((strstr(res[2],"Off"))!=NULL) {
			s_device->onstatus = false;
			//printf("Turned off from server\n");
		}
		else printf("Corrupted message from server\n");
	}
	else 	printf("Corrupted message from server Message Type Unknown\n");

	//Logical Clock
	if(servertime > ((long int) time(NULL)+timediff))
					timediff = timediff + (servertime - ((long int) time(NULL)));
//	printf("End of func\n");
}
void vmsLogger::WriteLog(const tstring& message)
{
    tstring logFile = fsGetDataFilePath("fdmlog.txt");

    std::fstream file(logFile, std::ios_base::app);
    file << GetTimeStamp() << _T(" ") << message << std::endl;
}
Exemple #24
0
void CuDlgIpmDetailNetTrafic::GetNetTraficData(CaIpmPropertyNetTraficData& data)
{
	data.m_TraficInfo = m_TraficInfo;
	data.m_bStartup = m_bStartup ;
	data.m_nCounter = m_nCounter; 
	data.m_strTimeStamp = GetTimeStamp();

	data.m_strTotalPacketIn = m_strTotalPacketIn;
	data.m_strTotalDataIn = m_strTotalDataIn;
	data.m_strTotalPacketOut = m_strTotalPacketOut;
	data.m_strTotalDataOut = m_strTotalDataOut;
	data.m_strCurrentPacketIn = m_strCurrentPacketIn;
	data.m_strCurrentDataIn = m_strCurrentDataIn;
	data.m_strCurrentPacketOut = m_strCurrentPacketOut;
	data.m_strCurrentDataOut = m_strCurrentDataOut;
	data.m_strAveragePacketIn = m_strAveragePacketIn;
	data.m_strAverageDataIn = m_strAverageDataIn;
	data.m_strAveragePacketOut = m_strAveragePacketOut;
	data.m_strAverageDataOut = m_strAverageDataOut;
	data.m_strPeekPacketIn = m_strPeekPacketIn;
	data.m_strPeekDataIn = m_strPeekDataIn;
	data.m_strPeekPacketOut = m_strPeekPacketOut;
	data.m_strPeekDataOut = m_strPeekDataOut;
	data.m_strDate1PacketIn = m_strDate1PacketIn;
	data.m_strDate2PacketIn = m_strDate2PacketIn;
	data.m_strDate1DataIn = m_strDate1DataIn;
	data.m_strDate2DataIn = m_strDate2DataIn;
	data.m_strDate1PacketOut = m_strDate1PacketOut;
	data.m_strDate2PacketOut = m_strDate2PacketOut;
	data.m_strDate1DataOut = m_strDate1DataOut;
	data.m_strDate2DataOut = m_strDate2DataOut;
}
Exemple #25
0
double get_master_clock(void)
{
    double tstamp;

    GetTimeStamp(hBuff, &tstamp);
    return tstamp - audio_delta;
};
void XnFrameStreamProcessor::OnEndOfFrame(const XnSensorProtocolResponseHeader* pHeader)
{
	// write dump
	XnBuffer* pCurWriteBuffer = m_pTripleBuffer->GetWriteBuffer();
	xnDumpWriteBuffer(m_InternalDump, pCurWriteBuffer->GetData(), pCurWriteBuffer->GetSize());
	xnDumpClose(&m_InternalDump);
	xnDumpClose(&m_InDump);

	if (!m_bFrameCorrupted)
	{
		// mark the buffer as stable
		XnUInt64 nTimestamp = GetTimeStamp(pHeader->nTimeStamp);
		XnUInt32 nFrameID;
		m_pTripleBuffer->MarkWriteBufferAsStable(nTimestamp, &nFrameID);

		// let inheriting classes do their stuff
		OnFrameReady(nFrameID, nTimestamp);
	}
	else
	{
		// restart
		m_pTripleBuffer->GetWriteBuffer()->Reset();
	}

	// log bandwidth
	XnUInt64 nSysTime;
	xnOSGetTimeStamp(&nSysTime);
	xnDumpWriteString(m_pDevicePrivateData->BandwidthDump, "%llu,%s,%d,%d\n", 
		nSysTime, m_csName, GetCurrentFrameID(), m_nBytesReceived);

	// re-init dumps
	xnDumpInit(&m_InDump, m_csInDumpMask, NULL, "%s_%d.raw", m_csInDumpMask, GetCurrentFrameID());
	xnDumpInit(&m_InternalDump, m_csInternalDumpMask, NULL, "%s_%d.raw", m_csInternalDumpMask, GetCurrentFrameID());
	m_nBytesReceived = 0;
}
Exemple #27
0
double Timer::GetTimeStampClear(unsigned int id)
{
	double t = GetTimeStamp(id);
	m_timeStamps.erase(id);

	return t;
}
Exemple #28
0
void StartAnimation()
{
   DirectFBStage *stage = sgDirectFBFrame->GetStage();
   
   while (!sgDead) {
       int waitMs = (stage->GetNextWake() - GetTimeStamp()) * 1000;
       if (waitMs < 0) {
           waitMs = 0;
       }
       sgEventBuffer->WaitForEventWithTimeout(sgEventBuffer, 0, waitMs);
      
      while (sgEventBuffer->HasEvent(sgEventBuffer) != DFB_BUFFEREMPTY) {
          DFBEvent event;
          sgEventBuffer->GetEvent(sgEventBuffer, DFB_EVENT(&event));
          stage->ProcessEvent(event);
          if (sgDead) {
              break;
          }
      }

      Event poll(etPoll);
      stage->HandleEvent(poll);
   }
   
   Event deactivate(etDeactivate);
   stage->HandleEvent(deactivate);
   
   Event kill(etDestroyHandler);
   stage->HandleEvent(kill);
}
Exemple #29
0
int getMixerTime(int inTime0)
{
   double now = GetTimeStamp();
   if (now>sLastMusicUpdate+1)
      return sSoundPos;

   return (sSoundPos-inTime0) + (int)( (now - sLastMusicUpdate)*sMusicFrequency );
}
Exemple #30
0
	//WriteLog function writes formatted log to File or Console
	void Logger::WriteLog(loglevel level, string message, bool file)
	{
		try{
			_msemaphore.lock();
			if (file)
			{
				_fhnd << GetTimeStamp() << " " << GetLoglevelString(level) << message << endl;
			}
			else {
				cout << GetTimeStamp() << " " << GetLoglevelString(level) << message << endl;
			}
			_msemaphore.unlock();
		}
		catch (std::exception& e){
			throw e;
		}
	}