Example #1
0
int main()
{

    //Inicializa a biblioteca gráfica com a estrutura a ser apresentada na tela
    init($VETOR,MAX,1);

    setDataType(float);

    int i = 0;

    setSleepTime(1);

    for(i = 0; i < MAX; i++)
    {
        vetor[i] = rand()%100;
    }

    setSleepTime(2);
    show(&vetor,0);



    setSleepTime(1);
    bubblesort();
    setSleepTime(10);
    show(&vetor,0);

    terminateDSGraph();

    return 0;
}
Example #2
0
// initialize the printer
void Printer::init() {
    reset();
    setStatus(true);
    setControlParameter();
    setPrintDensity();
    setSleepTime();
    setCodeTable();
    setCharacterSet();
    setBarcodePrintReadable();
}
// This is the viewer process (the parent process).
//
// This function is called for messages that have to
// be written to the plugin.
// Note that LLPLUGIN_MESSAGE_CLASS_INTERNAL messages
// are not sent to the plugin, but are handled here.
void LLPluginProcessParent::receiveMessage(const LLPluginMessage &message)
{
    std::string message_class = message.getClass();
    if(message_class == LLPLUGIN_MESSAGE_CLASS_INTERNAL)
    {
        // internal messages should be handled here
        std::string message_name = message.getName();
        if(message_name == "hello")
        {
            if(mState == STATE_CONNECTED)
            {
                // Plugin host has launched.  Tell it which plugin to load.
                setState(STATE_HELLO);
            }
            else
            {
                LL_WARNS("Plugin") << "received hello message in wrong state -- bailing out" << LL_ENDL;
                errorState();
            }

        }
        else if(message_name == "load_plugin_response")
        {
            if(mState == STATE_LOADING)
            {
                // Plugin has been loaded.

                mPluginVersionString = message.getValue("plugin_version");
                LL_INFOS("Plugin") << "plugin version string: " << mPluginVersionString << LL_ENDL;

                // Check which message classes/versions the plugin supports.
                // TODO: check against current versions
                // TODO: kill plugin on major mismatches?
                mMessageClassVersions = message.getValueLLSD("versions");
                LLSD::map_iterator iter;
                for(iter = mMessageClassVersions.beginMap(); iter != mMessageClassVersions.endMap(); iter++)
                {
                    LL_INFOS("Plugin") << "message class: " << iter->first << " -> version: " << iter->second.asString() << LL_ENDL;
                }

                // Send initial sleep time
                setSleepTime(mSleepTime, true);

                setState(STATE_RUNNING);
            }
            else
            {
                LL_WARNS("Plugin") << "received load_plugin_response message in wrong state -- bailing out" << LL_ENDL;
                errorState();
            }
        }
        else if(message_name == "heartbeat")
        {
            // this resets our timer.
            mHeartbeat.setTimerExpirySec(mPluginLockupTimeout);

            mCPUUsage = message.getValueReal("cpu_usage");

            LL_DEBUGS("PluginHeartbeat") << "cpu usage reported as " << mCPUUsage << LL_ENDL;
        }
        else if(message_name == "shutdown")
        {
            LL_INFOS("Plugin") << "received shutdown message" << LL_ENDL;
            mReceivedShutdown = true;
            mOwner->receivedShutdown();
        }
        else if(message_name == "shm_add_response")
        {
            // Nothing to do here.
        }
        else if(message_name == "shm_remove_response")
        {
            std::string name = message.getValue("name");
            sharedMemoryRegionsType::iterator iter = mSharedMemoryRegions.find(name);

            if(iter != mSharedMemoryRegions.end())
            {
                // destroy the shared memory region
                iter->second->destroy();

                // and remove it from our map
                mSharedMemoryRegions.erase(iter);
            }
        }
        else if(message_name == "log_message")
        {
            std::string msg=message.getValue("message");
            S32 level=message.getValueS32("log_level");

            switch(level)
            {
            case LLPluginMessage::LOG_LEVEL_DEBUG:
                LL_DEBUGS("Plugin child")<<msg<<LL_ENDL;
                break;
            case LLPluginMessage::LOG_LEVEL_INFO:
                LL_INFOS("Plugin child")<<msg<<LL_ENDL;
                break;
            case LLPluginMessage::LOG_LEVEL_WARN:
                LL_WARNS("Plugin child")<<msg<<LL_ENDL;
                break;
            case LLPluginMessage::LOG_LEVEL_ERR:
                LL_ERRS("Plugin child")<<msg<<LL_ENDL;
                break;
            default:
                break;
            }

        }
        else
        {
            LL_WARNS("Plugin") << "Unknown internal message from child: " << message_name << LL_ENDL;
        }
    }
    else
    {
        if(mOwner != NULL)
        {
            mOwner->receivePluginMessage(message);
        }
    }
}