SettingsWindow::SettingsWindow(const String &          title,
                               const String &          execType,
                               const ApplicationInfo & appInfo,
                               String &                endpointToUse,
                               String &                tagToUse,
                               String &                portToUse,
                               int &                   tagModifierCount,
                               StringArray &           argsToUse)  :
    inherited1(), inherited2(), inherited3(title, kWindowBackgroundColour, 0), inherited4(),
    _topText("topText"), _cancelButton("Cancel"), _okButton("OK"),
    _descriptors(appInfo._argDescriptions),
    _errorFont(Font::getDefaultMonospacedFontName(), FormField::kFontSize,
               Font::italic + Font::bold), _regularFont(Font::getDefaultMonospacedFontName(),
                                                        FormField::kFontSize, Font::plain),
    _execType(execType), _extraArgumentsGroup(NULL), _tagModifierGroup(NULL),
    _addArgumentsButton(NULL), _removeArgumentsButton(NULL), _endpointField(NULL), _portField(NULL),
    _tagField(NULL),
    _endpointDescriptor(new Utilities::ChannelArgumentDescriptor(kEndpointFieldName.toStdString(),
                                                                 "", Utilities::kArgModeOptional,
                                                                 "")),
    _portDescriptor(new Utilities::PortArgumentDescriptor(kPortFieldName.toStdString(), "",
                                                          Utilities::kArgModeOptional, 0, false)),
    _appInfo(appInfo), _endpointToUse(endpointToUse), _portToUse(portToUse), _tagToUse(tagToUse),
    _argsToUse(argsToUse), _tagModifierCount(tagModifierCount), _canSetEndpoint(false),
    _canSetPort(false), _canSetTag(false), _canUseModifier(false), _hasExtraArguments(false),
    _hasFileField(false)
{
    ODL_ENTER(); //####
    ODL_S2s("title = ", title.toStdString(), "execType = ", execType.toStdString()); //####
    ODL_P4("appInfo = ", &appInfo, "endpointToUse = ", &endpointToUse, "tagToUse = ", //####
           &tagToUse, "portToUse = ", &portToUse); //####
    ODL_P1("argsToUse = ", &argsToUse); //####
    _contentArea.setSize(100, 100);
    setContentNonOwned(&_contentArea, true);
    BorderSize<int> bt = getBorderThickness();
    BorderSize<int> cb = getContentComponentBorder();
    int             heightSoFar = 0;
    int             widthSoFar = 0;

    _argsToUse.clear();
    _canSetEndpoint = appInfo._options.contains("e");
    _canSetPort = appInfo._options.contains("p");
    _canSetTag = appInfo._options.contains("t");
    _canUseModifier = appInfo._options.contains("m");
    setUpStandardFields(widthSoFar, heightSoFar);
    int minW = jmax(widthSoFar, _cancelButton.getWidth() + _okButton.getWidth() +
                    (3 * FormField::kButtonGap));
    int calcW = minW + bt.getLeftAndRight() + cb.getLeftAndRight();
    int calcH = heightSoFar + bt.getTopAndBottom() + cb.getTopAndBottom();

    centreWithSize(calcW + kExtraSpaceInWindow, calcH + kExtraSpaceInWindow);
    adjustFields();
    setOpaque(true);
    setResizable(false, false);
    setVisible(true);
    addKeyListener(CommonVisuals::GetApplicationCommandManager().getKeyMappings());
    triggerAsyncUpdate();
    ODL_EXIT_P(this); //####
} // SettingsWindow::SettingsWindow
void
GraphicsPanel::setShaderProgram(const String & vertexShader,
                                const String & fragmentShader)
{
    ODL_OBJENTER(); //####
    ODL_S2s("vertexShader = ", vertexShader.toStdString(), "fragmentShader = ", //####
            fragmentShader.toStdString()); //####
    _vertexShaderSource = vertexShader;
    _fragmentShaderSource = fragmentShader;
    ODL_OBJEXIT(); //####
} // GraphicsPanel::setShaderProgram
Example #3
0
void InstanceProcessor::setStateInformation (const void* data, int sizeInBytes)
{
    ScopedPointer<XmlElement> xml(getXmlFromBinary(data, sizeInBytes));
    if(xml != nullptr)
    {
        if(xml->hasTagName("CamomileSettings"))
        {
            String name = xml->getStringAttribute("name");
            String path = xml->getStringAttribute("path");
            if(File::isAbsolutePath(path))
            {
                File file(path + File::separatorString + name);
                if(!file.exists())
                {
                    file = File(m_path + File::separatorString + name);
                    if(!file.exists())
                    {
                        file = File(File::getCurrentWorkingDirectory().getFullPathName() + File::separatorString + name);
                        if(!file.exists())
                        {
                            file = File(File::getSpecialLocation(juce::File::SpecialLocationType::userDocumentsDirectory).getFullPathName() + File::separatorString + name);
                            if(!file.exists())
                            {
                                file = File(path + File::separatorString + name);
                            }
                        }
                    }
                }
                loadPatch(name.toStdString(), path.toStdString());
            }
            
            XmlElement* params = xml->getChildByName(juce::StringRef("params"));
            if(params)
            {
                for(int i = 0; i < params->getNumAttributes(); i++)
                {
                    int index = getParameterIndex(params->getAttributeName(i));
                    if(index >= 0)
                    {
                        setParameterNotifyingHost(index, params->getAttributeValue(i).getDoubleValue());
                    }
                }
            }
        }
    }
}
void YSE::INTERNAL::logImplementation::logMessage(const String & message) {
  if (level == EL_NONE) return;

  if (funcPtr != nullptr) {
    funcPtr(message.toStdString().c_str());
  } else {
    fileLogger->logMessage(message);
  }
}
    void logMessage (String const& message)
    {
        if (m_shouldLog)
        {
#if BEAST_MSVC
            if (beast_isRunningUnderDebugger ())
            {
                Logger::outputDebugString (message);
            }
            else
            {
                std::cout << message.toStdString () << std::endl;
            }

#else
            std::cout << message.toStdString () << std::endl;

#endif
        }
    }
