<commit_before>//$Id$

#include <unistd.h>

#include "RemoteHopsanClient.h"

#include <tclap/CmdLine.h>

#include <iostream>
#include <fstream>
#include <sstream>
#include <thread>
using namespace std;

#define PRINTCLIENT "Client; "

int main(int argc, char* argv[])
{
    try {
        TCLAP::CmdLine cmd("RemoteHopsanClient");

        // Define a value argument and add it to the command line.
        TCLAP::ValueArg<int> longTOOption("","longtimeout","The receive timeout for time-consuming requests",false,30,"Time in seconds (default 30)", cmd);
        TCLAP::ValueArg<int> shortTOOption("","shorttimeout","The receive timeout for small (fast) requests",false,5,"Time in seconds (default 5)", cmd);
        TCLAP::MultiArg<std::string> shellOptions("", "shellexec", "Command to execute in shell", false, "string", cmd);
        TCLAP::MultiArg<std::string> requestOptions("", "request", "Request file (only from WD)", false, "string", cmd);
        TCLAP::MultiArg<std::string> assetsOptions("a", "asset", "Model assets (files)", false, "string (filepath)", cmd);
        TCLAP::ValueArg<std::string> userOption("u","user","The user identification string",false,"","user:password or user", cmd);
        TCLAP::ValueArg<std::string> hmfPathOption("m","hmf","The Hopsan model file to load",false,"","Path to file", cmd);
        TCLAP::ValueArg<std::string> serverAddrOption("s", "serverip", "Server IP address and port (default is localhost:45050)", false, "localhost:45050", "IP address", cmd);

        // Parse the argv array.
        cmd.parse( argc, argv );

        // Prepare our context and socket
#ifdef _WIN32
        zmq::context_t context(1, 63);
#else
        zmq::context_t context(1);
#endif
        RemoteHopsanClient rhopsan(context);
        // Set timeouts
        if (shortTOOption.isSet())
        {
            rhopsan.setShortReceiveTimeout(shortTOOption.getValue()*1000);
        }
        if (longTOOption.isSet())
        {
            rhopsan.setLongReceiveTimeout(longTOOption.getValue()*1000);
        }

        cout << PRINTCLIENT << "Connecting to: " << serverAddrOption.getValue() << endl;
        rhopsan.connectToServer(serverAddrOption.getValue());
        cout << PRINTCLIENT << "Connected: " << rhopsan.serverConnected() << endl;

        try
        {
            int workerPort;
            bool rc = rhopsan.requestSlot(1, workerPort);
            if (rc)
            {
                cout << PRINTCLIENT << "Got server worker slot at port: " << workerPort << endl;
                rhopsan.connectToWorker(workerPort);

                // Send user identification
                if (userOption.isSet())
                {
                    string nameandpasswd = userOption.getValue();
                    string username = nameandpasswd;
                    string password;
                    size_t e = nameandpasswd.find_last_of(':');
                    if (e != string::npos)
                    {
                        username = nameandpasswd.substr(0, e);
                        password = <PASSWORD>.substr(e+1);
                    }

                    rhopsan.sendUserIdentification(username, password);
                }

                // Send model assets
                const std::vector<std::string> &rAssets = assetsOptions.getValue();
                for (const string &rAsset : rAssets)
                {
                    cout << PRINTCLIENT << "Sending asset: " << rAsset <<  " ... ";
                    double progress;
                    // Set relative path to filename only<commit_msg>Added numslots argument to remote client to control how many slots to take<commit_after>//$Id$

#include <unistd.h>

#include "RemoteHopsanClient.h"

#include <tclap/CmdLine.h>

#include <iostream>
#include <fstream>
#include <sstream>
#include <thread>
using namespace std;

#define PRINTCLIENT "Client; "

int main(int argc, char* argv[])
{
    try {
        TCLAP::CmdLine cmd("RemoteHopsanClient");

        // Define a value argument and add it to the command line.
        TCLAP::ValueArg<int> longTOOption("","longtimeout","The receive timeout for time-consuming requests",false,30,"Time in seconds (default 30)", cmd);
        TCLAP::ValueArg<int> shortTOOption("","shorttimeout","The receive timeout for small (fast) requests",false,5,"Time in seconds (default 5)", cmd);
        TCLAP::ValueArg<int> numSlotsOption("","numslots", "The number of slots to request",false,1,"Integer (default 1)");
        TCLAP::MultiArg<std::string> shellOptions("", "shellexec", "Command to execute in shell", false, "string", cmd);
        TCLAP::MultiArg<std::string> requestOptions("", "request", "Request file (only from WD)", false, "string", cmd);
        TCLAP::MultiArg<std::string> assetsOptions("a", "asset", "Model assets (files)", false, "string (filepath)", cmd);
        TCLAP::ValueArg<std::string> userOption("u","user","The user identification string",false,"","user:password or user", cmd);
        TCLAP::ValueArg<std::string> hmfPathOption("m","hmf","The Hopsan model file to load",false,"","Path to file", cmd);
        TCLAP::ValueArg<std::string> serverAddrOption("s", "serverip", "Server IP address and port (default is localhost:45050)", false, "localhost:45050", "IP address", cmd);

        // Parse the argv array.
        cmd.parse( argc, argv );

        // Prepare our context and socket
#ifdef _WIN32
        zmq::context_t context(1, 63);
#else
        zmq::context_t context(1);
#endif
        RemoteHopsanClient rhopsan(context);
        // Set timeouts
        if (shortTOOption.isSet())
        {
            rhopsan.setShortReceiveTimeout(shortTOOption.getValue()*1000);
        }
        if (longTOOption.isSet())
        {
            rhopsan.setLongReceiveTimeout(longTOOption.getValue()*1000);
        }

        cout << PRINTCLIENT << "Connecting to: " << serverAddrOption.getValue() << endl;
        rhopsan.connectToServer(serverAddrOption.getValue());
        cout << PRINTCLIENT << "Connected: " << rhopsan.serverConnected() << endl;

        try
        {
            int workerPort;
            bool rc = rhopsan.requestSlot(numSlotsOption.getValue(), workerPort);
            if (rc)
            {
                cout << PRINTCLIENT << "Got server worker slot at port: " << workerPort << endl;
                rhopsan.connectToWorker(workerPort);

                // Send user identification
                if (userOption.isSet())
                {
                    string nameandpasswd = userOption.getValue();
                    string username = nameandpasswd;
                    string password;
                    size_t e = nameandpasswd.find_last_of(':');
                    if (e != string::npos)
                    {
                        username = nameandpasswd.substr(0, e);
                        password = <PASSWORD>.substr(e+1);
                    }

                    rhopsan.sendUserIdentification(username, password);
                }

                // Send model assets
                const std::vector<std::string> &rAssets = assetsOptions.getValue();
                for (const string &rAsset : rAssets)
                {
                    cout << PRINTCLIENT << "Sending asset: " << rAsset <<  " ... ";
                    double progress;
                    // Set relative path to filename only
{'fraction_non_alphanumeric': 0.13109631843499525, 'fraction_numerical': 0.00910202418149708, 'mean_word_length': 2.337262012692656, 'pattern_counts': {'":': 0, '<': 100, '<?xml version=': 0, '>': 36, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2387223', 'n_tokens_mistral': 2113, 'n_tokens_neox': 2022, 'n_words': 511}