Ejemplo n.º 1
0
void Outputer::OutputToFile()
{
    QString filename = sConfig.get(CONF_STRING_OUTPUT_LOG);
    if (filename.isEmpty())
        return;

    QFile file(filename);
    if (!file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Truncate))
        return;

    QTextStream str(&file);
    for(int p = 0; p <= cur_phase; ++p)
    {
        str << PhaseHeader[p]+endline;
        str << GetPercentBar(p)+space+GetSpecial(p)+space+Errors(p)+endline;
        if (p != cur_phase)
        {
            if (!current[p])
            {
                str << PhaseSkipped[p]+endline;
                break;
            }
            if (!PhaseHeader[p].isNull())
                str << PhaseEnd[p]+endline;
            str << "Total downloaded: "+getSizeFromLong(phaseDLed[p])+" total time: "+Timestamp(phaseLenght[p]/1000, 0).write(FORMAT_TIME)+endline;
        }
        str << endline;
    }

    str << "Current speed: "+getSpeedFormFromFloat(totalSpeed())+" Downloaded: "+getSizeFromLong(totalDLed)+" Total time: "+Timestamp(totalLenght()/1000, 0).write(FORMAT_TIME);
    file.close();
}
Ejemplo n.º 2
0
	void Connection::WritePacket(Packet* PACKET)
	{
		if(Errors())
			return;
				
		Write(PACKET->GetBytes());
	}
Ejemplo n.º 3
0
Archivo: GLSL.cpp Proyecto: jtkk/Boids
int GLSL::CompileShaderViaCode(const char *code, GLint type)
{
    GLuint shader = glCreateShader(type);
	if (!shader) {
		Errors();
		return false;
	}
    glShaderSource(shader, 1, &code, NULL);
	glCompileShader(shader);
    // check compile status
    GLint result;
    glGetShaderiv(shader, GL_COMPILE_STATUS, &result);
    if (result == GL_FALSE) {
        // report logged errors
        GLint logLen;
        glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &logLen);
        if (logLen > 0) {
            GLsizei written;
            char *log = new char[logLen];
            glGetShaderInfoLog(shader, logLen, &written, log);
            printf(log);
            delete [] log;
        }
        else
            printf("shader compilation failed\n");
        return 0;
    }
    // const char *t = type == GL_VERTEX_SHADER? "vertex" : "fragment";
    // printf("  %s shader (%i) successfully compiled\n", t, shader);
    return shader;
}
Ejemplo n.º 4
0
void Outputer::Refresh()
{
#ifdef WIN32
    QString line = GetPercentBar(cur_phase)+space+GetSpecial(cur_phase)+space+Errors(cur_phase)+space+DataFlow();
    printf(QString("\r"+line).toStdString().c_str());
    OutputToFile();
#endif
}
Ejemplo n.º 5
0
	void Connection::ReadPacket()
	{
		if(Errors())
			return;
				
		/** Handle Reading Packet Type Header. **/
		if(SOCKET->available() > 0 && INCOMING->GetHeader() == 255)
		{
			std::vector<unsigned char> HEADER(1, 255);
			if(Read(HEADER, 1) == 1)
				INCOMING->SetHeader(HEADER[0]);
					
			return;
		}
				
		if(INCOMING->GetHeader() != 255 && !INCOMING->Complete())
		{
			
			/** Handle Reading Packet Length Header. **/
			if(SOCKET->available() >= 4 && INCOMING->GetLength() == 0)
			{
				std::vector<unsigned char> BYTES(4, 0);
				if(Read(BYTES, 4) == 4)
				{
					INCOMING->SetLength(BYTES);
					Event(0);
				}
					
				return;
			}
					
			/** Handle Reading Packet Data. **/
			unsigned int nAvailable = SOCKET->available();
			if(nAvailable > 0 && INCOMING->GetLength() > 0 && INCOMING->GetData().size() < INCOMING->GetLength())
			{
				std::vector<unsigned char> DATA( std::min(nAvailable, (unsigned int)(INCOMING->GetLength() - INCOMING->GetData().size())), 0);
				unsigned int nRead = Read(DATA, DATA.size());
					
				if(nRead == DATA.size())
				{
					std::vector<unsigned char> dta = INCOMING->GetData();
					try
					{
						dta.insert(dta.end(), DATA.begin(), DATA.end());
					}
					catch(const std::exception e)
					{
						return;
					}
					INCOMING->SetData(dta);

					Event(nRead);
				}
					
				return;
			}
		}
	}