static int runUnitTests (String const& match, String const& format)
{
    bool const shouldLog = format != "junit";

    if (format != "junit" && format != "text" && format != "")
    {
        String s;
        s << "Warning, unknown unittest-format='" << format << "'";
        Log::out () << s.toStdString ();
    }

    RippleUnitTests tr (shouldLog);

    tr.runSelectedTests (match);

    if (format == "junit")
    {
        UnitTestUtilities::JUnitXMLFormatter f (tr);

        String const s = f.createDocumentString ();

        std::cout << s.toStdString ();
    }
    else
    {
        UnitTests::Results const& r (tr.getResults ());

        String s;

        s << "Summary: " <<
            String (r.suites.size ()) << " suites, " <<
            String (r.cases) << " cases, " <<
            String (r.tests) << " tests, " <<
            String (r.failures) << " failure" << ((r.failures != 1) ? "s" : "") << ".";

        tr.logMessage (s);
    }

    return tr.anyTestsFailed () ? EXIT_FAILURE : EXIT_SUCCESS;
}
void
GraphicsPanel::updateShader(void)
{
    ODL_OBJENTER(); //####
    if (_vertexShaderSource.isNotEmpty() || _fragmentShaderSource.isNotEmpty())
    {
        ScopedPointer<OpenGLShaderProgram> aProg(new OpenGLShaderProgram(_context));
        
        if (aProg->addVertexShader(_vertexShaderSource) &&
            aProg->addFragmentShader(_fragmentShaderSource) && aProg->link())
        {
            _shaderProgram = aProg;
            ODL_P1("_shaderProgram <- ", _shaderProgram); //####
            _shaderProgram->use();
            // Remember the vertex attributes
            _positionAttribute = createAttribute(_context, *_shaderProgram, "position");
            _normalAttribute = createAttribute(_context, *_shaderProgram, "normal");
            _sourceColourAttribute = createAttribute(_context, *_shaderProgram, "sourceColour");
            _textureCoordInAttribute = createAttribute(_context, *_shaderProgram, "texureCoordIn");
            ODL_P4("_positionAttribute <- ", _positionAttribute, "_normalAttribute <- ", //####
                   _normalAttribute, "_sourceColourAttribute <- ", _sourceColourAttribute, //####
                   "_textureCoordInAttribute <- ", _textureCoordInAttribute); //####
  
            // Remember the uniform attributes
            _offsetUniform = createUniform(_context, *_shaderProgram, "offset");
            _projectionMatrixUniform = createUniform(_context, *_shaderProgram, "projectionMatrix");
            _viewMatrixUniform = createUniform(_context, *_shaderProgram, "viewMatrix");
            _textureUniform = createUniform(_context, *_shaderProgram, "theTexture");
            _lightPositionUniform = createUniform(_context, *_shaderProgram, "lightPostion");
            ODL_P4("_projectionMatrixUniform <- ", _projectionMatrixUniform, //####
                   "_viewMatrixUniform <- ", _viewMatrixUniform, "_textureUniform <- ", //####
                   _textureUniform, "_lightPositionUniform <- ", _lightPositionUniform); //####
        }
        else
        {
            String lastError = aProg->getLastError();
            
            ODL_LOG("! (aProg->addVertexShader(_vertexShaderSource) && " //####
                    "aProg->addFragmentShader(_fragmentShaderSource) && aProg->link())"); //####
            ODL_S1s("lastError = ", lastError.toStdString()); //####
        }
        _vertexShaderSource = String::empty;
        _fragmentShaderSource = String::empty;
    }
    ODL_OBJEXIT(); //####
} // GraphicsPanel::updateShader
void ArduinoOutput::setDevice (String devName)
{
    if (! acquisitionIsActive)
    {
        Time timer;

        arduino.connect (devName.toStdString());

        if (arduino.isArduinoReady())
        {
            uint32 currentTime = timer.getMillisecondCounter();

            arduino.sendProtocolVersionRequest();
            timer.waitForMillisecondCounter (currentTime + 2000);
            arduino.update();
            arduino.sendFirmwareVersionRequest();

            timer.waitForMillisecondCounter (currentTime + 4000);
            arduino.update();

            std::cout << "firmata v" << arduino.getMajorFirmwareVersion()
                      << "." << arduino.getMinorFirmwareVersion() << std::endl;
        }

        if (arduino.isInitialized())
        {
            std::cout << "Arduino is initialized." << std::endl;
            arduino.sendDigitalPinMode (outputChannel, ARD_OUTPUT);
            CoreServices::sendStatusMessage (("Arduino initialized at" + devName));
            deviceSelected = true;
        }
        else
        {
            std::cout << "Arduino is NOT initialized." << std::endl;
            CoreServices::sendStatusMessage (("Arduino could not be initialized at" + devName));
        }
    }
    else
    {
        CoreServices::sendStatusMessage ("Cannot change device while acquisition is active.");
    }
}
Example #9
0
 String String::arg(String str)
 {
     return String(static_cast<QString*>(this)->arg(str.toStdString().c_str()));
 }
