void Foam::csvTableReader<Type>::operator()
(
    const fileName& fName,
    List<Tuple2<scalar, Type>>& data
)
{
    // IFstream in(fName);
    autoPtr<ISstream> inPtr(fileHandler().NewIFstream(fName));
    ISstream& in = inPtr();

    DynamicList<Tuple2<scalar, Type>> values;

    // Skip header
    if (headerLine_)
    {
        string line;
        in.getLine(line);
    }

    while (in.good())
    {
        string line;
        in.getLine(line);

        DynamicList<string> split;

        std::size_t pos = 0;
        while (pos != std::string::npos)
        {
            std::size_t nPos = line.find(separator_, pos);

            if (nPos == std::string::npos)
            {
                split.append(line.substr(pos));
                pos=nPos;
            }
            else
            {
                split.append(line.substr(pos, nPos-pos));
                pos=nPos+1;
            }
        }

        if (split.size() <= 1)
        {
            break;
        }

        scalar time = readScalar(IStringStream(split[timeColumn_])());
        Type value = readValue(split);

        values.append(Tuple2<scalar,Type>(time, value));
    }

    data.transfer(values);
}
Foam::instantList Foam::Time::findTimes
(
    const fileName& directory,
    const word& constantName
)
{
    if (debug)
    {
        InfoInFunction << "Finding times in directory " << directory << endl;
    }

    // Read directory entries into a list
    fileNameList dirEntries
    (
        fileHandler().readDir
        (
            directory,
            fileName::DIRECTORY
        )
    );

    // Initialise instant list
    instantList Times(dirEntries.size() + 1);
    label nTimes = 0;

    // Check for "constant"
    bool haveConstant = false;
    forAll(dirEntries, i)
    {
        if (dirEntries[i] == constantName)
        {
            Times[nTimes].value() = 0;
            Times[nTimes].name() = dirEntries[i];
            nTimes++;
            haveConstant = true;
            break;
        }
    }

    // Read and parse all the entries in the directory
    forAll(dirEntries, i)
    {
        IStringStream timeStream(dirEntries[i]);
        token timeToken(timeStream);

        if (timeToken.isNumber() && timeStream.eof())
        {
            Times[nTimes].value() = timeToken.number();
            Times[nTimes].name() = dirEntries[i];
            nTimes++;
        }
    }
Exemple #3
0
/**
 * Downloads a single file from the specified server.
 */
bool GetOneFile(
  const launcher::Settings &settings,
  const std::string &filename, const Signature crc) {

  Trace("Attempting to download " << filename);

  core::net::NetClient client(core::net::eConnectionMode::TCP_ASYNC);
  std::string hostName;
  for (auto server = settings.get_patch_server_begin(); server != settings.get_patch_server_end(); ++server) {
    client.start(settings.get_patch_server(0));
    if (client.valid()) {
      hostName = wrappers::net::http::Uri(server->get_dns_name()).getHost();
      break;
    }
  }

  if (!client.valid()) {
    Log(LL::Error) << "Unable to connect to any servers." << std::endl;
    return false;
  }

  wrappers::net::http::HttpHeader header = wrappers::net::http::HttpHeader::Builder()
      .setRequestType(wrappers::net::http::HttpHeader::eRequestType::HTTP_REQUEST_GET)
      .setRequestPath(std::string("/") + settings.get_server_patch_dir() + filename)
      .addHeader("host", hostName)
      .build();

  if (!header.valid()) {
    return false;
  }
  client.send(header.asBlob());

  const vfs::Path outputPath = GetOutputPath(filename);
  vfs::ofstream outfile(outputPath, std::ios::binary | std::ios::out);
  if (!outfile.is_open()) {
    Log(LL::Error) << "Unable to open file: " << outputPath.str() << std::endl;
    return false;
  }
  wrappers::net::http::HttpFileHandler fileHandler(outfile);
  while (client.valid() && !fileHandler.done()) {
    client.update(fileHandler);
    core::thread::thisthread::yield();
  }
  client.stop();
  outfile.flush();

  if (!fileHandler.success()) {
    return false;
  }

  return CheckSignature(outputPath, crc);
}
Exemple #4
0
/*
 * break connection to rtdServer
 */
void RtdCamera::disconnect()
{
    if( ! connected())
	return;
    dbl_->log("disconnect\n");
    semDecr();
    fileHandler(0);
    rtdClose(eventHndl_, NULL);
    eventHndl_->socket = 0;
    attached(0);
    connected(0);
    return;
}
NS_IMETHODIMP 
nsIOService::NewFileURI(nsIFile *file, nsIURI **result)
{
    nsresult rv;
    NS_ENSURE_ARG_POINTER(file);

    nsCOMPtr<nsIProtocolHandler> handler;

    rv = GetProtocolHandler("file", getter_AddRefs(handler));
    if (NS_FAILED(rv)) return rv;

    nsCOMPtr<nsIFileProtocolHandler> fileHandler( do_QueryInterface(handler, &rv) );
    if (NS_FAILED(rv)) return rv;
    
    return fileHandler->NewFileURI(file, result);
}
Exemple #6
0
Foam::IOobjectList::IOobjectList
(
    const objectRegistry& db,
    const fileName& instance,
    const fileName& local,
    IOobject::readOption r,
    IOobject::writeOption w,
    bool registerObject
)
:
    HashPtrTable<IOobject>()
{
    word newInstance;
    fileNameList ObjectNames = fileHandler().readObjects
    (
        db,
        instance,
        local,
        newInstance
    );


    forAll(ObjectNames, i)
    {
        IOobject* objectPtr = new IOobject
        (
            ObjectNames[i],
            newInstance,
            local,
            db,
            r,
            w,
            registerObject
        );

        // Use object with local scope
        if (objectPtr->typeHeaderOk<IOList<label>>(false))
        {
            insert(ObjectNames[i], objectPtr);
        }
        else
        {
            delete objectPtr;
        }
    }
Exemple #7
0
/*
 * start accepting images from the named camera.
 * "camera" is a string that identifies the camera.
 */
int RtdCamera::start(const char* cameraName) 
{
    if (strlen(cameraName) == 0)
	return error("start needs a camera name");
    camera(cameraName);  // new camera name

    dbl_->log("START camera %s\n", cameraName);

    // first we need to check the connection to rtdServer
    if (connected())
	rtdServerCheck();

    attached(0);
    if (! connected()) {
	dbl_->log("Connecting to %s: RTD name=%s\n", RTD_SERVICE, name_);
	if (rtdInitImageEvt(name_, eventHndl_, buffer_) != RTD_OK) {
	    disconnect();
	    sprintf(buffer_, 
		    "could not initialize image event: check if %s is running!\n",
		    RTD_SERVICE);
	    dbl_->log(buffer_);
	    return error(buffer_);
	}
    }
    connected(1);

    if (rtdAttachImageEvt(eventHndl_, camera(), buffer_) != RTD_OK) {
	disconnect();
	sprintf(buffer_, "detach image event: check if %s is running!\n", RTD_SERVICE);
	dbl_->log("%s\n", buffer_);
	return error(buffer_);
    }

    // now we are ready to receive image events
    attached(1);
    fileHandler(1);
    return TCL_OK;
}
Exemple #8
0
void DirReader::recurseDir(const QString &path, int curDepth)
{
        QDir dir(path);
        dir.setSorting(flags);
        dir.setFilter(QDir::AllDirs|QDir::Files);

        const QStringList files = dir.entryList();
	foreach (QString f, files)
        {
                if (f == "." || f == "..")
                        continue;

                QFileInfo finf(dir, f);
		fileHandler(finf);
                if (finf.isDir()) // && (finf.absoluteFilePath() != path))
		{
			if (curDepth < maxDirDepth)
			{
				recurseDir(finf.absoluteFilePath(), curDepth+1);
			}
		}
        }
}
void Foam::pairPotentialList::readPairPotentialDict
(
    const List<word>& idList,
    const dictionary& pairPotentialDict,
    const polyMesh& mesh
)
{
    Info<< nl << "Building pair potentials." << endl;

    rCutMax_ = 0.0;

    for (label a = 0; a < nIds_; ++a)
    {
        word idA = idList[a];

        for (label b = a; b < nIds_; ++b)
        {
            word idB = idList[b];

            word pairPotentialName;

            if (a == b)
            {
                if (pairPotentialDict.found(idA + "-" + idB))
                {
                    pairPotentialName = idA + "-" + idB;
                }
                else
                {
                    FatalErrorInFunction
                        << "Pair pairPotential specification subDict "
                        << idA << "-" << idB << " not found"
                        << nl << abort(FatalError);
                }
            }
            else
            {
                if (pairPotentialDict.found(idA + "-" + idB))
                {
                    pairPotentialName = idA + "-" + idB;
                }

                else if (pairPotentialDict.found(idB + "-" + idA))
                {
                    pairPotentialName = idB + "-" + idA;
                }

                else
                {
                    FatalErrorInFunction
                        << "Pair pairPotential specification subDict "
                        << idA << "-" << idB << " or "
                        << idB << "-" << idA << " not found"
                        << nl << abort(FatalError);
                }

                if
                (
                    pairPotentialDict.found(idA+"-"+idB)
                 && pairPotentialDict.found(idB+"-"+idA)
                )
                {
                    FatalErrorInFunction
                        << "Pair pairPotential specification subDict "
                        << idA << "-" << idB << " and "
                        << idB << "-" << idA << " found multiple definition"
                        << nl << abort(FatalError);
                }
            }

            (*this).set
            (
                pairPotentialIndex(a, b),
                pairPotential::New
                (
                    pairPotentialName,
                    pairPotentialDict.subDict(pairPotentialName)
                )
            );

            if ((*this)[pairPotentialIndex(a, b)].rCut() > rCutMax_)
            {
                rCutMax_ = (*this)[pairPotentialIndex(a, b)].rCut();
            }

            if ((*this)[pairPotentialIndex(a, b)].writeTables())
            {
                fileHandler().mkDir(mesh.time().path());
                autoPtr<Ostream> ppTabFile
                (
                    fileHandler().NewOFstream
                    (
                        mesh.time().path()/pairPotentialName
                    )
                );

                if
                (
                    !(*this)[pairPotentialIndex(a, b)].writeEnergyAndForceTables
                    (
                        ppTabFile()
                    )
                )
                {
                    FatalErrorInFunction
                        << "Failed writing to "
                        << ppTabFile().name() << nl
                        << abort(FatalError);
                }
            }
        }
    }

    if (!pairPotentialDict.found("electrostatic"))
    {
        FatalErrorInFunction
            << "Pair pairPotential specification subDict electrostatic"
            << nl << abort(FatalError);
    }

    electrostaticPotential_ = pairPotential::New
    (
        "electrostatic",
        pairPotentialDict.subDict("electrostatic")
    );

    if (electrostaticPotential_->rCut() > rCutMax_)
    {
        rCutMax_ = electrostaticPotential_->rCut();
    }

    if (electrostaticPotential_->writeTables())
    {
        fileHandler().mkDir(mesh.time().path());
        autoPtr<Ostream> ppTabFile
        (
            fileHandler().NewOFstream
            (
                mesh.time().path()/"electrostatic"
            )
        );

        if (!electrostaticPotential_->writeEnergyAndForceTables(ppTabFile()))
        {
            FatalErrorInFunction
                << "Failed writing to "
                << ppTabFile().name() << nl
                << abort(FatalError);
        }
    }

    rCutMaxSqr_ = rCutMax_*rCutMax_;
}
Foam::fileName Foam::fileOperations::autoParallelFileOperation::filePath
(
    const fileName& fName
) const
{
    static bool firstCall = true;

    fileName pathDir;

    {
        // Install basic file handler
        storeFileHandler defaultOp(basicFileHandler_);
        pathDir = fileHandler().filePath(fName);
        if (debug)
        {
            Pout<< indent
                << "autoParallelFileOperation::filePath :"
                << " fName:" << fName
                << " pathDir:" << pathDir << endl;
        }
    }

    if (Pstream::parRun() && pathDir.empty() && firstCall)
    {
        if (Pstream::master())
        {
            WarningInFunction
                << "Cannot open case directory "
                << fName << nl
                << "    Running decomposePar" << nl << nl << endl;

            const bool oldParRun = Pstream::parRun();
            Pstream::parRun() = false;

            if (!Foam::isDir("./system"))
            {
                FatalErrorInFunction
                    << "Cannot find ./system directory."
                    << " Please run application in case directory."
                    << exit(FatalError);
            }

            const fileName decompDictName("./system/decomposeParDict");
            bool synthesised = false;

            if (!Foam::exists(decompDictName))
            {
                WarningInFunction
                    << "Cannot open " << decompDictName << nl
                    << "    Synthesising temporary decomposeParDict"
                    << nl << nl << endl;

                OFstream os(decompDictName, IOstream::ASCII);
                decomposedBlockData::writeHeader
                (
                    os,
                    IOstream::currentVersion,
                    IOstream::ASCII,
                    "dictionary",
                    "",
                    "",
                    "decomposeParDict"
                );
                dictionary d;
                d.add("numberOfSubdomains", Pstream::nProcs());
                d.add("method", "scotch");
                d.write(os, false);
                IOobject::writeEndDivider(os);

                if (os.good())
                {
                    synthesised = true;
                }
            }
            Pstream::parRun() = oldParRun;

            if (system("decomposePar -noFields"))
            {
                FatalErrorInFunction
                    << "Failed executing 'decomposePar'"
                    << exit(FatalError);
            }

            if (synthesised)
            {
                Foam::rm(decompDictName);
            }
        }

        // Re-check
        storeFileHandler defaultOp(basicFileHandler_);
        pathDir = fileHandler().filePath(fName);
        if (debug)
        {
            Pout<< indent
                << "autoParallelFileOperation::filePath :"
                << " fName:" << fName
                << " rechecked pathDir:" << pathDir << endl;
        }
    }

    firstCall = false;

    return pathDir;
}
Exemple #11
0
/*
 * Read the message from the rtdServer and call a virtual method to
 * display the image and evaluate the tcl event scripts.
 */
int RtdCamera::fileEvent()
{
    Mem mem;
    rtdIMAGE_INFO info;
    int stat;

    memset(&info, '\0', sizeof(rtdIMAGE_INFO));
    info.semId = info.shmNum = -1;

    stat = rtdRecvImageInfo(eventHndl_, &info, verbose_, buffer_);

    semId_  = info.semId;
    shmNum_ = info.shmNum;

    if (stat != RTD_OK || checkType(info.dataType) != RTD_OK || 
	info.xPixels <=0 || info.yPixels <= 0) {
	checkStat();
	return TCL_ERROR;
    }
    
    if ( ! attached()) {
	semDecr();
	return TCL_OK;
    }

    /*
     * class Mem takes care of possible reusing previous shared memory areas 
     * and cleanup. Choose the constructor depending on whether the 
     * semaphore fields of the image info have been set.
     */
    int bytes = info.xPixels * info.yPixels * (abs(info.dataType) / 8);
    if (semId_ > 0)
	mem = Mem(bytes, info.shmId, 0, verbose_, shmNum_, semId_);
    else
	mem = Mem(bytes, info.shmId, 0, verbose_);
    
    if (mem.status() != 0) {
	checkStat();
	return TCL_ERROR;
    }

    dbl_->log("image event: Id=%d, x=%d, y=%d, width=%d, height=%d, "
	      "shmId=%d shmNum=%d semId=%d\n",
	      info.frameId, info.frameX, info.frameY, info.xPixels, info.yPixels, 
	      info.shmId, shmNum_, semId_);

    /*
     * before displaying the image delete the file handler. This blocks
     * new image events which must not be handled between camera pre/post commands.
     */
    fileHandler(0);

    // call the virtual method in a derived class to display the image
    int disperr = display(info, mem);

    // re-install the file handler
    fileHandler(1);

    // finally decrement the semaphore
    semDecr();
    return disperr;
}
Exemple #12
0
void Foam::Function1Types::CSV<Type>::read()
{
    fileName expandedFile(fName_);
    autoPtr<ISstream> isPtr(fileHandler().NewIFstream(expandedFile.expand()));
    ISstream& is = isPtr();

    if (!is.good())
    {
        FatalIOErrorInFunction(is)
            << "Cannot open CSV file for reading."
            << exit(FatalIOError);
    }

    DynamicList<Tuple2<scalar, Type>> values;

    // Skip header
    for (label i = 0; i < nHeaderLine_; i++)
    {
        string line;
        is.getLine(line);
    }

    const label nEntries = max(refColumn_, max(componentColumns_));

    // Read data
    while (is.good())
    {
        string line;
        is.getLine(line);


        label n = 0;
        std::size_t pos = 0;
        DynamicList<string> split;

        if (mergeSeparators_)
        {
            std::size_t nPos = 0;

            while ((pos != std::string::npos) && (n <= nEntries))
            {
                bool found = false;
                while (!found)
                {
                    nPos = line.find(separator_, pos);

                    if ((nPos != std::string::npos) && (nPos - pos == 0))
                    {
                        pos = nPos + 1;
                    }
                    else
                    {
                        found = true;
                    }
                }

                nPos = line.find(separator_, pos);

                if (nPos == std::string::npos)
                {
                    split.append(line.substr(pos));
                    pos = nPos;
                    n++;
                }
                else
                {
                    split.append(line.substr(pos, nPos - pos));
                    pos = nPos + 1;
                    n++;
                }
            }
        }
        else
        {
            while ((pos != std::string::npos) && (n <= nEntries))
            {
                std::size_t nPos = line.find(separator_, pos);

                if (nPos == std::string::npos)
                {
                    split.append(line.substr(pos));
                    pos = nPos;
                    n++;
                }
                else
                {
                    split.append(line.substr(pos, nPos - pos));
                    pos = nPos + 1;
                    n++;
                }
            }
        }


        if (split.size() <= 1)
        {
            break;
        }

        scalar x = readScalar(IStringStream(split[refColumn_])());
        Type value = readValue(split);

        values.append(Tuple2<scalar,Type>(x, value));
    }

    this->table_.transfer(values);
}
Exemple #13
0
int main(int argc, char** argv){

	// clear screen
	std::cout << "\033[2J\033[1;1H";

	std::cout <<  "Drachma : Partial Reconfiguration Cache Simulator\n\n\n";

	// instantiate drachma wallet
	wallet library = wallet();

    if(argc > 1 && argv[1][0] == 0x2D && argv[1][1] != 0){ //switches present

        // read for switch data
        short int switch_count = strlen(argv[1]) - 1;
        char switch_choices[switch_count];
        bool bad_switch = false;

    	for(int i = 0; i < switch_count; i++)
    		switch_choices[i] = argv[1][i + 1];

    	for(int i = 0; i < switch_count; i++){

    		bool valid_use = false;

    		switch(switch_choices[i]){

    			//case 'd': {
    				/*
    				 * add device to simulator wallet
    				 *
    				 * usage:
    				 * 		./drachma -da DEVICE_FILE [DEVICE_NAME]
    				 *
    				 * remove device to simulator wallet
    				 *
    				 * usage:
    				 * 		./drachma -dr DEVICE_FILE [DEVICE_NAME]
    				 */

    				/*if(switch_count == 2){ // require two switches

    					if(switch_choices[1] == 'a'){
    						std::cout << "Adding new device '" << argv[2] << "' to the Wallet.\n\n";
    						valid_use = true;

    						if(fileExists(argv[2])){

    							std::vector<std::string> device_params {"family", "model", "slices"};
    							fileHandler device_reader = fileHandler(argv[2], device_params);

    							if(device_reader.isFileValid()){

    							library.addDevice(argv[2]);
    							std::cout << "Done!\n";

    							}else
    								std::cout << "ERROR: The target file '" << argv[2] << "' is not a valid Device file.\n\n";
    						}else
								std::cout << "ERROR: The target file '" << argv[2] << "' does not exist.\n\n";

    					}else if(switch_choices[1] == 'r'){
    						std::cout << "Removing device '" << argv[2] << "' from the Wallet.\n\n";
    						valid_use = true;

    						if(!library.removeDevice(argv[2]))
    							std::cout << "ERROR: Could not remove Device '" << argv[2] << "' from the Wallet."
										  << " <Device was Not Present>\n\n";

    					}
    				}

    				if(!valid_use){
    					std::cout << "ERROR: Improper switch use; The operations concerning Devices are as follows:\n";
    					deviceHelp();
    				}

    				goto exit;
    			}*/

    			case 'h': { // help user
    				/*
    				 * help user - print usage synopsis
    				 *
    				 * usage:
    				 * 		./drachma -h
    				 */
    				displayHelp();
    				break;
    			}

    			case 'm': {
    				/*
    				 * add memory and replacement algorithm configurations
    				 *
    				 * usage:
    				 * 		./drachma -ma MEMORY_FILE [CONFIGURATION_NAME]
    				 *
     				 * remove memory and replacement algorithm configurations
    				 *
    				 * usage:
    				 * 		./drachma -mr MEMORY_FILE [CONFIGURATION_NAME]
    				 */

    				if(switch_count == 2){ // require two switches

    					if(switch_choices[1] == 'a'){
    						std::cout << "Adding new Memory Configuration '" << argv[2] << "' to the Wallet.\n\n";
    	    				valid_use = true;

    	    				if(fileExists(argv[2])){

    	    					fileHandler memory_reader = fileHandler(argv[2],
    	    							library.getMemoryParamRules(), library.getMemoryRegexRules());

    							if(memory_reader.isFileValid()){
    								library.addMemory(argv[2]);

    								std::cout << "Done!\n";
    							}else
    								std::cout << "ERROR: The target file '" << argv[2] << "' is not a valid Memory Configuration file.\n\n";

    	    				}else
    	    					std::cout << "ERROR: The target file '" << argv[2] << "' does not exist.\n\n";

    					}else if(switch_choices[1] == 'r'){
    						std::cout << "Removing Memory Configuration '" << argv[2] << "' from the Wallet.\n\n";
    						valid_use = true;

    						if(!library.removeMemory(argv[2]))
    							std::cout << "ERROR: Could not remove Memory Configuration '" << argv[2] << "' from the Wallet."
										  << " <Memory Configuration was Not Present>\n\n";
    					}
    				}

    				if(!valid_use){
    					std::cout << "ERROR: Improper switch use; The operations concerning Memory Configuration files are as follows:\n";
    					memoryHelp();
    				}

    				goto exit;
    			}

    			case 'a': {
    				/*
    				 * add application to simulator wallet
    				 *
    				 * usage:
    				 * 		./drachma -aa APPLICATION_FILE [APPLICATION_NAME]
    				 *
    				 * remove application to simulator wallet
    				 *
    				 * usage:
    				 * 		./drachma -ar APPLICATION_FILE [APPLICATION_NAME]
    				 */

    				if(switch_count == 2){ // require two switches

						if(switch_choices[1] == 'a'){
							std::cout << "Adding new application '" << argv[2] << "' to the Wallet.\n\n";
							valid_use = true;

							if(fileExists(argv[2])){

								fileHandler application_reader = fileHandler(argv[2],
										library.getApplicationParamRules(), library.getApplicationRegexRules());

								if(application_reader.isFileValid()){
									library.addApplication(argv[2]);

									std::cout << "Done!\n";
								}else
									std::cout << "ERROR: The target file '" << argv[2] << "' is not a valid Application file.\n\n";
							}else
								std::cout << "ERROR: The target file '" << argv[2] << "' does not exist.\n\n";

						}else if(switch_choices[1] == 'r'){
							std::cout << "Removing application '" << argv[2] << "' from the Wallet.\n\n";
							valid_use = true;

							if(!library.removeApplication(argv[2]))
								std::cout << "ERROR: Could not remove Application '" << argv[2] << "' from the Wallet."
										  << " <Application was Not Present>\n\n";

						}
					}

					if(!valid_use){
						std::cout << "ERROR: Improper switch use; The operations concerning Application files are as follows:\n";
						deviceHelp();
					}

					goto exit;
    			}

    			case 't': {
    				/*
    				 * add application trace to simulator wallet
    				 *
    				 * usage:
    				 * 		./drachma -ta TRACE_FILE [APPLICATION_NAME]
    				 *
    				 * remove application trace from simulator wallet
    				 *
    				 * usage:
    				 * 		./drachma -tr TRACE_FILE [APPLICATION_NAME]
    				 */

    				if(switch_count == 2){ // require two switches

    					if(switch_choices[1] == 'a'){
    						std::cout << "Adding new Trace File '" << argv[2] << "' to the Wallet.\n\n";
							valid_use = true;

							if(fileExists(argv[2])){

								fileHandler trace_reader = fileHandler(argv[2],
										library.getTraceParamRules(), library.getTraceRegexRules());

    							if(trace_reader.isFileValid()){
    								library.addTraceFile(argv[2]);

    								std::cout << "Done!\n";
    							}else
    								std::cout << "ERROR: The target file '" << argv[2] << "' is not a valid Trace File.\n\n";

							}else
								std::cout << "ERROR: The target file '" << argv[2] << "' does not exist.\n\n";

    					}else if(switch_choices[1] == 'r'){
    						std::cout << "Removing Trace File '" << argv[2] << "' from the Wallet.\n\n";
    						valid_use = true;

    						if(!library.removeTraceFile(argv[2]))
    							std::cout << "ERROR: Could not remove Trace File '" << argv[2] << "' from the Wallet."
										  << " <Trace File was Not Present>\n\n";
    					}
    				}

    				if(!valid_use){
    					std::cout << "ERROR: Improper switch use; The operations concerning Trace files are as follows:\n";
    					traceHelp();
    				}

    				goto exit;
    			}

    			case 'w': {
    				/*
    				 * list objects contained in the simulator wallet"rcr count"
    				 *
    				 * usage:
    				 * 		./drachma -w
    				 */

    				library.printDetails();
    				goto exit;
    			}

    			case 's': {
    				/*
    				 * start simulation
    				 *
    				 * usage:
    				 * 		./drachma -s MEMORY_ID APPLICATION_ID TRACE_ID
    				 */

    				if(argc == 5 || argc == 6){

    					// initialize the simulation device
    					//device sim_device = library.getDevice( atoi(argv[2]) );
    					device sim_device = device();


    					// get memory hierarchy
    					reconfigurableRegions memory = library.getMemory( atoi(argv[2]) );

    					// get application
    					application* app = library.getApplication( atoi(argv[3]) );

    					// get application traces
    					std::vector<std::string> traces = library.getTraceFile( atoi(argv[4]) );


    					// apply memory hierarchy to device
    					sim_device.associateHierarchy(memory);

    					// prepare device resources needed by the application
    					if (sim_device.prepareApplicationResources(app)) {

    						sim_device.parseTraceFile(traces);

        					// if specified, stop the simulation after a certain mount of clock cycles
        					if(argc == 5)
        						sim_device.simulateApplication();
        					else
        						sim_device.simulateApplication(atoi(argv[5]));

    					} else
    						std::cout << "ERROR: Chosen application's bitstream library is too large to fit in the selected memory hierarchy.\n";

    				}else{
    					std::cout << "ERROR: Improper switch use; The operations concerning Starting the Simulator are as follows:\n";
    					startHelp();
    				}

    				goto exit;
    			}

    			default: // unrecognized switch
					bad_switch = true;
    		}
    	}

    }else{ // no switches - default action

    	std::cout << ">>> No Switches Present!  Have some help:" << std::endl << std::endl;
    	displayHelp();
    }

    exit:
		std::cout << std::endl;
		return 0;
}
Exemple #14
0
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    //Check if another instance has been started already
    QSharedMemory sharedMemory;
    sharedMemory.setKey("neu");

    if (!sharedMemory.create(1))
    {
        QMessageBox::warning(nullptr, QObject::tr("Warning!"), QObject::tr("An instance of this application is running!"));
        exit(0); // Exit process immediately
    }

    QSettings settings("neuPlayer.ini", QSettings::IniFormat);

    // Init Trad engine
    QString locale = QLocale::system().name().section('_', 0, 0);
    QTranslator translator;
    //Load correct translation based on system locale
    translator.load("neuplayer_" + locale);
    a.installTranslator(&translator);
    //Setup actual window
    qApp->setStyle(QStyleFactory::create("Fusion")); //base theme fusion

    if(settings.value("skin", 1).toInt() == 1 || settings.value("skin", 1).toInt() == 3)
    {
        Skin HoloFusion(1, nullptr);
        HoloFusion.load();
    }

    else
    {
        Skin CleanFusion(0, nullptr);
        CleanFusion.load();
    }
    //Ready to show
    //Create the helper so it isn't destroyed right away
    NcFramelessHelper helper(nullptr);
    QFile fileHandler(".configdone"); //So you config before anything else
    if(!fileHandler.exists()) //If there is the config to do, the config will launch the app when done
    {
        QPointer <InitialConfig> config = new InitialConfig();
        config->show();
    }
    else
    {
        Player *neuPlayer = new Player(nullptr);
        if(settings.value("Additional_Features/framelessWindow", false).toBool())
        {
            if(settings.value("visibilite").toBool())
                helper.activateOn(neuPlayer, true);
            else
                helper.activateOn(neuPlayer);
        }
        neuPlayer->show();
    }
    fileHandler.close();

    return a.exec();
}
Exemple #15
0
int main()
{
  FileHandler fileHandler("../maps/background_sample01.tmap");
  return 0;
}
bool Foam::regIOobject::writeObject
(
    IOstream::streamFormat fmt,
    IOstream::versionNumber ver,
    IOstream::compressionType cmp
) const
{
    if (!good())
    {
        SeriousErrorInFunction
            << "bad object " << name()
            << endl;

        return false;
    }

    if (instance().empty())
    {
        SeriousErrorInFunction
            << "instance undefined for object " << name()
            << endl;

        return false;
    }



    //- uncomment this if you want to write global objects on master only
    //bool isGlobal = global();
    bool isGlobal = false;

    if (instance() == time().timeName())
    {
        // Mark as written to local directory
        isGlobal = false;
    }
    else if
    (
        instance() != time().system()
     && instance() != time().caseSystem()
     && instance() != time().constant()
     && instance() != time().caseConstant()
    )
    {
        // Update instance
        const_cast<regIOobject&>(*this).instance() = time().timeName();

        // Mark as written to local directory
        isGlobal = false;
    }

    if (OFstream::debug)
    {
        if (isGlobal)
        {
            Pout<< "regIOobject::write() : "
                << "writing (global) file " << objectPath();
        }
        else
        {
            Pout<< "regIOobject::write() : "
                << "writing (local) file " << objectPath();
        }
    }


    bool osGood = false;


    // Everyone check or just master
    bool masterOnly =
        isGlobal
     && (
            regIOobject::fileModificationChecking == timeStampMaster
         || regIOobject::fileModificationChecking == inotifyMaster
        );


    if (Pstream::master() || !masterOnly)
    {
        //if (mkDir(path()))
        //{
        //    // Try opening an OFstream for object
        //    OFstream os(objectPath(), fmt, ver, cmp);
        //
        //    // If any of these fail, return (leave error handling to Ostream
        //    // class)
        //    if (!os.good())
        //    {
        //        return false;
        //    }
        //
        //    if (!writeHeader(os))
        //    {
        //        return false;
        //    }
        //
        //    // Write the data to the Ostream
        //    if (!writeData(os))
        //    {
        //        return false;
        //    }
        //
        //    writeEndDivider(os);
        //
        //    osGood = os.good();
        //}
        osGood = fileHandler().writeObject(*this, fmt, ver, cmp);
    }
    else
    {
        // Or scatter the master osGood?
        osGood = true;
    }

    if (OFstream::debug)
    {
        Pout<< " .... written" << endl;
    }

    // Only update the lastModified_ time if this object is re-readable,
    // i.e. lastModified_ is already set
    if (watchIndices_.size())
    {
        time().setUnmodified(watchIndices_.last());
    }

    return osGood;
}