Ejemplo n.º 1
0
/*--------------------------------------------------------------------------*/
xme_status_t
xme_core_exec_getTaskState
(
    xme_core_component_t componentId,
    xme_core_component_functionId_t functionId,
    xme_core_exec_functionState_t* taskState
)
{
    xme_core_exec_taskDescriptor_t* task = NULL;
    xme_status_t status;

    XME_CHECK_MSG(XME_STATUS_SUCCESS == (status = xme_core_exec_descriptorTable_getTaskDescriptor(componentId,
                                                                                                  functionId,
                                                                                                  &task)),
              status,
              XME_LOG_WARNING,
              MODULE_ACRONYM "error getting task descriptor for [%d|%d]\n",
              componentId, functionId);

    XME_CHECK(NULL != task,
              XME_STATUS_INTERNAL_ERROR);

    /* todo  Is locking while reading such a thing necessary? */
    xme_hal_sync_enterCriticalSection(taskDescriptorsMutex);
    *taskState = task->state;
    xme_hal_sync_leaveCriticalSection(taskDescriptorsMutex);

    return XME_STATUS_SUCCESS;
}
Ejemplo n.º 2
0
/*--------------------------------------------------------------------------*/
xme_status_t
xme_core_exec_dispatcher_setRunnable
(
    xme_core_component_t componentId,
    xme_core_component_functionId_t functionId,
    xme_hal_sched_taskHandle_t handle
)
{
    xme_core_exec_taskDescriptor_t* taskRecord;
    xme_status_t status;

    /* We only deal with an initialized component */
    if (!xme_core_exec_isInitialized())
            return XME_STATUS_UNEXPECTED;

    XME_CHECK(XME_STATUS_SUCCESS == (status=xme_core_exec_descriptorTable_getTaskDescriptor(componentId,
                                                                                    functionId,
                                                                                    &taskRecord)),
        status);

    xme_hal_sync_enterCriticalSection(taskDescriptorsMutex);

    taskRecord->handle = handle;

    xme_hal_sync_leaveCriticalSection(taskDescriptorsMutex);
    return XME_STATUS_SUCCESS;
}
Ejemplo n.º 3
0
xme_status_t
xme_hal_graphviz_generateImage
(
    const char* dotFilePath,
    const char* pngFilePath
)
{
	FILE *fp;
	graph_t *graph;

	fopen_s(&fp, dotFilePath, "r");
	XME_CHECK(fp != NULL, XME_STATUS_INTERNAL_ERROR);

	xme_hal_sync_enterCriticalSection(xme_hal_graphviz_mutex);
	graph = agread_usergets(fp, fgets);
	gvLayout(xme_hal_graphviz_gvc, graph, "dot");
	gvRenderFilename(xme_hal_graphviz_gvc, graph, "png", pngFilePath);
	gvFreeLayout(xme_hal_graphviz_gvc, graph);
	agclose(graph);
	xme_hal_sync_leaveCriticalSection(xme_hal_graphviz_mutex);

	fclose(fp);

	return XME_STATUS_SUCCESS;
}
Ejemplo n.º 4
0
/*--------------------------------------------------------------------------*/
xme_status_t
xme_core_exec_descriptorTable_fini( void )
{
    xme_hal_sync_enterCriticalSection(taskDescriptorsMutex);
    XME_HAL_TABLE_FINI(taskDescriptorsTable);
    xme_hal_sync_leaveCriticalSection(taskDescriptorsMutex);

    if(XME_STATUS_SUCCESS != xme_hal_sync_destroyCriticalSection(taskDescriptorsMutex))
        XME_LOG(XME_LOG_ERROR, MODULE_ACRONYM "could not destroy task descriptor table mutex!\n");
    return XME_STATUS_SUCCESS;

}
Ejemplo n.º 5
0
/*--------------------------------------------------------------------------*/
xme_status_t
xme_core_exec_descriptorTable_getTaskDescriptor
(
    xme_core_component_t componentId,
    xme_core_component_functionId_t functionId,
    xme_core_exec_taskDescriptor_t** taskDesc
)
{
        xme_core_exec_taskDescriptor_t* schedRecord = NULL;
        bool found=false;

        /* We only deal with an initialized component */
        if (!xme_core_exec_isInitialized())
                return XME_STATUS_UNEXPECTED;

        XME_LOG(XME_LOG_DEBUG,
            MODULE_ACRONYM "getTaskDescriptor(): (%d:%d)\n", componentId, functionId);

        xme_hal_sync_enterCriticalSection(taskDescriptorsMutex);
        {
            XME_HAL_TABLE_ITERATE_BEGIN(taskDescriptorsTable, uint32_t, i, xme_core_exec_taskDescriptor_t, schedRecord1);
            {
                if((schedRecord1->wrapper->componentId == componentId) && (schedRecord1->wrapper->functionId == functionId))
                {
                    schedRecord=schedRecord1;
                    found=true;
                    break;
                }
            }
            XME_HAL_TABLE_ITERATE_END();
        }
        xme_hal_sync_leaveCriticalSection(taskDescriptorsMutex);

        XME_LOG(XME_LOG_DEBUG,
            MODULE_ACRONYM "/getTaskDescriptor(): (%d:%d)\n", componentId, functionId);

        if(found)
        {
            *taskDesc = schedRecord;
            return XME_STATUS_SUCCESS;
        }
        else
        {
            XME_LOG(XME_LOG_VERBOSE,
                MODULE_ACRONYM "[%d|%d] not found in task table!\n", componentId, functionId);
            *taskDesc = NULL;
            return XME_STATUS_NOT_FOUND;
        }
}
Ejemplo n.º 6
0
/*--------------------------------------------------------------------------*/
xme_status_t
xme_core_exec_descriptorTable_init( void )
{
    /* Initialize a critical section to control the access to the task list */
    taskDescriptorsMutex = xme_hal_sync_createCriticalSection();

    XME_CHECK( XME_HAL_SYNC_INVALID_CRITICAL_SECTION_HANDLE != taskDescriptorsMutex,
        XME_STATUS_INTERNAL_ERROR);

    xme_hal_sync_enterCriticalSection(taskDescriptorsMutex);

    XME_HAL_TABLE_INIT(taskDescriptorsTable);

    xme_hal_sync_leaveCriticalSection(taskDescriptorsMutex);
    return XME_STATUS_SUCCESS;
}
Ejemplo n.º 7
0
/*--------------------------------------------------------------------------*/
static xme_status_t
xme_core_exec_dispatcher_addNewTaskDescriptor
(
    xme_core_exec_taskDescriptor_t** record1
)
{
    xme_core_exec_taskDescriptor_t* rec1 = NULL;
    xme_hal_table_rowHandle_t handle;

    XME_LOG(XME_LOG_DEBUG,
        MODULE_ACRONYM "> dispatcher_createTaskRecord()\n");

    xme_hal_sync_enterCriticalSection(taskDescriptorsMutex);
    {
        handle = XME_HAL_TABLE_ADD_ITEM(taskDescriptorsTable);
        XME_CHECK_REC(XME_HAL_TABLE_INVALID_ROW_HANDLE != handle,
            XME_STATUS_INTERNAL_ERROR,
            {
                xme_hal_sync_leaveCriticalSection(taskDescriptorsMutex);
            });
Ejemplo n.º 8
0
void
xme_core_exec_unlockMutex
(
    const char* ID,
    xme_hal_sync_criticalSectionHandle_t handle,
    xme_core_component_t componentId,
    xme_core_component_functionId_t functionId
)
{
    xme_hal_sync_leaveCriticalSection(handle);
#ifdef LOCKLOGGING
    XME_LOG(XME_LOG_DEBUG,
        MODULE_ACRONYM "%3d %s [%d|%d] rel\n",
        handle,
        ID, componentId, functionId);
#else
    XME_UNUSED_PARAMETER(ID);
    XME_UNUSED_PARAMETER(componentId);
    XME_UNUSED_PARAMETER(functionId);
#endif
}
Ejemplo n.º 9
0
/*--------------------------------------------------------------------------*/
xme_status_t
xme_core_exec_setTaskState
(
    xme_core_component_t componentId,
    xme_core_component_functionId_t functionId,
    xme_core_exec_functionState_t newTaskState
)
{
    xme_core_exec_taskDescriptor_t* task = NULL;

    XME_CHECK_MSG(XME_STATUS_SUCCESS == xme_core_exec_descriptorTable_getTaskDescriptor(componentId, functionId, &task),
        XME_STATUS_INTERNAL_ERROR,
        XME_LOG_WARNING,
        MODULE_ACRONYM "error getting task descriptor for [%d|%d]\n",
        componentId, functionId);

    XME_CHECK(NULL != task,
              XME_STATUS_INTERNAL_ERROR);

    xme_hal_sync_enterCriticalSection(taskDescriptorsMutex);
    task->state = newTaskState;
    xme_hal_sync_leaveCriticalSection(taskDescriptorsMutex);
    return XME_STATUS_SUCCESS;
}
Ejemplo n.º 10
0
void
userInputTask(void* userData)
{
    char inputBuffer[100];
    char cmdBuffer[CMD_BUFFER_SIZE];
    command_t* command = (command_t*)xme_hal_mem_alloc(sizeof(command_t));

    XME_UNUSED_PARAMETER(userData);

    XME_LOG
    (
        XME_LOG_ALWAYS,
        "\nEnter command (to print help type \"help\" without quotes):\n>"
    );
    XME_CHECK
    (
        inputBuffer == fgets(inputBuffer, sizeof(inputBuffer), stdin),
        XME_CHECK_RVAL_VOID
    );

#ifdef _MSC_VER
    (void)sscanf_s(inputBuffer, "%" CMD_STRLEN_STRING "s", cmdBuffer, CMD_BUFFER_SIZE);
#else
    (void)sscanf(inputBuffer, "%" CMD_STRLEN_STRING "s", cmdBuffer);
#endif

    tolowerString(cmdBuffer, cmdBuffer, CMD_BUFFER_SIZE);

    // TODO:
    // - Allow nodeName instead of nodeID (add "subscriberNode" 4099)
    // - Allow componentTypeName instead of componentType (add 2 "subscriber")

    if (0 == strcmp(cmdBuffer, BUILD_STRING))
    {
        xme_core_node_nodeId_t nodeID;
        xme_core_componentType_t componentType;

#ifdef _MSC_VER
        (void)sscanf_s(inputBuffer, BUILD_STRING " %d %d", &nodeID, &componentType);
#else
        (void)sscanf(inputBuffer, BUILD_STRING " %d %d", (int*)&nodeID, (int*)&componentType);
#endif
        xme_core_nodeMgr_compRep_cancelBuild(builder);

        builder = xme_core_nodeMgr_compRep_createBuilder(nodeID, componentType);

        return;
    }
    else if (0 == strcmp(cmdBuffer, SET_QUEUE_SIZE_STRING))
    {
        uint32_t portTypeID;
        uint32_t queueSize;

#ifdef _MSC_VER
        (void)sscanf_s(inputBuffer, SET_QUEUE_SIZE_STRING " %" PRIu32 " %" PRIu32, &portTypeID, &queueSize);
#else
        (void)sscanf(inputBuffer, SET_QUEUE_SIZE_STRING " %" PRIu32 " %" PRIu32, &portTypeID, &queueSize);
#endif

        XME_CHECK_MSG(queueSize <= UCHAR_MAX, XME_CHECK_RVAL_VOID, XME_LOG_ERROR, "Maximum queue size is 255.\n");

        xme_core_nodeMgr_compRep_builderSetQueueSize(builder, portTypeID, (uint8_t)queueSize);

        return;
    }
    else if (0 == strcmp(cmdBuffer, SET_EXECUTION_PERIOD_STRING))
    {
        uint32_t functionTypeID;
        xme_hal_time_timeInterval_t execPeriod;

#ifdef _MSC_VER
        (void)sscanf_s(inputBuffer, SET_EXECUTION_PERIOD_STRING " %" PRIu32 " %" PRIu64, &functionTypeID, (uint64_t*)&execPeriod);
#else
        (void)sscanf(inputBuffer, SET_EXECUTION_PERIOD_STRING " %" PRIu32 " %" PRIu64, &functionTypeID, (uint64_t*)&execPeriod);
#endif
        xme_core_nodeMgr_compRep_builderSetExecutionPeriod(builder, functionTypeID, execPeriod);

        return;
    }
    else if (0 == strcmp(cmdBuffer, SET_INITIALIZATION_STRING_STRING))
    {
        char* initializationString;
        size_t len = xme_hal_safeString_strnlen(inputBuffer, sizeof(inputBuffer));
        if (inputBuffer[len-1] == '\n')
        {
            inputBuffer[len-1] = 0;
        }
        initializationString = &inputBuffer[strlen(SET_INITIALIZATION_STRING_STRING)+1];
        xme_core_nodeMgr_compRep_builderSetInitializationString(builder, initializationString);

        return;
    }
    else if (0 == strcmp(cmdBuffer, COMMIT_STRING))
    {
        xme_status_t status;
        xme_core_nodeMgr_compRep_componentHandle_t componentHandle;

        status = xme_core_nodeMgr_compRep_build(builder, &componentHandle);
        builder = NULL;
        XME_CHECK_MSG(XME_STATUS_SUCCESS == status, XME_CHECK_RVAL_VOID, XME_LOG_ERROR, "Command could not be executed.\n");

        command->commandType = ADD;
        command->commandData.addComponent.componentHandle = componentHandle;
    }
    else if (0 == strcmp(cmdBuffer, ADD_STRING))
    {
        xme_status_t status;
        xme_core_node_nodeId_t nodeID;
        xme_core_componentType_t componentType;
        xme_core_nodeMgr_compRep_componentBuilder_t* addBuilder = NULL;
        xme_core_nodeMgr_compRep_componentHandle_t componentHandle;

#ifdef _MSC_VER
        (void)sscanf_s(inputBuffer, ADD_STRING " %d %d", &nodeID, &componentType);
#else
        (void)sscanf(inputBuffer, ADD_STRING " %d %d", (int*)&nodeID, (int*)&componentType);
#endif

        addBuilder = xme_core_nodeMgr_compRep_createBuilder(nodeID, componentType);
        XME_CHECK(NULL != addBuilder, XME_CHECK_RVAL_VOID);
        status = xme_core_nodeMgr_compRep_build(addBuilder, &componentHandle);
        XME_CHECK_MSG(XME_STATUS_SUCCESS == status, XME_CHECK_RVAL_VOID, XME_LOG_ERROR, "Command could not be executed.\n");

        command->commandType = ADD;
        command->commandData.addComponent.componentHandle = componentHandle;
    }
    else if (0 == strcmp(cmdBuffer, REMOVE_STRING))
    {
        command->commandType = REMOVE;

#ifdef _MSC_VER
        (void)sscanf_s(inputBuffer, REMOVE_STRING " %d %d", (int*)&command->commandData.removeComponent.nodeID, &command->commandData.removeComponent.componentID);
#else
        (void)sscanf(inputBuffer, REMOVE_STRING " %d %d", (int*)&command->commandData.removeComponent.nodeID, &command->commandData.removeComponent.componentID);
#endif
    }
    else if (0 == strcmp(cmdBuffer, REMOVE2_STRING)) // equivalent alternative for REMOVE_STRING
    {
        command->commandType = REMOVE;
#ifdef _MSC_VER
        (void)sscanf_s(inputBuffer, REMOVE2_STRING " %d %d", (int*)&command->commandData.removeComponent.nodeID, &command->commandData.removeComponent.componentID);
#else
        (void)sscanf(inputBuffer, REMOVE2_STRING " %d %d", (int*)&command->commandData.removeComponent.nodeID, &command->commandData.removeComponent.componentID);
#endif
    }
    else if (0 == strcmp(cmdBuffer, LOGOUT_STRING))
    {
        command->commandType = LOGOUT;
#ifdef _MSC_VER
        (void)sscanf_s(inputBuffer, LOGOUT_STRING " %d", (int*)&command->commandData.logout.nodeID);
#else
        (void)sscanf(inputBuffer, LOGOUT_STRING " %d", (int*)&command->commandData.logout.nodeID);
#endif
    }
    else if (0 == strcmp(cmdBuffer, LIST_STRING))
    {
        // TODO: Upper case LIST will not work here. More robust parsing needed.
#ifdef _MSC_VER
        (void)sscanf_s(inputBuffer, LIST_STRING " %" CMD_STRLEN_STRING "s", cmdBuffer, CMD_BUFFER_SIZE);
#else
        (void)sscanf(inputBuffer, LIST_STRING " %" CMD_STRLEN_STRING "s", cmdBuffer);
#endif

        tolowerString(cmdBuffer, cmdBuffer, CMD_BUFFER_SIZE);

        if (0 == strcmp(cmdBuffer, LIST_TYPES_STRING))
        {
            xme_core_manifestRepository_iterator_t iter;
            xme_core_componentManifest_t* compManifest;

            iter = xme_core_manifestRepository_initIterator();

            XME_LOG(XME_LOG_ALWAYS, "\nContent of manifest repository of this node:\n");
            XME_LOG(XME_LOG_ALWAYS, "             component type name | component type ID\n");
            XME_LOG(XME_LOG_ALWAYS, "---------------------------------|------------------\n");

            while (xme_core_manifestRepository_hasNext(iter))
            {
                compManifest = xme_core_manifestRepository_next(&iter);
                
                XME_LOG(XME_LOG_NOTE, "%32s | %5d\n", compManifest->name, compManifest->componentType);
            }

            xme_core_manifestRepository_finiIterator(iter);

            return;
        }
        else if (0 == strcmp(cmdBuffer, LIST_NODES_STRING))
        {
            // Print list of all nodes in the system

            char nodeNameBuffer[20];

            xme_core_directory_nodeRegistryController_nodeIDIterator_t nodeIDIterator;
                
            XME_LOG(XME_LOG_ALWAYS, "\nThe following nodes are registered in the system:\n");
            XME_LOG(XME_LOG_ALWAYS, "           node name | node ID\n");
            XME_LOG(XME_LOG_ALWAYS, "---------------------|--------\n");
        
            xme_core_directory_nodeRegistryController_initNodeIDIterator(&nodeIDIterator);
            while (xme_core_directory_nodeRegistryController_hasNextNodeID(&nodeIDIterator))
            {
                xme_core_node_nodeId_t nodeID;

                nodeID = xme_core_directory_nodeRegistryController_nextNodeID(&nodeIDIterator);

                xme_core_directory_nodeRegistryController_getNodeName(nodeID, nodeNameBuffer, sizeof(nodeNameBuffer));

                XME_LOG(XME_LOG_NOTE, "%20s | %2d\n", nodeNameBuffer, nodeID);
            }
            xme_core_directory_nodeRegistryController_finiNodeIDIterator(&nodeIDIterator);

            return;
        }
        else if (0 == strcmp(cmdBuffer, LIST_COMPONENTS_STRING))
        {
            // Print list of all components in the system

            bool verbose = false;
            char nodeNameBuffer[20];
            char portBuffer[6];
            char functionBuffer[30];

#ifdef _MSC_VER
            (void)sscanf_s(inputBuffer, LIST_STRING " " LIST_COMPONENTS_STRING " %" CMD_STRLEN_STRING "s", cmdBuffer, CMD_BUFFER_SIZE);
#else
            (void)sscanf(inputBuffer, LIST_STRING " " LIST_COMPONENTS_STRING " %" CMD_STRLEN_STRING "s", cmdBuffer);
#endif
            if (0 == strcmp(cmdBuffer, LIST_COMPONENTS_VERBOSE_STRING))
            {
                verbose = true;
            }

            XME_LOG(XME_LOG_ALWAYS, "\nThe following components are registered in the system:\n");
            if (verbose)
            {
                XME_LOG(XME_LOG_ALWAYS, "                      | comp. |                           | port: | function:\n");
                XME_LOG(XME_LOG_ALWAYS, "       node name (ID) | ID    |      comp. type name (ID) | queue | exec.period\n");
                XME_LOG(XME_LOG_ALWAYS, "----------------------|-------|---------------------------|-------|------------\n");
            }
            else
            {
                XME_LOG(XME_LOG_ALWAYS, "                      | comp. |\n");
                XME_LOG(XME_LOG_ALWAYS, "       node name (ID) | ID    |      comp. type name (ID)\n");
                XME_LOG(XME_LOG_ALWAYS, "----------------------|-------|--------------------------\n");
            }

            xme_core_nodeMgr_compRep_componentIteratorInit();
            while (xme_core_nodeMgr_compRep_componentIteratorHasNext())
            {
                xme_core_node_nodeId_t nodeID;
                xme_core_component_t componentID;
                xme_core_componentType_t componentType;
                xme_core_componentManifest_t manifest;
                xme_core_nodeMgr_compRep_componentHandle_t componentHandle;
                xme_core_nodeMgr_compRep_portHandle_t portHandle;
                xme_core_nodeMgr_compRep_functionHandle_t functionHandle;
                uint16_t i = 0u;

                componentHandle = xme_core_nodeMgr_compRep_componentIteratorNext();
                nodeID = xme_core_nodeMgr_compRep_getNodeID(componentHandle);
                componentID = xme_core_nodeMgr_compRep_getComponentID(componentHandle);
                componentType = xme_core_nodeMgr_compRep_getComponentType(componentHandle);
                xme_core_manifestRepository_findComponentManifest(componentType, &manifest);
                xme_core_directory_nodeRegistryController_getNodeName(nodeID, nodeNameBuffer, sizeof(nodeNameBuffer));

                if (verbose)
                {
                    XME_LOG(XME_LOG_NOTE, "%16s (%2d) | %5d | %17s (%5d) |       |\n", nodeNameBuffer, nodeID, componentID, manifest.name, componentType);
                }
                else
                {
                    XME_LOG(XME_LOG_NOTE, "%16s (%2d) | %5d | %17s (%5d)\n", nodeNameBuffer, nodeID, componentID, manifest.name, componentType);
                }

                if (verbose)
                {
                    i = 0u;
                    do
                    {
                        uint16_t queueSize;
                        xme_hal_time_timeInterval_t execPeriod;
                    
                        portHandle = xme_core_nodeMgr_compRep_getPort(componentHandle, i);
                        if (XME_CORE_NODEMGR_COMPREP_INVALID_HANDLE != portHandle)
                        {
                            queueSize = xme_core_nodeMgr_compRep_getQueueSize(portHandle);
                            xme_hal_safeString_snprintf(portBuffer, sizeof(portBuffer), "%2d:%2" PRIu16, i, queueSize);
                        }
                        else
                        {
                            xme_hal_safeString_snprintf(portBuffer, sizeof(portBuffer), "       ");
                        }
                    
                        functionHandle = xme_core_nodeMgr_compRep_getFunction(componentHandle, i);
                        if (XME_CORE_NODEMGR_COMPREP_INVALID_HANDLE != functionHandle)
                        {
                            execPeriod = xme_core_nodeMgr_compRep_getExecutionPeriod(portHandle);

                            if (0ull == execPeriod || 1000000ull < execPeriod)
                            {
                                execPeriod = execPeriod / 1000000ull;
                                xme_hal_safeString_snprintf(functionBuffer, sizeof(functionBuffer), "%2d:%2" PRIu64 "ms", i, execPeriod);
                            }
                            else 
                            {
                                xme_hal_safeString_snprintf(functionBuffer, sizeof(functionBuffer), "%2d:%2" PRIu64 "ns", i, execPeriod);
                            }
                        }
                        else
                        {
                            xme_hal_safeString_snprintf(functionBuffer, sizeof(functionBuffer), "       ");
                        }

                        XME_LOG(XME_LOG_NOTE, "                      |       |                           | %s | %s\n", portBuffer, functionBuffer);

                        i++;

                    } while (XME_CORE_NODEMGR_COMPREP_INVALID_HANDLE != portHandle && XME_CORE_NODEMGR_COMPREP_INVALID_HANDLE != functionHandle);
                }
            }
            xme_core_nodeMgr_compRep_componentIteratorFini();

            return;
        }
        else
        {
            XME_LOG(XME_LOG_ERROR, "Unknown command. Enter help to print available commands.");
            return;
        }
    }
    else if (0 == strcmp(cmdBuffer, HELP_STRING))
    {
        XME_LOG
        (
            XME_LOG_ALWAYS,
            "Enter one of the following commands:\n"
            "COMMAND [PARAMS...]            DESCRIPTION\n"
            "add <nodeID> <componentType>   Adds a new component of the given component type\n"
            "                               to the given node.\n"
            "rem <nodeID> <componentID>     Removes the given component instance from the\n"
            "                               given node.\n"
            "logout <nodeID>                Trigger logout of the given node.\n"
            "list nodes                     Prints list of all nodes.\n"
            "list components                Prints list of all components.\n"
            "list components verbose        Prints list of all components with verbose\n"
            "                               information.\n"
            "list types                     Prints list of all component types.\n"
            "\n"
            "Advanced options for building a component:\n"
            "build <nodeID> <componentType> Like \"add\", but the component is not immediately\n"
            "                               added. Use the following functions to further\n"
            "                               refine the component definition.\n"
            "setqs <portTypeID> <queueSize> Set queue size of the given port to the given\n"
            "                               value.\n"
            "setep <functTypeID> <timeInNs> Set execution period of the given function to\n"
            "                               the given time value in nanoseconds.\n"
            "setis <initializationString>   Set the initialization string for the new\n"
            "commit                         component. Finally add the constructed component.\n"
        );
        return;
    }
    else
    {
        XME_LOG(XME_LOG_ERROR, "Unknown command. Enter help to print available commands.");
        return;
    }

    xme_hal_sync_enterCriticalSection(commandQueueMutex);

    xme_hal_singlyLinkedList_addItem(&commandQueue, command);

    xme_hal_sync_leaveCriticalSection(commandQueueMutex);
}
Ejemplo n.º 11
0
void
configuratorExtension_adv_pnpControlUI_pnpControlUIFunction_step
(
    configuratorExtension_adv_pnpControlUI_pnpControlUIComponent_config_t* const componentConfig
)
{
    
    {
        // PROTECTED REGION ID(CONFIGURATOREXTENSION_ADV_PNPCONTROLUI_PNPCONTROLUIFUNCTION_STEP_C) ENABLED START
        
        command_t* command = NULL;
        xme_status_t status;

        XME_UNUSED_PARAMETER(componentConfig);

        xme_hal_sync_enterCriticalSection(commandQueueMutex);
        {
            if (xme_hal_singlyLinkedList_getItemCount(&commandQueue) > 0)
            {
                command = (command_t*) xme_hal_singlyLinkedList_itemFromIndex(&commandQueue, (xme_hal_linkedList_index_t) 0);
                (void) xme_hal_singlyLinkedList_removeItem(&commandQueue, (void*) command, false);
            }
        }
        xme_hal_sync_leaveCriticalSection(commandQueueMutex);

        if (NULL != command)
        {
            switch (command->commandType)
            {
                case ADD:
                    {
                        status = xme_core_pnp_pnpManager_plugInNewComponent(command->commandData.addComponent.componentHandle);

                        if (XME_STATUS_SUCCESS != status) { XME_LOG(XME_LOG_ERROR, "Command could not be executed.\n"); }
                    }
                    break;
                case REMOVE:
                    {
                        status = xme_core_pnp_pnpManager_unannounceComponentOnNode
                        (
                            command->commandData.removeComponent.nodeID,
                            command->commandData.removeComponent.componentID
                        );

                        if (XME_STATUS_SUCCESS != status) { XME_LOG(XME_LOG_ERROR, "Command could not be executed.\n"); }
                    }
                    break;
                case LOGOUT:
                    {
                        status = xme_core_pnp_pnpManager_unannounceNode
                        (
                            command->commandData.logout.nodeID
                        );

                        if (XME_STATUS_SUCCESS != status) { XME_LOG(XME_LOG_ERROR, "Command could not be executed.\n"); }
                    }
                    break;
                default:
                    XME_LOG(XME_LOG_ERROR, "Error in command structure. Unknown command type: %d\n", command->commandType);
            }

            // Always free command
            xme_hal_mem_free(command);
        }
        
        // PROTECTED REGION END
    }
    
    {
        // PROTECTED REGION ID(CONFIGURATOREXTENSION_ADV_PNPCONTROLUI_PNPCONTROLUIFUNCTION_STEP_2_C) ENABLED START
        
        // Nothing to do here
        
        // PROTECTED REGION END
    }
}