Ejemplo n.º 6
0
int main(int ArgCount, char** Args)
    {
    string  GrammarFilename;
//    TToken      NullToken = {nullptr, 0, 0};

//    _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);

    unique_ptr<TTokens> Tokens(new TTokens);

    try {
        // parse command-line so we can get an input file
        Global::ParseArgs(ArgCount, Args, true);
        if(Global::Dump)
            printf("# of threads = %u\n", HardwareConcurrency());

        GrammarFilename = Global::InputFilename();
        if(GrammarFilename.empty())
            Error("MISSING_INPUT_FILE");

        TokenizeAll(Tokens, GrammarFilename);
        Parse(Tokens);
        }
    catch(TError* ErrorParms)
        {
        unique_ptr<TError> Errors(ErrorParms);
        DUMPVERBOSE("Caught error: '%s'\n", ErrorParms->GetName().c_str());
        Tokens->Freeze();
        ErrorParms->WriteToFile(Tokens, stdout);
#if 0
        system("time /t");
#define LOOPS (1024*1024*16)
        for(int i=0; i < LOOPS; ++i)
            for(int j=0; j < Tokens->End(); ++j)
                if(Tokens->Get(j).Type == 999)
                    printf("!!\n");
        system("time /t");
        auto Slice = Tokens->Slice(0,-1);
        for(int i=0; i < LOOPS; ++i)
            {
//            for(auto Token: Tokens->Slice(0, -1))
            for(auto Token: Slice)
                if(Token.Type == 999)
                    printf("!!\n");
            }
        system("time /t");
        for(int i=0; i < LOOPS; ++i)
            {
//            for(auto Token: Tokens->Slice(0, -1))
            auto End = Slice.end();
            for(auto Iter=Slice.begin(); Iter < End; ++Iter)
                if(Iter->Type == 999)
                    printf("!!\n");
            }
        system("time /t");
#endif
        }
    }
Ejemplo n.º 7
0
// class constructor
PoolLayer::PoolLayer(ivec inshape, ConvNet* net) :
    Fshape({2, 2}),
    InShape(inshape),
    Excitations(inshape[0], inshape[1], inshape[2])
{   
    Stride   = 2;
    
    OutShape = outshape(InShape, Fshape, Stride, 0);
    Steps    = calcsteps(InShape, Fshape, Stride, 0);
    
    Activations(OutShape[0], OutShape[1], OutShape[2]);
    Errors(OutShape[0], OutShape[1], OutShape[2]);
    Brain = net;
}
Ejemplo n.º 8
0
void Outputer::PrintScreen()
{
    QString screenLine = "\f";
    for(int p = 0; p <= cur_phase; ++p)
    {
        screenLine.append(PhaseHeader[p]+endline);
        screenLine += GetPercentBar(p)+space+GetSpecial(p)+space+Errors(p)+endline;
        if (p != cur_phase)
        {
            if (!current[p])
            {
                str << PhaseSkipped[p]+endline;
                break;
            }
            if (!PhaseHeader[p].isNull())
                screenLine.append(PhaseEnd[p]+endline);
            screenLine += "Total downloaded: "+getSizeFromLong(phaseDLed[p])+" total time: "+Timestamp(phaseLenght[p]/1000, 0).write(FORMAT_TIME)+endline;
        }
        screenLine.append(endline);
    }
    screenLine += "Current speed: "+getSpeedFormFromFloat(totalSpeed())+" Downloaded: "+getSizeFromLong(totalDLed)+" Total time: "+Timestamp(totalLenght()/1000, 0).write(FORMAT_TIME)+endline;
    printf(screenLine.toStdString().c_str());
    OutputToFile();
}