int RippleMain::run (int argc, char const* const* argv)
{
    FatalErrorReporter reporter;

    //
    // These debug heap calls do nothing in release or non Visual Studio builds.
    //

    // Checks the heap at every allocation and deallocation (slow).
    //
    //Debug::setAlwaysCheckHeap (false);

    // Keeps freed memory blocks and fills them with a guard value.
    //
    //Debug::setHeapDelayedFree (false);

    // At exit, reports all memory blocks which have not been freed.
    //
#if 1
    Debug::setHeapReportLeaks (false);

#else
    // This is some temporary leak checking test code
    //
    Debug::setHeapReportLeaks (false);

    //malloc (512); // Any leaks before this line in the output are from static initializations.

    ThreadWithCallQueue t ("test");
    GlobalPagedFreeStore::getInstance ();
    t.start ();

    return 0;
#endif

    using namespace std;

    setCallingThreadName ("main");
    int iResult = 0;
    po::variables_map   vm;                                     // Map of options.

    String importDescription;
    {
        importDescription <<
            "Import an existing node database (specified in the " <<
            "[" << ConfigSection::importNodeDatabase () << "] configuration file section) "
            "into the current node database (specified in the " <<
            "[" << ConfigSection::nodeDatabase () << "] configuration file section). ";
    }

    // VFALCO TODO Replace boost program options with something from Beast.
    //
    // Set up option parsing.
    //
    po::options_description desc ("General Options");
    desc.add_options ()
    ("help,h", "Display this message.")
    ("conf", po::value<std::string> (), "Specify the configuration file.")
    ("rpc", "Perform rpc command (default).")
    ("rpc_ip", po::value <std::string> (), "Specify the IP address for RPC command. Format: <ip-address>[':'<port-number>]")
    ("rpc_port", po::value <int> (), "Specify the port number for RPC command.")
    ("standalone,a", "Run with no peers.")
    ("testnet,t", "Run in test net mode.")
    ("unittest,u", po::value <std::string> ()->implicit_value (""), "Perform unit tests.")
    ("unittest-format", po::value <std::string> ()->implicit_value ("text"), "Format unit test output. Choices are 'text', 'junit'")
    ("parameters", po::value< vector<string> > (), "Specify comma separated parameters.")
    ("quiet,q", "Reduce diagnotics.")
    ("verbose,v", "Verbose logging.")
    ("load", "Load the current ledger from the local DB.")
    ("replay","Replay a ledger close.")
    ("ledger", po::value<std::string> (), "Load the specified ledger and start from .")
    ("start", "Start from a fresh Ledger.")
    ("net", "Get the initial ledger from the network.")
    ("fg", "Run in the foreground.")
    ("import", importDescription.toStdString ().c_str ())
    ;

    // Interpret positional arguments as --parameters.
    po::positional_options_description p;
    p.add ("parameters", -1);

    // These must be added before the Application object is created
    NodeStore::addBackendFactory (KeyvaDBBackendFactory::getInstance ());
    NodeStore::addBackendFactory (LevelDBBackendFactory::getInstance ());
    NodeStore::addBackendFactory (MemoryBackendFactory::getInstance ());
    NodeStore::addBackendFactory (NullBackendFactory::getInstance ());
    NodeStore::addBackendFactory (SqliteBackendFactory::getInstance ());
#if RIPPLE_HYPERLEVELDB_AVAILABLE
    NodeStore::addBackendFactory (HyperLevelDBBackendFactory::getInstance ());
#endif
#if RIPPLE_MDB_AVAILABLE
    NodeStore::addBackendFactory (MdbBackendFactory::getInstance ());
#endif

    if (! RandomNumbers::getInstance ().initialize ())
    {
        Log::out() << "Unable to add system entropy";
        iResult = 2;
    }

    if (iResult)
    {
        nothing ();
    }
    else
    {
        // Parse options, if no error.
        try
        {
            po::store (po::command_line_parser (argc, argv)
                       .options (desc)                                         // Parse options.
                       .positional (p)                                         // Remainder as --parameters.
                       .run (),
                       vm);
            po::notify (vm);                                            // Invoke option notify functions.
        }
        catch (...)
        {
            iResult = 1;
        }
    }

    if (iResult)
    {
        nothing ();
    }
    else if (vm.count ("help"))
    {
        iResult = 1;
    }

    // Use a watchdog process unless we're invoking a stand alone type of mode
    //
    if (HaveSustain ()
        && !iResult
        && !vm.count ("parameters")
        && !vm.count ("fg")
        && !vm.count ("standalone")
        && !vm.count ("unittest"))
    {
        std::string logMe = DoSustain (getConfig ().DEBUG_LOGFILE.string());

        if (!logMe.empty ())
            Log (lsWARNING) << logMe;
    }

    if (vm.count ("quiet"))
    {
        Log::setMinSeverity (lsFATAL, true);
    }
    else if (vm.count ("verbose"))
    {
        Log::setMinSeverity (lsTRACE, true);
    }
    else
    {
        Log::setMinSeverity (lsINFO, true);
    }

    // Run the unit tests if requested.
    // The unit tests will exit the application with an appropriate return code.
    //
    if (vm.count ("unittest"))
    {
        String format;

        if (vm.count ("unittest-format"))
            format = vm ["unittest-format"].as <std::string> ();

        return runUnitTests (vm ["unittest"].as <std::string> (), format);
    }

    if (!iResult)
    {
        getConfig ().setup (
            vm.count ("conf") ? vm["conf"].as<std::string> () : "", // Config file.
            !!vm.count ("testnet"),                                 // Testnet flag.
            !!vm.count ("quiet"));                                  // Quiet flag.

        if (vm.count ("standalone"))
        {
            getConfig ().RUN_STANDALONE = true;
            getConfig ().LEDGER_HISTORY = 0;
        }
    }

    if (vm.count ("start")) getConfig ().START_UP = Config::FRESH;

    // Handle a one-time import option
    //
    if (vm.count ("import"))
    {
        String const optionString (vm ["import"].as <std::string> ());

        getConfig ().importNodeDatabase = parseDelimitedKeyValueString (optionString);
    }

    if (vm.count ("ledger"))
    {
        getConfig ().START_LEDGER = vm["ledger"].as<std::string> ();
        if (vm.count("replay"))
            getConfig ().START_UP = Config::REPLAY;
        else
            getConfig ().START_UP = Config::LOAD;
    }
    else if (vm.count ("load"))
    {
        getConfig ().START_UP = Config::LOAD;
    }
    else if (vm.count ("net"))
    {
        getConfig ().START_UP = Config::NETWORK;

        if (getConfig ().VALIDATION_QUORUM < 2)
            getConfig ().VALIDATION_QUORUM = 2;
    }

    if (iResult == 0)
    {
        // These overrides must happen after the config file is loaded.

        // Override the RPC destination IP address
        //
        if (vm.count ("rpc_ip"))
        {
            getConfig ().setRpcIpAndOptionalPort (vm ["rpc_ip"].as <std::string> ());
        }

        // Override the RPC destination port number
        //
        if (vm.count ("rpc_port"))
        {
            // VFALCO TODO This should be a short.
            getConfig ().setRpcPort (vm ["rpc_port"].as <int> ());
        }
    }

    if (iResult == 0)
    {
        if (!vm.count ("parameters"))
        {
            // No arguments. Run server.
            setupServer ();
            setCallingThreadName ("io");
            startServer ();
        }
        else
        {
            // Have a RPC command.
            setCallingThreadName ("rpc");
            std::vector<std::string> vCmd   = vm["parameters"].as<std::vector<std::string> > ();

            iResult = commandLineRPC (vCmd);
        }
    }

    if (1 == iResult && !vm.count ("quiet"))
        printHelp (desc);

    return iResult;
}